@passlock/node 2.0.1 → 2.0.3

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 (64) hide show
  1. package/dist/effect.d.ts +5 -5
  2. package/dist/effect.d.ts.map +1 -1
  3. package/dist/effect.js +2 -2
  4. package/dist/effect.js.map +1 -1
  5. package/dist/errors.d.ts +71 -0
  6. package/dist/errors.d.ts.map +1 -0
  7. package/dist/errors.js +30 -0
  8. package/dist/errors.js.map +1 -0
  9. package/dist/index.d.ts +93 -34
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +87 -30
  12. package/dist/index.js.map +1 -1
  13. package/dist/network.d.ts +134 -0
  14. package/dist/network.d.ts.map +1 -0
  15. package/dist/network.js +172 -0
  16. package/dist/network.js.map +1 -0
  17. package/dist/passkey/passkey.d.ts +132 -0
  18. package/dist/passkey/passkey.d.ts.map +1 -0
  19. package/dist/passkey/passkey.js +158 -0
  20. package/dist/passkey/passkey.js.map +1 -0
  21. package/dist/principal/principal.d.ts +22 -0
  22. package/dist/principal/principal.d.ts.map +1 -0
  23. package/dist/{principal.js → principal/principal.js} +28 -27
  24. package/dist/principal/principal.js.map +1 -0
  25. package/dist/safe.d.ts +154 -0
  26. package/dist/safe.d.ts.map +1 -0
  27. package/dist/safe.js +147 -0
  28. package/dist/safe.js.map +1 -0
  29. package/dist/schemas/errors.d.ts +0 -75
  30. package/dist/schemas/errors.d.ts.map +1 -1
  31. package/dist/schemas/errors.js +51 -22
  32. package/dist/schemas/errors.js.map +1 -1
  33. package/dist/schemas/passkey.d.ts +41 -19
  34. package/dist/schemas/passkey.d.ts.map +1 -1
  35. package/dist/schemas/passkey.js +21 -16
  36. package/dist/schemas/passkey.js.map +1 -1
  37. package/dist/schemas/principal.d.ts +46 -6
  38. package/dist/schemas/principal.d.ts.map +1 -1
  39. package/dist/schemas/principal.js +6 -6
  40. package/dist/schemas/principal.js.map +1 -1
  41. package/dist/schemas/satisfy.d.ts +2 -0
  42. package/dist/schemas/satisfy.d.ts.map +1 -0
  43. package/dist/schemas/satisfy.js +2 -0
  44. package/dist/schemas/satisfy.js.map +1 -0
  45. package/dist/shared.d.ts +3 -5
  46. package/dist/shared.d.ts.map +1 -1
  47. package/dist/shared.js +0 -3
  48. package/dist/shared.js.map +1 -1
  49. package/package.json +21 -22
  50. package/dist/passkey.d.ts +0 -24
  51. package/dist/passkey.d.ts.map +0 -1
  52. package/dist/passkey.js +0 -87
  53. package/dist/passkey.js.map +0 -1
  54. package/dist/principal.d.ts +0 -18
  55. package/dist/principal.d.ts.map +0 -1
  56. package/dist/principal.js.map +0 -1
  57. package/dist/testUtils.d.ts +0 -11
  58. package/dist/testUtils.d.ts.map +0 -1
  59. package/dist/testUtils.js +0 -25
  60. package/dist/testUtils.js.map +0 -1
  61. package/dist/unsafe.d.ts +0 -55
  62. package/dist/unsafe.d.ts.map +0 -1
  63. package/dist/unsafe.js +0 -52
  64. package/dist/unsafe.js.map +0 -1
package/dist/effect.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export type { AssignUserRequest, DeleteAuthenticatorOptions, GetAuthenticatorOptions, ListPasskeyOptions, } from "./passkey.js";
2
- export type { ExchangeCodeOptions, VerifyTokenOptions } from "./principal.js";
3
- export type { AuthenticatedTenancyOptions, TenancyOptions } from "./shared.js";
4
- export { assignUser, deletePasskey, getPasskey, listPasskeys, } from "./passkey.js";
5
- export { exchangeCode, VerificationFailure, verifyIdToken } from "./principal.js";
1
+ export type { AssignUserOptions, ListPasskeyOptions, } from "./passkey/passkey.js";
2
+ export { assignUser, deletePasskey, getPasskey, listPasskeys, } from "./passkey/passkey.js";
3
+ export type {} from "./principal/principal.js";
4
+ export { exchangeCode, VerificationError, verifyIdToken, } from "./principal/principal.js";
6
5
  export * from "./schemas/index.js";
6
+ export type { AuthenticatedOptions, PasslockOptions, } from "./shared.js";
7
7
  //# sourceMappingURL=effect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,0BAA0B,EAC1B,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAC7E,YAAY,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC9E,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,GACb,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACjF,cAAc,oBAAoB,CAAA"}
1
+ {"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,GACb,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC9C,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,GACd,MAAM,0BAA0B,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,YAAY,EACV,oBAAoB,EACpB,eAAe,GAChB,MAAM,aAAa,CAAA"}
package/dist/effect.js CHANGED
@@ -1,4 +1,4 @@
1
- export { assignUser, deletePasskey, getPasskey, listPasskeys, } from "./passkey.js";
2
- export { exchangeCode, VerificationFailure, verifyIdToken } from "./principal.js";
1
+ export { assignUser, deletePasskey, getPasskey, listPasskeys, } from "./passkey/passkey.js";
2
+ export { exchangeCode, VerificationError, verifyIdToken, } from "./principal/principal.js";
3
3
  export * from "./schemas/index.js";
4
4
  //# sourceMappingURL=effect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"effect.js","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,GACb,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACjF,cAAc,oBAAoB,CAAA","sourcesContent":["export type {\n AssignUserRequest,\n DeleteAuthenticatorOptions,\n GetAuthenticatorOptions,\n ListPasskeyOptions,\n} from \"./passkey.js\"\nexport type { ExchangeCodeOptions, VerifyTokenOptions } from \"./principal.js\"\nexport type { AuthenticatedTenancyOptions, TenancyOptions } from \"./shared.js\"\nexport {\n assignUser,\n deletePasskey,\n getPasskey,\n listPasskeys,\n} from \"./passkey.js\"\nexport { exchangeCode, VerificationFailure, verifyIdToken } from \"./principal.js\"\nexport * from \"./schemas/index.js\"\n"]}
1
+ {"version":3,"file":"effect.js","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,GACb,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,GACd,MAAM,0BAA0B,CAAA;AACjC,cAAc,oBAAoB,CAAA","sourcesContent":["export type {\n AssignUserOptions,\n ListPasskeyOptions,\n} from \"./passkey/passkey.js\"\nexport {\n assignUser,\n deletePasskey,\n getPasskey,\n listPasskeys,\n} from \"./passkey/passkey.js\"\nexport type {} from \"./principal/principal.js\"\nexport {\n exchangeCode,\n VerificationError,\n verifyIdToken,\n} from \"./principal/principal.js\"\nexport * from \"./schemas/index.js\"\nexport type {\n AuthenticatedOptions,\n PasslockOptions,\n} from \"./shared.js\"\n"]}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @category Authentication
3
+ */
4
+ export type UnauthorizedError = {
5
+ _tag: "@error/Unauthorized";
6
+ message: string;
7
+ };
8
+ export declare const isUnauthorizedError: (payload: unknown) => payload is UnauthorizedError;
9
+ /**
10
+ * @category Authentication
11
+ */
12
+ export type ForbiddenError = {
13
+ _tag: "@error/Forbidden";
14
+ message: string;
15
+ };
16
+ export declare const isForbiddenError: (payload: unknown) => payload is ForbiddenError;
17
+ /**
18
+ * @category Principal
19
+ */
20
+ export type InvalidCodeError = {
21
+ _tag: "@error/InvalidCode";
22
+ message: string;
23
+ };
24
+ export declare const isInvalidCodeError: (payload: unknown) => payload is InvalidCodeError;
25
+ /**
26
+ * @category Principal
27
+ */
28
+ export type VerificationError = {
29
+ _tag: "@error/Verification";
30
+ message: string;
31
+ };
32
+ export declare const isVerificationError: (payload: unknown) => payload is VerificationError;
33
+ export type InvalidTenancyError = {
34
+ _tag: "@error/InvalidTenancy";
35
+ message: string;
36
+ };
37
+ export declare const isInvalidTenancyError: (payload: unknown) => payload is InvalidTenancyError;
38
+ /**
39
+ * Error payload returned when a passkey cannot be found for a given
40
+ * authentication attempt.
41
+ *
42
+ * @category Passkeys
43
+ */
44
+ export type PasskeyNotFoundError = {
45
+ _tag: "@error/PasskeyNotFound";
46
+ message: string;
47
+ credentialId: string;
48
+ rpId: string;
49
+ };
50
+ export declare const isPasskeyNotFoundError: (payload: unknown) => payload is PasskeyNotFoundError;
51
+ export type NotFoundError = {
52
+ _tag: "@error/NotFound";
53
+ message: string;
54
+ };
55
+ export declare const isNotFoundError: (payload: unknown) => payload is NotFoundError;
56
+ export type InvalidEmailError = {
57
+ _tag: "@error/InvalidEmail";
58
+ message: string;
59
+ };
60
+ export declare const isInvalidEmailError: (payload: unknown) => payload is InvalidEmailError;
61
+ export type DuplicateEmailError = {
62
+ _tag: "@error/DuplicateEmail";
63
+ message: string;
64
+ };
65
+ export declare const isDuplicateEmailError: (payload: unknown) => payload is DuplicateEmailError;
66
+ export type BadRequestError = {
67
+ _tag: "@error/BadRequest";
68
+ message: string;
69
+ };
70
+ export declare const isBadRequestError: (payload: unknown) => payload is BadRequestError;
71
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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AAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,iBAAiB,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,eAAe,YArGhB,OAAO,KAAG,OAAO,iBAqG4C,CAAA;AAIzE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAA;IAC3B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,mBAAmB,YA9GpB,OAAO,KAAG,OAAO,qBAgH5B,CAAA;AAID,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,uBAAuB,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,qBAAqB,YAzHtB,OAAO,KAAG,OAAO,uBA2H5B,CAAA;AAID,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,mBAAmB,CAAA;IACzB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,iBAAiB,YApIlB,OAAO,KAAG,OAAO,mBAoIkD,CAAA"}
package/dist/errors.js ADDED
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Publicly exposed errors.
3
+ * The errors we receive from the API live in the schemas/errors.ts module.
4
+ * The errors here have the same shape but they are simple types
5
+ * so are easier for non Effect consumers to handle.
6
+ */
7
+ const isTagged = (tag) => (payload) => {
8
+ if (typeof payload !== "object")
9
+ return false;
10
+ if (payload === null)
11
+ return false;
12
+ if (!("_tag" in payload))
13
+ return false;
14
+ if (typeof payload._tag !== "string")
15
+ return false;
16
+ if (payload._tag !== tag)
17
+ return false;
18
+ return true;
19
+ };
20
+ export const isUnauthorizedError = isTagged("@error/Unauthorized");
21
+ export const isForbiddenError = isTagged("@error/Forbidden");
22
+ export const isInvalidCodeError = isTagged("@error/InvalidCode");
23
+ export const isVerificationError = isTagged("@error/Verification");
24
+ export const isInvalidTenancyError = isTagged("@error/InvalidTenancy");
25
+ export const isPasskeyNotFoundError = isTagged("@error/PasskeyNotFound");
26
+ export const isNotFoundError = isTagged("@error/NotFound");
27
+ export const isInvalidEmailError = isTagged("@error/InvalidEmail");
28
+ export const isDuplicateEmailError = isTagged("@error/DuplicateEmail");
29
+ export const isBadRequestError = isTagged("@error/BadRequest");
30
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,QAAQ,GACZ,CAA6B,GAAc,EAAE,EAAE,CAC/C,CAAC,OAAgB,EAAgB,EAAE;IACjC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC7C,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAElC,IAAI,CAAC,CAAC,MAAM,IAAI,OAAO,CAAC;QAAE,OAAO,KAAK,CAAA;IACtC,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAClD,IAAI,OAAO,CAAC,IAAI,KAAK,GAAG;QAAE,OAAO,KAAK,CAAA;IAEtC,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAYH,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CACzC,qBAAqB,CACtB,CAAA;AAYD,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAiB,kBAAkB,CAAC,CAAA;AAY5E,MAAM,CAAC,MAAM,kBAAkB,GAC7B,QAAQ,CAAmB,oBAAoB,CAAC,CAAA;AAYlD,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CACzC,qBAAqB,CACtB,CAAA;AASD,MAAM,CAAC,MAAM,qBAAqB,GAAG,QAAQ,CAC3C,uBAAuB,CACxB,CAAA;AAiBD,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAC5C,wBAAwB,CACzB,CAAA;AASD,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAgB,iBAAiB,CAAC,CAAA;AASzE,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CACzC,qBAAqB,CACtB,CAAA;AASD,MAAM,CAAC,MAAM,qBAAqB,GAAG,QAAQ,CAC3C,uBAAuB,CACxB,CAAA;AASD,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAkB,mBAAmB,CAAC,CAAA","sourcesContent":["/*\n * Publicly exposed errors.\n * The errors we receive from the API live in the schemas/errors.ts module.\n * The errors here have the same shape but they are simple types\n * so are easier for non Effect consumers to handle.\n */\n\nconst isTagged =\n <A extends { _tag: string }>(tag: A[\"_tag\"]) =>\n (payload: unknown): payload is A => {\n if (typeof payload !== \"object\") return false\n if (payload === null) return false\n\n if (!(\"_tag\" in payload)) return false\n if (typeof payload._tag !== \"string\") return false\n if (payload._tag !== tag) return false\n\n return true\n }\n\n/* Unauthorized */\n\n/**\n * @category Authentication\n */\nexport type UnauthorizedError = {\n _tag: \"@error/Unauthorized\"\n message: string\n}\n\nexport const isUnauthorizedError = isTagged<UnauthorizedError>(\n \"@error/Unauthorized\"\n)\n\n/* Forbidden */\n\n/**\n * @category Authentication\n */\nexport type ForbiddenError = {\n _tag: \"@error/Forbidden\"\n message: string\n}\n\nexport const isForbiddenError = isTagged<ForbiddenError>(\"@error/Forbidden\")\n\n/* InvalidCode */\n\n/**\n * @category Principal\n */\nexport type InvalidCodeError = {\n _tag: \"@error/InvalidCode\"\n message: string\n}\n\nexport const isInvalidCodeError =\n isTagged<InvalidCodeError>(\"@error/InvalidCode\")\n\n/* VerificationFailure */\n\n/**\n * @category Principal\n */\nexport type VerificationError = {\n _tag: \"@error/Verification\"\n message: string\n}\n\nexport const isVerificationError = isTagged<VerificationError>(\n \"@error/Verification\"\n)\n\n/* InvalidTenancy */\n\nexport type InvalidTenancyError = {\n _tag: \"@error/InvalidTenancy\"\n message: string\n}\n\nexport const isInvalidTenancyError = isTagged<InvalidTenancyError>(\n \"@error/InvalidTenancy\"\n)\n\n/* PasskeyNotFound */\n\n/**\n * Error payload returned when a passkey cannot be found for a given\n * authentication attempt.\n *\n * @category Passkeys\n */\nexport type PasskeyNotFoundError = {\n _tag: \"@error/PasskeyNotFound\"\n message: string\n credentialId: string\n rpId: string\n}\n\nexport const isPasskeyNotFoundError = isTagged<PasskeyNotFoundError>(\n \"@error/PasskeyNotFound\"\n)\n\n/* NotFound */\n\nexport type NotFoundError = {\n _tag: \"@error/NotFound\"\n message: string\n}\n\nexport const isNotFoundError = isTagged<NotFoundError>(\"@error/NotFound\")\n\n/* InvalidEmail */\n\nexport type InvalidEmailError = {\n _tag: \"@error/InvalidEmail\"\n message: string\n}\n\nexport const isInvalidEmailError = isTagged<InvalidEmailError>(\n \"@error/InvalidEmail\"\n)\n\n/* DuplicateEmail */\n\nexport type DuplicateEmailError = {\n _tag: \"@error/DuplicateEmail\"\n message: string\n}\n\nexport const isDuplicateEmailError = isTagged<DuplicateEmailError>(\n \"@error/DuplicateEmail\"\n)\n\n/* BadRequest */\n\nexport type BadRequestError = {\n _tag: \"@error/BadRequest\"\n message: string\n}\n\nexport const isBadRequestError = isTagged<BadRequestError>(\"@error/BadRequest\")\n"]}
package/dist/index.d.ts CHANGED
@@ -1,56 +1,115 @@
1
- import type { AssignUserRequest, DeleteAuthenticatorOptions, GetAuthenticatorOptions, ListPasskeyOptions, Passkey } from "./passkey.js";
2
- import type { ExchangeCodeOptions, VerificationFailure, VerifyTokenOptions } from "./principal.js";
3
- import type { Forbidden, InvalidCode, NotFound } from "./schemas/errors.js";
4
- import type { DeletedPasskey, FindAllPasskeys } from "./schemas/passkey.js";
1
+ /**
2
+ * Unsafe functions that could potentially throw errors.
3
+ *
4
+ * @categoryDescription Passkeys
5
+ * Functions and related types for managing passkeys
6
+ *
7
+ * @showCategories
8
+ *
9
+ * @module unsafe
10
+ */
11
+ import type { AssignUserOptions, DeletePasskeyOptions, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey, UpdatedPasskeyUsernames, UpdatePasskeyOptions, UpdatePasskeyUsernamesOptions } from "./passkey/passkey.js";
12
+ import type { ExchangeCodeOptions, VerifyIdTokenOptions } from "./principal/principal.js";
5
13
  import type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
6
14
  /**
7
15
  * Call the Passlock backend API to assign a userId to an authenticator
16
+ *
8
17
  * @param request
18
+ * @returns A promise resolving to the updated passkey.
19
+ * @throws {@link NotFoundError} if passkey does not exist
20
+ * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
21
+ *
22
+ * @category Passkeys
23
+ */
24
+ export declare const assignUser: (request: AssignUserOptions) => Promise<Passkey>;
25
+ /**
26
+ * Call the Passlock backend API to update passkey properties
27
+ *
28
+ * @param request
29
+ * @returns A promise resolving to the updated passkey.
30
+ * @throws {@link NotFoundError} if passkey does not exist
31
+ * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
32
+ *
33
+ * @category Passkeys
34
+ */
35
+ export declare const updatePasskey: (request: UpdatePasskeyOptions) => Promise<Passkey>;
36
+ /**
37
+ * Call the Passlock backend API to update all passkeys for a given user
38
+ *
9
39
  * @param request
10
- * @returns
40
+ * @returns A promise resolving to updated usernames for matching passkeys.
41
+ * @throws {@link NotFoundError} if no passkeys are found for the given user
42
+ * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
43
+ *
44
+ * @category Passkeys
11
45
  */
12
- export declare const assignUser: (request: AssignUserRequest) => Promise<Passkey | NotFound | Forbidden>;
46
+ export declare const updatePasskeyUsernames: (request: UpdatePasskeyUsernamesOptions) => Promise<UpdatedPasskeyUsernames>;
13
47
  /**
14
48
  * Call the Passlock backend API to delete an authenticator
49
+ *
15
50
  * @param options
16
- * @param options
17
- * @returns
51
+ * @returns A promise resolving to the deleted passkey.
52
+ * @throws {@link NotFoundError} if passkey does not exist
53
+ * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
54
+ *
55
+ * @category Passkeys
18
56
  */
19
- export declare const deletePasskey: (passkeyId: string, options: DeleteAuthenticatorOptions) => Promise<DeletedPasskey | Forbidden | NotFound>;
57
+ export declare const deletePasskey: (options: DeletePasskeyOptions) => Promise<Passkey>;
20
58
  /**
21
59
  * Call the Passlock backend API to fetch an authenticator
22
- * @param request
23
- * @param request
24
- * @returns
60
+ *
61
+ * @param options
62
+ * @returns A promise resolving to the passkey.
63
+ * @throws {@link NotFoundError} if passkey does not exist
64
+ * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
65
+ *
66
+ * @category Passkeys
25
67
  */
26
- export declare const getPasskey: (authenticatorId: string, options: GetAuthenticatorOptions) => Promise<Passkey | Forbidden | NotFound>;
68
+ export declare const getPasskey: (options: GetPasskeyOptions) => Promise<Passkey>;
27
69
  /**
28
- * List passkeys for the given tenancy. Note this could return a cursor, in which case the function chould be called with the given cursor.
70
+ * List passkeys for the given tenancy. Note this could return a cursor,
71
+ * in which case the function should be called again with the given cursor.
72
+ *
29
73
  * @param options
30
- * @returns
74
+ * @returns A promise resolving to a page of passkey summaries.
75
+ * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
76
+ *
77
+ * @category Passkeys
31
78
  */
32
- export declare const listPasskeys: (options: ListPasskeyOptions) => Promise<FindAllPasskeys | Forbidden>;
79
+ export declare const listPasskeys: (options: ListPasskeyOptions) => Promise<FindAllPasskeys>;
33
80
  /**
34
- * Call the Passlock backend API to exchange a code for a Principal
35
- * @param code
36
- * @package options
37
- * @returns
81
+ * Call the Passlock backend API to exchange a code for an ExtendedPrincipal
82
+ *
83
+ * @param options
84
+ * @returns A promise resolving to an extended principal.
85
+ * @throws {@link InvalidCodeError} if the code is invalid or expired
86
+ * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
87
+ *
88
+ * @category Principal
38
89
  */
39
- export declare const exchangeCode: (code: string, options: ExchangeCodeOptions) => Promise<ExtendedPrincipal | Forbidden | InvalidCode>;
90
+ export declare const exchangeCode: (options: ExchangeCodeOptions) => Promise<ExtendedPrincipal>;
40
91
  /**
41
- * Decode and verify a Passlock idToken.
42
- * Note: This will make a network call to the passlock.dev/.well-known/jwks.json
43
- * endpoint to fetch the relevant public key. The response will be cached, however
44
- * bear in mind that for something like AWS lambda it will make the call on every
92
+ * Decode and verify a Passlock `id_token` (JWT).
93
+ * Note: This will make a network call to
94
+ * `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)
95
+ * to fetch the relevant public key. The response will be cached, however
96
+ * bear in mind that for something like AWS Lambda it will make the call on every
45
97
  * cold start so might actually be slower than {@link exchangeCode}
46
- * @param token
98
+ *
47
99
  * @param options
48
- * @returns
49
- */
50
- export declare const verifyIdToken: (token: string, options: VerifyTokenOptions) => Promise<Principal | VerificationFailure>;
51
- export type { AssignUserRequest, DeleteAuthenticatorOptions, GetAuthenticatorOptions, ListPasskeyOptions, } from "./passkey.js";
52
- export type { ExchangeCodeOptions, VerifyTokenOptions } from "./principal.js";
53
- export type { AuthenticatedTenancyOptions, TenancyOptions } from "./shared.js";
54
- export { VerificationFailure } from "./principal.js";
55
- export * from "./schemas/index.js";
100
+ * @returns A promise resolving to the verified principal.
101
+ * @throws {@link VerificationError} if token verification fails
102
+ *
103
+ * @category Principal
104
+ */
105
+ export declare const verifyIdToken: (options: VerifyIdTokenOptions) => Promise<Principal>;
106
+ export type { BadRequestError, DuplicateEmailError, ForbiddenError, InvalidCodeError, InvalidEmailError, InvalidTenancyError, NotFoundError, PasskeyNotFoundError, UnauthorizedError, VerificationError, } from "./errors.js";
107
+ export { isBadRequestError, isDuplicateEmailError, isForbiddenError, isInvalidCodeError, isInvalidEmailError, isInvalidTenancyError, isNotFoundError, isPasskeyNotFoundError, isUnauthorizedError, isVerificationError, } from "./errors.js";
108
+ export type { AssignUserOptions, Credential, DeletePasskeyOptions, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey, PasskeySummary, Platform, UpdatedPasskeys, UpdatedPasskeyUsernames, UpdatePasskeyOptions, UpdatePasskeyUsernamesOptions, } from "./passkey/passkey.js";
109
+ export { isPasskey, isPasskeySummary, isUpdatedPasskeys, isUpdatedPasskeyUsernames, } from "./passkey/passkey.js";
110
+ export type { ExchangeCodeOptions, VerifyIdTokenOptions, } from "./principal/principal.js";
111
+ export type { CredentialDeviceType, Transports, } from "./schemas/passkey.js";
112
+ export type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
113
+ export { isExtendedPrincipal, isPrincipal } from "./schemas/principal.js";
114
+ export type { AuthenticatedOptions, PasslockOptions, } from "./shared.js";
56
115
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,0BAA0B,EAC1B,uBAAuB,EACvB,kBAAkB,EAClB,OAAO,EACR,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAClG,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAW1E;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,iBAAiB,KAAG,OAAO,CAAC,OAAO,GAAG,QAAQ,GAAG,SAAS,CAK3F,CAAA;AAEH;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,WAAW,MAAM,EACjB,SAAS,0BAA0B,KAClC,OAAO,CAAC,cAAc,GAAG,SAAS,GAAG,QAAQ,CAK7C,CAAA;AAEH;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GACrB,iBAAiB,MAAM,EACvB,SAAS,uBAAuB,KAC/B,OAAO,CAAC,OAAO,GAAG,SAAS,GAAG,QA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B,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/index.js CHANGED
@@ -1,52 +1,109 @@
1
- import { FetchHttpClient } from "@effect/platform";
2
- import { Effect, identity, pipe } from "effect";
3
- import { assignUser as assignUserE, deletePasskey as deletePasskeyE, getPasskey as getPasskeyE, listPasskeys as listPasskeysE, } from "./passkey.js";
4
- import { exchangeCode as exchangeCodeE, verifyIdToken as verifyIdTokenE } from "./principal.js";
1
+ /**
2
+ * Unsafe functions that could potentially throw errors.
3
+ *
4
+ * @categoryDescription Passkeys
5
+ * Functions and related types for managing passkeys
6
+ *
7
+ * @showCategories
8
+ *
9
+ * @module unsafe
10
+ */
11
+ import { Effect, pipe } from "effect";
12
+ import { assignUser as assignUserE, deletePasskey as deletePasskeyE, getPasskey as getPasskeyE, listPasskeys as listPasskeysE, updatePasskey as updatePasskeyE, updatePasskeyUsernames as updatePasskeyUsernamesE, } from "./passkey/passkey.js";
13
+ import { exchangeCode as exchangeCodeE, verifyIdToken as verifyIdTokenE, } from "./principal/principal.js";
5
14
  /**
6
15
  * Call the Passlock backend API to assign a userId to an authenticator
16
+ *
17
+ * @param request
18
+ * @returns A promise resolving to the updated passkey.
19
+ * @throws {@link NotFoundError} if passkey does not exist
20
+ * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
21
+ *
22
+ * @category Passkeys
23
+ */
24
+ export const assignUser = (request) => pipe(assignUserE(request), Effect.runPromise);
25
+ /**
26
+ * Call the Passlock backend API to update passkey properties
27
+ *
7
28
  * @param request
29
+ * @returns A promise resolving to the updated passkey.
30
+ * @throws {@link NotFoundError} if passkey does not exist
31
+ * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
32
+ *
33
+ * @category Passkeys
34
+ */
35
+ export const updatePasskey = (request) => pipe(updatePasskeyE(request), Effect.runPromise);
36
+ /**
37
+ * Call the Passlock backend API to update all passkeys for a given user
38
+ *
8
39
  * @param request
9
- * @returns
40
+ * @returns A promise resolving to updated usernames for matching passkeys.
41
+ * @throws {@link NotFoundError} if no passkeys are found for the given user
42
+ * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
43
+ *
44
+ * @category Passkeys
10
45
  */
11
- export const assignUser = (request) => pipe(assignUserE(request), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
46
+ export const updatePasskeyUsernames = (request) => pipe(updatePasskeyUsernamesE(request), Effect.runPromise);
12
47
  /**
13
48
  * Call the Passlock backend API to delete an authenticator
49
+ *
14
50
  * @param options
15
- * @param options
16
- * @returns
51
+ * @returns A promise resolving to the deleted passkey.
52
+ * @throws {@link NotFoundError} if passkey does not exist
53
+ * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
54
+ *
55
+ * @category Passkeys
17
56
  */
18
- export const deletePasskey = (passkeyId, options) => pipe(deletePasskeyE(passkeyId, options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
57
+ export const deletePasskey = (options) => pipe(deletePasskeyE(options), Effect.runPromise);
19
58
  /**
20
59
  * Call the Passlock backend API to fetch an authenticator
21
- * @param request
22
- * @param request
23
- * @returns
60
+ *
61
+ * @param options
62
+ * @returns A promise resolving to the passkey.
63
+ * @throws {@link NotFoundError} if passkey does not exist
64
+ * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
65
+ *
66
+ * @category Passkeys
24
67
  */
25
- export const getPasskey = (authenticatorId, options) => pipe(getPasskeyE(authenticatorId, options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
68
+ export const getPasskey = (options) => pipe(getPasskeyE(options), Effect.runPromise);
26
69
  /**
27
- * List passkeys for the given tenancy. Note this could return a cursor, in which case the function chould be called with the given cursor.
70
+ * List passkeys for the given tenancy. Note this could return a cursor,
71
+ * in which case the function should be called again with the given cursor.
72
+ *
28
73
  * @param options
29
- * @returns
74
+ * @returns A promise resolving to a page of passkey summaries.
75
+ * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
76
+ *
77
+ * @category Passkeys
30
78
  */
31
- export const listPasskeys = (options) => pipe(listPasskeysE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
79
+ export const listPasskeys = (options) => pipe(listPasskeysE(options), Effect.runPromise);
32
80
  /**
33
- * Call the Passlock backend API to exchange a code for a Principal
34
- * @param code
35
- * @package options
36
- * @returns
81
+ * Call the Passlock backend API to exchange a code for an ExtendedPrincipal
82
+ *
83
+ * @param options
84
+ * @returns A promise resolving to an extended principal.
85
+ * @throws {@link InvalidCodeError} if the code is invalid or expired
86
+ * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
87
+ *
88
+ * @category Principal
37
89
  */
38
- export const exchangeCode = (code, options) => pipe(exchangeCodeE(code, options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.provide(FetchHttpClient.layer), Effect.runPromise);
90
+ export const exchangeCode = (options) => pipe(exchangeCodeE(options), Effect.runPromise);
39
91
  /**
40
- * Decode and verify a Passlock idToken.
41
- * Note: This will make a network call to the passlock.dev/.well-known/jwks.json
42
- * endpoint to fetch the relevant public key. The response will be cached, however
43
- * bear in mind that for something like AWS lambda it will make the call on every
92
+ * Decode and verify a Passlock `id_token` (JWT).
93
+ * Note: This will make a network call to
94
+ * `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)
95
+ * to fetch the relevant public key. The response will be cached, however
96
+ * bear in mind that for something like AWS Lambda it will make the call on every
44
97
  * cold start so might actually be slower than {@link exchangeCode}
45
- * @param token
98
+ *
46
99
  * @param options
47
- * @returns
100
+ * @returns A promise resolving to the verified principal.
101
+ * @throws {@link VerificationError} if token verification fails
102
+ *
103
+ * @category Principal
48
104
  */
49
- export const verifyIdToken = (token, options) => pipe(verifyIdTokenE(token, options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
50
- export { VerificationFailure } from "./principal.js";
51
- export * from "./schemas/index.js";
105
+ export const verifyIdToken = (options) => pipe(verifyIdTokenE(options), Effect.runPromise);
106
+ export { isBadRequestError, isDuplicateEmailError, isForbiddenError, isInvalidCodeError, isInvalidEmailError, isInvalidTenancyError, isNotFoundError, isPasskeyNotFoundError, isUnauthorizedError, isVerificationError, } from "./errors.js";
107
+ export { isPasskey, isPasskeySummary, isUpdatedPasskeys, isUpdatedPasskeyUsernames, } from "./passkey/passkey.js";
108
+ export { isExtendedPrincipal, isPrincipal } from "./schemas/principal.js";
52
109
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EACL,UAAU,IAAI,WAAW,EACzB,aAAa,IAAI,cAAc,EAC/B,UAAU,IAAI,WAAW,EACzB,YAAY,IAAI,aAAa,GAC9B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,YAAY,IAAI,aAAa,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAA0B,EAA2C,EAAE,CAChG,IAAI,CACF,WAAW,CAAC,OAAO,CAAC,EACpB,MAAM,CAAC,KA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;AAEH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAa,EACb,OAA2B,EACe,EAAE,CAC5C,IAAI,CACF,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,EAC9B,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAC1D,MAAM,CAAC,UAAU,CAClB,CAAA;AAUH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,cAAc,oBAAoB,CAAA","sourcesContent":["import type {\n AssignUserRequest,\n DeleteAuthenticatorOptions,\n GetAuthenticatorOptions,\n ListPasskeyOptions,\n Passkey,\n} from \"./passkey.js\"\nimport type { ExchangeCodeOptions, VerificationFailure, VerifyTokenOptions } from \"./principal.js\"\nimport type { Forbidden, InvalidCode, NotFound } from \"./schemas/errors.js\"\nimport type { DeletedPasskey, FindAllPasskeys } from \"./schemas/passkey.js\"\nimport type { ExtendedPrincipal, Principal } from \"./schemas/principal.js\"\nimport { FetchHttpClient } from \"@effect/platform\"\nimport { Effect, identity, pipe } from \"effect\"\nimport {\n assignUser as assignUserE,\n deletePasskey as deletePasskeyE,\n getPasskey as getPasskeyE,\n listPasskeys as listPasskeysE,\n} from \"./passkey.js\"\nimport { exchangeCode as exchangeCodeE, verifyIdToken as verifyIdTokenE } from \"./principal.js\"\n\n/**\n * Call the Passlock backend API to assign a userId to an authenticator\n * @param request\n * @param request\n * @returns\n */\nexport const assignUser = (request: AssignUserRequest): Promise<Passkey | NotFound | Forbidden> =>\n pipe(\n assignUserE(request),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Call the Passlock backend API to delete an authenticator\n * @param options\n * @param options\n * @returns\n */\nexport const deletePasskey = (\n passkeyId: string,\n options: DeleteAuthenticatorOptions\n): Promise<DeletedPasskey | Forbidden | NotFound> =>\n pipe(\n deletePasskeyE(passkeyId, options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Call the Passlock backend API to fetch an authenticator\n * @param request\n * @param request\n * @returns\n */\nexport const getPasskey = (\n authenticatorId: string,\n options: GetAuthenticatorOptions\n): Promise<Passkey | Forbidden | NotFound> =>\n pipe(\n getPasskeyE(authenticatorId, 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, in which case the function chould be called with the given cursor.\n * @param options\n * @returns\n */\nexport const listPasskeys = (options: ListPasskeyOptions): Promise<FindAllPasskeys | Forbidden> =>\n pipe(\n listPasskeysE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Call the Passlock backend API to exchange a code for a Principal\n * @param code\n * @package options\n * @returns\n */\nexport const exchangeCode = (\n code: string,\n options: ExchangeCodeOptions\n): Promise<ExtendedPrincipal | Forbidden | InvalidCode> =>\n pipe(\n exchangeCodeE(code, options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.provide(FetchHttpClient.layer),\n Effect.runPromise\n )\n\n/**\n * Decode and verify a Passlock idToken.\n * Note: This will make a network call to the passlock.dev/.well-known/jwks.json\n * endpoint 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 * @param token\n * @param options\n * @returns\n */\nexport const verifyIdToken = (\n token: string,\n options: VerifyTokenOptions\n): Promise<Principal | VerificationFailure> =>\n pipe(\n verifyIdTokenE(token, options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\nexport type {\n AssignUserRequest,\n DeleteAuthenticatorOptions,\n GetAuthenticatorOptions,\n ListPasskeyOptions,\n} from \"./passkey.js\"\nexport type { ExchangeCodeOptions, VerifyTokenOptions } from \"./principal.js\"\nexport type { AuthenticatedTenancyOptions, TenancyOptions } from \"./shared.js\"\nexport { VerificationFailure } from \"./principal.js\"\nexport * from \"./schemas/index.js\"\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAYrC,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;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAA0B,EAAoB,EAAE,CACzE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAE/C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAA6B,EACX,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAEvE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,OAAsC,EACJ,EAAE,CACpC,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAE3D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAA6B,EACX,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAEvE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAA0B,EAAoB,EAAE,CACzE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAE/C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAA2B,EACD,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAE9E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAA4B,EACA,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAEhF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAA6B,EACT,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAgBzE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,aAAa,CAAA;AAgBpB,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAU7B,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA","sourcesContent":["/**\n * Unsafe functions that could potentially throw errors.\n *\n * @categoryDescription Passkeys\n * Functions and related types for managing passkeys\n *\n * @showCategories\n *\n * @module unsafe\n */\n\nimport { Effect, pipe } from \"effect\"\nimport type {\n AssignUserOptions,\n DeletePasskeyOptions,\n FindAllPasskeys,\n GetPasskeyOptions,\n ListPasskeyOptions,\n Passkey,\n UpdatedPasskeyUsernames,\n UpdatePasskeyOptions,\n UpdatePasskeyUsernamesOptions,\n} from \"./passkey/passkey.js\"\nimport {\n assignUser as assignUserE,\n deletePasskey as deletePasskeyE,\n getPasskey as getPasskeyE,\n listPasskeys as listPasskeysE,\n updatePasskey as updatePasskeyE,\n updatePasskeyUsernames as updatePasskeyUsernamesE,\n} from \"./passkey/passkey.js\"\nimport type {\n ExchangeCodeOptions,\n VerifyIdTokenOptions,\n} from \"./principal/principal.js\"\nimport {\n exchangeCode as exchangeCodeE,\n verifyIdToken as verifyIdTokenE,\n} from \"./principal/principal.js\"\nimport type { ExtendedPrincipal, Principal } from \"./schemas/principal.js\"\n\n/**\n * Call the Passlock backend API to assign a userId to an authenticator\n *\n * @param request\n * @returns A promise resolving to the updated passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const assignUser = (request: AssignUserOptions): Promise<Passkey> =>\n pipe(assignUserE(request), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to update passkey properties\n *\n * @param request\n * @returns A promise resolving to the updated passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const updatePasskey = (\n request: UpdatePasskeyOptions\n): Promise<Passkey> => pipe(updatePasskeyE(request), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to update all passkeys for a given user\n *\n * @param request\n * @returns A promise resolving to updated usernames for matching passkeys.\n * @throws {@link NotFoundError} if no passkeys are found for the given user\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const updatePasskeyUsernames = (\n request: UpdatePasskeyUsernamesOptions\n): Promise<UpdatedPasskeyUsernames> =>\n pipe(updatePasskeyUsernamesE(request), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to delete an authenticator\n *\n * @param options\n * @returns A promise resolving to the deleted passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const deletePasskey = (\n options: DeletePasskeyOptions\n): Promise<Passkey> => pipe(deletePasskeyE(options), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to fetch an authenticator\n *\n * @param options\n * @returns A promise resolving to the passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const getPasskey = (options: GetPasskeyOptions): Promise<Passkey> =>\n pipe(getPasskeyE(options), Effect.runPromise)\n\n/**\n * List passkeys for the given tenancy. Note this could return a cursor,\n * in which case the function should be called again with the given cursor.\n *\n * @param options\n * @returns A promise resolving to a page of passkey summaries.\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const listPasskeys = (\n options: ListPasskeyOptions\n): Promise<FindAllPasskeys> => pipe(listPasskeysE(options), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to exchange a code for an ExtendedPrincipal\n *\n * @param options\n * @returns A promise resolving to an extended principal.\n * @throws {@link InvalidCodeError} if the code is invalid or expired\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Principal\n */\nexport const exchangeCode = (\n options: ExchangeCodeOptions\n): Promise<ExtendedPrincipal> => pipe(exchangeCodeE(options), Effect.runPromise)\n\n/**\n * Decode and verify a Passlock `id_token` (JWT).\n * Note: This will make a network call to\n * `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)\n * to fetch the relevant public key. The response will be cached, however\n * bear in mind that for something like AWS Lambda it will make the call on every\n * cold start so might actually be slower than {@link exchangeCode}\n *\n * @param options\n * @returns A promise resolving to the verified principal.\n * @throws {@link VerificationError} if token verification fails\n *\n * @category Principal\n */\nexport const verifyIdToken = (\n options: VerifyIdTokenOptions\n): Promise<Principal> => pipe(verifyIdTokenE(options), Effect.runPromise)\n\n/* Re-exports */\n\nexport type {\n BadRequestError,\n DuplicateEmailError,\n ForbiddenError,\n InvalidCodeError,\n InvalidEmailError,\n InvalidTenancyError,\n NotFoundError,\n PasskeyNotFoundError,\n UnauthorizedError,\n VerificationError,\n} from \"./errors.js\"\nexport {\n isBadRequestError,\n isDuplicateEmailError,\n isForbiddenError,\n isInvalidCodeError,\n isInvalidEmailError,\n isInvalidTenancyError,\n isNotFoundError,\n isPasskeyNotFoundError,\n isUnauthorizedError,\n isVerificationError,\n} from \"./errors.js\"\nexport type {\n AssignUserOptions,\n Credential,\n DeletePasskeyOptions,\n FindAllPasskeys,\n GetPasskeyOptions,\n ListPasskeyOptions,\n Passkey,\n PasskeySummary,\n Platform,\n UpdatedPasskeys,\n UpdatedPasskeyUsernames,\n UpdatePasskeyOptions,\n UpdatePasskeyUsernamesOptions,\n} from \"./passkey/passkey.js\"\nexport {\n isPasskey,\n isPasskeySummary,\n isUpdatedPasskeys,\n isUpdatedPasskeyUsernames,\n} from \"./passkey/passkey.js\"\nexport type {\n ExchangeCodeOptions,\n VerifyIdTokenOptions,\n} from \"./principal/principal.js\"\nexport type {\n CredentialDeviceType,\n Transports,\n} from \"./schemas/passkey.js\"\nexport type { ExtendedPrincipal, Principal } from \"./schemas/principal.js\"\nexport { isExtendedPrincipal, isPrincipal } from \"./schemas/principal.js\"\nexport type {\n AuthenticatedOptions,\n PasslockOptions,\n} from \"./shared.js\"\n"]}