@passlock/client 2.0.6 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/index.d.ts +101 -18
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +106 -17
  4. package/dist/index.js.map +1 -1
  5. package/dist/internal/network.d.ts +14 -1
  6. package/dist/internal/network.d.ts.map +1 -1
  7. package/dist/internal/network.js +11 -1
  8. package/dist/internal/network.js.map +1 -1
  9. package/dist/internal/promise.d.ts +7 -3
  10. package/dist/internal/promise.d.ts.map +1 -1
  11. package/dist/internal/promise.js +9 -5
  12. package/dist/internal/promise.js.map +1 -1
  13. package/dist/internal/result.d.ts +33 -0
  14. package/dist/internal/result.d.ts.map +1 -0
  15. package/dist/internal/result.js +35 -0
  16. package/dist/internal/result.js.map +1 -0
  17. package/dist/options.d.ts +5 -5
  18. package/dist/options.d.ts.map +1 -1
  19. package/dist/passkey/authentication/authentication.d.ts +13 -6
  20. package/dist/passkey/authentication/authentication.d.ts.map +1 -1
  21. package/dist/passkey/authentication/authentication.js +4 -1
  22. package/dist/passkey/authentication/authentication.js.map +1 -1
  23. package/dist/passkey/errors.d.ts +19 -13
  24. package/dist/passkey/errors.d.ts.map +1 -1
  25. package/dist/passkey/errors.js +16 -16
  26. package/dist/passkey/errors.js.map +1 -1
  27. package/dist/passkey/registration/registration.d.ts +9 -6
  28. package/dist/passkey/registration/registration.d.ts.map +1 -1
  29. package/dist/passkey/registration/registration.js +3 -3
  30. package/dist/passkey/registration/registration.js.map +1 -1
  31. package/dist/passkey/signals/signals.d.ts +188 -27
  32. package/dist/passkey/signals/signals.d.ts.map +1 -1
  33. package/dist/passkey/signals/signals.js +122 -24
  34. package/dist/passkey/signals/signals.js.map +1 -1
  35. package/dist/principal.d.ts +1 -1
  36. package/dist/safe.d.ts +165 -59
  37. package/dist/safe.d.ts.map +1 -1
  38. package/dist/safe.js +163 -54
  39. package/dist/safe.js.map +1 -1
  40. package/package.json +7 -7
package/dist/index.d.ts CHANGED
@@ -10,12 +10,12 @@
10
10
  * Testing for browser capabilities related to passkeys, type guards and other utilities.
11
11
  *
12
12
  * @showCategories
13
- * @module unsafe
13
+ * @module unsafe (default)
14
14
  */
15
15
  import { Logger } from "./logger.js";
16
16
  import type { AuthenticationOptions, AuthenticationSuccess } from "./passkey/authentication/authentication.js";
17
17
  import type { RegistrationOptions, RegistrationSuccess } from "./passkey/registration/registration.js";
18
- import type { DeleteCredentialOptions, DeletePasskeyOptions, DeleteSuccess, PrunePasskeyOptions, PruningSuccess, UpdateCredentialOptions, UpdatePasskeyOptions, UpdateSuccess } from "./passkey/signals/signals.js";
18
+ import type { DeleteCredentialOptions, DeletePasskeyOptions, DeleteSuccess, Credential, PrunePasskeyOptions, PruningSuccess, UpdateCredentialOptions, UpdatePasskeyOptions, UpdateSuccess } from "./passkey/signals/signals.js";
19
19
  import type { OrphanedPasskeyError } from "./safe.js";
20
20
  /**
21
21
  * Registers a passkey on the user's device, then saves the server-side component in your vault.
@@ -25,7 +25,7 @@ import type { OrphanedPasskeyError } from "./safe.js";
25
25
  *
26
26
  * @param options
27
27
  *
28
- * @returns A successful registration payload.
28
+ * @returns A promise resolving to a {@link RegistrationSuccess}.
29
29
  *
30
30
  * @see {@link isRegistrationSuccess}
31
31
  * @see {@link isPasskeyUnsupportedError}
@@ -68,7 +68,7 @@ logger?: typeof Logger.Service) => Promise<RegistrationSuccess>;
68
68
  *
69
69
  * @param options
70
70
  *
71
- * @returns A successful authentication payload.
71
+ * @returns A promise resolving to an {@link AuthenticationSuccess}.
72
72
  *
73
73
  * @see {@link isAuthenticationSuccess}
74
74
  * @see {@link isPasskeyUnsupportedError}
@@ -113,8 +113,12 @@ logger?: typeof Logger.Service) => Promise<AuthenticationSuccess>;
113
113
  * By calling this function and supplying a new username/display name, their local
114
114
  * password manager will align with their updated account identifier.
115
115
  *
116
- * @param options You will typically supply a target `passkeyId` via {@link UpdatePasskeyOptions}. {@link UpdateCredentialOptions} is for advanced use cases.
117
- * @returns Update status
116
+ * @param options You will typically supply a target `passkeyId` via
117
+ * {@link UpdatePasskeyOptions}. {@link UpdateCredentialOptions} is intended
118
+ * for credential-scoped updates, for example when replaying data returned by
119
+ * `@passlock/server`.
120
+ * @returns A promise resolving to an {@link UpdateSuccess} once the browser
121
+ * has been asked to refresh the local passkey details.
118
122
  * @see {@link isUpdateError}
119
123
  * @throws {@link UpdateError} if the passkey cannot be updated
120
124
  *
@@ -127,7 +131,7 @@ logger?: typeof Logger.Service) => Promise<AuthenticationSuccess>;
127
131
  *
128
132
  * try {
129
133
  * const result = await updatePasskey({ tenancyId, passkeyId, username, displayName });
130
- * console.log("passkey updated");
134
+ * console.log("passkey update signal sent");
131
135
  * } catch (error) {
132
136
  * console.log(error);
133
137
  * }
@@ -138,9 +142,84 @@ export declare const updatePasskey: (options: UpdatePasskeyOptions | UpdateCrede
138
142
  /** @hidden */
139
143
  logger?: typeof Logger.Service) => Promise<UpdateSuccess>;
140
144
  /**
141
- * Attempts to delete a passkey from a local device. There are two scenarios in which this function proves useful:
145
+ * Attempt to update the username or display name for multiple passkeys (client-side only).
142
146
  *
143
- * 1. **Deleting a passkey**. Use the `@passlock/node` package or make vanilla REST calls from your
147
+ * Useful if the user has changed their account identifier. For example, they register
148
+ * using jdoe@gmail.com but later change their account username to jdoe@yahoo.com.
149
+ * Even after you update their account details in your backend, their local password
150
+ * manager will continue to display jdoe@gmail.com.
151
+ *
152
+ * By calling this function and supplying a new username/display name, their local
153
+ * password manager will align with their updated account identifier.
154
+ *
155
+ * @param options The `credentials` array returned by
156
+ * `@passlock/server`'s `updatePasskeyUsernames`.
157
+ * @returns A promise resolving to an {@link UpdateSuccess} once the browser
158
+ * has been asked to refresh the local passkey details.
159
+ * @throws {@link UpdateError} if one or more local passkeys cannot be updated
160
+ *
161
+ * @example
162
+ * // server code
163
+ * import { updatePasskeyUsernames as updatePasskeyUsernamesOnServer } from "@passlock/server";
164
+ *
165
+ * // send the backendResult to your frontend
166
+ * const backendResult = await updatePasskeyUsernamesOnServer({
167
+ * tenancyId,
168
+ * userId,
169
+ * username,
170
+ * displayName,
171
+ * });
172
+ *
173
+ * // client code
174
+ * import { updatePasskeyUsernames } from "@passlock/client";
175
+ *
176
+ * const credentialsFromBackend = backendResult.credentials;
177
+ * const result = await updatePasskeyUsernames(credentialsFromBackend);
178
+ *
179
+ * @category Passkeys (core)
180
+ */
181
+ export declare const updatePasskeyUsernames: (options: ReadonlyArray<UpdateCredentialOptions>,
182
+ /** @hidden */
183
+ logger?: typeof Logger.Service) => Promise<UpdateSuccess>;
184
+ /**
185
+ * Attempt to signal removal of multiple passkeys from a local device.
186
+ *
187
+ * Use this after deleting the server-side passkeys. The `deleted` array returned
188
+ * by `@passlock/server` already has the right shape, so you can pass it straight
189
+ * into this function.
190
+ *
191
+ * @param options Credentials derived from deleted backend passkeys.
192
+ * @returns A promise resolving to a {@link DeleteSuccess} once the browser
193
+ * removal signals have been queued.
194
+ * @see {@link isDeleteError}
195
+ * @throws {@link DeleteError} if one or more local passkeys cannot be deleted
196
+ *
197
+ * @example
198
+ * // server code
199
+ * import { deleteUserPasskeys as deleteUserPasskeysOnServer } from "@passlock/server";
200
+ *
201
+ * const deletedPasskeys = await deleteUserPasskeysOnServer({
202
+ * tenancyId,
203
+ * userId,
204
+ * apiKey,
205
+ * });
206
+ *
207
+ * // client code
208
+ * import { deleteUserPasskeys } from "@passlock/client";
209
+ *
210
+ * const deletedCredentials = deletedPasskeys.deleted;
211
+ * const result = await deleteUserPasskeys(deletedCredentials);
212
+ *
213
+ * @category Passkeys (core)
214
+ */
215
+ export declare const deleteUserPasskeys: (options: ReadonlyArray<Credential>,
216
+ /** @hidden */
217
+ logger?: typeof Logger.Service) => Promise<DeleteSuccess>;
218
+ /**
219
+ * Attempts to signal removal of a passkey from a local device. There are two
220
+ * scenarios in which this function proves useful:
221
+ *
222
+ * 1. **Deleting a passkey**. Use the `@passlock/server` package or make vanilla REST calls from your
144
223
  * backend to delete the server-side component, then use this function to delete the client-side component.
145
224
  *
146
225
  * 2. **Missing passkey**. The user tried to present a passkey, but the server-side component could not be found.
@@ -149,8 +228,11 @@ logger?: typeof Logger.Service) => Promise<UpdateSuccess>;
149
228
  * See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) and
150
229
  * [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/) in the documentation.
151
230
  *
152
- * @param options You typically pass a {@link DeletePasskeyOptions}, the other types are for advanced edge-cases.
153
- * @returns A {@link DeleteSuccess} payload if the passkey is deleted.
231
+ * @param options You typically pass a {@link DeletePasskeyOptions}. Use
232
+ * {@link DeleteCredentialOptions} or {@link OrphanedPasskeyError} when you
233
+ * already have the credential metadata.
234
+ * @returns A {@link DeleteSuccess} payload once the browser removal signal has
235
+ * been queued.
154
236
  * @see {@link isDeleteError}
155
237
  * @throws {@link DeleteError} if the passkey cannot be deleted
156
238
  *
@@ -161,7 +243,7 @@ logger?: typeof Logger.Service) => Promise<UpdateSuccess>;
161
243
  *
162
244
  * try {
163
245
  * const result = await deletePasskey({ tenancyId, passkeyId });
164
- * console.log("passkey deleted");
246
+ * console.log("passkey removal signal sent");
165
247
  * } catch (error) {
166
248
  * console.log(error);
167
249
  * }
@@ -178,7 +260,8 @@ logger?: typeof Logger.Service) => Promise<DeleteSuccess>;
178
260
  * should still exist for a given account on this device.
179
261
  *
180
262
  * @param options Pass the passkeys you want to retain.
181
- * @returns A {@link PruningSuccess} payload if local passkeys were pruned.
263
+ * @returns A {@link PruningSuccess} payload once the browser has been told
264
+ * which credentials should remain accepted.
182
265
  * @see {@link isPruningError}
183
266
  *
184
267
  * @throws {@link PruningError}
@@ -190,7 +273,7 @@ logger?: typeof Logger.Service) => Promise<DeleteSuccess>;
190
273
  *
191
274
  * try {
192
275
  * const result = await prunePasskeys({ tenancyId, allowablePasskeyIds });
193
- * console.log("local passkeys pruned", result);
276
+ * console.log("accepted credentials signal sent", result);
194
277
  * } catch (error) {
195
278
  * if (isPruningError(error)) {
196
279
  * console.log(error.code);
@@ -205,7 +288,7 @@ export declare const prunePasskeys: (options: PrunePasskeyOptions,
205
288
  /** @hidden */
206
289
  logger?: typeof Logger.Service) => Promise<PruningSuccess>;
207
290
  /**
208
- * Does the local device support programmatic passkey deletion
291
+ * Does the local device support programmatic passkey deletion?
209
292
  *
210
293
  * @returns `true` if local passkey deletion is supported.
211
294
  *
@@ -213,7 +296,7 @@ logger?: typeof Logger.Service) => Promise<PruningSuccess>;
213
296
  */
214
297
  export declare const isPasskeyDeleteSupport: () => boolean;
215
298
  /**
216
- * Does the local device support programmatic passkey pruning
299
+ * Does the local device support programmatic passkey pruning?
217
300
  *
218
301
  * @returns `true` if local passkey pruning is supported.
219
302
  *
@@ -221,7 +304,7 @@ export declare const isPasskeyDeleteSupport: () => boolean;
221
304
  */
222
305
  export declare const isPasskeyPruningSupport: () => boolean;
223
306
  /**
224
- * Does the local device support programmatic passkey updates
307
+ * Does the local device support programmatic passkey updates?
225
308
  *
226
309
  * @returns `true` if local passkey updates are supported.
227
310
  *
@@ -238,7 +321,7 @@ export { DeleteError, DuplicatePasskeyError, isDeleteError, isDuplicatePasskeyEr
238
321
  export type { OnRegistrationEvent, RegistrationError, RegistrationEvent, RegistrationOptions, RegistrationSuccess, } from "./passkey/registration/registration.js";
239
322
  export { isRegistrationSuccess, RegistrationHelper, } from "./passkey/registration/registration.js";
240
323
  export type { UserVerification } from "./passkey/shared.js";
241
- export type { CredentialMapping, DeleteCredentialOptions, DeletePasskeyOptions, DeleteSuccess, PrunePasskeyOptions, PruningSuccess, UpdateCredentialOptions, UpdatePasskeyOptions, UpdateSuccess, } from "./passkey/signals/signals.js";
324
+ export type { Credential, DeleteCredentialOptions, DeletePasskeyOptions, DeleteSuccess, PrunePasskeyOptions, PruningSuccess, UpdateCredentialOptions, UpdatePasskeyOptions, UpdateSuccess, } from "./passkey/signals/signals.js";
242
325
  export { isDeleteSuccess, isPruningSuccess, isUpdateSuccess, } from "./passkey/signals/signals.js";
243
326
  export { isAutofillSupport, isPasskeySupport, } from "./passkey/support.js";
244
327
  export type { Principal } from "./principal.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAe,MAAM,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,4CAA4C,CAAA;AAKnD,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,wCAAwC,CAAA;AAK/C,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACd,MAAM,8BAA8B,CAAA;AASrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAIrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,mBAAmB;AAC5B,cAAc;AACd,SAAQ,OAAO,MAAM,CAAC,OAAqB,KAC1C,OAAO,CAAC,mBAAmB,CAM3B,CAAA;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,mBAAmB,GAC9B,SAAS,qBAAqB;AAC9B,cAAc;AACd,SAAQ,OAAO,MAAM,CAAC,OAAqB,KAC1C,OAAO,CAAC,qBAAqB,CAM7B,CAAA;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,oBAAoB,GAAG,uBAAuB;AACvD,cAAc;AACd,SAAQ,OAAO,MAAM,CAAC,OAAqB,KAC1C,OAAO,CAAC,aAAa,CAGvB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8B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jB,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
package/dist/index.js CHANGED
@@ -10,14 +10,14 @@
10
10
  * Testing for browser capabilities related to passkeys, type guards and other utilities.
11
11
  *
12
12
  * @showCategories
13
- * @module unsafe
13
+ * @module unsafe (default)
14
14
  */
15
15
  import { Micro, pipe } from "effect";
16
16
  import { runToPromiseUnsafe } from "./internal/index.js";
17
17
  import { eventLogger, Logger } from "./logger.js";
18
18
  import { AuthenticationHelper, authenticatePasskey as authenticatePasskeyM, } from "./passkey/authentication/authentication.js";
19
19
  import { RegistrationHelper, registerPasskey as registerPasskeyM, } from "./passkey/registration/registration.js";
20
- import { deletePasskey as deletePasskeyM, isPasskeyDeleteSupport as isPasskeyDeleteSupportM, isPasskeyPruningSupport as isPasskeyPruningSupportM, isPasskeyUpdateSupport as isPasskeyUpdateSupportM, prunePasskeys as prunePasskeysM, updatePasskey as updatePasskeyM, } from "./passkey/signals/signals.js";
20
+ import { deletePasskey as deletePasskeyM, deleteUserPasskeys as deleteUserPasskeysM, isPasskeyDeleteSupport as isPasskeyDeleteSupportM, isPasskeyPruningSupport as isPasskeyPruningSupportM, isPasskeyUpdateSupport as isPasskeyUpdateSupportM, prunePasskeys as prunePasskeysM, updatePasskey as updatePasskeyM, updatePasskeyUsernames as updatePasskeyUsernamesM, } from "./passkey/signals/signals.js";
21
21
  /* Registration */
22
22
  /**
23
23
  * Registers a passkey on the user's device, then saves the server-side component in your vault.
@@ -27,7 +27,7 @@ import { deletePasskey as deletePasskeyM, isPasskeyDeleteSupport as isPasskeyDel
27
27
  *
28
28
  * @param options
29
29
  *
30
- * @returns A successful registration payload.
30
+ * @returns A promise resolving to a {@link RegistrationSuccess}.
31
31
  *
32
32
  * @see {@link isRegistrationSuccess}
33
33
  * @see {@link isPasskeyUnsupportedError}
@@ -71,7 +71,7 @@ logger = eventLogger) => pipe(registerPasskeyM(options), Micro.provideService(Re
71
71
  *
72
72
  * @param options
73
73
  *
74
- * @returns A successful authentication payload.
74
+ * @returns A promise resolving to an {@link AuthenticationSuccess}.
75
75
  *
76
76
  * @see {@link isAuthenticationSuccess}
77
77
  * @see {@link isPasskeyUnsupportedError}
@@ -117,8 +117,12 @@ logger = eventLogger) => pipe(authenticatePasskeyM(options), Micro.provideServic
117
117
  * By calling this function and supplying a new username/display name, their local
118
118
  * password manager will align with their updated account identifier.
119
119
  *
120
- * @param options You will typically supply a target `passkeyId` via {@link UpdatePasskeyOptions}. {@link UpdateCredentialOptions} is for advanced use cases.
121
- * @returns Update status
120
+ * @param options You will typically supply a target `passkeyId` via
121
+ * {@link UpdatePasskeyOptions}. {@link UpdateCredentialOptions} is intended
122
+ * for credential-scoped updates, for example when replaying data returned by
123
+ * `@passlock/server`.
124
+ * @returns A promise resolving to an {@link UpdateSuccess} once the browser
125
+ * has been asked to refresh the local passkey details.
122
126
  * @see {@link isUpdateError}
123
127
  * @throws {@link UpdateError} if the passkey cannot be updated
124
128
  *
@@ -131,7 +135,7 @@ logger = eventLogger) => pipe(authenticatePasskeyM(options), Micro.provideServic
131
135
  *
132
136
  * try {
133
137
  * const result = await updatePasskey({ tenancyId, passkeyId, username, displayName });
134
- * console.log("passkey updated");
138
+ * console.log("passkey update signal sent");
135
139
  * } catch (error) {
136
140
  * console.log(error);
137
141
  * }
@@ -145,9 +149,90 @@ logger = eventLogger) => {
145
149
  return pipe(micro, Micro.provideService(Logger, logger), runToPromiseUnsafe);
146
150
  };
147
151
  /**
148
- * Attempts to delete a passkey from a local device. There are two scenarios in which this function proves useful:
152
+ * Attempt to update the username or display name for multiple passkeys (client-side only).
149
153
  *
150
- * 1. **Deleting a passkey**. Use the `@passlock/node` package or make vanilla REST calls from your
154
+ * Useful if the user has changed their account identifier. For example, they register
155
+ * using jdoe@gmail.com but later change their account username to jdoe@yahoo.com.
156
+ * Even after you update their account details in your backend, their local password
157
+ * manager will continue to display jdoe@gmail.com.
158
+ *
159
+ * By calling this function and supplying a new username/display name, their local
160
+ * password manager will align with their updated account identifier.
161
+ *
162
+ * @param options The `credentials` array returned by
163
+ * `@passlock/server`'s `updatePasskeyUsernames`.
164
+ * @returns A promise resolving to an {@link UpdateSuccess} once the browser
165
+ * has been asked to refresh the local passkey details.
166
+ * @throws {@link UpdateError} if one or more local passkeys cannot be updated
167
+ *
168
+ * @example
169
+ * // server code
170
+ * import { updatePasskeyUsernames as updatePasskeyUsernamesOnServer } from "@passlock/server";
171
+ *
172
+ * // send the backendResult to your frontend
173
+ * const backendResult = await updatePasskeyUsernamesOnServer({
174
+ * tenancyId,
175
+ * userId,
176
+ * username,
177
+ * displayName,
178
+ * });
179
+ *
180
+ * // client code
181
+ * import { updatePasskeyUsernames } from "@passlock/client";
182
+ *
183
+ * const credentialsFromBackend = backendResult.credentials;
184
+ * const result = await updatePasskeyUsernames(credentialsFromBackend);
185
+ *
186
+ * @category Passkeys (core)
187
+ */
188
+ export const updatePasskeyUsernames = (options,
189
+ /** @hidden */
190
+ logger = eventLogger) => {
191
+ const micro = updatePasskeyUsernamesM(options);
192
+ return pipe(micro, Micro.provideService(Logger, logger), runToPromiseUnsafe);
193
+ };
194
+ /**
195
+ * Attempt to signal removal of multiple passkeys from a local device.
196
+ *
197
+ * Use this after deleting the server-side passkeys. The `deleted` array returned
198
+ * by `@passlock/server` already has the right shape, so you can pass it straight
199
+ * into this function.
200
+ *
201
+ * @param options Credentials derived from deleted backend passkeys.
202
+ * @returns A promise resolving to a {@link DeleteSuccess} once the browser
203
+ * removal signals have been queued.
204
+ * @see {@link isDeleteError}
205
+ * @throws {@link DeleteError} if one or more local passkeys cannot be deleted
206
+ *
207
+ * @example
208
+ * // server code
209
+ * import { deleteUserPasskeys as deleteUserPasskeysOnServer } from "@passlock/server";
210
+ *
211
+ * const deletedPasskeys = await deleteUserPasskeysOnServer({
212
+ * tenancyId,
213
+ * userId,
214
+ * apiKey,
215
+ * });
216
+ *
217
+ * // client code
218
+ * import { deleteUserPasskeys } from "@passlock/client";
219
+ *
220
+ * const deletedCredentials = deletedPasskeys.deleted;
221
+ * const result = await deleteUserPasskeys(deletedCredentials);
222
+ *
223
+ * @category Passkeys (core)
224
+ */
225
+ export const deleteUserPasskeys = (options,
226
+ /** @hidden */
227
+ logger = eventLogger) => {
228
+ const micro = deleteUserPasskeysM(options);
229
+ return pipe(micro, Micro.provideService(Logger, logger), runToPromiseUnsafe);
230
+ };
231
+ /**
232
+ * Attempts to signal removal of a passkey from a local device. There are two
233
+ * scenarios in which this function proves useful:
234
+ *
235
+ * 1. **Deleting a passkey**. Use the `@passlock/server` package or make vanilla REST calls from your
151
236
  * backend to delete the server-side component, then use this function to delete the client-side component.
152
237
  *
153
238
  * 2. **Missing passkey**. The user tried to present a passkey, but the server-side component could not be found.
@@ -156,8 +241,11 @@ logger = eventLogger) => {
156
241
  * See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) and
157
242
  * [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/) in the documentation.
158
243
  *
159
- * @param options You typically pass a {@link DeletePasskeyOptions}, the other types are for advanced edge-cases.
160
- * @returns A {@link DeleteSuccess} payload if the passkey is deleted.
244
+ * @param options You typically pass a {@link DeletePasskeyOptions}. Use
245
+ * {@link DeleteCredentialOptions} or {@link OrphanedPasskeyError} when you
246
+ * already have the credential metadata.
247
+ * @returns A {@link DeleteSuccess} payload once the browser removal signal has
248
+ * been queued.
161
249
  * @see {@link isDeleteError}
162
250
  * @throws {@link DeleteError} if the passkey cannot be deleted
163
251
  *
@@ -168,7 +256,7 @@ logger = eventLogger) => {
168
256
  *
169
257
  * try {
170
258
  * const result = await deletePasskey({ tenancyId, passkeyId });
171
- * console.log("passkey deleted");
259
+ * console.log("passkey removal signal sent");
172
260
  * } catch (error) {
173
261
  * console.log(error);
174
262
  * }
@@ -188,7 +276,8 @@ logger = eventLogger) => {
188
276
  * should still exist for a given account on this device.
189
277
  *
190
278
  * @param options Pass the passkeys you want to retain.
191
- * @returns A {@link PruningSuccess} payload if local passkeys were pruned.
279
+ * @returns A {@link PruningSuccess} payload once the browser has been told
280
+ * which credentials should remain accepted.
192
281
  * @see {@link isPruningError}
193
282
  *
194
283
  * @throws {@link PruningError}
@@ -200,7 +289,7 @@ logger = eventLogger) => {
200
289
  *
201
290
  * try {
202
291
  * const result = await prunePasskeys({ tenancyId, allowablePasskeyIds });
203
- * console.log("local passkeys pruned", result);
292
+ * console.log("accepted credentials signal sent", result);
204
293
  * } catch (error) {
205
294
  * if (isPruningError(error)) {
206
295
  * console.log(error.code);
@@ -219,7 +308,7 @@ logger = eventLogger) => {
219
308
  };
220
309
  /* Support */
221
310
  /**
222
- * Does the local device support programmatic passkey deletion
311
+ * Does the local device support programmatic passkey deletion?
223
312
  *
224
313
  * @returns `true` if local passkey deletion is supported.
225
314
  *
@@ -227,7 +316,7 @@ logger = eventLogger) => {
227
316
  */
228
317
  export const isPasskeyDeleteSupport = () => pipe(isPasskeyDeleteSupportM, Micro.runSync);
229
318
  /**
230
- * Does the local device support programmatic passkey pruning
319
+ * Does the local device support programmatic passkey pruning?
231
320
  *
232
321
  * @returns `true` if local passkey pruning is supported.
233
322
  *
@@ -235,7 +324,7 @@ export const isPasskeyDeleteSupport = () => pipe(isPasskeyDeleteSupportM, Micro.
235
324
  */
236
325
  export const isPasskeyPruningSupport = () => pipe(isPasskeyPruningSupportM, Micro.runSync);
237
326
  /**
238
- * Does the local device support programmatic passkey updates
327
+ * Does the local device support programmatic passkey updates?
239
328
  *
240
329
  * @returns `true` if local passkey updates are supported.
241
330
  *
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,aA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,CAAC,EAAE,kBAAkB,CAAC,CAAA;AAC9E,CAAC,CAAA;AAED,aAAa;AAEb;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE,CACzC,IAAI,CAAC,uBAAuB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;AAE9C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE,CAC1C,IAAI,CAAC,wBAAwB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;AAE/C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE,CACzC,IAAI,CAAC,uBAAuB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;AAE9C,gBAAgB;AAEhB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,GACT,MAAM,aAAa,CAAA;AAUpB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,4CAA4C,CAAA;AAEnD,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,YAAY,EACZ,WAAW,GACZ,MAAM,qBAAqB,CAAA;AAQ5B,OAAO,EACL,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,wCAAwC,CAAA;AAa/C,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAA"}
@@ -1,5 +1,12 @@
1
1
  import { Context, Micro } from "effect";
2
+ /**
3
+ * Type guard for {@link NetworkError}.
4
+ */
2
5
  export declare const isNetworkError: (payload: unknown) => payload is NetworkError;
6
+ /**
7
+ * Error raised when a request to the Passlock API fails or returns an
8
+ * unexpected response payload.
9
+ */
3
10
  export declare class NetworkError extends Error {
4
11
  readonly _tag: "@error/Network";
5
12
  readonly message: string;
@@ -14,13 +21,19 @@ declare const Endpoint_base: Context.TagClass<Endpoint, "Endpoint", {
14
21
  readonly endpoint: string;
15
22
  }>;
16
23
  /**
17
- * Passlock API endpoint
24
+ * Effect service that provides the Passlock API base URL.
18
25
  */
19
26
  export declare class Endpoint extends Endpoint_base {
20
27
  }
28
+ /**
29
+ * Create an {@link Endpoint} service from an optional base URL override.
30
+ */
21
31
  export declare const makeEndpoint: ({ endpoint, }: {
22
32
  endpoint?: string;
23
33
  }) => Endpoint["Type"];
34
+ /**
35
+ * Options for {@link makeRequest}.
36
+ */
24
37
  export type RequestOptions<A extends object, E = never> = {
25
38
  url: URL;
26
39
  /** Request payload */
@@ -1 +1 @@
1
- {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/internal/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEvC,eAAO,MAAM,cAAc,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,YAI5D,CAAA;AAED,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAG,gBAAgB,CAAS;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;gBAER,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAM9D,MAAM,CAAC,cAAc,YAjBiB,OAAO,KAAG,OAAO,IAAI,YAAY,CAiBjC;CACvC;;uBAmBsB,MAAM;;AAL7B;;GAEG;AACH,qBAAa,QAAS,SAAQ,aAG3B;CAAG;AAEN,eAAO,MAAM,YAAY,GAAI,eAE1B;IACD,QAAQ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YArBiB,OAAO,KAAG,OAAO,IAAI,YAAY,CAqBjC;CACvC;;uBAmBsB,MAAM;;AAL7B;;GAEG;AACH,qBAAa,QAAS,SAAQ,aAG3B;CAAG;AAEN;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,eAE1B;IACD,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,KAAG,QAAQ,CAAC,MAAM,CAA8B,CAAA;AAwBjD;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,GAAG,KAAK,IAAI;IACxD,GAAG,EAAE,GAAG,CAAA;IAER,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAA;IAEf,0BAA0B;IAC1B,iBAAiB,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,GAAG,IAAI,CAAC,CAAA;IAE7C,gCAAgC;IAChC,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,GAAG,IAAI,CAAC,CAAA;IAE3D,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,GAAG,KAAK,EAAE,6DAMtD,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,YAAY,CA0ErD,CAAA"}
@@ -1,4 +1,7 @@
1
1
  import { Context, Micro } from "effect";
2
+ /**
3
+ * Type guard for {@link NetworkError}.
4
+ */
2
5
  export const isNetworkError = (payload) => {
3
6
  if (typeof payload !== "object")
4
7
  return false;
@@ -6,6 +9,10 @@ export const isNetworkError = (payload) => {
6
9
  return false;
7
10
  return payload instanceof NetworkError;
8
11
  };
12
+ /**
13
+ * Error raised when a request to the Passlock API fails or returns an
14
+ * unexpected response payload.
15
+ */
9
16
  export class NetworkError extends Error {
10
17
  _tag = "@error/Network";
11
18
  message;
@@ -28,10 +35,13 @@ export class NetworkError extends Error {
28
35
  */
29
36
  const DEFAULT_ENDPOINT = "https://api.passlock.dev";
30
37
  /**
31
- * Passlock API endpoint
38
+ * Effect service that provides the Passlock API base URL.
32
39
  */
33
40
  export class Endpoint extends Context.Tag("Endpoint")() {
34
41
  }
42
+ /**
43
+ * Create an {@link Endpoint} service from an optional base URL override.
44
+ */
35
45
  export const makeEndpoint = ({ endpoint = DEFAULT_ENDPOINT, }) => Endpoint.of({ endpoint });
36
46
  const isErrorResponse = (payload) => {
37
47
  if (typeof payload !== "object")
@@ -1 +1 @@
1
- {"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/internal/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEvC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAgB,EAA2B,EAAE;IAC1E,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC7C,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAClC,OAAO,OAAO,YAAY,YAAY,CAAA;AACxC,CAAC,CAAA;AAED,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC5B,IAAI,GAAG,gBAAyB,CAAA;IAChC,OAAO,CAAQ;IACf,GAAG,CAAQ;IAEpB,YAAY,EAAE,OAAO,EAAE,GAAG,EAAoC;QAC5D,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,MAAM,CAAC,cAAc,GAAG,cAAc,CAAA;;AAGxC;;;;;;;;GAQG;AAEH,MAAM,gBAAgB,GAAG,0BAA0B,CAAA;AAEnD;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAGlD;CAAG;AAEN,MAAM,CAAC,MAAM,Y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jB,CAAC,CACH,CAAA;IACH,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;QACnC,GAAG,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,EAAsB;QACnD,KAAK,EAAE,GAAG,EAAE,CAAC,UAAU;KACxB,CAAC,CAAA;IAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC;QAC5B,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;AAC/C,CAAC,CAAC,CAAA"}
@@ -1,11 +1,15 @@
1
1
  import { Micro } from "effect";
2
+ import { type Result } from "./result.js";
2
3
  /**
3
- * Run a Micro and return a success or failure.
4
+ * Run a Micro and return a result envelope containing either
5
+ * the successful value or the expected error value.
6
+ *
4
7
  * Note: function could still throw for an unexpected error.
8
+ *
5
9
  * @param micro
6
- * @returns Promise resolving to either the success value or error value.
10
+ * @returns Promise resolving to a result envelope.
7
11
  */
8
- export declare const runToPromise: <A, E>(micro: Micro.Micro<A, E>) => Promise<A | E>;
12
+ export declare const runToPromise: <A extends object, E extends object>(micro: Micro.Micro<A, E>) => Promise<Result<A, E>>;
9
13
  /**
10
14
  * Run a Micro and return a success or throw an error
11
15
  * @param micro
@@ -1 +1 @@
1
- {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../src/internal/promise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,EAAQ,MAAM,QAAQ,CAAA;AAGtD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAU,CAAC,EAAE,CAAC,EACrC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KACvB,OAAO,CAAC,CAAC,GAAG,CAAC,CAOf,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAU,CAAC,EAAE,CAAC,EAC3C,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KACvB,OAAO,CAAC,CAAC,CAqBX,CAAA"}
1
+ {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../src/internal/promise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAQ,MAAM,QAAQ,CAAA;AAE5C,OAAO,EAAE,KAAK,MAAM,EAA2B,MAAM,aAAa,CAAA;AAElE;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GAAU,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EACnE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KACvB,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAOtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAU,CAAC,EAAE,CAAC,EAC3C,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KACvB,OAAO,CAAC,CAAC,CAqBX,CAAA"}
@@ -1,16 +1,20 @@
1
- import { Either, identity, Micro, pipe } from "effect";
1
+ import { Either, Micro, pipe } from "effect";
2
2
  import { error } from "effect/Brand";
3
+ import { toErrResult, toOkResult } from "./result.js";
3
4
  /**
4
- * Run a Micro and return a success or failure.
5
+ * Run a Micro and return a result envelope containing either
6
+ * the successful value or the expected error value.
7
+ *
5
8
  * Note: function could still throw for an unexpected error.
9
+ *
6
10
  * @param micro
7
- * @returns Promise resolving to either the success value or error value.
11
+ * @returns Promise resolving to a result envelope.
8
12
  */
9
13
  export const runToPromise = async (micro) => {
10
14
  const either = await pipe(micro, Micro.either, Micro.runPromise);
11
15
  return Either.match(either, {
12
- onLeft: identity,
13
- onRight: identity,
16
+ onLeft: (failure) => toErrResult(failure),
17
+ onRight: (success) => toOkResult(success),
14
18
  });
15
19
  };
16
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"promise.js","sourceRoot":"","sources":["../../src/internal/promise.ts"],"names":[],"mappings":"AAAA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