@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,103 +1,81 @@
|
|
|
1
|
-
import type { PasslockOptions } from "../../shared/options";
|
|
2
|
-
import type { UserVerification } from "../types";
|
|
3
1
|
import * as Helper from "@simplewebauthn/browser";
|
|
4
2
|
import { type PublicKeyCredentialCreationOptionsJSON, type RegistrationResponseJSON } from "@simplewebauthn/browser";
|
|
5
|
-
import {
|
|
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";
|
|
6
7
|
import { Logger } from "../../logger";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
interface OptionsResponse {
|
|
11
|
-
sessionToken: string;
|
|
12
|
-
optionsJSON: PublicKeyCredentialCreationOptionsJSON;
|
|
13
|
-
}
|
|
14
|
-
declare const RegistrationHelper_base: Context.TagClass<RegistrationHelper, "RegistrationHelper", {
|
|
15
|
-
browserSupportsWebAuthn: typeof Helper.browserSupportsWebAuthn;
|
|
16
|
-
startRegistration: typeof Helper.startRegistration;
|
|
17
|
-
}>;
|
|
18
|
-
export declare class RegistrationHelper extends RegistrationHelper_base {
|
|
19
|
-
static Default: {
|
|
20
|
-
browserSupportsWebAuthn: typeof Helper.browserSupportsWebAuthn;
|
|
21
|
-
startRegistration: typeof Helper.startRegistration;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export declare const isDuplicatePasskey: (err: unknown) => err is DuplicatePasskeyError;
|
|
25
|
-
declare const DuplicatePasskeyError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Micro.YieldableError & {
|
|
26
|
-
readonly _tag: "@error/DuplicatePasskey";
|
|
27
|
-
} & Readonly<A>;
|
|
28
|
-
/**
|
|
29
|
-
* Raised if excludeCredentials or userId was provided and the
|
|
30
|
-
* device recognises one of the passkey ids i.e. the user currently
|
|
31
|
-
* has a passkey registered on the current device for a given userId.
|
|
32
|
-
*/
|
|
33
|
-
export declare class DuplicatePasskeyError extends DuplicatePasskeyError_base<{
|
|
34
|
-
readonly message: string;
|
|
35
|
-
}> {
|
|
36
|
-
static isDuplicatePasskey: (err: unknown) => err is DuplicatePasskeyError;
|
|
37
|
-
}
|
|
38
|
-
export declare const registrationEvent: readonly ["optionsRequest", "createCredential", "saveCredential"];
|
|
39
|
-
export type RegistrationEvent = (typeof registrationEvent)[number];
|
|
40
|
-
export type OnEventFn = (event: RegistrationEvent) => void;
|
|
8
|
+
import type { PasslockOptions } from "../../options";
|
|
9
|
+
import { DuplicatePasskeyError, OtherPasskeyError, PasskeyUnsupportedError } from "../errors";
|
|
10
|
+
import type { Millis, UserVerification } from "../shared";
|
|
41
11
|
/**
|
|
42
12
|
* Passkey registration options
|
|
13
|
+
*
|
|
14
|
+
* @category Passkeys (core)
|
|
43
15
|
*/
|
|
44
16
|
export interface RegistrationOptions extends PasslockOptions {
|
|
45
17
|
/**
|
|
46
|
-
*
|
|
18
|
+
* Username associated with passkey. Will be shown by the device during
|
|
19
|
+
* registration and subsequent authentication. The value used should be
|
|
20
|
+
* meaningful to the user e.g. jdoe or jdoe@gmail.com vs 5487546.
|
|
47
21
|
*
|
|
48
|
-
*
|
|
22
|
+
* You won't directly associate the username with an account in your
|
|
23
|
+
* backend. Instead, you'll associate the passkey ID with an account.
|
|
24
|
+
*
|
|
25
|
+
* @see {@link https://passlock.dev/passkeys/registration}
|
|
49
26
|
*/
|
|
50
27
|
username: string;
|
|
51
28
|
/**
|
|
52
|
-
*
|
|
29
|
+
* May be shown by devices in place of the username e.g. given a username
|
|
30
|
+
* of jdoe or jdoe@gmail.com a suitable display name might be "John Doe"
|
|
31
|
+
* or "John Doe (personal)". Note: no guarantee browsers/devices will
|
|
32
|
+
* choose to display this property.
|
|
53
33
|
*/
|
|
54
34
|
userDisplayName?: string | undefined;
|
|
55
|
-
/**
|
|
56
|
-
* Passlock userId. Essentially a shortcut to look up any
|
|
57
|
-
* currently registered passkeys (excludeCredentials) for a given user.
|
|
58
|
-
*/
|
|
59
|
-
userId?: string | undefined;
|
|
60
35
|
/**
|
|
61
36
|
* Prevents the user registering a passkey if they already have one
|
|
62
|
-
* (
|
|
37
|
+
* (associated with the same user account) registered on the current device.
|
|
63
38
|
*
|
|
64
|
-
* @see {@link https://passlock.dev/passkeys/
|
|
39
|
+
* @see {@link https://passlock.dev/passkeys/exclude-credentials}
|
|
65
40
|
*/
|
|
66
41
|
excludeCredentials?: Array<string> | undefined;
|
|
67
42
|
/**
|
|
68
43
|
* Whether the device should re-authenticate the user locally before registering the passkey.
|
|
69
44
|
*
|
|
70
|
-
* @see {@link https://passlock.dev/passkeys/user-verification
|
|
45
|
+
* @see {@link https://passlock.dev/passkeys/user-verification}
|
|
71
46
|
*/
|
|
72
47
|
userVerification?: UserVerification | undefined;
|
|
73
48
|
/**
|
|
74
49
|
* Receive notifications about key stages in the registration process.
|
|
75
50
|
* For example, you might use event notifications to toggle loading icons or
|
|
76
51
|
* to disable certain form fields.
|
|
52
|
+
*
|
|
77
53
|
* @param event
|
|
78
|
-
* @returns
|
|
54
|
+
* @returns Nothing.
|
|
79
55
|
*/
|
|
80
|
-
onEvent?:
|
|
81
|
-
|
|
56
|
+
onEvent?: OnRegistrationEvent;
|
|
57
|
+
/**
|
|
58
|
+
* Abort the operation after N milliseconds
|
|
59
|
+
*/
|
|
60
|
+
timeout?: Millis | undefined;
|
|
82
61
|
}
|
|
83
|
-
export declare const fetchOptions: (options: Omit<RegistrationOptions, keyof PasslockOptions>) => Micro.Micro<OptionsResponse, UnexpectedError, Logger | Endpoint | TenancyId>;
|
|
84
|
-
declare const RegistrationSuccessTag: "RegistrationSuccess";
|
|
85
|
-
type RegistrationSuccessTag = typeof RegistrationSuccessTag;
|
|
86
62
|
/**
|
|
87
|
-
* Represents the outcome of a
|
|
63
|
+
* Represents the outcome of a successful passkey registration.
|
|
88
64
|
* Submit the code and/or id_token to your backend, then either
|
|
89
65
|
* exchange the code with the passlock REST API or decode and
|
|
90
66
|
* verify the id_token (JWT).
|
|
91
67
|
*
|
|
92
68
|
* Note: The @passlock/node library includes utilities to do this
|
|
93
69
|
* for you.
|
|
70
|
+
*
|
|
71
|
+
* @category Passkeys (core)
|
|
94
72
|
*/
|
|
95
|
-
export
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
73
|
+
export type RegistrationSuccess = {
|
|
74
|
+
/**
|
|
75
|
+
* Discriminator for use in a discriminated union.
|
|
76
|
+
*/
|
|
77
|
+
_tag: "RegistrationSuccess";
|
|
78
|
+
principal: Principal;
|
|
101
79
|
/**
|
|
102
80
|
* A signed JWT representing the newly registered passkey.
|
|
103
81
|
* Decode and verify this in your backend or use one of the @passlock/node
|
|
@@ -110,27 +88,58 @@ export interface RegistrationSuccess {
|
|
|
110
88
|
* Call the Passlock API to exchange this code for details about the newly
|
|
111
89
|
* registered passkey.
|
|
112
90
|
*
|
|
113
|
-
* @see {@link https://passlock.dev/principal/code-exchange
|
|
91
|
+
* @see {@link https://passlock.dev/principal/code-exchange/|code exchange}
|
|
114
92
|
*/
|
|
115
93
|
code: string;
|
|
116
|
-
}
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Type guard to test for a {@link RegistrationSuccess}. Typically used to test the
|
|
97
|
+
* object returned from {@link registerPasskey}
|
|
98
|
+
*
|
|
99
|
+
* @param payload
|
|
100
|
+
* @returns `true` if the payload is a {@link RegistrationSuccess}.
|
|
101
|
+
*
|
|
102
|
+
* @category Passkeys (other)
|
|
103
|
+
*/
|
|
117
104
|
export declare const isRegistrationSuccess: (payload: unknown) => payload is RegistrationSuccess;
|
|
105
|
+
export type OptionsResponse = {
|
|
106
|
+
sessionToken: string;
|
|
107
|
+
optionsJSON: PublicKeyCredentialCreationOptionsJSON;
|
|
108
|
+
};
|
|
109
|
+
export declare const isOptionsResponse: (payload: unknown) => payload is OptionsResponse;
|
|
110
|
+
export declare const fetchOptions: (options: Omit<RegistrationOptions, keyof PasslockOptions>) => Micro.Micro<OptionsResponse, NetworkError, Endpoint | TenancyId | Logger>;
|
|
118
111
|
export declare const startRegistration: (optionsJSON: PublicKeyCredentialCreationOptionsJSON, { onEvent }: {
|
|
119
|
-
onEvent?:
|
|
120
|
-
}) => Micro.Micro<Helper.RegistrationResponseJSON,
|
|
112
|
+
onEvent?: OnRegistrationEvent | undefined;
|
|
113
|
+
}) => Micro.Micro<Helper.RegistrationResponseJSON, PasskeyUnsupportedError | OtherPasskeyError | DuplicatePasskeyError, Logger | RegistrationHelper>;
|
|
121
114
|
export declare const verifyCredential: (sessionToken: string, response: RegistrationResponseJSON, { onEvent }: {
|
|
122
|
-
onEvent?:
|
|
123
|
-
}) => Micro.Micro<RegistrationSuccess,
|
|
115
|
+
onEvent?: OnRegistrationEvent | undefined;
|
|
116
|
+
}) => Micro.Micro<RegistrationSuccess, NetworkError, Endpoint | TenancyId | Logger>;
|
|
124
117
|
/**
|
|
125
118
|
* Potential errors associated with Passkey registration
|
|
119
|
+
*
|
|
120
|
+
* @category Passkeys (errors)
|
|
126
121
|
*/
|
|
127
|
-
export type RegistrationError =
|
|
122
|
+
export type RegistrationError = PasskeyUnsupportedError | DuplicatePasskeyError | OtherPasskeyError | NetworkError;
|
|
128
123
|
/**
|
|
129
|
-
*
|
|
130
|
-
*
|
|
124
|
+
* Trigger local passkey registration then save the passkey in your Passlock vault.
|
|
125
|
+
* Returns a code and id_token that can be exchanged/decoded in your backend.
|
|
126
|
+
*
|
|
131
127
|
* @param options
|
|
132
|
-
* @returns
|
|
128
|
+
* @returns A Micro effect that resolves with {@link RegistrationSuccess} or
|
|
129
|
+
* fails with {@link RegistrationError}.
|
|
133
130
|
*/
|
|
134
131
|
export declare const registerPasskey: (options: RegistrationOptions) => Micro.Micro<RegistrationSuccess, RegistrationError, Logger | RegistrationHelper>;
|
|
135
|
-
export
|
|
132
|
+
export declare const RegistrationEvent: readonly ["optionsRequest", "createCredential", "saveCredential"];
|
|
133
|
+
/**
|
|
134
|
+
* Type of the registration event
|
|
135
|
+
*
|
|
136
|
+
* @category Passkeys (other)
|
|
137
|
+
*/
|
|
138
|
+
export type RegistrationEvent = (typeof RegistrationEvent)[number];
|
|
139
|
+
/**
|
|
140
|
+
* Callback to receive registration lifecycle events.
|
|
141
|
+
*
|
|
142
|
+
* @category Passkeys (other)
|
|
143
|
+
*/
|
|
144
|
+
export type OnRegistrationEvent = (event: RegistrationEvent) => void;
|
|
136
145
|
//# sourceMappingURL=registration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../src/passkey/registration/registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../src/passkey/registration/registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAA;AACjD,OAAO,EACL,KAAK,sCAAsC,EAC3C,KAAK,wBAAwB,EAE9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAW,KAAK,EAA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;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,sCAAsC,CAAA;CACpD,CAAA;AAED,eAAO,MAAM,iBAAiB,GAC5B,SAAS,OAAO,KACf,OAAO,IAAI,eAYb,CAAA;AAED,eAAO,MAAM,YAAY,GACvB,SAAS,IAAI,CAAC,mBAAmB,EAAE,MAAM,eAAe,CAAC,8EAmCvD,CAAA;AAEJ,eAAO,MAAM,iBAAiB,GAC5B,aAAa,sCAAsC,EACnD,aAAa;IAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAA;CAAE,mJAoCxD,CAAA;AAEJ,eAAO,MAAM,gBAAgB,GAC3B,cAAc,MAAM,EACpB,UAAU,wBAAwB,EAClC,aAAa;IAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAA;CAAE,kFAgCxD,CAAA;AAEJ;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GACzB,uBAAuB,GACvB,qBAAqB,GACrB,iBAAiB,GACjB,YAAY,CAAA;AAEhB;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,mBAAmB,KAC3B,KAAK,CAAC,KAAK,CACZ,mBAAmB,EACnB,iBAAiB,EACjB,MAAM,GAAG,kBAAkB,CAmB5B,CAAA;AAED,eAAO,MAAM,iBAAiB,mEAIpB,CAAA;AAEV;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAA;AAElE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAA"}
|
|
@@ -1,26 +1,42 @@
|
|
|
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 { 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
|
+
if (payload._tag !== "RegistrationSuccess")
|
|
36
|
+
return false;
|
|
37
|
+
return true;
|
|
38
|
+
};
|
|
39
|
+
export const isOptionsResponse = (payload) => {
|
|
24
40
|
if (typeof payload !== "object")
|
|
25
41
|
return false;
|
|
26
42
|
if (payload === null)
|
|
@@ -37,12 +53,11 @@ const isOptionsResponse = (payload) => {
|
|
|
37
53
|
return false;
|
|
38
54
|
return true;
|
|
39
55
|
};
|
|
40
|
-
export const registrationEvent = ["optionsRequest", "createCredential", "saveCredential"];
|
|
41
56
|
export const fetchOptions = (options) => Micro.gen(function* () {
|
|
42
57
|
const logger = yield* Micro.service(Logger);
|
|
43
58
|
const { endpoint } = yield* Micro.service(Endpoint);
|
|
44
59
|
const { tenancyId } = yield* Micro.service(TenancyId);
|
|
45
|
-
const { username, userDisplayName,
|
|
60
|
+
const { username, userDisplayName, excludeCredentials, userVerification, timeout, onEvent, } = options;
|
|
46
61
|
const url = new URL(`${tenancyId}/passkey/registration/options`, endpoint);
|
|
47
62
|
onEvent?.("optionsRequest");
|
|
48
63
|
yield* logger.logInfo("Fetching passkey registration options from Passlock");
|
|
@@ -50,7 +65,6 @@ export const fetchOptions = (options) => Micro.gen(function* () {
|
|
|
50
65
|
excludeCredentials,
|
|
51
66
|
timeout,
|
|
52
67
|
userDisplayName,
|
|
53
|
-
userId,
|
|
54
68
|
username,
|
|
55
69
|
userVerification,
|
|
56
70
|
};
|
|
@@ -61,20 +75,6 @@ export const fetchOptions = (options) => Micro.gen(function* () {
|
|
|
61
75
|
url,
|
|
62
76
|
});
|
|
63
77
|
});
|
|
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
78
|
export const startRegistration = (optionsJSON, { onEvent }) => Micro.gen(function* () {
|
|
79
79
|
onEvent?.("createCredential");
|
|
80
80
|
const logger = yield* Micro.service(Logger);
|
|
@@ -82,10 +82,11 @@ export const startRegistration = (optionsJSON, { onEvent }) => Micro.gen(functio
|
|
|
82
82
|
const helper = yield* Micro.service(RegistrationHelper);
|
|
83
83
|
const isSupport = helper.browserSupportsWebAuthn();
|
|
84
84
|
if (!isSupport)
|
|
85
|
-
yield* new
|
|
85
|
+
yield* Micro.fail(new PasskeyUnsupportedError({
|
|
86
86
|
message: "Device does not support passkeys",
|
|
87
|
-
});
|
|
87
|
+
}));
|
|
88
88
|
return yield* Micro.tryPromise({
|
|
89
|
+
try: () => helper.startRegistration({ optionsJSON }),
|
|
89
90
|
catch: (error) => {
|
|
90
91
|
if (error instanceof WebAuthnError &&
|
|
91
92
|
error.code === "ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED") {
|
|
@@ -102,7 +103,6 @@ export const startRegistration = (optionsJSON, { onEvent }) => Micro.gen(functio
|
|
|
102
103
|
return new OtherPasskeyError({ error, message: "Unexpected error" });
|
|
103
104
|
}
|
|
104
105
|
},
|
|
105
|
-
try: () => helper.startRegistration({ optionsJSON }),
|
|
106
106
|
});
|
|
107
107
|
});
|
|
108
108
|
export const verifyCredential = (sessionToken, response, { onEvent }) => Micro.gen(function* () {
|
|
@@ -126,13 +126,15 @@ export const verifyCredential = (sessionToken, response, { onEvent }) => Micro.g
|
|
|
126
126
|
return registrationResponse;
|
|
127
127
|
});
|
|
128
128
|
/**
|
|
129
|
-
*
|
|
130
|
-
*
|
|
129
|
+
* Trigger local passkey registration then save the passkey in your Passlock vault.
|
|
130
|
+
* Returns a code and id_token that can be exchanged/decoded in your backend.
|
|
131
|
+
*
|
|
131
132
|
* @param options
|
|
132
|
-
* @returns
|
|
133
|
+
* @returns A Micro effect that resolves with {@link RegistrationSuccess} or
|
|
134
|
+
* fails with {@link RegistrationError}.
|
|
133
135
|
*/
|
|
134
136
|
export const registerPasskey = (options) => {
|
|
135
|
-
const endpoint =
|
|
137
|
+
const endpoint = makeEndpoint(options);
|
|
136
138
|
const effect = Micro.gen(function* () {
|
|
137
139
|
const { sessionToken, optionsJSON } = yield* fetchOptions(options);
|
|
138
140
|
const response = yield* startRegistration(optionsJSON, {
|
|
@@ -144,4 +146,9 @@ export const registerPasskey = (options) => {
|
|
|
144
146
|
});
|
|
145
147
|
return pipe(effect, Micro.provideService(TenancyId, options), Micro.provideService(Endpoint, endpoint));
|
|
146
148
|
};
|
|
149
|
+
export const RegistrationEvent = [
|
|
150
|
+
"optionsRequest",
|
|
151
|
+
"createCredential",
|
|
152
|
+
"saveCredential",
|
|
153
|
+
];
|
|
147
154
|
//# sourceMappingURL=registration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../src/passkey/registration/registration.ts"],"names":[],"mappings":"
|
|
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;AA4DlB;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAMtE;IACD,MAAM,CAAC,OAAO,GAAG;QACf,uBAAuB,EAAE,MAAM,CAAC,uBAAuB;QACvD,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;KACA,CAAA;;AAuC/C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,OAAgB,EACgB,EAAE;IAClC,IAAI,OAAO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KAAK,CAAC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CACzC,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,gBAAgB;IAChB,kBAAkB;IAClB,gBAAgB;CACR,CAAA"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://w3c.github.io/webauthn/#user-verification
|
|
3
|
+
*
|
|
4
|
+
* @category Passkeys (core)
|
|
5
|
+
*/
|
|
1
6
|
export type UserVerification = "discouraged" | "preferred" | "required";
|
|
2
7
|
/**
|
|
3
8
|
* https://w3c.github.io/webauthn/#enumdef-publickeycredentialhint
|
|
@@ -10,7 +15,7 @@ export type AttestationFormat = "fido-u2f" | "packed" | "android-safetynet" | "a
|
|
|
10
15
|
/**
|
|
11
16
|
* https://w3c.github.io/webauthn/#dictdef-publickeycredentialcreationoptionsjson
|
|
12
17
|
*/
|
|
13
|
-
export
|
|
18
|
+
export type PublicKeyCredentialCreationOptionsJSON = {
|
|
14
19
|
rp: PublicKeyCredentialRpEntity;
|
|
15
20
|
user: PublicKeyCredentialUserEntityJSON;
|
|
16
21
|
challenge: Base64URLString;
|
|
@@ -22,5 +27,6 @@ export interface PublicKeyCredentialCreationOptionsJSON {
|
|
|
22
27
|
attestation?: AttestationConveyancePreference;
|
|
23
28
|
attestationFormats?: Array<AttestationFormat>;
|
|
24
29
|
extensions?: AuthenticationExtensionsClientInputs;
|
|
25
|
-
}
|
|
26
|
-
|
|
30
|
+
};
|
|
31
|
+
export type Millis = number;
|
|
32
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/passkey/shared.ts"],"names":[],"mappings":"AAAA;;;;GAIG;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 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/passkey/shared.ts"],"names":[],"mappings":""}
|
|
@@ -1,45 +1,103 @@
|
|
|
1
|
-
import type { PasslockOptions } from "../../shared/options";
|
|
2
1
|
import { Micro } from "effect";
|
|
3
2
|
import { Logger } from "../../logger";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
declare const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
3
|
+
import type { PasslockOptions } from "../../options";
|
|
4
|
+
import { DeleteError, 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
|
+
/**
|
|
18
|
+
* Instruct the device to remove a passkey. E.g. attempt to remove it from
|
|
19
|
+
* Apple Password Manager / iCloud.
|
|
20
|
+
*
|
|
21
|
+
* @param passkeyId Passkey identifier.
|
|
22
|
+
* @param options Passlock tenancy and endpoint options.
|
|
23
|
+
* @returns A Micro effect that resolves with `true` or fails with {@link DeleteError}.
|
|
24
|
+
*/
|
|
25
|
+
export declare const deletePasskey: (passkeyId: string, options: PasslockOptions) => Micro.Micro<boolean, DeleteError, Logger>;
|
|
26
|
+
/**
|
|
27
|
+
* Given a list of passkey ids, instruct the device to remove any redundant passkeys.
|
|
28
|
+
*
|
|
29
|
+
* Note: this will only remove redundant passkeys (based on the userId).
|
|
30
|
+
*
|
|
31
|
+
* For example:
|
|
32
|
+
*
|
|
33
|
+
* The user has two passkeys registered against the jdoe@gmail.com account: passkey1
|
|
34
|
+
* and passkey2. The user has another passkey (passkey3) registered against the
|
|
35
|
+
* jdoe@work.com account.
|
|
36
|
+
*
|
|
37
|
+
* If you pass in the id for passkey1, the device will recognise it's assigned to the
|
|
38
|
+
* jdoe@gmail.com account and remove passkey2. However as passkey3 is registered to a
|
|
39
|
+
* different account, the device will retain it.
|
|
40
|
+
*
|
|
41
|
+
* @param passkeyIds Passkey identifiers to keep.
|
|
42
|
+
* @param options Passlock tenancy and endpoint options.
|
|
43
|
+
* @returns A Micro effect that resolves with `true` or fails with {@link PruningError}.
|
|
44
|
+
*/
|
|
45
|
+
export declare const prunePasskeys: (passkeyIds: Array<string>, options: PasslockOptions) => Micro.Micro<boolean, PruningError, Logger>;
|
|
46
|
+
/**
|
|
47
|
+
* @category Passkeys (core)
|
|
48
|
+
*/
|
|
49
|
+
export interface UpdatePasskeyOptions extends PasslockOptions {
|
|
50
|
+
passkeyId: string;
|
|
51
|
+
/**
|
|
52
|
+
* New username
|
|
53
|
+
*/
|
|
54
|
+
username: string;
|
|
55
|
+
/**
|
|
56
|
+
* New display name
|
|
57
|
+
*/
|
|
58
|
+
displayName: string;
|
|
29
59
|
}
|
|
30
|
-
export declare const deletePasskey: (passkeyId: string, options: PasslockOptions) => Micro.Micro<boolean, DeletionError, Logger>;
|
|
31
60
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
61
|
+
* Update a passkey e.g. change the username and or display name.
|
|
62
|
+
* Note: this is purely informational, it does not change any identifiers.
|
|
63
|
+
* The typical use case is when a user changes their account email, you would
|
|
64
|
+
* want to change the username in your backend system and also the user's
|
|
65
|
+
* device local passkey. Otherwise the passkey associated with your new-name@gmail.com
|
|
66
|
+
* account would still show up in their password manager as old-name@gmail.com.
|
|
67
|
+
*
|
|
68
|
+
* @param options Passkey update options.
|
|
69
|
+
* @returns A Micro effect that resolves with `true` or fails with {@link UpdateError}.
|
|
35
70
|
*/
|
|
36
|
-
export declare const
|
|
37
|
-
export
|
|
71
|
+
export declare const updatePasskey: (options: UpdatePasskeyOptions) => Micro.Micro<boolean, UpdateError, Logger>;
|
|
72
|
+
export type CredentialMapping = {
|
|
73
|
+
credentialId: string;
|
|
74
|
+
userId: string;
|
|
75
|
+
rpId: string;
|
|
76
|
+
};
|
|
77
|
+
export type CredentialMappings = {
|
|
38
78
|
rpId: string;
|
|
39
79
|
userId: string;
|
|
40
80
|
allAcceptedCredentialIds: string[];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
81
|
+
};
|
|
82
|
+
type IPasskeyNotFound = {
|
|
83
|
+
message: string;
|
|
84
|
+
credentialId: string;
|
|
85
|
+
rpId: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Tell the client device to remove a given credential
|
|
89
|
+
*
|
|
90
|
+
* @param credential Credential mapping or missing-passkey payload.
|
|
91
|
+
* @returns A Micro effect that resolves with `true` or fails with {@link DeleteError}.
|
|
92
|
+
*/
|
|
93
|
+
export declare const signalCredentialRemoval: (credential: CredentialMapping | IPasskeyNotFound) => Micro.Micro<boolean, DeleteError, Logger>;
|
|
94
|
+
/**
|
|
95
|
+
* Tell the client device which credentials are still accepted for a user.
|
|
96
|
+
*
|
|
97
|
+
* @param credentials Accepted credential mapping for the user.
|
|
98
|
+
* @returns A Micro effect that resolves with `true` or fails with {@link PruningError}.
|
|
99
|
+
*/
|
|
100
|
+
export declare const signalAcceptedCredentials: (credentials: CredentialMappings) => Micro.Micro<boolean, PruningError, Logger>;
|
|
101
|
+
export declare const signalCurrentUserDetails: (credential: CredentialMapping, updates: Omit<UpdatePasskeyOptions, "passkeyId">) => Micro.Micro<boolean, UpdateError, Logger>;
|
|
44
102
|
export {};
|
|
45
103
|
//# sourceMappingURL=signals.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../../src/passkey/signals/signals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
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;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eA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