@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.
Files changed (45) hide show
  1. package/dist/effect.d.ts +8 -0
  2. package/dist/effect.d.ts.map +1 -1
  3. package/dist/effect.js +8 -0
  4. package/dist/effect.js.map +1 -1
  5. package/dist/errors.d.ts +65 -0
  6. package/dist/errors.d.ts.map +1 -1
  7. package/dist/errors.js +36 -5
  8. package/dist/errors.js.map +1 -1
  9. package/dist/index.d.ts +54 -18
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +52 -16
  12. package/dist/index.js.map +1 -1
  13. package/dist/network.d.ts +3 -3
  14. package/dist/passkey/passkey.d.ts +242 -10
  15. package/dist/passkey/passkey.d.ts.map +1 -1
  16. package/dist/passkey/passkey.js +140 -4
  17. package/dist/passkey/passkey.js.map +1 -1
  18. package/dist/principal/principal.d.ts +45 -1
  19. package/dist/principal/principal.d.ts.map +1 -1
  20. package/dist/principal/principal.js +27 -0
  21. package/dist/principal/principal.js.map +1 -1
  22. package/dist/safe-result.d.ts +33 -0
  23. package/dist/safe-result.d.ts.map +1 -0
  24. package/dist/safe-result.js +35 -0
  25. package/dist/safe-result.js.map +1 -0
  26. package/dist/safe.d.ts +79 -28
  27. package/dist/safe.d.ts.map +1 -1
  28. package/dist/safe.js +82 -28
  29. package/dist/safe.js.map +1 -1
  30. package/dist/schemas/passkey.d.ts +148 -0
  31. package/dist/schemas/passkey.d.ts.map +1 -1
  32. package/dist/schemas/passkey.js +82 -12
  33. package/dist/schemas/passkey.js.map +1 -1
  34. package/dist/schemas/principal.d.ts +50 -0
  35. package/dist/schemas/principal.d.ts.map +1 -1
  36. package/dist/schemas/principal.js +30 -0
  37. package/dist/schemas/principal.js.map +1 -1
  38. package/dist/schemas/signup.d.ts +20 -0
  39. package/dist/schemas/signup.d.ts.map +1 -1
  40. package/dist/schemas/signup.js +10 -0
  41. package/dist/schemas/signup.js.map +1 -1
  42. package/dist/shared.d.ts +18 -0
  43. package/dist/shared.d.ts.map +1 -1
  44. package/dist/shared.js.map +1 -1
  45. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../src/safe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EAClB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,OAAO,EACP,uBAAuB,EACvB,oBAAoB,EACpB,6BAA6B,EAC9B,MAAM,sBAAsB,CAAA;AAS7B,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,0BAA0B,CAAA;AAKjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAE1E;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,UAAU,GACrB,SAAS,iBAAiB,KACzB,OAAO,CAAC,OAAO,GAAG,aAAa,GAAG,cAAc,CAKhD,CAAA;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,oBAAoB,KAC5B,OAAO,CAAC,OAAO,GAAG,aAAa,GAAG,cAAc,CAKhD,CAAA;AAEH;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,6BAA6B,KACrC,OAAO,CAAC,uBAAuB,GAAG,aAAa,GAAG,cAAc,CAKhE,CAAA;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,oBAAoB,KAC5B,OAAO,CAAC,OAAO,GAAG,cAAc,GAAG,aAAa,CAKhD,CAAA;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,GACrB,SAAS,iBAAiB,KACz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mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,aAAa,CAAA;AACpB,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,oBAAoB,EACpB,yBAAyB,EACzB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,OAAO,EACP,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,eAAe,EACf,kBAAkB,IAAI,kBAAkB,EACxC,oBAAoB,EACpB,sBAAsB,IAAI,wBAAwB,GACnD,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EACV,mBAAmB,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/safe.js CHANGED
@@ -1,9 +1,31 @@
1
1
  /**
2
- * Safe functions that return discriminated unions representing
3
- * the successful outcome or expected failures.
2
+ * Safe functions that return result envelopes over the original
3
+ * tagged success and error payloads. The returned value keeps
4
+ * its original `_tag` shape, and is also augmented with a
5
+ * result envelope for `success`- or `failure`-style branching.
4
6
  *
5
7
  * Note: unexpected runtime failures may still throw.
6
8
  *
9
+ * ```ts
10
+ * const result = await exchangeCode({
11
+ * apiKey,
12
+ * code,
13
+ * tenancyId,
14
+ * })
15
+ *
16
+ * if (result.success) {
17
+ * console.log(result.value.id)
18
+ * }
19
+ *
20
+ * if (result.failure) {
21
+ * console.log(result.error.message)
22
+ * }
23
+ *
24
+ * if (isExtendedPrincipal(result)) {
25
+ * console.log(result.id)
26
+ * }
27
+ * ```
28
+ *
7
29
  * @categoryDescription Passkeys
8
30
  * Functions and related types for managing passkeys
9
31
  *
@@ -11,9 +33,14 @@
11
33
  *
12
34
  * @module safe
13
35
  */
14
- import { Effect, identity, pipe } from "effect";
15
- import { assignUser as assignUserE, deletePasskey as deletePasskeyE, getPasskey as getPasskeyE, listPasskeys as listPasskeysE, updatePasskey as updatePasskeyE, updatePasskeyUsernames as updatePasskeyUsernamesE, } from "./passkey/passkey.js";
36
+ import { Effect, pipe } from "effect";
37
+ 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";
16
38
  import { exchangeCode as exchangeCodeE, verifyIdToken as verifyIdTokenE, } from "./principal/principal.js";
39
+ import { toErrResult, toOkResult } from "./safe-result.js";
40
+ const runSafe = (effect) => pipe(effect, Effect.match({
41
+ onFailure: (error) => toErrResult(error),
42
+ onSuccess: (value) => toOkResult(value),
43
+ }), Effect.runPromise);
17
44
  /**
18
45
  * Assign a custom User ID to a passkey. Will be reflected in the next
19
46
  * {@link Principal} or {@link ExtendedPrincipal} generated.
@@ -26,14 +53,14 @@ import { exchangeCode as exchangeCodeE, verifyIdToken as verifyIdTokenE, } from
26
53
  * @see [credential](https://passlock.dev/rest-api/credential/)
27
54
  *
28
55
  * @param request
29
- * @returns A promise resolving to either a passkey or an API error.
56
+ * @returns A promise resolving to a {@link Result} whose success branch contains
57
+ * a passkey and whose error branch contains an API error.
30
58
  *
31
59
  * @category Passkeys
32
60
  */
33
- export const assignUser = (request) => pipe(assignUserE(request), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
61
+ export const assignUser = (request) => runSafe(assignUserE(request));
34
62
  /**
35
- * Can also be used to assign a custom User ID, but also allows you to update
36
- * the username.
63
+ * Update a passkey's custom user ID and/or username metadata.
37
64
  *
38
65
  * **Important:** changing the username has no bearing on authentication, as
39
66
  * it's typically only used in the client-side component of the passkey
@@ -43,27 +70,35 @@ export const assignUser = (request) => pipe(assignUserE(request), Effect.match({
43
70
  * client-side component to simplify end user support.
44
71
  *
45
72
  * @param request
46
- * @returns A promise resolving to either a passkey or an API error.
73
+ * @returns A promise resolving to a {@link Result} whose success branch contains
74
+ * a passkey and whose error branch contains an API error.
47
75
  *
48
76
  * @category Passkeys
49
77
  */
50
- export const updatePasskey = (request) => pipe(updatePasskeyE(request), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
78
+ export const updatePasskey = (request) => runSafe(updatePasskeyE(request));
51
79
  /**
52
- * Update the username for all passkeys belonging to a given user.
80
+ * Update the username and/or display name for all passkeys belonging to a given user.
53
81
  *
54
- * **Important:** changing the username has no bearing on authentication, as
82
+ * **Important:** changing these values has no bearing on authentication, as
55
83
  * it's typically only used in the client-side component of the passkey
56
84
  * (so the user knows which account the passkey relates to).
57
85
  *
58
- * However you might choose to align the username in your vault with the
86
+ * However you might choose to align the username and display name in your vault with the
59
87
  * client-side component to simplify end user support.
60
88
  *
89
+ * **Note:** This can be used alongside `@passlock/client`'s
90
+ * `updatePasskeyUsernames` helper to update those details on the user's device.
91
+ *
61
92
  * @param request
62
- * @returns A promise resolving to either updated passkey usernames or an API error.
93
+ * @returns A promise resolving to a {@link Result}.
94
+ * The success branch contains an {@link UpdatedCredentials} payload, whose
95
+ * `credentials` array can be passed into the client's `updatePasskeyUsernames` function.
96
+ * The error branch contains
97
+ * an API error.
63
98
  *
64
99
  * @category Passkeys
65
100
  */
66
- export const updatePasskeyUsernames = (request) => pipe(updatePasskeyUsernamesE(request), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
101
+ export const updatePasskeyUsernames = (request) => runSafe(updatePasskeyUsernamesE(request));
67
102
  /**
68
103
  * Delete a passkey from your vault.
69
104
  *
@@ -84,11 +119,25 @@ export const updatePasskeyUsernames = (request) => pipe(updatePasskeyUsernamesE(
84
119
  * @see [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)
85
120
  *
86
121
  * @param options
87
- * @returns A promise resolving to either the deleted passkey or an API error.
122
+ * @returns A promise resolving to a {@link Result} whose success branch contains
123
+ * the deleted passkey and whose error branch contains an API error.
88
124
  *
89
125
  * @category Passkeys
90
126
  */
91
- export const deletePasskey = (options) => pipe(deletePasskeyE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
127
+ export const deletePasskey = (options) => runSafe(deletePasskeyE(options));
128
+ /**
129
+ * Delete all passkeys associated with a user.
130
+ *
131
+ * @param request
132
+ * @returns A promise resolving to a {@link Result}.
133
+ * The success branch contains a {@link DeletedPasskeys} payload whose
134
+ * `deleted` array can be passed directly into `@passlock/client`'s
135
+ * `deleteUserPasskeys` helper for follow-up client-side passkey removal.
136
+ * The error branch contains an API error.
137
+ *
138
+ * @category Passkeys
139
+ */
140
+ export const deleteUserPasskeys = (request) => runSafe(deleteUserPasskeysE(request));
92
141
  /**
93
142
  * Fetch details about a passkey. **Important**: Not to be confused with
94
143
  * the {@link exchangeCode} or {@link verifyIdToken} functions, which
@@ -96,21 +145,23 @@ export const deletePasskey = (options) => pipe(deletePasskeyE(options), Effect.m
96
145
  * Use this function for passkey management, not authentication.
97
146
  *
98
147
  * @param options
99
- * @returns A promise resolving to either passkey details or an API error.
148
+ * @returns A promise resolving to a {@link Result} whose success branch contains
149
+ * passkey details and whose error branch contains an API error.
100
150
  *
101
151
  * @category Passkeys
102
152
  */
103
- export const getPasskey = (options) => pipe(getPasskeyE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
153
+ export const getPasskey = (options) => runSafe(getPasskeyE(options));
104
154
  /**
105
155
  * List passkeys for the given tenancy. Note: This could return a cursor.
106
156
  * If so, call again, passing the cursor back in.
107
157
  *
108
158
  * @param options
109
- * @returns A promise resolving to a page of passkey summaries or an API error.
159
+ * @returns A promise resolving to a {@link Result} whose success branch contains
160
+ * a page of passkey summaries and whose error branch contains an API error.
110
161
  *
111
162
  * @category Passkeys
112
163
  */
113
- export const listPasskeys = (options) => pipe(listPasskeysE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
164
+ export const listPasskeys = (options) => runSafe(listPasskeysE(options));
114
165
  /**
115
166
  * The @passlock/client library generates codes, which you should send to
116
167
  * your backend. Use this function to exchange the code for details about
@@ -120,28 +171,31 @@ export const listPasskeys = (options) => pipe(listPasskeysE(options), Effect.mat
120
171
  * @see {@link ExtendedPrincipal}
121
172
  *
122
173
  * @param options
123
- * @returns A promise resolving to an extended principal or an API error.
174
+ * @returns A promise resolving to a {@link Result} whose success branch contains
175
+ * an extended principal and whose error branch contains an API error.
124
176
  *
125
177
  * @category Principal
126
178
  */
127
- export const exchangeCode = (options) => pipe(exchangeCodeE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
179
+ export const exchangeCode = (options) => runSafe(exchangeCodeE(options));
128
180
  /**
129
181
  * Decode and verify an id_token (JWT) locally.
182
+ *
130
183
  * **Note:** This will make a network call to
131
184
  * `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)
132
185
  * to fetch the relevant public key. The response will be cached, however
133
- * bear in mind that for something like AWS Lambda it will make the call on every
134
- * cold start so might actually be slower than {@link exchangeCode}
186
+ * bear in mind that for environments such as AWS Lambda it will make the call
187
+ * on each cold start, so it might be slower than {@link exchangeCode}.
135
188
  *
136
189
  * @see {@link Principal}
137
190
  *
138
191
  * @param options
139
- * @returns A promise resolving to a verified principal or verification failure.
192
+ * @returns A promise resolving to a {@link Result} whose success branch contains
193
+ * a verified principal and whose error branch contains a verification error.
140
194
  *
141
195
  * @category Principal
142
196
  */
143
- export const verifyIdToken = (options) => pipe(verifyIdTokenE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
197
+ export const verifyIdToken = (options) => runSafe(verifyIdTokenE(options));
144
198
  export { isBadRequestError, isDuplicateEmailError, isForbiddenError, isInvalidCodeError, isInvalidEmailError, isInvalidTenancyError, isNotFoundError, isPasskeyNotFoundError, isUnauthorizedError, isVerificationError, } from "./errors.js";
145
- export { isPasskey, isPasskeySummary, isUpdatedPasskeys, isUpdatedPasskeyUsernames, } from "./passkey/passkey.js";
199
+ export { isDeletedPasskeys, isPasskey, isPasskeySummary, isUpdatedPasskeys, isUpdatedUserDetails, } from "./passkey/passkey.js";
146
200
  export { isExtendedPrincipal, isPrincipal } from "./schemas/principal.js";
147
201
  //# sourceMappingURL=safe.js.map
package/dist/safe.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"safe.js","sourceRoot":"","sources":["../src/safe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAkB/C,OAAO,EACL,UAAU,IAAI,WAAW,EACzB,aAAa,IAAI,cAAc,EAC/B,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;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,OAA0B,EACyB,EAAE,CACrD,IAAI,CACF,WAAW,CAAC,OAAO,CAAC,EACpB,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAC1D,MAAM,CAAC,UAAU,CAClB,CAAA;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAA6B,EACsB,EAAE,CACrD,IAAI,CACF,cA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CAAC,MAAM,YAAY,GAAG,CAC1B,OAA4B,EACoC,EAAE,CAClE,IAAI,CACF,aAAa,CAAC,OAAO,CAAC,EACtB,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAC1D,MAAM,CAAC,UAAU,CAClB,CAAA;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAA6B,EACW,EAAE,CAC1C,IAAI,CACF,cAAc,CAAC,OAAO,CAAC,EACvB,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAC1D,MAAM,CAAC,UAAU,CAClB,CAAA;AAgBH,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 * Safe functions that return discriminated unions representing\n * the successful outcome or expected failures.\n *\n * Note: unexpected runtime failures may still throw.\n *\n * @categoryDescription Passkeys\n * Functions and related types for managing passkeys\n *\n * @showCategories\n *\n * @module safe\n */\n\nimport { Effect, identity, pipe } from \"effect\"\nimport type {\n ForbiddenError,\n InvalidCodeError,\n NotFoundError,\n VerificationError,\n} from \"./errors.js\"\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 * Assign a custom User ID to a passkey. Will be reflected in the next\n * {@link Principal} or {@link ExtendedPrincipal} generated.\n *\n * **Note:** This does not change the underlying WebAuthn credential's `userId`.\n * Instead we apply a layer of indirection.\n *\n * @see {@link Principal}\n * @see {@link ExtendedPrincipal}\n * @see [credential](https://passlock.dev/rest-api/credential/)\n *\n * @param request\n * @returns A promise resolving to either a passkey or an API error.\n *\n * @category Passkeys\n */\nexport const assignUser = (\n request: AssignUserOptions\n): Promise<Passkey | NotFoundError | ForbiddenError> =>\n pipe(\n assignUserE(request),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Can also be used to assign a custom User ID, but also allows you to update\n * the username.\n *\n * **Important:** changing the username 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 username in your vault with the\n * client-side component to simplify end user support.\n *\n * @param request\n * @returns A promise resolving to either a passkey or an API error.\n *\n * @category Passkeys\n */\nexport const updatePasskey = (\n request: UpdatePasskeyOptions\n): Promise<Passkey | NotFoundError | ForbiddenError> =>\n pipe(\n updatePasskeyE(request),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Update the username for all passkeys belonging to a given user.\n *\n * **Important:** changing the username 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 username in your vault with the\n * client-side component to simplify end user support.\n *\n * @param request\n * @returns A promise resolving to either updated passkey usernames or an API error.\n *\n * @category Passkeys\n */\nexport const updatePasskeyUsernames = (\n request: UpdatePasskeyUsernamesOptions\n): Promise<UpdatedPasskeyUsernames | NotFoundError | ForbiddenError> =>\n pipe(\n updatePasskeyUsernamesE(request),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Delete a passkey from your vault.\n *\n * **Note:** The user will still retain the passkey on their device so\n * you will need to either:\n *\n * a) Use the @passlock/client functions to delete the passkey from the user's device.\n * b) Remind the user to delete the passkey\n *\n * See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) in the documentation.\n *\n * In addition, during authentication you should handle a missing passkey scenario.\n * This happens when a user tries to authenticate with a passkey that is missing from\n * your vault. The @passlock/client library can help with this. See\n * [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)\n *\n * @see [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/)\n * @see [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)\n *\n * @param options\n * @returns A promise resolving to either the deleted passkey or an API error.\n *\n * @category Passkeys\n */\nexport const deletePasskey = (\n options: DeletePasskeyOptions\n): Promise<Passkey | ForbiddenError | NotFoundError> =>\n pipe(\n deletePasskeyE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Fetch details about a passkey. **Important**: Not to be confused with\n * the {@link exchangeCode} or {@link verifyIdToken} functions, which\n * return details about specific authentication or registration operations.\n * Use this function for passkey management, not authentication.\n *\n * @param options\n * @returns A promise resolving to either passkey details or an API error.\n *\n * @category Passkeys\n */\nexport const getPasskey = (\n options: GetPasskeyOptions\n): Promise<Passkey | ForbiddenError | NotFoundError> =>\n pipe(\n getPasskeyE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * List passkeys for the given tenancy. Note: This could return a cursor.\n * If so, call again, passing the cursor back in.\n *\n * @param options\n * @returns A promise resolving to a page of passkey summaries or an API error.\n *\n * @category Passkeys\n */\nexport const listPasskeys = (\n options: ListPasskeyOptions\n): Promise<FindAllPasskeys | ForbiddenError> =>\n pipe(\n listPasskeysE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * The @passlock/client library generates codes, which you should send to\n * your backend. Use this function to exchange the code for details about\n * the registration or authentication operation. **Note:** a code is valid\n * for 5 minutes.\n *\n * @see {@link ExtendedPrincipal}\n *\n * @param options\n * @returns A promise resolving to an extended principal or an API error.\n *\n * @category Principal\n */\nexport const exchangeCode = (\n options: ExchangeCodeOptions\n): Promise<ExtendedPrincipal | ForbiddenError | InvalidCodeError> =>\n pipe(\n exchangeCodeE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Decode and verify an id_token (JWT) locally.\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 * @see {@link Principal}\n *\n * @param options\n * @returns A promise resolving to a verified principal or verification failure.\n *\n * @category Principal\n */\nexport const verifyIdToken = (\n options: VerifyIdTokenOptions\n): Promise<Principal | VerificationError> =>\n pipe(\n verifyIdTokenE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\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":"safe.js","sourceRoot":"","sources":["../src/safe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAoBrC,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;AACjC,OAAO,EAAe,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGvE,MAAM,OAAO,GAAG,CACd,MAA2B,EACJ,EAAE,CACzB,IAAI,CACF,MAAM,EACN,MAAM,CAAC,KAAK,CAAC;IACX,S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;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAA4B,EAC2C,EAAE,CACzE,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAA;AAEjC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAA6B,EACkB,EAAE,CACjD,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;AAiBlC,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 * Safe functions that return result envelopes over the original\n * tagged success and error payloads. The returned value keeps\n * its original `_tag` shape, and is also augmented with a\n * result envelope for `success`- or `failure`-style branching.\n *\n * Note: unexpected runtime failures may still throw.\n *\n * ```ts\n * const result = await exchangeCode({\n * apiKey,\n * code,\n * tenancyId,\n * })\n *\n * if (result.success) {\n * console.log(result.value.id)\n * }\n *\n * if (result.failure) {\n * console.log(result.error.message)\n * }\n *\n * if (isExtendedPrincipal(result)) {\n * console.log(result.id)\n * }\n * ```\n *\n * @categoryDescription Passkeys\n * Functions and related types for managing passkeys\n *\n * @showCategories\n *\n * @module safe\n */\n\nimport { Effect, pipe } from \"effect\"\nimport type {\n ForbiddenError,\n InvalidCodeError,\n NotFoundError,\n VerificationError,\n} from \"./errors.js\"\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 Result, toErrResult, toOkResult } from \"./safe-result.js\"\nimport type { ExtendedPrincipal, Principal } from \"./schemas/principal.js\"\n\nconst runSafe = <A extends object, E extends object>(\n effect: Effect.Effect<A, E>\n): Promise<Result<A, E>> =>\n pipe(\n effect,\n Effect.match({\n onFailure: (error): Result<A, E> => toErrResult(error) as Result<A, E>,\n onSuccess: (value): Result<A, E> => toOkResult(value) as Result<A, E>,\n }),\n Effect.runPromise\n )\n\n/**\n * Assign a custom User ID to a passkey. Will be reflected in the next\n * {@link Principal} or {@link ExtendedPrincipal} generated.\n *\n * **Note:** This does not change the underlying WebAuthn credential's `userId`.\n * Instead we apply a layer of indirection.\n *\n * @see {@link Principal}\n * @see {@link ExtendedPrincipal}\n * @see [credential](https://passlock.dev/rest-api/credential/)\n *\n * @param request\n * @returns A promise resolving to a {@link Result} whose success branch contains\n * a passkey and whose error branch contains an API error.\n *\n * @category Passkeys\n */\nexport const assignUser = (\n request: AssignUserOptions\n): Promise<Result<Passkey, NotFoundError | ForbiddenError>> =>\n runSafe(assignUserE(request))\n\n/**\n * Update a passkey's custom user ID and/or username metadata.\n *\n * **Important:** changing the username 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 username in your vault with the\n * client-side component to simplify end user support.\n *\n * @param request\n * @returns A promise resolving to a {@link Result} whose success branch contains\n * a passkey and whose error branch contains an API error.\n *\n * @category Passkeys\n */\nexport const updatePasskey = (\n request: UpdatePasskeyOptions\n): Promise<Result<Passkey, NotFoundError | ForbiddenError>> =>\n runSafe(updatePasskeyE(request))\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 username and display name 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 a {@link Result}.\n * The success branch contains an {@link UpdatedCredentials} payload, whose\n * `credentials` array can be passed into the client's `updatePasskeyUsernames` function.\n * The error branch contains\n * an API error.\n *\n * @category Passkeys\n */\nexport const updatePasskeyUsernames = (\n request: UpdateUsernamesOptions\n): Promise<Result<UpdatedCredentials, NotFoundError | ForbiddenError>> =>\n runSafe(updatePasskeyUsernamesE(request))\n\n/**\n * Delete a passkey from your vault.\n *\n * **Note:** The user will still retain the passkey on their device so\n * you will need to either:\n *\n * a) Use the @passlock/client functions to delete the passkey from the user's device.\n * b) Remind the user to delete the passkey\n *\n * See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) in the documentation.\n *\n * In addition, during authentication you should handle a missing passkey scenario.\n * This happens when a user tries to authenticate with a passkey that is missing from\n * your vault. The @passlock/client library can help with this. See\n * [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)\n *\n * @see [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/)\n * @see [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)\n *\n * @param options\n * @returns A promise resolving to a {@link Result} whose success branch contains\n * the deleted passkey and whose error branch contains an API error.\n *\n * @category Passkeys\n */\nexport const deletePasskey = (\n options: DeletePasskeyOptions\n): Promise<Result<Passkey, ForbiddenError | NotFoundError>> =>\n runSafe(deletePasskeyE(options))\n\n/**\n * Delete all passkeys associated with a user.\n *\n * @param request\n * @returns A promise resolving to a {@link Result}.\n * The success branch contains a {@link DeletedPasskeys} payload whose\n * `deleted` array can be passed directly into `@passlock/client`'s\n * `deleteUserPasskeys` helper for follow-up client-side passkey removal.\n * The error branch contains an API error.\n *\n * @category Passkeys\n */\nexport const deleteUserPasskeys = (\n request: DeleteUserPasskeysOptions\n): Promise<Result<DeletedPasskeys, ForbiddenError | NotFoundError>> =>\n runSafe(deleteUserPasskeysE(request))\n\n/**\n * Fetch details about a passkey. **Important**: Not to be confused with\n * the {@link exchangeCode} or {@link verifyIdToken} functions, which\n * return details about specific authentication or registration operations.\n * Use this function for passkey management, not authentication.\n *\n * @param options\n * @returns A promise resolving to a {@link Result} whose success branch contains\n * passkey details and whose error branch contains an API error.\n *\n * @category Passkeys\n */\nexport const getPasskey = (\n options: GetPasskeyOptions\n): Promise<Result<Passkey, ForbiddenError | NotFoundError>> =>\n runSafe(getPasskeyE(options))\n\n/**\n * List passkeys for the given tenancy. Note: This could return a cursor.\n * If so, call again, passing the cursor back in.\n *\n * @param options\n * @returns A promise resolving to a {@link Result} whose success branch contains\n * a page of passkey summaries and whose error branch contains an API error.\n *\n * @category Passkeys\n */\nexport const listPasskeys = (\n options: ListPasskeyOptions\n): Promise<Result<FindAllPasskeys, ForbiddenError>> =>\n runSafe(listPasskeysE(options))\n\n/**\n * The @passlock/client library generates codes, which you should send to\n * your backend. Use this function to exchange the code for details about\n * the registration or authentication operation. **Note:** a code is valid\n * for 5 minutes.\n *\n * @see {@link ExtendedPrincipal}\n *\n * @param options\n * @returns A promise resolving to a {@link Result} whose success branch contains\n * an extended principal and whose error branch contains an API error.\n *\n * @category Principal\n */\nexport const exchangeCode = (\n options: ExchangeCodeOptions\n): Promise<Result<ExtendedPrincipal, ForbiddenError | InvalidCodeError>> =>\n runSafe(exchangeCodeE(options))\n\n/**\n * Decode and verify an id_token (JWT) locally.\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 * @see {@link Principal}\n *\n * @param options\n * @returns A promise resolving to a {@link Result} whose success branch contains\n * a verified principal and whose error branch contains a verification error.\n *\n * @category Principal\n */\nexport const verifyIdToken = (\n options: VerifyIdTokenOptions\n): Promise<Result<Principal, VerificationError>> =>\n runSafe(verifyIdTokenE(options))\n\n/* Re-exports */\n\nexport type { Err, Ok, Result } from \"./safe-result.js\"\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"]}
@@ -1,9 +1,62 @@
1
1
  import { Schema } from "effect";
2
+ /**
3
+ * Valid user verification requirements for WebAuthn operations.
4
+ *
5
+ * @category Passkeys
6
+ */
2
7
  export declare const UserVerification: Schema.Literal<["required", "preferred", "discouraged"]>;
8
+ /**
9
+ * Possible device types reported for a passkey credential.
10
+ *
11
+ * @category Passkeys
12
+ */
3
13
  export declare const CredentialDeviceType: readonly ["singleDevice", "multiDevice"];
14
+ /**
15
+ * Union of device types reported for a passkey credential.
16
+ *
17
+ * @category Passkeys
18
+ */
4
19
  export type CredentialDeviceType = (typeof CredentialDeviceType)[number];
20
+ /**
21
+ * Possible authenticator transport hints exposed by Passlock.
22
+ *
23
+ * @category Passkeys
24
+ */
5
25
  export declare const Transports: readonly ["ble", "hybrid", "internal", "nfc", "usb", "cable", "smart-card"];
26
+ /**
27
+ * Union of authenticator transport hints exposed by Passlock.
28
+ *
29
+ * @category Passkeys
30
+ */
6
31
  export type Transports = (typeof Transports)[number];
32
+ /**
33
+ * Schema for the WebAuthn credential portion of a passkey.
34
+ *
35
+ * @category Passkeys
36
+ */
37
+ export declare const PasskeyCredential: Schema.Struct<{
38
+ id: typeof Schema.String;
39
+ userId: typeof Schema.String;
40
+ username: typeof Schema.String;
41
+ aaguid: typeof Schema.String;
42
+ backedUp: typeof Schema.Boolean;
43
+ counter: typeof Schema.Number;
44
+ deviceType: Schema.Literal<["singleDevice", "multiDevice"]>;
45
+ transports: Schema.Array$<Schema.Literal<["ble", "hybrid", "internal", "nfc", "usb", "cable", "smart-card"]>>;
46
+ publicKey: Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>;
47
+ rpId: typeof Schema.String;
48
+ }>;
49
+ /**
50
+ * Type produced by {@link PasskeyCredential}.
51
+ *
52
+ * @category Passkeys
53
+ */
54
+ export type PasskeyCredential = typeof PasskeyCredential.Type;
55
+ /**
56
+ * Schema for a passkey stored in the Passlock vault.
57
+ *
58
+ * @category Passkeys
59
+ */
7
60
  export declare const Passkey: Schema.TaggedStruct<"Passkey", {
8
61
  id: typeof Schema.String;
9
62
  userId: Schema.optional<typeof Schema.String>;
@@ -28,8 +81,26 @@ export declare const Passkey: Schema.TaggedStruct<"Passkey", {
28
81
  createdAt: typeof Schema.Number;
29
82
  updatedAt: typeof Schema.Number;
30
83
  }>;
84
+ /**
85
+ * Type produced by {@link Passkey}.
86
+ *
87
+ * @category Passkeys
88
+ */
31
89
  export type Passkey = typeof Passkey.Type;
90
+ /**
91
+ * Encoded transport shape for {@link Passkey}.
92
+ *
93
+ * Binary fields such as `publicKey` are represented using schema-friendly
94
+ * encoded values.
95
+ *
96
+ * @category Passkeys
97
+ */
32
98
  export type PasskeyEncoded = typeof Passkey.Encoded;
99
+ /**
100
+ * Schema for the compact passkey payload returned by listing operations.
101
+ *
102
+ * @category Passkeys
103
+ */
33
104
  export declare const PasskeySummary: Schema.TaggedStruct<"PasskeySummary", {
34
105
  id: typeof Schema.String;
35
106
  userId: typeof Schema.String;
@@ -41,7 +112,17 @@ export declare const PasskeySummary: Schema.TaggedStruct<"PasskeySummary", {
41
112
  createdAt: typeof Schema.Number;
42
113
  lastUsed: Schema.optional<typeof Schema.Number>;
43
114
  }>;
115
+ /**
116
+ * Type produced by {@link PasskeySummary}.
117
+ *
118
+ * @category Passkeys
119
+ */
44
120
  export type PasskeySummary = typeof PasskeySummary.Type;
121
+ /**
122
+ * Schema for one page of passkey summaries.
123
+ *
124
+ * @category Passkeys
125
+ */
45
126
  export declare const FindAllPasskeys: Schema.TaggedStruct<"FindAllPasskeys", {
46
127
  cursor: Schema.NullOr<typeof Schema.String>;
47
128
  records: Schema.Array$<Schema.TaggedStruct<"PasskeySummary", {
@@ -56,6 +137,11 @@ export declare const FindAllPasskeys: Schema.TaggedStruct<"FindAllPasskeys", {
56
137
  lastUsed: Schema.optional<typeof Schema.Number>;
57
138
  }>>;
58
139
  }>;
140
+ /**
141
+ * Schema for a bulk passkey update response.
142
+ *
143
+ * @category Passkeys
144
+ */
59
145
  export declare const UpdatedPasskeys: Schema.TaggedStruct<"UpdatedPasskeys", {
60
146
  updated: Schema.Array$<Schema.TaggedStruct<"Passkey", {
61
147
  id: typeof Schema.String;
@@ -82,4 +168,66 @@ export declare const UpdatedPasskeys: Schema.TaggedStruct<"UpdatedPasskeys", {
82
168
  updatedAt: typeof Schema.Number;
83
169
  }>>;
84
170
  }>;
171
+ /**
172
+ * Schema for the credential identifiers returned after deleting passkeys.
173
+ *
174
+ * @category Passkeys
175
+ */
176
+ export declare const Credential: Schema.Struct<{
177
+ credentialId: typeof Schema.String;
178
+ userId: typeof Schema.String;
179
+ rpId: typeof Schema.String;
180
+ }>;
181
+ /**
182
+ * Type produced by {@link Credential}.
183
+ *
184
+ * @category Passkeys
185
+ */
186
+ export type Credential = typeof Credential.Type;
187
+ /**
188
+ * Raw REST API schema returned when passkeys are deleted.
189
+ *
190
+ * The package maps this into {@link DeletedPasskeys} before exposing it from
191
+ * the higher-level APIs.
192
+ *
193
+ * @category Passkeys
194
+ */
195
+ export declare const DeletedPasskeysResponse: Schema.TaggedStruct<"DeletedPasskeys", {
196
+ deleted: Schema.Array$<Schema.TaggedStruct<"Passkey", {
197
+ id: typeof Schema.String;
198
+ userId: Schema.optional<typeof Schema.String>;
199
+ enabled: typeof Schema.Boolean;
200
+ credential: Schema.Struct<{
201
+ id: typeof Schema.String;
202
+ userId: typeof Schema.String;
203
+ username: typeof Schema.String;
204
+ aaguid: typeof Schema.String;
205
+ backedUp: typeof Schema.Boolean;
206
+ counter: typeof Schema.Number;
207
+ deviceType: Schema.Literal<["singleDevice", "multiDevice"]>;
208
+ transports: Schema.Array$<Schema.Literal<["ble", "hybrid", "internal", "nfc", "usb", "cable", "smart-card"]>>;
209
+ publicKey: Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>;
210
+ rpId: typeof Schema.String;
211
+ }>;
212
+ platform: Schema.optional<Schema.Struct<{
213
+ icon: Schema.optional<typeof Schema.String>;
214
+ name: Schema.optional<typeof Schema.String>;
215
+ }>>;
216
+ lastUsed: Schema.optional<typeof Schema.Number>;
217
+ createdAt: typeof Schema.Number;
218
+ updatedAt: typeof Schema.Number;
219
+ }>>;
220
+ }>;
221
+ /**
222
+ * Public schema returned when passkeys are deleted by user ID.
223
+ *
224
+ * @category Passkeys
225
+ */
226
+ export declare const DeletedPasskeys: Schema.TaggedStruct<"DeletedPasskeys", {
227
+ deleted: Schema.Array$<Schema.Struct<{
228
+ credentialId: typeof Schema.String;
229
+ userId: typeof Schema.String;
230
+ rpId: typeof Schema.String;
231
+ }>>;
232
+ }>;
85
233
  //# sourceMappingURL=passkey.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"passkey.d.ts","sourceRoot":"","sources":["../../src/schemas/passkey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAW/B,eAAO,MAAM,gBAAgB,0DAI5B,CAAA;AAID,eAAO,MAAM,oBAAoB,0CAA2C,CAAA;AAC5E,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAA;AAExE,eAAO,MAAM,UAAU,6EAQb,CAAA;AACV,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;AAIpD,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;EAyBlB,CAAA;AAEF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAEzC,MAAM,MAAM,cAAc,GAAG,OAAO,OAAO,CAAC,OAAO,CAAA;AAEnD,eAAO,MAAM,cAAc;;;;;;;;;;EAUzB,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAA;AAEvD,eAAO,MAAM,eAAe;;;;;;;;;;;;;EAG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GAIG;AACH,eAAO,MAAM,UAAU;;;;EAIrB,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA;AAE/C;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;EAElC,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;;EAE1B,CAAA"}
@@ -6,9 +6,24 @@ import { Schema } from "effect";
6
6
  * kind of a type level satisfies
7
7
  */
8
8
  /* Registration Options */
9
+ /**
10
+ * Valid user verification requirements for WebAuthn operations.
11
+ *
12
+ * @category Passkeys
13
+ */
9
14
  export const UserVerification = Schema.Literal("required", "preferred", "discouraged");
10
15
  /* Passkey */
16
+ /**
17
+ * Possible device types reported for a passkey credential.
18
+ *
19
+ * @category Passkeys
20
+ */
11
21
  export const CredentialDeviceType = ["singleDevice", "multiDevice"];
22
+ /**
23
+ * Possible authenticator transport hints exposed by Passlock.
24
+ *
25
+ * @category Passkeys
26
+ */
12
27
  export const Transports = [
13
28
  "ble",
14
29
  "hybrid",
@@ -19,22 +34,33 @@ export const Transports = [
19
34
  "smart-card",
20
35
  ];
21
36
  /* Passkey */
37
+ /**
38
+ * Schema for the WebAuthn credential portion of a passkey.
39
+ *
40
+ * @category Passkeys
41
+ */
42
+ export const PasskeyCredential = Schema.Struct({
43
+ id: Schema.String, // webAuthnId (Base64Url)
44
+ userId: Schema.String, // webAuthnUserId (Base64Url)
45
+ username: Schema.String,
46
+ aaguid: Schema.String,
47
+ backedUp: Schema.Boolean,
48
+ counter: Schema.Number,
49
+ deviceType: Schema.Literal(...CredentialDeviceType),
50
+ transports: Schema.Array(Schema.Literal(...Transports)),
51
+ publicKey: Schema.Uint8ArrayFromBase64Url,
52
+ rpId: Schema.String,
53
+ });
54
+ /**
55
+ * Schema for a passkey stored in the Passlock vault.
56
+ *
57
+ * @category Passkeys
58
+ */
22
59
  export const Passkey = Schema.TaggedStruct("Passkey", {
23
60
  id: Schema.String,
24
61
  userId: Schema.optional(Schema.String),
25
62
  enabled: Schema.Boolean,
26
- credential: Schema.Struct({
27
- id: Schema.String, // webAuthnId (Base64Url)
28
- userId: Schema.String, // webAuthnUserId (Base64Url)
29
- username: Schema.String,
30
- aaguid: Schema.String,
31
- backedUp: Schema.Boolean,
32
- counter: Schema.Number,
33
- deviceType: Schema.Literal(...CredentialDeviceType),
34
- transports: Schema.Array(Schema.Literal(...Transports)),
35
- publicKey: Schema.Uint8ArrayFromBase64Url,
36
- rpId: Schema.String,
37
- }),
63
+ credential: PasskeyCredential,
38
64
  platform: Schema.optional(Schema.Struct({
39
65
  icon: Schema.optional(Schema.String),
40
66
  name: Schema.optional(Schema.String),
@@ -43,6 +69,11 @@ export const Passkey = Schema.TaggedStruct("Passkey", {
43
69
  createdAt: Schema.Number,
44
70
  updatedAt: Schema.Number,
45
71
  });
72
+ /**
73
+ * Schema for the compact passkey payload returned by listing operations.
74
+ *
75
+ * @category Passkeys
76
+ */
46
77
  export const PasskeySummary = Schema.TaggedStruct("PasskeySummary", {
47
78
  id: Schema.String,
48
79
  userId: Schema.String,
@@ -54,11 +85,50 @@ export const PasskeySummary = Schema.TaggedStruct("PasskeySummary", {
54
85
  createdAt: Schema.Number,
55
86
  lastUsed: Schema.optional(Schema.Number),
56
87
  });
88
+ /**
89
+ * Schema for one page of passkey summaries.
90
+ *
91
+ * @category Passkeys
92
+ */
57
93
  export const FindAllPasskeys = Schema.TaggedStruct("FindAllPasskeys", {
58
94
  cursor: Schema.NullOr(Schema.String),
59
95
  records: Schema.Array(PasskeySummary),
60
96
  });
97
+ /**
98
+ * Schema for a bulk passkey update response.
99
+ *
100
+ * @category Passkeys
101
+ */
61
102
  export const UpdatedPasskeys = Schema.TaggedStruct("UpdatedPasskeys", {
62
103
  updated: Schema.Array(Passkey),
63
104
  });
105
+ /**
106
+ * Schema for the credential identifiers returned after deleting passkeys.
107
+ *
108
+ * @category Passkeys
109
+ */
110
+ export const Credential = Schema.Struct({
111
+ credentialId: Schema.String,
112
+ userId: Schema.String,
113
+ rpId: Schema.String,
114
+ });
115
+ /**
116
+ * Raw REST API schema returned when passkeys are deleted.
117
+ *
118
+ * The package maps this into {@link DeletedPasskeys} before exposing it from
119
+ * the higher-level APIs.
120
+ *
121
+ * @category Passkeys
122
+ */
123
+ export const DeletedPasskeysResponse = Schema.TaggedStruct("DeletedPasskeys", {
124
+ deleted: Schema.Array(Passkey),
125
+ });
126
+ /**
127
+ * Public schema returned when passkeys are deleted by user ID.
128
+ *
129
+ * @category Passkeys
130
+ */
131
+ export const DeletedPasskeys = Schema.TaggedStruct("DeletedPasskeys", {
132
+ deleted: Schema.Array(Credential),
133
+ });
64
134
  //# sourceMappingURL=passkey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"passkey.js","sourceRoot":"","sources":["../../src/schemas/passkey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B;;;;;GAKG;AAEH,0BAA0B;AAE1B,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAC5C,UAAU,EACV,WAAW,EACX,aAAa,CACd,CAAA;AAED,aAAa;AAEb,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,cAAc,EAAE,aAAa,CAAU,CAAA;AAG5E,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK;IACL,QAAQ;IACR,UAAU;IACV,KAAK;IACL,KAAK;IACL,OAAO;IACP,YAAY;CACJ,CAAA;AAGV,aAAa;AAEb,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE;IACpD,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC,OAAO;IACvB,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC;QACxB,EAA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AAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACzC,CAAC,CAAA;AAIF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE;IACpE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC;CACtC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE;IACpE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;CAC/B,CAAC,CAAA","sourcesContent":["import { Schema } from \"effect\"\n\n/*\n * Important. We don't use `type X = typeof X.Type` because it won't generate\n * the Typedoc docs, so instead we mirror the types and use a dummy\n * `type _x = satisfy<typeof X.Type, X>`\n * kind of a type level satisfies\n */\n\n/* Registration Options */\n\nexport const UserVerification = Schema.Literal(\n \"required\",\n \"preferred\",\n \"discouraged\"\n)\n\n/* Passkey */\n\nexport const CredentialDeviceType = [\"singleDevice\", \"multiDevice\"] as const\nexport type CredentialDeviceType = (typeof CredentialDeviceType)[number]\n\nexport const Transports = [\n \"ble\",\n \"hybrid\",\n \"internal\",\n \"nfc\",\n \"usb\",\n \"cable\",\n \"smart-card\",\n] as const\nexport type Transports = (typeof Transports)[number]\n\n/* Passkey */\n\nexport const Passkey = Schema.TaggedStruct(\"Passkey\", {\n id: Schema.String,\n userId: Schema.optional(Schema.String),\n enabled: Schema.Boolean,\n credential: Schema.Struct({\n id: Schema.String, // webAuthnId (Base64Url)\n userId: Schema.String, // webAuthnUserId (Base64Url)\n username: Schema.String,\n aaguid: Schema.String,\n backedUp: Schema.Boolean,\n counter: Schema.Number,\n deviceType: Schema.Literal(...CredentialDeviceType),\n transports: Schema.Array(Schema.Literal(...Transports)),\n publicKey: Schema.Uint8ArrayFromBase64Url,\n rpId: Schema.String,\n }),\n platform: Schema.optional(\n Schema.Struct({\n icon: Schema.optional(Schema.String),\n name: Schema.optional(Schema.String),\n })\n ),\n lastUsed: Schema.optional(Schema.Number),\n createdAt: Schema.Number,\n updatedAt: Schema.Number,\n})\n\nexport type Passkey = typeof Passkey.Type\n\nexport type PasskeyEncoded = typeof Passkey.Encoded\n\nexport const PasskeySummary = Schema.TaggedStruct(\"PasskeySummary\", {\n id: Schema.String,\n userId: Schema.String,\n credential: Schema.Struct({\n id: Schema.String,\n userId: Schema.String,\n }),\n enabled: Schema.Boolean,\n createdAt: Schema.Number,\n lastUsed: Schema.optional(Schema.Number),\n})\n\nexport type PasskeySummary = typeof PasskeySummary.Type\n\nexport const FindAllPasskeys = Schema.TaggedStruct(\"FindAllPasskeys\", {\n cursor: Schema.NullOr(Schema.String),\n records: Schema.Array(PasskeySummary),\n})\n\nexport const UpdatedPasskeys = Schema.TaggedStruct(\"UpdatedPasskeys\", {\n updated: Schema.Array(Passkey),\n})\n"]}
1
+ {"version":3,"file":"passkey.js","sourceRoot":"","sources":["../../src/schemas/passkey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B;;;;;GAKG;AAEH,0BAA0B;AAE1B;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAC5C,UAAU,EACV,WAAW,EACX,aAAa,CACd,CAAA;AAED,aAAa;AAEb;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,cAAc,EAAE,aAAa,CAAU,CAAA;AAS5E;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK;IACL,QAAQ;IACR,UAAU;IACV,KAAK;IACL,KAAK;IACL,OAAO;IACP,YAAY;CACJ,CAAA;AASV,aAAa;AAEb;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7C,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,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ema } from \"effect\"\n\n/*\n * Important. We don't use `type X = typeof X.Type` because it won't generate\n * the Typedoc docs, so instead we mirror the types and use a dummy\n * `type _x = satisfy<typeof X.Type, X>`\n * kind of a type level satisfies\n */\n\n/* Registration Options */\n\n/**\n * Valid user verification requirements for WebAuthn operations.\n *\n * @category Passkeys\n */\nexport const UserVerification = Schema.Literal(\n \"required\",\n \"preferred\",\n \"discouraged\"\n)\n\n/* Passkey */\n\n/**\n * Possible device types reported for a passkey credential.\n *\n * @category Passkeys\n */\nexport const CredentialDeviceType = [\"singleDevice\", \"multiDevice\"] as const\n\n/**\n * Union of device types reported for a passkey credential.\n *\n * @category Passkeys\n */\nexport type CredentialDeviceType = (typeof CredentialDeviceType)[number]\n\n/**\n * Possible authenticator transport hints exposed by Passlock.\n *\n * @category Passkeys\n */\nexport const Transports = [\n \"ble\",\n \"hybrid\",\n \"internal\",\n \"nfc\",\n \"usb\",\n \"cable\",\n \"smart-card\",\n] as const\n\n/**\n * Union of authenticator transport hints exposed by Passlock.\n *\n * @category Passkeys\n */\nexport type Transports = (typeof Transports)[number]\n\n/* Passkey */\n\n/**\n * Schema for the WebAuthn credential portion of a passkey.\n *\n * @category Passkeys\n */\nexport const PasskeyCredential = Schema.Struct({\n id: Schema.String, // webAuthnId (Base64Url)\n userId: Schema.String, // webAuthnUserId (Base64Url)\n username: Schema.String,\n aaguid: Schema.String,\n backedUp: Schema.Boolean,\n counter: Schema.Number,\n deviceType: Schema.Literal(...CredentialDeviceType),\n transports: Schema.Array(Schema.Literal(...Transports)),\n publicKey: Schema.Uint8ArrayFromBase64Url,\n rpId: Schema.String,\n})\n\n/**\n * Type produced by {@link PasskeyCredential}.\n *\n * @category Passkeys\n */\nexport type PasskeyCredential = typeof PasskeyCredential.Type\n\n/**\n * Schema for a passkey stored in the Passlock vault.\n *\n * @category Passkeys\n */\nexport const Passkey = Schema.TaggedStruct(\"Passkey\", {\n id: Schema.String,\n userId: Schema.optional(Schema.String),\n enabled: Schema.Boolean,\n credential: PasskeyCredential,\n platform: Schema.optional(\n Schema.Struct({\n icon: Schema.optional(Schema.String),\n name: Schema.optional(Schema.String),\n })\n ),\n lastUsed: Schema.optional(Schema.Number),\n createdAt: Schema.Number,\n updatedAt: Schema.Number,\n})\n\n/**\n * Type produced by {@link Passkey}.\n *\n * @category Passkeys\n */\nexport type Passkey = typeof Passkey.Type\n\n/**\n * Encoded transport shape for {@link Passkey}.\n *\n * Binary fields such as `publicKey` are represented using schema-friendly\n * encoded values.\n *\n * @category Passkeys\n */\nexport type PasskeyEncoded = typeof Passkey.Encoded\n\n/**\n * Schema for the compact passkey payload returned by listing operations.\n *\n * @category Passkeys\n */\nexport const PasskeySummary = Schema.TaggedStruct(\"PasskeySummary\", {\n id: Schema.String,\n userId: Schema.String,\n credential: Schema.Struct({\n id: Schema.String,\n userId: Schema.String,\n }),\n enabled: Schema.Boolean,\n createdAt: Schema.Number,\n lastUsed: Schema.optional(Schema.Number),\n})\n\n/**\n * Type produced by {@link PasskeySummary}.\n *\n * @category Passkeys\n */\nexport type PasskeySummary = typeof PasskeySummary.Type\n\n/**\n * Schema for one page of passkey summaries.\n *\n * @category Passkeys\n */\nexport const FindAllPasskeys = Schema.TaggedStruct(\"FindAllPasskeys\", {\n cursor: Schema.NullOr(Schema.String),\n records: Schema.Array(PasskeySummary),\n})\n\n/**\n * Schema for a bulk passkey update response.\n *\n * @category Passkeys\n */\nexport const UpdatedPasskeys = Schema.TaggedStruct(\"UpdatedPasskeys\", {\n updated: Schema.Array(Passkey),\n})\n\n/**\n * Schema for the credential identifiers returned after deleting passkeys.\n *\n * @category Passkeys\n */\nexport const Credential = Schema.Struct({\n credentialId: Schema.String,\n userId: Schema.String,\n rpId: Schema.String,\n})\n\n/**\n * Type produced by {@link Credential}.\n *\n * @category Passkeys\n */\nexport type Credential = typeof Credential.Type\n\n/**\n * Raw REST API schema returned when passkeys are deleted.\n *\n * The package maps this into {@link DeletedPasskeys} before exposing it from\n * the higher-level APIs.\n *\n * @category Passkeys\n */\nexport const DeletedPasskeysResponse = Schema.TaggedStruct(\"DeletedPasskeys\", {\n deleted: Schema.Array(Passkey),\n})\n\n/**\n * Public schema returned when passkeys are deleted by user ID.\n *\n * @category Passkeys\n */\nexport const DeletedPasskeys = Schema.TaggedStruct(\"DeletedPasskeys\", {\n deleted: Schema.Array(Credential),\n})\n"]}