@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
|
@@ -1,45 +1,49 @@
|
|
|
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 {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
4
|
+
import { Endpoint, makeEndpoint, makeRequest, TenancyId } from "../../internal";
|
|
5
|
+
import { Logger } from "../../logger";
|
|
6
|
+
import { OrphanedPasskeyError, OtherPasskeyError, 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 {@link 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)
|
|
24
|
-
return false;
|
|
25
|
-
if (!("sessionToken" in payload))
|
|
31
|
+
if (!("_tag" in payload))
|
|
26
32
|
return false;
|
|
27
|
-
if (typeof payload.
|
|
33
|
+
if (typeof payload._tag !== "string")
|
|
28
34
|
return false;
|
|
29
|
-
return
|
|
35
|
+
return payload._tag === AuthenticationSuccessTag;
|
|
30
36
|
};
|
|
31
|
-
export const authenticationEvent = ["optionsRequest", "getCredential", "verifyCredential"];
|
|
32
37
|
export const fetchOptions = (options) => Micro.gen(function* () {
|
|
33
38
|
const logger = yield* Micro.service(Logger);
|
|
34
39
|
const { endpoint } = yield* Micro.service(Endpoint);
|
|
35
40
|
const { tenancyId } = yield* Micro.service(TenancyId);
|
|
36
|
-
const {
|
|
41
|
+
const { userVerification, allowCredentials, timeout, onEvent } = options;
|
|
37
42
|
const url = new URL(`${tenancyId}/passkey/authentication/options`, endpoint);
|
|
38
43
|
onEvent?.("optionsRequest");
|
|
39
44
|
yield* logger.logInfo("Fetching passkey authentication options from Passlock");
|
|
40
45
|
const payload = {
|
|
41
46
|
allowCredentials,
|
|
42
|
-
userId,
|
|
43
47
|
userVerification,
|
|
44
48
|
timeout,
|
|
45
49
|
};
|
|
@@ -50,42 +54,20 @@ export const fetchOptions = (options) => Micro.gen(function* () {
|
|
|
50
54
|
url,
|
|
51
55
|
});
|
|
52
56
|
});
|
|
53
|
-
const
|
|
54
|
-
export const isAuthenticationSuccess = (payload) => {
|
|
57
|
+
export const isOptionsResponse = (payload) => {
|
|
55
58
|
if (typeof payload !== "object")
|
|
56
59
|
return false;
|
|
57
60
|
if (payload === null)
|
|
58
61
|
return false;
|
|
59
|
-
if (!("
|
|
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) => {
|
|
68
|
-
if (typeof payload !== "object")
|
|
69
|
-
return false;
|
|
70
|
-
if (payload === null)
|
|
71
|
-
return false;
|
|
72
|
-
if (!("_tag" in payload))
|
|
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")
|
|
62
|
+
if (!("optionsJSON" in payload))
|
|
81
63
|
return false;
|
|
82
|
-
if (
|
|
64
|
+
if (typeof payload.optionsJSON !== "object")
|
|
83
65
|
return false;
|
|
84
|
-
if (
|
|
66
|
+
if (payload.optionsJSON === null)
|
|
85
67
|
return false;
|
|
86
|
-
if (!("
|
|
68
|
+
if (!("sessionToken" in payload))
|
|
87
69
|
return false;
|
|
88
|
-
if (typeof payload.
|
|
70
|
+
if (typeof payload.sessionToken !== "string")
|
|
89
71
|
return false;
|
|
90
72
|
return true;
|
|
91
73
|
};
|
|
@@ -96,9 +78,9 @@ export const startAuthentication = (optionsJSON, { useBrowserAutofill, onEvent,
|
|
|
96
78
|
const helper = yield* Micro.service(AuthenticationHelper);
|
|
97
79
|
const isSupport = helper.browserSupportsWebAuthn();
|
|
98
80
|
if (!isSupport)
|
|
99
|
-
yield* new PasskeyUnsupportedError({
|
|
81
|
+
yield* Micro.fail(new PasskeyUnsupportedError({
|
|
100
82
|
message: "Device does not support passkeys",
|
|
101
|
-
});
|
|
83
|
+
}));
|
|
102
84
|
return yield* Micro.tryPromise({
|
|
103
85
|
catch: (error) => {
|
|
104
86
|
if (error instanceof WebAuthnError) {
|
|
@@ -116,6 +98,31 @@ export const startAuthentication = (optionsJSON, { useBrowserAutofill, onEvent,
|
|
|
116
98
|
try: () => helper.startAuthentication({ optionsJSON, useBrowserAutofill }),
|
|
117
99
|
});
|
|
118
100
|
});
|
|
101
|
+
const isPasskeyNotFound = (payload) => {
|
|
102
|
+
if (typeof payload !== "object")
|
|
103
|
+
return false;
|
|
104
|
+
if (payload === null)
|
|
105
|
+
return false;
|
|
106
|
+
if (!("_tag" in payload))
|
|
107
|
+
return false;
|
|
108
|
+
if (typeof payload._tag !== "string")
|
|
109
|
+
return false;
|
|
110
|
+
if (payload._tag !== "@error/PasskeyNotFound")
|
|
111
|
+
return false;
|
|
112
|
+
if (!("message" in payload))
|
|
113
|
+
return false;
|
|
114
|
+
if (typeof payload.message !== "string")
|
|
115
|
+
return false;
|
|
116
|
+
if (!("credentialId" in payload))
|
|
117
|
+
return false;
|
|
118
|
+
if (typeof payload.credentialId !== "string")
|
|
119
|
+
return false;
|
|
120
|
+
if (!("rpId" in payload))
|
|
121
|
+
return false;
|
|
122
|
+
if (typeof payload.rpId !== "string")
|
|
123
|
+
return false;
|
|
124
|
+
return true;
|
|
125
|
+
};
|
|
119
126
|
export const verifyCredential = (sessionToken, response, { onEvent }) => Micro.gen(function* () {
|
|
120
127
|
const logger = yield* Micro.service(Logger);
|
|
121
128
|
const { endpoint } = yield* Micro.service(Endpoint);
|
|
@@ -127,25 +134,26 @@ export const verifyCredential = (sessionToken, response, { onEvent }) => Micro.g
|
|
|
127
134
|
response,
|
|
128
135
|
sessionToken,
|
|
129
136
|
};
|
|
130
|
-
const authenticationResponse = yield* makeRequest({
|
|
137
|
+
const authenticationResponse = yield* pipe(makeRequest({
|
|
131
138
|
errorPredicate: isPasskeyNotFound,
|
|
132
139
|
label: "authentication verification",
|
|
133
140
|
payload,
|
|
134
141
|
responsePredicate: isAuthenticationSuccess,
|
|
135
142
|
url,
|
|
136
|
-
});
|
|
143
|
+
}), Micro.catchTag("@error/PasskeyNotFound", (err) => Micro.fail(new OrphanedPasskeyError(err))));
|
|
137
144
|
yield* logger.logInfo(`Passkey with id ${authenticationResponse.principal.authenticatorId} successfully authenticated`);
|
|
138
145
|
return authenticationResponse;
|
|
139
146
|
});
|
|
140
147
|
/**
|
|
141
|
-
* Trigger local passkey authentication then verify the passkey in
|
|
148
|
+
* Trigger local passkey authentication then verify the passkey in your Passlock vault.
|
|
142
149
|
* Returns a code and id_token that can be exchanged/decoded in your backend.
|
|
143
150
|
*
|
|
144
151
|
* @param options
|
|
145
|
-
* @returns
|
|
152
|
+
* @returns A Micro effect that resolves with {@link AuthenticationSuccess} or
|
|
153
|
+
* fails with {@link AuthenticationError}.
|
|
146
154
|
*/
|
|
147
155
|
export const authenticatePasskey = (options) => {
|
|
148
|
-
const endpoint =
|
|
156
|
+
const endpoint = makeEndpoint(options);
|
|
149
157
|
const micro = Micro.gen(function* () {
|
|
150
158
|
const { sessionToken, optionsJSON } = yield* fetchOptions(options);
|
|
151
159
|
const go = (useBrowserAutofill) => Micro.gen(function* () {
|
|
@@ -169,4 +177,14 @@ export const authenticatePasskey = (options) => {
|
|
|
169
177
|
});
|
|
170
178
|
return pipe(micro, Micro.provideService(TenancyId, options), Micro.provideService(Endpoint, endpoint));
|
|
171
179
|
};
|
|
180
|
+
/**
|
|
181
|
+
* Type of the authentication event
|
|
182
|
+
*
|
|
183
|
+
* @category Passkeys (other)
|
|
184
|
+
*/
|
|
185
|
+
export const AuthenticationEvents = [
|
|
186
|
+
"optionsRequest",
|
|
187
|
+
"getCredential",
|
|
188
|
+
"verifyCredential",
|
|
189
|
+
];
|
|
172
190
|
//# sourceMappingURL=authentication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.js","sourceRoot":"","sources":["../../../src/passkey/authentication/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAGL,aAAa,GACd,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7C,OA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C,CAAA;YAE/C,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,mBAAmB,CAAC,WAAW,EAAE;gBACvD,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,kBAAkB;aACnB,CAAC,CAAA;YAEF,OAAO,CAAC,OAAO,EAAE,CAAC,kBAAkB,CAAC,CAAA;YACrC,OAAO,KAAK,CAAC,CAAC,gBAAgB,CAAC,YAAY,EAAE,QAAQ,EAAE;gBACrD,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QAEJ,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACpC,CAAC;aAAM,CAAC;YACN,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;QACzB,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,IAAI,CACT,KAAK,EACL,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,EACxC,KAAK,CAAC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CACzC,CAAA;AACH,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,gBAAgB;IAChB,eAAe;IACf,kBAAkB;CACV,CAAA"}
|
package/dist/passkey/errors.d.ts
CHANGED
|
@@ -1,25 +1,160 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 {
|
|
4
15
|
readonly _tag: "@error/PasskeyUnsupported";
|
|
5
|
-
} & Readonly<A>;
|
|
6
|
-
export declare class PasskeyUnsupportedError extends PasskeyUnsupportedError_base<{
|
|
7
16
|
readonly message: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
17
|
+
constructor({ message }: {
|
|
18
|
+
message: string;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Client tried to authenticate with a passkey that was not found in the vault.
|
|
23
|
+
* Note: this error can be passed to the {@link deletePasskey} function. This is
|
|
24
|
+
* useful when the user has an orphaned passkey on their device with no server-side
|
|
25
|
+
* component. Just pass this error into deletePasskey and the library will attempt
|
|
26
|
+
* to remove the orphaned passkey from the local device.
|
|
27
|
+
*
|
|
28
|
+
* @category Passkeys (errors)
|
|
29
|
+
*/
|
|
30
|
+
export declare const isOrphanedPasskeyError: (payload: unknown) => payload is OrphanedPasskeyError;
|
|
31
|
+
/**
|
|
32
|
+
* Client tried to authenticate with a passkey that was not found in the vault.
|
|
33
|
+
* Note: this error can be passed to the {@link deletePasskey} function. This is
|
|
34
|
+
* useful when the user has an orphaned passkey on their device with no server-side
|
|
35
|
+
* component. Just pass this error into deletePasskey and the library will attempt
|
|
36
|
+
* to remove the orphaned passkey from the local device.
|
|
37
|
+
*
|
|
38
|
+
* @category Passkeys (errors)
|
|
39
|
+
*/
|
|
40
|
+
export declare class OrphanedPasskeyError extends Error {
|
|
41
|
+
readonly _tag: "@error/OrphanedPasskey";
|
|
42
|
+
readonly message: string;
|
|
43
|
+
readonly credentialId: string;
|
|
44
|
+
readonly rpId: string;
|
|
45
|
+
constructor({ message, credentialId, rpId, }: {
|
|
46
|
+
message: string;
|
|
47
|
+
credentialId: string;
|
|
48
|
+
rpId: string;
|
|
49
|
+
});
|
|
10
50
|
}
|
|
11
51
|
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
|
-
|
|
52
|
+
/**
|
|
53
|
+
* An unexpected passkey specific error occurred.
|
|
54
|
+
* Check the code and message for more information.
|
|
55
|
+
*
|
|
56
|
+
* @category Passkeys (errors)
|
|
57
|
+
*/
|
|
58
|
+
export declare const isOtherPasskeyError: (payload: unknown) => payload is OtherPasskeyError;
|
|
59
|
+
/**
|
|
60
|
+
* An unexpected passkey specific error occurred.
|
|
61
|
+
* Check the code and message for more information.
|
|
62
|
+
*
|
|
63
|
+
* @category Passkeys (errors)
|
|
64
|
+
*/
|
|
65
|
+
export declare class OtherPasskeyError extends Error {
|
|
66
|
+
readonly _tag: "@error/OtherPasskey";
|
|
17
67
|
readonly error: unknown;
|
|
18
68
|
readonly message: string;
|
|
19
69
|
readonly code?: ErrorCode;
|
|
20
70
|
readonly cause?: unknown;
|
|
21
|
-
}
|
|
22
|
-
|
|
71
|
+
constructor({ error, message, code, cause, }: {
|
|
72
|
+
error: unknown;
|
|
73
|
+
message: string;
|
|
74
|
+
code?: ErrorCode;
|
|
75
|
+
cause?: unknown;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Raised if excludeCredentials was provided and the device
|
|
80
|
+
* recognises one of the excluded passkeys i.e. the user currently
|
|
81
|
+
* has a passkey registered for a given userId.
|
|
82
|
+
*
|
|
83
|
+
* @category Passkeys (errors)
|
|
84
|
+
*/
|
|
85
|
+
export declare const isDuplicatePasskeyError: (payload: unknown) => payload is DuplicatePasskeyError;
|
|
86
|
+
/**
|
|
87
|
+
* Raised if excludeCredentials was provided and the device
|
|
88
|
+
* recognises one of the excluded passkeys i.e. the user currently
|
|
89
|
+
* has a passkey registered for a given userId.
|
|
90
|
+
*
|
|
91
|
+
* @category Passkeys (errors)
|
|
92
|
+
*/
|
|
93
|
+
export declare class DuplicatePasskeyError extends Error {
|
|
94
|
+
readonly _tag: "@error/DuplicatePasskey";
|
|
95
|
+
readonly message: string;
|
|
96
|
+
constructor({ message }: {
|
|
97
|
+
message: string;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The browser/device was unable to delete the passkey
|
|
102
|
+
*
|
|
103
|
+
* @category Passkeys (errors)
|
|
104
|
+
*/
|
|
105
|
+
export declare const isDeleteError: (payload: unknown) => payload is DeleteError;
|
|
106
|
+
/**
|
|
107
|
+
* The browser/device was unable to delete the passkey
|
|
108
|
+
*
|
|
109
|
+
* @category Passkeys (errors)
|
|
110
|
+
*/
|
|
111
|
+
export declare class DeleteError extends Error {
|
|
112
|
+
readonly _tag: "@error/Delete";
|
|
113
|
+
readonly message: string;
|
|
114
|
+
readonly code: "PASSKEY_DELETION_UNSUPPORTED" | "PASSKEY_NOT_FOUND" | "OTHER_ERROR";
|
|
115
|
+
constructor({ message, code, }: {
|
|
116
|
+
message: string;
|
|
117
|
+
code: "PASSKEY_DELETION_UNSUPPORTED" | "PASSKEY_NOT_FOUND" | "OTHER_ERROR";
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The browser/device was unable to prune the passkeys
|
|
122
|
+
*
|
|
123
|
+
* @category Passkeys (errors)
|
|
124
|
+
*/
|
|
125
|
+
export declare const isPruningError: (payload: unknown) => payload is PruningError;
|
|
126
|
+
/**
|
|
127
|
+
* The browser/device was unable to prune the passkeys
|
|
128
|
+
*
|
|
129
|
+
* @category Passkeys (errors)
|
|
130
|
+
*/
|
|
131
|
+
export declare class PruningError extends Error {
|
|
132
|
+
readonly _tag: "@error/Pruning";
|
|
133
|
+
readonly message: string;
|
|
134
|
+
readonly code: "PASSKEY_PRUNING_UNSUPPORTED" | "OTHER_ERROR";
|
|
135
|
+
constructor({ message, code, }: {
|
|
136
|
+
message: string;
|
|
137
|
+
code: "PASSKEY_PRUNING_UNSUPPORTED" | "OTHER_ERROR";
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The browser/device was unable to update the local passkey
|
|
142
|
+
*
|
|
143
|
+
* @category Passkeys (errors)
|
|
144
|
+
*/
|
|
145
|
+
export declare const isUpdateError: (payload: unknown) => payload is UpdateError;
|
|
146
|
+
/**
|
|
147
|
+
* The browser/device was unable to update the local passkey
|
|
148
|
+
*
|
|
149
|
+
* @category Passkeys (errors)
|
|
150
|
+
*/
|
|
151
|
+
export declare class UpdateError extends Error {
|
|
152
|
+
readonly _tag: "@error/Update";
|
|
153
|
+
readonly message: string;
|
|
154
|
+
readonly code: "PASSKEY_UPDATE_UNSUPPORTED" | "OTHER_ERROR";
|
|
155
|
+
constructor({ message, code, }: {
|
|
156
|
+
message: string;
|
|
157
|
+
code: "PASSKEY_UPDATE_UNSUPPORTED" | "OTHER_ERROR";
|
|
158
|
+
});
|
|
23
159
|
}
|
|
24
|
-
export {};
|
|
25
160
|
//# 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":"AA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,EAAG,gBAAgB,CAAS;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,6BAA6B,GAAG,aAAa,CAAA;gBAEhD,EACV,OAAO,EACP,IAAI,GACL,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,6BAA6B,GAAG,aAAa,CAAA;KAAE;CAK5E;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,eAAe,CAAS;IACxC,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;CAK3E"}
|
package/dist/passkey/errors.js
CHANGED
|
@@ -1,10 +1,211 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
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 = "@error/PasskeyUnsupported";
|
|
22
|
+
message;
|
|
23
|
+
constructor({ message }) {
|
|
24
|
+
super();
|
|
25
|
+
this.message = message;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Client tried to authenticate with a passkey that was not found in the vault.
|
|
30
|
+
* Note: this error can be passed to the {@link deletePasskey} function. This is
|
|
31
|
+
* useful when the user has an orphaned passkey on their device with no server-side
|
|
32
|
+
* component. Just pass this error into deletePasskey and the library will attempt
|
|
33
|
+
* to remove the orphaned passkey from the local device.
|
|
34
|
+
*
|
|
35
|
+
* @category Passkeys (errors)
|
|
36
|
+
*/
|
|
37
|
+
export const isOrphanedPasskeyError = (payload) => {
|
|
38
|
+
if (typeof payload !== "object")
|
|
39
|
+
return false;
|
|
40
|
+
if (payload === null)
|
|
41
|
+
return false;
|
|
42
|
+
return payload instanceof OrphanedPasskeyError;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Client tried to authenticate with a passkey that was not found in the vault.
|
|
46
|
+
* Note: this error can be passed to the {@link deletePasskey} function. This is
|
|
47
|
+
* useful when the user has an orphaned passkey on their device with no server-side
|
|
48
|
+
* component. Just pass this error into deletePasskey and the library will attempt
|
|
49
|
+
* to remove the orphaned passkey from the local device.
|
|
50
|
+
*
|
|
51
|
+
* @category Passkeys (errors)
|
|
52
|
+
*/
|
|
53
|
+
export class OrphanedPasskeyError extends Error {
|
|
54
|
+
_tag = "@error/OrphanedPasskey";
|
|
55
|
+
message;
|
|
56
|
+
credentialId;
|
|
57
|
+
rpId;
|
|
58
|
+
constructor({ message, credentialId, rpId, }) {
|
|
59
|
+
super();
|
|
60
|
+
this.message = message;
|
|
61
|
+
this.credentialId = credentialId;
|
|
62
|
+
this.rpId = rpId;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* An unexpected passkey specific error occurred.
|
|
67
|
+
* Check the code and message for more information.
|
|
68
|
+
*
|
|
69
|
+
* @category Passkeys (errors)
|
|
70
|
+
*/
|
|
71
|
+
export const isOtherPasskeyError = (payload) => {
|
|
72
|
+
if (typeof payload !== "object")
|
|
73
|
+
return false;
|
|
74
|
+
if (payload === null)
|
|
75
|
+
return false;
|
|
76
|
+
return payload instanceof OtherPasskeyError;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* An unexpected passkey specific error occurred.
|
|
80
|
+
* Check the code and message for more information.
|
|
81
|
+
*
|
|
82
|
+
* @category Passkeys (errors)
|
|
83
|
+
*/
|
|
84
|
+
export class OtherPasskeyError extends Error {
|
|
85
|
+
_tag = "@error/OtherPasskey";
|
|
86
|
+
error;
|
|
87
|
+
message;
|
|
88
|
+
code;
|
|
89
|
+
cause;
|
|
90
|
+
constructor({ error, message, code, cause, }) {
|
|
91
|
+
super();
|
|
92
|
+
this.error = error;
|
|
93
|
+
this.message = message;
|
|
94
|
+
if (code)
|
|
95
|
+
this.code = code;
|
|
96
|
+
if (cause)
|
|
97
|
+
this.cause = cause;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Raised if excludeCredentials was provided and the device
|
|
102
|
+
* recognises one of the excluded passkeys i.e. the user currently
|
|
103
|
+
* has a passkey registered for a given userId.
|
|
104
|
+
*
|
|
105
|
+
* @category Passkeys (errors)
|
|
106
|
+
*/
|
|
107
|
+
export const isDuplicatePasskeyError = (payload) => {
|
|
108
|
+
if (typeof payload !== "object")
|
|
109
|
+
return false;
|
|
110
|
+
if (payload === null)
|
|
111
|
+
return false;
|
|
112
|
+
return payload instanceof DuplicatePasskeyError;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Raised if excludeCredentials was provided and the device
|
|
116
|
+
* recognises one of the excluded passkeys i.e. the user currently
|
|
117
|
+
* has a passkey registered for a given userId.
|
|
118
|
+
*
|
|
119
|
+
* @category Passkeys (errors)
|
|
120
|
+
*/
|
|
121
|
+
export class DuplicatePasskeyError extends Error {
|
|
122
|
+
_tag = "@error/DuplicatePasskey";
|
|
123
|
+
message;
|
|
124
|
+
constructor({ message }) {
|
|
125
|
+
super();
|
|
126
|
+
this.message = message;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The browser/device was unable to delete the passkey
|
|
131
|
+
*
|
|
132
|
+
* @category Passkeys (errors)
|
|
133
|
+
*/
|
|
134
|
+
export const isDeleteError = (payload) => {
|
|
135
|
+
if (typeof payload !== "object")
|
|
136
|
+
return false;
|
|
137
|
+
if (payload === null)
|
|
138
|
+
return false;
|
|
139
|
+
return payload instanceof DeleteError;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* The browser/device was unable to delete the passkey
|
|
143
|
+
*
|
|
144
|
+
* @category Passkeys (errors)
|
|
145
|
+
*/
|
|
146
|
+
export class DeleteError extends Error {
|
|
147
|
+
_tag = "@error/Delete";
|
|
148
|
+
message;
|
|
149
|
+
code;
|
|
150
|
+
constructor({ message, code, }) {
|
|
151
|
+
super();
|
|
152
|
+
this.message = message;
|
|
153
|
+
this.code = code;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/* Pruning error */
|
|
157
|
+
/**
|
|
158
|
+
* The browser/device was unable to prune the passkeys
|
|
159
|
+
*
|
|
160
|
+
* @category Passkeys (errors)
|
|
161
|
+
*/
|
|
162
|
+
export const isPruningError = (payload) => {
|
|
163
|
+
if (typeof payload !== "object")
|
|
164
|
+
return false;
|
|
165
|
+
if (payload === null)
|
|
166
|
+
return false;
|
|
167
|
+
return payload instanceof PruningError;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* The browser/device was unable to prune the passkeys
|
|
171
|
+
*
|
|
172
|
+
* @category Passkeys (errors)
|
|
173
|
+
*/
|
|
174
|
+
export class PruningError extends Error {
|
|
175
|
+
_tag = "@error/Pruning";
|
|
176
|
+
message;
|
|
177
|
+
code;
|
|
178
|
+
constructor({ message, code, }) {
|
|
179
|
+
super();
|
|
180
|
+
this.message = message;
|
|
181
|
+
this.code = code;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The browser/device was unable to update the local passkey
|
|
186
|
+
*
|
|
187
|
+
* @category Passkeys (errors)
|
|
188
|
+
*/
|
|
189
|
+
export const isUpdateError = (payload) => {
|
|
190
|
+
if (typeof payload !== "object")
|
|
191
|
+
return false;
|
|
192
|
+
if (payload === null)
|
|
193
|
+
return false;
|
|
194
|
+
return payload instanceof UpdateError;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* The browser/device was unable to update the local passkey
|
|
198
|
+
*
|
|
199
|
+
* @category Passkeys (errors)
|
|
200
|
+
*/
|
|
201
|
+
export class UpdateError extends Error {
|
|
202
|
+
_tag = "@error/Update";
|
|
203
|
+
message;
|
|
204
|
+
code;
|
|
205
|
+
constructor({ message, code, }) {
|
|
206
|
+
super();
|
|
207
|
+
this.message = message;
|
|
208
|
+
this.code = code;
|
|
209
|
+
}
|
|
9
210
|
}
|
|
10
211
|
//# 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,
|
|
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,OAAO,YAAY,uBAAuB,CAAA;AACnD,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACv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