@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,18 +1,20 @@
1
1
  import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse, } from "@effect/platform";
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";
6
- export const getPasskey = (authenticatorId, options, httpClient = FetchHttpClient.layer) => pipe(Effect.gen(function* () {
2
+ import { Chunk, Effect, Match, Option, pipe, Schema, Stream, } from "effect";
3
+ import { FindAllPasskeysSchema, Forbidden, NotFound } from "../schemas/index.js";
4
+ import { DeletedPasskeySchema, PasskeySchema, PasskeySummarySchema, } from "../schemas/passkey.js";
5
+ export const isPasskey = (payload) => Schema.is(PasskeySchema)(payload);
6
+ export const isPasskeySummary = (payload) => Schema.is(PasskeySummarySchema)(payload);
7
+ export const isDeletedPasskey = (payload) => Schema.is(DeletedPasskeySchema)(payload);
8
+ export const getPasskey = (options, httpClient = FetchHttpClient.layer) => pipe(Effect.gen(function* () {
7
9
  const client = yield* HttpClient.HttpClient;
8
10
  const baseUrl = options.endpoint ?? "https://api.passlock.dev";
9
- const { tenancyId } = options;
10
- const url = new URL(`/${tenancyId}/passkeys/${authenticatorId}`, baseUrl);
11
+ const { tenancyId, passkeyId } = options;
12
+ const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl);
11
13
  const response = yield* HttpClientRequest.get(url, {
12
14
  headers: { Authorization: `Bearer ${options.apiKey}` },
13
15
  }).pipe(client.execute);
14
16
  const encoded = yield* HttpClientResponse.matchStatus(response, {
15
- "2xx": () => HttpClientResponse.schemaBodyJson(Passkey)(response),
17
+ "2xx": () => HttpClientResponse.schemaBodyJson(PasskeySchema)(response),
16
18
  orElse: () => HttpClientResponse.schemaBodyJson(Schema.Union(Forbidden, NotFound))(response),
17
19
  });
18
20
  return yield* pipe(Match.value(encoded), Match.tag("Passkey", (data) => Effect.succeed(data)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.tag("@error/NotFound", (err) => Effect.fail(err)), Match.exhaustive);
@@ -21,16 +23,16 @@ export const getPasskey = (authenticatorId, options, httpClient = FetchHttpClien
21
23
  RequestError: (err) => Effect.die(err),
22
24
  ResponseError: (err) => Effect.die(err),
23
25
  }), Effect.provide(httpClient));
24
- export const deletePasskey = (passkeyId, request, httpClient = FetchHttpClient.layer) => pipe(Effect.gen(function* () {
26
+ export const deletePasskey = (options, httpClient = FetchHttpClient.layer) => pipe(Effect.gen(function* () {
25
27
  const client = yield* HttpClient.HttpClient;
26
- const baseUrl = request.endpoint ?? "https://api.passlock.dev";
27
- const { tenancyId } = request;
28
+ const baseUrl = options.endpoint ?? "https://api.passlock.dev";
29
+ const { tenancyId, passkeyId } = options;
28
30
  const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl);
29
31
  const response = yield* HttpClientRequest.del(url, {
30
- headers: { Authorization: `Bearer ${request.apiKey}` },
32
+ headers: { Authorization: `Bearer ${options.apiKey}` },
31
33
  }).pipe(client.execute);
32
34
  const encoded = yield* HttpClientResponse.matchStatus(response, {
33
- "2xx": () => HttpClientResponse.schemaBodyJson(DeletedPasskey)(response),
35
+ "2xx": () => HttpClientResponse.schemaBodyJson(DeletedPasskeySchema)(response),
34
36
  orElse: () => HttpClientResponse.schemaBodyJson(Schema.Union(Forbidden, NotFound))(response),
35
37
  });
36
38
  return yield* pipe(Match.value(encoded), Match.tag("DeletedPasskey", (deletedPasskey) => Effect.succeed(deletedPasskey)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.tag("@error/NotFound", (err) => Effect.fail(err)), Match.exhaustive);
@@ -39,17 +41,38 @@ export const deletePasskey = (passkeyId, request, httpClient = FetchHttpClient.l
39
41
  RequestError: (err) => Effect.die(err),
40
42
  ResponseError: (err) => Effect.die(err),
41
43
  }), Effect.provide(httpClient));
42
- export const assignUser = (request, httpClient = FetchHttpClient.layer) => pipe(Effect.gen(function* () {
44
+ // TODO reuse updatePasskey
45
+ export const assignUser = (options, httpClient = FetchHttpClient.layer) => pipe(Effect.gen(function* () {
43
46
  const client = yield* HttpClient.HttpClient;
44
- const baseUrl = request.endpoint ?? "https://api.passlock.dev";
45
- const { userId, passkeyId } = request;
46
- const { tenancyId } = request;
47
+ const baseUrl = options.endpoint ?? "https://api.passlock.dev";
48
+ const { userId, passkeyId } = options;
49
+ const { tenancyId } = options;
47
50
  const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl);
48
51
  const response = yield* HttpClientRequest.patch(url, {
49
- headers: { Authorization: `Bearer ${request.apiKey}` },
52
+ headers: { Authorization: `Bearer ${options.apiKey}` },
50
53
  }).pipe(HttpClientRequest.bodyJson({ userId }), Effect.flatMap(client.execute));
51
54
  const encoded = yield* HttpClientResponse.matchStatus(response, {
52
- "2xx": () => HttpClientResponse.schemaBodyJson(Passkey)(response),
55
+ "2xx": () => HttpClientResponse.schemaBodyJson(PasskeySchema)(response),
56
+ orElse: () => HttpClientResponse.schemaBodyJson(Schema.Union(NotFound, Forbidden))(response),
57
+ });
58
+ return yield* pipe(Match.value(encoded), Match.tag("Passkey", (passkey) => Effect.succeed(passkey)), Match.tag("@error/NotFound", (err) => Effect.fail(err)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.exhaustive);
59
+ }), Effect.catchTags({
60
+ HttpBodyError: (err) => Effect.die(err),
61
+ ParseError: (err) => Effect.die(err),
62
+ RequestError: (err) => Effect.die(err),
63
+ ResponseError: (err) => Effect.die(err),
64
+ }), Effect.provide(httpClient));
65
+ export const updatePasskey = (options, httpClient = FetchHttpClient.layer) => pipe(Effect.gen(function* () {
66
+ const client = yield* HttpClient.HttpClient;
67
+ const baseUrl = options.endpoint ?? "https://api.passlock.dev";
68
+ const { userId, passkeyId, username } = options;
69
+ const { tenancyId } = options;
70
+ const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl);
71
+ const response = yield* HttpClientRequest.patch(url, {
72
+ headers: { Authorization: `Bearer ${options.apiKey}` },
73
+ }).pipe(HttpClientRequest.bodyJson({ userId, username }), Effect.flatMap(client.execute));
74
+ const encoded = yield* HttpClientResponse.matchStatus(response, {
75
+ "2xx": () => HttpClientResponse.schemaBodyJson(PasskeySchema)(response),
53
76
  orElse: () => HttpClientResponse.schemaBodyJson(Schema.Union(NotFound, Forbidden))(response),
54
77
  });
55
78
  return yield* pipe(Match.value(encoded), Match.tag("Passkey", (passkey) => Effect.succeed(passkey)), Match.tag("@error/NotFound", (err) => Effect.fail(err)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.exhaustive);
@@ -59,6 +82,7 @@ export const assignUser = (request, httpClient = FetchHttpClient.layer) => pipe(
59
82
  RequestError: (err) => Effect.die(err),
60
83
  ResponseError: (err) => Effect.die(err),
61
84
  }), Effect.provide(httpClient));
85
+ /* List Passkeys */
62
86
  export const listPasskeysStream = (options, httpClient = FetchHttpClient.layer) => pipe(Stream.paginateChunkEffect(null, (cursor) => pipe(listPasskeys(cursor ? { ...options, cursor } : options, httpClient), Effect.map((result) => [
63
87
  Chunk.fromIterable(result.records),
64
88
  Option.fromNullable(result.cursor),
@@ -75,7 +99,7 @@ export const listPasskeys = (options, httpClient = FetchHttpClient.layer) => pip
75
99
  headers: { Authorization: `Bearer ${options.apiKey}` },
76
100
  }).pipe(client.execute);
77
101
  const encoded = yield* HttpClientResponse.matchStatus(response, {
78
- "2xx": () => HttpClientResponse.schemaBodyJson(FindAllPasskeys)(response),
102
+ "2xx": () => HttpClientResponse.schemaBodyJson(FindAllPasskeysSchema)(response),
79
103
  orElse: () => HttpClientResponse.schemaBodyJson(Forbidden)(response),
80
104
  });
81
105
  return yield* pipe(Match.value(encoded), Match.tag("FindAllPasskeys", (data) => Effect.succeed(data)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.exhaustive);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passkey.js","sourceRoot":"","sources":["../../src/passkey/passkey.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,KAAK,EACL,MAAM,EAEN,KAAK,EACL,MAAM,EACN,IAAI,EACJ,MAAM,EACN,MAAM,GACP,MAAM,QAAQ,CAAA;AAEf,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAEL,oBAAoB,EACpB,aAAa,EACb,oBAAoB,GAErB,MAAM,uBAAuB,CAAA;AA4D9B,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAsB,EAAE,CAChE,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAA;AAqBnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAA6B,EAAE,CAC9E,MAAM,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,CAAA;AAiC1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAA6B,EAAE,CAC9E,MAAM,CA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AAY,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 {\n FetchHttpClient,\n HttpClient,\n HttpClientRequest,\n HttpClientResponse,\n} from \"@effect/platform\"\n\nimport {\n Chunk,\n Effect,\n type Layer,\n Match,\n Option,\n pipe,\n Schema,\n Stream,\n} from \"effect\"\nimport type { satisfy } from \"src/schemas/satisfy.js\"\nimport { FindAllPasskeysSchema, Forbidden, NotFound } from \"../schemas/index.js\"\nimport {\n type CredentialDeviceType,\n DeletedPasskeySchema,\n PasskeySchema,\n PasskeySummarySchema,\n type Transports,\n} from \"../schemas/passkey.js\"\nimport type { AuthenticatedOptions } from \"../shared.js\"\n\n/**\n * WebAuthn specific passkey data\n */\nexport type Credential = {\n id: string\n userId: string\n username: string\n aaguid: string\n backedUp: boolean\n counter: number\n deviceType: CredentialDeviceType\n transports: ReadonlyArray<Transports>\n publicKey: Uint8Array<ArrayBufferLike>\n}\n\n/**\n * Passkeys are usually synced across devices **but only within\n * a specific platform/ecosystem** e.g. a passkey created on Apple\n * devices would typically be synced across devices sharing the same\n * iCloud ID.\n *\n * However, if the user also wants to sign in from their Windows\n * or Android/Chrome devices they will need an additional passkey.\n * Therefore when listing the passkeys registered to a user's account\n * it's a good idea to tell them which platform the passkeys relate to.\n *\n * We've also included links to icons (SVG) so you can give your users\n * a quick visual indication.\n */\nexport type Platform = {\n name?: string | undefined\n icon?: string | undefined\n}\n\n/**\n * The server-side component of a passkey\n *\n * @category Passkeys\n */\nexport type Passkey = {\n _tag: \"Passkey\"\n /**\n * Not to be confused with the credential.id\n */\n id: string\n /**\n * Not to be confused with the credential.userId\n */\n userId?: string | undefined\n enabled: boolean\n credential: Credential\n platform?: Platform | undefined\n lastUsed?: number | undefined\n createdAt: number\n updatedAt: number\n}\n\nexport const isPasskey = (payload: unknown): payload is Passkey =>\n Schema.is(PasskeySchema)(payload)\n\n/**\n * needed to ensure the Passkey === Passkey.Type\n * @internal\n * */\nexport type _Passkey = satisfy<typeof PasskeySchema.Type, Passkey>\n\nexport type PasskeySummary = {\n readonly _tag: \"PasskeySummary\"\n readonly id: string\n readonly userId: string\n readonly enabled: boolean\n readonly credential: {\n readonly id: string\n readonly userId: string\n }\n readonly lastUsed?: number | undefined\n readonly createdAt: number\n}\n\nexport const isPasskeySummary = (payload: unknown): payload is PasskeySummary =>\n Schema.is(PasskeySummarySchema)(payload)\n\n/**\n * needed to ensure the PasskeySummary === PasskeySummary.Type\n * @internal\n */\nexport type _PasskeySummary = satisfy<\n typeof PasskeySummarySchema.Type,\n PasskeySummary\n>\n\nexport type FindAllPasskeys = {\n readonly _tag: \"FindAllPasskeys\"\n readonly cursor: string | null\n readonly records: ReadonlyArray<PasskeySummary>\n}\n\n/**\n * needed to ensure the FindAllPasskeys === FindAllPasskeys.Type\n * @internal\n */\nexport type _FindAllPasskeys = satisfy<\n typeof FindAllPasskeysSchema.Type,\n FindAllPasskeys\n>\n\nexport type DeletedPasskey = {\n readonly _tag: \"DeletedPasskey\"\n readonly id: string\n readonly credentialId: string\n readonly rpId: string\n}\n\nexport const isDeletedPasskey = (payload: unknown): payload is DeletedPasskey =>\n Schema.is(DeletedPasskeySchema)(payload)\n\n/**\n * needed to ensure the DeletedPasskey === DeletedPasskey.Type\n * @internal\n */\nexport type _DeletedPasskey = satisfy<\n typeof DeletedPasskeySchema.Type,\n DeletedPasskey\n>\n\n/* Get Passkey */\n\nexport interface GetPasskeyOptions extends AuthenticatedOptions {\n passkeyId: string\n}\n\nexport const getPasskey = (\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, passkeyId } = options\n\n const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, 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(PasskeySchema)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(Schema.Union(Forbidden, NotFound))(\n response\n ),\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\n/* Delete Passkey */\n\nexport interface DeletePasskeyOptions extends AuthenticatedOptions {\n passkeyId: string\n}\n\nexport const deletePasskey = (\n options: DeletePasskeyOptions,\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 = options.endpoint ?? \"https://api.passlock.dev\"\n const { tenancyId, passkeyId } = options\n\n const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl)\n\n const response = yield* HttpClientRequest.del(url, {\n headers: { Authorization: `Bearer ${options.apiKey}` },\n }).pipe(client.execute)\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () =>\n HttpClientResponse.schemaBodyJson(DeletedPasskeySchema)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(Schema.Union(Forbidden, NotFound))(\n response\n ),\n })\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"DeletedPasskey\", (deletedPasskey) =>\n Effect.succeed(deletedPasskey)\n ),\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\n/* Assign User */\n\n/**\n * @category Passkeys\n */\nexport interface AssignUserOptions extends AuthenticatedOptions {\n passkeyId: string\n\n /**\n * Custom User ID to align with your own systems\n */\n userId: string\n}\n\n// TODO reuse updatePasskey\nexport const assignUser = (\n options: AssignUserOptions,\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 { userId, passkeyId } = options\n const { tenancyId } = options\n\n const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl)\n\n const response = yield* HttpClientRequest.patch(url, {\n headers: { Authorization: `Bearer ${options.apiKey}` },\n }).pipe(\n HttpClientRequest.bodyJson({ userId }),\n Effect.flatMap(client.execute)\n )\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () => HttpClientResponse.schemaBodyJson(PasskeySchema)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(Schema.Union(NotFound, Forbidden))(\n response\n ),\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 interface UpdatePasskeyOptions extends AuthenticatedOptions {\n passkeyId: string\n userId?: string\n username?: string\n}\n\nexport const updatePasskey = (\n options: UpdatePasskeyOptions,\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 { userId, passkeyId, username } = options\n const { tenancyId } = options\n\n const url = new URL(`/${tenancyId}/passkeys/${passkeyId}`, baseUrl)\n\n const response = yield* HttpClientRequest.patch(url, {\n headers: { Authorization: `Bearer ${options.apiKey}` },\n }).pipe(\n HttpClientRequest.bodyJson({ userId, username }),\n Effect.flatMap(client.execute)\n )\n\n const encoded = yield* HttpClientResponse.matchStatus(response, {\n \"2xx\": () => HttpClientResponse.schemaBodyJson(PasskeySchema)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(Schema.Union(NotFound, Forbidden))(\n response\n ),\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\n/* List Passkeys */\n\nexport const listPasskeysStream = (\n options: AuthenticatedOptions,\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 interface ListPasskeyOptions extends AuthenticatedOptions {\n cursor?: string\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\": () =>\n HttpClientResponse.schemaBodyJson(FindAllPasskeysSchema)(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"]}
@@ -0,0 +1,22 @@
1
+ import { HttpClient } from "@effect/platform";
2
+ import { Effect, type Layer } from "effect";
3
+ import { Forbidden, InvalidCode } from "../schemas/errors.js";
4
+ import { type ExtendedPrincipal, type Principal } from "../schemas/principal.js";
5
+ import type { AuthenticatedOptions, PasslockOptions } from "../shared.js";
6
+ export interface ExchangeCodeOptions extends AuthenticatedOptions {
7
+ code: string;
8
+ }
9
+ export declare const exchangeCode: (options: ExchangeCodeOptions, httpClient?: Layer.Layer<HttpClient.HttpClient>) => Effect.Effect<ExtendedPrincipal, InvalidCode | Forbidden>;
10
+ 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 & {
11
+ readonly _tag: "@error/VerificationFailure";
12
+ } & Readonly<A>;
13
+ export declare class VerificationFailure extends VerificationFailure_base<{
14
+ message: string;
15
+ }> {
16
+ }
17
+ export interface VerifyIdTokenOptions extends PasslockOptions {
18
+ token: string;
19
+ }
20
+ export declare const verifyIdToken: (options: VerifyIdTokenOptions) => Effect.Effect<Principal, VerificationFailure>;
21
+ export {};
22
+ //# sourceMappingURL=principal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"principal.d.ts","sourceRoot":"","sources":["../../src/principal/principal.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAEX,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAQ,MAAM,EAAE,KAAK,KAAK,EAAuB,MAAM,QAAQ,CAAA;AAGtE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAE7D,OAAO,EACL,KAAK,iBAAiB,EAGtB,KAAK,SAAS,EACf,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEzE,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,IAAI,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,YAAY,GACvB,SAAS,mBAAmB,EAC5B,aAAY,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAyB,KACrE,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,WAAW,GAAG,SAAS,CAwCxD,CAAA;;;;AAcH,qBAAa,mBAAoB,SAAQ,yBAEvC;IACA,OAAO,EAAE,MAAM,CAAA;CAChB,CAAC;CAAG;AAEL,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,KAAK,EAAE,MAAM,CAAA;CACd;AAED,eAAO,MAAM,aAAa,GACxB,SAAS,oBAAoB,KAC5B,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,mBAAmB,CAyC5C,CAAA"}
@@ -1,18 +1,18 @@
1
- import { FetchHttpClient, HttpClient, HttpClientResponse } from "@effect/platform";
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";
6
- export const exchangeCode = (code, options, httpClient = FetchHttpClient.layer) => pipe(Effect.gen(function* () {
4
+ import { Forbidden, InvalidCode } from "../schemas/errors.js";
5
+ import { ExtendedPrincipalSchema, IdTokenSchema, } from "../schemas/principal.js";
6
+ export const exchangeCode = (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";
9
- const { tenancyId } = options;
9
+ const { tenancyId, code } = options;
10
10
  const url = new URL(`/${tenancyId}/principal/${code}`, baseUrl);
11
11
  const response = yield* pipe(client.get(url, {
12
12
  headers: { Authorization: `Bearer ${options.apiKey}` },
13
13
  }));
14
14
  const encoded = yield* HttpClientResponse.matchStatus(response, {
15
- "2xx": () => HttpClientResponse.schemaBodyJson(ExtendedPrincipal)(response),
15
+ "2xx": () => HttpClientResponse.schemaBodyJson(ExtendedPrincipalSchema)(response),
16
16
  orElse: () => HttpClientResponse.schemaBodyJson(Schema.Union(InvalidCode, Forbidden))(response),
17
17
  });
18
18
  return yield* pipe(Match.value(encoded), Match.tag("ExtendedPrincipal", (principal) => Effect.succeed(principal)), Match.tag("@error/InvalidCode", (err) => Effect.fail(err)), Match.tag("@error/Forbidden", (err) => Effect.fail(err)), Match.exhaustive);
@@ -28,7 +28,7 @@ const createJwks = (endpoint) => Effect.sync(() => {
28
28
  const createCachedRemoteJwks = pipe(Effect.cachedFunction(createJwks), Effect.runSync);
29
29
  export class VerificationFailure extends Data.TaggedError("@error/VerificationFailure") {
30
30
  }
31
- export const verifyIdToken = (token, options) => pipe(Effect.gen(function* () {
31
+ export const verifyIdToken = (options) => pipe(Effect.gen(function* () {
32
32
  const JWKS = yield* createCachedRemoteJwks(options.endpoint);
33
33
  const { payload } = yield* Effect.tryPromise({
34
34
  catch: (err) => {
@@ -37,12 +37,12 @@ export const verifyIdToken = (token, options) => pipe(Effect.gen(function* () {
37
37
  ? new VerificationFailure({ message: err.message })
38
38
  : new VerificationFailure({ message: String(err) });
39
39
  },
40
- try: () => jose.jwtVerify(token, JWKS, {
40
+ try: () => jose.jwtVerify(options.token, JWKS, {
41
41
  audience: options.tenancyId,
42
42
  issuer: "passlock.dev",
43
43
  }),
44
44
  });
45
- const idToken = yield* Schema.decodeUnknown(IdToken)({
45
+ const idToken = yield* Schema.decodeUnknown(IdTokenSchema)({
46
46
  ...payload,
47
47
  _tag: "IdToken",
48
48
  });
@@ -0,0 +1 @@
1
+ {"version":3,"file":"principal.js","sourceRoot":"","sources":["../../src/principal/principal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,kBAAkB,GACnB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAc,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEtE,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAE7D,OAAO,EAEL,uBAAuB,EACvB,aAAa,GAEd,MAAM,yBAAyB,CAAA;AAQhC,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAA4B,EAC5B,aAAiD,eAAe,CAAC,KAAK,EACX,EAAE,CAC7D,IAAI,CACF,MAAM,CAAC,GAAG,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pipe, Schema } from \"effect\"\n\nimport * as jose from \"jose\"\nimport { Forbidden, InvalidCode } from \"../schemas/errors.js\"\n\nimport {\n type ExtendedPrincipal,\n ExtendedPrincipalSchema,\n IdTokenSchema,\n type Principal,\n} from \"../schemas/principal.js\"\n\nimport type { AuthenticatedOptions, PasslockOptions } from \"../shared.js\"\n\nexport interface ExchangeCodeOptions extends AuthenticatedOptions {\n code: string\n}\n\nexport const exchangeCode = (\n options: ExchangeCodeOptions,\n 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, code } = 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\": () =>\n HttpClientResponse.schemaBodyJson(ExtendedPrincipalSchema)(response),\n orElse: () =>\n HttpClientResponse.schemaBodyJson(\n Schema.Union(InvalidCode, Forbidden)\n )(response),\n })\n\n return yield* pipe(\n Match.value(encoded),\n Match.tag(\"ExtendedPrincipal\", (principal) =>\n Effect.succeed(principal)\n ),\n Match.tag(\"@error/InvalidCode\", (err) => Effect.fail(err)),\n Match.tag(\"@error/Forbidden\", (err) => Effect.fail(err)),\n Match.exhaustive\n )\n }),\n Effect.catchTags({\n ParseError: (err) => Effect.die(err),\n RequestError: (err) => Effect.die(err),\n ResponseError: (err) => Effect.die(err),\n }),\n Effect.provide(httpClient)\n )\n\nconst createJwks = (endpoint?: string) =>\n Effect.sync(() => {\n const baseUrl = endpoint ?? \"https://api.passlock.dev\"\n\n return jose.createRemoteJWKSet(new URL(\"/.well-known/jwks.json\", baseUrl))\n })\n\nconst createCachedRemoteJwks = pipe(\n Effect.cachedFunction(createJwks),\n Effect.runSync\n)\n\nexport class VerificationFailure extends Data.TaggedError(\n \"@error/VerificationFailure\"\n)<{\n message: string\n}> {}\n\nexport interface VerifyIdTokenOptions extends PasslockOptions {\n token: string\n}\n\nexport const verifyIdToken = (\n options: VerifyIdTokenOptions\n): Effect.Effect<Principal, 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(options.token, JWKS, {\n audience: options.tenancyId,\n issuer: \"passlock.dev\",\n }),\n })\n\n const idToken = yield* Schema.decodeUnknown(IdTokenSchema)({\n ...payload,\n _tag: \"IdToken\",\n })\n\n const principal: Principal = {\n _tag: \"Principal\",\n id: idToken[\"jti\"],\n authenticatorId: idToken[\"a:id\"],\n authenticatorType: \"passkey\",\n createdAt: idToken.iat * 1000,\n expiresAt: idToken.exp * 1000,\n passkey: {\n userVerified: idToken[\"pk:uv\"],\n verified: true,\n },\n userId: idToken.sub,\n }\n\n return principal\n }),\n Effect.catchTag(\"ParseError\", (err) => Effect.die(err))\n )\n"]}
package/dist/safe.d.ts ADDED
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Safe functions that don't throw but instead
3
+ * return a discriminated union of types representing
4
+ * the successful outcome or failures.
5
+ *
6
+ * @categoryDescription Passkeys
7
+ * Functions and related types for managing passkeys
8
+ *
9
+ * @showCategories
10
+ *
11
+ * @module safe
12
+ */
13
+ import type { Forbidden, InvalidCode, NotFound, VerificationFailure } from "./errors.js";
14
+ import type { AssignUserOptions, DeletedPasskey, DeletePasskeyOptions, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey, UpdatePasskeyOptions } from "./passkey/passkey.js";
15
+ import type { ExchangeCodeOptions, VerifyIdTokenOptions } from "./principal/principal.js";
16
+ import type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
17
+ /**
18
+ * Assign a custom User ID to a passkey. Will be reflected in the next
19
+ * {@link Principal} or {@link ExtendedPrincipal} generated.
20
+ *
21
+ * **Note:** This does not change the underlying WebAuthn credential's userID.
22
+ * Instead we apply a layer of indirection.
23
+ *
24
+ * @see {@link Principal}
25
+ * @see {@link ExtendedPrincipal}
26
+ * @see [credential](https://passlock.dev/rest-api/credential/)
27
+ *
28
+ * @param request
29
+ * @returns A promise resolving to either a passkey or an API error.
30
+ *
31
+ * @category Passkeys
32
+ */
33
+ export declare const assignUser: (request: AssignUserOptions) => Promise<Passkey | NotFound | Forbidden>;
34
+ /**
35
+ * Can also be used to assign a custom User ID, but also allows you to update
36
+ * the username.
37
+ *
38
+ * **Important:** changing the username has no bearing on authentication, as
39
+ * it's typically only used in the client-side component of the passkey
40
+ * (so the user knows which account the passkey relates to).
41
+ *
42
+ * However you might choose to align the username in your vault with the
43
+ * client-side component to simplify end user support.
44
+ *
45
+ * @param request
46
+ * @returns A promise resolving to either a passkey or an API error.
47
+ *
48
+ * @category Passkeys
49
+ */
50
+ export declare const updatePasskey: (request: UpdatePasskeyOptions) => Promise<Passkey | NotFound | Forbidden>;
51
+ /**
52
+ * Delete a passkey from your vault.
53
+ *
54
+ * **Note:** The user will still retain the passkey on their device so
55
+ * you will need to either:
56
+ *
57
+ * a) Use the @passlock/client functions to delete the passkey from the user's device.
58
+ * b) Remind the user to delete the passkey
59
+ *
60
+ * See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) in the documentation.
61
+ *
62
+ * In addition, during authentication you should handle a missing passkey scenario.
63
+ * This happens when a user tries to authenticate with a passkey that is missing from
64
+ * your vault. The @passlock/client library can help with this. See
65
+ * [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)
66
+ *
67
+ * @see [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/)
68
+ * @see [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)
69
+ *
70
+ * @param options
71
+ * @returns A promise resolving to either deleted-passkey details or an API error.
72
+ *
73
+ * @category Passkeys
74
+ */
75
+ export declare const deletePasskey: (options: DeletePasskeyOptions) => Promise<DeletedPasskey | Forbidden | NotFound>;
76
+ /**
77
+ * Fetch details about a passkey. **Important**: Not to be confused with
78
+ * the {@link exchangeCode} or {@link verifyIdToken} functions, which
79
+ * return details about specific authentication or registration operations.
80
+ * Use this function for passkey management, not authentication.
81
+ *
82
+ * @param options
83
+ * @returns A promise resolving to either passkey details or an API error.
84
+ *
85
+ * @category Passkeys
86
+ */
87
+ export declare const getPasskey: (options: GetPasskeyOptions) => Promise<Passkey | Forbidden | NotFound>;
88
+ /**
89
+ * List passkeys for the given tenancy. Note: This could return a cursor.
90
+ * If so, call again, passing the cursor back in.
91
+ *
92
+ * @param options
93
+ * @returns A promise resolving to a page of passkey summaries or an API error.
94
+ *
95
+ * @category Passkeys
96
+ */
97
+ export declare const listPasskeys: (options: ListPasskeyOptions) => Promise<FindAllPasskeys | Forbidden>;
98
+ /**
99
+ * The @passlock/client library generates codes, which you should send to
100
+ * your backend. Use this function to exchange the code for details about
101
+ * the registration or authentication operation. **Note:** a code is valid
102
+ * for 5 minutes.
103
+ *
104
+ * @see {@link ExtendedPrincipal}
105
+ *
106
+ * @param options
107
+ * @returns A promise resolving to an extended principal or an API error.
108
+ *
109
+ * @category Principal
110
+ */
111
+ export declare const exchangeCode: (options: ExchangeCodeOptions) => Promise<ExtendedPrincipal | Forbidden | InvalidCode>;
112
+ /**
113
+ * Decode and verify an id_token (JWT) locally.
114
+ * **Note:** This will make a network call to the passlock.dev/.well-known/jwks.json
115
+ * endpoint to fetch the relevant public key. The response will be cached, however
116
+ * bear in mind that for something like AWS lambda it will make the call on every
117
+ * cold start so might actually be slower than {@link exchangeCode}
118
+ *
119
+ * @see {@link Principal}
120
+ *
121
+ * @param options
122
+ * @returns A promise resolving to a verified principal or verification failure.
123
+ *
124
+ * @category Principal
125
+ */
126
+ export declare const verifyIdToken: (options: VerifyIdTokenOptions) => Promise<Principal | VerificationFailure>;
127
+ export type { BadRequest, DuplicateEmail, Forbidden, InvalidCode, InvalidEmail, InvalidTenancy, NotFound, PasskeyNotFound, Unauthorized, VerificationFailure, } from "./errors.js";
128
+ export { isBadRequest, isDuplicateEmail, isForbidden, isInvalidCode, isInvalidEmail, isInvalidTenancy, isNotFound, isPasskeyNotFound, isUnauthorized, isVerificationFailure, } from "./errors.js";
129
+ export type { AssignUserOptions, Credential, DeletedPasskey, DeletePasskeyOptions, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey, PasskeySummary, Platform, UpdatePasskeyOptions, } from "./passkey/passkey.js";
130
+ export { isDeletedPasskey, isPasskey, isPasskeySummary, } from "./passkey/passkey.js";
131
+ export type { ExchangeCodeOptions, VerifyIdTokenOptions, } from "./principal/principal.js";
132
+ export type { CredentialDeviceType, Transports, } from "./schemas/passkey.js";
133
+ export type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
134
+ export { isExtendedPrincipal, isPrincipal } from "./schemas/principal.js";
135
+ export type { AuthenticatedOptions, PasslockOptions, } from "./shared.js";
136
+ //# sourceMappingURL=safe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../src/safe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,QAAQ,EACR,mBAAmB,EACpB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,OAAO,EACP,oBAAoB,EACrB,MAAM,sBAAsB,CAAA;AAQ7B,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,0BAA0B,CAAA;AAKjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAE1E;;;;;;;;;;;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,EACjB,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,OAAO,EACP,cAAc,EACd,QAAQ,EACR,oBAAoB,GACrB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,gBAAgB,GACjB,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EACV,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,0BAA0B,CAAA;AACjC,YAAY,EACV,oBAAoB,EACpB,UAAU,GACX,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAC1E,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzE,YAAY,EACV,oBAAoB,EACpB,eAAe,GAChB,MAAM,aAAa,CAAA"}
package/dist/safe.js ADDED
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Safe functions that don't throw but instead
3
+ * return a discriminated union of types representing
4
+ * the successful outcome or failures.
5
+ *
6
+ * @categoryDescription Passkeys
7
+ * Functions and related types for managing passkeys
8
+ *
9
+ * @showCategories
10
+ *
11
+ * @module safe
12
+ */
13
+ import { FetchHttpClient } from "@effect/platform";
14
+ import { Effect, identity, pipe } from "effect";
15
+ import { assignUser as assignUserE, deletePasskey as deletePasskeyE, getPasskey as getPasskeyE, listPasskeys as listPasskeysE, updatePasskey as updatePasskeyE, } from "./passkey/passkey.js";
16
+ import { exchangeCode as exchangeCodeE, verifyIdToken as verifyIdTokenE, } from "./principal/principal.js";
17
+ /**
18
+ * Assign a custom User ID to a passkey. Will be reflected in the next
19
+ * {@link Principal} or {@link ExtendedPrincipal} generated.
20
+ *
21
+ * **Note:** This does not change the underlying WebAuthn credential's userID.
22
+ * Instead we apply a layer of indirection.
23
+ *
24
+ * @see {@link Principal}
25
+ * @see {@link ExtendedPrincipal}
26
+ * @see [credential](https://passlock.dev/rest-api/credential/)
27
+ *
28
+ * @param request
29
+ * @returns A promise resolving to either a passkey or an API error.
30
+ *
31
+ * @category Passkeys
32
+ */
33
+ export const assignUser = (request) => pipe(assignUserE(request), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
34
+ /**
35
+ * Can also be used to assign a custom User ID, but also allows you to update
36
+ * the username.
37
+ *
38
+ * **Important:** changing the username has no bearing on authentication, as
39
+ * it's typically only used in the client-side component of the passkey
40
+ * (so the user knows which account the passkey relates to).
41
+ *
42
+ * However you might choose to align the username in your vault with the
43
+ * client-side component to simplify end user support.
44
+ *
45
+ * @param request
46
+ * @returns A promise resolving to either a passkey or an API error.
47
+ *
48
+ * @category Passkeys
49
+ */
50
+ export const updatePasskey = (request) => pipe(updatePasskeyE(request), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
51
+ /**
52
+ * Delete a passkey from your vault.
53
+ *
54
+ * **Note:** The user will still retain the passkey on their device so
55
+ * you will need to either:
56
+ *
57
+ * a) Use the @passlock/client functions to delete the passkey from the user's device.
58
+ * b) Remind the user to delete the passkey
59
+ *
60
+ * See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) in the documentation.
61
+ *
62
+ * In addition, during authentication you should handle a missing passkey scenario.
63
+ * This happens when a user tries to authenticate with a passkey that is missing from
64
+ * your vault. The @passlock/client library can help with this. See
65
+ * [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)
66
+ *
67
+ * @see [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/)
68
+ * @see [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)
69
+ *
70
+ * @param options
71
+ * @returns A promise resolving to either deleted-passkey details or an API error.
72
+ *
73
+ * @category Passkeys
74
+ */
75
+ export const deletePasskey = (options) => pipe(deletePasskeyE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
76
+ /**
77
+ * Fetch details about a passkey. **Important**: Not to be confused with
78
+ * the {@link exchangeCode} or {@link verifyIdToken} functions, which
79
+ * return details about specific authentication or registration operations.
80
+ * Use this function for passkey management, not authentication.
81
+ *
82
+ * @param options
83
+ * @returns A promise resolving to either passkey details or an API error.
84
+ *
85
+ * @category Passkeys
86
+ */
87
+ export const getPasskey = (options) => pipe(getPasskeyE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
88
+ /**
89
+ * List passkeys for the given tenancy. Note: This could return a cursor.
90
+ * If so, call again, passing the cursor back in.
91
+ *
92
+ * @param options
93
+ * @returns A promise resolving to a page of passkey summaries or an API error.
94
+ *
95
+ * @category Passkeys
96
+ */
97
+ export const listPasskeys = (options) => pipe(listPasskeysE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
98
+ /**
99
+ * The @passlock/client library generates codes, which you should send to
100
+ * your backend. Use this function to exchange the code for details about
101
+ * the registration or authentication operation. **Note:** a code is valid
102
+ * for 5 minutes.
103
+ *
104
+ * @see {@link ExtendedPrincipal}
105
+ *
106
+ * @param options
107
+ * @returns A promise resolving to an extended principal or an API error.
108
+ *
109
+ * @category Principal
110
+ */
111
+ export const exchangeCode = (options) => pipe(exchangeCodeE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.provide(FetchHttpClient.layer), Effect.runPromise);
112
+ /**
113
+ * Decode and verify an id_token (JWT) locally.
114
+ * **Note:** This will make a network call to the passlock.dev/.well-known/jwks.json
115
+ * endpoint to fetch the relevant public key. The response will be cached, however
116
+ * bear in mind that for something like AWS lambda it will make the call on every
117
+ * cold start so might actually be slower than {@link exchangeCode}
118
+ *
119
+ * @see {@link Principal}
120
+ *
121
+ * @param options
122
+ * @returns A promise resolving to a verified principal or verification failure.
123
+ *
124
+ * @category Principal
125
+ */
126
+ export const verifyIdToken = (options) => pipe(verifyIdTokenE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
127
+ export { isBadRequest, isDuplicateEmail, isForbidden, isInvalidCode, isInvalidEmail, isInvalidTenancy, isNotFound, isPasskeyNotFound, isUnauthorized, isVerificationFailure, } from "./errors.js";
128
+ export { isDeletedPasskey, isPasskey, isPasskeySummary, } from "./passkey/passkey.js";
129
+ export { isExtendedPrincipal, isPrincipal } from "./schemas/principal.js";
130
+ //# sourceMappingURL=safe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe.js","sourceRoot":"","sources":["../src/safe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAiB/C,OAAO,EACL,UAAU,IAAI,WAAW,EACzB,aAAa,IAAI,cAAc,EAC/B,UAAU,IAAI,WAAW,EACzB,YAAY,IAAI,aAAa,EAC7B,aAAa,IAAI,cAAc,GAChC,MAAM,sBAAsB,CAAA;AAK7B,OAAO,EACL,YAAY,IAAI,aAAa,EAC7B,aAAa,IAAI,cAAc,GAChC,MAAM,0BAA0B,CAAA;AAGjC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,OAA0B,EACe,EAAE,CAC3C,IAAI,CACF,WAAW,CAAC,OAAO,CAAC,EACpB,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAC1D,MAAM,CAAC,UAAU,CAClB,CAAA;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAA6B,EACY,EAAE,CAC3C,IAAI,CACF,cAAc,CAAC,OAAO,CAAC,EACvB,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAC1D,MAAM,CAAC,UAAU,CAClB,CAAA;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAA6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MAAM,CAAC,UAAU,CAClB,CAAA;AAgBH,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,qBAAqB,GACtB,MAAM,aAAa,CAAA;AAcpB,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,gBAAgB,GACjB,MAAM,sBAAsB,CAAA;AAU7B,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA","sourcesContent":["/**\n * Safe functions that don't throw but instead\n * return a discriminated union of types representing\n * the successful outcome or failures.\n *\n * @categoryDescription Passkeys\n * Functions and related types for managing passkeys\n *\n * @showCategories\n *\n * @module safe\n */\n\nimport { FetchHttpClient } from \"@effect/platform\"\nimport { Effect, identity, pipe } from \"effect\"\nimport type {\n Forbidden,\n InvalidCode,\n NotFound,\n VerificationFailure,\n} from \"./errors.js\"\nimport type {\n AssignUserOptions,\n DeletedPasskey,\n DeletePasskeyOptions,\n FindAllPasskeys,\n GetPasskeyOptions,\n ListPasskeyOptions,\n Passkey,\n UpdatePasskeyOptions,\n} from \"./passkey/passkey.js\"\nimport {\n assignUser as assignUserE,\n deletePasskey as deletePasskeyE,\n getPasskey as getPasskeyE,\n listPasskeys as listPasskeysE,\n updatePasskey as updatePasskeyE,\n} from \"./passkey/passkey.js\"\nimport type {\n ExchangeCodeOptions,\n VerifyIdTokenOptions,\n} from \"./principal/principal.js\"\nimport {\n exchangeCode as exchangeCodeE,\n verifyIdToken as verifyIdTokenE,\n} from \"./principal/principal.js\"\nimport type { ExtendedPrincipal, Principal } from \"./schemas/principal.js\"\n\n/**\n * Assign a custom User ID to a passkey. Will be reflected in the next\n * {@link Principal} or {@link ExtendedPrincipal} generated.\n *\n * **Note:** This does not change the underlying WebAuthn credential's userID.\n * Instead we apply a layer of indirection.\n *\n * @see {@link Principal}\n * @see {@link ExtendedPrincipal}\n * @see [credential](https://passlock.dev/rest-api/credential/)\n *\n * @param request\n * @returns A promise resolving to either a passkey or an API error.\n *\n * @category Passkeys\n */\nexport const assignUser = (\n request: AssignUserOptions\n): Promise<Passkey | NotFound | Forbidden> =>\n pipe(\n assignUserE(request),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Can also be used to assign a custom User ID, but also allows you to update\n * the username.\n *\n * **Important:** changing the username has no bearing on authentication, as\n * it's typically only used in the client-side component of the passkey\n * (so the user knows which account the passkey relates to).\n *\n * However you might choose to align the username in your vault with the\n * client-side component to simplify end user support.\n *\n * @param request\n * @returns A promise resolving to either a passkey or an API error.\n *\n * @category Passkeys\n */\nexport const updatePasskey = (\n request: UpdatePasskeyOptions\n): Promise<Passkey | NotFound | Forbidden> =>\n pipe(\n updatePasskeyE(request),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Delete a passkey from your vault.\n *\n * **Note:** The user will still retain the passkey on their device so\n * you will need to either:\n *\n * a) Use the @passlock/client functions to delete the passkey from the user's device.\n * b) Remind the user to delete the passkey\n *\n * See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) in the documentation.\n *\n * In addition, during authentication you should handle a missing passkey scenario.\n * This happens when a user tries to authenticate with a passkey that is missing from\n * your vault. The @passlock/client library can help with this. See\n * [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)\n *\n * @see [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/)\n * @see [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)\n *\n * @param options\n * @returns A promise resolving to either deleted-passkey details or an API error.\n *\n * @category Passkeys\n */\nexport const deletePasskey = (\n options: DeletePasskeyOptions\n): Promise<DeletedPasskey | Forbidden | NotFound> =>\n pipe(\n deletePasskeyE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Fetch details about a passkey. **Important**: Not to be confused with\n * the {@link exchangeCode} or {@link verifyIdToken} functions, which\n * return details about specific authentication or registration operations.\n * Use this function for passkey management, not authentication.\n *\n * @param options\n * @returns A promise resolving to either passkey details or an API error.\n *\n * @category Passkeys\n */\nexport const getPasskey = (\n options: GetPasskeyOptions\n): Promise<Passkey | Forbidden | NotFound> =>\n pipe(\n getPasskeyE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * List passkeys for the given tenancy. Note: This could return a cursor.\n * If so, call again, passing the cursor back in.\n *\n * @param options\n * @returns A promise resolving to a page of passkey summaries or an API error.\n *\n * @category Passkeys\n */\nexport const listPasskeys = (\n options: ListPasskeyOptions\n): Promise<FindAllPasskeys | Forbidden> =>\n pipe(\n listPasskeysE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * The @passlock/client library generates codes, which you should send to\n * your backend. Use this function to exchange the code for details about\n * the registration or authentication operation. **Note:** a code is valid\n * for 5 minutes.\n *\n * @see {@link ExtendedPrincipal}\n *\n * @param options\n * @returns A promise resolving to an extended principal or an API error.\n *\n * @category Principal\n */\nexport const exchangeCode = (\n options: ExchangeCodeOptions\n): Promise<ExtendedPrincipal | Forbidden | InvalidCode> =>\n pipe(\n exchangeCodeE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.provide(FetchHttpClient.layer),\n Effect.runPromise\n )\n\n/**\n * Decode and verify an id_token (JWT) locally.\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 *\n * @see {@link Principal}\n *\n * @param options\n * @returns A promise resolving to a verified principal or verification failure.\n *\n * @category Principal\n */\nexport const verifyIdToken = (\n options: VerifyIdTokenOptions\n): Promise<Principal | VerificationFailure> =>\n pipe(\n verifyIdTokenE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/* Re-exports */\n\nexport type {\n BadRequest,\n DuplicateEmail,\n Forbidden,\n InvalidCode,\n InvalidEmail,\n InvalidTenancy,\n NotFound,\n PasskeyNotFound,\n Unauthorized,\n VerificationFailure,\n} from \"./errors.js\"\nexport {\n isBadRequest,\n isDuplicateEmail,\n isForbidden,\n isInvalidCode,\n isInvalidEmail,\n isInvalidTenancy,\n isNotFound,\n isPasskeyNotFound,\n isUnauthorized,\n isVerificationFailure,\n} from \"./errors.js\"\nexport type {\n AssignUserOptions,\n Credential,\n DeletedPasskey,\n DeletePasskeyOptions,\n FindAllPasskeys,\n GetPasskeyOptions,\n ListPasskeyOptions,\n Passkey,\n PasskeySummary,\n Platform,\n UpdatePasskeyOptions,\n} from \"./passkey/passkey.js\"\nexport {\n isDeletedPasskey,\n isPasskey,\n isPasskeySummary,\n} from \"./passkey/passkey.js\"\nexport type {\n ExchangeCodeOptions,\n VerifyIdTokenOptions,\n} from \"./principal/principal.js\"\nexport type {\n CredentialDeviceType,\n Transports,\n} from \"./schemas/passkey.js\"\nexport type { ExtendedPrincipal, Principal } from \"./schemas/principal.js\"\nexport { isExtendedPrincipal, isPrincipal } from \"./schemas/principal.js\"\nexport type {\n AuthenticatedOptions,\n PasslockOptions,\n} from \"./shared.js\"\n"]}