@passlock/client 2.0.1 → 2.0.3
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.
- package/README.md +2 -2
- package/README.template.md +2 -2
- package/dist/index.d.ts +235 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +237 -36
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +4 -0
- package/dist/internal/index.d.ts.map +1 -0
- package/dist/internal/index.js +4 -0
- package/dist/internal/index.js.map +1 -0
- package/dist/{shared → internal}/network.d.ts +19 -16
- package/dist/internal/network.d.ts.map +1 -0
- package/dist/{shared → internal}/network.js +41 -24
- package/dist/internal/network.js.map +1 -0
- package/dist/{shared → internal}/promise.d.ts +2 -2
- package/dist/internal/promise.d.ts.map +1 -0
- package/dist/{shared → internal}/promise.js +2 -2
- package/dist/internal/promise.js.map +1 -0
- package/dist/internal/tenancy.d.ts.map +1 -0
- package/dist/internal/tenancy.js.map +1 -0
- package/dist/{logger/index.d.ts → logger.d.ts} +19 -4
- package/dist/logger.d.ts.map +1 -0
- package/dist/{logger/index.js → logger.js} +23 -8
- package/dist/logger.js.map +1 -0
- package/dist/{shared/options.d.ts → options.d.ts} +4 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/{shared/options.js.map → options.js.map} +1 -1
- package/dist/passkey/authentication/authentication.d.ts +145 -0
- package/dist/passkey/authentication/authentication.d.ts.map +1 -0
- package/dist/passkey/{authentication.js → authentication/authentication.js} +70 -52
- package/dist/passkey/authentication/authentication.js.map +1 -0
- package/dist/passkey/errors.d.ts +150 -15
- package/dist/passkey/errors.d.ts.map +1 -1
- package/dist/passkey/errors.js +209 -8
- package/dist/passkey/errors.js.map +1 -1
- package/dist/passkey/registration/registration.d.ts +149 -0
- package/dist/passkey/registration/registration.d.ts.map +1 -0
- package/dist/passkey/{registration.js → registration/registration.js} +46 -36
- package/dist/passkey/registration/registration.js.map +1 -0
- package/dist/passkey/shared.d.ts +10 -2
- package/dist/passkey/shared.d.ts.map +1 -1
- package/dist/passkey/signals/signals.d.ts +160 -0
- package/dist/passkey/signals/signals.d.ts.map +1 -0
- package/dist/passkey/{signals.js → signals/signals.js} +123 -84
- package/dist/passkey/signals/signals.js.map +1 -0
- package/dist/passkey/support.d.ts +15 -0
- package/dist/passkey/support.d.ts.map +1 -1
- package/dist/passkey/support.js +16 -1
- package/dist/passkey/support.js.map +1 -1
- package/dist/principal.d.ts +19 -0
- package/dist/principal.d.ts.map +1 -0
- package/dist/principal.js +2 -0
- package/dist/principal.js.map +1 -0
- package/dist/safe.d.ts +267 -0
- package/dist/safe.d.ts.map +1 -0
- package/dist/safe.js +275 -0
- package/dist/safe.js.map +1 -0
- package/package.json +22 -20
- package/dist/logger/index.d.ts.map +0 -1
- package/dist/logger/index.js.map +0 -1
- package/dist/passkey/authentication.d.ts +0 -118
- package/dist/passkey/authentication.d.ts.map +0 -1
- package/dist/passkey/authentication.js.map +0 -1
- package/dist/passkey/authentication.test.d.ts +0 -2
- package/dist/passkey/authentication.test.d.ts.map +0 -1
- package/dist/passkey/authentication.test.js +0 -157
- package/dist/passkey/authentication.test.js.map +0 -1
- package/dist/passkey/registration.d.ts +0 -136
- package/dist/passkey/registration.d.ts.map +0 -1
- package/dist/passkey/registration.js.map +0 -1
- package/dist/passkey/registration.test.d.ts +0 -2
- package/dist/passkey/registration.test.d.ts.map +0 -1
- package/dist/passkey/registration.test.js +0 -161
- package/dist/passkey/registration.test.js.map +0 -1
- package/dist/passkey/signals.d.ts +0 -113
- package/dist/passkey/signals.d.ts.map +0 -1
- package/dist/passkey/signals.js.map +0 -1
- package/dist/shared/network.d.ts.map +0 -1
- package/dist/shared/network.js.map +0 -1
- package/dist/shared/options.d.ts.map +0 -1
- package/dist/shared/promise.d.ts.map +0 -1
- package/dist/shared/promise.js.map +0 -1
- package/dist/shared/tenancy.d.ts.map +0 -1
- package/dist/shared/tenancy.js.map +0 -1
- package/dist/surface.test.d.ts +0 -2
- package/dist/surface.test.d.ts.map +0 -1
- package/dist/surface.test.js +0 -38
- package/dist/surface.test.js.map +0 -1
- package/dist/unsafe.d.ts +0 -41
- package/dist/unsafe.d.ts.map +0 -1
- package/dist/unsafe.js +0 -52
- package/dist/unsafe.js.map +0 -1
- /package/dist/{shared → internal}/tenancy.d.ts +0 -0
- /package/dist/{shared → internal}/tenancy.js +0 -0
- /package/dist/{shared/options.js → options.js} +0 -0
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ in README.template.md and outputs to README.md
|
|
|
36
36
|
|
|
37
37
|
Powerful features including signals and related origin requests...
|
|
38
38
|
|
|
39
|
-
1. **🔓 No lock-in**
|
|
39
|
+
1. **🔓 No lock-in**
|
|
40
40
|
Framework agnostic. Standards compliant.
|
|
41
41
|
|
|
42
42
|
2. **🔑 Related origins (domain migration)**
|
|
@@ -48,7 +48,7 @@ Works out of the box with sensible defaults.
|
|
|
48
48
|
4. **📱 Credential management**
|
|
49
49
|
Programmatically manage passkeys on end user devices
|
|
50
50
|
|
|
51
|
-
5. **💪 Powerful**
|
|
51
|
+
5. **💪 Powerful**
|
|
52
52
|
User verification, autofill, roaming authenticators and more.
|
|
53
53
|
|
|
54
54
|
## More information
|
package/README.template.md
CHANGED
|
@@ -36,7 +36,7 @@ in README.template.md and outputs to README.md
|
|
|
36
36
|
|
|
37
37
|
Powerful features including signals and related origin requests...
|
|
38
38
|
|
|
39
|
-
1. **🔓 No lock-in**
|
|
39
|
+
1. **🔓 No lock-in**
|
|
40
40
|
Framework agnostic. Standards compliant.
|
|
41
41
|
|
|
42
42
|
2. **🔑 Related origins (domain migration)**
|
|
@@ -48,7 +48,7 @@ Works out of the box with sensible defaults.
|
|
|
48
48
|
4. **📱 Credential management**
|
|
49
49
|
Programmatically manage passkeys on end user devices
|
|
50
50
|
|
|
51
|
-
5. **💪 Powerful**
|
|
51
|
+
5. **💪 Powerful**
|
|
52
52
|
User verification, autofill, roaming authenticators and more.
|
|
53
53
|
|
|
54
54
|
## More information
|
package/dist/index.d.ts
CHANGED
|
@@ -1,41 +1,245 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* _unsafe_ functions that could throw an error. Be sure to catch errors and use one of the
|
|
3
|
+
* type guards to narrow the thrown error down to a specific type.
|
|
4
|
+
*
|
|
5
|
+
* @categoryDescription Passkeys (core)
|
|
6
|
+
* Creating, authenticating, updating and deleting passkeys. {@link registerPasskey}
|
|
7
|
+
* and {@link authenticatePasskey} are the key functions.
|
|
8
|
+
*
|
|
9
|
+
* @categoryDescription Passkeys (other)
|
|
10
|
+
* Testing for browser capabilities related to passkeys, type guards and other utilities.
|
|
11
|
+
*
|
|
12
|
+
* @showCategories
|
|
13
|
+
* @module unsafe
|
|
14
|
+
*/
|
|
4
15
|
import { Logger } from "./logger";
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
16
|
+
import type { AuthenticationOptions, AuthenticationSuccess } from "./passkey/authentication/authentication";
|
|
17
|
+
import type { RegistrationOptions, RegistrationSuccess } from "./passkey/registration/registration";
|
|
18
|
+
import type { DeleteCredentialOptions, DeletePasskeyOptions, DeleteSuccess, PrunePasskeyOptions, PruningSuccess, UpdateCredentialOptions, UpdatePasskeyOptions, UpdateSuccess } from "./passkey/signals/signals";
|
|
19
|
+
import type { OrphanedPasskeyError } from "./safe";
|
|
8
20
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
21
|
+
* Registers a passkey on the user's device, then saves the server-side component in your vault.
|
|
22
|
+
* If successful, this function returns both a `code` and an `id_token` (JWT).
|
|
23
|
+
* Send either value to your backend for verification.
|
|
24
|
+
* See [register a passkey](https://passlock.dev/passkeys/registration/) in the documentation.
|
|
25
|
+
*
|
|
11
26
|
* @param options
|
|
12
|
-
*
|
|
27
|
+
*
|
|
28
|
+
* @returns A successful registration payload.
|
|
29
|
+
*
|
|
30
|
+
* @see {@link isRegistrationSuccess}
|
|
31
|
+
* @see {@link isPasskeyUnsupportedError}
|
|
32
|
+
* @see {@link isDuplicatePasskeyError}
|
|
33
|
+
* @see {@link isOtherPasskeyError}
|
|
34
|
+
*
|
|
35
|
+
* @throws {@link RegistrationError} (alias to a union of potential errors)
|
|
36
|
+
* @throws {@link PasskeyUnsupportedError} if the device does not support passkeys
|
|
37
|
+
* @throws {@link DuplicatePasskeyError} if `excludeCredentials` includes a passkey that already exists on the device
|
|
38
|
+
* @throws {@link OtherPasskeyError} typically a low level failure
|
|
39
|
+
* @throws {@link NetworkError}
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // from your Passlock console settings
|
|
43
|
+
* const tenancyId = "myTenancyId";
|
|
44
|
+
* const username = "jdoe@gmail.com";
|
|
45
|
+
*
|
|
46
|
+
* try {
|
|
47
|
+
* const result = await registerPasskey({ tenancyId, username });
|
|
48
|
+
* // send this to your backend for verification
|
|
49
|
+
* console.log(result.code);
|
|
50
|
+
* } catch (error) {
|
|
51
|
+
* if (isPasskeyUnsupportedError(error)) {
|
|
52
|
+
* alert("passkeys not supported on this device");
|
|
53
|
+
* } else {
|
|
54
|
+
* console.log(error);
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* @category Passkeys (core)
|
|
13
59
|
*/
|
|
14
|
-
export declare const registerPasskey: (options: RegistrationOptions,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export { DuplicatePasskeyError, isDuplicatePasskey, isRegistrationSuccess, } from "./passkey/registration";
|
|
18
|
-
export { isUnexpectedError, UnexpectedError } from "./shared/network";
|
|
60
|
+
export declare const registerPasskey: (options: RegistrationOptions,
|
|
61
|
+
/** @hidden */
|
|
62
|
+
logger?: typeof Logger.Service) => Promise<RegistrationSuccess>;
|
|
19
63
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
64
|
+
* 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 both a `code` and an `id_token` (JWT). Send either value to your backend for verification.
|
|
66
|
+
* See
|
|
67
|
+
* [authenticate a passkey](https://passlock.dev/passkeys/authentication/) in the documentation.
|
|
22
68
|
*
|
|
23
69
|
* @param options
|
|
24
|
-
*
|
|
70
|
+
*
|
|
71
|
+
* @returns A successful authentication payload.
|
|
72
|
+
*
|
|
73
|
+
* @see {@link isAuthenticationSuccess}
|
|
74
|
+
* @see {@link isPasskeyUnsupportedError}
|
|
75
|
+
* @see {@link isOrphanedPasskeyError}
|
|
76
|
+
* @see {@link isOtherPasskeyError}
|
|
77
|
+
*
|
|
78
|
+
* @throws {@link AuthenticationError} (alias to a union of potential errors)
|
|
79
|
+
* @throws {@link PasskeyUnsupportedError} if the device does not support passkeys
|
|
80
|
+
* @throws {@link OrphanedPasskeyError} if the passkey is orphaned i.e. deleted from the vault but still present on the local device
|
|
81
|
+
* @throws {@link OtherPasskeyError} typically a low level failure
|
|
82
|
+
* @throws {@link NetworkError}
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* // from your Passlock console settings
|
|
86
|
+
* const tenancyId = "myTenancyId";
|
|
87
|
+
*
|
|
88
|
+
* try {
|
|
89
|
+
* const result = await authenticatePasskey({ tenancyId });
|
|
90
|
+
* // send this to your backend for verification
|
|
91
|
+
* console.log(result.code);
|
|
92
|
+
* } catch (error) {
|
|
93
|
+
* if (isPasskeyUnsupportedError(error)) {
|
|
94
|
+
* alert("passkeys not supported on this device");
|
|
95
|
+
* } else {
|
|
96
|
+
* console.log(error);
|
|
97
|
+
* }
|
|
98
|
+
* }
|
|
99
|
+
*
|
|
100
|
+
* @category Passkeys (core)
|
|
101
|
+
*/
|
|
102
|
+
export declare const authenticatePasskey: (options: AuthenticationOptions,
|
|
103
|
+
/** @hidden */
|
|
104
|
+
logger?: typeof Logger.Service) => Promise<AuthenticationSuccess>;
|
|
105
|
+
/**
|
|
106
|
+
* Attempt to update the username or display name for a passkey (client-side only).
|
|
107
|
+
*
|
|
108
|
+
* Useful if the user has changed their account identifier. For example, they register
|
|
109
|
+
* using jdoe@gmail.com but later change their account username to jdoe@yahoo.com.
|
|
110
|
+
* Even after you update their account details in your backend, their local password
|
|
111
|
+
* manager will continue to display jdoe@gmail.com.
|
|
112
|
+
*
|
|
113
|
+
* By calling this function and supplying a new username/display name, their local
|
|
114
|
+
* password manager will align with their updated account identifier.
|
|
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
|
|
118
|
+
* @see {@link isUpdateError}
|
|
119
|
+
* @throws {@link UpdateError} if the passkey cannot be updated
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* // from your Passlock console settings
|
|
123
|
+
* const tenancyId = "myTenancyId";
|
|
124
|
+
* const passkeyId = "myPasskeyId";
|
|
125
|
+
* const username = "newUsername@gmail.com";
|
|
126
|
+
* const displayName = "New Account Name";
|
|
127
|
+
*
|
|
128
|
+
* try {
|
|
129
|
+
* const result = await updatePasskey({ tenancyId, passkeyId, username, displayName });
|
|
130
|
+
* console.log("passkey updated");
|
|
131
|
+
* } catch (error) {
|
|
132
|
+
* console.log(error);
|
|
133
|
+
* }
|
|
134
|
+
*
|
|
135
|
+
* @category Passkeys (core)
|
|
136
|
+
*/
|
|
137
|
+
export declare const updatePasskey: (options: UpdatePasskeyOptions | UpdateCredentialOptions,
|
|
138
|
+
/** @hidden */
|
|
139
|
+
logger?: typeof Logger.Service) => Promise<UpdateSuccess>;
|
|
140
|
+
/**
|
|
141
|
+
* Attempts to delete a passkey from a local device. There are two scenarios in which this function proves useful:
|
|
142
|
+
*
|
|
143
|
+
* 1. **Deleting a passkey**. Use the `@passlock/node` package or make vanilla REST calls from your
|
|
144
|
+
* backend to delete the server-side component, then use this function to delete the client-side component.
|
|
145
|
+
*
|
|
146
|
+
* 2. **Missing passkey**. The user tried to present a passkey, but the server-side component could not be found.
|
|
147
|
+
* Remove the passkey from the local device to prevent it happening again.
|
|
148
|
+
*
|
|
149
|
+
* See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) and
|
|
150
|
+
* [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/) in the documentation.
|
|
151
|
+
*
|
|
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.
|
|
154
|
+
* @see {@link isDeleteError}
|
|
155
|
+
* @throws {@link DeleteError} if the passkey cannot be deleted
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* // from your Passlock console settings
|
|
159
|
+
* const tenancyId = "myTenancyId";
|
|
160
|
+
* const passkeyId = "myPasskeyId";
|
|
161
|
+
*
|
|
162
|
+
* try {
|
|
163
|
+
* const result = await deletePasskey({ tenancyId, passkeyId });
|
|
164
|
+
* console.log("passkey deleted");
|
|
165
|
+
* } catch (error) {
|
|
166
|
+
* console.log(error);
|
|
167
|
+
* }
|
|
168
|
+
*
|
|
169
|
+
* @category Passkeys (core)
|
|
170
|
+
*/
|
|
171
|
+
export declare const deletePasskey: (options: DeletePasskeyOptions | DeleteCredentialOptions | OrphanedPasskeyError,
|
|
172
|
+
/** @hidden */
|
|
173
|
+
logger?: typeof Logger.Service) => Promise<DeleteSuccess>;
|
|
174
|
+
/**
|
|
175
|
+
* Attempt to prune local passkeys by keeping only the passkey IDs you trust.
|
|
176
|
+
*
|
|
177
|
+
* This is useful when your backend is the source of truth for which passkeys
|
|
178
|
+
* should still exist for a given account on this device.
|
|
179
|
+
*
|
|
180
|
+
* @param options Pass the passkeys you want to retain.
|
|
181
|
+
* @returns A {@link PruningSuccess} payload if local passkeys were pruned.
|
|
182
|
+
* @see {@link isPruningError}
|
|
183
|
+
*
|
|
184
|
+
* @throws {@link PruningError}
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* // from your Passlock console settings
|
|
188
|
+
* const tenancyId = "myTenancyId";
|
|
189
|
+
* const allowablePasskeyIds = ["passkey-1", "passkey-2"];
|
|
190
|
+
*
|
|
191
|
+
* try {
|
|
192
|
+
* const result = await prunePasskeys({ tenancyId, allowablePasskeyIds });
|
|
193
|
+
* console.log("local passkeys pruned", result);
|
|
194
|
+
* } catch (error) {
|
|
195
|
+
* if (isPruningError(error)) {
|
|
196
|
+
* console.log(error.code);
|
|
197
|
+
* } else {
|
|
198
|
+
* console.log(error);
|
|
199
|
+
* }
|
|
200
|
+
* }
|
|
201
|
+
*
|
|
202
|
+
* @category Passkeys (core)
|
|
203
|
+
*/
|
|
204
|
+
export declare const prunePasskeys: (options: PrunePasskeyOptions,
|
|
205
|
+
/** @hidden */
|
|
206
|
+
logger?: typeof Logger.Service) => Promise<PruningSuccess>;
|
|
207
|
+
/**
|
|
208
|
+
* Does the local device support programmatic passkey deletion
|
|
209
|
+
*
|
|
210
|
+
* @returns `true` if local passkey deletion is supported.
|
|
211
|
+
*
|
|
212
|
+
* @category Passkeys (other)
|
|
213
|
+
*/
|
|
214
|
+
export declare const isPasskeyDeleteSupport: () => boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Does the local device support programmatic passkey pruning
|
|
217
|
+
*
|
|
218
|
+
* @returns `true` if local passkey pruning is supported.
|
|
219
|
+
*
|
|
220
|
+
* @category Passkeys (other)
|
|
221
|
+
*/
|
|
222
|
+
export declare const isPasskeyPruningSupport: () => boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Does the local device support programmatic passkey updates
|
|
225
|
+
*
|
|
226
|
+
* @returns `true` if local passkey updates are supported.
|
|
227
|
+
*
|
|
228
|
+
* @category Passkeys (other)
|
|
25
229
|
*/
|
|
26
|
-
export declare const authenticatePasskey: (options: AuthenticationOptions, logger?: typeof Logger.Service) => Promise<AuthenticationSuccess | AuthenticationError>;
|
|
27
|
-
export type { AuthenticationError, AuthenticationOptions, AuthenticationSuccess, PasskeyNotFound, } from "./passkey/authentication";
|
|
28
|
-
export { isAuthenticationSuccess, isPasskeyNotFound, } from "./passkey/authentication";
|
|
29
|
-
export declare const isPasskeyDeletionSupport: () => boolean;
|
|
30
|
-
export declare const isPasskeySyncSupport: () => boolean;
|
|
31
230
|
export declare const isPasskeyUpdateSupport: () => boolean;
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export {
|
|
35
|
-
export
|
|
36
|
-
export {
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export {
|
|
40
|
-
export {
|
|
231
|
+
export { isNetworkError, NetworkError } from "./internal/network";
|
|
232
|
+
export { LogEvent, Logger, LogLevel, } from "./logger";
|
|
233
|
+
export type { PasslockOptions } from "./options";
|
|
234
|
+
export type { AuthenticationError, AuthenticationEvent, AuthenticationEvents, AuthenticationOptions, AuthenticationSuccess, OnAuthenticationEvent, } from "./passkey/authentication/authentication";
|
|
235
|
+
export { AuthenticationHelper, isAuthenticationSuccess, } from "./passkey/authentication/authentication";
|
|
236
|
+
export type { ErrorCode } from "./passkey/errors";
|
|
237
|
+
export { DeleteError, DuplicatePasskeyError, isDeleteError, isDuplicatePasskeyError, isOrphanedPasskeyError, isOtherPasskeyError, isPasskeyUnsupportedError, isPruningError, isUpdateError, OrphanedPasskeyError, OtherPasskeyError, PasskeyUnsupportedError, PruningError, UpdateError, } from "./passkey/errors";
|
|
238
|
+
export type { OnRegistrationEvent, RegistrationError, RegistrationEvent, RegistrationOptions, RegistrationSuccess, } from "./passkey/registration/registration";
|
|
239
|
+
export { isRegistrationSuccess, RegistrationHelper, } from "./passkey/registration/registration";
|
|
240
|
+
export type { UserVerification } from "./passkey/shared";
|
|
241
|
+
export type { CredentialMapping, DeleteCredentialOptions, DeletePasskeyOptions, DeleteSuccess, PrunePasskeyOptions, PruningSuccess, UpdateCredentialOptions, UpdatePasskeyOptions, UpdateSuccess, } from "./passkey/signals/signals";
|
|
242
|
+
export { isDeleteSuccess, isPruningSuccess, isUpdateSuccess, } from "./passkey/signals/signals";
|
|
243
|
+
export { isAutofillSupport, isPasskeySupport, } from "./passkey/support";
|
|
244
|
+
export type { Principal } from "./principal";
|
|
41
245
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
CHANGED
|
@@ -1,52 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* _unsafe_ functions that could throw an error. Be sure to catch errors and use one of the
|
|
3
|
+
* type guards to narrow the thrown error down to a specific type.
|
|
4
|
+
*
|
|
5
|
+
* @categoryDescription Passkeys (core)
|
|
6
|
+
* Creating, authenticating, updating and deleting passkeys. {@link registerPasskey}
|
|
7
|
+
* and {@link authenticatePasskey} are the key functions.
|
|
8
|
+
*
|
|
9
|
+
* @categoryDescription Passkeys (other)
|
|
10
|
+
* Testing for browser capabilities related to passkeys, type guards and other utilities.
|
|
11
|
+
*
|
|
12
|
+
* @showCategories
|
|
13
|
+
* @module unsafe
|
|
14
|
+
*/
|
|
1
15
|
import { Micro, pipe } from "effect";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
export { ConsoleLogger, EventLogger, LogEvent, Logger, LogLevel } from "./logger";
|
|
16
|
+
import { runToPromiseUnsafe } from "./internal";
|
|
17
|
+
import { eventLogger, Logger } from "./logger";
|
|
18
|
+
import { AuthenticationHelper, authenticatePasskey as authenticatePasskeyM, } from "./passkey/authentication/authentication";
|
|
19
|
+
import { RegistrationHelper, registerPasskey as registerPasskeyM, } from "./passkey/registration/registration";
|
|
20
|
+
import { deletePasskey as deletePasskeyM, isPasskeyDeleteSupport as isPasskeyDeleteSupportM, isPasskeyPruningSupport as isPasskeyPruningSupportM, isPasskeyUpdateSupport as isPasskeyUpdateSupportM, prunePasskeys as prunePasskeysM, updatePasskey as updatePasskeyM, } from "./passkey/signals/signals";
|
|
8
21
|
/* Registration */
|
|
9
22
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
23
|
+
* Registers a passkey on the user's device, then saves the server-side component in your vault.
|
|
24
|
+
* If successful, this function returns both a `code` and an `id_token` (JWT).
|
|
25
|
+
* Send either value to your backend for verification.
|
|
26
|
+
* See [register a passkey](https://passlock.dev/passkeys/registration/) in the documentation.
|
|
27
|
+
*
|
|
12
28
|
* @param options
|
|
13
|
-
*
|
|
29
|
+
*
|
|
30
|
+
* @returns A successful registration payload.
|
|
31
|
+
*
|
|
32
|
+
* @see {@link isRegistrationSuccess}
|
|
33
|
+
* @see {@link isPasskeyUnsupportedError}
|
|
34
|
+
* @see {@link isDuplicatePasskeyError}
|
|
35
|
+
* @see {@link isOtherPasskeyError}
|
|
36
|
+
*
|
|
37
|
+
* @throws {@link RegistrationError} (alias to a union of potential errors)
|
|
38
|
+
* @throws {@link PasskeyUnsupportedError} if the device does not support passkeys
|
|
39
|
+
* @throws {@link DuplicatePasskeyError} if `excludeCredentials` includes a passkey that already exists on the device
|
|
40
|
+
* @throws {@link OtherPasskeyError} typically a low level failure
|
|
41
|
+
* @throws {@link NetworkError}
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // from your Passlock console settings
|
|
45
|
+
* const tenancyId = "myTenancyId";
|
|
46
|
+
* const username = "jdoe@gmail.com";
|
|
47
|
+
*
|
|
48
|
+
* try {
|
|
49
|
+
* const result = await registerPasskey({ tenancyId, username });
|
|
50
|
+
* // send this to your backend for verification
|
|
51
|
+
* console.log(result.code);
|
|
52
|
+
* } catch (error) {
|
|
53
|
+
* if (isPasskeyUnsupportedError(error)) {
|
|
54
|
+
* alert("passkeys not supported on this device");
|
|
55
|
+
* } else {
|
|
56
|
+
* console.log(error);
|
|
57
|
+
* }
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* @category Passkeys (core)
|
|
14
61
|
*/
|
|
15
|
-
export const registerPasskey = async (options,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export { isUnexpectedError, UnexpectedError } from "./shared/network";
|
|
62
|
+
export const registerPasskey = async (options,
|
|
63
|
+
/** @hidden */
|
|
64
|
+
logger = eventLogger) => pipe(registerPasskeyM(options), Micro.provideService(RegistrationHelper, RegistrationHelper.Default), Micro.provideService(Logger, logger), runToPromiseUnsafe);
|
|
19
65
|
/* Authentication */
|
|
20
66
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
67
|
+
* Asks the client to present a passkey, which is then verified against the server-side component in your vault.
|
|
68
|
+
* If successful, this function returns both a `code` and an `id_token` (JWT). Send either value to your backend for verification.
|
|
69
|
+
* See
|
|
70
|
+
* [authenticate a passkey](https://passlock.dev/passkeys/authentication/) in the documentation.
|
|
23
71
|
*
|
|
24
72
|
* @param options
|
|
25
|
-
*
|
|
73
|
+
*
|
|
74
|
+
* @returns A successful authentication payload.
|
|
75
|
+
*
|
|
76
|
+
* @see {@link isAuthenticationSuccess}
|
|
77
|
+
* @see {@link isPasskeyUnsupportedError}
|
|
78
|
+
* @see {@link isOrphanedPasskeyError}
|
|
79
|
+
* @see {@link isOtherPasskeyError}
|
|
80
|
+
*
|
|
81
|
+
* @throws {@link AuthenticationError} (alias to a union of potential errors)
|
|
82
|
+
* @throws {@link PasskeyUnsupportedError} if the device does not support passkeys
|
|
83
|
+
* @throws {@link OrphanedPasskeyError} if the passkey is orphaned i.e. deleted from the vault but still present on the local device
|
|
84
|
+
* @throws {@link OtherPasskeyError} typically a low level failure
|
|
85
|
+
* @throws {@link NetworkError}
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* // from your Passlock console settings
|
|
89
|
+
* const tenancyId = "myTenancyId";
|
|
90
|
+
*
|
|
91
|
+
* try {
|
|
92
|
+
* const result = await authenticatePasskey({ tenancyId });
|
|
93
|
+
* // send this to your backend for verification
|
|
94
|
+
* console.log(result.code);
|
|
95
|
+
* } catch (error) {
|
|
96
|
+
* if (isPasskeyUnsupportedError(error)) {
|
|
97
|
+
* alert("passkeys not supported on this device");
|
|
98
|
+
* } else {
|
|
99
|
+
* console.log(error);
|
|
100
|
+
* }
|
|
101
|
+
* }
|
|
102
|
+
*
|
|
103
|
+
* @category Passkeys (core)
|
|
26
104
|
*/
|
|
27
|
-
export const authenticatePasskey = (options,
|
|
28
|
-
|
|
105
|
+
export const authenticatePasskey = (options,
|
|
106
|
+
/** @hidden */
|
|
107
|
+
logger = eventLogger) => pipe(authenticatePasskeyM(options), Micro.provideService(AuthenticationHelper, AuthenticationHelper.Default), Micro.provideService(Logger, logger), runToPromiseUnsafe);
|
|
29
108
|
/* Signals */
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Attempt to update the username or display name for a passkey (client-side only).
|
|
111
|
+
*
|
|
112
|
+
* Useful if the user has changed their account identifier. For example, they register
|
|
113
|
+
* using jdoe@gmail.com but later change their account username to jdoe@yahoo.com.
|
|
114
|
+
* Even after you update their account details in your backend, their local password
|
|
115
|
+
* manager will continue to display jdoe@gmail.com.
|
|
116
|
+
*
|
|
117
|
+
* By calling this function and supplying a new username/display name, their local
|
|
118
|
+
* password manager will align with their updated account identifier.
|
|
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
|
|
122
|
+
* @see {@link isUpdateError}
|
|
123
|
+
* @throws {@link UpdateError} if the passkey cannot be updated
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* // from your Passlock console settings
|
|
127
|
+
* const tenancyId = "myTenancyId";
|
|
128
|
+
* const passkeyId = "myPasskeyId";
|
|
129
|
+
* const username = "newUsername@gmail.com";
|
|
130
|
+
* const displayName = "New Account Name";
|
|
131
|
+
*
|
|
132
|
+
* try {
|
|
133
|
+
* const result = await updatePasskey({ tenancyId, passkeyId, username, displayName });
|
|
134
|
+
* console.log("passkey updated");
|
|
135
|
+
* } catch (error) {
|
|
136
|
+
* console.log(error);
|
|
137
|
+
* }
|
|
138
|
+
*
|
|
139
|
+
* @category Passkeys (core)
|
|
140
|
+
*/
|
|
141
|
+
export const updatePasskey = (options,
|
|
142
|
+
/** @hidden */
|
|
143
|
+
logger = eventLogger) => {
|
|
144
|
+
const micro = updatePasskeyM(options);
|
|
145
|
+
return pipe(micro, Micro.provideService(Logger, logger), runToPromiseUnsafe);
|
|
38
146
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Attempts to delete a passkey from a local device. There are two scenarios in which this function proves useful:
|
|
149
|
+
*
|
|
150
|
+
* 1. **Deleting a passkey**. Use the `@passlock/node` package or make vanilla REST calls from your
|
|
151
|
+
* backend to delete the server-side component, then use this function to delete the client-side component.
|
|
152
|
+
*
|
|
153
|
+
* 2. **Missing passkey**. The user tried to present a passkey, but the server-side component could not be found.
|
|
154
|
+
* Remove the passkey from the local device to prevent it happening again.
|
|
155
|
+
*
|
|
156
|
+
* See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) and
|
|
157
|
+
* [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/) in the documentation.
|
|
158
|
+
*
|
|
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.
|
|
161
|
+
* @see {@link isDeleteError}
|
|
162
|
+
* @throws {@link DeleteError} if the passkey cannot be deleted
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* // from your Passlock console settings
|
|
166
|
+
* const tenancyId = "myTenancyId";
|
|
167
|
+
* const passkeyId = "myPasskeyId";
|
|
168
|
+
*
|
|
169
|
+
* try {
|
|
170
|
+
* const result = await deletePasskey({ tenancyId, passkeyId });
|
|
171
|
+
* console.log("passkey deleted");
|
|
172
|
+
* } catch (error) {
|
|
173
|
+
* console.log(error);
|
|
174
|
+
* }
|
|
175
|
+
*
|
|
176
|
+
* @category Passkeys (core)
|
|
177
|
+
*/
|
|
178
|
+
export const deletePasskey = (options,
|
|
179
|
+
/** @hidden */
|
|
180
|
+
logger = eventLogger) => {
|
|
181
|
+
const micro = deletePasskeyM(options);
|
|
182
|
+
return pipe(micro, Micro.provideService(Logger, logger), runToPromiseUnsafe);
|
|
43
183
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
184
|
+
/**
|
|
185
|
+
* Attempt to prune local passkeys by keeping only the passkey IDs you trust.
|
|
186
|
+
*
|
|
187
|
+
* This is useful when your backend is the source of truth for which passkeys
|
|
188
|
+
* should still exist for a given account on this device.
|
|
189
|
+
*
|
|
190
|
+
* @param options Pass the passkeys you want to retain.
|
|
191
|
+
* @returns A {@link PruningSuccess} payload if local passkeys were pruned.
|
|
192
|
+
* @see {@link isPruningError}
|
|
193
|
+
*
|
|
194
|
+
* @throws {@link PruningError}
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* // from your Passlock console settings
|
|
198
|
+
* const tenancyId = "myTenancyId";
|
|
199
|
+
* const allowablePasskeyIds = ["passkey-1", "passkey-2"];
|
|
200
|
+
*
|
|
201
|
+
* try {
|
|
202
|
+
* const result = await prunePasskeys({ tenancyId, allowablePasskeyIds });
|
|
203
|
+
* console.log("local passkeys pruned", result);
|
|
204
|
+
* } catch (error) {
|
|
205
|
+
* if (isPruningError(error)) {
|
|
206
|
+
* console.log(error.code);
|
|
207
|
+
* } else {
|
|
208
|
+
* console.log(error);
|
|
209
|
+
* }
|
|
210
|
+
* }
|
|
211
|
+
*
|
|
212
|
+
* @category Passkeys (core)
|
|
213
|
+
*/
|
|
214
|
+
export const prunePasskeys = (options,
|
|
215
|
+
/** @hidden */
|
|
216
|
+
logger = eventLogger) => {
|
|
217
|
+
const micro = prunePasskeysM(options);
|
|
218
|
+
return pipe(micro, Micro.provideService(Logger, logger), runToPromiseUnsafe);
|
|
48
219
|
};
|
|
49
|
-
export { isUpdateError, UpdateError } from "./passkey/signals";
|
|
50
220
|
/* Support */
|
|
51
|
-
|
|
221
|
+
/**
|
|
222
|
+
* Does the local device support programmatic passkey deletion
|
|
223
|
+
*
|
|
224
|
+
* @returns `true` if local passkey deletion is supported.
|
|
225
|
+
*
|
|
226
|
+
* @category Passkeys (other)
|
|
227
|
+
*/
|
|
228
|
+
export const isPasskeyDeleteSupport = () => pipe(isPasskeyDeleteSupportM, Micro.runSync);
|
|
229
|
+
/**
|
|
230
|
+
* Does the local device support programmatic passkey pruning
|
|
231
|
+
*
|
|
232
|
+
* @returns `true` if local passkey pruning is supported.
|
|
233
|
+
*
|
|
234
|
+
* @category Passkeys (other)
|
|
235
|
+
*/
|
|
236
|
+
export const isPasskeyPruningSupport = () => pipe(isPasskeyPruningSupportM, Micro.runSync);
|
|
237
|
+
/**
|
|
238
|
+
* Does the local device support programmatic passkey updates
|
|
239
|
+
*
|
|
240
|
+
* @returns `true` if local passkey updates are supported.
|
|
241
|
+
*
|
|
242
|
+
* @category Passkeys (other)
|
|
243
|
+
*/
|
|
244
|
+
export const isPasskeyUpdateSupport = () => pipe(isPasskeyUpdateSupportM, Micro.runSync);
|
|
245
|
+
/* Re-exports */
|
|
246
|
+
export { isNetworkError, NetworkError } from "./internal/network";
|
|
247
|
+
export { LogEvent, Logger, LogLevel, } from "./logger";
|
|
248
|
+
export { AuthenticationHelper, isAuthenticationSuccess, } from "./passkey/authentication/authentication";
|
|
249
|
+
export { DeleteError, DuplicatePasskeyError, isDeleteError, isDuplicatePasskeyError, isOrphanedPasskeyError, isOtherPasskeyError, isPasskeyUnsupportedError, isPruningError, isUpdateError, OrphanedPasskeyError, OtherPasskeyError, PasskeyUnsupportedError, PruningError, UpdateError, } from "./passkey/errors";
|
|
250
|
+
export { isRegistrationSuccess, RegistrationHelper, } from "./passkey/registration/registration";
|
|
251
|
+
export { isDeleteSuccess, isPruningSuccess, isUpdateSuccess, } from "./passkey/signals/signals";
|
|
252
|
+
export { isAutofillSupport, isPasskeySupport, } from "./passkey/support";
|
|
52
253
|
//# sourceMappingURL=index.js.map
|