@passlock/server 2.1.0

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 (59) hide show
  1. package/README.md +45 -0
  2. package/README.template.md +45 -0
  3. package/dist/effect.d.ts +7 -0
  4. package/dist/effect.d.ts.map +1 -0
  5. package/dist/effect.js +4 -0
  6. package/dist/effect.js.map +1 -0
  7. package/dist/errors.d.ts +71 -0
  8. package/dist/errors.d.ts.map +1 -0
  9. package/dist/errors.js +30 -0
  10. package/dist/errors.js.map +1 -0
  11. package/dist/index.d.ts +115 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +109 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/network.d.ts +134 -0
  16. package/dist/network.d.ts.map +1 -0
  17. package/dist/network.js +172 -0
  18. package/dist/network.js.map +1 -0
  19. package/dist/passkey/passkey.d.ts +132 -0
  20. package/dist/passkey/passkey.d.ts.map +1 -0
  21. package/dist/passkey/passkey.js +158 -0
  22. package/dist/passkey/passkey.js.map +1 -0
  23. package/dist/principal/principal.d.ts +22 -0
  24. package/dist/principal/principal.d.ts.map +1 -0
  25. package/dist/principal/principal.js +65 -0
  26. package/dist/principal/principal.js.map +1 -0
  27. package/dist/safe.d.ts +154 -0
  28. package/dist/safe.d.ts.map +1 -0
  29. package/dist/safe.js +147 -0
  30. package/dist/safe.js.map +1 -0
  31. package/dist/schemas/errors.d.ts +2 -0
  32. package/dist/schemas/errors.d.ts.map +1 -0
  33. package/dist/schemas/errors.js +72 -0
  34. package/dist/schemas/errors.js.map +1 -0
  35. package/dist/schemas/index.d.ts +5 -0
  36. package/dist/schemas/index.d.ts.map +1 -0
  37. package/dist/schemas/index.js +5 -0
  38. package/dist/schemas/index.js.map +1 -0
  39. package/dist/schemas/passkey.d.ts +85 -0
  40. package/dist/schemas/passkey.d.ts.map +1 -0
  41. package/dist/schemas/passkey.js +64 -0
  42. package/dist/schemas/passkey.js.map +1 -0
  43. package/dist/schemas/principal.d.ts +88 -0
  44. package/dist/schemas/principal.d.ts.map +1 -0
  45. package/dist/schemas/principal.js +46 -0
  46. package/dist/schemas/principal.js.map +1 -0
  47. package/dist/schemas/satisfy.d.ts +2 -0
  48. package/dist/schemas/satisfy.d.ts.map +1 -0
  49. package/dist/schemas/satisfy.js +2 -0
  50. package/dist/schemas/satisfy.js.map +1 -0
  51. package/dist/schemas/signup.d.ts +13 -0
  52. package/dist/schemas/signup.d.ts.map +1 -0
  53. package/dist/schemas/signup.js +11 -0
  54. package/dist/schemas/signup.js.map +1 -0
  55. package/dist/shared.d.ts +19 -0
  56. package/dist/shared.d.ts.map +1 -0
  57. package/dist/shared.js +9 -0
  58. package/dist/shared.js.map +1 -0
  59. package/package.json +93 -0
@@ -0,0 +1,65 @@
1
+ import { Data, Effect, Match, pipe, Schema } from "effect";
2
+ import * as jose from "jose";
3
+ import { fetchNetwork, matchStatus, NetworkFetchLive, } from "../network.js";
4
+ import { ForbiddenError, InvalidCodeError } from "../schemas/errors.js";
5
+ import { ExtendedPrincipalSchema, IdTokenSchema, } from "../schemas/principal.js";
6
+ export const exchangeCode = (options, fetchLayer = NetworkFetchLive) => pipe(Effect.gen(function* () {
7
+ const baseUrl = options.endpoint ?? "https://api.passlock.dev";
8
+ const { tenancyId, code } = options;
9
+ const url = new URL(`/${tenancyId}/principal/${code}`, baseUrl);
10
+ const response = yield* fetchNetwork(url, "get", undefined, {
11
+ headers: {
12
+ authorization: `Bearer ${options.apiKey}`,
13
+ },
14
+ });
15
+ const encoded = yield* matchStatus(response, {
16
+ "2xx": ({ json }) => pipe(json, Effect.flatMap(Schema.decodeUnknown(ExtendedPrincipalSchema))),
17
+ orElse: ({ json }) => pipe(json, Effect.flatMap(Schema.decodeUnknown(Schema.Union(InvalidCodeError, ForbiddenError)))),
18
+ });
19
+ return yield* pipe(Match.value(encoded), Match.tag("ExtendedPrincipal", (principal) => Effect.succeed(principal)), Match.tag("@error/InvalidCode", (err) => Effect.fail(err)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.exhaustive);
20
+ }), Effect.catchTags({
21
+ "@error/NetworkPayload": (err) => Effect.die(err),
22
+ "@error/NetworkRequest": (err) => Effect.die(err),
23
+ "@error/NetworkResponse": (err) => Effect.die(err),
24
+ ParseError: (err) => Effect.die(err),
25
+ }), Effect.provide(fetchLayer));
26
+ export class VerificationError extends Data.TaggedError("@error/Verification") {
27
+ }
28
+ export const verifyIdToken = (options) => pipe(Effect.gen(function* () {
29
+ const JWKS = yield* createCachedRemoteJwks(options.endpoint);
30
+ const { payload } = yield* Effect.tryPromise({
31
+ catch: (err) => {
32
+ return err instanceof Error
33
+ ? new VerificationError({ message: err.message })
34
+ : new VerificationError({ message: String(err) });
35
+ },
36
+ try: () => jose.jwtVerify(options.token, JWKS, {
37
+ audience: options.tenancyId,
38
+ issuer: "passlock.dev",
39
+ }),
40
+ });
41
+ const idToken = yield* Schema.decodeUnknown(IdTokenSchema)({
42
+ ...payload,
43
+ _tag: "IdToken",
44
+ });
45
+ const principal = {
46
+ _tag: "Principal",
47
+ id: idToken["jti"],
48
+ authenticatorId: idToken["a:id"],
49
+ authenticatorType: "passkey",
50
+ createdAt: idToken.iat * 1000,
51
+ expiresAt: idToken.exp * 1000,
52
+ passkey: {
53
+ userVerified: idToken["pk:uv"],
54
+ verified: true,
55
+ },
56
+ userId: idToken.sub,
57
+ };
58
+ return principal;
59
+ }), Effect.catchTag("ParseError", (err) => Effect.die(err)));
60
+ const createJwks = (endpoint) => Effect.sync(() => {
61
+ const baseUrl = endpoint ?? "https://api.passlock.dev";
62
+ return jose.createRemoteJWKSet(new URL("/.well-known/jwks.json", baseUrl));
63
+ });
64
+ const createCachedRemoteJwks = pipe(Effect.cachedFunction(createJwks), Effect.runSync);
65
+ //# sourceMappingURL=principal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"principal.js","sourceRoot":"","sources":["../../src/principal/principal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EA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AAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CACxD,CAAA;AAEH,MAAM,UAAU,GAAG,CAAC,QAAiB,EAAE,EAAE,CACvC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;IACf,MAAM,OAAO,GAAG,QAAQ,IAAI,0BAA0B,CAAA;IAEtD,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,GAAG,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC,CAAA;AAC5E,CAAC,CAAC,CAAA;AAEJ,MAAM,sBAAsB,GAAG,IAAI,CACjC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,EACjC,MAAM,CAAC,OAAO,CACf,CAAA","sourcesContent":["import { Data, Effect, type Layer, Match, pipe, Schema } from \"effect\"\n\nimport * as jose from \"jose\"\nimport {\n fetchNetwork,\n matchStatus,\n type NetworkFetch,\n NetworkFetchLive,\n type NetworkPayloadError,\n type NetworkRequestError,\n type NetworkResponseError,\n} from \"../network.js\"\nimport { ForbiddenError, InvalidCodeError } from \"../schemas/errors.js\"\nimport {\n type ExtendedPrincipal,\n ExtendedPrincipalSchema,\n IdTokenSchema,\n type Principal,\n} from \"../schemas/principal.js\"\n\nimport type { AuthenticatedOptions, PasslockOptions } from \"../shared.js\"\n\nexport interface ExchangeCodeOptions extends AuthenticatedOptions {\n code: string\n}\n\nexport const exchangeCode = (\n options: ExchangeCodeOptions,\n fetchLayer: Layer.Layer<NetworkFetch> = NetworkFetchLive\n): Effect.Effect<ExtendedPrincipal, InvalidCodeError | ForbiddenError> =>\n pipe(\n Effect.gen(function* () {\n const baseUrl = options.endpoint ?? \"https://api.passlock.dev\"\n const { tenancyId, code } = options\n\n const url = new URL(`/${tenancyId}/principal/${code}`, baseUrl)\n\n const response = yield* fetchNetwork(url, \"get\", undefined, {\n headers: {\n authorization: `Bearer ${options.apiKey}`,\n },\n })\n\n const encoded: ExtendedPrincipal | InvalidCodeError | ForbiddenError =\n yield* matchStatus(response, {\n \"2xx\": ({ json }) =>\n pipe(\n json,\n Effect.flatMap(Schema.decodeUnknown(ExtendedPrincipalSchema))\n ),\n orElse: ({ json }) =>\n pipe(\n json,\n Effect.flatMap(\n Schema.decodeUnknown(\n Schema.Union(InvalidCodeError, ForbiddenError)\n )\n )\n ),\n })\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"ExtendedPrincipal\", (principal) =>\n Effect.succeed(principal)\n ),\n Match.tag(\"@error/InvalidCode\", (err) => Effect.fail(err)),\n Match.tag(\"@error/Forbidden\", (err) => Effect.fail(err)),\n Match.exhaustive\n )\n }),\n Effect.catchTags({\n \"@error/NetworkPayload\": (err: NetworkPayloadError) => Effect.die(err),\n \"@error/NetworkRequest\": (err: NetworkRequestError) => Effect.die(err),\n \"@error/NetworkResponse\": (err: NetworkResponseError) => Effect.die(err),\n ParseError: (err) => Effect.die(err),\n }),\n Effect.provide(fetchLayer)\n )\n\nexport class VerificationError extends Data.TaggedError(\"@error/Verification\")<{\n message: string\n}> {}\n\nexport interface VerifyIdTokenOptions extends PasslockOptions {\n token: string\n}\n\nexport const verifyIdToken = (\n options: VerifyIdTokenOptions\n): Effect.Effect<Principal, VerificationError> =>\n pipe(\n Effect.gen(function* () {\n const JWKS = yield* createCachedRemoteJwks(options.endpoint)\n\n const { payload } = yield* Effect.tryPromise({\n catch: (err) => {\n return err instanceof Error\n ? new VerificationError({ message: err.message })\n : new VerificationError({ message: String(err) })\n },\n try: () =>\n jose.jwtVerify(options.token, JWKS, {\n audience: options.tenancyId,\n issuer: \"passlock.dev\",\n }),\n })\n\n const idToken = yield* Schema.decodeUnknown(IdTokenSchema)({\n ...payload,\n _tag: \"IdToken\",\n })\n\n const principal: Principal = {\n _tag: \"Principal\",\n id: idToken[\"jti\"],\n authenticatorId: idToken[\"a:id\"],\n authenticatorType: \"passkey\",\n createdAt: idToken.iat * 1000,\n expiresAt: idToken.exp * 1000,\n passkey: {\n userVerified: idToken[\"pk:uv\"],\n verified: true,\n },\n userId: idToken.sub,\n }\n\n return principal\n }),\n Effect.catchTag(\"ParseError\", (err) => Effect.die(err))\n )\n\nconst createJwks = (endpoint?: string) =>\n Effect.sync(() => {\n const baseUrl = endpoint ?? \"https://api.passlock.dev\"\n\n return jose.createRemoteJWKSet(new URL(\"/.well-known/jwks.json\", baseUrl))\n })\n\nconst createCachedRemoteJwks = pipe(\n Effect.cachedFunction(createJwks),\n Effect.runSync\n)\n"]}
package/dist/safe.d.ts ADDED
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Safe functions that return discriminated unions representing
3
+ * the successful outcome or expected failures.
4
+ *
5
+ * Note: unexpected runtime failures may still throw.
6
+ *
7
+ * @categoryDescription Passkeys
8
+ * Functions and related types for managing passkeys
9
+ *
10
+ * @showCategories
11
+ *
12
+ * @module safe
13
+ */
14
+ import type { ForbiddenError, InvalidCodeError, NotFoundError, VerificationError } from "./errors.js";
15
+ import type { AssignUserOptions, DeletePasskeyOptions, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey, UpdatedPasskeyUsernames, UpdatePasskeyOptions, UpdatePasskeyUsernamesOptions } from "./passkey/passkey.js";
16
+ import type { ExchangeCodeOptions, VerifyIdTokenOptions } from "./principal/principal.js";
17
+ import type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
18
+ /**
19
+ * Assign a custom User ID to a passkey. Will be reflected in the next
20
+ * {@link Principal} or {@link ExtendedPrincipal} generated.
21
+ *
22
+ * **Note:** This does not change the underlying WebAuthn credential's `userId`.
23
+ * Instead we apply a layer of indirection.
24
+ *
25
+ * @see {@link Principal}
26
+ * @see {@link ExtendedPrincipal}
27
+ * @see [credential](https://passlock.dev/rest-api/credential/)
28
+ *
29
+ * @param request
30
+ * @returns A promise resolving to either a passkey or an API error.
31
+ *
32
+ * @category Passkeys
33
+ */
34
+ export declare const assignUser: (request: AssignUserOptions) => Promise<Passkey | NotFoundError | ForbiddenError>;
35
+ /**
36
+ * Can also be used to assign a custom User ID, but also allows you to update
37
+ * the username.
38
+ *
39
+ * **Important:** changing the username has no bearing on authentication, as
40
+ * it's typically only used in the client-side component of the passkey
41
+ * (so the user knows which account the passkey relates to).
42
+ *
43
+ * However you might choose to align the username in your vault with the
44
+ * client-side component to simplify end user support.
45
+ *
46
+ * @param request
47
+ * @returns A promise resolving to either a passkey or an API error.
48
+ *
49
+ * @category Passkeys
50
+ */
51
+ export declare const updatePasskey: (request: UpdatePasskeyOptions) => Promise<Passkey | NotFoundError | ForbiddenError>;
52
+ /**
53
+ * Update the username for all passkeys belonging to a given user.
54
+ *
55
+ * **Important:** changing the username has no bearing on authentication, as
56
+ * it's typically only used in the client-side component of the passkey
57
+ * (so the user knows which account the passkey relates to).
58
+ *
59
+ * However you might choose to align the username in your vault with the
60
+ * client-side component to simplify end user support.
61
+ *
62
+ * @param request
63
+ * @returns A promise resolving to either updated passkey usernames or an API error.
64
+ *
65
+ * @category Passkeys
66
+ */
67
+ export declare const updatePasskeyUsernames: (request: UpdatePasskeyUsernamesOptions) => Promise<UpdatedPasskeyUsernames | NotFoundError | ForbiddenError>;
68
+ /**
69
+ * Delete a passkey from your vault.
70
+ *
71
+ * **Note:** The user will still retain the passkey on their device so
72
+ * you will need to either:
73
+ *
74
+ * a) Use the @passlock/client functions to delete the passkey from the user's device.
75
+ * b) Remind the user to delete the passkey
76
+ *
77
+ * See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) in the documentation.
78
+ *
79
+ * In addition, during authentication you should handle a missing passkey scenario.
80
+ * This happens when a user tries to authenticate with a passkey that is missing from
81
+ * your vault. The @passlock/client library can help with this. See
82
+ * [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)
83
+ *
84
+ * @see [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/)
85
+ * @see [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)
86
+ *
87
+ * @param options
88
+ * @returns A promise resolving to either the deleted passkey or an API error.
89
+ *
90
+ * @category Passkeys
91
+ */
92
+ export declare const deletePasskey: (options: DeletePasskeyOptions) => Promise<Passkey | ForbiddenError | NotFoundError>;
93
+ /**
94
+ * Fetch details about a passkey. **Important**: Not to be confused with
95
+ * the {@link exchangeCode} or {@link verifyIdToken} functions, which
96
+ * return details about specific authentication or registration operations.
97
+ * Use this function for passkey management, not authentication.
98
+ *
99
+ * @param options
100
+ * @returns A promise resolving to either passkey details or an API error.
101
+ *
102
+ * @category Passkeys
103
+ */
104
+ export declare const getPasskey: (options: GetPasskeyOptions) => Promise<Passkey | ForbiddenError | NotFoundError>;
105
+ /**
106
+ * List passkeys for the given tenancy. Note: This could return a cursor.
107
+ * If so, call again, passing the cursor back in.
108
+ *
109
+ * @param options
110
+ * @returns A promise resolving to a page of passkey summaries or an API error.
111
+ *
112
+ * @category Passkeys
113
+ */
114
+ export declare const listPasskeys: (options: ListPasskeyOptions) => Promise<FindAllPasskeys | ForbiddenError>;
115
+ /**
116
+ * The @passlock/client library generates codes, which you should send to
117
+ * your backend. Use this function to exchange the code for details about
118
+ * the registration or authentication operation. **Note:** a code is valid
119
+ * for 5 minutes.
120
+ *
121
+ * @see {@link ExtendedPrincipal}
122
+ *
123
+ * @param options
124
+ * @returns A promise resolving to an extended principal or an API error.
125
+ *
126
+ * @category Principal
127
+ */
128
+ export declare const exchangeCode: (options: ExchangeCodeOptions) => Promise<ExtendedPrincipal | ForbiddenError | InvalidCodeError>;
129
+ /**
130
+ * Decode and verify an id_token (JWT) locally.
131
+ * **Note:** This will make a network call to
132
+ * `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)
133
+ * to fetch the relevant public key. The response will be cached, however
134
+ * bear in mind that for something like AWS Lambda it will make the call on every
135
+ * cold start so might actually be slower than {@link exchangeCode}
136
+ *
137
+ * @see {@link Principal}
138
+ *
139
+ * @param options
140
+ * @returns A promise resolving to a verified principal or verification failure.
141
+ *
142
+ * @category Principal
143
+ */
144
+ export declare const verifyIdToken: (options: VerifyIdTokenOptions) => Promise<Principal | VerificationError>;
145
+ export type { BadRequestError, DuplicateEmailError, ForbiddenError, InvalidCodeError, InvalidEmailError, InvalidTenancyError, NotFoundError, PasskeyNotFoundError, UnauthorizedError, VerificationError, } from "./errors.js";
146
+ export { isBadRequestError, isDuplicateEmailError, isForbiddenError, isInvalidCodeError, isInvalidEmailError, isInvalidTenancyError, isNotFoundError, isPasskeyNotFoundError, isUnauthorizedError, isVerificationError, } from "./errors.js";
147
+ export type { AssignUserOptions, Credential, DeletePasskeyOptions, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey, PasskeySummary, Platform, UpdatedPasskeys, UpdatedPasskeyUsernames, UpdatePasskeyOptions, UpdatePasskeyUsernamesOptions, } from "./passkey/passkey.js";
148
+ export { isPasskey, isPasskeySummary, isUpdatedPasskeys, isUpdatedPasskeyUsernames, } from "./passkey/passkey.js";
149
+ export type { ExchangeCodeOptions, VerifyIdTokenOptions, } from "./principal/principal.js";
150
+ export type { CredentialDeviceType, Transports, } from "./schemas/passkey.js";
151
+ export type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
152
+ export { isExtendedPrincipal, isPrincipal } from "./schemas/principal.js";
153
+ export type { AuthenticatedOptions, PasslockOptions, } from "./shared.js";
154
+ //# sourceMappingURL=safe.d.ts.map
@@ -0,0 +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,E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iB,GAClB,MAAM,aAAa,CAAA;AACpB,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;AACpB,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,OAAO,EACP,cAAc,EACd,QAAQ,EACR,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,GAC1B,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 ADDED
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Safe functions that return discriminated unions representing
3
+ * the successful outcome or expected failures.
4
+ *
5
+ * Note: unexpected runtime failures may still throw.
6
+ *
7
+ * @categoryDescription Passkeys
8
+ * Functions and related types for managing passkeys
9
+ *
10
+ * @showCategories
11
+ *
12
+ * @module safe
13
+ */
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";
16
+ import { exchangeCode as exchangeCodeE, verifyIdToken as verifyIdTokenE, } from "./principal/principal.js";
17
+ /**
18
+ * Assign a custom User ID to a passkey. Will be reflected in the next
19
+ * {@link Principal} or {@link ExtendedPrincipal} generated.
20
+ *
21
+ * **Note:** This does not change the underlying WebAuthn credential's `userId`.
22
+ * Instead we apply a layer of indirection.
23
+ *
24
+ * @see {@link Principal}
25
+ * @see {@link ExtendedPrincipal}
26
+ * @see [credential](https://passlock.dev/rest-api/credential/)
27
+ *
28
+ * @param request
29
+ * @returns A promise resolving to either a passkey or an API error.
30
+ *
31
+ * @category Passkeys
32
+ */
33
+ export const assignUser = (request) => pipe(assignUserE(request), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
34
+ /**
35
+ * Can also be used to assign a custom User ID, but also allows you to update
36
+ * the username.
37
+ *
38
+ * **Important:** changing the username has no bearing on authentication, as
39
+ * it's typically only used in the client-side component of the passkey
40
+ * (so the user knows which account the passkey relates to).
41
+ *
42
+ * However you might choose to align the username in your vault with the
43
+ * client-side component to simplify end user support.
44
+ *
45
+ * @param request
46
+ * @returns A promise resolving to either a passkey or an API error.
47
+ *
48
+ * @category Passkeys
49
+ */
50
+ export const updatePasskey = (request) => pipe(updatePasskeyE(request), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
51
+ /**
52
+ * Update the username for all passkeys belonging to a given user.
53
+ *
54
+ * **Important:** changing the username has no bearing on authentication, as
55
+ * it's typically only used in the client-side component of the passkey
56
+ * (so the user knows which account the passkey relates to).
57
+ *
58
+ * However you might choose to align the username in your vault with the
59
+ * client-side component to simplify end user support.
60
+ *
61
+ * @param request
62
+ * @returns A promise resolving to either updated passkey usernames or an API error.
63
+ *
64
+ * @category Passkeys
65
+ */
66
+ export const updatePasskeyUsernames = (request) => pipe(updatePasskeyUsernamesE(request), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
67
+ /**
68
+ * Delete a passkey from your vault.
69
+ *
70
+ * **Note:** The user will still retain the passkey on their device so
71
+ * you will need to either:
72
+ *
73
+ * a) Use the @passlock/client functions to delete the passkey from the user's device.
74
+ * b) Remind the user to delete the passkey
75
+ *
76
+ * See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) in the documentation.
77
+ *
78
+ * In addition, during authentication you should handle a missing passkey scenario.
79
+ * This happens when a user tries to authenticate with a passkey that is missing from
80
+ * your vault. The @passlock/client library can help with this. See
81
+ * [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)
82
+ *
83
+ * @see [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/)
84
+ * @see [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)
85
+ *
86
+ * @param options
87
+ * @returns A promise resolving to either the deleted passkey or an API error.
88
+ *
89
+ * @category Passkeys
90
+ */
91
+ export const deletePasskey = (options) => pipe(deletePasskeyE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
92
+ /**
93
+ * Fetch details about a passkey. **Important**: Not to be confused with
94
+ * the {@link exchangeCode} or {@link verifyIdToken} functions, which
95
+ * return details about specific authentication or registration operations.
96
+ * Use this function for passkey management, not authentication.
97
+ *
98
+ * @param options
99
+ * @returns A promise resolving to either passkey details or an API error.
100
+ *
101
+ * @category Passkeys
102
+ */
103
+ export const getPasskey = (options) => pipe(getPasskeyE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
104
+ /**
105
+ * List passkeys for the given tenancy. Note: This could return a cursor.
106
+ * If so, call again, passing the cursor back in.
107
+ *
108
+ * @param options
109
+ * @returns A promise resolving to a page of passkey summaries or an API error.
110
+ *
111
+ * @category Passkeys
112
+ */
113
+ export const listPasskeys = (options) => pipe(listPasskeysE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
114
+ /**
115
+ * The @passlock/client library generates codes, which you should send to
116
+ * your backend. Use this function to exchange the code for details about
117
+ * the registration or authentication operation. **Note:** a code is valid
118
+ * for 5 minutes.
119
+ *
120
+ * @see {@link ExtendedPrincipal}
121
+ *
122
+ * @param options
123
+ * @returns A promise resolving to an extended principal or an API error.
124
+ *
125
+ * @category Principal
126
+ */
127
+ export const exchangeCode = (options) => pipe(exchangeCodeE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
128
+ /**
129
+ * Decode and verify an id_token (JWT) locally.
130
+ * **Note:** This will make a network call to
131
+ * `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)
132
+ * 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}
135
+ *
136
+ * @see {@link Principal}
137
+ *
138
+ * @param options
139
+ * @returns A promise resolving to a verified principal or verification failure.
140
+ *
141
+ * @category Principal
142
+ */
143
+ export const verifyIdToken = (options) => pipe(verifyIdTokenE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
144
+ export { isBadRequestError, isDuplicateEmailError, isForbiddenError, isInvalidCodeError, isInvalidEmailError, isInvalidTenancyError, isNotFoundError, isPasskeyNotFoundError, isUnauthorizedError, isVerificationError, } from "./errors.js";
145
+ export { isPasskey, isPasskeySummary, isUpdatedPasskeys, isUpdatedPasskeyUsernames, } from "./passkey/passkey.js";
146
+ export { isExtendedPrincipal, isPrincipal } from "./schemas/principal.js";
147
+ //# sourceMappingURL=safe.js.map
@@ -0,0 +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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E,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"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/schemas/errors.ts"],"names":[],"mappings":""}
@@ -0,0 +1,72 @@
1
+ import { Schema } from "effect";
2
+ /* Unauthorized */
3
+ /** @internal */
4
+ export class UnauthorizedError extends Schema.TaggedError()("@error/Unauthorized", {}) {
5
+ }
6
+ /** @internal */
7
+ export const isUnauthorizedError = (payload) => Schema.is(UnauthorizedError)(payload);
8
+ /* Forbidden */
9
+ /** @internal */
10
+ export class ForbiddenError extends Schema.TaggedError()("@error/Forbidden", {}) {
11
+ }
12
+ /** @internal */
13
+ export const isForbiddenError = (payload) => Schema.is(ForbiddenError)(payload);
14
+ /* InvalidCode */
15
+ /** @internal */
16
+ export class InvalidCodeError extends Schema.TaggedError()("@error/InvalidCode", {
17
+ message: Schema.String,
18
+ }) {
19
+ }
20
+ /** @internal */
21
+ export const isInvalidCodeError = (payload) => Schema.is(InvalidCodeError)(payload);
22
+ /* InvalidTenancy */
23
+ /** @internal */
24
+ export class InvalidTenancyError extends Schema.TaggedError()("@error/InvalidTenancy", {
25
+ message: Schema.String,
26
+ }) {
27
+ }
28
+ /** @internal */
29
+ export const isInvalidTenancyError = (payload) => Schema.is(InvalidTenancyError)(payload);
30
+ /* PasskeyNotFound */
31
+ /** @internal */
32
+ export class PasskeyNotFoundError extends Schema.TaggedError()("@error/PasskeyNotFound", {
33
+ credentialId: Schema.String,
34
+ message: Schema.String,
35
+ rpId: Schema.String,
36
+ }) {
37
+ }
38
+ /** @internal */
39
+ export const isPasskeyNotFoundError = (payload) => Schema.is(PasskeyNotFoundError)(payload);
40
+ /* NotFound */
41
+ /** @internal */
42
+ export class NotFoundError extends Schema.TaggedError()("@error/NotFound", {
43
+ message: Schema.String,
44
+ }) {
45
+ }
46
+ /** @internal */
47
+ export const isNotFoundError = (payload) => Schema.is(NotFoundError)(payload);
48
+ /* InvalidEmail */
49
+ /** @internal */
50
+ export class InvalidEmailError extends Schema.TaggedError()("@error/InvalidEmail", {
51
+ message: Schema.String,
52
+ }) {
53
+ }
54
+ /** @internal */
55
+ export const isInvalidEmailError = (payload) => Schema.is(InvalidEmailError)(payload);
56
+ /* DuplicateEmail */
57
+ /** @internal */
58
+ export class DuplicateEmailError extends Schema.TaggedError()("@error/DuplicateEmail", {
59
+ message: Schema.String,
60
+ }) {
61
+ }
62
+ /** @internal */
63
+ export const isDuplicateEmailError = (payload) => Schema.is(DuplicateEmailError)(payload);
64
+ /* BadRequest */
65
+ /** @internal */
66
+ export class BadRequestError extends Schema.TaggedError()("@error/BadRequest", {
67
+ message: Schema.String,
68
+ }) {
69
+ }
70
+ /** @internal */
71
+ export const isBadRequestError = (payload) => Schema.is(BadRequestError)(payload);
72
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/schemas/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,kBAAkB;AAElB,gBAAgB;AAChB,MAAM,OAAO,iBAAkB,SAAQ,MAAM,CAAC,WAAW,EAAqB,CAC5E,qBAAqB,EACrB,EAAE,CACH;CAAG;AAEJ,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,OAAgB,EACc,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAA;AAExE,eAAe;AAEf,gBAAgB;AAChB,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,WAAW,EAAkB,CACtE,kBAAkB,EAClB,EAAE,CACH;CAAG;AAEJ,gBAAgB;AAChB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAA6B,EAAE,CAC9E,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAA;AAEpC,iBAAiB;AAEjB,gBAAgB;AAChB,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,WAAW,EAAoB,CAC1E,oBAAoB,EACpB;IACE,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CACF;CAAG;AAEJ,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,OAAgB,EACa,EAA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J,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,OAAgB,EACc,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAA;AAExE,oBAAoB;AAEpB,gBAAgB;AAChB,MAAM,OAAO,mBAAoB,SAAQ,MAAM,CAAC,WAAW,EAAuB,CAChF,uBAAuB,EACvB;IACE,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CACF;CAAG;AAEJ,gBAAgB;AAChB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,OAAgB,EACgB,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,CAAA;AAE5E,gBAAgB;AAEhB,gBAAgB;AAChB,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,WAAW,EAAmB,CACxE,mBAAmB,EACnB;IACE,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CACF;CAAG;AAEJ,gBAAgB;AAChB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,OAAgB,EACY,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAA","sourcesContent":["import { Schema } from \"effect\"\n\n/* Unauthorized */\n\n/** @internal */\nexport class UnauthorizedError extends Schema.TaggedError<UnauthorizedError>()(\n \"@error/Unauthorized\",\n {}\n) {}\n\n/** @internal */\nexport const isUnauthorizedError = (\n payload: unknown\n): payload is UnauthorizedError => Schema.is(UnauthorizedError)(payload)\n\n/* Forbidden */\n\n/** @internal */\nexport class ForbiddenError extends Schema.TaggedError<ForbiddenError>()(\n \"@error/Forbidden\",\n {}\n) {}\n\n/** @internal */\nexport const isForbiddenError = (payload: unknown): payload is ForbiddenError =>\n Schema.is(ForbiddenError)(payload)\n\n/* InvalidCode */\n\n/** @internal */\nexport class InvalidCodeError extends Schema.TaggedError<InvalidCodeError>()(\n \"@error/InvalidCode\",\n {\n message: Schema.String,\n }\n) {}\n\n/** @internal */\nexport const isInvalidCodeError = (\n payload: unknown\n): payload is InvalidCodeError => Schema.is(InvalidCodeError)(payload)\n\n/* InvalidTenancy */\n\n/** @internal */\nexport class InvalidTenancyError extends Schema.TaggedError<InvalidTenancyError>()(\n \"@error/InvalidTenancy\",\n {\n message: Schema.String,\n }\n) {}\n\n/** @internal */\nexport const isInvalidTenancyError = (\n payload: unknown\n): payload is InvalidTenancyError => Schema.is(InvalidTenancyError)(payload)\n\n/* PasskeyNotFound */\n\n/** @internal */\nexport class PasskeyNotFoundError extends Schema.TaggedError<PasskeyNotFoundError>()(\n \"@error/PasskeyNotFound\",\n {\n credentialId: Schema.String,\n message: Schema.String,\n rpId: Schema.String,\n }\n) {}\n\n/** @internal */\nexport const isPasskeyNotFoundError = (\n payload: unknown\n): payload is PasskeyNotFoundError => Schema.is(PasskeyNotFoundError)(payload)\n\n/* NotFound */\n\n/** @internal */\nexport class NotFoundError extends Schema.TaggedError<NotFoundError>()(\n \"@error/NotFound\",\n {\n message: Schema.String,\n }\n) {}\n\n/** @internal */\nexport const isNotFoundError = (payload: unknown): payload is NotFoundError =>\n Schema.is(NotFoundError)(payload)\n\n/* InvalidEmail */\n\n/** @internal */\nexport class InvalidEmailError extends Schema.TaggedError<InvalidEmailError>()(\n \"@error/InvalidEmail\",\n {\n message: Schema.String,\n }\n) {}\n\n/** @internal */\nexport const isInvalidEmailError = (\n payload: unknown\n): payload is InvalidEmailError => Schema.is(InvalidEmailError)(payload)\n\n/* DuplicateEmail */\n\n/** @internal */\nexport class DuplicateEmailError extends Schema.TaggedError<DuplicateEmailError>()(\n \"@error/DuplicateEmail\",\n {\n message: Schema.String,\n }\n) {}\n\n/** @internal */\nexport const isDuplicateEmailError = (\n payload: unknown\n): payload is DuplicateEmailError => Schema.is(DuplicateEmailError)(payload)\n\n/* BadRequest */\n\n/** @internal */\nexport class BadRequestError extends Schema.TaggedError<BadRequestError>()(\n \"@error/BadRequest\",\n {\n message: Schema.String,\n }\n) {}\n\n/** @internal */\nexport const isBadRequestError = (\n payload: unknown\n): payload is BadRequestError => Schema.is(BadRequestError)(payload)\n"]}
@@ -0,0 +1,5 @@
1
+ export * from "./errors.js";
2
+ export * from "./passkey.js";
3
+ export * from "./principal.js";
4
+ export * from "./signup.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from "./errors.js";
2
+ export * from "./passkey.js";
3
+ export * from "./principal.js";
4
+ export * from "./signup.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA","sourcesContent":["export * from \"./errors.js\"\nexport * from \"./passkey.js\"\nexport * from \"./principal.js\"\nexport * from \"./signup.js\"\n"]}
@@ -0,0 +1,85 @@
1
+ import { Schema } from "effect";
2
+ export declare const UserVerification: Schema.Literal<["required", "preferred", "discouraged"]>;
3
+ export declare const CredentialDeviceType: readonly ["singleDevice", "multiDevice"];
4
+ export type CredentialDeviceType = (typeof CredentialDeviceType)[number];
5
+ export declare const Transports: readonly ["ble", "hybrid", "internal", "nfc", "usb", "cable", "smart-card"];
6
+ export type Transports = (typeof Transports)[number];
7
+ export declare const Passkey: Schema.TaggedStruct<"Passkey", {
8
+ id: typeof Schema.String;
9
+ userId: Schema.optional<typeof Schema.String>;
10
+ enabled: typeof Schema.Boolean;
11
+ credential: Schema.Struct<{
12
+ id: typeof Schema.String;
13
+ userId: typeof Schema.String;
14
+ username: typeof Schema.String;
15
+ aaguid: typeof Schema.String;
16
+ backedUp: typeof Schema.Boolean;
17
+ counter: typeof Schema.Number;
18
+ deviceType: Schema.Literal<["singleDevice", "multiDevice"]>;
19
+ transports: Schema.Array$<Schema.Literal<["ble", "hybrid", "internal", "nfc", "usb", "cable", "smart-card"]>>;
20
+ publicKey: Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>;
21
+ rpId: typeof Schema.String;
22
+ }>;
23
+ platform: Schema.optional<Schema.Struct<{
24
+ icon: Schema.optional<typeof Schema.String>;
25
+ name: Schema.optional<typeof Schema.String>;
26
+ }>>;
27
+ lastUsed: Schema.optional<typeof Schema.Number>;
28
+ createdAt: typeof Schema.Number;
29
+ updatedAt: typeof Schema.Number;
30
+ }>;
31
+ export type Passkey = typeof Passkey.Type;
32
+ export type PasskeyEncoded = typeof Passkey.Encoded;
33
+ export declare const PasskeySummary: Schema.TaggedStruct<"PasskeySummary", {
34
+ id: typeof Schema.String;
35
+ userId: typeof Schema.String;
36
+ credential: Schema.Struct<{
37
+ id: typeof Schema.String;
38
+ userId: typeof Schema.String;
39
+ }>;
40
+ enabled: typeof Schema.Boolean;
41
+ createdAt: typeof Schema.Number;
42
+ lastUsed: Schema.optional<typeof Schema.Number>;
43
+ }>;
44
+ export type PasskeySummary = typeof PasskeySummary.Type;
45
+ export declare const FindAllPasskeys: Schema.TaggedStruct<"FindAllPasskeys", {
46
+ cursor: Schema.NullOr<typeof Schema.String>;
47
+ records: Schema.Array$<Schema.TaggedStruct<"PasskeySummary", {
48
+ id: typeof Schema.String;
49
+ userId: typeof Schema.String;
50
+ credential: Schema.Struct<{
51
+ id: typeof Schema.String;
52
+ userId: typeof Schema.String;
53
+ }>;
54
+ enabled: typeof Schema.Boolean;
55
+ createdAt: typeof Schema.Number;
56
+ lastUsed: Schema.optional<typeof Schema.Number>;
57
+ }>>;
58
+ }>;
59
+ export declare const UpdatedPasskeys: Schema.TaggedStruct<"UpdatedPasskeys", {
60
+ updated: Schema.Array$<Schema.TaggedStruct<"Passkey", {
61
+ id: typeof Schema.String;
62
+ userId: Schema.optional<typeof Schema.String>;
63
+ enabled: typeof Schema.Boolean;
64
+ credential: Schema.Struct<{
65
+ id: typeof Schema.String;
66
+ userId: typeof Schema.String;
67
+ username: typeof Schema.String;
68
+ aaguid: typeof Schema.String;
69
+ backedUp: typeof Schema.Boolean;
70
+ counter: typeof Schema.Number;
71
+ deviceType: Schema.Literal<["singleDevice", "multiDevice"]>;
72
+ transports: Schema.Array$<Schema.Literal<["ble", "hybrid", "internal", "nfc", "usb", "cable", "smart-card"]>>;
73
+ publicKey: Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>;
74
+ rpId: typeof Schema.String;
75
+ }>;
76
+ platform: Schema.optional<Schema.Struct<{
77
+ icon: Schema.optional<typeof Schema.String>;
78
+ name: Schema.optional<typeof Schema.String>;
79
+ }>>;
80
+ lastUsed: Schema.optional<typeof Schema.Number>;
81
+ createdAt: typeof Schema.Number;
82
+ updatedAt: typeof Schema.Number;
83
+ }>>;
84
+ }>;
85
+ //# sourceMappingURL=passkey.d.ts.map
@@ -0,0 +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;;;;;;;;;;;;;EAG1B,CAAA;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;EAE1B,CAAA"}