@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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import * as Helper from "@simplewebauthn/browser";
|
|
2
|
+
import { type PublicKeyCredentialCreationOptionsJSON, type RegistrationResponseJSON } from "@simplewebauthn/browser";
|
|
3
|
+
import { Micro } from "effect";
|
|
4
|
+
import type { Principal } from "src/principal";
|
|
5
|
+
import { Endpoint, TenancyId } from "../../internal";
|
|
6
|
+
import type { NetworkError } from "../../internal/network";
|
|
7
|
+
import { Logger } from "../../logger";
|
|
8
|
+
import type { PasslockOptions } from "../../options";
|
|
9
|
+
import { DuplicatePasskeyError, OtherPasskeyError, PasskeyUnsupportedError } from "../errors";
|
|
10
|
+
import type { Millis, UserVerification } from "../shared";
|
|
11
|
+
/**
|
|
12
|
+
* Passkey registration options
|
|
13
|
+
*
|
|
14
|
+
* @see {@link registerPasskey}
|
|
15
|
+
*
|
|
16
|
+
* @category Passkeys (core)
|
|
17
|
+
*/
|
|
18
|
+
export interface RegistrationOptions extends PasslockOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Username associated with passkey. Will be shown by the device during
|
|
21
|
+
* registration and subsequent authentication. The value used should be
|
|
22
|
+
* meaningful to the user e.g. jdoe or jdoe@gmail.com vs 5487546.
|
|
23
|
+
*
|
|
24
|
+
* You won't directly associate the username with an account in your
|
|
25
|
+
* backend. Instead, you'll associate the passkey ID with an account.
|
|
26
|
+
*
|
|
27
|
+
* @see {@link https://passlock.dev/passkeys/registration Register a passkey (main docs)}
|
|
28
|
+
*/
|
|
29
|
+
username: string;
|
|
30
|
+
/**
|
|
31
|
+
* May be shown by devices in place of the username e.g. given a username
|
|
32
|
+
* of jdoe or jdoe@gmail.com a suitable display name might be "John Doe"
|
|
33
|
+
* or "John Doe (personal)". **note:** There's no guarantee browsers/devices
|
|
34
|
+
* will choose to display this property.
|
|
35
|
+
*/
|
|
36
|
+
userDisplayName?: string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Prevents the user registering a passkey if they already have one
|
|
39
|
+
* (associated with the same user account) registered on the current device.
|
|
40
|
+
*
|
|
41
|
+
* @see {@link https://passlock.dev/passkeys/exclude-credentials Excluding credentials (main docs)}
|
|
42
|
+
*/
|
|
43
|
+
excludeCredentials?: Array<string> | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the device should re-authenticate the user locally before registering the passkey.
|
|
46
|
+
*
|
|
47
|
+
* @see {@link https://passlock.dev/passkeys/user-verification User verification (main docs)}
|
|
48
|
+
*/
|
|
49
|
+
userVerification?: UserVerification | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Receive notifications about key stages in the registration process.
|
|
52
|
+
* For example, you might use event notifications to toggle loading icons or
|
|
53
|
+
* to disable certain form fields.
|
|
54
|
+
*/
|
|
55
|
+
onEvent?: OnRegistrationEvent;
|
|
56
|
+
/**
|
|
57
|
+
* Abort the operation after N milliseconds
|
|
58
|
+
*/
|
|
59
|
+
timeout?: Millis | undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Represents the outcome of a successful passkey registration.
|
|
63
|
+
* Submit the `code` and/or `id_token` to your backend, then either
|
|
64
|
+
* exchange the code with the Passlock REST API or decode and
|
|
65
|
+
* verify the id_token (JWT). **note:** The @passlock/node library
|
|
66
|
+
* includes utilities for this.
|
|
67
|
+
*
|
|
68
|
+
* @see {@link isRegistrationSuccess}
|
|
69
|
+
*
|
|
70
|
+
* @category Passkeys (core)
|
|
71
|
+
*/
|
|
72
|
+
export type RegistrationSuccess = {
|
|
73
|
+
/**
|
|
74
|
+
* Discriminator for use in a discriminated union.
|
|
75
|
+
*/
|
|
76
|
+
_tag: "RegistrationSuccess";
|
|
77
|
+
principal: Principal;
|
|
78
|
+
/**
|
|
79
|
+
* A signed JWT representing the newly registered passkey.
|
|
80
|
+
* Decode and verify this in your backend or use one of the @passlock/node
|
|
81
|
+
* helper utilities.
|
|
82
|
+
*
|
|
83
|
+
* @see {@link https://passlock.dev/principal/idtoken-verification/|id_token}
|
|
84
|
+
*/
|
|
85
|
+
id_token: string;
|
|
86
|
+
/**
|
|
87
|
+
* Call the Passlock API to exchange this code for details about the newly
|
|
88
|
+
* registered passkey.
|
|
89
|
+
*
|
|
90
|
+
* @see {@link https://passlock.dev/principal/code-exchange/|code exchange}
|
|
91
|
+
*/
|
|
92
|
+
code: string;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Type guard to test for a {@link RegistrationSuccess}. Typically used to test the
|
|
96
|
+
* object returned from {@link registerPasskey}
|
|
97
|
+
*
|
|
98
|
+
* @param payload
|
|
99
|
+
* @returns `true` if the payload is a {@link RegistrationSuccess}.
|
|
100
|
+
*
|
|
101
|
+
* @category Passkeys (other)
|
|
102
|
+
*/
|
|
103
|
+
export declare const isRegistrationSuccess: (payload: unknown) => payload is RegistrationSuccess;
|
|
104
|
+
export type OptionsResponse = {
|
|
105
|
+
sessionToken: string;
|
|
106
|
+
optionsJSON: PublicKeyCredentialCreationOptionsJSON;
|
|
107
|
+
};
|
|
108
|
+
export declare const isOptionsResponse: (payload: unknown) => payload is OptionsResponse;
|
|
109
|
+
export declare const fetchOptions: (options: Omit<RegistrationOptions, keyof PasslockOptions>) => Micro.Micro<OptionsResponse, NetworkError, Endpoint | TenancyId | Logger>;
|
|
110
|
+
export declare const startRegistration: (optionsJSON: PublicKeyCredentialCreationOptionsJSON, { onEvent }: {
|
|
111
|
+
onEvent?: OnRegistrationEvent | undefined;
|
|
112
|
+
}) => Micro.Micro<Helper.RegistrationResponseJSON, PasskeyUnsupportedError | OtherPasskeyError | DuplicatePasskeyError, Logger | RegistrationHelper>;
|
|
113
|
+
export declare const verifyCredential: (sessionToken: string, response: RegistrationResponseJSON, { onEvent }: {
|
|
114
|
+
onEvent?: OnRegistrationEvent | undefined;
|
|
115
|
+
}) => Micro.Micro<RegistrationSuccess, NetworkError, Endpoint | TenancyId | Logger>;
|
|
116
|
+
/**
|
|
117
|
+
* Potential errors associated with Passkey registration
|
|
118
|
+
*
|
|
119
|
+
* @category Passkeys (errors)
|
|
120
|
+
*/
|
|
121
|
+
export type RegistrationError = PasskeyUnsupportedError | DuplicatePasskeyError | OtherPasskeyError | NetworkError;
|
|
122
|
+
/**
|
|
123
|
+
* Trigger local passkey registration then save the passkey in your Passlock vault.
|
|
124
|
+
* Returns a code and id_token that can be exchanged/decoded in your backend.
|
|
125
|
+
*
|
|
126
|
+
* @param options
|
|
127
|
+
* @returns A Micro effect that resolves with {@link RegistrationSuccess} or
|
|
128
|
+
* fails with {@link RegistrationError}.
|
|
129
|
+
*/
|
|
130
|
+
export declare const registerPasskey: (options: RegistrationOptions) => Micro.Micro<RegistrationSuccess, RegistrationError, Logger | RegistrationHelper>;
|
|
131
|
+
/**
|
|
132
|
+
* Type of the registration event
|
|
133
|
+
*
|
|
134
|
+
* @category Passkeys (other)
|
|
135
|
+
*/
|
|
136
|
+
export declare const RegistrationEvents: readonly ["optionsRequest", "createCredential", "saveCredential"];
|
|
137
|
+
/**
|
|
138
|
+
* Type of the registration event
|
|
139
|
+
*
|
|
140
|
+
* @category Passkeys (other)
|
|
141
|
+
*/
|
|
142
|
+
export type RegistrationEvent = "optionsRequest" | "createCredential" | "saveCredential";
|
|
143
|
+
/**
|
|
144
|
+
* Callback to receive registration lifecycle events.
|
|
145
|
+
*
|
|
146
|
+
* @category Passkeys (other)
|
|
147
|
+
*/
|
|
148
|
+
export type OnRegistrationEvent = (event: RegistrationEvent) => void;
|
|
149
|
+
//# sourceMappingURL=registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../src/passkey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,CAAA"}
|
|
@@ -1,26 +1,40 @@
|
|
|
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 { DuplicatePasskeyError, OtherPasskeyError, PasskeyUnsupportedError, } from "../errors";
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
8
11
|
export class RegistrationHelper extends Context.Tag("RegistrationHelper")() {
|
|
9
12
|
static Default = {
|
|
10
13
|
browserSupportsWebAuthn: Helper.browserSupportsWebAuthn,
|
|
11
14
|
startRegistration: Helper.startRegistration,
|
|
12
15
|
};
|
|
13
16
|
}
|
|
14
|
-
export const isDuplicatePasskey = (err) => err instanceof DuplicatePasskeyError;
|
|
15
17
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
18
|
+
* Type guard to test for a {@link RegistrationSuccess}. Typically used to test the
|
|
19
|
+
* object returned from {@link registerPasskey}
|
|
20
|
+
*
|
|
21
|
+
* @param payload
|
|
22
|
+
* @returns `true` if the payload is a {@link RegistrationSuccess}.
|
|
23
|
+
*
|
|
24
|
+
* @category Passkeys (other)
|
|
19
25
|
*/
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
export const isRegistrationSuccess = (payload) => {
|
|
27
|
+
if (typeof payload !== "object")
|
|
28
|
+
return false;
|
|
29
|
+
if (payload === null)
|
|
30
|
+
return false;
|
|
31
|
+
if (!("_tag" in payload))
|
|
32
|
+
return false;
|
|
33
|
+
if (typeof payload._tag !== "string")
|
|
34
|
+
return false;
|
|
35
|
+
return payload._tag === "RegistrationSuccess";
|
|
36
|
+
};
|
|
37
|
+
export const isOptionsResponse = (payload) => {
|
|
24
38
|
if (typeof payload !== "object")
|
|
25
39
|
return false;
|
|
26
40
|
if (payload === null)
|
|
@@ -37,12 +51,11 @@ const isOptionsResponse = (payload) => {
|
|
|
37
51
|
return false;
|
|
38
52
|
return true;
|
|
39
53
|
};
|
|
40
|
-
export const registrationEvent = ["optionsRequest", "createCredential", "saveCredential"];
|
|
41
54
|
export const fetchOptions = (options) => Micro.gen(function* () {
|
|
42
55
|
const logger = yield* Micro.service(Logger);
|
|
43
56
|
const { endpoint } = yield* Micro.service(Endpoint);
|
|
44
57
|
const { tenancyId } = yield* Micro.service(TenancyId);
|
|
45
|
-
const { username, userDisplayName,
|
|
58
|
+
const { username, userDisplayName, excludeCredentials, userVerification, timeout, onEvent, } = options;
|
|
46
59
|
const url = new URL(`${tenancyId}/passkey/registration/options`, endpoint);
|
|
47
60
|
onEvent?.("optionsRequest");
|
|
48
61
|
yield* logger.logInfo("Fetching passkey registration options from Passlock");
|
|
@@ -50,7 +63,6 @@ export const fetchOptions = (options) => Micro.gen(function* () {
|
|
|
50
63
|
excludeCredentials,
|
|
51
64
|
timeout,
|
|
52
65
|
userDisplayName,
|
|
53
|
-
userId,
|
|
54
66
|
username,
|
|
55
67
|
userVerification,
|
|
56
68
|
};
|
|
@@ -61,20 +73,6 @@ export const fetchOptions = (options) => Micro.gen(function* () {
|
|
|
61
73
|
url,
|
|
62
74
|
});
|
|
63
75
|
});
|
|
64
|
-
const RegistrationSuccessTag = "RegistrationSuccess";
|
|
65
|
-
export const isRegistrationSuccess = (payload) => {
|
|
66
|
-
if (typeof payload !== "object")
|
|
67
|
-
return false;
|
|
68
|
-
if (payload === null)
|
|
69
|
-
return false;
|
|
70
|
-
if (!("_tag" in payload))
|
|
71
|
-
return false;
|
|
72
|
-
if (typeof payload._tag !== "string")
|
|
73
|
-
return false;
|
|
74
|
-
if (payload._tag !== RegistrationSuccessTag)
|
|
75
|
-
return false;
|
|
76
|
-
return true;
|
|
77
|
-
};
|
|
78
76
|
export const startRegistration = (optionsJSON, { onEvent }) => Micro.gen(function* () {
|
|
79
77
|
onEvent?.("createCredential");
|
|
80
78
|
const logger = yield* Micro.service(Logger);
|
|
@@ -82,10 +80,11 @@ export const startRegistration = (optionsJSON, { onEvent }) => Micro.gen(functio
|
|
|
82
80
|
const helper = yield* Micro.service(RegistrationHelper);
|
|
83
81
|
const isSupport = helper.browserSupportsWebAuthn();
|
|
84
82
|
if (!isSupport)
|
|
85
|
-
yield* new PasskeyUnsupportedError({
|
|
83
|
+
yield* Micro.fail(new PasskeyUnsupportedError({
|
|
86
84
|
message: "Device does not support passkeys",
|
|
87
|
-
});
|
|
85
|
+
}));
|
|
88
86
|
return yield* Micro.tryPromise({
|
|
87
|
+
try: () => helper.startRegistration({ optionsJSON }),
|
|
89
88
|
catch: (error) => {
|
|
90
89
|
if (error instanceof WebAuthnError &&
|
|
91
90
|
error.code === "ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED") {
|
|
@@ -102,7 +101,6 @@ export const startRegistration = (optionsJSON, { onEvent }) => Micro.gen(functio
|
|
|
102
101
|
return new OtherPasskeyError({ error, message: "Unexpected error" });
|
|
103
102
|
}
|
|
104
103
|
},
|
|
105
|
-
try: () => helper.startRegistration({ optionsJSON }),
|
|
106
104
|
});
|
|
107
105
|
});
|
|
108
106
|
export const verifyCredential = (sessionToken, response, { onEvent }) => Micro.gen(function* () {
|
|
@@ -126,13 +124,15 @@ export const verifyCredential = (sessionToken, response, { onEvent }) => Micro.g
|
|
|
126
124
|
return registrationResponse;
|
|
127
125
|
});
|
|
128
126
|
/**
|
|
129
|
-
*
|
|
130
|
-
*
|
|
127
|
+
* Trigger local passkey registration then save the passkey in your Passlock vault.
|
|
128
|
+
* Returns a code and id_token that can be exchanged/decoded in your backend.
|
|
129
|
+
*
|
|
131
130
|
* @param options
|
|
132
|
-
* @returns
|
|
131
|
+
* @returns A Micro effect that resolves with {@link RegistrationSuccess} or
|
|
132
|
+
* fails with {@link RegistrationError}.
|
|
133
133
|
*/
|
|
134
134
|
export const registerPasskey = (options) => {
|
|
135
|
-
const endpoint =
|
|
135
|
+
const endpoint = makeEndpoint(options);
|
|
136
136
|
const effect = Micro.gen(function* () {
|
|
137
137
|
const { sessionToken, optionsJSON } = yield* fetchOptions(options);
|
|
138
138
|
const response = yield* startRegistration(optionsJSON, {
|
|
@@ -144,4 +144,14 @@ export const registerPasskey = (options) => {
|
|
|
144
144
|
});
|
|
145
145
|
return pipe(effect, Micro.provideService(TenancyId, options), Micro.provideService(Endpoint, endpoint));
|
|
146
146
|
};
|
|
147
|
+
/**
|
|
148
|
+
* Type of the registration event
|
|
149
|
+
*
|
|
150
|
+
* @category Passkeys (other)
|
|
151
|
+
*/
|
|
152
|
+
export const RegistrationEvents = [
|
|
153
|
+
"optionsRequest",
|
|
154
|
+
"createCredential",
|
|
155
|
+
"saveCredential",
|
|
156
|
+
];
|
|
147
157
|
//# sourceMappingURL=registration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../src/passkey/registration/registration.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,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/E,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,WAAW,CAAA;AA2DlB;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAMtE;IACD,MAAM,CAAC,OAAO,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,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,OAAO,IAAI,CACT,MAAM,EACN,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,kBAAkB,GAAG;IAChC,gBAAgB;IAChB,kBAAkB;IAClB,gBAAgB;CACR,CAAA"}
|
package/dist/passkey/shared.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://w3c.github.io/webauthn/#user-verification
|
|
3
|
+
*
|
|
4
|
+
* @see {@link https://passlock.dev/passkeys/user-verification/ User verification (main docs site)}
|
|
5
|
+
*
|
|
6
|
+
* @category Passkeys (core)
|
|
7
|
+
*/
|
|
1
8
|
export type UserVerification = "discouraged" | "preferred" | "required";
|
|
2
9
|
/**
|
|
3
10
|
* https://w3c.github.io/webauthn/#enumdef-publickeycredentialhint
|
|
@@ -10,7 +17,7 @@ export type AttestationFormat = "fido-u2f" | "packed" | "android-safetynet" | "a
|
|
|
10
17
|
/**
|
|
11
18
|
* https://w3c.github.io/webauthn/#dictdef-publickeycredentialcreationoptionsjson
|
|
12
19
|
*/
|
|
13
|
-
export
|
|
20
|
+
export type PublicKeyCredentialCreationOptionsJSON = {
|
|
14
21
|
rp: PublicKeyCredentialRpEntity;
|
|
15
22
|
user: PublicKeyCredentialUserEntityJSON;
|
|
16
23
|
challenge: Base64URLString;
|
|
@@ -22,5 +29,6 @@ export interface PublicKeyCredentialCreationOptionsJSON {
|
|
|
22
29
|
attestation?: AttestationConveyancePreference;
|
|
23
30
|
attestationFormats?: Array<AttestationFormat>;
|
|
24
31
|
extensions?: AuthenticationExtensionsClientInputs;
|
|
25
|
-
}
|
|
32
|
+
};
|
|
33
|
+
export type Millis = number;
|
|
26
34
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/passkey/shared.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,WAAW,GAAG,UAAU,CAAA;AAEvE;;GAEG;AACH,MAAM,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/passkey/shared.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,WAAW,GAAG,UAAU,CAAA;AAEvE;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAC/B,QAAQ,GACR,cAAc,GACd,eAAe,CAAA;AAEnB;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,QAAQ,GACR,mBAAmB,GACnB,aAAa,GACb,KAAK,GACL,OAAO,GACP,MAAM,CAAA;AAEV;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,EAAE,EAAE,2BAA2B,CAAA;IAC/B,IAAI,EAAE,iCAAiC,CAAA;IACvC,SAAS,EAAE,eAAe,CAAA;IAC1B,gBAAgB,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAA;IACtD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kBAAkB,CAAC,EAAE,KAAK,CAAC,iCAAiC,CAAC,CAAA;IAC7D,sBAAsB,CAAC,EAAE,8BAA8B,CAAA;IACvD,KAAK,CAAC,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAA;IACtC,WAAW,CAAC,EAAE,+BAA+B,CAAA;IAC7C,kBAAkB,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAC7C,UAAU,CAAC,EAAE,oCAAoC,CAAA;CAClD,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Micro } from "effect";
|
|
2
|
+
import { Logger } from "../../logger";
|
|
3
|
+
import type { PasslockOptions } from "../../options";
|
|
4
|
+
import { DeleteError, type OrphanedPasskeyError, PruningError, UpdateError } from "../errors";
|
|
5
|
+
/**
|
|
6
|
+
* Does the current device support local passkey removal
|
|
7
|
+
*/
|
|
8
|
+
export declare const isPasskeyDeleteSupport: Micro.Micro<boolean, never, never>;
|
|
9
|
+
/**
|
|
10
|
+
* Does the current device support local passkey pruning
|
|
11
|
+
*/
|
|
12
|
+
export declare const isPasskeyPruningSupport: Micro.Micro<boolean, never, never>;
|
|
13
|
+
/**
|
|
14
|
+
* Does the current device support local passkey updates
|
|
15
|
+
*/
|
|
16
|
+
export declare const isPasskeyUpdateSupport: Micro.Micro<boolean, never, never>;
|
|
17
|
+
export interface DeletePasskeyOptions extends PasslockOptions {
|
|
18
|
+
passkeyId: string;
|
|
19
|
+
}
|
|
20
|
+
export interface DeleteCredentialOptions extends PasslockOptions {
|
|
21
|
+
credentialId: string;
|
|
22
|
+
userId: string;
|
|
23
|
+
rpId: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Instruct the device to remove a passkey. E.g. attempt to remove it from
|
|
27
|
+
* Apple Password Manager / iCloud.
|
|
28
|
+
*
|
|
29
|
+
* @param options Passkey identifier/credential details and Passlock tenancy options.
|
|
30
|
+
* @returns A Micro effect that resolves with a {@link DeleteSuccess} or fails with {@link DeleteError}.
|
|
31
|
+
*/
|
|
32
|
+
export declare const deletePasskey: (options: DeletePasskeyOptions | DeleteCredentialOptions | OrphanedPasskeyError) => Micro.Micro<DeleteSuccess, DeleteError, Logger>;
|
|
33
|
+
export interface PrunePasskeyOptions extends PasslockOptions {
|
|
34
|
+
allowablePasskeyIds: Array<string>;
|
|
35
|
+
}
|
|
36
|
+
export type PruningSuccess = {
|
|
37
|
+
_tag: "PruningSuccess";
|
|
38
|
+
};
|
|
39
|
+
export declare const isPruningSuccess: (payload: unknown) => payload is PruningSuccess;
|
|
40
|
+
/**
|
|
41
|
+
* Given a list of passkey IDs, instruct the device to remove any redundant passkeys.
|
|
42
|
+
*
|
|
43
|
+
* Note: this will only remove redundant passkeys (based on the userId).
|
|
44
|
+
*
|
|
45
|
+
* For example:
|
|
46
|
+
*
|
|
47
|
+
* The user has two passkeys registered against the jdoe@gmail.com account: passkey1
|
|
48
|
+
* and passkey2. The user has another passkey (passkey3) registered against the
|
|
49
|
+
* jdoe@work.com account.
|
|
50
|
+
*
|
|
51
|
+
* If you pass in the id for passkey1, the device will recognise it's assigned to the
|
|
52
|
+
* jdoe@gmail.com account and remove passkey2. However as passkey3 is registered to a
|
|
53
|
+
* different account, the device will retain it.
|
|
54
|
+
*
|
|
55
|
+
* @param options Passlock tenancy/endpoint options and the passkey IDs to keep.
|
|
56
|
+
* @returns A Micro effect that resolves with a {@link PruningSuccess} or fails with {@link PruningError}.
|
|
57
|
+
*/
|
|
58
|
+
export declare const prunePasskeys: (options: PrunePasskeyOptions) => Micro.Micro<PruningSuccess, PruningError, Logger>;
|
|
59
|
+
/**
|
|
60
|
+
* Used when you want to update a local device passkey by Passkey ID aka authenticatorId.
|
|
61
|
+
*
|
|
62
|
+
* @see {@link updatePasskey}
|
|
63
|
+
*
|
|
64
|
+
* @category Passkeys (core)
|
|
65
|
+
*/
|
|
66
|
+
export interface UpdatePasskeyOptions extends PasslockOptions {
|
|
67
|
+
/**
|
|
68
|
+
* The Passlock passkey id
|
|
69
|
+
*/
|
|
70
|
+
passkeyId: string;
|
|
71
|
+
/**
|
|
72
|
+
* New username
|
|
73
|
+
*/
|
|
74
|
+
username: string;
|
|
75
|
+
/**
|
|
76
|
+
* New display name
|
|
77
|
+
*/
|
|
78
|
+
displayName?: string | undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Used when you want to update one or more passkeys by the Credential User ID i.e. the
|
|
82
|
+
* immutable Base64Url encoded binary ID.
|
|
83
|
+
*
|
|
84
|
+
* @see {@link updatePasskey}
|
|
85
|
+
* @see {@link https://passlock.dev/rest-api/credential/ The Credential property (main docs site)}
|
|
86
|
+
*
|
|
87
|
+
* @category Passkeys (core)
|
|
88
|
+
*/
|
|
89
|
+
export interface UpdateCredentialOptions extends PasslockOptions {
|
|
90
|
+
userId: string;
|
|
91
|
+
rpId: string;
|
|
92
|
+
/**
|
|
93
|
+
* New username
|
|
94
|
+
*/
|
|
95
|
+
username: string;
|
|
96
|
+
/**
|
|
97
|
+
* New display name
|
|
98
|
+
*/
|
|
99
|
+
displayName?: string | undefined;
|
|
100
|
+
}
|
|
101
|
+
export type UpdateSuccess = {
|
|
102
|
+
_tag: "UpdateSuccess";
|
|
103
|
+
};
|
|
104
|
+
export declare const isUpdateSuccess: (payload: unknown) => payload is UpdateSuccess;
|
|
105
|
+
/**
|
|
106
|
+
* Update a passkey e.g. change the username and/or display name.
|
|
107
|
+
* Note: this is purely informational, it does not change any identifiers.
|
|
108
|
+
* The typical use case is when a user changes their account email, you would
|
|
109
|
+
* want to change the username in your backend system and also the user's
|
|
110
|
+
* device local passkey. Otherwise the passkey associated with your new-name@gmail.com
|
|
111
|
+
* account would still show up in their password manager as old-name@gmail.com.
|
|
112
|
+
*
|
|
113
|
+
* @param options Passkey update options.
|
|
114
|
+
* @returns A Micro effect that resolves with a {@link UpdateSuccess} or fails with {@link UpdateError}.
|
|
115
|
+
*/
|
|
116
|
+
export declare const updatePasskey: (options: UpdatePasskeyOptions | UpdateCredentialOptions) => Micro.Micro<{
|
|
117
|
+
readonly _tag: "UpdateSuccess";
|
|
118
|
+
}, UpdateError, Logger>;
|
|
119
|
+
export type CredentialMapping = {
|
|
120
|
+
credentialId: string;
|
|
121
|
+
userId: string;
|
|
122
|
+
rpId: string;
|
|
123
|
+
};
|
|
124
|
+
export type CredentialMappings = {
|
|
125
|
+
rpId: string;
|
|
126
|
+
userId: string;
|
|
127
|
+
allAcceptedCredentialIds: string[];
|
|
128
|
+
};
|
|
129
|
+
type IPasskeyNotFound = {
|
|
130
|
+
message: string;
|
|
131
|
+
credentialId: string;
|
|
132
|
+
rpId: string;
|
|
133
|
+
};
|
|
134
|
+
export type DeleteSuccess = {
|
|
135
|
+
_tag: "DeleteSuccess";
|
|
136
|
+
};
|
|
137
|
+
export declare const isDeleteSuccess: (payload: unknown) => payload is DeleteSuccess;
|
|
138
|
+
/**
|
|
139
|
+
* Tell the client device to remove a given credential
|
|
140
|
+
*
|
|
141
|
+
* @param credential Credential mapping or missing-passkey payload.
|
|
142
|
+
* @returns A Micro effect that resolves with a {@link DeleteSuccess} or fails with {@link DeleteError}.
|
|
143
|
+
*/
|
|
144
|
+
export declare const signalCredentialRemoval: (credential: CredentialMapping | IPasskeyNotFound) => Micro.Micro<DeleteSuccess, DeleteError, Logger>;
|
|
145
|
+
/**
|
|
146
|
+
* Tell the client device which credentials are still accepted for a user.
|
|
147
|
+
*
|
|
148
|
+
* @param credentials Accepted credential mapping for the user.
|
|
149
|
+
* @returns A Micro effect that resolves with a {@link PruningSuccess} or fails with {@link PruningError}.
|
|
150
|
+
*/
|
|
151
|
+
export declare const signalAcceptedCredentials: (credentials: CredentialMappings) => Micro.Micro<PruningSuccess, PruningError, Logger>;
|
|
152
|
+
export type CredentialUserId = {
|
|
153
|
+
userId: string;
|
|
154
|
+
rpId: string;
|
|
155
|
+
};
|
|
156
|
+
export declare const signalCurrentUserDetails: (credential: CredentialUserId, updates: Pick<UpdatePasskeyOptions, "username" | "displayName">) => Micro.Micro<{
|
|
157
|
+
readonly _tag: "UpdateSuccess";
|
|
158
|
+
}, UpdateError, Logger>;
|
|
159
|
+
export {};
|
|
160
|
+
//# sourceMappingURL=signals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../../src/passkey/signals/signals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAQ,MAAM,QAAQ,CAAA;AAGpC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA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