@passlock/client 2.0.2 → 2.0.4

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 (39) hide show
  1. package/dist/index.d.ts +38 -39
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +34 -35
  4. package/dist/index.js.map +1 -1
  5. package/dist/internal/network.d.ts +1 -1
  6. package/dist/internal/network.d.ts.map +1 -1
  7. package/dist/internal/network.js +6 -4
  8. package/dist/internal/network.js.map +1 -1
  9. package/dist/logger.js +4 -4
  10. package/dist/logger.js.map +1 -1
  11. package/dist/passkey/authentication/authentication.d.ts +28 -17
  12. package/dist/passkey/authentication/authentication.d.ts.map +1 -1
  13. package/dist/passkey/authentication/authentication.js +7 -7
  14. package/dist/passkey/authentication/authentication.js.map +1 -1
  15. package/dist/passkey/errors.d.ts +9 -16
  16. package/dist/passkey/errors.d.ts.map +1 -1
  17. package/dist/passkey/errors.js +10 -17
  18. package/dist/passkey/errors.js.map +1 -1
  19. package/dist/passkey/registration/registration.d.ts +19 -15
  20. package/dist/passkey/registration/registration.d.ts.map +1 -1
  21. package/dist/passkey/registration/registration.js +7 -4
  22. package/dist/passkey/registration/registration.js.map +1 -1
  23. package/dist/passkey/shared.d.ts +2 -0
  24. package/dist/passkey/shared.d.ts.map +1 -1
  25. package/dist/passkey/signals/signals.d.ts +76 -19
  26. package/dist/passkey/signals/signals.d.ts.map +1 -1
  27. package/dist/passkey/signals/signals.js +67 -26
  28. package/dist/passkey/signals/signals.js.map +1 -1
  29. package/dist/principal.d.ts +3 -0
  30. package/dist/principal.d.ts.map +1 -1
  31. package/dist/safe.d.ts +75 -55
  32. package/dist/safe.d.ts.map +1 -1
  33. package/dist/safe.js +71 -50
  34. package/dist/safe.js.map +1 -1
  35. package/package.json +6 -9
  36. package/dist/errors.d.ts +0 -4
  37. package/dist/errors.d.ts.map +0 -1
  38. package/dist/errors.js +0 -14
  39. package/dist/errors.js.map +0 -1
package/dist/safe.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  /**
2
- * _safe_ functions i.e. functions that do not throw but instead return discriminated union
3
- * types composed of a successful result or an error. Use one of the type guards to narrow
4
- * the result to a given success or error type.
2
+ * _safe_ functions i.e. functions that return discriminated unions composed of either a
3
+ * success result or an error result for expected outcomes. Use one of the type guards to
4
+ * narrow the result to a given success or error type.
5
+ *
6
+ * Note: unexpected runtime failures may still throw.
5
7
  *
6
8
  * @categoryDescription Passkeys (core)
7
- * Creating, updating, authenticating and deleting passkeys. {@link registerPasskey}
8
- * and {@link authenticatePasskey} are the primary functions.
9
+ * Creating, authenticating, updating and deleting passkeys. {@link registerPasskey}
10
+ * and {@link authenticatePasskey} are the key functions.
9
11
  *
10
12
  * @categoryDescription Passkeys (other)
11
13
  * Testing for browser capabilities related to passkeys, type guards and other utilities.
@@ -17,23 +19,24 @@
17
19
  * @module safe
18
20
  */
19
21
  import { Logger } from "./logger";
20
- import type { PasslockOptions } from "./options";
21
22
  import type { AuthenticationError, AuthenticationOptions, AuthenticationSuccess } from "./passkey/authentication/authentication";
22
- import type { DeleteError, PasskeyNotFoundError, PruningError, UpdateError } from "./passkey/errors";
23
+ import type { DeleteError, OrphanedPasskeyError, PruningError, UpdateError } from "./passkey/errors";
23
24
  import type { RegistrationError, RegistrationOptions, RegistrationSuccess } from "./passkey/registration/registration";
24
- import type { CredentialMapping, UpdatePasskeyOptions } from "./passkey/signals/signals";
25
+ import type { DeleteCredentialOptions, DeletePasskeyOptions, DeleteSuccess, PrunePasskeyOptions, PruningSuccess, UpdateCredentialOptions, UpdatePasskeyOptions, UpdateSuccess } from "./passkey/signals/signals";
25
26
  /**
26
27
  * Registers a passkey on the user's device, then saves the server-side component in your vault.
27
- * If successful, this function returns a `code` or `id_token` (JWT). The code and/or jwt should
28
- * be sent to your backend for verification. See
28
+ * If successful, this function returns both a `code` and an `id_token` (JWT).
29
+ * Send either value to your backend for verification. See
29
30
  * [register a passkey](https://passlock.dev/passkeys/registration/) in the documentation.
30
31
  *
31
32
  * @param options
32
33
  *
33
- * @returns Use {@link isRegistrationSuccess} to test for a successful result, `RegistrationError` is
34
+ * @returns Use {@link isRegistrationSuccess} to test for a successful result, {@link RegistrationError} is
34
35
  * an alias to a union of potential errors. Use one of the appropriate isXXX type guards to narrow
35
36
  * the error.
36
37
  *
38
+ * Alternatively test the result's `_tag` property, which acts as a union discriminator.
39
+ *
37
40
  * @see {@link isRegistrationSuccess}
38
41
  * @see {@link isPasskeyUnsupportedError}
39
42
  * @see {@link isDuplicatePasskeyError}
@@ -50,9 +53,13 @@ import type { CredentialMapping, UpdatePasskeyOptions } from "./passkey/signals/
50
53
  * // send this to your backend for verification
51
54
  * console.log(result.code);
52
55
  * } else if (isPasskeyUnsupportedError(result)) {
53
- * console.error("Device does not support passkeys");
56
+ * // ^^ using an error type guard
57
+ * console.log("Device does not support passkeys");
58
+ * } else if (result._tag === "@error/OtherPasskey") {
59
+ * // ^^ narrowing the result using the _tag
60
+ * console.log(result.message);
54
61
  * } else {
55
- * console.error(result.message);
62
+ * ...
56
63
  * }
57
64
  *
58
65
  * @category Passkeys (core)
@@ -62,19 +69,21 @@ export declare const registerPasskey: (options: RegistrationOptions,
62
69
  logger?: typeof Logger.Service) => Promise<RegistrationSuccess | RegistrationError>;
63
70
  /**
64
71
  * Asks the client to present a passkey, which is then verified against the server-side component in your vault.
65
- * If successful, this function returns a `code` or `id_token` (JWT). The code and/or jwt should
66
- * be sent to your backend for verification. See
72
+ * If successful, this function returns both a `code` and an `id_token` (JWT).
73
+ * Send either value to your backend for verification. See
67
74
  * [authenticate a passkey](https://passlock.dev/passkeys/authentication/) in the documentation.
68
75
  *
69
76
  * @param options
70
77
  *
71
- * @returns Use {@link isAuthenticationSuccess} to test for a successful result, `AuthenticationError` is
78
+ * @returns Use {@link isAuthenticationSuccess} to test for a successful result, {@link AuthenticationError} is
72
79
  * an alias to a union of potential errors. Use one of the appropriate isXXX type guards to narrow
73
80
  * the error.
74
81
  *
82
+ * Alternatively test the result's `_tag` property, which acts as a union discriminator.
83
+ *
75
84
  * @see {@link isAuthenticationSuccess}
76
85
  * @see {@link isPasskeyUnsupportedError}
77
- * @see {@link isPasskeyNotFoundError}
86
+ * @see {@link isOrphanedPasskeyError}
78
87
  * @see {@link isOtherPasskeyError}
79
88
  *
80
89
  * @example
@@ -87,9 +96,11 @@ logger?: typeof Logger.Service) => Promise<RegistrationSuccess | RegistrationErr
87
96
  * // send this to your backend for verification
88
97
  * console.log(result.code);
89
98
  * } else if (isPasskeyUnsupportedError(result)) {
90
- * console.error("Device does not support passkeys");
91
- * } else {
92
- * console.error(result.message);
99
+ * // ^^ using an error type guard
100
+ * console.log("Device does not support passkeys");
101
+ * } else if (result._tag === "@error/OtherPasskey") {
102
+ * // ^^ narrowing the result using the _tag
103
+ * console.log(result.message);
93
104
  * }
94
105
  *
95
106
  * @category Passkeys (core)
@@ -108,8 +119,12 @@ logger?: typeof Logger.Service) => Promise<AuthenticationSuccess | Authenticatio
108
119
  * By calling this function and supplying a new username/display name, their local
109
120
  * password manager will align with their updated account identifier.
110
121
  *
111
- * @param options
112
- * @returns Update status
122
+ * @param options You will typically supply a target `passkeyId` via {@link UpdatePasskeyOptions}. {@link UpdateCredentialOptions} is for advanced use cases.
123
+ * @returns Use {@link isUpdateSuccess} and {@link isUpdateError} to test the update status.
124
+ *
125
+ * Alternatively, examine the result's `_tag` property, which acts as a discriminator.
126
+ *
127
+ * @see {@link isUpdateSuccess}
113
128
  * @see {@link isUpdateError}
114
129
  *
115
130
  * @example
@@ -121,36 +136,37 @@ logger?: typeof Logger.Service) => Promise<AuthenticationSuccess | Authenticatio
121
136
  *
122
137
  * const result = await updatePasskey({ tenancyId, passkeyId, username, displayName });
123
138
  *
124
- * if (result === true) {
139
+ * if (result._tag === "UpdateSuccess") {
140
+ * // ^^ narrowing the result using the _tag
125
141
  * console.log("passkey updated locally");
126
142
  * } else if (isUpdateError(result)) {
127
143
  * // narrowed to an UpdateError type
128
- * console.error(result.code);
144
+ * console.log(result.code);
129
145
  * } else {
130
- * console.error("unable to update passkey");
146
+ * console.log("unable to update passkey");
131
147
  * }
132
148
  *
133
149
  * @category Passkeys (core)
134
150
  */
135
- export declare const updatePasskey: (options: UpdatePasskeyOptions,
151
+ export declare const updatePasskey: (options: UpdatePasskeyOptions | UpdateCredentialOptions,
136
152
  /** @hidden */
137
- logger?: typeof Logger.Service) => Promise<boolean | UpdateError>;
153
+ logger?: typeof Logger.Service) => Promise<UpdateSuccess | UpdateError>;
138
154
  /**
139
- * Attempts to delete a passkey from a local device. There are two scenarios in which this function proves useful:
155
+ * Attempts to delete a passkey from a local device. There are two scenarios in which this function is useful:
140
156
  *
141
- * 1. **Deleting a passkey**. Use the `@passlock/node` package or make vanilla REST calls from your
157
+ * 1. **Deleting a passkey** - Use the `@passlock/node` package or make vanilla REST calls from your
142
158
  * backend to delete the server-side component, then use this function to delete the client-side component.
143
159
  *
144
- * 2. **Missing passkey**. The user tried to present a passkey, but the server-side component could not be found.
160
+ * 2. **Missing passkey** - When a user presented a passkey but the server-side component could not be found.
145
161
  * Remove the passkey from the local device to prevent it happening again.
146
162
  *
147
163
  * See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) and
148
164
  * [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/) in the documentation.
149
165
  *
150
- * @param identifiers Passkey identifier, credential mapping, or a {@link PasskeyNotFoundError}
151
- * payload from failed authentication.
152
- * @param options Passlock tenancy and endpoint options.
153
- * @returns Delete status
166
+ * @param options You will typically pass {@link DeletePasskeyOptions}, the other types are for advanced use cases/optimizations.
167
+ * @returns Use {@link isDeleteSuccess} to test for a successful deletion, or {@link isDeleteError} to test for an error.
168
+ * Alternatively, test the result's `_tag` property, which acts as a discriminator.
169
+ * @see {@link isDeleteSuccess}
154
170
  * @see {@link isDeleteError}
155
171
  *
156
172
  * @example
@@ -158,54 +174,58 @@ logger?: typeof Logger.Service) => Promise<boolean | UpdateError>;
158
174
  * const tenancyId = "myTenancyId";
159
175
  * const passkeyId = "myPasskeyId";
160
176
  *
161
- * const result = await deletePasskey(passkeyId, { tenancyId });
177
+ * const result = await deletePasskey({ tenancyId, passkeyId });
162
178
  *
163
- * if (result === true) {
179
+ * if (result._tag === "DeleteSuccess") {
180
+ * // ^^ narrowing the result using the _tag
164
181
  * console.log("passkey deleted locally");
165
182
  * } else if (isDeleteError(result)) {
166
183
  * // narrowed to a DeleteError type
167
- * console.error(result.code);
184
+ * console.log(result.code);
168
185
  * } else {
169
- * console.error("unable to delete passkey");
186
+ * console.log("unable to delete passkey");
170
187
  * }
171
188
  *
172
189
  * @category Passkeys (core)
173
190
  */
174
- export declare const deletePasskey: (identifiers: string | CredentialMapping | PasskeyNotFoundError, options: PasslockOptions,
191
+ export declare const deletePasskey: (options: DeletePasskeyOptions | DeleteCredentialOptions | OrphanedPasskeyError,
175
192
  /** @hidden */
176
- logger?: typeof Logger.Service) => Promise<boolean | DeleteError>;
193
+ logger?: typeof Logger.Service) => Promise<DeleteSuccess | DeleteError>;
177
194
  /**
178
195
  * Attempt to prune local passkeys by keeping only the passkey IDs you trust.
179
196
  *
180
197
  * This is useful when your backend is the source of truth for which passkeys
181
198
  * should still exist for a given account on this device.
182
199
  *
183
- * @param passkeyIds IDs to keep on-device.
184
- * @param options Passlock tenancy and endpoint options.
185
- * @returns Pruning status
200
+ * @param options Pass the passkeys you **want to retain**.
201
+ * @returns Use {@link isPruningSuccess} and {@link isPruningError} to narrow the result.
202
+ * Alternatively test the result's `_tag` property, which acts as a discriminator.
203
+ *
204
+ * @see {@link isPruningSuccess}
186
205
  * @see {@link isPruningError}
187
206
  *
188
207
  * @example
189
208
  * // from your Passlock console settings
190
209
  * const tenancyId = "myTenancyId";
191
- * const activePasskeyIds = ["passkey-1", "passkey-2"];
210
+ * const allowablePasskeyIds = ["passkey-1", "passkey-2"];
192
211
  *
193
- * const result = await prunePasskeys(activePasskeyIds, { tenancyId });
212
+ * const result = await prunePasskeys({ tenancyId, allowablePasskeyIds });
194
213
  *
195
- * if (result === true) {
214
+ * if (result._tag === "PruningSuccess") {
215
+ * // ^^ narrowing the result using the _tag
196
216
  * console.log("local passkeys pruned");
197
217
  * } else if (isPruningError(result)) {
198
218
  * // narrowed to a PruningError type
199
- * console.error(result.code);
219
+ * console.log(result.code);
200
220
  * } else {
201
- * console.error("unable to prune passkeys");
221
+ * console.log("unable to prune passkeys");
202
222
  * }
203
223
  *
204
224
  * @category Passkeys (core)
205
225
  */
206
- export declare const prunePasskeys: (passkeyIds: Array<string>, options: PasslockOptions,
226
+ export declare const prunePasskeys: (options: PrunePasskeyOptions,
207
227
  /** @hidden */
208
- logger?: typeof Logger.Service) => Promise<boolean | PruningError>;
228
+ logger?: typeof Logger.Service) => Promise<PruningSuccess | PruningError>;
209
229
  /**
210
230
  * Does the local device support programmatic passkey deletion
211
231
  *
@@ -230,18 +250,18 @@ export declare const isPasskeyPruningSupport: () => boolean;
230
250
  * @category Passkeys (other)
231
251
  */
232
252
  export declare const isPasskeyUpdateSupport: () => boolean;
233
- export type { NetworkError } from "./internal/network";
234
- export { isNetworkError } from "./internal/network";
253
+ export { isNetworkError, NetworkError } from "./internal/network";
235
254
  export { LogEvent, Logger, LogLevel, } from "./logger";
236
255
  export type { PasslockOptions } from "./options";
237
- export type { AuthenticationError, AuthenticationEvent, AuthenticationOptions, AuthenticationSuccess, OnAuthenticationEvent, } from "./passkey/authentication/authentication";
256
+ export type { AuthenticationError, AuthenticationEvent, AuthenticationEvents, AuthenticationOptions, AuthenticationSuccess, OnAuthenticationEvent, } from "./passkey/authentication/authentication";
238
257
  export { AuthenticationHelper, isAuthenticationSuccess, } from "./passkey/authentication/authentication";
239
258
  export type { ErrorCode } from "./passkey/errors";
240
- export { DeleteError, DuplicatePasskeyError, isDeleteError, isDuplicatePasskeyError, isOtherPasskeyError, isPasskeyNotFoundError, isPasskeyUnsupportedError, isPruningError, isUpdateError, OtherPasskeyError, PasskeyNotFoundError, PasskeyUnsupportedError, PruningError, UpdateError, } from "./passkey/errors";
259
+ export { DeleteError, DuplicatePasskeyError, isDeleteError, isDuplicatePasskeyError, isOrphanedPasskeyError, isOtherPasskeyError, isPasskeyUnsupportedError, isPruningError, isUpdateError, OrphanedPasskeyError, OtherPasskeyError, PasskeyUnsupportedError, PruningError, UpdateError, } from "./passkey/errors";
241
260
  export type { OnRegistrationEvent, RegistrationError, RegistrationEvent, RegistrationOptions, RegistrationSuccess, } from "./passkey/registration/registration";
242
261
  export { isRegistrationSuccess, RegistrationHelper, } from "./passkey/registration/registration";
243
262
  export type { UserVerification } from "./passkey/shared";
244
- export type { CredentialMapping, UpdatePasskeyOptions, } from "./passkey/signals/signals";
263
+ export type { CredentialMapping, DeleteCredentialOptions, DeletePasskeyOptions, DeleteSuccess, PrunePasskeyOptions, PruningSuccess, UpdateCredentialOptions, UpdatePasskeyOptions, UpdateSuccess, } from "./passkey/signals/signals";
264
+ export { isDeleteSuccess, isPruningSuccess, isUpdateSuccess, } from "./passkey/signals/signals";
245
265
  export { isAutofillSupport, isPasskeySupport, } from "./passkey/support";
246
266
  export type { Principal } from "./principal";
247
267
  //# sourceMappingURL=safe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../src/safe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,EAAe,MAAM,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,yCAAyC,CAAA;AAKhD,OAAO,KAAK,EACV,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,WAAW,EACZ,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,qCAAqC,CAAA;AAM5C,OAAO,KAAK,EACV,iBAAiB,EACj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B,GACnB,MAAM,qCAAqC,CAAA;AAC5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,YAAY,EACV,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,GACd,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
package/dist/safe.js CHANGED
@@ -1,11 +1,13 @@
1
1
  /**
2
- * _safe_ functions i.e. functions that do not throw but instead return discriminated union
3
- * types composed of a successful result or an error. Use one of the type guards to narrow
4
- * the result to a given success or error type.
2
+ * _safe_ functions i.e. functions that return discriminated unions composed of either a
3
+ * success result or an error result for expected outcomes. Use one of the type guards to
4
+ * narrow the result to a given success or error type.
5
+ *
6
+ * Note: unexpected runtime failures may still throw.
5
7
  *
6
8
  * @categoryDescription Passkeys (core)
7
- * Creating, updating, authenticating and deleting passkeys. {@link registerPasskey}
8
- * and {@link authenticatePasskey} are the primary functions.
9
+ * Creating, authenticating, updating and deleting passkeys. {@link registerPasskey}
10
+ * and {@link authenticatePasskey} are the key functions.
9
11
  *
10
12
  * @categoryDescription Passkeys (other)
11
13
  * Testing for browser capabilities related to passkeys, type guards and other utilities.
@@ -21,20 +23,22 @@ import { runToPromise } from "./internal";
21
23
  import { eventLogger, Logger } from "./logger";
22
24
  import { AuthenticationHelper, authenticatePasskey as authenticatePasskeyM, } from "./passkey/authentication/authentication";
23
25
  import { RegistrationHelper, registerPasskey as registerPasskeyM, } from "./passkey/registration/registration";
24
- import { deletePasskey as deletePasskeyM, isPasskeyDeleteSupport as isPasskeyDeleteSupportM, isPasskeyPruningSupport as isPasskeyPruningSupportM, isPasskeyUpdateSupport as isPasskeyUpdateSupportM, prunePasskeys as prunePasskeysM, signalCredentialRemoval, updatePasskey as updatePasskeyM, } from "./passkey/signals/signals";
26
+ import { deletePasskey as deletePasskeyM, isDeleteSuccess, isPasskeyDeleteSupport as isPasskeyDeleteSupportM, isPasskeyPruningSupport as isPasskeyPruningSupportM, isPasskeyUpdateSupport as isPasskeyUpdateSupportM, isPruningSuccess, isUpdateSuccess, prunePasskeys as prunePasskeysM, updatePasskey as updatePasskeyM, } from "./passkey/signals/signals";
25
27
  /* Registration */
26
28
  /**
27
29
  * Registers a passkey on the user's device, then saves the server-side component in your vault.
28
- * If successful, this function returns a `code` or `id_token` (JWT). The code and/or jwt should
29
- * be sent to your backend for verification. See
30
+ * If successful, this function returns both a `code` and an `id_token` (JWT).
31
+ * Send either value to your backend for verification. See
30
32
  * [register a passkey](https://passlock.dev/passkeys/registration/) in the documentation.
31
33
  *
32
34
  * @param options
33
35
  *
34
- * @returns Use {@link isRegistrationSuccess} to test for a successful result, `RegistrationError` is
36
+ * @returns Use {@link isRegistrationSuccess} to test for a successful result, {@link RegistrationError} is
35
37
  * an alias to a union of potential errors. Use one of the appropriate isXXX type guards to narrow
36
38
  * the error.
37
39
  *
40
+ * Alternatively test the result's `_tag` property, which acts as a union discriminator.
41
+ *
38
42
  * @see {@link isRegistrationSuccess}
39
43
  * @see {@link isPasskeyUnsupportedError}
40
44
  * @see {@link isDuplicatePasskeyError}
@@ -51,9 +55,13 @@ import { deletePasskey as deletePasskeyM, isPasskeyDeleteSupport as isPasskeyDel
51
55
  * // send this to your backend for verification
52
56
  * console.log(result.code);
53
57
  * } else if (isPasskeyUnsupportedError(result)) {
54
- * console.error("Device does not support passkeys");
58
+ * // ^^ using an error type guard
59
+ * console.log("Device does not support passkeys");
60
+ * } else if (result._tag === "@error/OtherPasskey") {
61
+ * // ^^ narrowing the result using the _tag
62
+ * console.log(result.message);
55
63
  * } else {
56
- * console.error(result.message);
64
+ * ...
57
65
  * }
58
66
  *
59
67
  * @category Passkeys (core)
@@ -64,19 +72,21 @@ logger = eventLogger) => pipe(registerPasskeyM(options), Micro.provideService(Re
64
72
  /* Authentication */
65
73
  /**
66
74
  * Asks the client to present a passkey, which is then verified against the server-side component in your vault.
67
- * If successful, this function returns a `code` or `id_token` (JWT). The code and/or jwt should
68
- * be sent to your backend for verification. See
75
+ * If successful, this function returns both a `code` and an `id_token` (JWT).
76
+ * Send either value to your backend for verification. See
69
77
  * [authenticate a passkey](https://passlock.dev/passkeys/authentication/) in the documentation.
70
78
  *
71
79
  * @param options
72
80
  *
73
- * @returns Use {@link isAuthenticationSuccess} to test for a successful result, `AuthenticationError` is
81
+ * @returns Use {@link isAuthenticationSuccess} to test for a successful result, {@link AuthenticationError} is
74
82
  * an alias to a union of potential errors. Use one of the appropriate isXXX type guards to narrow
75
83
  * the error.
76
84
  *
85
+ * Alternatively test the result's `_tag` property, which acts as a union discriminator.
86
+ *
77
87
  * @see {@link isAuthenticationSuccess}
78
88
  * @see {@link isPasskeyUnsupportedError}
79
- * @see {@link isPasskeyNotFoundError}
89
+ * @see {@link isOrphanedPasskeyError}
80
90
  * @see {@link isOtherPasskeyError}
81
91
  *
82
92
  * @example
@@ -89,9 +99,11 @@ logger = eventLogger) => pipe(registerPasskeyM(options), Micro.provideService(Re
89
99
  * // send this to your backend for verification
90
100
  * console.log(result.code);
91
101
  * } else if (isPasskeyUnsupportedError(result)) {
92
- * console.error("Device does not support passkeys");
93
- * } else {
94
- * console.error(result.message);
102
+ * // ^^ using an error type guard
103
+ * console.log("Device does not support passkeys");
104
+ * } else if (result._tag === "@error/OtherPasskey") {
105
+ * // ^^ narrowing the result using the _tag
106
+ * console.log(result.message);
95
107
  * }
96
108
  *
97
109
  * @category Passkeys (core)
@@ -111,8 +123,12 @@ logger = eventLogger) => pipe(authenticatePasskeyM(options), Micro.provideServic
111
123
  * By calling this function and supplying a new username/display name, their local
112
124
  * password manager will align with their updated account identifier.
113
125
  *
114
- * @param options
115
- * @returns Update status
126
+ * @param options You will typically supply a target `passkeyId` via {@link UpdatePasskeyOptions}. {@link UpdateCredentialOptions} is for advanced use cases.
127
+ * @returns Use {@link isUpdateSuccess} and {@link isUpdateError} to test the update status.
128
+ *
129
+ * Alternatively, examine the result's `_tag` property, which acts as a discriminator.
130
+ *
131
+ * @see {@link isUpdateSuccess}
116
132
  * @see {@link isUpdateError}
117
133
  *
118
134
  * @example
@@ -124,13 +140,14 @@ logger = eventLogger) => pipe(authenticatePasskeyM(options), Micro.provideServic
124
140
  *
125
141
  * const result = await updatePasskey({ tenancyId, passkeyId, username, displayName });
126
142
  *
127
- * if (result === true) {
143
+ * if (result._tag === "UpdateSuccess") {
144
+ * // ^^ narrowing the result using the _tag
128
145
  * console.log("passkey updated locally");
129
146
  * } else if (isUpdateError(result)) {
130
147
  * // narrowed to an UpdateError type
131
- * console.error(result.code);
148
+ * console.log(result.code);
132
149
  * } else {
133
- * console.error("unable to update passkey");
150
+ * console.log("unable to update passkey");
134
151
  * }
135
152
  *
136
153
  * @category Passkeys (core)
@@ -142,21 +159,21 @@ logger = eventLogger) => {
142
159
  return pipe(micro, Micro.provideService(Logger, logger), runToPromise);
143
160
  };
144
161
  /**
145
- * Attempts to delete a passkey from a local device. There are two scenarios in which this function proves useful:
162
+ * Attempts to delete a passkey from a local device. There are two scenarios in which this function is useful:
146
163
  *
147
- * 1. **Deleting a passkey**. Use the `@passlock/node` package or make vanilla REST calls from your
164
+ * 1. **Deleting a passkey** - Use the `@passlock/node` package or make vanilla REST calls from your
148
165
  * backend to delete the server-side component, then use this function to delete the client-side component.
149
166
  *
150
- * 2. **Missing passkey**. The user tried to present a passkey, but the server-side component could not be found.
167
+ * 2. **Missing passkey** - When a user presented a passkey but the server-side component could not be found.
151
168
  * Remove the passkey from the local device to prevent it happening again.
152
169
  *
153
170
  * See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) and
154
171
  * [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/) in the documentation.
155
172
  *
156
- * @param identifiers Passkey identifier, credential mapping, or a {@link PasskeyNotFoundError}
157
- * payload from failed authentication.
158
- * @param options Passlock tenancy and endpoint options.
159
- * @returns Delete status
173
+ * @param options You will typically pass {@link DeletePasskeyOptions}, the other types are for advanced use cases/optimizations.
174
+ * @returns Use {@link isDeleteSuccess} to test for a successful deletion, or {@link isDeleteError} to test for an error.
175
+ * Alternatively, test the result's `_tag` property, which acts as a discriminator.
176
+ * @see {@link isDeleteSuccess}
160
177
  * @see {@link isDeleteError}
161
178
  *
162
179
  * @example
@@ -164,25 +181,24 @@ logger = eventLogger) => {
164
181
  * const tenancyId = "myTenancyId";
165
182
  * const passkeyId = "myPasskeyId";
166
183
  *
167
- * const result = await deletePasskey(passkeyId, { tenancyId });
184
+ * const result = await deletePasskey({ tenancyId, passkeyId });
168
185
  *
169
- * if (result === true) {
186
+ * if (result._tag === "DeleteSuccess") {
187
+ * // ^^ narrowing the result using the _tag
170
188
  * console.log("passkey deleted locally");
171
189
  * } else if (isDeleteError(result)) {
172
190
  * // narrowed to a DeleteError type
173
- * console.error(result.code);
191
+ * console.log(result.code);
174
192
  * } else {
175
- * console.error("unable to delete passkey");
193
+ * console.log("unable to delete passkey");
176
194
  * }
177
195
  *
178
196
  * @category Passkeys (core)
179
197
  */
180
- export const deletePasskey = (identifiers, options,
198
+ export const deletePasskey = (options,
181
199
  /** @hidden */
182
200
  logger = eventLogger) => {
183
- const micro = typeof identifiers === "string"
184
- ? deletePasskeyM(identifiers, options)
185
- : signalCredentialRemoval(identifiers);
201
+ const micro = deletePasskeyM(options);
186
202
  return pipe(micro, Micro.provideService(Logger, logger), runToPromise);
187
203
  };
188
204
  /**
@@ -191,33 +207,36 @@ logger = eventLogger) => {
191
207
  * This is useful when your backend is the source of truth for which passkeys
192
208
  * should still exist for a given account on this device.
193
209
  *
194
- * @param passkeyIds IDs to keep on-device.
195
- * @param options Passlock tenancy and endpoint options.
196
- * @returns Pruning status
210
+ * @param options Pass the passkeys you **want to retain**.
211
+ * @returns Use {@link isPruningSuccess} and {@link isPruningError} to narrow the result.
212
+ * Alternatively test the result's `_tag` property, which acts as a discriminator.
213
+ *
214
+ * @see {@link isPruningSuccess}
197
215
  * @see {@link isPruningError}
198
216
  *
199
217
  * @example
200
218
  * // from your Passlock console settings
201
219
  * const tenancyId = "myTenancyId";
202
- * const activePasskeyIds = ["passkey-1", "passkey-2"];
220
+ * const allowablePasskeyIds = ["passkey-1", "passkey-2"];
203
221
  *
204
- * const result = await prunePasskeys(activePasskeyIds, { tenancyId });
222
+ * const result = await prunePasskeys({ tenancyId, allowablePasskeyIds });
205
223
  *
206
- * if (result === true) {
224
+ * if (result._tag === "PruningSuccess") {
225
+ * // ^^ narrowing the result using the _tag
207
226
  * console.log("local passkeys pruned");
208
227
  * } else if (isPruningError(result)) {
209
228
  * // narrowed to a PruningError type
210
- * console.error(result.code);
229
+ * console.log(result.code);
211
230
  * } else {
212
- * console.error("unable to prune passkeys");
231
+ * console.log("unable to prune passkeys");
213
232
  * }
214
233
  *
215
234
  * @category Passkeys (core)
216
235
  */
217
- export const prunePasskeys = (passkeyIds, options,
236
+ export const prunePasskeys = (options,
218
237
  /** @hidden */
219
238
  logger = eventLogger) => {
220
- const micro = prunePasskeysM(passkeyIds, options);
239
+ const micro = prunePasskeysM(options);
221
240
  return pipe(micro, Micro.provideService(Logger, logger), runToPromise);
222
241
  };
223
242
  /* Support */
@@ -245,10 +264,12 @@ export const isPasskeyPruningSupport = () => pipe(isPasskeyPruningSupportM, Micr
245
264
  * @category Passkeys (other)
246
265
  */
247
266
  export const isPasskeyUpdateSupport = () => pipe(isPasskeyUpdateSupportM, Micro.runSync);
248
- export { isNetworkError } from "./internal/network";
267
+ /* Re-exports */
268
+ export { isNetworkError, NetworkError } from "./internal/network";
249
269
  export { LogEvent, Logger, LogLevel, } from "./logger";
250
270
  export { AuthenticationHelper, isAuthenticationSuccess, } from "./passkey/authentication/authentication";
251
- export { DeleteError, DuplicatePasskeyError, isDeleteError, isDuplicatePasskeyError, isOtherPasskeyError, isPasskeyNotFoundError, isPasskeyUnsupportedError, isPruningError, isUpdateError, OtherPasskeyError, PasskeyNotFoundError, PasskeyUnsupportedError, PruningError, UpdateError, } from "./passkey/errors";
271
+ export { DeleteError, DuplicatePasskeyError, isDeleteError, isDuplicatePasskeyError, isOrphanedPasskeyError, isOtherPasskeyError, isPasskeyUnsupportedError, isPruningError, isUpdateError, OrphanedPasskeyError, OtherPasskeyError, PasskeyUnsupportedError, PruningError, UpdateError, } from "./passkey/errors";
252
272
  export { isRegistrationSuccess, RegistrationHelper, } from "./passkey/registration/registration";
273
+ export { isDeleteSuccess, isPruningSuccess, isUpdateSuccess, } from "./passkey/signals/signals";
253
274
  export { isAutofillSupport, isPasskeySupport, } from "./passkey/support";
254
275
  //# sourceMappingURL=safe.js.map
package/dist/safe.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"safe.js","sourceRoot":"","sources":["../src/safe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAO9C,OAAO,EACL,oBAAoB,EACpB,mBAAmB,IAAI,oBAAoB,GAC5C,MAAM,yCAAyC,CAAA;AAahD,OAAO,EACL,kBAAkB,EAClB,eAAe,IAAI,gBAAgB,GACpC,MAAM,qCAAqC,CAAA;AAM5C,OAAO,EACL,aAAa,IAAI,cAAc,EAC/B,sBAAsB,IAAI,uBAAuB,EACjD,uBAAuB,IAAI,wBAAwB,EACnD,sBAAsB,IAAI,uBAAuB,EACjD,aAAa,IAAI,cAAc,EAC/B,uBAAuB,EACvB,aAAa,IAAI,cAAc,GAChC,MAAM,2BAA2B,CAAA;AAElC,kBAAkB;AAElB;;;;;;;;;;;;;;;;;;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package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@passlock/client",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Flexible passkey authentication for Astro, SvelteKit, NextJS and other frameworks",
5
5
  "keywords": [
6
6
  "passkey",
@@ -52,21 +52,18 @@
52
52
  },
53
53
  "devDependencies": {
54
54
  "@biomejs/biome": "^2.4.4",
55
- "@effect/language-service": "^0.75.1",
55
+ "@effect/language-service": "^0.77.0",
56
56
  "@fetch-mock/vitest": "^0.2.18",
57
- "@typescript/lib-dom": "npm:@types/web@^0.0.337",
58
- "globals": "^17.3.0",
59
- "npm-check-updates": "^19.4.1",
60
- "publint": "0.3.17",
57
+ "@typescript/lib-dom": "npm:@types/web@^0.0.339",
58
+ "globals": "^17.4.0",
59
+ "npm-check-updates": "^19.6.3",
60
+ "publint": "0.3.18",
61
61
  "rimraf": "^6.1.3",
62
62
  "tsx": "4.21.0",
63
63
  "typedoc": "^0.28.17",
64
64
  "typescript": "^5.9.3",
65
65
  "vitest": "^4.0.16"
66
66
  },
67
- "peerDependencies": {
68
- "effect": "3.19.19"
69
- },
70
67
  "scripts": {
71
68
  "build": "tsc -p tsconfig.build.json",
72
69
  "build:clean": "$npm_execpath run clean:full && $npm_execpath run build",
package/dist/errors.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export declare const isTagged: <A extends {
2
- _tag: string;
3
- }>(tag: A["_tag"]) => (payload: unknown) => payload is A;
4
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,GAClB,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,MAC1C,SAAS,OAAO,KAAG,OAAO,IAAI,CAS9B,CAAA"}
package/dist/errors.js DELETED
@@ -1,14 +0,0 @@
1
- export const isTagged = (tag) => (payload) => {
2
- if (typeof payload !== "object")
3
- return false;
4
- if (payload === null)
5
- return false;
6
- if (!("_tag" in payload))
7
- return false;
8
- if (typeof payload._tag !== "string")
9
- return false;
10
- if (payload._tag !== tag)
11
- return false;
12
- return true;
13
- };
14
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GACnB,CAA6B,GAAc,EAAE,EAAE,CAC/C,CAAC,OAAgB,EAAgB,EAAE;IACjC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC7C,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAElC,IAAI,CAAC,CAAC,MAAM,IAAI,OAAO,CAAC;QAAE,OAAO,KAAK,CAAA;IACtC,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAClD,IAAI,OAAO,CAAC,IAAI,KAAK,GAAG;QAAE,OAAO,KAAK,CAAA;IAEtC,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}