@passlock/client 2.0.0 → 2.0.2
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 +14 -16
- package/README.template.md +14 -16
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +14 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +245 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +253 -3
- 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 +40 -25
- 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} +19 -4
- 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 +82 -66
- package/dist/passkey/authentication/authentication.d.ts.map +1 -1
- package/dist/passkey/authentication/authentication.js +67 -49
- package/dist/passkey/authentication/authentication.js.map +1 -1
- package/dist/passkey/errors.d.ts +158 -16
- package/dist/passkey/errors.d.ts.map +1 -1
- package/dist/passkey/errors.js +214 -6
- package/dist/passkey/errors.js.map +1 -1
- package/dist/passkey/registration/registration.d.ts +81 -72
- package/dist/passkey/registration/registration.d.ts.map +1 -1
- package/dist/passkey/registration/registration.js +42 -35
- package/dist/passkey/registration/registration.js.map +1 -1
- package/dist/passkey/{types.d.ts → shared.d.ts} +9 -3
- package/dist/passkey/shared.d.ts.map +1 -0
- package/dist/passkey/shared.js +2 -0
- package/dist/passkey/shared.js.map +1 -0
- package/dist/passkey/signals/signals.d.ts +93 -35
- package/dist/passkey/signals/signals.d.ts.map +1 -1
- package/dist/passkey/signals/signals.js +197 -90
- package/dist/passkey/signals/signals.js.map +1 -1
- 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 +16 -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 +247 -0
- package/dist/safe.d.ts.map +1 -0
- package/dist/safe.js +254 -0
- package/dist/safe.js.map +1 -0
- package/package.json +26 -21
- package/dist/logger/index.d.ts.map +0 -1
- package/dist/logger/index.js.map +0 -1
- package/dist/passkey/authentication/authentication.test.d.ts +0 -2
- package/dist/passkey/authentication/authentication.test.d.ts.map +0 -1
- package/dist/passkey/authentication/authentication.test.js +0 -157
- package/dist/passkey/authentication/authentication.test.js.map +0 -1
- package/dist/passkey/authentication/index.d.ts +0 -21
- package/dist/passkey/authentication/index.d.ts.map +0 -1
- package/dist/passkey/authentication/index.js +0 -22
- package/dist/passkey/authentication/index.js.map +0 -1
- package/dist/passkey/index.d.ts +0 -6
- package/dist/passkey/index.d.ts.map +0 -1
- package/dist/passkey/index.js +0 -6
- package/dist/passkey/index.js.map +0 -1
- package/dist/passkey/registration/index.d.ts +0 -19
- package/dist/passkey/registration/index.d.ts.map +0 -1
- package/dist/passkey/registration/index.js +0 -20
- package/dist/passkey/registration/index.js.map +0 -1
- package/dist/passkey/registration/registration.test.d.ts +0 -2
- package/dist/passkey/registration/registration.test.d.ts.map +0 -1
- package/dist/passkey/registration/registration.test.js +0 -161
- package/dist/passkey/registration/registration.test.js.map +0 -1
- package/dist/passkey/signals/index.d.ts +0 -9
- package/dist/passkey/signals/index.d.ts.map +0 -1
- package/dist/passkey/signals/index.js +0 -19
- package/dist/passkey/signals/index.js.map +0 -1
- package/dist/passkey/types.d.ts.map +0 -1
- package/dist/passkey/types.js +0 -2
- package/dist/passkey/types.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/{shared → internal}/tenancy.d.ts +0 -0
- /package/dist/{shared → internal}/tenancy.js +0 -0
- /package/dist/{shared/options.js → options.js} +0 -0
|
@@ -1,45 +1,51 @@
|
|
|
1
1
|
import * as Helper from "@simplewebauthn/browser";
|
|
2
2
|
import { WebAuthnError, } from "@simplewebauthn/browser";
|
|
3
3
|
import { Context, Micro, pipe } from "effect";
|
|
4
|
+
import { Endpoint, makeEndpoint, makeRequest, TenancyId } from "../../internal";
|
|
4
5
|
import { Logger } from "../../logger";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import { OtherPasskeyError, PasskeyNotFoundError, PasskeyUnsupportedError, } from "../errors";
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
8
11
|
export class AuthenticationHelper extends Context.Tag("AuthenticationHelper")() {
|
|
9
12
|
static Default = {
|
|
10
13
|
browserSupportsWebAuthn: Helper.browserSupportsWebAuthn,
|
|
11
14
|
startAuthentication: Helper.startAuthentication,
|
|
12
15
|
};
|
|
13
16
|
}
|
|
14
|
-
const
|
|
17
|
+
export const AuthenticationSuccessTag = "AuthenticationSuccess";
|
|
18
|
+
/**
|
|
19
|
+
* Type guard to narrow something down to an AuthenticationSuccess
|
|
20
|
+
*
|
|
21
|
+
* @param payload
|
|
22
|
+
* @returns `true` if the payload is an {@link AuthenticationSuccess}.
|
|
23
|
+
*
|
|
24
|
+
* @category Passkeys (other)
|
|
25
|
+
*/
|
|
26
|
+
export const isAuthenticationSuccess = (payload) => {
|
|
15
27
|
if (typeof payload !== "object")
|
|
16
28
|
return false;
|
|
17
29
|
if (payload === null)
|
|
18
30
|
return false;
|
|
19
|
-
if (!("
|
|
20
|
-
return false;
|
|
21
|
-
if (typeof payload.optionsJSON !== "object")
|
|
22
|
-
return false;
|
|
23
|
-
if (payload.optionsJSON === null)
|
|
31
|
+
if (!("_tag" in payload))
|
|
24
32
|
return false;
|
|
25
|
-
if (
|
|
33
|
+
if (typeof payload._tag !== "string")
|
|
26
34
|
return false;
|
|
27
|
-
if (
|
|
35
|
+
if (payload._tag !== AuthenticationSuccessTag)
|
|
28
36
|
return false;
|
|
29
37
|
return true;
|
|
30
38
|
};
|
|
31
|
-
export const authenticationEvent = ["optionsRequest", "getCredential", "verifyCredential"];
|
|
32
39
|
export const fetchOptions = (options) => Micro.gen(function* () {
|
|
33
40
|
const logger = yield* Micro.service(Logger);
|
|
34
41
|
const { endpoint } = yield* Micro.service(Endpoint);
|
|
35
42
|
const { tenancyId } = yield* Micro.service(TenancyId);
|
|
36
|
-
const {
|
|
43
|
+
const { userVerification, allowCredentials, timeout, onEvent } = options;
|
|
37
44
|
const url = new URL(`${tenancyId}/passkey/authentication/options`, endpoint);
|
|
38
45
|
onEvent?.("optionsRequest");
|
|
39
46
|
yield* logger.logInfo("Fetching passkey authentication options from Passlock");
|
|
40
47
|
const payload = {
|
|
41
48
|
allowCredentials,
|
|
42
|
-
userId,
|
|
43
49
|
userVerification,
|
|
44
50
|
timeout,
|
|
45
51
|
};
|
|
@@ -50,42 +56,20 @@ export const fetchOptions = (options) => Micro.gen(function* () {
|
|
|
50
56
|
url,
|
|
51
57
|
});
|
|
52
58
|
});
|
|
53
|
-
const
|
|
54
|
-
export const isAuthenticationSuccess = (payload) => {
|
|
55
|
-
if (typeof payload !== "object")
|
|
56
|
-
return false;
|
|
57
|
-
if (payload === null)
|
|
58
|
-
return false;
|
|
59
|
-
if (!("_tag" in payload))
|
|
60
|
-
return false;
|
|
61
|
-
if (typeof payload._tag !== "string")
|
|
62
|
-
return false;
|
|
63
|
-
if (payload._tag !== AuthenticationSuccessTag)
|
|
64
|
-
return false;
|
|
65
|
-
return true;
|
|
66
|
-
};
|
|
67
|
-
export const isPasskeyNotFound = (payload) => {
|
|
59
|
+
export const isOptionsResponse = (payload) => {
|
|
68
60
|
if (typeof payload !== "object")
|
|
69
61
|
return false;
|
|
70
62
|
if (payload === null)
|
|
71
63
|
return false;
|
|
72
|
-
if (!("
|
|
73
|
-
return false;
|
|
74
|
-
if (typeof payload._tag !== "string")
|
|
75
|
-
return false;
|
|
76
|
-
if (payload._tag !== "@error/PasskeyNotFound")
|
|
77
|
-
return false;
|
|
78
|
-
if (!("message" in payload))
|
|
79
|
-
return false;
|
|
80
|
-
if (typeof payload.message !== "string")
|
|
64
|
+
if (!("optionsJSON" in payload))
|
|
81
65
|
return false;
|
|
82
|
-
if (
|
|
66
|
+
if (typeof payload.optionsJSON !== "object")
|
|
83
67
|
return false;
|
|
84
|
-
if (
|
|
68
|
+
if (payload.optionsJSON === null)
|
|
85
69
|
return false;
|
|
86
|
-
if (!("
|
|
70
|
+
if (!("sessionToken" in payload))
|
|
87
71
|
return false;
|
|
88
|
-
if (typeof payload.
|
|
72
|
+
if (typeof payload.sessionToken !== "string")
|
|
89
73
|
return false;
|
|
90
74
|
return true;
|
|
91
75
|
};
|
|
@@ -96,9 +80,9 @@ export const startAuthentication = (optionsJSON, { useBrowserAutofill, onEvent,
|
|
|
96
80
|
const helper = yield* Micro.service(AuthenticationHelper);
|
|
97
81
|
const isSupport = helper.browserSupportsWebAuthn();
|
|
98
82
|
if (!isSupport)
|
|
99
|
-
yield* new
|
|
83
|
+
yield* Micro.fail(new PasskeyUnsupportedError({
|
|
100
84
|
message: "Device does not support passkeys",
|
|
101
|
-
});
|
|
85
|
+
}));
|
|
102
86
|
return yield* Micro.tryPromise({
|
|
103
87
|
catch: (error) => {
|
|
104
88
|
if (error instanceof WebAuthnError) {
|
|
@@ -116,6 +100,31 @@ export const startAuthentication = (optionsJSON, { useBrowserAutofill, onEvent,
|
|
|
116
100
|
try: () => helper.startAuthentication({ optionsJSON, useBrowserAutofill }),
|
|
117
101
|
});
|
|
118
102
|
});
|
|
103
|
+
const isPasskeyNotFound = (payload) => {
|
|
104
|
+
if (typeof payload !== "object")
|
|
105
|
+
return false;
|
|
106
|
+
if (payload === null)
|
|
107
|
+
return false;
|
|
108
|
+
if (!("_tag" in payload))
|
|
109
|
+
return false;
|
|
110
|
+
if (typeof payload._tag !== "string")
|
|
111
|
+
return false;
|
|
112
|
+
if (payload._tag !== "@error/PasskeyNotFound")
|
|
113
|
+
return false;
|
|
114
|
+
if (!("message" in payload))
|
|
115
|
+
return false;
|
|
116
|
+
if (typeof payload.message !== "string")
|
|
117
|
+
return false;
|
|
118
|
+
if (!("credentialId" in payload))
|
|
119
|
+
return false;
|
|
120
|
+
if (typeof payload.credentialId !== "string")
|
|
121
|
+
return false;
|
|
122
|
+
if (!("rpId" in payload))
|
|
123
|
+
return false;
|
|
124
|
+
if (typeof payload.rpId !== "string")
|
|
125
|
+
return false;
|
|
126
|
+
return true;
|
|
127
|
+
};
|
|
119
128
|
export const verifyCredential = (sessionToken, response, { onEvent }) => Micro.gen(function* () {
|
|
120
129
|
const logger = yield* Micro.service(Logger);
|
|
121
130
|
const { endpoint } = yield* Micro.service(Endpoint);
|
|
@@ -127,25 +136,26 @@ export const verifyCredential = (sessionToken, response, { onEvent }) => Micro.g
|
|
|
127
136
|
response,
|
|
128
137
|
sessionToken,
|
|
129
138
|
};
|
|
130
|
-
const authenticationResponse = yield* makeRequest({
|
|
139
|
+
const authenticationResponse = yield* pipe(makeRequest({
|
|
131
140
|
errorPredicate: isPasskeyNotFound,
|
|
132
141
|
label: "authentication verification",
|
|
133
142
|
payload,
|
|
134
143
|
responsePredicate: isAuthenticationSuccess,
|
|
135
144
|
url,
|
|
136
|
-
});
|
|
145
|
+
}), Micro.catchTag("@error/PasskeyNotFound", (err) => Micro.fail(new PasskeyNotFoundError(err))));
|
|
137
146
|
yield* logger.logInfo(`Passkey with id ${authenticationResponse.principal.authenticatorId} successfully authenticated`);
|
|
138
147
|
return authenticationResponse;
|
|
139
148
|
});
|
|
140
149
|
/**
|
|
141
|
-
* Trigger local passkey authentication then verify the passkey in
|
|
150
|
+
* Trigger local passkey authentication then verify the passkey in your Passlock vault.
|
|
142
151
|
* Returns a code and id_token that can be exchanged/decoded in your backend.
|
|
143
152
|
*
|
|
144
153
|
* @param options
|
|
145
|
-
* @returns
|
|
154
|
+
* @returns A Micro effect that resolves with {@link AuthenticationSuccess} or
|
|
155
|
+
* fails with {@link AuthenticationError}.
|
|
146
156
|
*/
|
|
147
157
|
export const authenticatePasskey = (options) => {
|
|
148
|
-
const endpoint =
|
|
158
|
+
const endpoint = makeEndpoint(options);
|
|
149
159
|
const micro = Micro.gen(function* () {
|
|
150
160
|
const { sessionToken, optionsJSON } = yield* fetchOptions(options);
|
|
151
161
|
const go = (useBrowserAutofill) => Micro.gen(function* () {
|
|
@@ -169,4 +179,12 @@ export const authenticatePasskey = (options) => {
|
|
|
169
179
|
});
|
|
170
180
|
return pipe(micro, Micro.provideService(TenancyId, options), Micro.provideService(Endpoint, endpoint));
|
|
171
181
|
};
|
|
182
|
+
/**
|
|
183
|
+
* Type of the authentication event
|
|
184
|
+
*/
|
|
185
|
+
export const AuthenticationEvent = [
|
|
186
|
+
"optionsRequest",
|
|
187
|
+
"getCredential",
|
|
188
|
+
"verifyCredential",
|
|
189
|
+
];
|
|
172
190
|
//# sourceMappingURL=authentication.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.js","sourceRoot":"","sources":["../../../src/passkey/authentication/authentication.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"authentication.js","s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|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The local device does not support Passkeys.
|
|
3
|
+
* See the message property (string) for more details
|
|
4
|
+
*
|
|
5
|
+
* @category Passkeys (errors)
|
|
6
|
+
*/
|
|
7
|
+
export declare const isPasskeyUnsupportedError: (payload: unknown) => payload is PasskeyUnsupportedError;
|
|
8
|
+
/**
|
|
9
|
+
* The local device does not support Passkeys.
|
|
10
|
+
* See the message property (string) for more details
|
|
11
|
+
*
|
|
12
|
+
* @category Passkeys (errors)
|
|
13
|
+
*/
|
|
14
|
+
export declare class PasskeyUnsupportedError extends Error {
|
|
15
|
+
readonly _tag: "PasskeyUnsupported";
|
|
7
16
|
readonly message: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
17
|
+
constructor({ message }: {
|
|
18
|
+
message: string;
|
|
19
|
+
});
|
|
20
|
+
static isPasskeyUnsupportedError: (payload: unknown) => payload is PasskeyUnsupportedError;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Client tried to authenticate with a passkey that was not found in the vault.
|
|
24
|
+
* Note: this error can be passed to the {@link deletePasskey} function. This is
|
|
25
|
+
* useful when the user has an orphaned passkey on their device with no server-side
|
|
26
|
+
* component. Just pass this error into deletePasskey and the library will attempt
|
|
27
|
+
* to remove the orphaned passkey from the local device.
|
|
28
|
+
*
|
|
29
|
+
* @category Passkeys (errors)
|
|
30
|
+
*/
|
|
31
|
+
export declare const isPasskeyNotFoundError: (payload: unknown) => payload is PasskeyNotFoundError;
|
|
32
|
+
/**
|
|
33
|
+
* Client tried to authenticate with a passkey that was not found in the vault.
|
|
34
|
+
* Note: this error can be passed to the {@link deletePasskey} function. This is
|
|
35
|
+
* useful when the user has an orphaned passkey on their device with no server-side
|
|
36
|
+
* component. Just pass this error into deletePasskey and the library will attempt
|
|
37
|
+
* to remove the orphaned passkey from the local device.
|
|
38
|
+
*
|
|
39
|
+
* @category Passkeys (errors)
|
|
40
|
+
*/
|
|
41
|
+
export declare class PasskeyNotFoundError extends Error {
|
|
42
|
+
readonly _tag: "PasskeyNotFoundError";
|
|
43
|
+
readonly message: string;
|
|
44
|
+
readonly credentialId: string;
|
|
45
|
+
readonly rpId: string;
|
|
46
|
+
constructor({ message, credentialId, rpId, }: {
|
|
47
|
+
message: string;
|
|
48
|
+
credentialId: string;
|
|
49
|
+
rpId: string;
|
|
50
|
+
});
|
|
51
|
+
static isPasskeyNotFoundError: (payload: unknown) => payload is PasskeyNotFoundError;
|
|
10
52
|
}
|
|
11
53
|
export type ErrorCode = "ERROR_CEREMONY_ABORTED" | "ERROR_INVALID_DOMAIN" | "ERROR_INVALID_RP_ID" | "ERROR_INVALID_USER_ID_LENGTH" | "ERROR_MALFORMED_PUBKEYCREDPARAMS" | "ERROR_AUTHENTICATOR_GENERAL_ERROR" | "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT" | "ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT" | "ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED" | "ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG" | "ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE" | "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
54
|
+
/**
|
|
55
|
+
* An unexpected passkey specific error occurred.
|
|
56
|
+
* Check the code and message for more information.
|
|
57
|
+
*
|
|
58
|
+
* @category Passkeys (errors)
|
|
59
|
+
*/
|
|
60
|
+
export declare const isOtherPasskeyError: (payload: unknown) => payload is OtherPasskeyError;
|
|
61
|
+
/**
|
|
62
|
+
* An unexpected passkey specific error occurred.
|
|
63
|
+
* Check the code and message for more information.
|
|
64
|
+
*
|
|
65
|
+
* @category Passkeys (errors)
|
|
66
|
+
*/
|
|
67
|
+
export declare class OtherPasskeyError extends Error {
|
|
68
|
+
readonly _tag: "OtherPasskey";
|
|
17
69
|
readonly error: unknown;
|
|
18
70
|
readonly message: string;
|
|
19
71
|
readonly code?: ErrorCode;
|
|
20
72
|
readonly cause?: unknown;
|
|
21
|
-
}
|
|
22
|
-
|
|
73
|
+
constructor({ error, message, code, cause, }: {
|
|
74
|
+
error: unknown;
|
|
75
|
+
message: string;
|
|
76
|
+
code?: ErrorCode;
|
|
77
|
+
cause?: unknown;
|
|
78
|
+
});
|
|
79
|
+
static isOtherPasskeyError: (payload: unknown) => payload is OtherPasskeyError;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Raised if excludeCredentials was provided and the device
|
|
83
|
+
* recognises one of the excluded passkeys i.e. the user currently
|
|
84
|
+
* has a passkey registered for a given userId.
|
|
85
|
+
*
|
|
86
|
+
* @category Passkeys (errors)
|
|
87
|
+
*/
|
|
88
|
+
export declare const isDuplicatePasskeyError: (payload: unknown) => payload is DuplicatePasskeyError;
|
|
89
|
+
/**
|
|
90
|
+
* Raised if excludeCredentials was provided and the device
|
|
91
|
+
* recognises one of the excluded passkeys i.e. the user currently
|
|
92
|
+
* has a passkey registered for a given userId.
|
|
93
|
+
*
|
|
94
|
+
* @category Passkeys (errors)
|
|
95
|
+
*/
|
|
96
|
+
export declare class DuplicatePasskeyError extends Error {
|
|
97
|
+
readonly _tag: "DuplicatePasskeyError";
|
|
98
|
+
readonly message: string;
|
|
99
|
+
constructor({ message }: {
|
|
100
|
+
message: string;
|
|
101
|
+
});
|
|
102
|
+
static isDuplicatePasskeyError: (payload: unknown) => payload is DuplicatePasskeyError;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The browser/device was unable to delete the passkey
|
|
106
|
+
*
|
|
107
|
+
* @category Passkeys (errors)
|
|
108
|
+
*/
|
|
109
|
+
export declare const isDeleteError: (payload: unknown) => payload is DeleteError;
|
|
110
|
+
/**
|
|
111
|
+
* The browser/device was unable to delete the passkey
|
|
112
|
+
*
|
|
113
|
+
* @category Passkeys (errors)
|
|
114
|
+
*/
|
|
115
|
+
export declare class DeleteError extends Error {
|
|
116
|
+
readonly _tag: "DeleteError";
|
|
117
|
+
readonly message: string;
|
|
118
|
+
readonly code: "PASSKEY_DELETION_UNSUPPORTED" | "PASSKEY_NOT_FOUND" | "OTHER_ERROR";
|
|
119
|
+
constructor({ message, code, }: {
|
|
120
|
+
message: string;
|
|
121
|
+
code: "PASSKEY_DELETION_UNSUPPORTED" | "PASSKEY_NOT_FOUND" | "OTHER_ERROR";
|
|
122
|
+
});
|
|
123
|
+
static isDeleteError: (payload: unknown) => payload is DeleteError;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The browser/device was unable to prune the passkeys
|
|
127
|
+
*
|
|
128
|
+
* @category Passkeys (errors)
|
|
129
|
+
*/
|
|
130
|
+
export declare const isPruningError: (payload: unknown) => payload is PruningError;
|
|
131
|
+
/**
|
|
132
|
+
* The browser/device was unable to prune the passkeys
|
|
133
|
+
*
|
|
134
|
+
* @category Passkeys (errors)
|
|
135
|
+
*/
|
|
136
|
+
export declare class PruningError extends Error {
|
|
137
|
+
readonly _tag: "PruningError";
|
|
138
|
+
readonly message: string;
|
|
139
|
+
readonly code: "PASSKEY_PRUNING_UNSUPPORTED" | "OTHER_ERROR";
|
|
140
|
+
constructor({ message, code, }: {
|
|
141
|
+
message: string;
|
|
142
|
+
code: "PASSKEY_PRUNING_UNSUPPORTED" | "OTHER_ERROR";
|
|
143
|
+
});
|
|
144
|
+
static isPruningError: (payload: unknown) => payload is PruningError;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The browser/device was unable to update the local passkey
|
|
148
|
+
*
|
|
149
|
+
* @category Passkeys (errors)
|
|
150
|
+
*/
|
|
151
|
+
export declare const isUpdateError: (payload: unknown) => payload is UpdateError;
|
|
152
|
+
/**
|
|
153
|
+
* The browser/device was unable to update the local passkey
|
|
154
|
+
*
|
|
155
|
+
* @category Passkeys (errors)
|
|
156
|
+
*/
|
|
157
|
+
export declare class UpdateError extends Error {
|
|
158
|
+
readonly _tag: "UpdateError";
|
|
159
|
+
readonly message: string;
|
|
160
|
+
readonly code: "PASSKEY_UPDATE_UNSUPPORTED" | "OTHER_ERROR";
|
|
161
|
+
constructor({ message, code, }: {
|
|
162
|
+
message: string;
|
|
163
|
+
code: "PASSKEY_UPDATE_UNSUPPORTED" | "OTHER_ERROR";
|
|
164
|
+
});
|
|
165
|
+
static isUpdateError: (payload: unknown) => payload is UpdateError;
|
|
23
166
|
}
|
|
24
|
-
export {};
|
|
25
167
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/passkey/errors.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/passkey/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GACpC,SAAS,OAAO,KACf,OAAO,IAAI,uBAIb,CAAA;AAED;;;;;GAKG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,EAAG,oBAAoB,CAAS;IAC7C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;gBAEZ,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;IAK5C,MAAM,CAAC,yBAAyB,YAtBvB,OAAO,KACf,OAAO,IAAI,uBAAuB,CAqByB;CAC7D;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,OAAO,KACf,OAAO,IAAI,oBAIb,CAAA;AAED;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAG,sBAAsB,CAAS;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAA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OAAO,IAAI,YAAY,CAyBjC;CACvC;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,WAI3D,CAAA;AAED;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAG,aAAa,CAAS;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,4BAA4B,GAAG,aAAa,CAAA;gBAE/C,EACV,OAAO,EACP,IAAI,GACL,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,4BAA4B,GAAG,aAAa,CAAA;KAAE;IAM1E,MAAM,CAAC,aAAa,YAzBiB,OAAO,KAAG,OAAO,IAAI,WAAW,CAyBjC;CACrC"}
|
package/dist/passkey/errors.js
CHANGED
|
@@ -1,10 +1,218 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The local device does not support Passkeys.
|
|
3
|
+
* See the message property (string) for more details
|
|
4
|
+
*
|
|
5
|
+
* @category Passkeys (errors)
|
|
6
|
+
*/
|
|
7
|
+
export const isPasskeyUnsupportedError = (payload) => {
|
|
8
|
+
if (typeof payload !== "object")
|
|
9
|
+
return false;
|
|
10
|
+
if (payload === null)
|
|
11
|
+
return false;
|
|
12
|
+
return payload instanceof PasskeyUnsupportedError;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The local device does not support Passkeys.
|
|
16
|
+
* See the message property (string) for more details
|
|
17
|
+
*
|
|
18
|
+
* @category Passkeys (errors)
|
|
19
|
+
*/
|
|
20
|
+
export class PasskeyUnsupportedError extends Error {
|
|
21
|
+
_tag = "PasskeyUnsupported";
|
|
22
|
+
message;
|
|
23
|
+
constructor({ message }) {
|
|
24
|
+
super();
|
|
25
|
+
this.message = message;
|
|
26
|
+
}
|
|
27
|
+
static isPasskeyUnsupportedError = isPasskeyUnsupportedError;
|
|
5
28
|
}
|
|
6
|
-
|
|
7
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Client tried to authenticate with a passkey that was not found in the vault.
|
|
31
|
+
* Note: this error can be passed to the {@link deletePasskey} function. This is
|
|
32
|
+
* useful when the user has an orphaned passkey on their device with no server-side
|
|
33
|
+
* component. Just pass this error into deletePasskey and the library will attempt
|
|
34
|
+
* to remove the orphaned passkey from the local device.
|
|
35
|
+
*
|
|
36
|
+
* @category Passkeys (errors)
|
|
37
|
+
*/
|
|
38
|
+
export const isPasskeyNotFoundError = (payload) => {
|
|
39
|
+
if (typeof payload !== "object")
|
|
40
|
+
return false;
|
|
41
|
+
if (payload === null)
|
|
42
|
+
return false;
|
|
43
|
+
return payload instanceof PasskeyNotFoundError;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Client tried to authenticate with a passkey that was not found in the vault.
|
|
47
|
+
* Note: this error can be passed to the {@link deletePasskey} function. This is
|
|
48
|
+
* useful when the user has an orphaned passkey on their device with no server-side
|
|
49
|
+
* component. Just pass this error into deletePasskey and the library will attempt
|
|
50
|
+
* to remove the orphaned passkey from the local device.
|
|
51
|
+
*
|
|
52
|
+
* @category Passkeys (errors)
|
|
53
|
+
*/
|
|
54
|
+
export class PasskeyNotFoundError extends Error {
|
|
55
|
+
_tag = "PasskeyNotFoundError";
|
|
56
|
+
message;
|
|
57
|
+
credentialId;
|
|
58
|
+
rpId;
|
|
59
|
+
constructor({ message, credentialId, rpId, }) {
|
|
60
|
+
super();
|
|
61
|
+
this.message = message;
|
|
62
|
+
this.credentialId = credentialId;
|
|
63
|
+
this.rpId = rpId;
|
|
64
|
+
}
|
|
65
|
+
static isPasskeyNotFoundError = isPasskeyNotFoundError;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* An unexpected passkey specific error occurred.
|
|
69
|
+
* Check the code and message for more information.
|
|
70
|
+
*
|
|
71
|
+
* @category Passkeys (errors)
|
|
72
|
+
*/
|
|
73
|
+
export const isOtherPasskeyError = (payload) => {
|
|
74
|
+
if (typeof payload !== "object")
|
|
75
|
+
return false;
|
|
76
|
+
if (payload === null)
|
|
77
|
+
return false;
|
|
78
|
+
return payload instanceof OtherPasskeyError;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* An unexpected passkey specific error occurred.
|
|
82
|
+
* Check the code and message for more information.
|
|
83
|
+
*
|
|
84
|
+
* @category Passkeys (errors)
|
|
85
|
+
*/
|
|
86
|
+
export class OtherPasskeyError extends Error {
|
|
87
|
+
_tag = "OtherPasskey";
|
|
88
|
+
error;
|
|
89
|
+
message;
|
|
90
|
+
code;
|
|
91
|
+
cause;
|
|
92
|
+
constructor({ error, message, code, cause, }) {
|
|
93
|
+
super();
|
|
94
|
+
this.error = error;
|
|
95
|
+
this.message = message;
|
|
96
|
+
if (code)
|
|
97
|
+
this.code = code;
|
|
98
|
+
if (cause)
|
|
99
|
+
this.cause = cause;
|
|
100
|
+
}
|
|
8
101
|
static isOtherPasskeyError = isOtherPasskeyError;
|
|
9
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Raised if excludeCredentials was provided and the device
|
|
105
|
+
* recognises one of the excluded passkeys i.e. the user currently
|
|
106
|
+
* has a passkey registered for a given userId.
|
|
107
|
+
*
|
|
108
|
+
* @category Passkeys (errors)
|
|
109
|
+
*/
|
|
110
|
+
export const isDuplicatePasskeyError = (payload) => {
|
|
111
|
+
if (typeof payload !== "object")
|
|
112
|
+
return false;
|
|
113
|
+
if (payload === null)
|
|
114
|
+
return false;
|
|
115
|
+
return payload instanceof DuplicatePasskeyError;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Raised if excludeCredentials was provided and the device
|
|
119
|
+
* recognises one of the excluded passkeys i.e. the user currently
|
|
120
|
+
* has a passkey registered for a given userId.
|
|
121
|
+
*
|
|
122
|
+
* @category Passkeys (errors)
|
|
123
|
+
*/
|
|
124
|
+
export class DuplicatePasskeyError extends Error {
|
|
125
|
+
_tag = "DuplicatePasskeyError";
|
|
126
|
+
message;
|
|
127
|
+
constructor({ message }) {
|
|
128
|
+
super();
|
|
129
|
+
this.message = message;
|
|
130
|
+
}
|
|
131
|
+
static isDuplicatePasskeyError = isDuplicatePasskeyError;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The browser/device was unable to delete the passkey
|
|
135
|
+
*
|
|
136
|
+
* @category Passkeys (errors)
|
|
137
|
+
*/
|
|
138
|
+
export const isDeleteError = (payload) => {
|
|
139
|
+
if (typeof payload !== "object")
|
|
140
|
+
return false;
|
|
141
|
+
if (payload === null)
|
|
142
|
+
return false;
|
|
143
|
+
return payload instanceof DeleteError;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* The browser/device was unable to delete the passkey
|
|
147
|
+
*
|
|
148
|
+
* @category Passkeys (errors)
|
|
149
|
+
*/
|
|
150
|
+
export class DeleteError extends Error {
|
|
151
|
+
_tag = "DeleteError";
|
|
152
|
+
message;
|
|
153
|
+
code;
|
|
154
|
+
constructor({ message, code, }) {
|
|
155
|
+
super();
|
|
156
|
+
this.message = message;
|
|
157
|
+
this.code = code;
|
|
158
|
+
}
|
|
159
|
+
static isDeleteError = isDeleteError;
|
|
160
|
+
}
|
|
161
|
+
/* Pruning error */
|
|
162
|
+
/**
|
|
163
|
+
* The browser/device was unable to prune the passkeys
|
|
164
|
+
*
|
|
165
|
+
* @category Passkeys (errors)
|
|
166
|
+
*/
|
|
167
|
+
export const isPruningError = (payload) => {
|
|
168
|
+
if (typeof payload !== "object")
|
|
169
|
+
return false;
|
|
170
|
+
if (payload === null)
|
|
171
|
+
return false;
|
|
172
|
+
return payload instanceof PruningError;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* The browser/device was unable to prune the passkeys
|
|
176
|
+
*
|
|
177
|
+
* @category Passkeys (errors)
|
|
178
|
+
*/
|
|
179
|
+
export class PruningError extends Error {
|
|
180
|
+
_tag = "PruningError";
|
|
181
|
+
message;
|
|
182
|
+
code;
|
|
183
|
+
constructor({ message, code, }) {
|
|
184
|
+
super();
|
|
185
|
+
this.message = message;
|
|
186
|
+
this.code = code;
|
|
187
|
+
}
|
|
188
|
+
static isPruningError = isPruningError;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The browser/device was unable to update the local passkey
|
|
192
|
+
*
|
|
193
|
+
* @category Passkeys (errors)
|
|
194
|
+
*/
|
|
195
|
+
export const isUpdateError = (payload) => {
|
|
196
|
+
if (typeof payload !== "object")
|
|
197
|
+
return false;
|
|
198
|
+
if (payload === null)
|
|
199
|
+
return false;
|
|
200
|
+
return payload instanceof UpdateError;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* The browser/device was unable to update the local passkey
|
|
204
|
+
*
|
|
205
|
+
* @category Passkeys (errors)
|
|
206
|
+
*/
|
|
207
|
+
export class UpdateError extends Error {
|
|
208
|
+
_tag = "UpdateError";
|
|
209
|
+
message;
|
|
210
|
+
code;
|
|
211
|
+
constructor({ message, code, }) {
|
|
212
|
+
super();
|
|
213
|
+
this.message = message;
|
|
214
|
+
this.code = code;
|
|
215
|
+
}
|
|
216
|
+
static isUpdateError = isUpdateError;
|
|
217
|
+
}
|
|
10
218
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/passkey/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/passkey/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,OAAgB,EACoB,EAAE;IACtC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC7C,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAClC,OAAO,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