@passlock/client 2.0.0-beta.2 → 2.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/index.d.ts +3 -2
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +2 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/{network.d.ts → internal/network.d.ts} +5 -3
  6. package/dist/internal/network.d.ts.map +1 -0
  7. package/dist/{network.js → internal/network.js} +29 -10
  8. package/dist/internal/network.js.map +1 -0
  9. package/dist/internal/promise.d.ts.map +1 -0
  10. package/dist/internal/promise.js.map +1 -0
  11. package/dist/internal/tenancy.d.ts.map +1 -0
  12. package/dist/internal/tenancy.js.map +1 -0
  13. package/dist/logger/index.d.ts +3 -1
  14. package/dist/logger/index.d.ts.map +1 -1
  15. package/dist/logger/index.js +8 -3
  16. package/dist/logger/index.js.map +1 -1
  17. package/dist/passkey/authentication/index.d.ts +2 -2
  18. package/dist/passkey/authentication/index.d.ts.map +1 -1
  19. package/dist/passkey/authentication/index.js +4 -4
  20. package/dist/passkey/authentication/index.js.map +1 -1
  21. package/dist/passkey/authentication/micro.d.ts +54 -7
  22. package/dist/passkey/authentication/micro.d.ts.map +1 -1
  23. package/dist/passkey/authentication/micro.it.test.d.ts +2 -0
  24. package/dist/passkey/authentication/micro.it.test.d.ts.map +1 -0
  25. package/dist/passkey/authentication/micro.it.test.js +74 -0
  26. package/dist/passkey/authentication/micro.it.test.js.map +1 -0
  27. package/dist/passkey/authentication/micro.js +98 -31
  28. package/dist/passkey/authentication/micro.js.map +1 -1
  29. package/dist/passkey/authentication/micro.test.d.ts +2 -0
  30. package/dist/passkey/authentication/micro.test.d.ts.map +1 -0
  31. package/dist/passkey/authentication/micro.test.js +157 -0
  32. package/dist/passkey/authentication/micro.test.js.map +1 -0
  33. package/dist/passkey/{shared.d.ts → errors.d.ts} +3 -3
  34. package/dist/passkey/errors.d.ts.map +1 -0
  35. package/dist/passkey/{shared.js → errors.js} +3 -3
  36. package/dist/passkey/errors.js.map +1 -0
  37. package/dist/passkey/index.d.ts +4 -6
  38. package/dist/passkey/index.d.ts.map +1 -1
  39. package/dist/passkey/index.js +4 -4
  40. package/dist/passkey/index.js.map +1 -1
  41. package/dist/passkey/registration/index.d.ts +2 -2
  42. package/dist/passkey/registration/index.d.ts.map +1 -1
  43. package/dist/passkey/registration/index.js +4 -4
  44. package/dist/passkey/registration/index.js.map +1 -1
  45. package/dist/passkey/registration/micro.d.ts +43 -8
  46. package/dist/passkey/registration/micro.d.ts.map +1 -1
  47. package/dist/passkey/registration/micro.it.test.d.ts +2 -0
  48. package/dist/passkey/registration/micro.it.test.d.ts.map +1 -0
  49. package/dist/passkey/registration/micro.it.test.js +33 -0
  50. package/dist/passkey/registration/micro.it.test.js.map +1 -0
  51. package/dist/passkey/registration/micro.js +61 -40
  52. package/dist/passkey/registration/micro.js.map +1 -1
  53. package/dist/passkey/registration/micro.test.d.ts +2 -0
  54. package/dist/passkey/registration/micro.test.d.ts.map +1 -0
  55. package/dist/passkey/registration/micro.test.js +161 -0
  56. package/dist/passkey/registration/micro.test.js.map +1 -0
  57. package/dist/passkey/signals/micro.d.ts +12 -0
  58. package/dist/passkey/signals/micro.d.ts.map +1 -0
  59. package/dist/passkey/signals/micro.js +22 -0
  60. package/dist/passkey/signals/micro.js.map +1 -0
  61. package/dist/passkey/support.d.ts.map +1 -1
  62. package/dist/passkey/support.js +1 -1
  63. package/dist/passkey/support.js.map +1 -1
  64. package/dist/passkey/types.d.ts.map +1 -1
  65. package/dist/shared.d.ts.map +1 -1
  66. package/package.json +21 -25
  67. package/dist/network.d.ts.map +0 -1
  68. package/dist/network.js.map +0 -1
  69. package/dist/passkey/shared.d.ts.map +0 -1
  70. package/dist/passkey/shared.js.map +0 -1
  71. package/dist/promise.d.ts.map +0 -1
  72. package/dist/promise.js.map +0 -1
  73. package/dist/tenancy.d.ts.map +0 -1
  74. package/dist/tenancy.js.map +0 -1
  75. /package/dist/{promise.d.ts → internal/promise.d.ts} +0 -0
  76. /package/dist/{promise.js → internal/promise.js} +0 -0
  77. /package/dist/{tenancy.d.ts → internal/tenancy.d.ts} +0 -0
  78. /package/dist/{tenancy.js → internal/tenancy.js} +0 -0
@@ -1,10 +1,17 @@
1
- import { WebAuthnError, startAuthentication as simpleAuthentication, browserSupportsWebAuthn, } from "@simplewebauthn/browser";
2
- import { Micro, pipe } from "effect";
3
- import { TenancyId } from "../../tenancy";
4
- import { buildEndpoint, Endpoint, makeRequest, } from "../../network";
5
- import { OtherPasskeyError, PasskeysUnsupportedError } from "../shared";
6
- import {} from "../../shared";
1
+ import * as Helper from "@simplewebauthn/browser";
2
+ import { WebAuthnError, } from "@simplewebauthn/browser";
3
+ import { Context, Micro, pipe } from "effect";
4
+ import { buildEndpoint, Endpoint, makeRequest } from "../../internal/network";
5
+ import { TenancyId } from "../../internal/tenancy";
7
6
  import { Logger } from "../../logger";
7
+ import { OtherPasskeyError, PasskeysUnsupportedError } from "../errors";
8
+ import { signalCredentialRemoval } from "../signals/micro";
9
+ export class AuthenticationHelper extends Context.Tag("AuthenticationHelper")() {
10
+ static Default = {
11
+ browserSupportsWebAuthn: Helper.browserSupportsWebAuthn,
12
+ startAuthentication: Helper.startAuthentication,
13
+ };
14
+ }
8
15
  const isOptionsResponse = (payload) => {
9
16
  if (typeof payload !== "object")
10
17
  return false;
@@ -22,17 +29,26 @@ const isOptionsResponse = (payload) => {
22
29
  return false;
23
30
  return true;
24
31
  };
25
- const fetchOptions = ({ userId, userVerification }) => Micro.gen(function* () {
32
+ export const authenticationEvent = ["optionsRequest", "getCredential", "verifyCredential"];
33
+ export const fetchOptions = (options) => Micro.gen(function* () {
26
34
  const logger = yield* Micro.service(Logger);
27
35
  const { endpoint } = yield* Micro.service(Endpoint);
28
36
  const { tenancyId } = yield* Micro.service(TenancyId);
37
+ const { userId, userVerification, allowCredentials, timeout, onEvent } = options;
29
38
  const url = new URL(`${tenancyId}/passkey/authentication/options`, endpoint);
39
+ onEvent?.("optionsRequest");
30
40
  yield* logger.logInfo("Fetching passkey authentication options from Passlock");
41
+ const payload = {
42
+ allowCredentials,
43
+ userId,
44
+ userVerification,
45
+ timeout,
46
+ };
31
47
  return yield* makeRequest({
32
- url,
33
- payload: { userId, userVerification },
34
48
  label: "authentication options",
49
+ payload,
35
50
  responsePredicate: isOptionsResponse,
51
+ url,
36
52
  });
37
53
  });
38
54
  const AuthenticationSuccessTag = "AuthenticationSuccess";
@@ -49,44 +65,77 @@ export const isAuthenticationSuccess = (payload) => {
49
65
  return false;
50
66
  return true;
51
67
  };
52
- const verifyCredential = (sessionToken, response) => Micro.gen(function* () {
53
- const logger = yield* Micro.service(Logger);
54
- const { endpoint } = yield* Micro.service(Endpoint);
55
- const { tenancyId } = yield* Micro.service(TenancyId);
56
- const url = new URL(`${tenancyId}/passkey/authentication/verification`, endpoint);
57
- yield* logger.logInfo("Verifying passkey in Passlock vault");
58
- const authenticationResponse = yield* makeRequest({
59
- url,
60
- payload: { sessionToken, response },
61
- label: "authentication verification",
62
- responsePredicate: isAuthenticationSuccess,
63
- });
64
- yield* logger.logInfo(`Passkey with id ${authenticationResponse.principal.authenticatorId} successfully authenticated`);
65
- return authenticationResponse;
66
- });
67
- const startAuthentication = (optionsJSON) => Micro.gen(function* () {
68
+ export const isPasskeyNotFound = (payload) => {
69
+ if (typeof payload !== "object")
70
+ return false;
71
+ if (payload === null)
72
+ return false;
73
+ if (!("_tag" in payload))
74
+ return false;
75
+ if (typeof payload._tag !== "string")
76
+ return false;
77
+ if (payload._tag !== "@error/PasskeyNotFound")
78
+ return false;
79
+ if (!("message" in payload))
80
+ return false;
81
+ if (typeof payload.message !== "string")
82
+ return false;
83
+ if (!("credentialId" in payload))
84
+ return false;
85
+ if (typeof payload.credentialId !== "string")
86
+ return false;
87
+ if (!("rpId" in payload))
88
+ return false;
89
+ if (typeof payload.rpId !== "string")
90
+ return false;
91
+ return true;
92
+ };
93
+ export const startAuthentication = (optionsJSON, { useBrowserAutofill, onEvent, }) => Micro.gen(function* () {
94
+ onEvent?.("getCredential");
68
95
  const logger = yield* Micro.service(Logger);
69
96
  yield* logger.logInfo("Requesting passkey authentication on device");
70
- const isSupport = browserSupportsWebAuthn();
97
+ const helper = yield* Micro.service(AuthenticationHelper);
98
+ const isSupport = helper.browserSupportsWebAuthn();
71
99
  if (!isSupport)
72
100
  yield* new PasskeysUnsupportedError({
73
101
  message: "Device does not support passkeys",
74
102
  });
75
103
  return yield* Micro.tryPromise({
76
- try: () => simpleAuthentication({ optionsJSON }),
77
104
  catch: (error) => {
78
105
  if (error instanceof WebAuthnError) {
79
106
  return new OtherPasskeyError({
107
+ code: error.code,
80
108
  error: error.cause,
81
109
  message: error.message,
82
- code: error.code,
83
110
  });
84
111
  }
85
112
  else {
86
113
  return new OtherPasskeyError({ error, message: "Unexpected error" });
87
114
  }
88
115
  },
116
+ try: () => helper.startAuthentication({ optionsJSON, useBrowserAutofill }),
117
+ });
118
+ });
119
+ export const verifyCredential = (sessionToken, response, { onEvent }) => Micro.gen(function* () {
120
+ const logger = yield* Micro.service(Logger);
121
+ const { endpoint } = yield* Micro.service(Endpoint);
122
+ const { tenancyId } = yield* Micro.service(TenancyId);
123
+ const url = new URL(`${tenancyId}/passkey/authentication/verification`, endpoint);
124
+ onEvent?.("verifyCredential");
125
+ yield* logger.logInfo("Verifying passkey in Passlock vault");
126
+ const payload = {
127
+ response,
128
+ sessionToken,
129
+ };
130
+ const authenticationResponse = yield* makeRequest({
131
+ errorPredicate: isPasskeyNotFound,
132
+ label: "authentication verification",
133
+ payload,
134
+ responsePredicate: isAuthenticationSuccess,
135
+ url,
89
136
  });
137
+ yield* logger.logInfo(`Passkey with id ${authenticationResponse.principal.authenticatorId} successfully authenticated`);
138
+ return authenticationResponse;
90
139
  });
91
140
  /**
92
141
  * Trigger local passkey authentication then verify the passkey in the Passlock vault.
@@ -99,9 +148,27 @@ export const authenticatePasskey = (options) => {
99
148
  const endpoint = buildEndpoint(options);
100
149
  const effect = Micro.gen(function* () {
101
150
  const { sessionToken, optionsJSON } = yield* fetchOptions(options);
102
- const response = yield* startAuthentication(optionsJSON);
103
- return yield* verifyCredential(sessionToken, response);
151
+ const go = (useBrowserAutofill) => Micro.gen(function* () {
152
+ yield* Micro.sleep(100);
153
+ const response = yield* startAuthentication(optionsJSON, {
154
+ onEvent: options.onEvent,
155
+ useBrowserAutofill,
156
+ });
157
+ options.onEvent?.("verifyCredential");
158
+ return yield* verifyCredential(sessionToken, response, {
159
+ onEvent: options.onEvent,
160
+ });
161
+ });
162
+ if (options.autofill === true) {
163
+ return yield* go(options.autofill);
164
+ }
165
+ else {
166
+ return yield* go(false);
167
+ }
104
168
  });
105
- return pipe(effect, Micro.provideService(TenancyId, options), Micro.provideService(Endpoint, endpoint));
169
+ // try to remove the passkey from the device
170
+ // if it doesnt exist in the vault
171
+ const withNotFoundHandling = pipe(effect, Micro.tapError((err) => err._tag === "@error/PasskeyNotFound" ? signalCredentialRemoval(err) : Micro.void));
172
+ return pipe(withNotFoundHandling, Micro.provideService(TenancyId, options), Micro.provideService(Endpoint, endpoint));
106
173
  };
107
174
  //# sourceMappingURL=micro.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"micro.js","sourceRoot":"","sources":["../../../src/passkey/authentication/micro.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACb,mBAAmB,IAAI,oBAAoB,EAC3C,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAEL,aAAa,EACb,QAAQ,EACR,WAAW,GACZ,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAwB,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE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AAO,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACpC,CAAC;aAAM,CAAC;YACN,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;QACzB,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,4CAA4C;IAC5C,kCAAkC;IAClC,MAAM,oBAAoB,GAAG,IAAI,CAC/B,MAAM,EACN,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,EAAE,CACrB,GAAG,CAAC,IAAI,KAAK,wBAAwB,CAAC,CAAC,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAClF,CACF,CAAA;IAED,OAAO,IAAI,CACT,oBAAoB,EACpB,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,EACxC,KAAK,CAAC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CACzC,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=micro.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"micro.test.d.ts","sourceRoot":"","sources":["../../../src/passkey/authentication/micro.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,157 @@
1
+ import fetchMock from "@fetch-mock/vitest";
2
+ import { Context, Micro, pipe } from "effect";
3
+ import { afterAll, describe, expect, it, vi } from "vitest";
4
+ import { Endpoint } from "../../internal/network";
5
+ import { TenancyId } from "../../internal/tenancy";
6
+ import { Logger } from "../../logger";
7
+ import { PasskeysUnsupportedError } from "../errors";
8
+ import { AuthenticationHelper, authenticatePasskey, fetchOptions, startAuthentication, verifyCredential, } from "./micro";
9
+ const loggerTest = {
10
+ logDebug: () => Micro.void,
11
+ logError: () => Micro.void,
12
+ logInfo: () => Micro.void,
13
+ logWarn: () => Micro.void,
14
+ };
15
+ describe(fetchOptions.name, () => {
16
+ const endpoint = "https://api.passlock.dev";
17
+ const tenancyId = "dummyTenancyId";
18
+ const ctx = pipe(Context.make(Endpoint, { endpoint }), Context.add(Logger, loggerTest), Context.add(TenancyId, { tenancyId }));
19
+ const expectedRoute = `${endpoint}/${tenancyId}/passkey/authentication/options`;
20
+ const mockResponse = {
21
+ optionsJSON: {},
22
+ sessionToken: "dummySessionToken",
23
+ };
24
+ describe("given an empty set of options", () => {
25
+ it("should fetch some PublicKeyCredentialCreationOptions", async () => {
26
+ fetchMock.mockGlobal().postOnce(expectedRoute, mockResponse);
27
+ const result = await pipe(fetchOptions({}), Micro.provideContext(ctx), Micro.runPromise);
28
+ expect(result.sessionToken).toBeTruthy();
29
+ expect(result.optionsJSON).toBeTruthy();
30
+ });
31
+ });
32
+ describe("given a userId", () => {
33
+ const userId = "dummyUserId";
34
+ it("should send it to the backend", async () => {
35
+ fetchMock.mockGlobal().postOnce(expectedRoute, mockResponse);
36
+ await pipe(fetchOptions({ userId }), Micro.provideContext(ctx), Micro.runPromise);
37
+ expect(fetchMock).toHavePosted(expectedRoute, { body: { userId } });
38
+ });
39
+ });
40
+ describe("given a list of allowCredentials", () => {
41
+ const allowCredentials = ["dummyCredential"];
42
+ it("should send them to the backend", async () => {
43
+ fetchMock.mockGlobal().postOnce(expectedRoute, mockResponse);
44
+ await pipe(fetchOptions({ allowCredentials }), Micro.provideContext(ctx), Micro.runPromise);
45
+ expect(fetchMock).toHavePosted(expectedRoute, {
46
+ body: { allowCredentials },
47
+ });
48
+ });
49
+ });
50
+ describe("given a userVerification", () => {
51
+ const userVerification = "required";
52
+ it("should send it to the backend", async () => {
53
+ fetchMock.mockGlobal().postOnce(expectedRoute, mockResponse);
54
+ await pipe(fetchOptions({ userVerification }), Micro.provideContext(ctx), Micro.runPromise);
55
+ expect(fetchMock).toHavePosted(expectedRoute, {
56
+ body: { userVerification },
57
+ });
58
+ });
59
+ });
60
+ it("should invoke the onEvent handler", async () => {
61
+ fetchMock.mockGlobal().postOnce(expectedRoute, mockResponse);
62
+ const onEvent = vi.fn();
63
+ await pipe(fetchOptions({ onEvent }), Micro.provideContext(ctx), Micro.runPromise);
64
+ expect(onEvent).toHaveBeenCalledWith("optionsRequest");
65
+ });
66
+ });
67
+ describe(startAuthentication.name, () => {
68
+ describe("given valid options", () => {
69
+ const authenticationHelperTest = {
70
+ browserSupportsWebAuthn: () => true,
71
+ startAuthentication: () => Promise.resolve({}),
72
+ };
73
+ it("should invoke the underlying startAuthentication function", async () => {
74
+ await pipe(startAuthentication({}, {
75
+ useBrowserAutofill: false,
76
+ }), Micro.provideService(Logger, loggerTest), Micro.provideService(AuthenticationHelper, authenticationHelperTest), Micro.runPromise);
77
+ });
78
+ });
79
+ describe("if the device does not support passkeys", () => {
80
+ const authenticationHelperTest = {
81
+ browserSupportsWebAuthn: () => false,
82
+ startAuthentication: () => Promise.resolve({}),
83
+ };
84
+ it("should return an error", async () => {
85
+ const result = await pipe(startAuthentication({}, {
86
+ useBrowserAutofill: false,
87
+ }), Micro.flip, Micro.provideService(Logger, loggerTest), Micro.provideService(AuthenticationHelper, authenticationHelperTest), Micro.runPromise);
88
+ expect(result).toBeInstanceOf(PasskeysUnsupportedError);
89
+ });
90
+ });
91
+ });
92
+ describe(verifyCredential.name, () => {
93
+ const endpoint = "https://api.passlock.dev";
94
+ const tenancyId = "dummyTenancyId";
95
+ const ctx = pipe(Context.make(Endpoint, { endpoint }), Context.add(Logger, loggerTest), Context.add(TenancyId, { tenancyId }));
96
+ const expectedRoute = `${endpoint}/${tenancyId}/passkey/authentication/verification`;
97
+ describe("when the passkey exists", () => {
98
+ const mockResponse = {
99
+ _tag: "AuthenticationSuccess",
100
+ code: "dummyCode",
101
+ id_token: "dummyIdToken",
102
+ principal: {
103
+ authenticatorId: "dummyPasskeyId",
104
+ },
105
+ };
106
+ it("should return a successful response", async () => {
107
+ fetchMock.mockGlobal().postOnce(expectedRoute, mockResponse);
108
+ const result = await pipe(verifyCredential("dummySessionToken", {}, {}), Micro.provideContext(ctx), Micro.runPromise);
109
+ expect(result).toStrictEqual(mockResponse);
110
+ });
111
+ });
112
+ describe("when the backend says the passkey does not exist", () => {
113
+ it("should return an error", async () => {
114
+ const mockResponse = {
115
+ _tag: "@error/PasskeyNotFound",
116
+ credentialId: "dummyWebAuthnId",
117
+ message: "oops",
118
+ rpId: "localhost",
119
+ };
120
+ fetchMock.mockGlobal().postOnce(expectedRoute, { body: mockResponse, status: 400 });
121
+ const error = await pipe(verifyCredential("dummySessionToken", {}, {}), Micro.flip, Micro.provideContext(ctx), Micro.runPromise);
122
+ expect(error).toStrictEqual(mockResponse);
123
+ });
124
+ });
125
+ });
126
+ describe(authenticatePasskey.name, () => {
127
+ const endpoint = "https://api.passlock.dev";
128
+ const tenancyId = "dummyTenancyId";
129
+ const authenticationHelperTest = {
130
+ browserSupportsWebAuthn: () => true,
131
+ startAuthentication: () => Promise.resolve({}),
132
+ };
133
+ const ctx = pipe(Context.make(Endpoint, { endpoint }), Context.add(Logger, loggerTest), Context.add(TenancyId, { tenancyId }), Context.add(AuthenticationHelper, authenticationHelperTest));
134
+ const optionsRoute = `${endpoint}/${tenancyId}/passkey/authentication/options`;
135
+ const optionsResponse = {
136
+ optionsJSON: {},
137
+ sessionToken: "dummySessionToken",
138
+ };
139
+ const verificationRoute = `${endpoint}/${tenancyId}/passkey/authentication/verification`;
140
+ const verificationResponse = {
141
+ _tag: "AuthenticationSuccess",
142
+ code: "dummyCode",
143
+ id_token: "dummyIdToken",
144
+ principal: {
145
+ authenticatorId: "dummyPasskeyId",
146
+ },
147
+ };
148
+ it("should fetch the options and kick off the authentication", async () => {
149
+ fetchMock.mockGlobal().postOnce(optionsRoute, optionsResponse);
150
+ fetchMock.mockGlobal().postOnce(verificationRoute, verificationResponse);
151
+ pipe(authenticatePasskey({ tenancyId }), Micro.provideContext(ctx), Micro.runPromise);
152
+ });
153
+ });
154
+ afterAll(() => {
155
+ fetchMock.unmockGlobal();
156
+ });
157
+ //# sourceMappingURL=micro.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"micro.test.js","sourceRoot":"","sources":["../../../src/passkey/authentication/micro.test.ts"],"names":[],"mappings":"AAIA,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,SAAS,CAAA;AAEhB,MAAM,UAAU,GAAG;IACjB,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI;IAC1B,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI;IAC1B,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI;IACzB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI;CACM,CAAA;AAEjC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE;IAC/B,MAAM,QAAQ,GAAG,0BAA0B,CAAA;IAC3C,MAAM,SAAS,GAAG,gBAAgB,CAAA;IAElC,MAAM,GAAG,GAAG,IAAI,CACd,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,EACpC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAC/B,OAAO,CAAC,GAAG,CAAC,SAAS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,EAAE,CAAC,EACpC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAC/B,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,CAAC,EACrC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,wBAAwB,CAAC,CAC5D,CAAA;IAED,MAAM,YAAY,GAAG,GAAG,QAAQ,IAAI,SAAS,iCAAiC,CAAA;IAE9E,MAAM,eAAe,GAAG;QACtB,WAAW,EAAE,EAAE;QACf,YAAY,EAAE,mBAAmB;KAClC,CAAA;IAED,MAAM,iBAAiB,GAAG,GAAG,QAAQ,IAAI,SAAS,sCAAsC,CAAA;IAExF,MAAM,oBAAoB,GAAG;QAC3B,IAAI,EAAE,uBAAuB;QAC7B,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,cAAc;QACxB,SAAS,EAAE;YACT,eAAe,EAAE,gBAAgB;SAClC;KACF,CAAA;IAED,EAAE,CAAC,0DAA0D,EAAE,KAAK,IAAI,EAAE;QACxE,SAAS,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC,CAAA;QAC9D,SAAS,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAA;QAExE,IAAI,CAAC,mBAAmB,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;IACvF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,GAAG,EAAE;IACZ,SAAS,CAAC,YAAY,EAAE,CAAA;AAC1B,CAAC,CAAC,CAAA"}
@@ -1,12 +1,12 @@
1
1
  import { Micro } from "effect";
2
- export declare const isPasskeysUnsupportedError: (error: unknown) => error is PasskeysUnsupportedError;
2
+ export declare const isPasskeysUnsupported: (error: unknown) => error is PasskeysUnsupportedError;
3
3
  declare const PasskeysUnsupportedError_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]; }) => Micro.YieldableError & {
4
4
  readonly _tag: "@error/PasskeysUnsupportedError";
5
5
  } & Readonly<A>;
6
6
  export declare class PasskeysUnsupportedError extends PasskeysUnsupportedError_base<{
7
7
  readonly message: string;
8
8
  }> {
9
- static isPasskeysUnsupportedError: (error: unknown) => error is PasskeysUnsupportedError;
9
+ static isPasskeysUnsupported: (error: unknown) => error is PasskeysUnsupportedError;
10
10
  }
11
11
  export type ErrorCode = "ERROR_CEREMONY_ABORTED" | "ERROR_INVALID_DOMAIN" | "ERROR_INVALID_RP_ID" | "ERROR_INVALID_USER_ID_LENGTH" | "ERROR_MALFORMED_PUBKEYCREDPARAMS" | "ERROR_AUTHENTICATOR_GENERAL_ERROR" | "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT" | "ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT" | "ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED" | "ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG" | "ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE" | "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY";
12
12
  export declare const isOtherPasskeyError: (error: unknown) => error is OtherPasskeyError;
@@ -21,4 +21,4 @@ export declare class OtherPasskeyError extends OtherPasskeyError_base<{
21
21
  static isOtherPasskeyError: (error: unknown) => error is OtherPasskeyError;
22
22
  }
23
23
  export {};
24
- //# sourceMappingURL=shared.d.ts.map
24
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/passkey/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE9B,eAAO,MAAM,qBAAqB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,wBACrB,CAAA;;;;AAE3C,qBAAa,wBAAyB,SAAQ,8BAAqD;IACjG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAC;IACA,MAAM,CAAC,qBAAqB,UANe,OAAO,KAAG,KAAK,IAAI,wBAAwB,CAMlC;CACrD;AAED,MAAM,MAAM,SAAS,GACjB,wBAAwB,GACxB,sBAAsB,GACtB,qBAAqB,GACrB,8BAA8B,GAC9B,kCAAkC,GAClC,mCAAmC,GACnC,6DAA6D,GAC7D,uDAAuD,GACvD,2CAA2C,GAC3C,uDAAuD,GACvD,+CAA+C,GAC/C,sCAAsC,CAAA;AAE1C,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,iBAC1B,CAAA;;;;AAEpC,qBAAa,iBAAkB,SAAQ,uBAA8C;IACnF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAC1B,CAAC;IACA,MAAM,CAAC,mBAAmB,UARe,OAAO,KAAG,KAAK,IAAI,iBAAiB,CAQ7B;CACjD"}
@@ -1,10 +1,10 @@
1
1
  import { Micro } from "effect";
2
- export const isPasskeysUnsupportedError = (error) => error instanceof PasskeysUnsupportedError;
2
+ export const isPasskeysUnsupported = (error) => error instanceof PasskeysUnsupportedError;
3
3
  export class PasskeysUnsupportedError extends Micro.TaggedError("@error/PasskeysUnsupportedError") {
4
- static isPasskeysUnsupportedError = isPasskeysUnsupportedError;
4
+ static isPasskeysUnsupported = isPasskeysUnsupported;
5
5
  }
6
6
  export const isOtherPasskeyError = (error) => error instanceof OtherPasskeyError;
7
7
  export class OtherPasskeyError extends Micro.TaggedError("@error/OtherPasskeyError") {
8
8
  static isOtherPasskeyError = isOtherPasskeyError;
9
9
  }
10
- //# sourceMappingURL=shared.js.map
10
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/passkey/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE9B,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAc,EAAqC,EAAE,CACzF,KAAK,YAAY,wBAAwB,CAAA;AAE3C,MAAM,OAAO,wBAAyB,SAAQ,KAAK,CAAC,WAAW,CAAC,iCAAiC,CAE/F;IACA,MAAM,CAAC,qBAAqB,GAAG,qBAAqB,CAAA;;AAiBtD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAA8B,EAAE,CAChF,KAAK,YAAY,iBAAiB,CAAA;AAEpC,MAAM,OAAO,iBAAkB,SAAQ,KAAK,CAAC,WAAW,CAAC,0BAA0B,CAIjF;IACA,MAAM,CAAC,mBAAmB,GAAG,mBAAmB,CAAA"}
@@ -1,7 +1,5 @@
1
- export type { RegistrationOptions, RegistrationSuccess, RegistrationError, DuplicatePasskeyError, } from "./registration/micro";
2
- export { registerPasskeyUnsafe, registerPasskey, isRegistrationSuccess, } from "./registration/index";
3
- export type { AuthenticationOptions, AuthenticationSuccess, AuthenticationError, } from "./authentication/micro";
4
- export { authenticatePasskeyUnsafe, authenticatePasskey, isAuthenticationSuccess, } from "./authentication/index";
5
- export { isPasskeySupport, isAutofillSupport } from "./support";
6
- export { PasskeysUnsupportedError, OtherPasskeyError } from "./shared";
1
+ export * from "./authentication/index";
2
+ export * from "./errors";
3
+ export * from "./registration/index";
4
+ export * from "./support";
7
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/passkey/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEhE,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/passkey/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,UAAU,CAAA;AACxB,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA"}
@@ -1,5 +1,5 @@
1
- export { registerPasskeyUnsafe, registerPasskey, isRegistrationSuccess, } from "./registration/index";
2
- export { authenticatePasskeyUnsafe, authenticatePasskey, isAuthenticationSuccess, } from "./authentication/index";
3
- export { isPasskeySupport, isAutofillSupport } from "./support";
4
- export { PasskeysUnsupportedError, OtherPasskeyError } from "./shared";
1
+ export * from "./authentication/index";
2
+ export * from "./errors";
3
+ export * from "./registration/index";
4
+ export * from "./support";
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/passkey/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEhE,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/passkey/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,UAAU,CAAA;AACxB,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA"}
@@ -1,5 +1,5 @@
1
- import { type RegistrationError, type RegistrationOptions, type RegistrationSuccess } from "./micro";
2
1
  import { Logger } from "../../logger";
2
+ import { type RegistrationError, type RegistrationOptions, type RegistrationSuccess } from "./micro";
3
3
  /**
4
4
  * Register a passkey on the local device and store the
5
5
  * associated public key in your Passlock vault.
@@ -14,6 +14,6 @@ export declare const registerPasskeyUnsafe: (options: RegistrationOptions, logge
14
14
  * @returns
15
15
  */
16
16
  export declare const registerPasskey: (options: RegistrationOptions, logger?: typeof Logger.Service) => Promise<RegistrationSuccess | RegistrationError>;
17
- export type { RegistrationSuccess, RegistrationError } from "./micro";
17
+ export type { RegistrationError, RegistrationOptions, RegistrationSuccess } from "./micro";
18
18
  export { isRegistrationSuccess } from "./micro";
19
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/passkey/registration/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACzB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAe,MAAM,EAAE,MAAM,cAAc,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAChC,SAAS,mBAAmB,EAC5B,SAAQ,OAAO,MAAM,CAAC,OAAqB,KAC1C,OAAO,CAAC,mBAAmB,CAK3B,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,mBAAmB,EAC5B,SAAQ,OAAO,MAAM,CAAC,OAAqB,KAC1C,OAAO,CAAC,mBAAmB,GAAG,iBAAiB,CAK/C,CAAC;AAEJ,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/passkey/registration/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,MAAM,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EAEzB,MAAM,SAAS,CAAA;AAEhB;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAChC,SAAS,mBAAmB,EAC5B,SAAQ,OAAO,MAAM,CAAC,OAAqB,KAC1C,OAAO,CAAC,mBAAmB,CAM3B,CAAA;AAEH;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,mBAAmB,EAC5B,SAAQ,OAAO,MAAM,CAAC,OAAqB,KAC1C,OAAO,CAAC,mBAAmB,GAAG,iBAAiB,CAM/C,CAAA;AAEH,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA"}
@@ -1,20 +1,20 @@
1
1
  import { Micro, pipe } from "effect";
2
- import { runToPromise, runToPromiseUnsafe } from "../../promise";
3
- import { registerPasskey as registerPasskeyM, } from "./micro";
2
+ import { runToPromise, runToPromiseUnsafe } from "../../internal/promise";
4
3
  import { EventLogger, Logger } from "../../logger";
4
+ import { RegistrationHelper, registerPasskey as registerPasskeyM, } from "./micro";
5
5
  /**
6
6
  * Register a passkey on the local device and store the
7
7
  * associated public key in your Passlock vault.
8
8
  * @param options
9
9
  * @returns
10
10
  */
11
- export const registerPasskeyUnsafe = async (options, logger = EventLogger) => pipe(registerPasskeyM(options), Micro.provideService(Logger, logger), runToPromiseUnsafe);
11
+ export const registerPasskeyUnsafe = async (options, logger = EventLogger) => pipe(registerPasskeyM(options), Micro.provideService(Logger, logger), Micro.provideService(RegistrationHelper, RegistrationHelper.Default), runToPromiseUnsafe);
12
12
  /**
13
13
  * Register a passkey on the local device and store the
14
14
  * associated public key in your Passlock vault.
15
15
  * @param options
16
16
  * @returns
17
17
  */
18
- export const registerPasskey = async (options, logger = EventLogger) => pipe(registerPasskeyM(options), Micro.provideService(Logger, logger), runToPromise);
18
+ export const registerPasskey = async (options, logger = EventLogger) => pipe(registerPasskeyM(options), Micro.provideService(Logger, logger), Micro.provideService(RegistrationHelper, RegistrationHelper.Default), runToPromise);
19
19
  export { isRegistrationSuccess } from "./micro";
20
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/passkey/registration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EACL,eAAe,IAAI,gBAAgB,GAIpC,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EACxC,OAA4B,EAC5B,SAAgC,WAAW,EACb,EAAE,CAChC,IAAI,CACF,gBAAgB,CAAC,OAAO,CAAC,EACzB,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,kBAAkB,CACnB,CAAC;AAEJ;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,OAA4B,EAC5B,SAAgC,WAAW,EACO,EAAE,CACpD,IAAI,CACF,gBAAgB,CAAC,OAAO,CAAC,EACzB,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,YAAY,CACb,CAAC;AAGJ,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/passkey/registration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAEL,kBAAkB,EAGlB,eAAe,IAAI,gBAAgB,GACpC,MAAM,SAAS,CAAA;AAEhB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EACxC,OAA4B,EAC5B,SAAgC,WAAW,EACb,EAAE,CAChC,IAAI,CACF,gBAAgB,CAAC,OAAO,CAAC,EACzB,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,KAAK,CAAC,cAAc,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,OAAO,CAAC,EACpE,kBAAkB,CACnB,CAAA;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,OAA4B,EAC5B,SAAgC,WAAW,EACO,EAAE,CACpD,IAAI,CACF,gBAAgB,CAAC,OAAO,CAAC,EACzB,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,KAAK,CAAC,cAAc,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,OAAO,CAAC,EACpE,YAAY,CACb,CAAA;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA"}
@@ -1,10 +1,27 @@
1
- import { Micro } from "effect";
2
- import { type UnexpectedError } from "../../network";
3
- import { OtherPasskeyError as OtherPasskeyError, PasskeysUnsupportedError } from "../shared";
4
- import { type PasslockOptions } from "../../shared";
5
- import { Logger } from "../../logger";
1
+ import type { PasslockOptions } from "../../shared";
6
2
  import type { UserVerification } from "../types";
7
- export declare const isDuplicatePasskeyError: (err: unknown) => err is DuplicatePasskeyError;
3
+ import * as Helper from "@simplewebauthn/browser";
4
+ import { type PublicKeyCredentialCreationOptionsJSON, type RegistrationResponseJSON } from "@simplewebauthn/browser";
5
+ import { Context, Micro } from "effect";
6
+ import { Endpoint, type UnexpectedError } from "../../internal/network";
7
+ import { TenancyId } from "../../internal/tenancy";
8
+ import { Logger } from "../../logger";
9
+ import { OtherPasskeyError, PasskeysUnsupportedError } from "../errors";
10
+ interface OptionsResponse {
11
+ sessionToken: string;
12
+ optionsJSON: PublicKeyCredentialCreationOptionsJSON;
13
+ }
14
+ declare const RegistrationHelper_base: Context.TagClass<RegistrationHelper, "RegistrationHelper", {
15
+ browserSupportsWebAuthn: typeof Helper.browserSupportsWebAuthn;
16
+ startRegistration: typeof Helper.startRegistration;
17
+ }>;
18
+ export declare class RegistrationHelper extends RegistrationHelper_base {
19
+ static Default: {
20
+ browserSupportsWebAuthn: typeof Helper.browserSupportsWebAuthn;
21
+ startRegistration: typeof Helper.startRegistration;
22
+ };
23
+ }
24
+ export declare const isDuplicatePasskey: (err: unknown) => err is DuplicatePasskeyError;
8
25
  declare const DuplicatePasskeyError_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]; }) => Micro.YieldableError & {
9
26
  readonly _tag: "@error/DuplicatePasskeyError";
10
27
  } & Readonly<A>;
@@ -16,8 +33,11 @@ declare const DuplicatePasskeyError_base: new <A extends Record<string, any> = {
16
33
  export declare class DuplicatePasskeyError extends DuplicatePasskeyError_base<{
17
34
  readonly message: string;
18
35
  }> {
19
- static isDuplicatePasskeyError: (err: unknown) => err is DuplicatePasskeyError;
36
+ static isDuplicatePasskey: (err: unknown) => err is DuplicatePasskeyError;
20
37
  }
38
+ export declare const registrationEvent: readonly ["optionsRequest", "createCredential", "saveCredential"];
39
+ export type RegistrationEvent = (typeof registrationEvent)[number];
40
+ export type OnEventFn = (event: RegistrationEvent) => void;
21
41
  /**
22
42
  * Passkey registration options
23
43
  */
@@ -50,8 +70,17 @@ export interface RegistrationOptions extends PasslockOptions {
50
70
  * @see {@link https://passlock.dev/passkeys/user-verification/|userVerification}
51
71
  */
52
72
  userVerification?: UserVerification | undefined;
73
+ /**
74
+ * Receive notifications about key stages in the registration process.
75
+ * For example, you might use event notifications to toggle loading icons or
76
+ * to disable certain form fields.
77
+ * @param event
78
+ * @returns
79
+ */
80
+ onEvent?: OnEventFn;
53
81
  timeout?: number | undefined;
54
82
  }
83
+ export declare const fetchOptions: (options: Omit<RegistrationOptions, keyof PasslockOptions>) => Micro.Micro<OptionsResponse, UnexpectedError, Endpoint | Logger | TenancyId>;
55
84
  declare const RegistrationSuccessTag: "RegistrationSuccess";
56
85
  type RegistrationSuccessTag = typeof RegistrationSuccessTag;
57
86
  /**
@@ -86,6 +115,12 @@ export interface RegistrationSuccess {
86
115
  code: string;
87
116
  }
88
117
  export declare const isRegistrationSuccess: (payload: unknown) => payload is RegistrationSuccess;
118
+ export declare const startRegistration: (optionsJSON: PublicKeyCredentialCreationOptionsJSON, { onEvent }: {
119
+ onEvent?: OnEventFn | undefined;
120
+ }) => Micro.Micro<Helper.RegistrationResponseJSON, PasskeysUnsupportedError | OtherPasskeyError | DuplicatePasskeyError, Logger | RegistrationHelper>;
121
+ export declare const verifyCredential: (sessionToken: string, response: RegistrationResponseJSON, { onEvent }: {
122
+ onEvent?: OnEventFn | undefined;
123
+ }) => Micro.Micro<RegistrationSuccess, UnexpectedError, Endpoint | Logger | TenancyId>;
89
124
  /**
90
125
  * Potential errors associated with Passkey registration
91
126
  */
@@ -96,6 +131,6 @@ export type RegistrationError = PasskeysUnsupportedError | DuplicatePasskeyError
96
131
  * @param options
97
132
  * @returns
98
133
  */
99
- export declare const registerPasskey: (options: RegistrationOptions) => Micro.Micro<RegistrationSuccess, RegistrationError, Logger>;
134
+ export declare const registerPasskey: (options: RegistrationOptions) => Micro.Micro<RegistrationSuccess, RegistrationError, Logger | RegistrationHelper>;
100
135
  export {};
101
136
  //# sourceMappingURL=micro.d.ts.map