@passlock/node 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +0 -1
  2. package/README.template.md +0 -1
  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/index.d.ts +54 -3
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +50 -3
  10. package/dist/index.js.map +1 -1
  11. package/dist/{passkey/effects.d.ts → passkey.d.ts} +5 -5
  12. package/dist/passkey.d.ts.map +1 -0
  13. package/dist/{passkey/effects.js → passkey.js} +4 -4
  14. package/dist/passkey.js.map +1 -0
  15. package/dist/{principal/principal.d.ts → principal.d.ts} +3 -3
  16. package/dist/principal.d.ts.map +1 -0
  17. package/dist/{principal/principal.js → principal.js} +2 -2
  18. package/dist/principal.js.map +1 -0
  19. package/dist/schemas/errors.d.ts +9 -0
  20. package/dist/schemas/errors.d.ts.map +1 -1
  21. package/dist/schemas/errors.js +9 -0
  22. package/dist/schemas/errors.js.map +1 -1
  23. package/dist/unsafe.d.ts +55 -0
  24. package/dist/unsafe.d.ts.map +1 -0
  25. package/dist/unsafe.js +52 -0
  26. package/dist/unsafe.js.map +1 -0
  27. package/package.json +22 -19
  28. package/dist/effects/index.d.ts +0 -5
  29. package/dist/effects/index.d.ts.map +0 -1
  30. package/dist/effects/index.js +0 -5
  31. package/dist/effects/index.js.map +0 -1
  32. package/dist/passkey/effects.d.ts.map +0 -1
  33. package/dist/passkey/effects.js.map +0 -1
  34. package/dist/passkey/index.d.ts +0 -64
  35. package/dist/passkey/index.d.ts.map +0 -1
  36. package/dist/passkey/index.js +0 -58
  37. package/dist/passkey/index.js.map +0 -1
  38. package/dist/principal/index.d.ts +0 -43
  39. package/dist/principal/index.d.ts.map +0 -1
  40. package/dist/principal/index.js +0 -41
  41. package/dist/principal/index.js.map +0 -1
  42. package/dist/principal/principal.d.ts.map +0 -1
  43. package/dist/principal/principal.js.map +0 -1
package/README.md CHANGED
@@ -42,5 +42,4 @@ Node 22+
42
42
 
43
43
  Please see the [Quick start guide](https://passlock.dev/getting-started/)
44
44
 
45
- [contact]: https://passlock.dev/contact
46
45
  [client]: https://www.npmjs.com/package/@passlock/client
@@ -42,5 +42,4 @@ Node 22+
42
42
 
43
43
  Please see the [Quick start guide](#{TUTORIAL}#)
44
44
 
45
- [contact]: https://passlock.dev/contact
46
45
  [client]: https://www.npmjs.com/package/@passlock/client
@@ -0,0 +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";
6
+ export * from "./schemas/index.js";
7
+ //# sourceMappingURL=effect.d.ts.map
@@ -0,0 +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"}
package/dist/effect.js ADDED
@@ -0,0 +1,4 @@
1
+ export { assignUser, deletePasskey, getPasskey, listPasskeys, } from "./passkey.js";
2
+ export { exchangeCode, VerificationFailure, verifyIdToken } from "./principal.js";
3
+ export * from "./schemas/index.js";
4
+ //# sourceMappingURL=effect.js.map
@@ -0,0 +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"]}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,56 @@
1
- export * from "./passkey/index.js";
2
- export * from "./principal/index.js";
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";
5
+ import type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
6
+ /**
7
+ * Call the Passlock backend API to assign a userId to an authenticator
8
+ * @param request
9
+ * @param request
10
+ * @returns
11
+ */
12
+ export declare const assignUser: (request: AssignUserRequest) => Promise<Passkey | NotFound | Forbidden>;
13
+ /**
14
+ * Call the Passlock backend API to delete an authenticator
15
+ * @param options
16
+ * @param options
17
+ * @returns
18
+ */
19
+ export declare const deletePasskey: (passkeyId: string, options: DeleteAuthenticatorOptions) => Promise<DeletedPasskey | Forbidden | NotFound>;
20
+ /**
21
+ * Call the Passlock backend API to fetch an authenticator
22
+ * @param request
23
+ * @param request
24
+ * @returns
25
+ */
26
+ export declare const getPasskey: (authenticatorId: string, options: GetAuthenticatorOptions) => Promise<Passkey | Forbidden | NotFound>;
27
+ /**
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.
29
+ * @param options
30
+ * @returns
31
+ */
32
+ export declare const listPasskeys: (options: ListPasskeyOptions) => Promise<FindAllPasskeys | Forbidden>;
33
+ /**
34
+ * Call the Passlock backend API to exchange a code for a Principal
35
+ * @param code
36
+ * @package options
37
+ * @returns
38
+ */
39
+ export declare const exchangeCode: (code: string, options: ExchangeCodeOptions) => Promise<ExtendedPrincipal | Forbidden | InvalidCode>;
40
+ /**
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
45
+ * cold start so might actually be slower than {@link exchangeCode}
46
+ * @param token
47
+ * @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";
3
55
  export * from "./schemas/index.js";
4
- export * from "./shared.js";
5
56
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.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B,GAAG,SAAS,GAAG,WAAW,CAMnD,CAAA;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,MAAM,EACb,SAAS,kBAAkB,KAC1B,OAAO,CAAC,SAAS,GAAG,mBAAmB,CAKvC,CAAA;AAEH,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,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,cAAc,oBAAoB,CAAA"}
package/dist/index.js CHANGED
@@ -1,5 +1,52 @@
1
- export * from "./passkey/index.js";
2
- export * from "./principal/index.js";
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";
5
+ /**
6
+ * Call the Passlock backend API to assign a userId to an authenticator
7
+ * @param request
8
+ * @param request
9
+ * @returns
10
+ */
11
+ export const assignUser = (request) => pipe(assignUserE(request), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
12
+ /**
13
+ * Call the Passlock backend API to delete an authenticator
14
+ * @param options
15
+ * @param options
16
+ * @returns
17
+ */
18
+ export const deletePasskey = (passkeyId, options) => pipe(deletePasskeyE(passkeyId, options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
19
+ /**
20
+ * Call the Passlock backend API to fetch an authenticator
21
+ * @param request
22
+ * @param request
23
+ * @returns
24
+ */
25
+ export const getPasskey = (authenticatorId, options) => pipe(getPasskeyE(authenticatorId, options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
26
+ /**
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.
28
+ * @param options
29
+ * @returns
30
+ */
31
+ export const listPasskeys = (options) => pipe(listPasskeysE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
32
+ /**
33
+ * Call the Passlock backend API to exchange a code for a Principal
34
+ * @param code
35
+ * @package options
36
+ * @returns
37
+ */
38
+ export const exchangeCode = (code, options) => pipe(exchangeCodeE(code, options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.provide(FetchHttpClient.layer), Effect.runPromise);
39
+ /**
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
44
+ * cold start so might actually be slower than {@link exchangeCode}
45
+ * @param token
46
+ * @param options
47
+ * @returns
48
+ */
49
+ export const verifyIdToken = (token, options) => pipe(verifyIdTokenE(token, options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
50
+ export { VerificationFailure } from "./principal.js";
3
51
  export * from "./schemas/index.js";
4
- export * from "./shared.js";
5
52
  //# 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":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA","sourcesContent":["export * from \"./passkey/index.js\"\nexport * from \"./principal/index.js\"\nexport * from \"./schemas/index.js\"\nexport * from \"./shared.js\"\n"]}
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,EA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SAAS,EAAE,QAAQ,EAAE,CAAC,EAC1D,MAAM,CAAC,UAAU,CAClB,CAAA;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,IAAY,EACZ,OAA4B,EAC0B,EAAE,CACxD,IAAI,CACF,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,EAC5B,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAC1D,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EACrC,MAAM,CAAC,UAAU,CAClB,CAAA;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,9 +1,9 @@
1
- import type { AuthenticatedTenancyOptions } from "../shared.js";
1
+ import type { AuthenticatedTenancyOptions } from "./shared.js";
2
2
  import { HttpClient } from "@effect/platform";
3
3
  import { Effect, type Layer, Stream } from "effect";
4
- import { Forbidden, NotFound } from "../schemas/errors.js";
5
- import { FindAllPasskeys } from "../schemas/index.js";
6
- import { DeletedPasskey, Passkey, type PasskeySummary } from "../schemas/passkey.js";
4
+ import { Forbidden, NotFound } from "./schemas/errors.js";
5
+ import { FindAllPasskeys } from "./schemas/index.js";
6
+ import { DeletedPasskey, Passkey, type PasskeySummary } from "./schemas/passkey.js";
7
7
  export type GetPasskeyOptions = AuthenticatedTenancyOptions;
8
8
  export declare const getPasskey: (authenticatorId: string, options: GetPasskeyOptions, httpClient?: Layer.Layer<HttpClient.HttpClient>) => Effect.Effect<Passkey, NotFound | Forbidden>;
9
9
  export type { GetPasskeyOptions as GetAuthenticatorOptions, Passkey };
@@ -21,4 +21,4 @@ export interface ListPasskeyOptions extends AuthenticatedTenancyOptions {
21
21
  }
22
22
  export declare const listPasskeysStream: (options: AuthenticatedTenancyOptions, httpClient?: Layer.Layer<HttpClient.HttpClient>) => Stream.Stream<PasskeySummary, Forbidden>;
23
23
  export declare const listPasskeys: (options: ListPasskeyOptions, httpClient?: Layer.Layer<HttpClient.HttpClient>) => Effect.Effect<FindAllPasskeys, Forbidden>;
24
- //# sourceMappingURL=effects.d.ts.map
24
+ //# sourceMappingURL=passkey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passkey.d.ts","sourceRoot":"","sources":["../src/passkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EAEL,UAAU,EAGX,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAS,MAAM,EAAE,KAAK,KAAK,EAA+B,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAInF,MAAM,MAAM,iBAAiB,GAAG,2BAA2B,CAAA;AAE3D,eAAO,MAAM,UAAU,GACrB,iBAAiB,MAAM,EACvB,SAAS,iBAAiB,EAC1B,aAAY,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAyB,KACrE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,SAAS,CAiC3C,CAAA;AAEH,YAAY,EAAE,iBAAiB,IAAI,uBAAuB,EAAE,OAAO,EAAE,CAAA;AAIrE,KAAK,0BAA0B,GAAG,2BAA2B,CAAA;AAE7D,eAAO,MAAM,aAAa,GACxB,WAAW,MAAM,EACjB,SAAS,0BAA0B,EACnC,aAAY,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAyB,KACrE,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,QAAQ,GAAG,SAAS,CAiClD,CAAA;AAEH,YAAY,EAAE,0BAA0B,EAAE,CAAA;AAI1C,UAAU,iBAAkB,SAAQ,2BAA2B;IAC7D,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,eAAO,MAAM,UAAU,GACrB,SAAS,iBAAiB,EAC1B,aAAY,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAyB,KACrE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,GAAG,SAAS,CAmC3C,CAAA;AAEH,YAAY,EAAE,iBAAiB,EAAE,CAAA;AAIjC,MAAM,WAAW,kBAAmB,SAAQ,2BAA2B;IACrE,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,eAAO,MAAM,kBAAkB,GAC7B,SAAS,2BAA2B,EACpC,aAAY,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAyB,KACrE,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,SAAS,CAWvC,CAAA;AAEH,eAAO,MAAM,YAAY,GACvB,SAAS,kBAAkB,EAC3B,aAAY,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAyB,KACrE,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,CAkCxC,CAAA"}
@@ -1,8 +1,8 @@
1
1
  import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse, } from "@effect/platform";
2
2
  import { Chunk, Effect, Match, Option, pipe, Schema, Stream } from "effect";
3
- import { Forbidden, NotFound } from "../schemas/errors.js";
4
- import { FindAllPasskeys } from "../schemas/index.js";
5
- import { DeletedPasskey, Passkey } from "../schemas/passkey.js";
3
+ import { Forbidden, NotFound } from "./schemas/errors.js";
4
+ import { FindAllPasskeys } from "./schemas/index.js";
5
+ import { DeletedPasskey, Passkey } from "./schemas/passkey.js";
6
6
  export const getPasskey = (authenticatorId, options, httpClient = FetchHttpClient.layer) => pipe(Effect.gen(function* () {
7
7
  const client = yield* HttpClient.HttpClient;
8
8
  const baseUrl = options.endpoint ?? "https://api.passlock.dev";
@@ -84,4 +84,4 @@ export const listPasskeys = (options, httpClient = FetchHttpClient.layer) => pip
84
84
  RequestError: (err) => Effect.die(err),
85
85
  ResponseError: (err) => Effect.die(err),
86
86
  }), Effect.provide(httpClient));
87
- //# sourceMappingURL=effects.js.map
87
+ //# sourceMappingURL=passkey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passkey.js","sourceRoot":"","sources":["../src/passkey.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAc,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAuB,MAAM,sBAAsB,CAAA;AAMnF,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,eAAuB,EACvB,OAA0B,EAC1B,aAAiD,eAAe,CAAC,KAAK,EACxB,EAAE,CAChD,IAAI,CACF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAA;IAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,IAAI,0BAA0B,CAAA;IAC9D,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;IAE7B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,SAAS,aAAa,eAAe,EAAE,EAAE,OAAO,CAAC,CAAA;IAEzE,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE;QACjD,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,OAAO,CAAC,MAAM,EAAE,EAAE;KACvD,CAAC,CA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pClient,\n HttpClient,\n HttpClientRequest,\n HttpClientResponse,\n} from \"@effect/platform\"\nimport { Chunk, Effect, type Layer, Match, Option, pipe, Schema, Stream } from \"effect\"\nimport { Forbidden, NotFound } from \"./schemas/errors.js\"\nimport { FindAllPasskeys } from \"./schemas/index.js\"\nimport { DeletedPasskey, Passkey, type PasskeySummary } from \"./schemas/passkey.js\"\n\n/* Get Passkey */\n\nexport type GetPasskeyOptions = AuthenticatedTenancyOptions\n\nexport const getPasskey = (\n authenticatorId: string,\n options: GetPasskeyOptions,\n httpClient: Layer.Layer<HttpClient.HttpClient> = FetchHttpClient.layer\n): Effect.Effect<Passkey, NotFound | Forbidden> =>\n pipe(\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient\n const baseUrl = options.endpoint ?? \"https://api.passlock.dev\"\n const { tenancyId } = options\n\n const url = new URL(`/${tenancyId}/passkeys/${authenticatorId}`, baseUrl)\n\n const response = yield* HttpClientRequest.get(url, {\n headers: { Authorization: `Bearer ${options.apiKey}` },\n }).pipe(client.execute)\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () => HttpClientResponse.schemaBodyJson(Passkey)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(Schema.Union(Forbidden, NotFound))(response),\n })\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"Passkey\", (data) => Effect.succeed(data)),\n Match.tag(\"@error/Forbidden\", (err) => Effect.fail(err)),\n Match.tag(\"@error/NotFound\", (err) => Effect.fail(err)),\n Match.exhaustive\n )\n }),\n Effect.catchTags({\n ParseError: (err) => Effect.die(err),\n RequestError: (err) => Effect.die(err),\n ResponseError: (err) => Effect.die(err),\n }),\n Effect.provide(httpClient)\n )\n\nexport type { GetPasskeyOptions as GetAuthenticatorOptions, Passkey }\n\n/* Delete Passkey */\n\ntype DeleteAuthenticatorOptions = AuthenticatedTenancyOptions\n\nexport const deletePasskey = (\n passkeyId: string,\n request: DeleteAuthenticatorOptions,\n httpClient: Layer.Layer<HttpClient.HttpClient> = FetchHttpClient.layer\n): Effect.Effect<DeletedPasskey, NotFound | Forbidden> =>\n pipe(\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient\n const baseUrl = request.endpoint ?? \"https://api.passlock.dev\"\n const { tenancyId } = request\n\n const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl)\n\n const response = yield* HttpClientRequest.del(url, {\n headers: { Authorization: `Bearer ${request.apiKey}` },\n }).pipe(client.execute)\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () => HttpClientResponse.schemaBodyJson(DeletedPasskey)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(Schema.Union(Forbidden, NotFound))(response),\n })\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"DeletedPasskey\", (deletedPasskey) => Effect.succeed(deletedPasskey)),\n Match.tag(\"@error/Forbidden\", (err) => Effect.fail(err)),\n Match.tag(\"@error/NotFound\", (err) => Effect.fail(err)),\n Match.exhaustive\n )\n }),\n Effect.catchTags({\n ParseError: (err) => Effect.die(err),\n RequestError: (err) => Effect.die(err),\n ResponseError: (err) => Effect.die(err),\n }),\n Effect.provide(httpClient)\n )\n\nexport type { DeleteAuthenticatorOptions }\n\n/* Assign User */\n\ninterface AssignUserRequest extends AuthenticatedTenancyOptions {\n userId: string\n passkeyId: string\n}\n\nexport const assignUser = (\n request: AssignUserRequest,\n httpClient: Layer.Layer<HttpClient.HttpClient> = FetchHttpClient.layer\n): Effect.Effect<Passkey, NotFound | Forbidden> =>\n pipe(\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient\n const baseUrl = request.endpoint ?? \"https://api.passlock.dev\"\n const { userId, passkeyId } = request\n const { tenancyId } = request\n\n const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl)\n\n const response = yield* HttpClientRequest.patch(url, {\n headers: { Authorization: `Bearer ${request.apiKey}` },\n }).pipe(HttpClientRequest.bodyJson({ userId }), Effect.flatMap(client.execute))\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () => HttpClientResponse.schemaBodyJson(Passkey)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(Schema.Union(NotFound, Forbidden))(response),\n })\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"Passkey\", (passkey) => Effect.succeed(passkey)),\n Match.tag(\"@error/NotFound\", (err) => Effect.fail(err)),\n Match.tag(\"@error/Forbidden\", (err) => Effect.fail(err)),\n Match.exhaustive\n )\n }),\n Effect.catchTags({\n HttpBodyError: (err) => Effect.die(err),\n ParseError: (err) => Effect.die(err),\n RequestError: (err) => Effect.die(err),\n ResponseError: (err) => Effect.die(err),\n }),\n Effect.provide(httpClient)\n )\n\nexport type { AssignUserRequest }\n\n/* List Passkeys */\n\nexport interface ListPasskeyOptions extends AuthenticatedTenancyOptions {\n cursor?: string\n}\n\nexport const listPasskeysStream = (\n options: AuthenticatedTenancyOptions,\n httpClient: Layer.Layer<HttpClient.HttpClient> = FetchHttpClient.layer\n): Stream.Stream<PasskeySummary, Forbidden> =>\n pipe(\n Stream.paginateChunkEffect(null as string | null, (cursor) =>\n pipe(\n listPasskeys(cursor ? { ...options, cursor } : options, httpClient),\n Effect.map((result) => [\n Chunk.fromIterable(result.records),\n Option.fromNullable(result.cursor),\n ])\n )\n )\n )\n\nexport const listPasskeys = (\n options: ListPasskeyOptions,\n httpClient: Layer.Layer<HttpClient.HttpClient> = FetchHttpClient.layer\n): Effect.Effect<FindAllPasskeys, Forbidden> =>\n pipe(\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient\n const baseUrl = options.endpoint ?? \"https://api.passlock.dev\"\n const { tenancyId } = options\n\n const url = new URL(`/${tenancyId}/passkeys/`, baseUrl)\n if (options.cursor) {\n url.searchParams.append(\"cursor\", options.cursor)\n }\n\n const response = yield* HttpClientRequest.get(url, {\n headers: { Authorization: `Bearer ${options.apiKey}` },\n }).pipe(client.execute)\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () => HttpClientResponse.schemaBodyJson(FindAllPasskeys)(response),\n orElse: () => HttpClientResponse.schemaBodyJson(Forbidden)(response),\n })\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"FindAllPasskeys\", (data) => Effect.succeed(data)),\n Match.tag(\"@error/Forbidden\", (err) => Effect.fail(err)),\n Match.exhaustive\n )\n }),\n Effect.catchTags({\n ParseError: (err) => Effect.die(err),\n RequestError: (err) => Effect.die(err),\n ResponseError: (err) => Effect.die(err),\n }),\n Effect.provide(httpClient)\n )\n"]}
@@ -1,8 +1,8 @@
1
- import type { AuthenticatedTenancyOptions, TenancyOptions } from "../shared.js";
1
+ import type { AuthenticatedTenancyOptions, TenancyOptions } from "./shared.js";
2
2
  import { HttpClient } from "@effect/platform";
3
3
  import { Effect, type Layer } from "effect";
4
- import { Forbidden, InvalidCode } from "../schemas/errors.js";
5
- import { ExtendedPrincipal, type Principal } from "../schemas/principal.js";
4
+ import { Forbidden, InvalidCode } from "./schemas/errors.js";
5
+ import { ExtendedPrincipal, type Principal } from "./schemas/principal.js";
6
6
  type ExchangeCodeOptions = AuthenticatedTenancyOptions;
7
7
  export declare const exchangeCode: (code: string, options: ExchangeCodeOptions, httpClient?: Layer.Layer<HttpClient.HttpClient>) => Effect.Effect<ExtendedPrincipal, InvalidCode | Forbidden>;
8
8
  type VerifyTokenOptions = TenancyOptions;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"principal.d.ts","sourceRoot":"","sources":["../src/principal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC9E,OAAO,EAAmB,UAAU,EAAsB,MAAM,kBAAkB,CAAA;AAClF,OAAO,EAAQ,MAAM,EAAE,KAAK,KAAK,EAAuB,MAAM,QAAQ,CAAA;AAEtE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAW,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAEnF,KAAK,mBAAmB,GAAG,2BAA2B,CAAA;AAEtD,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,EACZ,SAAS,mBAAmB,EAC5B,aAAY,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAyB,KACrE,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,WAAW,GAAG,SAAS,CAmCxD,CAAA;AAEH,KAAK,kBAAkB,GAAG,cAAc,CAAA;;;;AAWxC,qBAAa,mBAAoB,SAAQ,yBAA+C;IACtF,OAAO,EAAE,MAAM,CAAA;CAChB,CAAC;CAAG;AAEL,eAAO,MAAM,aAAa,GACxB,OAAO,MAAM,EACb,SAAS,kBAAkB,KAC1B,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,mBAAmB,CAyC5C,CAAA;AAEH,YAAY,EAAE,mBAAmB,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAA"}
@@ -1,8 +1,8 @@
1
1
  import { FetchHttpClient, HttpClient, HttpClientResponse } from "@effect/platform";
2
2
  import { Data, Effect, Match, pipe, Schema } from "effect";
3
3
  import * as jose from "jose";
4
- import { Forbidden, InvalidCode } from "../schemas/errors.js";
5
- import { ExtendedPrincipal, IdToken } from "../schemas/principal.js";
4
+ import { Forbidden, InvalidCode } from "./schemas/errors.js";
5
+ import { ExtendedPrincipal, IdToken } from "./schemas/principal.js";
6
6
  export const exchangeCode = (code, options, httpClient = FetchHttpClient.layer) => pipe(Effect.gen(function* () {
7
7
  const client = yield* HttpClient.HttpClient;
8
8
  const baseUrl = options.endpoint ?? "https://api.passlock.dev";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"principal.js","sourceRoot":"","sources":["../src/principal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAClF,OAAO,EAAE,IAAI,EAAE,MAAM,EAAc,K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E,OAAO,CAAC,OAAO,CAAC;YAC9B,QAAQ,EAAE,IAAI;SACf;QACD,MAAM,EAAE,OAAO,CAAC,GAAG;KACpB,CAAA;IAED,OAAO,SAAS,CAAA;AAClB,CAAC,CAAC,EACF,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CACxD,CAAA","sourcesContent":["import type { AuthenticatedTenancyOptions, TenancyOptions } from \"./shared.js\"\nimport { FetchHttpClient, HttpClient, HttpClientResponse } from \"@effect/platform\"\nimport { Data, Effect, type Layer, Match, pipe, Schema } from \"effect\"\nimport * as jose from \"jose\"\nimport { Forbidden, InvalidCode } from \"./schemas/errors.js\"\nimport { ExtendedPrincipal, IdToken, type Principal } from \"./schemas/principal.js\"\n\ntype ExchangeCodeOptions = AuthenticatedTenancyOptions\n\nexport const exchangeCode = (\n code: string,\n options: ExchangeCodeOptions,\n httpClient: Layer.Layer<HttpClient.HttpClient> = FetchHttpClient.layer\n): Effect.Effect<ExtendedPrincipal, InvalidCode | Forbidden> =>\n pipe(\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient\n const baseUrl = options.endpoint ?? \"https://api.passlock.dev\"\n const { tenancyId } = options\n\n const url = new URL(`/${tenancyId}/principal/${code}`, baseUrl)\n\n const response = yield* pipe(\n client.get(url, {\n headers: { Authorization: `Bearer ${options.apiKey}` },\n })\n )\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () => HttpClientResponse.schemaBodyJson(ExtendedPrincipal)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(Schema.Union(InvalidCode, Forbidden))(response),\n })\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"ExtendedPrincipal\", (principal) => Effect.succeed(principal)),\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 ParseError: (err) => Effect.die(err),\n RequestError: (err) => Effect.die(err),\n ResponseError: (err) => Effect.die(err),\n }),\n Effect.provide(httpClient)\n )\n\ntype VerifyTokenOptions = TenancyOptions\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(Effect.cachedFunction(createJwks), Effect.runSync)\n\nexport class VerificationFailure extends Data.TaggedError(\"@error/VerificationFailure\")<{\n message: string\n}> {}\n\nexport const verifyIdToken = (\n token: string,\n options: VerifyTokenOptions\n): Effect.Effect<Principal, VerificationFailure> =>\n pipe(\n Effect.gen(function* () {\n const JWKS = yield* createCachedRemoteJwks(options.endpoint)\n\n const { payload } = yield* Effect.tryPromise({\n catch: (err) => {\n console.error(err)\n return err instanceof Error\n ? new VerificationFailure({ message: err.message })\n : new VerificationFailure({ message: String(err) })\n },\n try: () =>\n jose.jwtVerify(token, JWKS, {\n audience: options.tenancyId,\n issuer: \"passlock.dev\",\n }),\n })\n\n const idToken = yield* Schema.decodeUnknown(IdToken)({\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\nexport type { ExchangeCodeOptions, Principal, VerifyTokenOptions }\n"]}
@@ -4,11 +4,13 @@ declare const Unauthorized_base: Schema.TaggedErrorClass<Unauthorized, "@error/U
4
4
  }>;
5
5
  export declare class Unauthorized extends Unauthorized_base {
6
6
  }
7
+ export declare const isUnauthorized: (payload: unknown) => payload is Unauthorized;
7
8
  declare const Forbidden_base: Schema.TaggedErrorClass<Forbidden, "@error/Forbidden", {
8
9
  readonly _tag: Schema.tag<"@error/Forbidden">;
9
10
  }>;
10
11
  export declare class Forbidden extends Forbidden_base {
11
12
  }
13
+ export declare const isForbidden: (payload: unknown) => payload is Forbidden;
12
14
  declare const InvalidCode_base: Schema.TaggedErrorClass<InvalidCode, "@error/InvalidCode", {
13
15
  readonly _tag: Schema.tag<"@error/InvalidCode">;
14
16
  } & {
@@ -16,6 +18,7 @@ declare const InvalidCode_base: Schema.TaggedErrorClass<InvalidCode, "@error/Inv
16
18
  }>;
17
19
  export declare class InvalidCode extends InvalidCode_base {
18
20
  }
21
+ export declare const isInvalidCode: (payload: unknown) => payload is InvalidCode;
19
22
  declare const InvalidTenancy_base: Schema.TaggedErrorClass<InvalidTenancy, "@error/InvalidTenancy", {
20
23
  readonly _tag: Schema.tag<"@error/InvalidTenancy">;
21
24
  } & {
@@ -23,6 +26,7 @@ declare const InvalidTenancy_base: Schema.TaggedErrorClass<InvalidTenancy, "@err
23
26
  }>;
24
27
  export declare class InvalidTenancy extends InvalidTenancy_base {
25
28
  }
29
+ export declare const isInvalidTenancy: (payload: unknown) => payload is InvalidTenancy;
26
30
  declare const PasskeyNotFound_base: Schema.TaggedErrorClass<PasskeyNotFound, "@error/PasskeyNotFound", {
27
31
  readonly _tag: Schema.tag<"@error/PasskeyNotFound">;
28
32
  } & {
@@ -36,6 +40,7 @@ declare const PasskeyNotFound_base: Schema.TaggedErrorClass<PasskeyNotFound, "@e
36
40
  */
37
41
  export declare class PasskeyNotFound extends PasskeyNotFound_base {
38
42
  }
43
+ export declare const isPasskeyNotFound: (payload: unknown) => payload is PasskeyNotFound;
39
44
  declare const NotFound_base: Schema.TaggedErrorClass<NotFound, "@error/NotFound", {
40
45
  readonly _tag: Schema.tag<"@error/NotFound">;
41
46
  } & {
@@ -43,6 +48,7 @@ declare const NotFound_base: Schema.TaggedErrorClass<NotFound, "@error/NotFound"
43
48
  }>;
44
49
  export declare class NotFound extends NotFound_base {
45
50
  }
51
+ export declare const isNotFound: (payload: unknown) => payload is NotFound;
46
52
  declare const InvalidEmail_base: Schema.TaggedErrorClass<InvalidEmail, "@error/InvalidEmail", {
47
53
  readonly _tag: Schema.tag<"@error/InvalidEmail">;
48
54
  } & {
@@ -50,6 +56,7 @@ declare const InvalidEmail_base: Schema.TaggedErrorClass<InvalidEmail, "@error/I
50
56
  }>;
51
57
  export declare class InvalidEmail extends InvalidEmail_base {
52
58
  }
59
+ export declare const isInvalidEmail: (payload: unknown) => payload is InvalidEmail;
53
60
  declare const DuplicateEmail_base: Schema.TaggedErrorClass<DuplicateEmail, "@error/DuplicateEmail", {
54
61
  readonly _tag: Schema.tag<"@error/DuplicateEmail">;
55
62
  } & {
@@ -57,6 +64,7 @@ declare const DuplicateEmail_base: Schema.TaggedErrorClass<DuplicateEmail, "@err
57
64
  }>;
58
65
  export declare class DuplicateEmail extends DuplicateEmail_base {
59
66
  }
67
+ export declare const isDuplicateEmail: (payload: unknown) => payload is DuplicateEmail;
60
68
  declare const BadRequest_base: Schema.TaggedErrorClass<BadRequest, "@error/BadRequest", {
61
69
  readonly _tag: Schema.tag<"@error/BadRequest">;
62
70
  } & {
@@ -64,5 +72,6 @@ declare const BadRequest_base: Schema.TaggedErrorClass<BadRequest, "@error/BadRe
64
72
  }>;
65
73
  export declare class BadRequest extends BadRequest_base {
66
74
  }
75
+ export declare const isBadRequest: (payload: unknown) => payload is BadRequest;
67
76
  export {};
68
77
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/schemas/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;;;;AAE/B,qBAAa,YAAa,SAAQ,iBAA6D;CAAG;;;;AAElG,qBAAa,SAAU,SAAQ,cAAuD;CAAG;;;;;;AAEzF,qBAAa,WAAY,SAAQ,gB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J,eAAO,MAAM,cAAc,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,YAC3B,CAAA;;;;;;AAElC,qBAAa,cAAe,SAAQ,mBAGnC;CAAG;AAEJ,eAAO,MAAM,gBAAgB,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,cAC3B,CAAA;;;;;;AAEpC,qBAAa,UAAW,SAAQ,eAG/B;CAAG;AAEJ,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,UAC3B,CAAA"}
@@ -1,16 +1,20 @@
1
1
  import { Schema } from "effect";
2
2
  export class Unauthorized extends Schema.TaggedError()("@error/Unauthorized", {}) {
3
3
  }
4
+ export const isUnauthorized = (payload) => Schema.is(Unauthorized)(payload);
4
5
  export class Forbidden extends Schema.TaggedError()("@error/Forbidden", {}) {
5
6
  }
7
+ export const isForbidden = (payload) => Schema.is(Forbidden)(payload);
6
8
  export class InvalidCode extends Schema.TaggedError("@error/InvalidCode")("@error/InvalidCode", {
7
9
  message: Schema.String,
8
10
  }) {
9
11
  }
12
+ export const isInvalidCode = (payload) => Schema.is(InvalidCode)(payload);
10
13
  export class InvalidTenancy extends Schema.TaggedError()("@error/InvalidTenancy", {
11
14
  message: Schema.String,
12
15
  }) {
13
16
  }
17
+ export const isInvalidTenancy = (payload) => Schema.is(InvalidTenancy)(payload);
14
18
  /**
15
19
  * We need the credentialId and rpId to feed into the
16
20
  * client's signalCredentialRemoval function
@@ -21,14 +25,19 @@ export class PasskeyNotFound extends Schema.TaggedError("@error/PasskeyNotFound"
21
25
  rpId: Schema.String,
22
26
  }) {
23
27
  }
28
+ export const isPasskeyNotFound = (payload) => Schema.is(PasskeyNotFound)(payload);
24
29
  export class NotFound extends Schema.TaggedError("@error/NotFound")("@error/NotFound", {
25
30
  message: Schema.String,
26
31
  }) {
27
32
  }
33
+ export const isNotFound = (payload) => Schema.is(NotFound)(payload);
28
34
  export class InvalidEmail extends Schema.TaggedError("@error/InvalidEmail")("@error/InvalidEmail", { message: Schema.String }) {
29
35
  }
36
+ export const isInvalidEmail = (payload) => Schema.is(InvalidEmail)(payload);
30
37
  export class DuplicateEmail extends Schema.TaggedError("@error/DuplicateEmail")("@error/DuplicateEmail", { message: Schema.String }) {
31
38
  }
39
+ export const isDuplicateEmail = (payload) => Schema.is(DuplicateEmail)(payload);
32
40
  export class BadRequest extends Schema.TaggedError("@error/BadRequest")("@error/BadRequest", { message: Schema.String }) {
33
41
  }
42
+ export const isBadRequest = (payload) => Schema.is(BadRequest)(payload);
34
43
  //# sourceMappingURL=errors.js.map
@@ -1 +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,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,EAAgB,CAAC,qBAAqB,EAAE,EAAE,CAAC;CAAG;AAElG,MAAM,OAAO,SAAU,SAAQ,MAAM,CAAC,WAAW,EAAa,CAAC,kBAAkB,EAAE,EAAE,CAAC;CAAG;AAEzF,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,WAAW,CAAc,oBAAoB,CAAC,CACpF,oBAAoB,EACpB;IACE,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CACF;CAAG;AAEJ,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,WAAW,EAAkB,CAAC,uBAAuB,EAAE;IAChG,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC;CAAG;AAEL;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,WAAW,CAAkB,wBAAwB,CAAC,CAChG,wBAAwB,EACxB;IACE,YAAY,EAAE,MAAM,CAAC,MAAM;IAC3B,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,IAAI,EAAE,MAAM,CAAC,MAAM;CACpB,CACF;CAAG;AAEJ,MAAM,OAAO,QAAS,SAAQ,MAAM,CAAC,WAAW,CAAW,iBAAiB,CAAC,CAAC,iBAAiB,EAAE;IAC/F,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC;CAAG;AAEL,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,CAAe,qBAAqB,CAAC,CACvF,qBAAqB,EACrB,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAC3B;CAAG;AAEJ,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,WAAW,CAAiB,uBAAuB,CAAC,CAC7F,uBAAuB,EACvB,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAC3B;CAAG;AAEJ,MAAM,OAAO,UAAW,SAAQ,MAAM,CAAC,WAAW,CAAa,mBAAmB,CAAC,CACjF,mBAAmB,EACnB,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAC3B;CAAG","sourcesContent":["import { Schema } from \"effect\"\n\nexport class Unauthorized extends Schema.TaggedError<Unauthorized>()(\"@error/Unauthorized\", {}) {}\n\nexport class Forbidden extends Schema.TaggedError<Forbidden>()(\"@error/Forbidden\", {}) {}\n\nexport class InvalidCode extends Schema.TaggedError<InvalidCode>(\"@error/InvalidCode\")(\n \"@error/InvalidCode\",\n {\n message: Schema.String,\n }\n) {}\n\nexport class InvalidTenancy extends Schema.TaggedError<InvalidTenancy>()(\"@error/InvalidTenancy\", {\n message: Schema.String,\n}) {}\n\n/**\n * We need the credentialId and rpId to feed into the\n * client's signalCredentialRemoval function\n */\nexport class PasskeyNotFound extends Schema.TaggedError<PasskeyNotFound>(\"@error/PasskeyNotFound\")(\n \"@error/PasskeyNotFound\",\n {\n credentialId: Schema.String,\n message: Schema.String,\n rpId: Schema.String,\n }\n) {}\n\nexport class NotFound extends Schema.TaggedError<NotFound>(\"@error/NotFound\")(\"@error/NotFound\", {\n message: Schema.String,\n}) {}\n\nexport class InvalidEmail extends Schema.TaggedError<InvalidEmail>(\"@error/InvalidEmail\")(\n \"@error/InvalidEmail\",\n { message: Schema.String }\n) {}\n\nexport class DuplicateEmail extends Schema.TaggedError<DuplicateEmail>(\"@error/DuplicateEmail\")(\n \"@error/DuplicateEmail\",\n { message: Schema.String }\n) {}\n\nexport class BadRequest extends Schema.TaggedError<BadRequest>(\"@error/BadRequest\")(\n \"@error/BadRequest\",\n { message: Schema.String }\n) {}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/schemas/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,EAAgB,CAAC,qBAAqB,EAAE,EAAE,CAAC;CAAG;AAElG,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAgB,EAA2B,EAAE,CAC1E,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAA;AAElC,MAAM,OAAO,SAAU,SAAQ,MAAM,CAAC,WAAW,EAAa,CAAC,kBAAkB,EAAE,EAAE,CAAC;CAAG;AAEzF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAgB,EAAwB,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAA;AAEpG,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,WAAW,CAAc,oBAAoB,CAAC,CACpF,oBAAoB,EACpB;IACE,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CACF;CAAG;AAEJ,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAgB,EAA0B,EAAE,CACxE,MAAM,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAA;AAEjC,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,WAAW,EAAkB,CAAC,uBAAuB,EAAE;IAChG,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC;CAAG;AAEL,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAA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AC,EAAE,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAA;AAEpC,MAAM,OAAO,UAAW,SAAQ,MAAM,CAAC,WAAW,CAAa,mBAAmB,CAAC,CACjF,mBAAmB,EACnB,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAC3B;CAAG;AAEJ,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAgB,EAAyB,EAAE,CACtE,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAA","sourcesContent":["import { Schema } from \"effect\"\n\nexport class Unauthorized extends Schema.TaggedError<Unauthorized>()(\"@error/Unauthorized\", {}) {}\n\nexport const isUnauthorized = (payload: unknown): payload is Unauthorized =>\n Schema.is(Unauthorized)(payload)\n\nexport class Forbidden extends Schema.TaggedError<Forbidden>()(\"@error/Forbidden\", {}) {}\n\nexport const isForbidden = (payload: unknown): payload is Forbidden => Schema.is(Forbidden)(payload)\n\nexport class InvalidCode extends Schema.TaggedError<InvalidCode>(\"@error/InvalidCode\")(\n \"@error/InvalidCode\",\n {\n message: Schema.String,\n }\n) {}\n\nexport const isInvalidCode = (payload: unknown): payload is InvalidCode =>\n Schema.is(InvalidCode)(payload)\n\nexport class InvalidTenancy extends Schema.TaggedError<InvalidTenancy>()(\"@error/InvalidTenancy\", {\n message: Schema.String,\n}) {}\n\nexport const isInvalidTenancy = (payload: unknown): payload is InvalidTenancy =>\n Schema.is(InvalidTenancy)(payload)\n\n/**\n * We need the credentialId and rpId to feed into the\n * client's signalCredentialRemoval function\n */\nexport class PasskeyNotFound extends Schema.TaggedError<PasskeyNotFound>(\"@error/PasskeyNotFound\")(\n \"@error/PasskeyNotFound\",\n {\n credentialId: Schema.String,\n message: Schema.String,\n rpId: Schema.String,\n }\n) {}\n\nexport const isPasskeyNotFound = (payload: unknown): payload is PasskeyNotFound =>\n Schema.is(PasskeyNotFound)(payload)\n\nexport class NotFound extends Schema.TaggedError<NotFound>(\"@error/NotFound\")(\"@error/NotFound\", {\n message: Schema.String,\n}) {}\n\nexport const isNotFound = (payload: unknown): payload is NotFound => Schema.is(NotFound)(payload)\n\nexport class InvalidEmail extends Schema.TaggedError<InvalidEmail>(\"@error/InvalidEmail\")(\n \"@error/InvalidEmail\",\n { message: Schema.String }\n) {}\n\nexport const isInvalidEmail = (payload: unknown): payload is InvalidEmail =>\n Schema.is(InvalidEmail)(payload)\n\nexport class DuplicateEmail extends Schema.TaggedError<DuplicateEmail>(\"@error/DuplicateEmail\")(\n \"@error/DuplicateEmail\",\n { message: Schema.String }\n) {}\n\nexport const isDuplicateEmail = (payload: unknown): payload is DuplicateEmail =>\n Schema.is(DuplicateEmail)(payload)\n\nexport class BadRequest extends Schema.TaggedError<BadRequest>(\"@error/BadRequest\")(\n \"@error/BadRequest\",\n { message: Schema.String }\n) {}\n\nexport const isBadRequest = (payload: unknown): payload is BadRequest =>\n Schema.is(BadRequest)(payload)\n"]}
@@ -0,0 +1,55 @@
1
+ import type { AssignUserRequest, DeleteAuthenticatorOptions, GetAuthenticatorOptions, ListPasskeyOptions, Passkey } from "./passkey.js";
2
+ import type { ExchangeCodeOptions, VerifyTokenOptions } from "./principal.js";
3
+ import type { DeletedPasskey, FindAllPasskeys } from "./schemas/passkey.js";
4
+ import type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
5
+ /**
6
+ * Call the Passlock backend API to assign a userId to an authenticator
7
+ * @param request
8
+ * @param request
9
+ * @returns
10
+ */
11
+ export declare const assignUser: (request: AssignUserRequest) => Promise<Passkey>;
12
+ /**
13
+ * Call the Passlock backend API to delete an authenticator
14
+ * @param options
15
+ * @param options
16
+ * @returns
17
+ */
18
+ export declare const deletePasskey: (passkeyId: string, options: DeleteAuthenticatorOptions) => Promise<DeletedPasskey>;
19
+ /**
20
+ * Call the Passlock backend API to fetch an authenticator
21
+ * @param authenticatorId
22
+ * @param options
23
+ * @returns
24
+ */
25
+ export declare const getPasskey: (authenticatorId: string, options: GetAuthenticatorOptions) => Promise<Passkey>;
26
+ /**
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.
28
+ * @param options
29
+ * @returns
30
+ */
31
+ export declare const listPasskeys: (options: ListPasskeyOptions) => Promise<FindAllPasskeys>;
32
+ /**
33
+ * Call the Passlock backend API to exchange a code for a Principal
34
+ * @param code
35
+ * @package options
36
+ * @returns
37
+ */
38
+ export declare const exchangeCode: (code: string, options: ExchangeCodeOptions) => Promise<ExtendedPrincipal>;
39
+ /**
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
44
+ * cold start so might actually be slower than {@link exchangeCode}
45
+ * @param token
46
+ * @param options
47
+ * @returns
48
+ */
49
+ export declare const verifyIdToken: (token: string, options: VerifyTokenOptions) => Promise<Principal>;
50
+ export type { AssignUserRequest, DeleteAuthenticatorOptions, GetAuthenticatorOptions, ListPasskeyOptions, } from "./passkey.js";
51
+ export type { ExchangeCodeOptions, VerifyTokenOptions } from "./principal.js";
52
+ export type { AuthenticatedTenancyOptions, TenancyOptions } from "./shared.js";
53
+ export { VerificationFailure } from "./principal.js";
54
+ export * from "./schemas/index.js";
55
+ //# sourceMappingURL=unsafe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsafe.d.ts","sourceRoot":"","sources":["../src/unsafe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,0BAA0B,EAC1B,uBAAuB,EACvB,kBAAkB,EAClB,OAAO,EACR,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAC7E,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,CACxB,CAAA;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,WAAW,MAAM,EACjB,SAAS,0BAA0B,KAClC,OAAO,CAAC,cAAc,CAAgE,CAAA;AAEzF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GACrB,iBAAiB,MAAM,EACvB,SAAS,uBAAuB,KAC/B,OAAO,CAAC,OAAO,CAAmE,CAAA;AAErF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,kBAAkB,KAAG,OAAO,CAAC,eAAe,CACjC,CAAA;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,EACZ,SAAS,mBAAmB,KAC3B,OAAO,CAAC,iBAAiB,CACkE,CAAA;AAE9F;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,SAAS,kBAAkB,KAAG,OAAO,CAAC,SAAS,CACI,CAAA;AAEhG,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,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,cAAc,oBAAoB,CAAA"}
package/dist/unsafe.js ADDED
@@ -0,0 +1,52 @@
1
+ import { FetchHttpClient } from "@effect/platform";
2
+ import { Effect, 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";
5
+ /**
6
+ * Call the Passlock backend API to assign a userId to an authenticator
7
+ * @param request
8
+ * @param request
9
+ * @returns
10
+ */
11
+ export const assignUser = (request) => pipe(assignUserE(request), Effect.runPromise);
12
+ /**
13
+ * Call the Passlock backend API to delete an authenticator
14
+ * @param options
15
+ * @param options
16
+ * @returns
17
+ */
18
+ export const deletePasskey = (passkeyId, options) => pipe(deletePasskeyE(passkeyId, options), Effect.runPromise);
19
+ /**
20
+ * Call the Passlock backend API to fetch an authenticator
21
+ * @param authenticatorId
22
+ * @param options
23
+ * @returns
24
+ */
25
+ export const getPasskey = (authenticatorId, options) => pipe(getPasskeyE(authenticatorId, options), Effect.runPromise);
26
+ /**
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.
28
+ * @param options
29
+ * @returns
30
+ */
31
+ export const listPasskeys = (options) => pipe(listPasskeysE(options), Effect.runPromise);
32
+ /**
33
+ * Call the Passlock backend API to exchange a code for a Principal
34
+ * @param code
35
+ * @package options
36
+ * @returns
37
+ */
38
+ export const exchangeCode = (code, options) => pipe(exchangeCodeE(code, options), Effect.provide(FetchHttpClient.layer), Effect.runPromise);
39
+ /**
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
44
+ * cold start so might actually be slower than {@link exchangeCode}
45
+ * @param token
46
+ * @param options
47
+ * @returns
48
+ */
49
+ export const verifyIdToken = (token, options) => pipe(verifyIdTokenE(token, options), Effect.provide(FetchHttpClient.layer), Effect.runPromise);
50
+ export { VerificationFailure } from "./principal.js";
51
+ export * from "./schemas/index.js";
52
+ //# sourceMappingURL=unsafe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsafe.js","sourceRoot":"","sources":["../src/unsafe.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EA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G,CAAC,KAAa,EAAE,OAA2B,EAAsB,EAAE,CAC9F,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAUhG,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, VerifyTokenOptions } from \"./principal.js\"\nimport type { DeletedPasskey, FindAllPasskeys } from \"./schemas/passkey.js\"\nimport type { ExtendedPrincipal, Principal } from \"./schemas/principal.js\"\nimport { FetchHttpClient } from \"@effect/platform\"\nimport { Effect, 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> =>\n pipe(assignUserE(request), Effect.runPromise)\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> => pipe(deletePasskeyE(passkeyId, options), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to fetch an authenticator\n * @param authenticatorId\n * @param options\n * @returns\n */\nexport const getPasskey = (\n authenticatorId: string,\n options: GetAuthenticatorOptions\n): Promise<Passkey> => pipe(getPasskeyE(authenticatorId, options), Effect.runPromise)\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> =>\n pipe(listPasskeysE(options), Effect.runPromise)\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> =>\n pipe(exchangeCodeE(code, options), Effect.provide(FetchHttpClient.layer), Effect.runPromise)\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 = (token: string, options: VerifyTokenOptions): Promise<Principal> =>\n pipe(verifyIdTokenE(token, options), Effect.provide(FetchHttpClient.layer), Effect.runPromise)\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@passlock/node",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Passkey authentication for NodeJS backends",
5
5
  "keywords": [
6
6
  "passkey",
@@ -15,7 +15,7 @@
15
15
  "repository": {
16
16
  "type": "git",
17
17
  "url": "git+https://github.com/passlock-dev/passlock.git",
18
- "directory": "packages/client"
18
+ "directory": "packages/node"
19
19
  },
20
20
  "license": "MIT",
21
21
  "author": {
@@ -29,10 +29,15 @@
29
29
  "import": "./dist/index.js",
30
30
  "default": "./dist/index.js"
31
31
  },
32
- "./effects": {
33
- "types": "./dist/effects/index.d.ts",
34
- "import": "./dist/effects/index.js",
35
- "default": "./dist/effects/index.js"
32
+ "./unsafe": {
33
+ "types": "./dist/unsafe.d.ts",
34
+ "import": "./dist/unsafe.js",
35
+ "default": "./dist/unsafe.js"
36
+ },
37
+ "./effect": {
38
+ "types": "./dist/effect.d.ts",
39
+ "import": "./dist/effect.js",
40
+ "default": "./dist/effect.js"
36
41
  }
37
42
  },
38
43
  "module": "./dist/index.js",
@@ -43,16 +48,16 @@
43
48
  "!dist/**/*.spec.*"
44
49
  ],
45
50
  "dependencies": {
46
- "@effect/platform": "^0.94.1",
47
- "@effect/platform-node": "^0.104.0",
51
+ "@effect/platform": "^0.94.2",
52
+ "@effect/platform-node": "^0.104.1",
48
53
  "jose": "^6.1.3"
49
54
  },
50
55
  "devDependencies": {
51
- "@biomejs/biome": "^2.3.11",
56
+ "@biomejs/biome": "^2.3.13",
52
57
  "@effect/vitest": "^0.27.0",
53
- "@types/node": "25.0.9",
54
- "globals": "^17.0.0",
55
- "npm-check-updates": "^19.3.1",
58
+ "@types/node": "25.1.0",
59
+ "globals": "^17.2.0",
60
+ "npm-check-updates": "^19.3.2",
56
61
  "publint": "0.3.17",
57
62
  "rimraf": "^6.1.2",
58
63
  "tsx": "4.21.0",
@@ -60,7 +65,7 @@
60
65
  "vitest": "^3.2.4"
61
66
  },
62
67
  "peerDependencies": {
63
- "effect": "3.19.14"
68
+ "effect": "3.19.15"
64
69
  },
65
70
  "engines": {
66
71
  "node": ">=22"
@@ -73,12 +78,10 @@
73
78
  "clean": "tsc --build --clean",
74
79
  "clean:full": "rimraf dist tsconfig.tsbuildinfo",
75
80
  "replaceTokens": "LATEST=${npm_package_version} tsx ../../scripts/replace-tokens.ts ./packages/node",
76
- "test": "vitest --project unit",
77
- "test:it": "vitest --project integration",
78
- "test:all": "vitest run --project unit --project integration",
79
- "test:coverage": "vitest run --coverage",
80
- "test:ui": "vitest --coverage.enabled=true --ui",
81
- "test:watch": "vitest dev",
81
+ "test:unit": "vitest --project unit run",
82
+ "test:unit:watch": "vitest --project unit",
83
+ "test:integration": "vitest --project integration run",
84
+ "test:all": "vitest --project unit --project integration run",
82
85
  "typecheck": "tsc --noEmit",
83
86
  "lint": "biome check .",
84
87
  "lint:fix": "biome check --fix .",
@@ -1,5 +0,0 @@
1
- export * from "../passkey/effects.js";
2
- export * from "../principal/principal.js";
3
- export * from "../schemas/index.js";
4
- export * from "../shared.js";
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/effects/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA"}
@@ -1,5 +0,0 @@
1
- export * from "../passkey/effects.js";
2
- export * from "../principal/principal.js";
3
- export * from "../schemas/index.js";
4
- export * from "../shared.js";
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/effects/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA","sourcesContent":["export * from \"../passkey/effects.js\"\nexport * from \"../principal/principal.js\"\nexport * from \"../schemas/index.js\"\nexport * from \"../shared.js\"\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../../src/passkey/effects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAEL,UAAU,EAGX,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAS,MAAM,EAAE,KAAK,KAAK,EAA+B,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC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,OAAO,CAAC,UAAU,CAAC,CAC3B,CAAA","sourcesContent":["import type { AuthenticatedTenancyOptions } from \"../shared.js\"\nimport {\n FetchHttpClient,\n HttpClient,\n HttpClientRequest,\n HttpClientResponse,\n} from \"@effect/platform\"\nimport { Chunk, Effect, type Layer, Match, Option, pipe, Schema, Stream } from \"effect\"\nimport { Forbidden, NotFound } from \"../schemas/errors.js\"\nimport { FindAllPasskeys } from \"../schemas/index.js\"\nimport { DeletedPasskey, Passkey, type PasskeySummary } from \"../schemas/passkey.js\"\n\n/* Get Passkey */\n\nexport type GetPasskeyOptions = AuthenticatedTenancyOptions\n\nexport const getPasskey = (\n authenticatorId: string,\n options: GetPasskeyOptions,\n httpClient: Layer.Layer<HttpClient.HttpClient> = FetchHttpClient.layer\n): Effect.Effect<Passkey, NotFound | Forbidden> =>\n pipe(\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient\n const baseUrl = options.endpoint ?? \"https://api.passlock.dev\"\n const { tenancyId } = options\n\n const url = new URL(`/${tenancyId}/passkeys/${authenticatorId}`, baseUrl)\n\n const response = yield* HttpClientRequest.get(url, {\n headers: { Authorization: `Bearer ${options.apiKey}` },\n }).pipe(client.execute)\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () => HttpClientResponse.schemaBodyJson(Passkey)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(Schema.Union(Forbidden, NotFound))(response),\n })\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"Passkey\", (data) => Effect.succeed(data)),\n Match.tag(\"@error/Forbidden\", (err) => Effect.fail(err)),\n Match.tag(\"@error/NotFound\", (err) => Effect.fail(err)),\n Match.exhaustive\n )\n }),\n Effect.catchTags({\n ParseError: (err) => Effect.die(err),\n RequestError: (err) => Effect.die(err),\n ResponseError: (err) => Effect.die(err),\n }),\n Effect.provide(httpClient)\n )\n\nexport type { GetPasskeyOptions as GetAuthenticatorOptions, Passkey }\n\n/* Delete Passkey */\n\ntype DeleteAuthenticatorOptions = AuthenticatedTenancyOptions\n\nexport const deletePasskey = (\n passkeyId: string,\n request: DeleteAuthenticatorOptions,\n httpClient: Layer.Layer<HttpClient.HttpClient> = FetchHttpClient.layer\n): Effect.Effect<DeletedPasskey, NotFound | Forbidden> =>\n pipe(\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient\n const baseUrl = request.endpoint ?? \"https://api.passlock.dev\"\n const { tenancyId } = request\n\n const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl)\n\n const response = yield* HttpClientRequest.del(url, {\n headers: { Authorization: `Bearer ${request.apiKey}` },\n }).pipe(client.execute)\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () => HttpClientResponse.schemaBodyJson(DeletedPasskey)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(Schema.Union(Forbidden, NotFound))(response),\n })\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"DeletedPasskey\", (deletedPasskey) => Effect.succeed(deletedPasskey)),\n Match.tag(\"@error/Forbidden\", (err) => Effect.fail(err)),\n Match.tag(\"@error/NotFound\", (err) => Effect.fail(err)),\n Match.exhaustive\n )\n }),\n Effect.catchTags({\n ParseError: (err) => Effect.die(err),\n RequestError: (err) => Effect.die(err),\n ResponseError: (err) => Effect.die(err),\n }),\n Effect.provide(httpClient)\n )\n\nexport type { DeleteAuthenticatorOptions }\n\n/* Assign User */\n\ninterface AssignUserRequest extends AuthenticatedTenancyOptions {\n userId: string\n passkeyId: string\n}\n\nexport const assignUser = (\n request: AssignUserRequest,\n httpClient: Layer.Layer<HttpClient.HttpClient> = FetchHttpClient.layer\n): Effect.Effect<Passkey, NotFound | Forbidden> =>\n pipe(\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient\n const baseUrl = request.endpoint ?? \"https://api.passlock.dev\"\n const { userId, passkeyId } = request\n const { tenancyId } = request\n\n const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl)\n\n const response = yield* HttpClientRequest.patch(url, {\n headers: { Authorization: `Bearer ${request.apiKey}` },\n }).pipe(HttpClientRequest.bodyJson({ userId }), Effect.flatMap(client.execute))\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () => HttpClientResponse.schemaBodyJson(Passkey)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(Schema.Union(NotFound, Forbidden))(response),\n })\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"Passkey\", (passkey) => Effect.succeed(passkey)),\n Match.tag(\"@error/NotFound\", (err) => Effect.fail(err)),\n Match.tag(\"@error/Forbidden\", (err) => Effect.fail(err)),\n Match.exhaustive\n )\n }),\n Effect.catchTags({\n HttpBodyError: (err) => Effect.die(err),\n ParseError: (err) => Effect.die(err),\n RequestError: (err) => Effect.die(err),\n ResponseError: (err) => Effect.die(err),\n }),\n Effect.provide(httpClient)\n )\n\nexport type { AssignUserRequest }\n\n/* List Passkeys */\n\nexport interface ListPasskeyOptions extends AuthenticatedTenancyOptions {\n cursor?: string\n}\n\nexport const listPasskeysStream = (\n options: AuthenticatedTenancyOptions,\n httpClient: Layer.Layer<HttpClient.HttpClient> = FetchHttpClient.layer\n): Stream.Stream<PasskeySummary, Forbidden> =>\n pipe(\n Stream.paginateChunkEffect(null as string | null, (cursor) =>\n pipe(\n listPasskeys(cursor ? { ...options, cursor } : options, httpClient),\n Effect.map((result) => [\n Chunk.fromIterable(result.records),\n Option.fromNullable(result.cursor),\n ])\n )\n )\n )\n\nexport const listPasskeys = (\n options: ListPasskeyOptions,\n httpClient: Layer.Layer<HttpClient.HttpClient> = FetchHttpClient.layer\n): Effect.Effect<FindAllPasskeys, Forbidden> =>\n pipe(\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient\n const baseUrl = options.endpoint ?? \"https://api.passlock.dev\"\n const { tenancyId } = options\n\n const url = new URL(`/${tenancyId}/passkeys/`, baseUrl)\n if (options.cursor) {\n url.searchParams.append(\"cursor\", options.cursor)\n }\n\n const response = yield* HttpClientRequest.get(url, {\n headers: { Authorization: `Bearer ${options.apiKey}` },\n }).pipe(client.execute)\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () => HttpClientResponse.schemaBodyJson(FindAllPasskeys)(response),\n orElse: () => HttpClientResponse.schemaBodyJson(Forbidden)(response),\n })\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"FindAllPasskeys\", (data) => Effect.succeed(data)),\n Match.tag(\"@error/Forbidden\", (err) => Effect.fail(err)),\n Match.exhaustive\n )\n }),\n Effect.catchTags({\n ParseError: (err) => Effect.die(err),\n RequestError: (err) => Effect.die(err),\n ResponseError: (err) => Effect.die(err),\n }),\n Effect.provide(httpClient)\n )\n"]}
@@ -1,64 +0,0 @@
1
- import type { Forbidden, NotFound } from "../schemas/errors.js";
2
- import type { DeletedPasskey, FindAllPasskeys, PasskeySummary } from "../schemas/passkey.js";
3
- import type { AuthenticatedTenancyOptions } from "../shared.js";
4
- import type { AssignUserRequest, DeleteAuthenticatorOptions, GetAuthenticatorOptions, ListPasskeyOptions, Passkey } from "./effects.js";
5
- /**
6
- * Call the Passlock backend API to assign a userId to an authenticator
7
- * @param request
8
- * @param request
9
- * @returns
10
- */
11
- export declare const assignUser: (request: AssignUserRequest) => Promise<Passkey | NotFound | Forbidden>;
12
- /**
13
- * Call the Passlock backend API to assign a userId to an authenticator
14
- * @param request
15
- * @param request
16
- * @returns
17
- */
18
- export declare const assignUserUnsafe: (request: AssignUserRequest) => Promise<Passkey>;
19
- /**
20
- * Call the Passlock backend API to delete an authenticator
21
- * @param options
22
- * @param options
23
- * @returns
24
- */
25
- export declare const deletePasskey: (passkeyId: string, options: DeleteAuthenticatorOptions) => Promise<DeletedPasskey | Forbidden | NotFound>;
26
- /**
27
- * Call the Passlock backend API to delete an authenticator
28
- * @param options
29
- * @param options
30
- * @returns
31
- */
32
- export declare const deletePasskeyUnsafe: (passkeyId: string, options: DeleteAuthenticatorOptions) => Promise<{
33
- passkeyId: string;
34
- }>;
35
- /**
36
- * Call the Passlock backend API to fetch an authenticator
37
- * @param request
38
- * @param request
39
- * @returns
40
- */
41
- export declare const getPasskey: (authenticatorId: string, options: GetAuthenticatorOptions) => Promise<Passkey | Forbidden | NotFound>;
42
- /**
43
- * Call the Passlock backend API to fetch an authenticator
44
- * @param authenticatorId
45
- * @param options
46
- * @returns
47
- */
48
- export declare const getPasskeyUnsafe: (authenticatorId: string, options: GetAuthenticatorOptions) => Promise<Passkey>;
49
- export type { AssignUserRequest, DeleteAuthenticatorOptions, GetAuthenticatorOptions, Passkey, } from "./effects.js";
50
- /**
51
- * List passkeys for the given tenancy. Note this could return a cursor, in which case the function chould be called with the given cursor.
52
- * @param options
53
- * @returns
54
- */
55
- export declare const listPasskeys: (options: ListPasskeyOptions) => Promise<FindAllPasskeys | Forbidden>;
56
- /**
57
- * List passkeys for the given tenancy. Note this could return a cursor, in which case the function chould be called with the given cursor.
58
- * @param options
59
- * @returns
60
- */
61
- export declare const listPasskeysUnsafe: (options: ListPasskeyOptions) => Promise<FindAllPasskeys>;
62
- export declare const listPasskeysStream: (options: AuthenticatedTenancyOptions) => ReadableStream<PasskeySummary>;
63
- export type { ListPasskeyOptions } from "./effects.js";
64
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/passkey/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC5F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,KAAK,EACV,iBAAiB,EACjB,0BAA0B,EAC1B,uBAAuB,EACvB,kBAAkB,EAClB,OAAO,EACR,MAAM,cAAc,CAAA;AAUrB;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAA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User as assignUserE, deletePasskey as deletePasskeyE, getPasskey as getPasskeyE, listPasskeys as listPasskeysE, listPasskeysStream as listPasskeysStreamE, } from "./effects.js";
3
- /**
4
- * Call the Passlock backend API to assign a userId to an authenticator
5
- * @param request
6
- * @param request
7
- * @returns
8
- */
9
- export const assignUser = (request) => pipe(assignUserE(request), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
10
- /**
11
- * Call the Passlock backend API to assign a userId to an authenticator
12
- * @param request
13
- * @param request
14
- * @returns
15
- */
16
- export const assignUserUnsafe = (request) => pipe(assignUserE(request), Effect.runPromise);
17
- /**
18
- * Call the Passlock backend API to delete an authenticator
19
- * @param options
20
- * @param options
21
- * @returns
22
- */
23
- export const deletePasskey = (passkeyId, options) => pipe(deletePasskeyE(passkeyId, options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
24
- /**
25
- * Call the Passlock backend API to delete an authenticator
26
- * @param options
27
- * @param options
28
- * @returns
29
- */
30
- export const deletePasskeyUnsafe = (passkeyId, options) => pipe(deletePasskeyE(passkeyId, options), Effect.as({ passkeyId }), Effect.runPromise);
31
- /**
32
- * Call the Passlock backend API to fetch an authenticator
33
- * @param request
34
- * @param request
35
- * @returns
36
- */
37
- export const getPasskey = (authenticatorId, options) => pipe(getPasskeyE(authenticatorId, options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
38
- /**
39
- * Call the Passlock backend API to fetch an authenticator
40
- * @param authenticatorId
41
- * @param options
42
- * @returns
43
- */
44
- export const getPasskeyUnsafe = (authenticatorId, options) => pipe(getPasskeyE(authenticatorId, options), Effect.runPromise);
45
- /**
46
- * List passkeys for the given tenancy. Note this could return a cursor, in which case the function chould be called with the given cursor.
47
- * @param options
48
- * @returns
49
- */
50
- export const listPasskeys = (options) => pipe(listPasskeysE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
51
- /**
52
- * List passkeys for the given tenancy. Note this could return a cursor, in which case the function chould be called with the given cursor.
53
- * @param options
54
- * @returns
55
- */
56
- export const listPasskeysUnsafe = (options) => pipe(listPasskeysE(options), Effect.runPromise);
57
- export const listPasskeysStream = (options) => pipe(listPasskeysStreamE(options), (stream) => Stream.toReadableStream(stream));
58
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/passkey/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvD,OAAO,EACL,UAAU,IAAI,WAAW,EACzB,aAAa,IAAI,cAAc,EAC/B,UAAU,IAAI,WAAW,EACzB,YAAY,IAAI,aAAa,EAC7B,kBAAkB,IAAI,mBAAmB,GAC1C,MAAM,cAAc,CAAA;AAErB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAA0B,EAA2C,EAAE,CAChG,IAAI,CACF,WAAW,CAAC,OAAO,CAAC,EACpB,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAC1D,MAAM,CAAC,UAAU,CAClB,CAAA;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAA0B,EAAoB,EAAE,CAC/E,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,SAAiB,EACjB,OAAmC,EACa,EAAE,CAClD,IAAI,CACF,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,EAClC,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAC1D,MAAM,CAAC,UAAU,CAClB,CAAA;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB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AAC,CAAC,CAAA","sourcesContent":["import type { Forbidden, NotFound } from \"../schemas/errors.js\"\nimport type { DeletedPasskey, FindAllPasskeys, PasskeySummary } from \"../schemas/passkey.js\"\nimport type { AuthenticatedTenancyOptions } from \"../shared.js\"\nimport type {\n AssignUserRequest,\n DeleteAuthenticatorOptions,\n GetAuthenticatorOptions,\n ListPasskeyOptions,\n Passkey,\n} from \"./effects.js\"\nimport { Effect, identity, pipe, Stream } from \"effect\"\nimport {\n assignUser as assignUserE,\n deletePasskey as deletePasskeyE,\n getPasskey as getPasskeyE,\n listPasskeys as listPasskeysE,\n listPasskeysStream as listPasskeysStreamE,\n} from \"./effects.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 assign a userId to an authenticator\n * @param request\n * @param request\n * @returns\n */\nexport const assignUserUnsafe = (request: AssignUserRequest): Promise<Passkey> =>\n pipe(assignUserE(request), Effect.runPromise)\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 delete an authenticator\n * @param options\n * @param options\n * @returns\n */\nexport const deletePasskeyUnsafe = (\n passkeyId: string,\n options: DeleteAuthenticatorOptions\n): Promise<{ passkeyId: string }> =>\n pipe(deletePasskeyE(passkeyId, options), Effect.as({ passkeyId }), Effect.runPromise)\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 * Call the Passlock backend API to fetch an authenticator\n * @param authenticatorId\n * @param options\n * @returns\n */\nexport const getPasskeyUnsafe = (\n authenticatorId: string,\n options: GetAuthenticatorOptions\n): Promise<Passkey> => pipe(getPasskeyE(authenticatorId, options), Effect.runPromise)\n\nexport type {\n AssignUserRequest,\n DeleteAuthenticatorOptions,\n GetAuthenticatorOptions,\n Passkey,\n} from \"./effects.js\"\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 * 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 listPasskeysUnsafe = (options: ListPasskeyOptions): Promise<FindAllPasskeys> =>\n pipe(listPasskeysE(options), Effect.runPromise)\n\nexport const listPasskeysStream = (\n options: AuthenticatedTenancyOptions\n): ReadableStream<PasskeySummary> =>\n pipe(listPasskeysStreamE(options), (stream) => Stream.toReadableStream(stream))\n\nexport type { ListPasskeyOptions } from \"./effects.js\"\n"]}
@@ -1,43 +0,0 @@
1
- import type { Forbidden, InvalidCode } from "../schemas/errors.js";
2
- import type { ExtendedPrincipal, Principal } from "../schemas/principal.js";
3
- import { type ExchangeCodeOptions, type VerificationFailure, type VerifyTokenOptions } from "./principal.js";
4
- /**
5
- * Call the Passlock backend API to exchange a code for a Principal
6
- * @param code
7
- * @package options
8
- * @returns
9
- */
10
- export declare const exchangeCode: (code: string, options: ExchangeCodeOptions) => Promise<ExtendedPrincipal | Forbidden | InvalidCode>;
11
- /**
12
- * Call the Passlock backend API to exchange a code for a Principal
13
- * @param code
14
- * @package options
15
- * @returns
16
- */
17
- export declare const exchangeCodeUnsafe: (code: string, options: ExchangeCodeOptions) => Promise<ExtendedPrincipal>;
18
- /**
19
- * Decode and verify a Passlock idToken.
20
- * Note: This will make a network call to the passlock.dev/.well-known/jwks.json
21
- * endpoint to fetch the relevant public key. The response will be cached, however
22
- * bear in mind that for something like AWS lambda it will make the call on every
23
- * cold start so might actually be slower than {@link exchangeCode}
24
- * @param token
25
- * @param options
26
- * @returns
27
- */
28
- export declare const verifyIdToken: (token: string, options: VerifyTokenOptions) => Promise<Principal | VerificationFailure>;
29
- /**
30
- * Decode and verify a Passlock idToken.
31
- * Note: This will make a network call to the passlock.dev/.well-known/jwks.json
32
- * endpoint to fetch the relevant public key. The response will be cached, however
33
- * bear in mind that for something like AWS lambda it will make the call on every
34
- * cold start so might actually be slower than {@link exchangeCode}
35
- * @param token
36
- * @param options
37
- * @returns
38
- */
39
- export declare const verifyIdTokenUnsafe: (token: string, options: VerifyTokenOptions) => Promise<Principal>;
40
- export type { InvalidCode } from "../schemas/errors.js";
41
- export type { ExchangeCodeOptions, Principal, VerificationFailure, VerifyTokenOptions, } from "./principal.js";
42
- export * from "../schemas/principal.js";
43
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/principal/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAG3E,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EAExB,MAAM,gBAAgB,CAAA;AAEvB;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,EACZ,SAAS,mBAAmB,KAC3B,OAAO,CAAC,iBAAiB,GAAG,SAAS,GAAG,WAAW,CAMnD,CAAA;AAEH;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,MAAM,EACZ,SAAS,mBAAmB,KAC3B,OAAO,CAAC,iBAAiB,CACkE,CAAA;AAE9F;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,MAAM,EACb,SAAS,kBAAkB,KAC1B,OAAO,CAAC,SAAS,GAAG,mBAAmB,CAKvC,CAAA;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,MAAM,EACb,SAAS,kBAAkB,KAC1B,OAAO,CAAC,SAAS,CAC4E,CAAA;AAEhG,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,YAAY,EACV,mBAAmB,EACnB,SAAS,EACT,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,gBAAgB,CAAA;AACvB,cAAc,yBAAyB,CAAA"}
@@ -1,41 +0,0 @@
1
- import { FetchHttpClient } from "@effect/platform";
2
- import { Effect, identity, pipe } from "effect";
3
- import { exchangeCode as exchangeCodeE, verifyIdToken as verifyIdTokenE, } from "./principal.js";
4
- /**
5
- * Call the Passlock backend API to exchange a code for a Principal
6
- * @param code
7
- * @package options
8
- * @returns
9
- */
10
- export const exchangeCode = (code, options) => pipe(exchangeCodeE(code, options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.provide(FetchHttpClient.layer), Effect.runPromise);
11
- /**
12
- * Call the Passlock backend API to exchange a code for a Principal
13
- * @param code
14
- * @package options
15
- * @returns
16
- */
17
- export const exchangeCodeUnsafe = (code, options) => pipe(exchangeCodeE(code, options), Effect.provide(FetchHttpClient.layer), Effect.runPromise);
18
- /**
19
- * Decode and verify a Passlock idToken.
20
- * Note: This will make a network call to the passlock.dev/.well-known/jwks.json
21
- * endpoint to fetch the relevant public key. The response will be cached, however
22
- * bear in mind that for something like AWS lambda it will make the call on every
23
- * cold start so might actually be slower than {@link exchangeCode}
24
- * @param token
25
- * @param options
26
- * @returns
27
- */
28
- export const verifyIdToken = (token, options) => pipe(verifyIdTokenE(token, options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
29
- /**
30
- * Decode and verify a Passlock idToken.
31
- * Note: This will make a network call to the passlock.dev/.well-known/jwks.json
32
- * endpoint to fetch the relevant public key. The response will be cached, however
33
- * bear in mind that for something like AWS lambda it will make the call on every
34
- * cold start so might actually be slower than {@link exchangeCode}
35
- * @param token
36
- * @param options
37
- * @returns
38
- */
39
- export const verifyIdTokenUnsafe = (token, options) => pipe(verifyIdTokenE(token, options), Effect.provide(FetchHttpClient.layer), Effect.runPromise);
40
- export * from "../schemas/principal.js";
41
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/principal/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EAEL,YAAY,IAAI,aAAa,EAG7B,aAAa,IAAI,cAAc,GAChC,MAAM,gBAAgB,CAAA;AAEvB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,IAAY,EACZ,OAA4B,EAC0B,EAAE,CACxD,IAAI,CACF,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,EAC5B,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAC1D,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EACrC,MAAM,CAAC,UAAU,CAClB,CAAA;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,IAAY,EACZ,OAA4B,EACA,EAAE,CAC9B,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAE9F;;;;;;;;;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;AAEH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,KAAa,EACb,OAA2B,EACP,EAAE,CACtB,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAShG,cAAc,yBAAyB,CAAA","sourcesContent":["import type { Forbidden, InvalidCode } from \"../schemas/errors.js\"\nimport type { ExtendedPrincipal, Principal } from \"../schemas/principal.js\"\nimport { FetchHttpClient } from \"@effect/platform\"\nimport { Effect, identity, pipe } from \"effect\"\nimport {\n type ExchangeCodeOptions,\n exchangeCode as exchangeCodeE,\n type VerificationFailure,\n type VerifyTokenOptions,\n verifyIdToken as verifyIdTokenE,\n} from \"./principal.js\"\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 * Call the Passlock backend API to exchange a code for a Principal\n * @param code\n * @package options\n * @returns\n */\nexport const exchangeCodeUnsafe = (\n code: string,\n options: ExchangeCodeOptions\n): Promise<ExtendedPrincipal> =>\n pipe(exchangeCodeE(code, options), Effect.provide(FetchHttpClient.layer), Effect.runPromise)\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\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 verifyIdTokenUnsafe = (\n token: string,\n options: VerifyTokenOptions\n): Promise<Principal> =>\n pipe(verifyIdTokenE(token, options), Effect.provide(FetchHttpClient.layer), Effect.runPromise)\n\nexport type { InvalidCode } from \"../schemas/errors.js\"\nexport type {\n ExchangeCodeOptions,\n Principal,\n VerificationFailure,\n VerifyTokenOptions,\n} from \"./principal.js\"\nexport * from \"../schemas/principal.js\"\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"principal.d.ts","sourceRoot":"","sources":["../../src/principal/principal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC/E,OAAO,EAAmB,UAAU,EAAsB,MAAM,kBAAkB,CAAA;AAClF,OAAO,EAAQ,MAAM,EAAE,KAAK,KAAK,EAAuB,MAAM,QAAQ,CAAA;AAEtE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,iBAAiB,EAAW,KAAK,SAAS,E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C,CAAC,IAAI,mBAAmB,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;gBACnD,CAAC,CAAC,IAAI,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACvD,CAAC;QACD,GAAG,EAAE,GAAG,EAAE,CACR,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE;YAC1B,QAAQ,EAAE,OAAO,CAAC,SAAS;YAC3B,MAAM,EAAE,cAAc;SACvB,CAAC;KACL,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACnD,GAAG,OAAO;QACV,IAAI,EAAE,SAAS;KAChB,CAAC,CAAA;IAEF,MAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,WAAW;QACjB,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC;QAClB,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC;QAChC,iBAAiB,EAAE,SAAS;QAC5B,SAAS,EAAE,OAAO,CAAC,GAAG,GAAG,IAAI;QAC7B,SAAS,EAAE,OAAO,CAAC,GAAG,GAAG,IAAI;QAC7B,OAAO,EAAE;YACP,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC;YAC9B,QAAQ,EAAE,IAAI;SACf;QACD,MAAM,EAAE,OAAO,CAAC,GAAG;KACpB,CAAA;IAED,OAAO,SAAS,CAAA;AAClB,CAAC,CAAC,EACF,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CACxD,CAAA","sourcesContent":["import type { AuthenticatedTenancyOptions, TenancyOptions } from \"../shared.js\"\nimport { FetchHttpClient, HttpClient, HttpClientResponse } from \"@effect/platform\"\nimport { Data, Effect, type Layer, Match, pipe, Schema } from \"effect\"\nimport * as jose from \"jose\"\nimport { Forbidden, InvalidCode } from \"../schemas/errors.js\"\nimport { ExtendedPrincipal, IdToken, type Principal } from \"../schemas/principal.js\"\n\ntype ExchangeCodeOptions = AuthenticatedTenancyOptions\n\nexport const exchangeCode = (\n code: string,\n options: ExchangeCodeOptions,\n httpClient: Layer.Layer<HttpClient.HttpClient> = FetchHttpClient.layer\n): Effect.Effect<ExtendedPrincipal, InvalidCode | Forbidden> =>\n pipe(\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient\n const baseUrl = options.endpoint ?? \"https://api.passlock.dev\"\n const { tenancyId } = options\n\n const url = new URL(`/${tenancyId}/principal/${code}`, baseUrl)\n\n const response = yield* pipe(\n client.get(url, {\n headers: { Authorization: `Bearer ${options.apiKey}` },\n })\n )\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () => HttpClientResponse.schemaBodyJson(ExtendedPrincipal)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(Schema.Union(InvalidCode, Forbidden))(response),\n })\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"ExtendedPrincipal\", (principal) => Effect.succeed(principal)),\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 ParseError: (err) => Effect.die(err),\n RequestError: (err) => Effect.die(err),\n ResponseError: (err) => Effect.die(err),\n }),\n Effect.provide(httpClient)\n )\n\ntype VerifyTokenOptions = TenancyOptions\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(Effect.cachedFunction(createJwks), Effect.runSync)\n\nexport class VerificationFailure extends Data.TaggedError(\"@error/VerificationFailure\")<{\n message: string\n}> {}\n\nexport const verifyIdToken = (\n token: string,\n options: VerifyTokenOptions\n): Effect.Effect<Principal, VerificationFailure> =>\n pipe(\n Effect.gen(function* () {\n const JWKS = yield* createCachedRemoteJwks(options.endpoint)\n\n const { payload } = yield* Effect.tryPromise({\n catch: (err) => {\n console.error(err)\n return err instanceof Error\n ? new VerificationFailure({ message: err.message })\n : new VerificationFailure({ message: String(err) })\n },\n try: () =>\n jose.jwtVerify(token, JWKS, {\n audience: options.tenancyId,\n issuer: \"passlock.dev\",\n }),\n })\n\n const idToken = yield* Schema.decodeUnknown(IdToken)({\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\nexport type { ExchangeCodeOptions, Principal, VerifyTokenOptions }\n"]}