@passlock/client 2.0.0 → 2.0.1
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/index.d.ts +38 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -2
- package/dist/index.js.map +1 -1
- package/dist/passkey/{authentication/authentication.d.ts → authentication.d.ts} +8 -8
- package/dist/passkey/authentication.d.ts.map +1 -0
- package/dist/passkey/{authentication/authentication.js → authentication.js} +5 -5
- package/dist/passkey/authentication.js.map +1 -0
- package/dist/passkey/authentication.test.d.ts.map +1 -0
- package/dist/passkey/{authentication/authentication.test.js → authentication.test.js} +5 -5
- package/dist/passkey/authentication.test.js.map +1 -0
- package/dist/passkey/errors.d.ts +5 -5
- package/dist/passkey/errors.d.ts.map +1 -1
- package/dist/passkey/errors.js +3 -3
- package/dist/passkey/errors.js.map +1 -1
- package/dist/passkey/{registration/registration.d.ts → registration.d.ts} +8 -8
- package/dist/passkey/registration.d.ts.map +1 -0
- package/dist/passkey/{registration/registration.js → registration.js} +5 -5
- package/dist/passkey/registration.js.map +1 -0
- package/dist/passkey/registration.test.d.ts.map +1 -0
- package/dist/passkey/{registration/registration.test.js → registration.test.js} +5 -5
- package/dist/passkey/registration.test.js.map +1 -0
- package/dist/passkey/{types.d.ts → shared.d.ts} +1 -1
- 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.d.ts +113 -0
- package/dist/passkey/signals.d.ts.map +1 -0
- package/dist/passkey/{signals/signals.js → signals.js} +172 -63
- package/dist/passkey/signals.js.map +1 -0
- package/dist/surface.test.d.ts +2 -0
- package/dist/surface.test.d.ts.map +1 -0
- package/dist/surface.test.js +38 -0
- package/dist/surface.test.js.map +1 -0
- package/dist/unsafe.d.ts +41 -0
- package/dist/unsafe.d.ts.map +1 -0
- package/dist/unsafe.js +52 -0
- package/dist/unsafe.js.map +1 -0
- package/package.json +16 -13
- package/dist/passkey/authentication/authentication.d.ts.map +0 -1
- package/dist/passkey/authentication/authentication.js.map +0 -1
- package/dist/passkey/authentication/authentication.test.d.ts.map +0 -1
- 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.d.ts.map +0 -1
- package/dist/passkey/registration/registration.js.map +0 -1
- package/dist/passkey/registration/registration.test.d.ts.map +0 -1
- 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/signals/signals.d.ts +0 -45
- package/dist/passkey/signals/signals.d.ts.map +0 -1
- package/dist/passkey/signals/signals.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/passkey/{authentication/authentication.test.d.ts → authentication.test.d.ts} +0 -0
- /package/dist/passkey/{registration/registration.test.d.ts → registration.test.d.ts} +0 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { PasslockOptions } from "../shared/options";
|
|
2
|
+
import type { PasskeyNotFound } from "./authentication";
|
|
3
|
+
import { Micro } from "effect";
|
|
4
|
+
import { Logger } from "../logger";
|
|
5
|
+
/**
|
|
6
|
+
* Does the current device support local passkey removal
|
|
7
|
+
*/
|
|
8
|
+
export declare const isPasskeyDeletionSupport: Micro.Micro<boolean, never, never>;
|
|
9
|
+
/**
|
|
10
|
+
* Does the current device support local passkey syncing
|
|
11
|
+
*/
|
|
12
|
+
export declare const isPasskeySyncSupport: 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 declare const isDeletionError: (err: unknown) => err is DeletionError;
|
|
18
|
+
declare const DeletionError_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 & {
|
|
19
|
+
readonly _tag: "@error/DeletionError";
|
|
20
|
+
} & Readonly<A>;
|
|
21
|
+
export declare class DeletionError extends DeletionError_base<{
|
|
22
|
+
readonly message: string;
|
|
23
|
+
readonly code: "PASSKEY_DELETION_UNSUPPORTED" | "PASSKEY_NOT_FOUND" | "OTHER_ERROR";
|
|
24
|
+
}> {
|
|
25
|
+
static isDeletionError: (err: unknown) => err is DeletionError;
|
|
26
|
+
}
|
|
27
|
+
export declare const isSyncError: (err: unknown) => err is SyncError;
|
|
28
|
+
declare const SyncError_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 & {
|
|
29
|
+
readonly _tag: "@error/SyncError";
|
|
30
|
+
} & Readonly<A>;
|
|
31
|
+
export declare class SyncError extends SyncError_base<{
|
|
32
|
+
readonly message: string;
|
|
33
|
+
readonly code: "PASSKEY_SYNC_UNSUPPORTED" | "OTHER_ERROR";
|
|
34
|
+
}> {
|
|
35
|
+
static isSyncError: (err: unknown) => err is SyncError;
|
|
36
|
+
}
|
|
37
|
+
export declare const isUpdateError: (err: unknown) => err is UpdateError;
|
|
38
|
+
declare const UpdateError_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 & {
|
|
39
|
+
readonly _tag: "@error/UpdateError";
|
|
40
|
+
} & Readonly<A>;
|
|
41
|
+
export declare class UpdateError extends UpdateError_base<{
|
|
42
|
+
readonly message: string;
|
|
43
|
+
readonly code: "PASSKEY_UPDATE_UNSUPPORTED" | "OTHER_ERROR";
|
|
44
|
+
}> {
|
|
45
|
+
static isUpdateError: (err: unknown) => err is UpdateError;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Instruct the device to remove a passkey. E.g. attempt to remove it from
|
|
49
|
+
* Apple Password Manager / iCloud.
|
|
50
|
+
*
|
|
51
|
+
* @param passkeyId
|
|
52
|
+
* @param options
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
export declare const deletePasskey: (passkeyId: string, options: PasslockOptions) => Micro.Micro<boolean, DeletionError, Logger>;
|
|
56
|
+
/**
|
|
57
|
+
* Given a list of passkey ids, instruct the device to remove any redundant passkeys.
|
|
58
|
+
*
|
|
59
|
+
* Note: this will only remove redundant passkeys (based on the userId).
|
|
60
|
+
*
|
|
61
|
+
* For example:
|
|
62
|
+
*
|
|
63
|
+
* The user has two passkeys registered against the jdoe@gmail.com account: passkey1
|
|
64
|
+
* and passkey2. The user has another passkey (passkey3) registered against the
|
|
65
|
+
* jdoe@work.com account.
|
|
66
|
+
*
|
|
67
|
+
* If you pass in the id for passkey1, the device will recognise it's assigned to the
|
|
68
|
+
* jdoe@gmail.com account and remove passkey2. However as passkey3 is registered to a
|
|
69
|
+
* different account, the device will retain it.
|
|
70
|
+
*
|
|
71
|
+
* @param passkeyIds
|
|
72
|
+
* @param options
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
export declare const syncPasskeys: (passkeyIds: Array<string>, options: PasslockOptions) => Micro.Micro<boolean, SyncError, Logger>;
|
|
76
|
+
export interface UpdateUserDetails extends PasslockOptions {
|
|
77
|
+
passkeyId: string;
|
|
78
|
+
username: string;
|
|
79
|
+
displayName: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Update a passkey e.g. change the username and or display name.
|
|
83
|
+
* Note: this is purely informational, it does not change any identifiers.
|
|
84
|
+
* The typical use case is when a user changes their account email, you would
|
|
85
|
+
* want to change the username in your backend system and also the user's
|
|
86
|
+
* device local passkey. Otherwise the passkey associated with your new-name@gmail.com
|
|
87
|
+
* account would still show up in their password manager as old-name@gmail.com.
|
|
88
|
+
*
|
|
89
|
+
* @param updates
|
|
90
|
+
* @param options
|
|
91
|
+
* @returns
|
|
92
|
+
*/
|
|
93
|
+
export declare const updateUserDetails: (options: UpdateUserDetails) => Micro.Micro<boolean, UpdateError, Logger>;
|
|
94
|
+
export interface CredentialMapping {
|
|
95
|
+
credentialId: string;
|
|
96
|
+
userId: string;
|
|
97
|
+
rpId: string;
|
|
98
|
+
}
|
|
99
|
+
export interface CredentialMappings {
|
|
100
|
+
rpId: string;
|
|
101
|
+
userId: string;
|
|
102
|
+
allAcceptedCredentialIds: string[];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Tell the client device to remove a given credential
|
|
106
|
+
* @param error
|
|
107
|
+
* @returns
|
|
108
|
+
*/
|
|
109
|
+
export declare const signalCredentialRemoval: (credential: CredentialMapping | PasskeyNotFound) => Micro.Micro<boolean, DeletionError, Logger>;
|
|
110
|
+
export declare const signalAcceptedCredentials: (credentials: CredentialMappings) => Micro.Micro<boolean, SyncError, Logger>;
|
|
111
|
+
export declare const signalCurrentUserDetails: (credential: CredentialMapping, updates: Omit<UpdateUserDetails, "passkeyId">) => Micro.Micro<boolean, UpdateError, Logger>;
|
|
112
|
+
export {};
|
|
113
|
+
//# sourceMappingURL=signals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.d.ts","s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AAM,aAAa,GAAI,WAAW,MAAM,EAAE,SAAS,eAAe,gDA+BrE,CAAA;AAEJ;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY,GAAI,YAAY,KAAK,CAAC,MAAM,CAAC,EAAE,SAAS,eAAe,4CAgC5E,CAAA;AAEJ,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAS,iBAAiB,8CA+BxD,CAAA;AAIJ,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb;AAkBD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,wBAAwB,EAAE,MAAM,EAAE,CAAA;CACnC;AAkBD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,YAAY,iBAAiB,GAAG,eAAe,KAC9C,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,CAiCzC,CAAA;AAEJ,eAAO,MAAM,yBAAyB,GACpC,aAAa,kBAAkB,KAC9B,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAgCrC,CAAA;AAEJ,eAAO,MAAM,wBAAwB,GACnC,YAAY,iBAAiB,EAC7B,SAAS,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC,8CAoC3C,CAAA"}
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { Micro, pipe } from "effect";
|
|
2
2
|
import { encodeUriComponent } from "effect/Encoding";
|
|
3
|
-
import { Logger } from "
|
|
4
|
-
import { buildEndpoint } from "
|
|
3
|
+
import { Logger } from "../logger";
|
|
4
|
+
import { buildEndpoint } from "../shared/network";
|
|
5
|
+
/**
|
|
6
|
+
* Does the current device support local passkey removal
|
|
7
|
+
*/
|
|
5
8
|
export const isPasskeyDeletionSupport = Micro.sync(() => {
|
|
6
9
|
return (PublicKeyCredential?.signalUnknownCredential &&
|
|
7
10
|
typeof PublicKeyCredential.signalUnknownCredential === "function");
|
|
8
11
|
});
|
|
9
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Does the current device support local passkey syncing
|
|
14
|
+
*/
|
|
15
|
+
export const isPasskeySyncSupport = Micro.sync(() => {
|
|
10
16
|
return (PublicKeyCredential?.signalAllAcceptedCredentials &&
|
|
11
17
|
typeof PublicKeyCredential.signalAllAcceptedCredentials === "function");
|
|
12
18
|
});
|
|
19
|
+
/**
|
|
20
|
+
* Does the current device support local passkey updates
|
|
21
|
+
*/
|
|
22
|
+
export const isPasskeyUpdateSupport = Micro.sync(() => {
|
|
23
|
+
return (PublicKeyCredential?.signalCurrentUserDetails &&
|
|
24
|
+
typeof PublicKeyCredential.signalCurrentUserDetails === "function");
|
|
25
|
+
});
|
|
13
26
|
/* Deletion error */
|
|
14
27
|
export const isDeletionError = (err) => err instanceof DeletionError;
|
|
15
28
|
export class DeletionError extends Micro.TaggedError("@error/DeletionError") {
|
|
@@ -20,21 +33,19 @@ export const isSyncError = (err) => err instanceof SyncError;
|
|
|
20
33
|
export class SyncError extends Micro.TaggedError("@error/SyncError") {
|
|
21
34
|
static isSyncError = isSyncError;
|
|
22
35
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return true;
|
|
37
|
-
};
|
|
36
|
+
/* Update error */
|
|
37
|
+
export const isUpdateError = (err) => err instanceof UpdateError;
|
|
38
|
+
export class UpdateError extends Micro.TaggedError("@error/UpdateError") {
|
|
39
|
+
static isUpdateError = isUpdateError;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Instruct the device to remove a passkey. E.g. attempt to remove it from
|
|
43
|
+
* Apple Password Manager / iCloud.
|
|
44
|
+
*
|
|
45
|
+
* @param passkeyId
|
|
46
|
+
* @param options
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
38
49
|
export const deletePasskey = (passkeyId, options) => Micro.gen(function* () {
|
|
39
50
|
const { tenancyId } = options;
|
|
40
51
|
const logger = yield* Micro.service(Logger);
|
|
@@ -63,55 +74,30 @@ export const deletePasskey = (passkeyId, options) => Micro.gen(function* () {
|
|
|
63
74
|
return yield* signalCredentialRemoval(credential);
|
|
64
75
|
});
|
|
65
76
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
77
|
+
* Given a list of passkey ids, instruct the device to remove any redundant passkeys.
|
|
78
|
+
*
|
|
79
|
+
* Note: this will only remove redundant passkeys (based on the userId).
|
|
80
|
+
*
|
|
81
|
+
* For example:
|
|
82
|
+
*
|
|
83
|
+
* The user has two passkeys registered against the jdoe@gmail.com account: passkey1
|
|
84
|
+
* and passkey2. The user has another passkey (passkey3) registered against the
|
|
85
|
+
* jdoe@work.com account.
|
|
86
|
+
*
|
|
87
|
+
* If you pass in the id for passkey1, the device will recognise it's assigned to the
|
|
88
|
+
* jdoe@gmail.com account and remove passkey2. However as passkey3 is registered to a
|
|
89
|
+
* different account, the device will retain it.
|
|
90
|
+
*
|
|
91
|
+
* @param passkeyIds
|
|
92
|
+
* @param options
|
|
68
93
|
* @returns
|
|
69
94
|
*/
|
|
70
|
-
export const signalCredentialRemoval = (signal) => Micro.gen(function* () {
|
|
71
|
-
const logger = yield* Micro.service(Logger);
|
|
72
|
-
yield* logger.logInfo("Testing for local passkey removal support");
|
|
73
|
-
const canDelete = yield* isPasskeyDeletionSupport;
|
|
74
|
-
if (!canDelete)
|
|
75
|
-
return yield* new DeletionError({
|
|
76
|
-
code: "PASSKEY_DELETION_UNSUPPORTED",
|
|
77
|
-
message: "Passkey deletion not supported on this device",
|
|
78
|
-
});
|
|
79
|
-
// might not be defined in older browsers
|
|
80
|
-
yield* logger.logInfo("Signalling browser to remove passkey");
|
|
81
|
-
yield* pipe(Micro.tryPromise({
|
|
82
|
-
try: () => PublicKeyCredential.signalUnknownCredential(signal),
|
|
83
|
-
catch: (err) => err instanceof Error ? err : new Error("Unable to signal credential removal"),
|
|
84
|
-
}), Micro.catchAllDefect((err) => err instanceof Error
|
|
85
|
-
? logger.logWarn(err.message)
|
|
86
|
-
: logger.logWarn("Unable to signal credential removal")), Micro.catchAll((err) => logger.logWarn(err.message)), Micro.forkDaemon);
|
|
87
|
-
yield* logger.logInfo("Passkey removed");
|
|
88
|
-
return true;
|
|
89
|
-
});
|
|
90
|
-
const isCredentialMappings = (payload) => {
|
|
91
|
-
if (typeof payload !== "object")
|
|
92
|
-
return false;
|
|
93
|
-
if (payload === null)
|
|
94
|
-
return false;
|
|
95
|
-
if (!("rpId" in payload))
|
|
96
|
-
return false;
|
|
97
|
-
if (typeof payload.rpId !== "string")
|
|
98
|
-
return false;
|
|
99
|
-
if (!("userId" in payload))
|
|
100
|
-
return false;
|
|
101
|
-
if (typeof payload.userId !== "string")
|
|
102
|
-
return false;
|
|
103
|
-
if (!("allAcceptedCredentialIds" in payload))
|
|
104
|
-
return false;
|
|
105
|
-
if (Array.isArray(payload.allAcceptedCredentialIds))
|
|
106
|
-
return false;
|
|
107
|
-
return true;
|
|
108
|
-
};
|
|
109
95
|
export const syncPasskeys = (passkeyIds, options) => Micro.gen(function* () {
|
|
110
96
|
const { tenancyId } = options;
|
|
111
97
|
const logger = yield* Micro.service(Logger);
|
|
112
98
|
const { endpoint } = buildEndpoint(options);
|
|
113
99
|
yield* logger.logInfo("Testing for local passkey sync support");
|
|
114
|
-
const canSync = yield*
|
|
100
|
+
const canSync = yield* isPasskeySyncSupport;
|
|
115
101
|
if (!canSync)
|
|
116
102
|
return yield* new SyncError({
|
|
117
103
|
code: "PASSKEY_SYNC_UNSUPPORTED",
|
|
@@ -134,10 +120,112 @@ export const syncPasskeys = (passkeyIds, options) => Micro.gen(function* () {
|
|
|
134
120
|
});
|
|
135
121
|
return yield* signalAcceptedCredentials(credentials);
|
|
136
122
|
});
|
|
137
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Update a passkey e.g. change the username and or display name.
|
|
125
|
+
* Note: this is purely informational, it does not change any identifiers.
|
|
126
|
+
* The typical use case is when a user changes their account email, you would
|
|
127
|
+
* want to change the username in your backend system and also the user's
|
|
128
|
+
* device local passkey. Otherwise the passkey associated with your new-name@gmail.com
|
|
129
|
+
* account would still show up in their password manager as old-name@gmail.com.
|
|
130
|
+
*
|
|
131
|
+
* @param updates
|
|
132
|
+
* @param options
|
|
133
|
+
* @returns
|
|
134
|
+
*/
|
|
135
|
+
export const updateUserDetails = (options) => Micro.gen(function* () {
|
|
136
|
+
const { tenancyId } = options;
|
|
137
|
+
const logger = yield* Micro.service(Logger);
|
|
138
|
+
const { endpoint } = buildEndpoint(options);
|
|
139
|
+
yield* logger.logInfo("Testing for local passkey update support");
|
|
140
|
+
const canUpdate = yield* isPasskeyUpdateSupport;
|
|
141
|
+
if (!canUpdate)
|
|
142
|
+
return yield* new UpdateError({
|
|
143
|
+
code: "PASSKEY_UPDATE_UNSUPPORTED",
|
|
144
|
+
message: "Passkey update not supported on this device",
|
|
145
|
+
});
|
|
146
|
+
yield* logger.logInfo("Fetching passkey credential and rp id");
|
|
147
|
+
const url = new URL(`${tenancyId}/credential/${options.passkeyId}`, endpoint);
|
|
148
|
+
const response = yield* Micro.promise(() => fetch(url));
|
|
149
|
+
if (response.status === 404)
|
|
150
|
+
return yield* new UpdateError({
|
|
151
|
+
code: "OTHER_ERROR",
|
|
152
|
+
message: "Unable to find the metadata associated with this passkey",
|
|
153
|
+
});
|
|
154
|
+
const credential = yield* Micro.promise(() => response.json());
|
|
155
|
+
if (!isCredentialMapping(credential))
|
|
156
|
+
return yield* new UpdateError({
|
|
157
|
+
code: "OTHER_ERROR",
|
|
158
|
+
message: "Invalid metadata associated with this passkey",
|
|
159
|
+
});
|
|
160
|
+
return yield* signalCurrentUserDetails(credential, options);
|
|
161
|
+
});
|
|
162
|
+
const isCredentialMapping = (payload) => {
|
|
163
|
+
if (typeof payload !== "object")
|
|
164
|
+
return false;
|
|
165
|
+
if (payload === null)
|
|
166
|
+
return false;
|
|
167
|
+
if (!("credentialId" in payload))
|
|
168
|
+
return false;
|
|
169
|
+
if (typeof payload.credentialId !== "string")
|
|
170
|
+
return false;
|
|
171
|
+
if (!("userId" in payload))
|
|
172
|
+
return false;
|
|
173
|
+
if (typeof payload.userId !== "string")
|
|
174
|
+
return false;
|
|
175
|
+
if (!("rpId" in payload))
|
|
176
|
+
return false;
|
|
177
|
+
if (typeof payload.rpId !== "string")
|
|
178
|
+
return false;
|
|
179
|
+
return true;
|
|
180
|
+
};
|
|
181
|
+
const isCredentialMappings = (payload) => {
|
|
182
|
+
if (typeof payload !== "object")
|
|
183
|
+
return false;
|
|
184
|
+
if (payload === null)
|
|
185
|
+
return false;
|
|
186
|
+
if (!("rpId" in payload))
|
|
187
|
+
return false;
|
|
188
|
+
if (typeof payload.rpId !== "string")
|
|
189
|
+
return false;
|
|
190
|
+
if (!("userId" in payload))
|
|
191
|
+
return false;
|
|
192
|
+
if (typeof payload.userId !== "string")
|
|
193
|
+
return false;
|
|
194
|
+
if (!("allAcceptedCredentialIds" in payload))
|
|
195
|
+
return false;
|
|
196
|
+
if (!Array.isArray(payload.allAcceptedCredentialIds))
|
|
197
|
+
return false;
|
|
198
|
+
return true;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Tell the client device to remove a given credential
|
|
202
|
+
* @param error
|
|
203
|
+
* @returns
|
|
204
|
+
*/
|
|
205
|
+
export const signalCredentialRemoval = (credential) => Micro.gen(function* () {
|
|
206
|
+
const logger = yield* Micro.service(Logger);
|
|
207
|
+
yield* logger.logInfo("Testing for local passkey removal support");
|
|
208
|
+
const canDelete = yield* isPasskeyDeletionSupport;
|
|
209
|
+
if (!canDelete)
|
|
210
|
+
return yield* new DeletionError({
|
|
211
|
+
code: "PASSKEY_DELETION_UNSUPPORTED",
|
|
212
|
+
message: "Passkey deletion not supported on this device",
|
|
213
|
+
});
|
|
214
|
+
// might not be defined in older browsers
|
|
215
|
+
yield* logger.logInfo("Signalling browser to remove passkey");
|
|
216
|
+
yield* pipe(Micro.tryPromise({
|
|
217
|
+
try: () => PublicKeyCredential.signalUnknownCredential(credential),
|
|
218
|
+
catch: (err) => err instanceof Error ? err : new Error("Unable to signal credential removal"),
|
|
219
|
+
}), Micro.catchAllDefect((err) => err instanceof Error
|
|
220
|
+
? logger.logWarn(err.message)
|
|
221
|
+
: logger.logWarn("Unable to signal credential removal")), Micro.catchAll((err) => logger.logWarn(err.message)), Micro.forkDaemon);
|
|
222
|
+
yield* logger.logInfo("Passkey removed");
|
|
223
|
+
return true;
|
|
224
|
+
});
|
|
225
|
+
export const signalAcceptedCredentials = (credentials) => Micro.gen(function* () {
|
|
138
226
|
const logger = yield* Micro.service(Logger);
|
|
139
227
|
yield* logger.logInfo("Testing for accepted credential signalling support");
|
|
140
|
-
const canSync = yield*
|
|
228
|
+
const canSync = yield* isPasskeySyncSupport;
|
|
141
229
|
if (!canSync)
|
|
142
230
|
return yield* new SyncError({
|
|
143
231
|
code: "PASSKEY_SYNC_UNSUPPORTED",
|
|
@@ -145,7 +233,7 @@ export const signalAcceptedCredentials = (signal) => Micro.gen(function* () {
|
|
|
145
233
|
});
|
|
146
234
|
yield* logger.logInfo("Signalling browser of accepted credentials");
|
|
147
235
|
yield* pipe(Micro.tryPromise({
|
|
148
|
-
try: () => PublicKeyCredential.signalAllAcceptedCredentials(
|
|
236
|
+
try: () => PublicKeyCredential.signalAllAcceptedCredentials(credentials),
|
|
149
237
|
catch: (err) => err instanceof Error ? err : new Error("Unable to signal accepted credentials"),
|
|
150
238
|
}), Micro.timeout(1000), Micro.catchAllDefect((err) => err instanceof Error
|
|
151
239
|
? logger.logWarn(err.message)
|
|
@@ -153,4 +241,25 @@ export const signalAcceptedCredentials = (signal) => Micro.gen(function* () {
|
|
|
153
241
|
yield* logger.logInfo("Accepted credentials signalled");
|
|
154
242
|
return true;
|
|
155
243
|
});
|
|
244
|
+
export const signalCurrentUserDetails = (credential, updates) => Micro.gen(function* () {
|
|
245
|
+
const logger = yield* Micro.service(Logger);
|
|
246
|
+
yield* logger.logInfo("Testing for local passkey update support");
|
|
247
|
+
const canUpdate = yield* isPasskeyUpdateSupport;
|
|
248
|
+
if (!canUpdate)
|
|
249
|
+
return yield* new UpdateError({
|
|
250
|
+
code: "PASSKEY_UPDATE_UNSUPPORTED",
|
|
251
|
+
message: "Passkey update not supported on this device",
|
|
252
|
+
});
|
|
253
|
+
yield* logger.logInfo("Signalling browser to update passkey");
|
|
254
|
+
const { username: name, displayName } = updates;
|
|
255
|
+
const credentialUpdates = { ...credential, name, displayName };
|
|
256
|
+
yield* pipe(Micro.tryPromise({
|
|
257
|
+
try: () => PublicKeyCredential.signalCurrentUserDetails(credentialUpdates),
|
|
258
|
+
catch: (err) => err instanceof Error ? err : new Error("Unable to signal credential update"),
|
|
259
|
+
}), Micro.catchAllDefect((err) => err instanceof Error
|
|
260
|
+
? logger.logWarn(err.message)
|
|
261
|
+
: logger.logWarn("Unable to signal credential update")), Micro.catchAll((err) => logger.logWarn(err.message)), Micro.forkDaemon);
|
|
262
|
+
yield* logger.logInfo("Passkey updated");
|
|
263
|
+
return true;
|
|
264
|
+
});
|
|
156
265
|
//# sourceMappingURL=signals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.js","sourceRoot":"","sources":["../../src/passkey/signals.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,MAAM,EA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pD,KAAK,CAAC,UAAU,CACjB,CAAA;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAExC,OAAO,IAAI,CAAA;AACb,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface.test.d.ts","sourceRoot":"","sources":["../src/surface.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, expect, expectTypeOf, it } from "vitest";
|
|
2
|
+
import * as root from "./index.js";
|
|
3
|
+
import * as unsafe from "./unsafe.js";
|
|
4
|
+
describe("public surface", () => {
|
|
5
|
+
it("exports identical keys for root and unsafe", () => {
|
|
6
|
+
expect(true).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
it("exports shared guards and utilities", () => {
|
|
9
|
+
expectTypeOf(root.isRegistrationSuccess).toBeFunction();
|
|
10
|
+
expectTypeOf(root.isAuthenticationSuccess).toBeFunction();
|
|
11
|
+
expectTypeOf(root.isPasskeyNotFound).toBeFunction();
|
|
12
|
+
expectTypeOf(root.isDuplicatePasskey).toBeFunction();
|
|
13
|
+
expectTypeOf(root.isPasskeyUnsupported).toBeFunction();
|
|
14
|
+
expectTypeOf(root.isOtherPasskeyError).toBeFunction();
|
|
15
|
+
expectTypeOf(root.isDeletionError).toBeFunction();
|
|
16
|
+
expectTypeOf(root.isSyncError).toBeFunction();
|
|
17
|
+
expectTypeOf(root.isUpdateError).toBeFunction();
|
|
18
|
+
expectTypeOf(root.isUnexpectedError).toBeFunction();
|
|
19
|
+
expectTypeOf(root.isPasskeySupport).toBeFunction();
|
|
20
|
+
expectTypeOf(root.isAutofillSupport).toBeFunction();
|
|
21
|
+
expectTypeOf(unsafe.isRegistrationSuccess).toBeFunction();
|
|
22
|
+
expectTypeOf(unsafe.isAuthenticationSuccess).toBeFunction();
|
|
23
|
+
expectTypeOf(unsafe.isPasskeyNotFound).toBeFunction();
|
|
24
|
+
expectTypeOf(unsafe.isDuplicatePasskey).toBeFunction();
|
|
25
|
+
expectTypeOf(unsafe.isPasskeyUnsupported).toBeFunction();
|
|
26
|
+
expectTypeOf(unsafe.isOtherPasskeyError).toBeFunction();
|
|
27
|
+
expectTypeOf(unsafe.isDeletionError).toBeFunction();
|
|
28
|
+
expectTypeOf(unsafe.isSyncError).toBeFunction();
|
|
29
|
+
expectTypeOf(unsafe.isUpdateError).toBeFunction();
|
|
30
|
+
expectTypeOf(unsafe.isUnexpectedError).toBeFunction();
|
|
31
|
+
expectTypeOf(unsafe.isPasskeySupport).toBeFunction();
|
|
32
|
+
expectTypeOf(unsafe.isAutofillSupport).toBeFunction();
|
|
33
|
+
});
|
|
34
|
+
it("keeps shared types identical", () => {
|
|
35
|
+
expect(true).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=surface.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface.test.js","sourceRoot":"","sources":["../src/surface.test.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC3D,OAAO,KAAK,IAAI,MAAM,YAAY,CAAA;AAClC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QAUpD,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,YAAY,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,YAAY,EAAE,CAAA;QACvD,YAAY,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,YAAY,EAAE,CAAA;QACzD,YAAY,CAAC,IAAI,CAAC,iBAAiB,CA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AC,YAAY,EAAE,CAAA;QACjD,YAAY,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,YAAY,EAAE,CAAA;QACrD,YAAY,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,YAAY,EAAE,CAAA;QACpD,YAAY,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,YAAY,EAAE,CAAA;IACvD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QActC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/dist/unsafe.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { PasslockOptions } from "./shared/options";
|
|
2
|
+
import { Logger } from "./logger";
|
|
3
|
+
import { type AuthenticationOptions, type AuthenticationSuccess, type PasskeyNotFound } from "./passkey/authentication";
|
|
4
|
+
import { type RegistrationOptions, type RegistrationSuccess } from "./passkey/registration";
|
|
5
|
+
import { type CredentialMapping, type UpdateUserDetails } from "./passkey/signals";
|
|
6
|
+
export type { PasslockOptions } from "./shared/options";
|
|
7
|
+
export { ConsoleLogger, EventLogger, LogEvent, Logger, LogLevel } from "./logger";
|
|
8
|
+
/**
|
|
9
|
+
* Register a passkey on the local device and store the
|
|
10
|
+
* associated public key in your Passlock vault.
|
|
11
|
+
* @param options
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare const registerPasskey: (options: RegistrationOptions, logger?: typeof Logger.Service) => Promise<RegistrationSuccess>;
|
|
15
|
+
export type { RegistrationError, RegistrationOptions, RegistrationSuccess, } from "./passkey/registration";
|
|
16
|
+
export { isOtherPasskeyError, isPasskeyUnsupported, OtherPasskeyError, PasskeyUnsupportedError, } from "./passkey/errors";
|
|
17
|
+
export { DuplicatePasskeyError, isDuplicatePasskey, isRegistrationSuccess, } from "./passkey/registration";
|
|
18
|
+
export { isUnexpectedError, UnexpectedError } from "./shared/network";
|
|
19
|
+
/**
|
|
20
|
+
* Trigger local passkey authentication then verify the passkey in the Passlock vault.
|
|
21
|
+
* Returns a code and id_token that can be exchanged/decoded in your backend.
|
|
22
|
+
*
|
|
23
|
+
* @param options
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
export declare const authenticatePasskey: (options: AuthenticationOptions, logger?: typeof Logger.Service) => Promise<AuthenticationSuccess>;
|
|
27
|
+
export type { AuthenticationError, AuthenticationOptions, AuthenticationSuccess, PasskeyNotFound, } from "./passkey/authentication";
|
|
28
|
+
export { isAuthenticationSuccess, isPasskeyNotFound, } from "./passkey/authentication";
|
|
29
|
+
export declare const isPasskeyDeletionSupport: () => boolean;
|
|
30
|
+
export declare const isPasskeySyncSupport: () => boolean;
|
|
31
|
+
export declare const isPasskeyUpdateSupport: () => boolean;
|
|
32
|
+
export declare const deletePasskey: (identifiers: string | CredentialMapping | PasskeyNotFound, options: PasslockOptions, logger?: typeof Logger.Service) => Promise<boolean>;
|
|
33
|
+
export type { CredentialMapping } from "./passkey/signals";
|
|
34
|
+
export { DeletionError, isDeletionError } from "./passkey/signals";
|
|
35
|
+
export declare const syncPasskeys: (passkeyIds: Array<string>, options: PasslockOptions, logger?: typeof Logger.Service) => Promise<boolean>;
|
|
36
|
+
export { isSyncError, SyncError } from "./passkey/signals";
|
|
37
|
+
export declare const updateUserDetails: (options: UpdateUserDetails, logger?: typeof Logger.Service) => Promise<boolean>;
|
|
38
|
+
export type { UpdateUserDetails } from "./passkey/signals";
|
|
39
|
+
export { isUpdateError, UpdateError } from "./passkey/signals";
|
|
40
|
+
export { isAutofillSupport, isPasskeySupport } from "./passkey/support";
|
|
41
|
+
//# sourceMappingURL=unsafe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsafe.d.ts","sourceRoot":"","sources":["../src/unsafe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EA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,GAClB,MAAM,0BAA0B,CAAA;AAIjC,eAAO,MAAM,wBAAwB,eAAuD,CAAA;AAC5F,eAAO,MAAM,oBAAoB,eAAmD,CAAA;AACpF,eAAO,MAAM,sBAAsB,eAAqD,CAAA;AAExF,eAAO,MAAM,aAAa,GACxB,aAAa,MAAM,GAAG,iBAAiB,GAAG,eAAe,EACzD,SAAS,eAAe,EACxB,SAAQ,OAAO,MAAM,CAAC,OAAqB,KAC1C,OAAO,CAAC,OAAO,CAOjB,CAAA;AAED,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAElE,eAAO,MAAM,YAAY,GACvB,YAAY,KAAK,CAAC,MAAM,CAAC,EACzB,SAAS,eAAe,EACxB,SAAQ,OAAO,MAAM,CAAC,OAAqB,KAC1C,OAAO,CAAC,OAAO,CAGjB,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE1D,eAAO,MAAM,iBAAiB,GAC5B,SAAS,iBAAiB,EAC1B,SAAQ,OAAO,MAAM,CAAC,OAAqB,KAC1C,OAAO,CAAC,OAAO,CAGjB,CAAA;AAED,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAI9D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA"}
|
package/dist/unsafe.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Micro, pipe } from "effect";
|
|
2
|
+
import { EventLogger, Logger } from "./logger";
|
|
3
|
+
import { AuthenticationHelper, authenticatePasskey as authenticatePasskeyM, } from "./passkey/authentication";
|
|
4
|
+
import { RegistrationHelper, registerPasskey as registerPasskeyM, } from "./passkey/registration";
|
|
5
|
+
import { deletePasskey as deletePasskeyM, isPasskeyDeletionSupport as isPasskeyDeletionSupportM, isPasskeySyncSupport as isPasskeySyncSupportM, isPasskeyUpdateSupport as isPasskeyUpdateSupportM, signalCredentialRemoval, syncPasskeys as syncPasskeysM, updateUserDetails as updateUserDetailsM, } from "./passkey/signals";
|
|
6
|
+
import { runToPromiseUnsafe } from "./shared/promise";
|
|
7
|
+
export { ConsoleLogger, EventLogger, LogEvent, Logger, LogLevel } from "./logger";
|
|
8
|
+
/* Registration */
|
|
9
|
+
/**
|
|
10
|
+
* Register a passkey on the local device and store the
|
|
11
|
+
* associated public key in your Passlock vault.
|
|
12
|
+
* @param options
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export const registerPasskey = async (options, logger = EventLogger) => pipe(registerPasskeyM(options), Micro.provideService(Logger, logger), Micro.provideService(RegistrationHelper, RegistrationHelper.Default), runToPromiseUnsafe);
|
|
16
|
+
export { isOtherPasskeyError, isPasskeyUnsupported, OtherPasskeyError, PasskeyUnsupportedError, } from "./passkey/errors";
|
|
17
|
+
export { DuplicatePasskeyError, isDuplicatePasskey, isRegistrationSuccess, } from "./passkey/registration";
|
|
18
|
+
export { isUnexpectedError, UnexpectedError } from "./shared/network";
|
|
19
|
+
/* Authentication */
|
|
20
|
+
/**
|
|
21
|
+
* Trigger local passkey authentication then verify the passkey in the Passlock vault.
|
|
22
|
+
* Returns a code and id_token that can be exchanged/decoded in your backend.
|
|
23
|
+
*
|
|
24
|
+
* @param options
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
export const authenticatePasskey = (options, logger = EventLogger) => pipe(authenticatePasskeyM(options), Micro.provideService(Logger, logger), Micro.provideService(AuthenticationHelper, AuthenticationHelper.Default), runToPromiseUnsafe);
|
|
28
|
+
export { isAuthenticationSuccess, isPasskeyNotFound, } from "./passkey/authentication";
|
|
29
|
+
/* Signals */
|
|
30
|
+
export const isPasskeyDeletionSupport = () => pipe(isPasskeyDeletionSupportM, Micro.runSync);
|
|
31
|
+
export const isPasskeySyncSupport = () => pipe(isPasskeySyncSupportM, Micro.runSync);
|
|
32
|
+
export const isPasskeyUpdateSupport = () => pipe(isPasskeyUpdateSupportM, Micro.runSync);
|
|
33
|
+
export const deletePasskey = (identifiers, options, logger = EventLogger) => {
|
|
34
|
+
const micro = typeof identifiers === "string"
|
|
35
|
+
? deletePasskeyM(identifiers, options)
|
|
36
|
+
: signalCredentialRemoval(identifiers);
|
|
37
|
+
return pipe(micro, Micro.provideService(Logger, logger), runToPromiseUnsafe);
|
|
38
|
+
};
|
|
39
|
+
export { DeletionError, isDeletionError } from "./passkey/signals";
|
|
40
|
+
export const syncPasskeys = (passkeyIds, options, logger = EventLogger) => {
|
|
41
|
+
const micro = syncPasskeysM(passkeyIds, options);
|
|
42
|
+
return pipe(micro, Micro.provideService(Logger, logger), runToPromiseUnsafe);
|
|
43
|
+
};
|
|
44
|
+
export { isSyncError, SyncError } from "./passkey/signals";
|
|
45
|
+
export const updateUserDetails = (options, logger = EventLogger) => {
|
|
46
|
+
const micro = updateUserDetailsM(options);
|
|
47
|
+
return pipe(micro, Micro.provideService(Logger, logger), runToPromiseUnsafe);
|
|
48
|
+
};
|
|
49
|
+
export { isUpdateError, UpdateError } from "./passkey/signals";
|
|
50
|
+
/* Support */
|
|
51
|
+
export { isAutofillSupport, isPasskeySupport } from "./passkey/support";
|
|
52
|
+
//# sourceMappingURL=unsafe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsafe.js","sourceRoot":"","sources":["../src/unsafe.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EACL,oBAAoB,EAGpB,mBAAmB,IAAI,oBAAoB,GAE5C,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,kBAAkB,EAGlB,eAAe,IAAI,gBAAgB,GACpC,MAA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