@passlock/server 2.1.0 → 2.2.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/dist/effect.d.ts +8 -0
- package/dist/effect.d.ts.map +1 -1
- package/dist/effect.js +8 -0
- package/dist/effect.js.map +1 -1
- package/dist/errors.d.ts +65 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +36 -5
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +54 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -16
- package/dist/index.js.map +1 -1
- package/dist/network.d.ts +3 -3
- package/dist/passkey/passkey.d.ts +242 -10
- package/dist/passkey/passkey.d.ts.map +1 -1
- package/dist/passkey/passkey.js +140 -4
- package/dist/passkey/passkey.js.map +1 -1
- package/dist/principal/principal.d.ts +45 -1
- package/dist/principal/principal.d.ts.map +1 -1
- package/dist/principal/principal.js +27 -0
- package/dist/principal/principal.js.map +1 -1
- package/dist/safe-result.d.ts +33 -0
- package/dist/safe-result.d.ts.map +1 -0
- package/dist/safe-result.js +35 -0
- package/dist/safe-result.js.map +1 -0
- package/dist/safe.d.ts +79 -28
- package/dist/safe.d.ts.map +1 -1
- package/dist/safe.js +82 -28
- package/dist/safe.js.map +1 -1
- package/dist/schemas/passkey.d.ts +148 -0
- package/dist/schemas/passkey.d.ts.map +1 -1
- package/dist/schemas/passkey.js +82 -12
- package/dist/schemas/passkey.js.map +1 -1
- package/dist/schemas/principal.d.ts +50 -0
- package/dist/schemas/principal.d.ts.map +1 -1
- package/dist/schemas/principal.js +30 -0
- package/dist/schemas/principal.js.map +1 -1
- package/dist/schemas/signup.d.ts +20 -0
- package/dist/schemas/signup.d.ts.map +1 -1
- package/dist/schemas/signup.js +10 -0
- package/dist/schemas/signup.js.map +1 -1
- package/dist/shared.d.ts +18 -0
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js.map +1 -1
- package/package.json +6 -6
package/dist/effect.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect-first exports for `@passlock/server`.
|
|
3
|
+
*
|
|
4
|
+
* This entrypoint exposes the original `Effect`-returning functions together
|
|
5
|
+
* with the public schemas used by the package.
|
|
6
|
+
*
|
|
7
|
+
* @module effect
|
|
8
|
+
*/
|
|
1
9
|
export type { AssignUserOptions, ListPasskeyOptions, } from "./passkey/passkey.js";
|
|
2
10
|
export { assignUser, deletePasskey, getPasskey, listPasskeys, } from "./passkey/passkey.js";
|
|
3
11
|
export type {} from "./principal/principal.js";
|
package/dist/effect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,GACb,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC9C,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,GACd,MAAM,0BAA0B,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,YAAY,EACV,oBAAoB,EACpB,eAAe,GAChB,MAAM,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,GACb,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC9C,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,GACd,MAAM,0BAA0B,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,YAAY,EACV,oBAAoB,EACpB,eAAe,GAChB,MAAM,aAAa,CAAA"}
|
package/dist/effect.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect-first exports for `@passlock/server`.
|
|
3
|
+
*
|
|
4
|
+
* This entrypoint exposes the original `Effect`-returning functions together
|
|
5
|
+
* with the public schemas used by the package.
|
|
6
|
+
*
|
|
7
|
+
* @module effect
|
|
8
|
+
*/
|
|
1
9
|
export { assignUser, deletePasskey, getPasskey, listPasskeys, } from "./passkey/passkey.js";
|
|
2
10
|
export { exchangeCode, VerificationError, verifyIdToken, } from "./principal/principal.js";
|
|
3
11
|
export * from "./schemas/index.js";
|
package/dist/effect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.js","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"effect.js","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,GACb,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,GACd,MAAM,0BAA0B,CAAA;AACjC,cAAc,oBAAoB,CAAA","sourcesContent":["/**\n * Effect-first exports for `@passlock/server`.\n *\n * This entrypoint exposes the original `Effect`-returning functions together\n * with the public schemas used by the package.\n *\n * @module effect\n */\n\nexport type {\n AssignUserOptions,\n ListPasskeyOptions,\n} from \"./passkey/passkey.js\"\nexport {\n assignUser,\n deletePasskey,\n getPasskey,\n listPasskeys,\n} from \"./passkey/passkey.js\"\nexport type {} from \"./principal/principal.js\"\nexport {\n exchangeCode,\n VerificationError,\n verifyIdToken,\n} from \"./principal/principal.js\"\nexport * from \"./schemas/index.js\"\nexport type {\n AuthenticatedOptions,\n PasslockOptions,\n} from \"./shared.js\"\n"]}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,39 +1,75 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Public error payload shapes exposed by the promise-based and safe entrypoints.
|
|
3
|
+
*
|
|
4
|
+
* These mirror the tagged errors used internally by the Effect-based
|
|
5
|
+
* implementation, but are represented as plain object types for easier
|
|
6
|
+
* consumption outside Effect.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Error payload returned when a request is not authenticated.
|
|
10
|
+
*
|
|
2
11
|
* @category Authentication
|
|
3
12
|
*/
|
|
4
13
|
export type UnauthorizedError = {
|
|
5
14
|
_tag: "@error/Unauthorized";
|
|
6
15
|
message: string;
|
|
7
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Type guard for {@link UnauthorizedError}.
|
|
19
|
+
*/
|
|
8
20
|
export declare const isUnauthorizedError: (payload: unknown) => payload is UnauthorizedError;
|
|
9
21
|
/**
|
|
22
|
+
* Error payload returned when the API key or tenancy is not permitted to
|
|
23
|
+
* perform the requested action.
|
|
24
|
+
*
|
|
10
25
|
* @category Authentication
|
|
11
26
|
*/
|
|
12
27
|
export type ForbiddenError = {
|
|
13
28
|
_tag: "@error/Forbidden";
|
|
14
29
|
message: string;
|
|
15
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Type guard for {@link ForbiddenError}.
|
|
33
|
+
*/
|
|
16
34
|
export declare const isForbiddenError: (payload: unknown) => payload is ForbiddenError;
|
|
17
35
|
/**
|
|
36
|
+
* Error payload returned when an exchanged code is invalid or expired.
|
|
37
|
+
*
|
|
18
38
|
* @category Principal
|
|
19
39
|
*/
|
|
20
40
|
export type InvalidCodeError = {
|
|
21
41
|
_tag: "@error/InvalidCode";
|
|
22
42
|
message: string;
|
|
23
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Type guard for {@link InvalidCodeError}.
|
|
46
|
+
*/
|
|
24
47
|
export declare const isInvalidCodeError: (payload: unknown) => payload is InvalidCodeError;
|
|
25
48
|
/**
|
|
49
|
+
* Error payload returned when `verifyIdToken` cannot validate a token.
|
|
50
|
+
*
|
|
26
51
|
* @category Principal
|
|
27
52
|
*/
|
|
28
53
|
export type VerificationError = {
|
|
29
54
|
_tag: "@error/Verification";
|
|
30
55
|
message: string;
|
|
31
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Type guard for {@link VerificationError}.
|
|
59
|
+
*/
|
|
32
60
|
export declare const isVerificationError: (payload: unknown) => payload is VerificationError;
|
|
61
|
+
/**
|
|
62
|
+
* Error payload returned when the supplied tenancy identifier is invalid.
|
|
63
|
+
*
|
|
64
|
+
* @category Authentication
|
|
65
|
+
*/
|
|
33
66
|
export type InvalidTenancyError = {
|
|
34
67
|
_tag: "@error/InvalidTenancy";
|
|
35
68
|
message: string;
|
|
36
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Type guard for {@link InvalidTenancyError}.
|
|
72
|
+
*/
|
|
37
73
|
export declare const isInvalidTenancyError: (payload: unknown) => payload is InvalidTenancyError;
|
|
38
74
|
/**
|
|
39
75
|
* Error payload returned when a passkey cannot be found for a given
|
|
@@ -47,25 +83,54 @@ export type PasskeyNotFoundError = {
|
|
|
47
83
|
credentialId: string;
|
|
48
84
|
rpId: string;
|
|
49
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* Type guard for {@link PasskeyNotFoundError}.
|
|
88
|
+
*/
|
|
50
89
|
export declare const isPasskeyNotFoundError: (payload: unknown) => payload is PasskeyNotFoundError;
|
|
90
|
+
/**
|
|
91
|
+
* Error payload returned when a requested resource cannot be found.
|
|
92
|
+
*
|
|
93
|
+
* @category Passkeys
|
|
94
|
+
*/
|
|
51
95
|
export type NotFoundError = {
|
|
52
96
|
_tag: "@error/NotFound";
|
|
53
97
|
message: string;
|
|
54
98
|
};
|
|
99
|
+
/**
|
|
100
|
+
* Type guard for {@link NotFoundError}.
|
|
101
|
+
*/
|
|
55
102
|
export declare const isNotFoundError: (payload: unknown) => payload is NotFoundError;
|
|
103
|
+
/**
|
|
104
|
+
* Error payload returned when an email address is invalid.
|
|
105
|
+
*/
|
|
56
106
|
export type InvalidEmailError = {
|
|
57
107
|
_tag: "@error/InvalidEmail";
|
|
58
108
|
message: string;
|
|
59
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* Type guard for {@link InvalidEmailError}.
|
|
112
|
+
*/
|
|
60
113
|
export declare const isInvalidEmailError: (payload: unknown) => payload is InvalidEmailError;
|
|
114
|
+
/**
|
|
115
|
+
* Error payload returned when an email address already exists.
|
|
116
|
+
*/
|
|
61
117
|
export type DuplicateEmailError = {
|
|
62
118
|
_tag: "@error/DuplicateEmail";
|
|
63
119
|
message: string;
|
|
64
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* Type guard for {@link DuplicateEmailError}.
|
|
123
|
+
*/
|
|
65
124
|
export declare const isDuplicateEmailError: (payload: unknown) => payload is DuplicateEmailError;
|
|
125
|
+
/**
|
|
126
|
+
* Error payload returned when the request body is invalid.
|
|
127
|
+
*/
|
|
66
128
|
export type BadRequestError = {
|
|
67
129
|
_tag: "@error/BadRequest";
|
|
68
130
|
message: string;
|
|
69
131
|
};
|
|
132
|
+
/**
|
|
133
|
+
* Type guard for {@link BadRequestError}.
|
|
134
|
+
*/
|
|
70
135
|
export declare const isBadRequestError: (payload: unknown) => payload is BadRequestError;
|
|
71
136
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiBH;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAA;IAC3B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,YA1BpB,OAAO,KAAG,OAAO,qBA4B5B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7IhB,OAAO,KAAG,OAAO,iBA6I4C,CAAA;AAIzE;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAA;IAC3B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,YA5JpB,OAAO,KAAG,OAAO,qBA8J5B,CAAA;AAID;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,uBAAuB,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,YA7KtB,OAAO,KAAG,OAAO,uBA+K5B,CAAA;AAID;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,mBAAmB,CAAA;IACzB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,YA9LlB,OAAO,KAAG,OAAO,mBA8LkD,CAAA"}
|
package/dist/errors.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
1
|
+
/**
|
|
2
|
+
* Public error payload shapes exposed by the promise-based and safe entrypoints.
|
|
3
|
+
*
|
|
4
|
+
* These mirror the tagged errors used internally by the Effect-based
|
|
5
|
+
* implementation, but are represented as plain object types for easier
|
|
6
|
+
* consumption outside Effect.
|
|
6
7
|
*/
|
|
7
8
|
const isTagged = (tag) => (payload) => {
|
|
8
9
|
if (typeof payload !== "object")
|
|
@@ -17,14 +18,44 @@ const isTagged = (tag) => (payload) => {
|
|
|
17
18
|
return false;
|
|
18
19
|
return true;
|
|
19
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Type guard for {@link UnauthorizedError}.
|
|
23
|
+
*/
|
|
20
24
|
export const isUnauthorizedError = isTagged("@error/Unauthorized");
|
|
25
|
+
/**
|
|
26
|
+
* Type guard for {@link ForbiddenError}.
|
|
27
|
+
*/
|
|
21
28
|
export const isForbiddenError = isTagged("@error/Forbidden");
|
|
29
|
+
/**
|
|
30
|
+
* Type guard for {@link InvalidCodeError}.
|
|
31
|
+
*/
|
|
22
32
|
export const isInvalidCodeError = isTagged("@error/InvalidCode");
|
|
33
|
+
/**
|
|
34
|
+
* Type guard for {@link VerificationError}.
|
|
35
|
+
*/
|
|
23
36
|
export const isVerificationError = isTagged("@error/Verification");
|
|
37
|
+
/**
|
|
38
|
+
* Type guard for {@link InvalidTenancyError}.
|
|
39
|
+
*/
|
|
24
40
|
export const isInvalidTenancyError = isTagged("@error/InvalidTenancy");
|
|
41
|
+
/**
|
|
42
|
+
* Type guard for {@link PasskeyNotFoundError}.
|
|
43
|
+
*/
|
|
25
44
|
export const isPasskeyNotFoundError = isTagged("@error/PasskeyNotFound");
|
|
45
|
+
/**
|
|
46
|
+
* Type guard for {@link NotFoundError}.
|
|
47
|
+
*/
|
|
26
48
|
export const isNotFoundError = isTagged("@error/NotFound");
|
|
49
|
+
/**
|
|
50
|
+
* Type guard for {@link InvalidEmailError}.
|
|
51
|
+
*/
|
|
27
52
|
export const isInvalidEmailError = isTagged("@error/InvalidEmail");
|
|
53
|
+
/**
|
|
54
|
+
* Type guard for {@link DuplicateEmailError}.
|
|
55
|
+
*/
|
|
28
56
|
export const isDuplicateEmailError = isTagged("@error/DuplicateEmail");
|
|
57
|
+
/**
|
|
58
|
+
* Type guard for {@link BadRequestError}.
|
|
59
|
+
*/
|
|
29
60
|
export const isBadRequestError = isTagged("@error/BadRequest");
|
|
30
61
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GA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;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAkB,mBAAmB,CAAC,CAAA","sourcesContent":["/**\n * Public error payload shapes exposed by the promise-based and safe entrypoints.\n *\n * These mirror the tagged errors used internally by the Effect-based\n * implementation, but are represented as plain object types for easier\n * consumption outside Effect.\n */\n\nconst isTagged =\n <A extends { _tag: string }>(tag: A[\"_tag\"]) =>\n (payload: unknown): payload is A => {\n if (typeof payload !== \"object\") return false\n if (payload === null) return false\n\n if (!(\"_tag\" in payload)) return false\n if (typeof payload._tag !== \"string\") return false\n if (payload._tag !== tag) return false\n\n return true\n }\n\n/* Unauthorized */\n\n/**\n * Error payload returned when a request is not authenticated.\n *\n * @category Authentication\n */\nexport type UnauthorizedError = {\n _tag: \"@error/Unauthorized\"\n message: string\n}\n\n/**\n * Type guard for {@link UnauthorizedError}.\n */\nexport const isUnauthorizedError = isTagged<UnauthorizedError>(\n \"@error/Unauthorized\"\n)\n\n/* Forbidden */\n\n/**\n * Error payload returned when the API key or tenancy is not permitted to\n * perform the requested action.\n *\n * @category Authentication\n */\nexport type ForbiddenError = {\n _tag: \"@error/Forbidden\"\n message: string\n}\n\n/**\n * Type guard for {@link ForbiddenError}.\n */\nexport const isForbiddenError = isTagged<ForbiddenError>(\"@error/Forbidden\")\n\n/* InvalidCode */\n\n/**\n * Error payload returned when an exchanged code is invalid or expired.\n *\n * @category Principal\n */\nexport type InvalidCodeError = {\n _tag: \"@error/InvalidCode\"\n message: string\n}\n\n/**\n * Type guard for {@link InvalidCodeError}.\n */\nexport const isInvalidCodeError =\n isTagged<InvalidCodeError>(\"@error/InvalidCode\")\n\n/* VerificationFailure */\n\n/**\n * Error payload returned when `verifyIdToken` cannot validate a token.\n *\n * @category Principal\n */\nexport type VerificationError = {\n _tag: \"@error/Verification\"\n message: string\n}\n\n/**\n * Type guard for {@link VerificationError}.\n */\nexport const isVerificationError = isTagged<VerificationError>(\n \"@error/Verification\"\n)\n\n/* InvalidTenancy */\n\n/**\n * Error payload returned when the supplied tenancy identifier is invalid.\n *\n * @category Authentication\n */\nexport type InvalidTenancyError = {\n _tag: \"@error/InvalidTenancy\"\n message: string\n}\n\n/**\n * Type guard for {@link InvalidTenancyError}.\n */\nexport const isInvalidTenancyError = isTagged<InvalidTenancyError>(\n \"@error/InvalidTenancy\"\n)\n\n/* PasskeyNotFound */\n\n/**\n * Error payload returned when a passkey cannot be found for a given\n * authentication attempt.\n *\n * @category Passkeys\n */\nexport type PasskeyNotFoundError = {\n _tag: \"@error/PasskeyNotFound\"\n message: string\n credentialId: string\n rpId: string\n}\n\n/**\n * Type guard for {@link PasskeyNotFoundError}.\n */\nexport const isPasskeyNotFoundError = isTagged<PasskeyNotFoundError>(\n \"@error/PasskeyNotFound\"\n)\n\n/* NotFound */\n\n/**\n * Error payload returned when a requested resource cannot be found.\n *\n * @category Passkeys\n */\nexport type NotFoundError = {\n _tag: \"@error/NotFound\"\n message: string\n}\n\n/**\n * Type guard for {@link NotFoundError}.\n */\nexport const isNotFoundError = isTagged<NotFoundError>(\"@error/NotFound\")\n\n/* InvalidEmail */\n\n/**\n * Error payload returned when an email address is invalid.\n */\nexport type InvalidEmailError = {\n _tag: \"@error/InvalidEmail\"\n message: string\n}\n\n/**\n * Type guard for {@link InvalidEmailError}.\n */\nexport const isInvalidEmailError = isTagged<InvalidEmailError>(\n \"@error/InvalidEmail\"\n)\n\n/* DuplicateEmail */\n\n/**\n * Error payload returned when an email address already exists.\n */\nexport type DuplicateEmailError = {\n _tag: \"@error/DuplicateEmail\"\n message: string\n}\n\n/**\n * Type guard for {@link DuplicateEmailError}.\n */\nexport const isDuplicateEmailError = isTagged<DuplicateEmailError>(\n \"@error/DuplicateEmail\"\n)\n\n/* BadRequest */\n\n/**\n * Error payload returned when the request body is invalid.\n */\nexport type BadRequestError = {\n _tag: \"@error/BadRequest\"\n message: string\n}\n\n/**\n * Type guard for {@link BadRequestError}.\n */\nexport const isBadRequestError = isTagged<BadRequestError>(\"@error/BadRequest\")\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Promise-based functions that reject with tagged error payloads for expected
|
|
3
|
+
* API failures.
|
|
4
|
+
*
|
|
5
|
+
* Unexpected runtime defects may still throw.
|
|
3
6
|
*
|
|
4
7
|
* @categoryDescription Passkeys
|
|
5
8
|
* Functions and related types for managing passkeys
|
|
6
9
|
*
|
|
7
10
|
* @showCategories
|
|
8
11
|
*
|
|
9
|
-
* @module unsafe
|
|
12
|
+
* @module unsafe (default)
|
|
10
13
|
*/
|
|
11
|
-
import type { AssignUserOptions, DeletePasskeyOptions, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey,
|
|
14
|
+
import type { AssignUserOptions, DeletePasskeyOptions, DeleteUserPasskeysOptions, DeletedPasskeys, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey, UpdatedCredentials, UpdatePasskeyOptions, UpdateUsernamesOptions } from "./passkey/passkey.js";
|
|
12
15
|
import type { ExchangeCodeOptions, VerifyIdTokenOptions } from "./principal/principal.js";
|
|
13
16
|
import type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
|
|
14
17
|
/**
|
|
15
|
-
*
|
|
18
|
+
* Assign a custom user ID to a passkey in the Passlock vault.
|
|
19
|
+
*
|
|
20
|
+
* This updates Passlock's server-side mapping for the passkey. It does not
|
|
21
|
+
* change the underlying WebAuthn credential's `userId`.
|
|
16
22
|
*
|
|
17
23
|
* @param request
|
|
18
24
|
* @returns A promise resolving to the updated passkey.
|
|
@@ -23,7 +29,10 @@ import type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
|
|
|
23
29
|
*/
|
|
24
30
|
export declare const assignUser: (request: AssignUserOptions) => Promise<Passkey>;
|
|
25
31
|
/**
|
|
26
|
-
*
|
|
32
|
+
* Update a passkey's custom user ID and/or username metadata.
|
|
33
|
+
*
|
|
34
|
+
* Updating the username only affects the metadata stored in the vault. It does
|
|
35
|
+
* not affect whether the passkey can be used for authentication.
|
|
27
36
|
*
|
|
28
37
|
* @param request
|
|
29
38
|
* @returns A promise resolving to the updated passkey.
|
|
@@ -34,18 +43,30 @@ export declare const assignUser: (request: AssignUserOptions) => Promise<Passkey
|
|
|
34
43
|
*/
|
|
35
44
|
export declare const updatePasskey: (request: UpdatePasskeyOptions) => Promise<Passkey>;
|
|
36
45
|
/**
|
|
37
|
-
*
|
|
46
|
+
* Update the username and/or display name for all passkeys belonging to a given user.
|
|
47
|
+
*
|
|
48
|
+
* **Important:** changing these values has no bearing on authentication, as
|
|
49
|
+
* it's typically only used in the client-side component of the passkey
|
|
50
|
+
* (so the user knows which account the passkey relates to).
|
|
51
|
+
*
|
|
52
|
+
* However you might choose to align the names in your vault with the
|
|
53
|
+
* client-side component to simplify end user support.
|
|
54
|
+
*
|
|
55
|
+
* **Note:** This can be used alongside `@passlock/client`'s
|
|
56
|
+
* `updatePasskeyUsernames` helper to update those details on the user's device.
|
|
38
57
|
*
|
|
39
58
|
* @param request
|
|
40
|
-
* @returns A promise resolving to
|
|
41
|
-
*
|
|
42
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
59
|
+
* @returns A promise resolving to an {@link UpdatedCredentials} payload.
|
|
60
|
+
* Its `credentials` array can be passed to the client's `updatePasskeyUsernames` function.
|
|
43
61
|
*
|
|
44
62
|
* @category Passkeys
|
|
45
63
|
*/
|
|
46
|
-
export declare const updatePasskeyUsernames: (request:
|
|
64
|
+
export declare const updatePasskeyUsernames: (request: UpdateUsernamesOptions) => Promise<UpdatedCredentials>;
|
|
47
65
|
/**
|
|
48
|
-
*
|
|
66
|
+
* Delete a passkey from the Passlock vault.
|
|
67
|
+
*
|
|
68
|
+
* This does not remove the passkey from the user's device. Use
|
|
69
|
+
* `@passlock/client` to coordinate client-side removal when needed.
|
|
49
70
|
*
|
|
50
71
|
* @param options
|
|
51
72
|
* @returns A promise resolving to the deleted passkey.
|
|
@@ -56,7 +77,20 @@ export declare const updatePasskeyUsernames: (request: UpdatePasskeyUsernamesOpt
|
|
|
56
77
|
*/
|
|
57
78
|
export declare const deletePasskey: (options: DeletePasskeyOptions) => Promise<Passkey>;
|
|
58
79
|
/**
|
|
59
|
-
* Call the Passlock backend API to
|
|
80
|
+
* Call the Passlock backend API to delete all passkeys associated with a user.
|
|
81
|
+
*
|
|
82
|
+
* @param request
|
|
83
|
+
* @returns A promise resolving to a {@link DeletedPasskeys} payload.
|
|
84
|
+
* Its `deleted` array can be passed directly into `@passlock/client`'s
|
|
85
|
+
* `deleteUserPasskeys` helper for follow-up client-side passkey removal.
|
|
86
|
+
* @throws {@link NotFoundError} if the user does not exist
|
|
87
|
+
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
88
|
+
*
|
|
89
|
+
* @category Passkeys
|
|
90
|
+
*/
|
|
91
|
+
export declare const deleteUserPasskeys: (request: DeleteUserPasskeysOptions) => Promise<DeletedPasskeys>;
|
|
92
|
+
/**
|
|
93
|
+
* Fetch a single passkey from the Passlock vault.
|
|
60
94
|
*
|
|
61
95
|
* @param options
|
|
62
96
|
* @returns A promise resolving to the passkey.
|
|
@@ -78,7 +112,8 @@ export declare const getPasskey: (options: GetPasskeyOptions) => Promise<Passkey
|
|
|
78
112
|
*/
|
|
79
113
|
export declare const listPasskeys: (options: ListPasskeyOptions) => Promise<FindAllPasskeys>;
|
|
80
114
|
/**
|
|
81
|
-
*
|
|
115
|
+
* Exchange a short-lived code from `@passlock/client` for an
|
|
116
|
+
* {@link ExtendedPrincipal}.
|
|
82
117
|
*
|
|
83
118
|
* @param options
|
|
84
119
|
* @returns A promise resolving to an extended principal.
|
|
@@ -90,11 +125,12 @@ export declare const listPasskeys: (options: ListPasskeyOptions) => Promise<Find
|
|
|
90
125
|
export declare const exchangeCode: (options: ExchangeCodeOptions) => Promise<ExtendedPrincipal>;
|
|
91
126
|
/**
|
|
92
127
|
* Decode and verify a Passlock `id_token` (JWT).
|
|
93
|
-
*
|
|
128
|
+
*
|
|
129
|
+
* Note: this will make a network call to
|
|
94
130
|
* `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)
|
|
95
131
|
* to fetch the relevant public key. The response will be cached, however
|
|
96
|
-
* bear in mind that for
|
|
97
|
-
* cold start so might
|
|
132
|
+
* bear in mind that for environments such as AWS Lambda it will make the call
|
|
133
|
+
* on each cold start, so it might be slower than {@link exchangeCode}.
|
|
98
134
|
*
|
|
99
135
|
* @param options
|
|
100
136
|
* @returns A promise resolving to the verified principal.
|
|
@@ -105,8 +141,8 @@ export declare const exchangeCode: (options: ExchangeCodeOptions) => Promise<Ext
|
|
|
105
141
|
export declare const verifyIdToken: (options: VerifyIdTokenOptions) => Promise<Principal>;
|
|
106
142
|
export type { BadRequestError, DuplicateEmailError, ForbiddenError, InvalidCodeError, InvalidEmailError, InvalidTenancyError, NotFoundError, PasskeyNotFoundError, UnauthorizedError, VerificationError, } from "./errors.js";
|
|
107
143
|
export { isBadRequestError, isDuplicateEmailError, isForbiddenError, isInvalidCodeError, isInvalidEmailError, isInvalidTenancyError, isNotFoundError, isPasskeyNotFoundError, isUnauthorizedError, isVerificationError, } from "./errors.js";
|
|
108
|
-
export type { AssignUserOptions, Credential, DeletePasskeyOptions, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey, PasskeySummary, Platform, UpdatedPasskeys,
|
|
109
|
-
export { isPasskey, isPasskeySummary, isUpdatedPasskeys,
|
|
144
|
+
export type { AssignUserOptions, Credential, DeletePasskeyOptions, DeleteUserPasskeysOptions, DeletedPasskeys, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey, PasskeyCredential, PasskeySummary, Platform, UpdatedPasskeys, UpdatedCredentials as UpdatedUserDetails, UpdatePasskeyOptions, UpdateUsernamesOptions as UpdateUserDetailsOptions, } from "./passkey/passkey.js";
|
|
145
|
+
export { isDeletedPasskeys, isPasskey, isPasskeySummary, isUpdatedPasskeys, isUpdatedUserDetails, } from "./passkey/passkey.js";
|
|
110
146
|
export type { ExchangeCodeOptions, VerifyIdTokenOptions, } from "./principal/principal.js";
|
|
111
147
|
export type { CredentialDeviceType, Transports, } from "./schemas/passkey.js";
|
|
112
148
|
export type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,OAAO,EACP,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,sBAAsB,CAAA;AAU7B,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,0BAA0B,CAAA;AAKjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAE1E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,iBAAiB,KAAG,OAAO,CAAC,OAAO,CACxB,CAAA;AAE/C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,oBAAoB,KAC5B,OAAO,CAAC,OAAO,CAAqD,CAAA;AAEvE;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,sBAAsB,KAC9B,OAAO,CAAC,kBAAkB,CAC8B,CAAA;AAE3D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,oBAAoB,KAC5B,OAAO,CAAC,OAAO,CAAqD,CAAA;AAEvE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,G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,EACnB,oBAAoB,GACrB,MAAM,0BAA0B,CAAA;AACjC,YAAY,EACV,oBAAoB,EACpB,UAAU,GACX,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAC1E,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzE,YAAY,EACV,oBAAoB,EACpB,eAAe,GAChB,MAAM,aAAa,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Promise-based functions that reject with tagged error payloads for expected
|
|
3
|
+
* API failures.
|
|
4
|
+
*
|
|
5
|
+
* Unexpected runtime defects may still throw.
|
|
3
6
|
*
|
|
4
7
|
* @categoryDescription Passkeys
|
|
5
8
|
* Functions and related types for managing passkeys
|
|
6
9
|
*
|
|
7
10
|
* @showCategories
|
|
8
11
|
*
|
|
9
|
-
* @module unsafe
|
|
12
|
+
* @module unsafe (default)
|
|
10
13
|
*/
|
|
11
14
|
import { Effect, pipe } from "effect";
|
|
12
|
-
import { assignUser as assignUserE, deletePasskey as deletePasskeyE, getPasskey as getPasskeyE, listPasskeys as listPasskeysE, updatePasskey as updatePasskeyE, updatePasskeyUsernames as updatePasskeyUsernamesE, } from "./passkey/passkey.js";
|
|
15
|
+
import { assignUser as assignUserE, deletePasskey as deletePasskeyE, deleteUserPasskeys as deleteUserPasskeysE, getPasskey as getPasskeyE, listPasskeys as listPasskeysE, updatePasskey as updatePasskeyE, updatePasskeyUsernames as updatePasskeyUsernamesE, } from "./passkey/passkey.js";
|
|
13
16
|
import { exchangeCode as exchangeCodeE, verifyIdToken as verifyIdTokenE, } from "./principal/principal.js";
|
|
14
17
|
/**
|
|
15
|
-
*
|
|
18
|
+
* Assign a custom user ID to a passkey in the Passlock vault.
|
|
19
|
+
*
|
|
20
|
+
* This updates Passlock's server-side mapping for the passkey. It does not
|
|
21
|
+
* change the underlying WebAuthn credential's `userId`.
|
|
16
22
|
*
|
|
17
23
|
* @param request
|
|
18
24
|
* @returns A promise resolving to the updated passkey.
|
|
@@ -23,7 +29,10 @@ import { exchangeCode as exchangeCodeE, verifyIdToken as verifyIdTokenE, } from
|
|
|
23
29
|
*/
|
|
24
30
|
export const assignUser = (request) => pipe(assignUserE(request), Effect.runPromise);
|
|
25
31
|
/**
|
|
26
|
-
*
|
|
32
|
+
* Update a passkey's custom user ID and/or username metadata.
|
|
33
|
+
*
|
|
34
|
+
* Updating the username only affects the metadata stored in the vault. It does
|
|
35
|
+
* not affect whether the passkey can be used for authentication.
|
|
27
36
|
*
|
|
28
37
|
* @param request
|
|
29
38
|
* @returns A promise resolving to the updated passkey.
|
|
@@ -34,18 +43,30 @@ export const assignUser = (request) => pipe(assignUserE(request), Effect.runProm
|
|
|
34
43
|
*/
|
|
35
44
|
export const updatePasskey = (request) => pipe(updatePasskeyE(request), Effect.runPromise);
|
|
36
45
|
/**
|
|
37
|
-
*
|
|
46
|
+
* Update the username and/or display name for all passkeys belonging to a given user.
|
|
47
|
+
*
|
|
48
|
+
* **Important:** changing these values has no bearing on authentication, as
|
|
49
|
+
* it's typically only used in the client-side component of the passkey
|
|
50
|
+
* (so the user knows which account the passkey relates to).
|
|
51
|
+
*
|
|
52
|
+
* However you might choose to align the names in your vault with the
|
|
53
|
+
* client-side component to simplify end user support.
|
|
54
|
+
*
|
|
55
|
+
* **Note:** This can be used alongside `@passlock/client`'s
|
|
56
|
+
* `updatePasskeyUsernames` helper to update those details on the user's device.
|
|
38
57
|
*
|
|
39
58
|
* @param request
|
|
40
|
-
* @returns A promise resolving to
|
|
41
|
-
*
|
|
42
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
59
|
+
* @returns A promise resolving to an {@link UpdatedCredentials} payload.
|
|
60
|
+
* Its `credentials` array can be passed to the client's `updatePasskeyUsernames` function.
|
|
43
61
|
*
|
|
44
62
|
* @category Passkeys
|
|
45
63
|
*/
|
|
46
64
|
export const updatePasskeyUsernames = (request) => pipe(updatePasskeyUsernamesE(request), Effect.runPromise);
|
|
47
65
|
/**
|
|
48
|
-
*
|
|
66
|
+
* Delete a passkey from the Passlock vault.
|
|
67
|
+
*
|
|
68
|
+
* This does not remove the passkey from the user's device. Use
|
|
69
|
+
* `@passlock/client` to coordinate client-side removal when needed.
|
|
49
70
|
*
|
|
50
71
|
* @param options
|
|
51
72
|
* @returns A promise resolving to the deleted passkey.
|
|
@@ -56,7 +77,20 @@ export const updatePasskeyUsernames = (request) => pipe(updatePasskeyUsernamesE(
|
|
|
56
77
|
*/
|
|
57
78
|
export const deletePasskey = (options) => pipe(deletePasskeyE(options), Effect.runPromise);
|
|
58
79
|
/**
|
|
59
|
-
* Call the Passlock backend API to
|
|
80
|
+
* Call the Passlock backend API to delete all passkeys associated with a user.
|
|
81
|
+
*
|
|
82
|
+
* @param request
|
|
83
|
+
* @returns A promise resolving to a {@link DeletedPasskeys} payload.
|
|
84
|
+
* Its `deleted` array can be passed directly into `@passlock/client`'s
|
|
85
|
+
* `deleteUserPasskeys` helper for follow-up client-side passkey removal.
|
|
86
|
+
* @throws {@link NotFoundError} if the user does not exist
|
|
87
|
+
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
88
|
+
*
|
|
89
|
+
* @category Passkeys
|
|
90
|
+
*/
|
|
91
|
+
export const deleteUserPasskeys = (request) => pipe(deleteUserPasskeysE(request), Effect.runPromise);
|
|
92
|
+
/**
|
|
93
|
+
* Fetch a single passkey from the Passlock vault.
|
|
60
94
|
*
|
|
61
95
|
* @param options
|
|
62
96
|
* @returns A promise resolving to the passkey.
|
|
@@ -78,7 +112,8 @@ export const getPasskey = (options) => pipe(getPasskeyE(options), Effect.runProm
|
|
|
78
112
|
*/
|
|
79
113
|
export const listPasskeys = (options) => pipe(listPasskeysE(options), Effect.runPromise);
|
|
80
114
|
/**
|
|
81
|
-
*
|
|
115
|
+
* Exchange a short-lived code from `@passlock/client` for an
|
|
116
|
+
* {@link ExtendedPrincipal}.
|
|
82
117
|
*
|
|
83
118
|
* @param options
|
|
84
119
|
* @returns A promise resolving to an extended principal.
|
|
@@ -90,11 +125,12 @@ export const listPasskeys = (options) => pipe(listPasskeysE(options), Effect.run
|
|
|
90
125
|
export const exchangeCode = (options) => pipe(exchangeCodeE(options), Effect.runPromise);
|
|
91
126
|
/**
|
|
92
127
|
* Decode and verify a Passlock `id_token` (JWT).
|
|
93
|
-
*
|
|
128
|
+
*
|
|
129
|
+
* Note: this will make a network call to
|
|
94
130
|
* `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)
|
|
95
131
|
* to fetch the relevant public key. The response will be cached, however
|
|
96
|
-
* bear in mind that for
|
|
97
|
-
* cold start so might
|
|
132
|
+
* bear in mind that for environments such as AWS Lambda it will make the call
|
|
133
|
+
* on each cold start, so it might be slower than {@link exchangeCode}.
|
|
98
134
|
*
|
|
99
135
|
* @param options
|
|
100
136
|
* @returns A promise resolving to the verified principal.
|
|
@@ -104,6 +140,6 @@ export const exchangeCode = (options) => pipe(exchangeCodeE(options), Effect.run
|
|
|
104
140
|
*/
|
|
105
141
|
export const verifyIdToken = (options) => pipe(verifyIdTokenE(options), Effect.runPromise);
|
|
106
142
|
export { isBadRequestError, isDuplicateEmailError, isForbiddenError, isInvalidCodeError, isInvalidEmailError, isInvalidTenancyError, isNotFoundError, isPasskeyNotFoundError, isUnauthorizedError, isVerificationError, } from "./errors.js";
|
|
107
|
-
export { isPasskey, isPasskeySummary, isUpdatedPasskeys,
|
|
143
|
+
export { isDeletedPasskeys, isPasskey, isPasskeySummary, isUpdatedPasskeys, isUpdatedUserDetails, } from "./passkey/passkey.js";
|
|
108
144
|
export { isExtendedPrincipal, isPrincipal } from "./schemas/principal.js";
|
|
109
145
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../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AM,YAAY,GAAG,CAC1B,OAA2B,EACD,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAE9E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAA4B,EACA,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAEhF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAA6B,EACT,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAgBzE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,aAAa,CAAA;AAgBpB,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAU7B,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA","sourcesContent":["/**\n * Unsafe functions that could potentially throw errors.\n *\n * @categoryDescription Passkeys\n * Functions and related types for managing passkeys\n *\n * @showCategories\n *\n * @module unsafe\n */\n\nimport { Effect, pipe } from \"effect\"\nimport type {\n AssignUserOptions,\n DeletePasskeyOptions,\n FindAllPasskeys,\n GetPasskeyOptions,\n ListPasskeyOptions,\n Passkey,\n UpdatedPasskeyUsernames,\n UpdatePasskeyOptions,\n UpdatePasskeyUsernamesOptions,\n} from \"./passkey/passkey.js\"\nimport {\n assignUser as assignUserE,\n deletePasskey as deletePasskeyE,\n getPasskey as getPasskeyE,\n listPasskeys as listPasskeysE,\n updatePasskey as updatePasskeyE,\n updatePasskeyUsernames as updatePasskeyUsernamesE,\n} from \"./passkey/passkey.js\"\nimport type {\n ExchangeCodeOptions,\n VerifyIdTokenOptions,\n} from \"./principal/principal.js\"\nimport {\n exchangeCode as exchangeCodeE,\n verifyIdToken as verifyIdTokenE,\n} from \"./principal/principal.js\"\nimport type { ExtendedPrincipal, Principal } from \"./schemas/principal.js\"\n\n/**\n * Call the Passlock backend API to assign a userId to an authenticator\n *\n * @param request\n * @returns A promise resolving to the updated passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const assignUser = (request: AssignUserOptions): Promise<Passkey> =>\n pipe(assignUserE(request), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to update passkey properties\n *\n * @param request\n * @returns A promise resolving to the updated passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const updatePasskey = (\n request: UpdatePasskeyOptions\n): Promise<Passkey> => pipe(updatePasskeyE(request), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to update all passkeys for a given user\n *\n * @param request\n * @returns A promise resolving to updated usernames for matching passkeys.\n * @throws {@link NotFoundError} if no passkeys are found for the given user\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const updatePasskeyUsernames = (\n request: UpdatePasskeyUsernamesOptions\n): Promise<UpdatedPasskeyUsernames> =>\n pipe(updatePasskeyUsernamesE(request), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to delete an authenticator\n *\n * @param options\n * @returns A promise resolving to the deleted passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const deletePasskey = (\n options: DeletePasskeyOptions\n): Promise<Passkey> => pipe(deletePasskeyE(options), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to fetch an authenticator\n *\n * @param options\n * @returns A promise resolving to the passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const getPasskey = (options: GetPasskeyOptions): Promise<Passkey> =>\n pipe(getPasskeyE(options), Effect.runPromise)\n\n/**\n * List passkeys for the given tenancy. Note this could return a cursor,\n * in which case the function should be called again with the given cursor.\n *\n * @param options\n * @returns A promise resolving to a page of passkey summaries.\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const listPasskeys = (\n options: ListPasskeyOptions\n): Promise<FindAllPasskeys> => pipe(listPasskeysE(options), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to exchange a code for an ExtendedPrincipal\n *\n * @param options\n * @returns A promise resolving to an extended principal.\n * @throws {@link InvalidCodeError} if the code is invalid or expired\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Principal\n */\nexport const exchangeCode = (\n options: ExchangeCodeOptions\n): Promise<ExtendedPrincipal> => pipe(exchangeCodeE(options), Effect.runPromise)\n\n/**\n * Decode and verify a Passlock `id_token` (JWT).\n * Note: This will make a network call to\n * `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)\n * to fetch the relevant public key. The response will be cached, however\n * bear in mind that for something like AWS Lambda it will make the call on every\n * cold start so might actually be slower than {@link exchangeCode}\n *\n * @param options\n * @returns A promise resolving to the verified principal.\n * @throws {@link VerificationError} if token verification fails\n *\n * @category Principal\n */\nexport const verifyIdToken = (\n options: VerifyIdTokenOptions\n): Promise<Principal> => pipe(verifyIdTokenE(options), Effect.runPromise)\n\n/* Re-exports */\n\nexport type {\n BadRequestError,\n DuplicateEmailError,\n ForbiddenError,\n InvalidCodeError,\n InvalidEmailError,\n InvalidTenancyError,\n NotFoundError,\n PasskeyNotFoundError,\n UnauthorizedError,\n VerificationError,\n} from \"./errors.js\"\nexport {\n isBadRequestError,\n isDuplicateEmailError,\n isForbiddenError,\n isInvalidCodeError,\n isInvalidEmailError,\n isInvalidTenancyError,\n isNotFoundError,\n isPasskeyNotFoundError,\n isUnauthorizedError,\n isVerificationError,\n} from \"./errors.js\"\nexport type {\n AssignUserOptions,\n Credential,\n DeletePasskeyOptions,\n FindAllPasskeys,\n GetPasskeyOptions,\n ListPasskeyOptions,\n Passkey,\n PasskeySummary,\n Platform,\n UpdatedPasskeys,\n UpdatedPasskeyUsernames,\n UpdatePasskeyOptions,\n UpdatePasskeyUsernamesOptions,\n} from \"./passkey/passkey.js\"\nexport {\n isPasskey,\n isPasskeySummary,\n isUpdatedPasskeys,\n isUpdatedPasskeyUsernames,\n} from \"./passkey/passkey.js\"\nexport type {\n ExchangeCodeOptions,\n VerifyIdTokenOptions,\n} from \"./principal/principal.js\"\nexport type {\n CredentialDeviceType,\n Transports,\n} from \"./schemas/passkey.js\"\nexport type { ExtendedPrincipal, Principal } from \"./schemas/principal.js\"\nexport { isExtendedPrincipal, isPrincipal } from \"./schemas/principal.js\"\nexport type {\n AuthenticatedOptions,\n PasslockOptions,\n} from \"./shared.js\"\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAcrC,OAAO,EACL,UAAU,IAAI,WAAW,EACzB,aAAa,IAAI,cAAc,EAC/B,kBAAkB,IAAI,mBAAmB,EACzC,UAAU,IAAI,WAAW,EACzB,YAAY,IAAI,aAAa,EAC7B,aAAa,IAAI,cAAc,EAC/B,sBAAsB,IAAI,uBAAuB,GAClD,MAAM,sBAAsB,CAAA;AAK7B,OAAO,EACL,YAAY,IAAI,aAAa,EAC7B,aAAa,IAAI,cAAc,GAChC,MAAM,0BAA0B,CAAA;AAGjC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAA0B,EAAoB,EAAE,CACzE,IAAI,C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;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAA6B,EACT,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAgBzE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,aAAa,CAAA;AAmBpB,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,sBAAsB,CAAA;AAU7B,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA","sourcesContent":["/**\n * Promise-based functions that reject with tagged error payloads for expected\n * API failures.\n *\n * Unexpected runtime defects may still throw.\n *\n * @categoryDescription Passkeys\n * Functions and related types for managing passkeys\n *\n * @showCategories\n *\n * @module unsafe (default)\n */\n\nimport { Effect, pipe } from \"effect\"\nimport type {\n AssignUserOptions,\n DeletePasskeyOptions,\n DeleteUserPasskeysOptions,\n DeletedPasskeys,\n FindAllPasskeys,\n GetPasskeyOptions,\n ListPasskeyOptions,\n Passkey,\n UpdatedCredentials,\n UpdatePasskeyOptions,\n UpdateUsernamesOptions,\n} from \"./passkey/passkey.js\"\nimport {\n assignUser as assignUserE,\n deletePasskey as deletePasskeyE,\n deleteUserPasskeys as deleteUserPasskeysE,\n getPasskey as getPasskeyE,\n listPasskeys as listPasskeysE,\n updatePasskey as updatePasskeyE,\n updatePasskeyUsernames as updatePasskeyUsernamesE,\n} from \"./passkey/passkey.js\"\nimport type {\n ExchangeCodeOptions,\n VerifyIdTokenOptions,\n} from \"./principal/principal.js\"\nimport {\n exchangeCode as exchangeCodeE,\n verifyIdToken as verifyIdTokenE,\n} from \"./principal/principal.js\"\nimport type { ExtendedPrincipal, Principal } from \"./schemas/principal.js\"\n\n/**\n * Assign a custom user ID to a passkey in the Passlock vault.\n *\n * This updates Passlock's server-side mapping for the passkey. It does not\n * change the underlying WebAuthn credential's `userId`.\n *\n * @param request\n * @returns A promise resolving to the updated passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const assignUser = (request: AssignUserOptions): Promise<Passkey> =>\n pipe(assignUserE(request), Effect.runPromise)\n\n/**\n * Update a passkey's custom user ID and/or username metadata.\n *\n * Updating the username only affects the metadata stored in the vault. It does\n * not affect whether the passkey can be used for authentication.\n *\n * @param request\n * @returns A promise resolving to the updated passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const updatePasskey = (\n request: UpdatePasskeyOptions\n): Promise<Passkey> => pipe(updatePasskeyE(request), Effect.runPromise)\n\n/**\n * Update the username and/or display name for all passkeys belonging to a given user.\n *\n * **Important:** changing these values has no bearing on authentication, as\n * it's typically only used in the client-side component of the passkey\n * (so the user knows which account the passkey relates to).\n *\n * However you might choose to align the names in your vault with the\n * client-side component to simplify end user support.\n *\n * **Note:** This can be used alongside `@passlock/client`'s\n * `updatePasskeyUsernames` helper to update those details on the user's device.\n *\n * @param request\n * @returns A promise resolving to an {@link UpdatedCredentials} payload.\n * Its `credentials` array can be passed to the client's `updatePasskeyUsernames` function.\n *\n * @category Passkeys\n */\nexport const updatePasskeyUsernames = (\n request: UpdateUsernamesOptions\n): Promise<UpdatedCredentials> =>\n pipe(updatePasskeyUsernamesE(request), Effect.runPromise)\n\n/**\n * Delete a passkey from the Passlock vault.\n *\n * This does not remove the passkey from the user's device. Use\n * `@passlock/client` to coordinate client-side removal when needed.\n *\n * @param options\n * @returns A promise resolving to the deleted passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const deletePasskey = (\n options: DeletePasskeyOptions\n): Promise<Passkey> => pipe(deletePasskeyE(options), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to delete all passkeys associated with a user.\n *\n * @param request\n * @returns A promise resolving to a {@link DeletedPasskeys} payload.\n * Its `deleted` array can be passed directly into `@passlock/client`'s\n * `deleteUserPasskeys` helper for follow-up client-side passkey removal.\n * @throws {@link NotFoundError} if the user does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const deleteUserPasskeys = (\n request: DeleteUserPasskeysOptions\n): Promise<DeletedPasskeys> =>\n pipe(deleteUserPasskeysE(request), Effect.runPromise)\n\n/**\n * Fetch a single passkey from the Passlock vault.\n *\n * @param options\n * @returns A promise resolving to the passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const getPasskey = (options: GetPasskeyOptions): Promise<Passkey> =>\n pipe(getPasskeyE(options), Effect.runPromise)\n\n/**\n * List passkeys for the given tenancy. Note this could return a cursor,\n * in which case the function should be called again with the given cursor.\n *\n * @param options\n * @returns A promise resolving to a page of passkey summaries.\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const listPasskeys = (\n options: ListPasskeyOptions\n): Promise<FindAllPasskeys> => pipe(listPasskeysE(options), Effect.runPromise)\n\n/**\n * Exchange a short-lived code from `@passlock/client` for an\n * {@link ExtendedPrincipal}.\n *\n * @param options\n * @returns A promise resolving to an extended principal.\n * @throws {@link InvalidCodeError} if the code is invalid or expired\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Principal\n */\nexport const exchangeCode = (\n options: ExchangeCodeOptions\n): Promise<ExtendedPrincipal> => pipe(exchangeCodeE(options), Effect.runPromise)\n\n/**\n * Decode and verify a Passlock `id_token` (JWT).\n *\n * Note: this will make a network call to\n * `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)\n * to fetch the relevant public key. The response will be cached, however\n * bear in mind that for environments such as AWS Lambda it will make the call\n * on each cold start, so it might be slower than {@link exchangeCode}.\n *\n * @param options\n * @returns A promise resolving to the verified principal.\n * @throws {@link VerificationError} if token verification fails\n *\n * @category Principal\n */\nexport const verifyIdToken = (\n options: VerifyIdTokenOptions\n): Promise<Principal> => pipe(verifyIdTokenE(options), Effect.runPromise)\n\n/* Re-exports */\n\nexport type {\n BadRequestError,\n DuplicateEmailError,\n ForbiddenError,\n InvalidCodeError,\n InvalidEmailError,\n InvalidTenancyError,\n NotFoundError,\n PasskeyNotFoundError,\n UnauthorizedError,\n VerificationError,\n} from \"./errors.js\"\nexport {\n isBadRequestError,\n isDuplicateEmailError,\n isForbiddenError,\n isInvalidCodeError,\n isInvalidEmailError,\n isInvalidTenancyError,\n isNotFoundError,\n isPasskeyNotFoundError,\n isUnauthorizedError,\n isVerificationError,\n} from \"./errors.js\"\nexport type {\n AssignUserOptions,\n Credential,\n DeletePasskeyOptions,\n DeleteUserPasskeysOptions,\n DeletedPasskeys,\n FindAllPasskeys,\n GetPasskeyOptions,\n ListPasskeyOptions,\n Passkey,\n PasskeyCredential,\n PasskeySummary,\n Platform,\n UpdatedPasskeys,\n UpdatedCredentials as UpdatedUserDetails,\n UpdatePasskeyOptions,\n UpdateUsernamesOptions as UpdateUserDetailsOptions,\n} from \"./passkey/passkey.js\"\nexport {\n isDeletedPasskeys,\n isPasskey,\n isPasskeySummary,\n isUpdatedPasskeys,\n isUpdatedUserDetails,\n} from \"./passkey/passkey.js\"\nexport type {\n ExchangeCodeOptions,\n VerifyIdTokenOptions,\n} from \"./principal/principal.js\"\nexport type {\n CredentialDeviceType,\n Transports,\n} from \"./schemas/passkey.js\"\nexport type { ExtendedPrincipal, Principal } from \"./schemas/principal.js\"\nexport { isExtendedPrincipal, isPrincipal } from \"./schemas/principal.js\"\nexport type {\n AuthenticatedOptions,\n PasslockOptions,\n} from \"./shared.js\"\n"]}
|
package/dist/network.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export interface MatchStatusCases<Resp extends NetworkResponse = NetworkResponse
|
|
|
66
66
|
readonly "5xx"?: MatchStatusHandler<Resp>;
|
|
67
67
|
readonly orElse: MatchStatusHandler<Resp>;
|
|
68
68
|
}
|
|
69
|
-
declare const NetworkRequestError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
69
|
+
declare const NetworkRequestError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
70
70
|
readonly _tag: "@error/NetworkRequest";
|
|
71
71
|
} & Readonly<A>;
|
|
72
72
|
/**
|
|
@@ -78,7 +78,7 @@ export declare class NetworkRequestError extends NetworkRequestError_base<{
|
|
|
78
78
|
readonly message: string;
|
|
79
79
|
}> {
|
|
80
80
|
}
|
|
81
|
-
declare const NetworkPayloadError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
81
|
+
declare const NetworkPayloadError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
82
82
|
readonly _tag: "@error/NetworkPayload";
|
|
83
83
|
} & Readonly<A>;
|
|
84
84
|
/**
|
|
@@ -89,7 +89,7 @@ export declare class NetworkPayloadError extends NetworkPayloadError_base<{
|
|
|
89
89
|
readonly message: string;
|
|
90
90
|
}> {
|
|
91
91
|
}
|
|
92
|
-
declare const NetworkResponseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
92
|
+
declare const NetworkResponseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
93
93
|
readonly _tag: "@error/NetworkResponse";
|
|
94
94
|
} & Readonly<A>;
|
|
95
95
|
/**
|