@passlock/node 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/effect.d.ts +5 -5
  2. package/dist/effect.d.ts.map +1 -1
  3. package/dist/effect.js +2 -2
  4. package/dist/effect.js.map +1 -1
  5. package/dist/errors.d.ts +71 -0
  6. package/dist/errors.d.ts.map +1 -0
  7. package/dist/errors.js +25 -0
  8. package/dist/errors.js.map +1 -0
  9. package/dist/index.d.ts +63 -29
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +57 -24
  12. package/dist/index.js.map +1 -1
  13. package/dist/passkey/passkey.d.ts +116 -0
  14. package/dist/passkey/passkey.d.ts.map +1 -0
  15. package/dist/{passkey.js → passkey/passkey.js} +44 -20
  16. package/dist/passkey/passkey.js.map +1 -0
  17. package/dist/principal/principal.d.ts +22 -0
  18. package/dist/principal/principal.d.ts.map +1 -0
  19. package/dist/{principal.js → principal/principal.js} +9 -9
  20. package/dist/principal/principal.js.map +1 -0
  21. package/dist/safe.d.ts +136 -0
  22. package/dist/safe.d.ts.map +1 -0
  23. package/dist/safe.js +130 -0
  24. package/dist/safe.js.map +1 -0
  25. package/dist/schemas/errors.d.ts +13 -65
  26. package/dist/schemas/errors.d.ts.map +1 -1
  27. package/dist/schemas/errors.js +47 -6
  28. package/dist/schemas/errors.js.map +1 -1
  29. package/dist/schemas/passkey.d.ts +19 -21
  30. package/dist/schemas/passkey.d.ts.map +1 -1
  31. package/dist/schemas/passkey.js +23 -17
  32. package/dist/schemas/passkey.js.map +1 -1
  33. package/dist/schemas/principal.d.ts +46 -6
  34. package/dist/schemas/principal.d.ts.map +1 -1
  35. package/dist/schemas/principal.js +6 -6
  36. package/dist/schemas/principal.js.map +1 -1
  37. package/dist/schemas/satisfy.d.ts +2 -0
  38. package/dist/schemas/satisfy.d.ts.map +1 -0
  39. package/dist/schemas/satisfy.js +2 -0
  40. package/dist/schemas/satisfy.js.map +1 -0
  41. package/dist/shared.d.ts +3 -5
  42. package/dist/shared.d.ts.map +1 -1
  43. package/dist/shared.js +0 -3
  44. package/dist/shared.js.map +1 -1
  45. package/package.json +21 -18
  46. package/dist/passkey.d.ts +0 -24
  47. package/dist/passkey.d.ts.map +0 -1
  48. package/dist/passkey.js.map +0 -1
  49. package/dist/principal.d.ts +0 -18
  50. package/dist/principal.d.ts.map +0 -1
  51. package/dist/principal.js.map +0 -1
  52. package/dist/testUtils.d.ts +0 -11
  53. package/dist/testUtils.d.ts.map +0 -1
  54. package/dist/testUtils.js +0 -25
  55. package/dist/testUtils.js.map +0 -1
  56. package/dist/unsafe.d.ts +0 -55
  57. package/dist/unsafe.d.ts.map +0 -1
  58. package/dist/unsafe.js +0 -52
  59. package/dist/unsafe.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAc9C,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,IAAI,CAAQ;IAErB,YAAY,IAAuC;QACjD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;IACvB,CAAC;IAEiB,QAAQ,GAAG,GAAW,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,WAAW,IAAI,CAAC,IAAI,GAAG,CAAA;CAClF;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAgB,EAAuB,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAA","sourcesContent":["import { Schema } from \"effect\"\nimport { NotFound } from \"./schemas/errors.js\"\n\nexport interface TenancyOptions {\n tenancyId: string\n /**\n * @default https://api.passlock.dev\n */\n endpoint?: string\n}\n\nexport interface AuthenticatedTenancyOptions extends TenancyOptions {\n apiKey: string\n}\n\nexport class UnexpectedError extends Error {\n readonly _tag: string\n\n constructor(data: { _tag: string; message: string }) {\n super(data.message)\n this._tag = data._tag\n }\n\n override readonly toString = (): string => `${this.message} (_tag: ${this._tag})`\n}\n\nexport const isNotFound = (payload: unknown): payload is NotFound => Schema.is(NotFound)(payload)\n"]}
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,IAAI,CAAQ;IAErB,YAAY,IAAuC;QACjD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;IACvB,CAAC;IAEiB,QAAQ,GAAG,GAAW,EAAE,CACxC,GAAG,IAAI,CAAC,OAAO,WAAW,IAAI,CAAC,IAAI,GAAG,CAAA;CACzC","sourcesContent":["export type PasslockOptions = {\n tenancyId: string\n\n /**\n * @default https://api.passlock.dev\n */\n endpoint?: string\n}\n\nexport interface AuthenticatedOptions extends PasslockOptions {\n apiKey: string\n}\n\nexport class UnexpectedError extends Error {\n readonly _tag: string\n\n constructor(data: { _tag: string; message: string }) {\n super(data.message)\n this._tag = data._tag\n }\n\n override readonly toString = (): string =>\n `${this.message} (_tag: ${this._tag})`\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@passlock/node",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Passkey authentication for NodeJS backends",
5
5
  "keywords": [
6
6
  "passkey",
@@ -29,10 +29,10 @@
29
29
  "import": "./dist/index.js",
30
30
  "default": "./dist/index.js"
31
31
  },
32
- "./unsafe": {
33
- "types": "./dist/unsafe.d.ts",
34
- "import": "./dist/unsafe.js",
35
- "default": "./dist/unsafe.js"
32
+ "./safe": {
33
+ "types": "./dist/safe.d.ts",
34
+ "import": "./dist/safe.js",
35
+ "default": "./dist/safe.js"
36
36
  },
37
37
  "./effect": {
38
38
  "types": "./dist/effect.d.ts",
@@ -48,41 +48,44 @@
48
48
  "!dist/**/*.spec.*"
49
49
  ],
50
50
  "dependencies": {
51
- "@effect/platform": "^0.94.2",
51
+ "@effect/platform": "^0.94.5",
52
52
  "@effect/platform-node": "^0.104.1",
53
53
  "jose": "^6.1.3"
54
54
  },
55
55
  "devDependencies": {
56
- "@biomejs/biome": "^2.3.13",
56
+ "@biomejs/biome": "^2.4.4",
57
57
  "@effect/vitest": "^0.27.0",
58
- "@types/node": "25.1.0",
59
- "globals": "^17.2.0",
60
- "npm-check-updates": "^19.3.2",
58
+ "@types/node": "25.3.0",
59
+ "globals": "^17.3.0",
60
+ "npm-check-updates": "^19.4.1",
61
61
  "publint": "0.3.17",
62
- "rimraf": "^6.1.2",
62
+ "rimraf": "^6.1.3",
63
63
  "tsx": "4.21.0",
64
+ "typedoc": "^0.28.17",
64
65
  "typescript": "^5.9.3",
66
+ "vite-tsconfig-paths": "^6.1.1",
65
67
  "vitest": "^3.2.4"
66
68
  },
67
69
  "peerDependencies": {
68
- "effect": "3.19.15"
70
+ "effect": "3.19.19"
69
71
  },
70
72
  "engines": {
71
73
  "node": ">=22"
72
74
  },
73
75
  "scripts": {
74
- "build": "tsc --build",
76
+ "build": "tsc -p tsconfig.build.json",
75
77
  "build:clean": "$npm_execpath run clean:full && $npm_execpath run build",
76
78
  "build:production": "$npm_execpath run build:clean && $npm_execpath run build:readme && $npm_execpath run replaceTokens && echo '' && publint",
77
- "build:readme": "LATEST=${npm_package_version} tsx ../../scripts/replace-readme-tokens.ts ./packages/node",
78
- "clean": "tsc --build --clean",
79
- "clean:full": "rimraf dist tsconfig.tsbuildinfo",
80
- "replaceTokens": "LATEST=${npm_package_version} tsx ../../scripts/replace-tokens.ts ./packages/node",
79
+ "build:readme": "VERSION=${npm_package_version} tsx ../../scripts/replace-readme-tokens.ts ./packages/node",
80
+ "typedoc": "typedoc",
81
+ "clean": "tsc -p tsconfig.build.json --clean",
82
+ "clean:full": "rimraf dist tsconfig.build.tsbuildinfo",
83
+ "replaceTokens": "VERSION=${npm_package_version} tsx ../../scripts/replace-tokens.ts ./packages/node",
81
84
  "test:unit": "vitest --project unit run",
82
85
  "test:unit:watch": "vitest --project unit",
83
86
  "test:integration": "vitest --project integration run",
84
87
  "test:all": "vitest --project unit --project integration run",
85
- "typecheck": "tsc --noEmit",
88
+ "typecheck": "tsc -p tsconfig.test.json --noEmit",
86
89
  "lint": "biome check .",
87
90
  "lint:fix": "biome check --fix .",
88
91
  "lint:ci": "biome ci .",
package/dist/passkey.d.ts DELETED
@@ -1,24 +0,0 @@
1
- import type { AuthenticatedTenancyOptions } from "./shared.js";
2
- import { HttpClient } from "@effect/platform";
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";
7
- export type GetPasskeyOptions = AuthenticatedTenancyOptions;
8
- export declare const getPasskey: (authenticatorId: string, options: GetPasskeyOptions, httpClient?: Layer.Layer<HttpClient.HttpClient>) => Effect.Effect<Passkey, NotFound | Forbidden>;
9
- export type { GetPasskeyOptions as GetAuthenticatorOptions, Passkey };
10
- type DeleteAuthenticatorOptions = AuthenticatedTenancyOptions;
11
- export declare const deletePasskey: (passkeyId: string, request: DeleteAuthenticatorOptions, httpClient?: Layer.Layer<HttpClient.HttpClient>) => Effect.Effect<DeletedPasskey, NotFound | Forbidden>;
12
- export type { DeleteAuthenticatorOptions };
13
- interface AssignUserRequest extends AuthenticatedTenancyOptions {
14
- userId: string;
15
- passkeyId: string;
16
- }
17
- export declare const assignUser: (request: AssignUserRequest, httpClient?: Layer.Layer<HttpClient.HttpClient>) => Effect.Effect<Passkey, NotFound | Forbidden>;
18
- export type { AssignUserRequest };
19
- export interface ListPasskeyOptions extends AuthenticatedTenancyOptions {
20
- cursor?: string;
21
- }
22
- export declare const listPasskeysStream: (options: AuthenticatedTenancyOptions, httpClient?: Layer.Layer<HttpClient.HttpClient>) => Stream.Stream<PasskeySummary, Forbidden>;
23
- export declare const listPasskeys: (options: ListPasskeyOptions, httpClient?: Layer.Layer<HttpClient.HttpClient>) => Effect.Effect<FindAllPasskeys, Forbidden>;
24
- //# sourceMappingURL=passkey.d.ts.map
@@ -1 +0,0 @@
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,MAA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O,CAAC,EACpB,KAAK,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAC5D,KAAK,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACxD,KAAK,CAAC,UAAU,CACjB,CAAA;AACH,CAAC,CAAC,EACF,MAAM,CAAC,SAAS,CAAC;IACf,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;IACpC,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;IACtC,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;CACxC,CAAC,EACF,MAAM,CAAC,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,18 +0,0 @@
1
- import type { AuthenticatedTenancyOptions, TenancyOptions } from "./shared.js";
2
- import { HttpClient } from "@effect/platform";
3
- import { Effect, type Layer } from "effect";
4
- import { Forbidden, InvalidCode } from "./schemas/errors.js";
5
- import { ExtendedPrincipal, type Principal } from "./schemas/principal.js";
6
- type ExchangeCodeOptions = AuthenticatedTenancyOptions;
7
- export declare const exchangeCode: (code: string, options: ExchangeCodeOptions, httpClient?: Layer.Layer<HttpClient.HttpClient>) => Effect.Effect<ExtendedPrincipal, InvalidCode | Forbidden>;
8
- type VerifyTokenOptions = TenancyOptions;
9
- declare const VerificationFailure_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
10
- readonly _tag: "@error/VerificationFailure";
11
- } & Readonly<A>;
12
- export declare class VerificationFailure extends VerificationFailure_base<{
13
- message: string;
14
- }> {
15
- }
16
- export declare const verifyIdToken: (token: string, options: VerifyTokenOptions) => Effect.Effect<Principal, VerificationFailure>;
17
- export type { ExchangeCodeOptions, Principal, VerifyTokenOptions };
18
- //# sourceMappingURL=principal.d.ts.map
@@ -1 +0,0 @@
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,KA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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"]}
@@ -1,11 +0,0 @@
1
- import { type HeadersInit } from "@effect/platform-node/Undici";
2
- import { Effect, Redacted } from "effect";
3
- export declare const intTestConfig: Effect.Effect<{
4
- tenancyId: string;
5
- passkeyId: string;
6
- code: string;
7
- apiKey: Redacted.Redacted<string>;
8
- endpoint: string;
9
- }, import("effect/ConfigError").ConfigError, never>;
10
- export declare const getHeaderValue: (headers: HeadersInit, header: string) => string | null;
11
- //# sourceMappingURL=testUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAA;AACxE,OAAO,EAAiB,MAAM,EAAgB,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAkBtE,eAAO,MAAM,aAAa;;;;;;mDAQxB,CAAA;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,EAAE,QAAQ,MAAM,KAAG,MAAM,GAAG,IAc9E,CAAA"}
package/dist/testUtils.js DELETED
@@ -1,25 +0,0 @@
1
- import { Headers } from "@effect/platform-node/Undici";
2
- import { Array, Config, Effect, Option, pipe, Redacted } from "effect";
3
- const lookupTenancyId = pipe(Config.string("PASSLOCK_TENANCY_ID"), Config.withDefault("itTenancy"));
4
- const lookupPasskeyId = pipe(Config.string("PASSLOCK_PASSKEY_ID"), Config.withDefault("itPasskey"));
5
- const lookupCode = pipe(Config.string("PASSLOCK_PRINCIPAL_CODE"), Config.withDefault("itPrincipal"));
6
- const lookupApiKey = pipe(Config.redacted("PASSLOCK_API_KEY"), Config.withDefault(Redacted.make("itApiKey")));
7
- const lookupEndpoint = pipe(Config.string("PASSLOCK_ENDPOINT"), Config.withDefault("http://localhost:3000"));
8
- export const intTestConfig = Effect.gen(function* () {
9
- const tenancyId = yield* lookupTenancyId;
10
- const passkeyId = yield* lookupPasskeyId;
11
- const code = yield* lookupCode;
12
- const apiKey = yield* lookupApiKey;
13
- const endpoint = yield* lookupEndpoint;
14
- return { tenancyId, passkeyId, code, apiKey, endpoint };
15
- });
16
- export const getHeaderValue = (headers, header) => {
17
- if (headers instanceof Headers) {
18
- return headers.get(header);
19
- }
20
- if (Array.isArray(headers)) {
21
- return pipe(Array.findFirst(headers, ([k]) => k === header), Option.map(([_, v]) => v), Option.getOrNull);
22
- }
23
- return headers["authorization"] ?? null;
24
- };
25
- //# sourceMappingURL=testUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testUtils.js","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAoB,MAAM,8BAA8B,CAAA;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEtE,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAA;AAEnG,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAA;AAEnG,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,yBAAyB,CAAC,EAA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C,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EACzB,MAAM,CAAC,SAAS,CACjB,CAAA;IACH,CAAC;IAED,OAAO,OAAO,CAAC,eAAe,CAAC,IAAI,IAAI,CAAA;AACzC,CAAC,CAAA","sourcesContent":["import { Headers, type HeadersInit } from \"@effect/platform-node/Undici\"\nimport { Array, Config, Effect, Option, pipe, Redacted } from \"effect\"\n\nconst lookupTenancyId = pipe(Config.string(\"PASSLOCK_TENANCY_ID\"), Config.withDefault(\"itTenancy\"))\n\nconst lookupPasskeyId = pipe(Config.string(\"PASSLOCK_PASSKEY_ID\"), Config.withDefault(\"itPasskey\"))\n\nconst lookupCode = pipe(Config.string(\"PASSLOCK_PRINCIPAL_CODE\"), Config.withDefault(\"itPrincipal\"))\n\nconst lookupApiKey = pipe(\n Config.redacted(\"PASSLOCK_API_KEY\"),\n Config.withDefault(Redacted.make(\"itApiKey\"))\n)\n\nconst lookupEndpoint = pipe(\n Config.string(\"PASSLOCK_ENDPOINT\"),\n Config.withDefault(\"http://localhost:3000\")\n)\n\nexport const intTestConfig = Effect.gen(function* () {\n const tenancyId = yield* lookupTenancyId\n const passkeyId = yield* lookupPasskeyId\n const code = yield* lookupCode\n const apiKey = yield* lookupApiKey\n const endpoint = yield* lookupEndpoint\n\n return { tenancyId, passkeyId, code, apiKey, endpoint }\n})\n\nexport const getHeaderValue = (headers: HeadersInit, header: string): string | null => {\n if (headers instanceof Headers) {\n return headers.get(header)\n }\n\n if (Array.isArray(headers)) {\n return pipe(\n Array.findFirst(headers, ([k]) => k === header),\n Option.map(([_, v]) => v),\n Option.getOrNull\n )\n }\n\n return headers[\"authorization\"] ?? null\n}\n"]}
package/dist/unsafe.d.ts DELETED
@@ -1,55 +0,0 @@
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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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 DELETED
@@ -1,52 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"unsafe.js","sourceRoot":"","sources":["../src/unsafe.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EACL,UAAU,IAAI,WAAW,EACzB,aAAa,IAAI,cAAc,EAC/B,UAAU,IAAI,WAAW,EACzB,YAAY,IAAI,aAAa,GAC9B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,YAAY,IAAI,aAAa,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAA0B,EAAoB,EAAE,CACzE,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,EACV,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAEzF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,eAAuB,EACvB,OAAgC,EACd,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAErF;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAA2B,EAA4B,EAAE,CACpF,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,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,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"]}