@passlock/client 0.9.30 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/README.md +14 -86
  2. package/README.template.md +16 -88
  3. package/dist/index.d.ts +4 -206
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +2 -158
  6. package/dist/index.js.map +1 -1
  7. package/dist/logger/index.d.ts +24 -0
  8. package/dist/logger/index.d.ts.map +1 -0
  9. package/dist/logger/index.js +47 -0
  10. package/dist/logger/index.js.map +1 -0
  11. package/dist/network.d.ts +39 -0
  12. package/dist/network.d.ts.map +1 -0
  13. package/dist/network.js +83 -0
  14. package/dist/network.js.map +1 -0
  15. package/dist/passkey/authentication/index.d.ts +21 -0
  16. package/dist/passkey/authentication/index.d.ts.map +1 -0
  17. package/dist/passkey/authentication/index.js +22 -0
  18. package/dist/passkey/authentication/index.js.map +1 -0
  19. package/dist/passkey/authentication/micro.d.ts +71 -0
  20. package/dist/passkey/authentication/micro.d.ts.map +1 -0
  21. package/dist/passkey/authentication/micro.js +107 -0
  22. package/dist/passkey/authentication/micro.js.map +1 -0
  23. package/dist/passkey/index.d.ts +7 -0
  24. package/dist/passkey/index.d.ts.map +1 -0
  25. package/dist/passkey/index.js +5 -0
  26. package/dist/passkey/index.js.map +1 -0
  27. package/dist/passkey/registration/index.d.ts +19 -0
  28. package/dist/passkey/registration/index.d.ts.map +1 -0
  29. package/dist/passkey/registration/index.js +20 -0
  30. package/dist/passkey/registration/index.js.map +1 -0
  31. package/dist/passkey/registration/micro.d.ts +101 -0
  32. package/dist/passkey/registration/micro.d.ts.map +1 -0
  33. package/dist/passkey/registration/micro.js +126 -0
  34. package/dist/passkey/registration/micro.js.map +1 -0
  35. package/dist/passkey/shared.d.ts +24 -0
  36. package/dist/passkey/shared.d.ts.map +1 -0
  37. package/dist/passkey/shared.js +10 -0
  38. package/dist/passkey/shared.js.map +1 -0
  39. package/dist/passkey/support.d.ts +3 -0
  40. package/dist/passkey/support.d.ts.map +1 -0
  41. package/dist/passkey/support.js +4 -0
  42. package/dist/passkey/support.js.map +1 -0
  43. package/dist/passkey/types.d.ts +26 -0
  44. package/dist/passkey/types.d.ts.map +1 -0
  45. package/dist/passkey/types.js +2 -0
  46. package/dist/passkey/types.js.map +1 -0
  47. package/dist/promise.d.ts +15 -0
  48. package/dist/promise.d.ts.map +1 -0
  49. package/dist/promise.js +46 -0
  50. package/dist/promise.js.map +1 -0
  51. package/dist/shared.d.ts +15 -0
  52. package/dist/shared.d.ts.map +1 -0
  53. package/dist/shared.js +2 -0
  54. package/dist/shared.js.map +1 -0
  55. package/dist/tenancy.d.ts +8 -0
  56. package/dist/tenancy.d.ts.map +1 -0
  57. package/dist/tenancy.js +4 -0
  58. package/dist/tenancy.js.map +1 -0
  59. package/package.json +52 -58
  60. package/LICENSE +0 -21
  61. package/dist/authentication/authenticate.d.ts +0 -24
  62. package/dist/authentication/authenticate.fixture.d.ts +0 -52
  63. package/dist/authentication/authenticate.fixture.js +0 -50
  64. package/dist/authentication/authenticate.fixture.js.map +0 -1
  65. package/dist/authentication/authenticate.js +0 -73
  66. package/dist/authentication/authenticate.js.map +0 -1
  67. package/dist/capabilities/capabilities.d.ts +0 -19
  68. package/dist/capabilities/capabilities.js +0 -37
  69. package/dist/capabilities/capabilities.js.map +0 -1
  70. package/dist/connection/connection.d.ts +0 -15
  71. package/dist/connection/connection.fixture.d.ts +0 -10
  72. package/dist/connection/connection.fixture.js +0 -13
  73. package/dist/connection/connection.fixture.js.map +0 -1
  74. package/dist/connection/connection.js +0 -23
  75. package/dist/connection/connection.js.map +0 -1
  76. package/dist/effect.d.ts +0 -26
  77. package/dist/effect.js +0 -78
  78. package/dist/effect.js.map +0 -1
  79. package/dist/email/email.d.ts +0 -70
  80. package/dist/email/email.fixture.d.ts +0 -46
  81. package/dist/email/email.fixture.js +0 -25
  82. package/dist/email/email.fixture.js.map +0 -1
  83. package/dist/email/email.js +0 -83
  84. package/dist/email/email.js.map +0 -1
  85. package/dist/event/event.d.ts +0 -8
  86. package/dist/event/event.js +0 -23
  87. package/dist/event/event.js.map +0 -1
  88. package/dist/logging/eventLogger.d.ts +0 -17
  89. package/dist/logging/eventLogger.js +0 -38
  90. package/dist/logging/eventLogger.js.map +0 -1
  91. package/dist/registration/register.d.ts +0 -27
  92. package/dist/registration/register.fixture.d.ts +0 -53
  93. package/dist/registration/register.fixture.js +0 -66
  94. package/dist/registration/register.fixture.js.map +0 -1
  95. package/dist/registration/register.js +0 -78
  96. package/dist/registration/register.js.map +0 -1
  97. package/dist/rpc/authentication.d.ts +0 -8
  98. package/dist/rpc/authentication.js +0 -16
  99. package/dist/rpc/authentication.js.map +0 -1
  100. package/dist/rpc/client.d.ts +0 -30
  101. package/dist/rpc/client.js +0 -101
  102. package/dist/rpc/client.js.map +0 -1
  103. package/dist/rpc/config.d.ts +0 -15
  104. package/dist/rpc/config.js +0 -6
  105. package/dist/rpc/config.js.map +0 -1
  106. package/dist/rpc/connection.d.ts +0 -8
  107. package/dist/rpc/connection.js +0 -15
  108. package/dist/rpc/connection.js.map +0 -1
  109. package/dist/rpc/registration.d.ts +0 -8
  110. package/dist/rpc/registration.js +0 -16
  111. package/dist/rpc/registration.js.map +0 -1
  112. package/dist/rpc/social.d.ts +0 -10
  113. package/dist/rpc/social.js +0 -18
  114. package/dist/rpc/social.js.map +0 -1
  115. package/dist/rpc/user.d.ts +0 -8
  116. package/dist/rpc/user.js +0 -19
  117. package/dist/rpc/user.js.map +0 -1
  118. package/dist/social/social.d.ts +0 -24
  119. package/dist/social/social.fixture.d.ts +0 -46
  120. package/dist/social/social.fixture.js +0 -31
  121. package/dist/social/social.fixture.js.map +0 -1
  122. package/dist/social/social.js +0 -39
  123. package/dist/social/social.js.map +0 -1
  124. package/dist/storage/storage.d.ts +0 -56
  125. package/dist/storage/storage.fixture.d.ts +0 -4
  126. package/dist/storage/storage.fixture.js +0 -10
  127. package/dist/storage/storage.fixture.js.map +0 -1
  128. package/dist/storage/storage.js +0 -111
  129. package/dist/storage/storage.js.map +0 -1
  130. package/dist/test/fixtures.d.ts +0 -15
  131. package/dist/test/fixtures.js +0 -56
  132. package/dist/test/fixtures.js.map +0 -1
  133. package/dist/tsconfig.tsbuildinfo +0 -1
  134. package/dist/user/user.d.ts +0 -25
  135. package/dist/user/user.fixture.d.ts +0 -12
  136. package/dist/user/user.fixture.js +0 -20
  137. package/dist/user/user.fixture.js.map +0 -1
  138. package/dist/user/user.js +0 -38
  139. package/dist/user/user.js.map +0 -1
  140. package/dist/version.d.ts +0 -1
  141. package/dist/version.js +0 -2
  142. package/dist/version.js.map +0 -1
  143. package/src/authentication/authenticate.fixture.ts +0 -73
  144. package/src/authentication/authenticate.test.ts +0 -249
  145. package/src/authentication/authenticate.ts +0 -149
  146. package/src/capabilities/capabilities.ts +0 -83
  147. package/src/connection/connection.fixture.ts +0 -20
  148. package/src/connection/connection.test.ts +0 -60
  149. package/src/connection/connection.ts +0 -51
  150. package/src/effect.ts +0 -280
  151. package/src/email/email.fixture.ts +0 -44
  152. package/src/email/email.test.ts +0 -186
  153. package/src/email/email.ts +0 -148
  154. package/src/event/event.node.test.ts +0 -21
  155. package/src/event/event.test.ts +0 -37
  156. package/src/event/event.ts +0 -25
  157. package/src/index.ts +0 -407
  158. package/src/logging/eventLogger.test.ts +0 -104
  159. package/src/logging/eventLogger.ts +0 -41
  160. package/src/registration/register.fixture.ts +0 -96
  161. package/src/registration/register.test.ts +0 -216
  162. package/src/registration/register.ts +0 -158
  163. package/src/rpc/authentication.ts +0 -43
  164. package/src/rpc/client.ts +0 -174
  165. package/src/rpc/config.ts +0 -18
  166. package/src/rpc/connection.ts +0 -30
  167. package/src/rpc/registration.ts +0 -41
  168. package/src/rpc/social.ts +0 -45
  169. package/src/rpc/user.ts +0 -57
  170. package/src/social/social.fixture.ts +0 -45
  171. package/src/social/social.test.ts +0 -179
  172. package/src/social/social.ts +0 -82
  173. package/src/storage/storage.fixture.ts +0 -16
  174. package/src/storage/storage.test.ts +0 -206
  175. package/src/storage/storage.ts +0 -168
  176. package/src/test/fixtures.ts +0 -70
  177. package/src/user/user.fixture.ts +0 -33
  178. package/src/user/user.test.ts +0 -84
  179. package/src/user/user.ts +0 -73
  180. package/src/version.ts +0 -1
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Passlock
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,24 +0,0 @@
1
- import { Context, Effect as E, Layer } from 'effect';
2
- import { InternalBrowserError, type NotSupported } from '@passlock/shared/dist/error/error.js';
3
- import { type OptionsErrors, type OptionsReq, type VerificationErrors } from '@passlock/shared/dist/rpc/authentication.js';
4
- import type { AuthenticationCredential } from '@passlock/shared/dist/schema/passkey.js';
5
- import type { Principal } from '@passlock/shared/dist/schema/principal.js';
6
- import { Capabilities } from '../capabilities/capabilities.js';
7
- import { AuthenticationClient } from '../rpc/authentication.js';
8
- import { StorageService } from '../storage/storage.js';
9
- export type AuthenticationRequest = OptionsReq;
10
- export type AuthenticationErrors = NotSupported | OptionsErrors | VerificationErrors;
11
- declare const GetCredential_base: Context.TagClass<GetCredential, "@services/GetCredential", {
12
- getCredential: (request: CredentialRequestOptions) => E.Effect<AuthenticationCredential, InternalBrowserError>;
13
- }>;
14
- export declare class GetCredential extends GetCredential_base {
15
- }
16
- declare const AuthenticationService_base: Context.TagClass<AuthenticationService, "@services/AuthenticationService", {
17
- authenticatePasskey: (request: AuthenticationRequest) => E.Effect<Principal, AuthenticationErrors>;
18
- }>;
19
- export declare class AuthenticationService extends AuthenticationService_base {
20
- }
21
- type Dependencies = GetCredential | Capabilities | StorageService | AuthenticationClient;
22
- export declare const authenticatePasskey: (request: AuthenticationRequest) => E.Effect<Principal, AuthenticationErrors, Dependencies>;
23
- export declare const AuthenticateServiceLive: Layer.Layer<AuthenticationService, never, Capabilities | AuthenticationClient | StorageService | GetCredential>;
24
- export {};
@@ -1,52 +0,0 @@
1
- import { Layer as L } from 'effect';
2
- import { OptionsRes, VerificationReq, VerificationRes } from '@passlock/shared/dist/rpc/authentication.js';
3
- import { IsExistingUserRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
4
- import type { AuthenticationCredential } from '@passlock/shared/dist/schema/passkey.js';
5
- import { AuthenticationClient } from '../rpc/authentication.js';
6
- import { type AuthenticationRequest, GetCredential } from './authenticate.js';
7
- export declare const session = "session";
8
- export declare const token = "token";
9
- export declare const code = "code";
10
- export declare const authType = "passkey";
11
- export declare const expireAt: number;
12
- export declare const request: AuthenticationRequest;
13
- export declare const rpcOptionsRes: OptionsRes;
14
- export declare const credential: AuthenticationCredential;
15
- export declare const rpcVerificationReq: VerificationReq;
16
- export declare const rpcVerificationRes: VerificationRes;
17
- export declare const rpcIsExistingUserRes: IsExistingUserRes;
18
- export declare const rpcVerifyEmailRes: VerifyEmailRes;
19
- export declare const getCredentialTest: L.Layer<GetCredential, never, never>;
20
- export declare const rpcClientTest: L.Layer<AuthenticationClient, never, never>;
21
- export declare const principal: {
22
- readonly email?: string;
23
- readonly givenName?: string;
24
- readonly familyName?: string;
25
- readonly emailVerified?: boolean;
26
- readonly user?: {
27
- readonly id: string;
28
- readonly email: string;
29
- readonly givenName: string;
30
- readonly familyName: string;
31
- readonly emailVerified: boolean;
32
- };
33
- readonly iss: string;
34
- readonly aud: string;
35
- readonly sub: string;
36
- readonly iat: Date;
37
- readonly nbf: Date;
38
- readonly exp: Date;
39
- readonly jti: string;
40
- readonly token: string;
41
- readonly userVerified: boolean;
42
- readonly authType: "email" | "apple" | "google" | "passkey";
43
- readonly authId: string;
44
- readonly authStatement: {
45
- readonly userVerified: boolean;
46
- readonly authType: "email" | "apple" | "google" | "passkey";
47
- readonly authTimestamp: Date;
48
- };
49
- readonly expireAt: Date;
50
- };
51
- export declare const capabilitiesTest: L.Layer<import("../capabilities/capabilities.js").Capabilities, never, never>;
52
- export declare const storageServiceTest: L.Layer<import("../storage/storage.js").StorageService, never, never>;
@@ -1,50 +0,0 @@
1
- import { Effect as E, Layer as L, Option as O } from 'effect';
2
- import { OptionsRes, VerificationReq, VerificationRes, } from '@passlock/shared/dist/rpc/authentication.js';
3
- import { IsExistingUserRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
4
- import * as Fixtures from '../test/fixtures.js';
5
- import { AuthenticationClient } from '../rpc/authentication.js';
6
- import { GetCredential } from './authenticate.js';
7
- export const session = 'session';
8
- export const token = 'token';
9
- export const code = 'code';
10
- export const authType = 'passkey';
11
- export const expireAt = Date.now() + 10000;
12
- export const request = {
13
- userVerification: O.some('preferred'),
14
- email: O.none(),
15
- };
16
- export const rpcOptionsRes = new OptionsRes({
17
- session,
18
- publicKey: {
19
- rpId: 'passlock.dev',
20
- challenge: 'FKZSl_saKu5OXjLLwoq8eK3wlD8XgpGiS10SszW5RiE',
21
- timeout: 60000,
22
- userVerification: 'preferred',
23
- },
24
- });
25
- export const credential = {
26
- id: '1',
27
- type: 'public-key',
28
- rawId: 'id',
29
- response: {
30
- clientDataJSON: '',
31
- authenticatorData: '',
32
- signature: '',
33
- userHandle: null,
34
- },
35
- clientExtensionResults: {},
36
- authenticatorAttachment: null,
37
- };
38
- export const rpcVerificationReq = new VerificationReq({ session, credential });
39
- export const rpcVerificationRes = new VerificationRes({ principal: Fixtures.principal });
40
- export const rpcIsExistingUserRes = new IsExistingUserRes({ existingUser: true, detail: O.none() });
41
- export const rpcVerifyEmailRes = new VerifyEmailRes({ principal: Fixtures.principal });
42
- export const getCredentialTest = L.succeed(GetCredential, GetCredential.of({ getCredential: () => E.succeed(credential) }));
43
- export const rpcClientTest = L.succeed(AuthenticationClient, AuthenticationClient.of({
44
- getAuthenticationOptions: () => E.succeed(rpcOptionsRes),
45
- verifyAuthenticationCredential: () => E.succeed(rpcVerificationRes),
46
- }));
47
- export const principal = Fixtures.principal;
48
- export const capabilitiesTest = Fixtures.capabilitiesTest;
49
- export const storageServiceTest = Fixtures.storageServiceTest;
50
- //# sourceMappingURL=authenticate.fixture.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authenticate.fixture.js","sourceRoot":"","sources":["../../src/authentication/authenticate.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE7D,OAAO,EACL,UAAU,EACV,eAAe,EACf,eAAe,GAChB,MAAM,6CAA6C,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAGrF,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAA8B,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAE7E,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAA;AAChC,MAAM,CAAC,MAAM,KAAK,GA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,GAAG,IAAI,cAAc,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAA;AAEtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,OAAO,CACxC,aAAa,EACb,aAAa,CAAC,EAAE,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CACjE,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,OAAO,CACpC,oBAAoB,EACpB,oBAAoB,CAAC,EAAE,CAAC;IACtB,wBAAwB,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;IACxD,8BAA8B,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC;CACpE,CAAC,CACH,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;AAC3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,gBAAgB,CAAA;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,kBAAkB,CAAA"}
@@ -1,73 +0,0 @@
1
- /**
2
- * Passkey authentication effects
3
- */
4
- import { parseRequestOptionsFromJSON, } from '@github/webauthn-json/browser-ponyfill';
5
- import { Context, Effect as E, Layer, flow, pipe } from 'effect';
6
- import { InternalBrowserError } from '@passlock/shared/dist/error/error.js';
7
- import { VerificationReq, } from '@passlock/shared/dist/rpc/authentication.js';
8
- import { Capabilities } from '../capabilities/capabilities.js';
9
- import { AuthenticationClient } from '../rpc/authentication.js';
10
- import { StorageService } from '../storage/storage.js';
11
- /* Dependencies */
12
- export class GetCredential extends Context.Tag('@services/GetCredential')() {
13
- }
14
- /* Service */
15
- export class AuthenticationService extends Context.Tag('@services/AuthenticationService')() {
16
- }
17
- /* Utilities */
18
- const fetchOptions = (request) => {
19
- return E.gen(function* (_) {
20
- yield* _(E.logDebug('Making request'));
21
- const rpcClient = yield* _(AuthenticationClient);
22
- const { publicKey, session } = yield* _(rpcClient.getAuthenticationOptions(request));
23
- yield* _(E.logDebug('Converting Passlock options to CredentialRequestOptions'));
24
- const options = yield* _(toRequestOptions({ publicKey }));
25
- return { options, session };
26
- });
27
- };
28
- const toRequestOptions = (request) => {
29
- return pipe(E.try(() => parseRequestOptionsFromJSON(request)), E.mapError(error => new InternalBrowserError({
30
- message: 'Browser was unable to create credential request options',
31
- detail: String(error.error),
32
- })));
33
- };
34
- const verifyCredential = (request) => {
35
- return E.gen(function* (_) {
36
- yield* _(E.logDebug('Making request'));
37
- const rpcClient = yield* _(AuthenticationClient);
38
- const { principal } = yield* _(rpcClient.verifyAuthenticationCredential(request));
39
- return principal;
40
- });
41
- };
42
- export const authenticatePasskey = (request) => {
43
- const effect = E.gen(function* (_) {
44
- yield* _(E.logInfo('Checking if browser supports Passkeys'));
45
- const capabilities = yield* _(Capabilities);
46
- yield* _(capabilities.passkeySupport);
47
- yield* _(E.logInfo('Fetching authentication options from Passlock'));
48
- const { options, session } = yield* _(fetchOptions(request));
49
- yield* _(E.logInfo('Looking up credential'));
50
- const { getCredential } = yield* _(GetCredential);
51
- const credential = yield* _(getCredential(options));
52
- yield* _(E.logInfo('Verifying credential with Passlock'));
53
- const principal = yield* _(verifyCredential(new VerificationReq({ credential, session })));
54
- const storageService = yield* _(StorageService);
55
- yield* _(storageService.storeToken(principal));
56
- yield* _(E.logDebug('Stored token in local storage'));
57
- yield* _(E.logDebug('Defering local token deletion'));
58
- const delayedClearTokenE = pipe(storageService.clearExpiredToken('passkey'), E.delay('6 minutes'), E.fork);
59
- yield* _(delayedClearTokenE);
60
- return principal;
61
- });
62
- return E.catchTag(effect, 'InternalBrowserError', e => E.die(e));
63
- };
64
- /* Live */
65
- /* v8 ignore start */
66
- export const AuthenticateServiceLive = Layer.effect(AuthenticationService, E.gen(function* (_) {
67
- const context = yield* _(E.context());
68
- return AuthenticationService.of({
69
- authenticatePasskey: flow(authenticatePasskey, E.provide(context)),
70
- });
71
- }));
72
- /* v8 ignore stop */
73
- //# sourceMappingURL=authenticate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../src/authentication/authenticate.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAEL,2BAA2B,GAC5B,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAEhE,OAAO,EAAE,oBAAoB,EAAqB,MAAM,sCAAsC,CAAA;AAC9F,OAAO,EAIL,eAAe,GAChB,MAAM,6CAA6C,CAAA;AAIpD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAStD,kBAAkB;AAElB,MAAM,OAAO,aAAc,SAAQ,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,EAOtE;CAAG;AAEN,aAAa;AAEb,MAAM,OAAO,qBAAsB,SAAQ,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,EAOtF;CAAG;AAEN,eAAe;AAEf,MAAM,YAAY,GAAG,CAAC,OAAmB,EAAE,EAAE;IAC3C,OAAO,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAA;QAEtC,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAA;QAChD,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,wBAAwB,CAAC,OAAO,C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CAAC,QAAQ,CAAC,+BAA+B,CAAC,CAAC,CAAA;QACrD,MAAM,kBAAkB,GAAG,IAAI,CAC7B,cAAc,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAC3C,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,EACpB,CAAC,CAAC,IAAI,CACP,CAAA;QACD,KAAK,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAA;QAE5B,OAAO,SAAS,CAAA;IAClB,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,sBAAsB,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AAClE,CAAC,CAAA;AAED,UAAU;AAEV,qBAAqB;AACrB,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC,MAAM,CACjD,qBAAqB,EACrB,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;IAChB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CACtB,CAAC,CAAC,OAAO,EAAwE,CAClF,CAAA;IAED,OAAO,qBAAqB,CAAC,EAAE,CAAC;QAC9B,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;KACnE,CAAC,CAAA;AACJ,CAAC,CAAC,CACH,CAAA;AACD,oBAAoB"}
@@ -1,19 +0,0 @@
1
- /**
2
- * Test if the browser supports passkeys, conditional UI etc
3
- */
4
- import { Context, Effect as E, Layer } from 'effect';
5
- import { NotSupported } from '@passlock/shared/dist/error/error.js';
6
- declare const Capabilities_base: Context.TagClass<Capabilities, "@services/Capabilities", {
7
- passkeySupport: E.Effect<void, NotSupported>;
8
- isPasskeySupport: E.Effect<boolean>;
9
- autofillSupport: E.Effect<void, NotSupported>;
10
- isAutofillSupport: E.Effect<boolean>;
11
- }>;
12
- export declare class Capabilities extends Capabilities_base {
13
- }
14
- export declare const passkeySupport: E.Effect<void, NotSupported, never>;
15
- export declare const isPasskeySupport: E.Effect<boolean, never, never>;
16
- export declare const autofillSupport: E.Effect<void, NotSupported, never>;
17
- export declare const isAutofillSupport: E.Effect<boolean, never, never>;
18
- export declare const capabilitiesLive: Layer.Layer<Capabilities, never, never>;
19
- export {};
@@ -1,37 +0,0 @@
1
- /**
2
- * Test if the browser supports passkeys, conditional UI etc
3
- */
4
- import { Context, Effect as E, Layer, identity, pipe } from 'effect';
5
- import { NotSupported } from '@passlock/shared/dist/error/error.js';
6
- /* Service */
7
- export class Capabilities extends Context.Tag('@services/Capabilities')() {
8
- }
9
- /* Effects */
10
- const hasWebAuthn = E.suspend(() => typeof window.PublicKeyCredential === 'function'
11
- ? E.void
12
- : new NotSupported({ message: 'WebAuthn API is not supported on this device' }));
13
- const hasPlatformAuth = pipe(E.tryPromise(() => window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()), E.filterOrFail(identity, () => new NotSupported({ message: 'No platform authenticator available on this device' })), E.asVoid);
14
- const hasConditionalUi = pipe(E.tryPromise({
15
- try: () => window.PublicKeyCredential.isConditionalMediationAvailable(),
16
- catch: () => new NotSupported({ message: 'Conditional mediation not available on this device' }),
17
- }), E.filterOrFail(identity, () => new NotSupported({ message: 'Conditional mediation not available on this device' })), E.asVoid);
18
- export const passkeySupport = pipe(hasWebAuthn, E.andThen(hasPlatformAuth), E.catchTag('UnknownException', e => E.die(e)));
19
- export const isPasskeySupport = pipe(passkeySupport, E.match({
20
- onFailure: () => false,
21
- onSuccess: () => true,
22
- }));
23
- export const autofillSupport = pipe(passkeySupport, E.andThen(hasConditionalUi));
24
- export const isAutofillSupport = pipe(autofillSupport, E.match({
25
- onFailure: () => false,
26
- onSuccess: () => true,
27
- }));
28
- /* Live */
29
- /* v8 ignore start */
30
- export const capabilitiesLive = Layer.succeed(Capabilities, {
31
- passkeySupport,
32
- isPasskeySupport,
33
- autofillSupport,
34
- isAutofillSupport,
35
- });
36
- /* v8 ignore stop */
37
- //# sourceMappingURL=capabilities.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/capabilities/capabilities.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAEpE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAEnE,aAAa;AAEb,MAAM,OAAO,YAAa,SAAQ,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,EAQpE;CAAG;AAEN,aAAa;AAEb,MAAM,WAAW,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CACjC,OAAO,MAAM,CAAC,mBAAmB,KAAK,UAAU;IAC9C,CAAC,CAAC,CAAC,CAAC,IAAI;IACR,CAAC,CAAC,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,8CAA8C,EAAE,CAAC,CAClF,CAAA;AAED,MAAM,eAAe,GAAG,IAAI,CAC1B,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,6CAA6C,EAAE,CAAC,EAC9F,CAAC,CAAC,YAAY,CACZ,QAAQ,EACR,GAAG,EAAE,CAAC,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,oDAAoD,EAAE,CAAC,CAC1F,EACD,CAAC,CAAC,MAAM,CACT,CAAA;AAED,MAAM,gBAAgB,GAAG,IAAI,CAC3B,CAAC,CAAC,UAAU,CAAC;IACX,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,+BAA+B,EAAE;IACvE,KAAK,EAAE,GAAG,EAAE,CACV,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,oDAAoD,EAAE,CAAC;CACtF,CAAC,EACF,CAAC,CAAC,YAAY,CACZ,QAAQ,EACR,GAAG,EAAE,CAAC,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,oDAAoD,EAAE,CAAC,CAC1F,EACD,CAAC,CAAC,MAAM,CACT,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAChC,WAAW,EACX,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,EAC1B,CAAC,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAC9C,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAClC,cAAc,EACd,CAAC,CAAC,KAAK,CAAC;IACN,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK;IACtB,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI;CACtB,CAAC,CACH,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAA;AAEhF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CACnC,eAAe,EACf,CAAC,CAAC,KAAK,CAAC;IACN,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK;IACtB,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI;CACtB,CAAC,CACH,CAAA;AAED,UAAU;AAEV,qBAAqB;AACrB,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE;IAC1D,cAAc;IACd,gBAAgB;IAChB,eAAe;IACf,iBAAiB;CAClB,CAAC,CAAA;AACF,oBAAoB"}
@@ -1,15 +0,0 @@
1
- /**
2
- * Hits the rpc endpoint to warm up a lambda
3
- */
4
- import { Context, Effect as E, Layer } from 'effect';
5
- import { Dispatcher } from '../rpc/client.js';
6
- import type { RpcConfig } from '../rpc/config.js';
7
- import { ConnectionClient } from '../rpc/connection.js';
8
- declare const ConnectionService_base: Context.TagClass<ConnectionService, "@services/ConnectionService", {
9
- preConnect: () => E.Effect<void>;
10
- }>;
11
- export declare class ConnectionService extends ConnectionService_base {
12
- }
13
- export declare const preConnect: () => E.Effect<void, never, Dispatcher | ConnectionClient>;
14
- export declare const ConnectionServiceLive: Layer.Layer<ConnectionService, never, RpcConfig | Dispatcher | ConnectionClient>;
15
- export {};
@@ -1,10 +0,0 @@
1
- import { Layer as L } from 'effect';
2
- import { ConnectRes } from '@passlock/shared/dist/rpc/connection.js';
3
- import { ConnectionClient } from '../rpc/connection.js';
4
- export declare const preConnectRes: ConnectRes;
5
- export declare const rpcClientTest: L.Layer<ConnectionClient, never, never>;
6
- export declare const rpcConfig: {
7
- endpoint: string;
8
- tenancyId: string;
9
- clientId: string;
10
- };
@@ -1,13 +0,0 @@
1
- import { Effect as E, Layer as L } from 'effect';
2
- import { ConnectRes } from '@passlock/shared/dist/rpc/connection.js';
3
- import { ConnectionClient } from '../rpc/connection.js';
4
- export const preConnectRes = new ConnectRes({ warmed: true });
5
- export const rpcClientTest = L.succeed(ConnectionClient, ConnectionClient.of({
6
- preConnect: () => E.succeed(preConnectRes),
7
- }));
8
- export const rpcConfig = {
9
- endpoint: 'https://example.com',
10
- tenancyId: 'tenancyId',
11
- clientId: 'clientId',
12
- };
13
- //# sourceMappingURL=connection.fixture.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection.fixture.js","sourceRoot":"","sources":["../../src/connection/connection.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAA;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEvD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;AAE7D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,OAAO,CACpC,gBAAgB,EAChB,gBAAgB,CAAC,EAAE,CAAC;IAClB,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;CAC3C,CAAC,CACH,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,QAAQ,EAAE,qBAAqB;IAC/B,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;CACrB,CAAA"}
@@ -1,23 +0,0 @@
1
- /**
2
- * Hits the rpc endpoint to warm up a lambda
3
- */
4
- import { Context, Effect as E, Layer, flow, pipe } from 'effect';
5
- import { Dispatcher } from '../rpc/client.js';
6
- import { ConnectionClient } from '../rpc/connection.js';
7
- /* Service */
8
- export class ConnectionService extends Context.Tag('@services/ConnectionService')() {
9
- }
10
- /* Effects */
11
- const hitPrincipal = pipe(E.logInfo('Pre-connecting to Principal endpoint'), E.zipRight(Dispatcher), E.flatMap(dispatcher => dispatcher.get('/token/token?warm=true')), E.asVoid, E.catchAll(() => E.void));
12
- const hitRpc = pipe(E.logInfo('Pre-connecting to RPC endpoint'), E.zipRight(ConnectionClient), E.flatMap(rpcClient => rpcClient.preConnect()), E.asVoid);
13
- export const preConnect = () => pipe(E.all([hitPrincipal, hitRpc], { concurrency: 2 }), E.asVoid);
14
- /* Live */
15
- /* v8 ignore start */
16
- export const ConnectionServiceLive = Layer.effect(ConnectionService, E.gen(function* (_) {
17
- const context = yield* _(E.context());
18
- return ConnectionService.of({
19
- preConnect: flow(preConnect, E.provide(context)),
20
- });
21
- }));
22
- /* v8 ignore stop */
23
- //# sourceMappingURL=connection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/connection/connection.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAEhE,OAAO,EAAE,UAAU,EAAE,M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C;QAC1B,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;KACjD,CAAC,CAAA;AACJ,CAAC,CAAC,CACH,CAAA;AACD,oBAAoB"}
package/dist/effect.d.ts DELETED
@@ -1,26 +0,0 @@
1
- import { Effect as E, Layer as L } from 'effect';
2
- import type { NoSuchElementException } from 'effect/Cause';
3
- import { type BadRequest } from '@passlock/shared/dist/error/error.js';
4
- import type { Principal } from '@passlock/shared/dist/schema/principal.js';
5
- import { type AuthenticationErrors, type AuthenticationRequest, AuthenticationService } from './authentication/authenticate.js';
6
- import { Capabilities } from './capabilities/capabilities.js';
7
- import { ConnectionService } from './connection/connection.js';
8
- import { EmailService, type VerifyEmailErrors, type VerifyRequest } from './email/email.js';
9
- import { type RegistrationErrors, type RegistrationRequest, RegistrationService } from './registration/register.js';
10
- import type { RpcConfig } from './rpc/config.js';
11
- import { type AuthenticateOidcReq, type AuthenticationErrors as OidcAuthenticationErrors, type RegistrationErrors as OidcRegistrationErrors, type RegisterOidcReq, SocialService } from './social/social.js';
12
- import { type AuthType, BrowserStorage, StorageService, type StoredToken } from './storage/storage.js';
13
- import { type Email, type ResendEmail, type ResendEmailErrors, UserService } from './user/user.js';
14
- export declare const allRequirements: L.Layer<Capabilities | StorageService | AuthenticationService | ConnectionService | EmailService | UserService | RegistrationService | SocialService, never, RpcConfig | BrowserStorage>;
15
- export declare const preConnect: () => E.Effect<void, never, RpcConfig>;
16
- export declare const isPasskeySupport: E.Effect<boolean>;
17
- export declare const isExistingUser: (request: Email) => E.Effect<boolean, BadRequest, RpcConfig>;
18
- export declare const registerPasskey: (request: RegistrationRequest) => E.Effect<Principal, RegistrationErrors, RpcConfig>;
19
- export declare const authenticatePasskey: (request: AuthenticationRequest) => E.Effect<Principal, AuthenticationErrors, RpcConfig>;
20
- export declare const verifyEmailCode: (request: VerifyRequest) => E.Effect<Principal, VerifyEmailErrors, RpcConfig>;
21
- export declare const verifyEmailLink: E.Effect<Principal, VerifyEmailErrors, RpcConfig>;
22
- export declare const resendVerificationEmail: (request: ResendEmail) => E.Effect<void, ResendEmailErrors, RpcConfig>;
23
- export declare const getSessionToken: (authType: AuthType) => E.Effect<StoredToken, NoSuchElementException>;
24
- export declare const clearExpiredTokens: E.Effect<void>;
25
- export declare const registerOidc: (request: RegisterOidcReq) => E.Effect<Principal, OidcRegistrationErrors, RpcConfig>;
26
- export declare const authenticateOidc: (request: AuthenticateOidcReq) => E.Effect<Principal, OidcAuthenticationErrors, RpcConfig>;
package/dist/effect.js DELETED
@@ -1,78 +0,0 @@
1
- import { create, get as getCredential } from '@github/webauthn-json/browser-ponyfill';
2
- import { Effect as E, Layer as L, Layer, Schedule, pipe } from 'effect';
3
- import { Duplicate, InternalBrowserError, } from '@passlock/shared/dist/error/error.js';
4
- import { AuthenticateServiceLive, AuthenticationService, GetCredential, } from './authentication/authenticate.js';
5
- import { Capabilities, capabilitiesLive } from './capabilities/capabilities.js';
6
- import { ConnectionService, ConnectionServiceLive } from './connection/connection.js';
7
- import { EmailService, EmailServiceLive, URLQueryString, } from './email/email.js';
8
- import { CreateCredential, RegistrationService, RegistrationServiceLive, } from './registration/register.js';
9
- import { AuthenticationClientLive } from './rpc/authentication.js';
10
- import { DispatcherLive } from './rpc/client.js';
11
- import { RetrySchedule } from './rpc/config.js';
12
- import { ConnectionClientLive } from './rpc/connection.js';
13
- import { RegistrationClientLive } from './rpc/registration.js';
14
- import { SocialClientLive } from './rpc/social.js';
15
- import { UserClientLive } from './rpc/user.js';
16
- import { SocialService, SocialServiceLive, } from './social/social.js';
17
- import { BrowserStorage, StorageService, StorageServiceLive, } from './storage/storage.js';
18
- import { UserService, UserServiceLive, } from './user/user.js';
19
- /* Layers */
20
- const createCredentialLive = L.succeed(CreateCredential, CreateCredential.of({
21
- createCredential: options => pipe(E.tryPromise({
22
- try: () => create(options),
23
- catch: e => {
24
- if (e instanceof Error && e.message.includes('excludeCredentials')) {
25
- return new Duplicate({
26
- message: 'Passkey already registered to this device or cloud account',
27
- });
28
- }
29
- else {
30
- return new InternalBrowserError({
31
- message: 'Unable to create credential',
32
- detail: String(e),
33
- });
34
- }
35
- },
36
- }), E.map(credential => credential.toJSON())),
37
- }));
38
- const getCredentialLive = L.succeed(GetCredential, GetCredential.of({
39
- getCredential: (options) => pipe(E.tryPromise({
40
- try: () => getCredential(options),
41
- catch: e => new InternalBrowserError({
42
- message: 'Unable to get authentication credential',
43
- detail: String(e),
44
- }),
45
- }), E.map(credential => credential.toJSON())),
46
- }));
47
- const schedule = Schedule.intersect(Schedule.recurs(3), Schedule.exponential('100 millis'));
48
- const retryScheduleLive = L.succeed(RetrySchedule, RetrySchedule.of({ schedule }));
49
- /* Services */
50
- const dispatcherLive = pipe(DispatcherLive, L.provide(retryScheduleLive));
51
- const connectClientLive = pipe(ConnectionClientLive, L.provide(dispatcherLive));
52
- const registerClientLive = pipe(RegistrationClientLive, L.provide(dispatcherLive));
53
- const authenticateClientLive = pipe(AuthenticationClientLive, L.provide(dispatcherLive));
54
- const socialClientLive = pipe(SocialClientLive, L.provide(dispatcherLive));
55
- const userClientLive = pipe(UserClientLive, L.provide(dispatcherLive));
56
- const storageServiceLive = StorageServiceLive;
57
- const userServiceLive = pipe(UserServiceLive, L.provide(userClientLive));
58
- const registrationServiceLive = pipe(RegistrationServiceLive, L.provide(registerClientLive), L.provide(userServiceLive), L.provide(capabilitiesLive), L.provide(createCredentialLive), L.provide(storageServiceLive));
59
- const authenticationServiceLive = pipe(AuthenticateServiceLive, L.provide(authenticateClientLive), L.provide(capabilitiesLive), L.provide(getCredentialLive), L.provide(storageServiceLive));
60
- const connectionServiceLive = pipe(ConnectionServiceLive, L.provide(connectClientLive), L.provide(dispatcherLive));
61
- const urlQueryStringLive = Layer.succeed(URLQueryString, URLQueryString.of(E.sync(() => globalThis.window.location.search)));
62
- const emailServiceLive = pipe(EmailServiceLive, L.provide(urlQueryStringLive), L.provide(userClientLive), L.provide(capabilitiesLive), L.provide(authenticationServiceLive), L.provide(storageServiceLive));
63
- const socialServiceLive = pipe(SocialServiceLive, L.provide(socialClientLive));
64
- export const allRequirements = Layer.mergeAll(capabilitiesLive, userServiceLive, registrationServiceLive, authenticationServiceLive, connectionServiceLive, emailServiceLive, storageServiceLive, socialServiceLive);
65
- const browserStorageLive = Layer.effect(BrowserStorage, E.sync(() => BrowserStorage.of(globalThis.localStorage)));
66
- export const preConnect = () => pipe(ConnectionService, E.flatMap(service => service.preConnect()), E.provide(connectionServiceLive));
67
- export const isPasskeySupport = pipe(Capabilities, E.flatMap(service => service.isPasskeySupport), E.provide(capabilitiesLive));
68
- export const isExistingUser = (request) => pipe(UserService, E.flatMap(service => service.isExistingUser(request)), E.provide(userServiceLive));
69
- export const registerPasskey = (request) => pipe(RegistrationService, E.flatMap(service => service.registerPasskey(request)), E.provide(registrationServiceLive), E.provide(browserStorageLive));
70
- export const authenticatePasskey = (request) => pipe(AuthenticationService, E.flatMap(service => service.authenticatePasskey(request)), E.provide(authenticationServiceLive), E.provide(browserStorageLive));
71
- export const verifyEmailCode = (request) => pipe(EmailService, E.flatMap(service => service.verifyEmailCode(request)), E.provide(emailServiceLive), E.provide(browserStorageLive));
72
- export const verifyEmailLink = pipe(EmailService, E.flatMap(service => service.verifyEmailLink()), E.provide(emailServiceLive), E.provide(browserStorageLive));
73
- export const resendVerificationEmail = (request) => pipe(UserService, E.flatMap(service => service.resendVerificationEmail(request)), E.provide(userServiceLive), E.provide(browserStorageLive));
74
- export const getSessionToken = (authType) => pipe(StorageService, E.flatMap(service => service.getToken(authType)), E.provide(storageServiceLive), E.provide(browserStorageLive));
75
- export const clearExpiredTokens = pipe(StorageService, E.flatMap(service => service.clearExpiredTokens), E.provide(storageServiceLive), E.provide(browserStorageLive));
76
- export const registerOidc = (request) => pipe(SocialService, E.flatMap(service => service.registerOidc(request)), E.provide(socialServiceLive));
77
- export const authenticateOidc = (request) => pipe(SocialService, E.flatMap(service => service.authenticateOidc(request)), E.provide(social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,CAAC,CAAC,EAChD,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAC7B,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAC9B,CAAA;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAmB,IAAI,CACpD,cAAc,EACd,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAChD,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAC7B,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAC9B,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAAwB,EACgC,EAAE,CAC1D,IAAI,CACF,aAAa,EACb,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,EACnD,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAC7B,CAAA;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,OAA4B,EAC8B,EAAE,CAC5D,IAAI,CACF,aAAa,EACb,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,EACvD,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAC7B,CAAA"}
@@ -1,70 +0,0 @@
1
- /**
2
- * Email verification effects
3
- */
4
- import { Context, Effect as E, Layer } from 'effect';
5
- import type { VerifyEmailErrors as RpcErrors } from '@passlock/shared/dist/rpc/user.js';
6
- import type { Principal } from '@passlock/shared/dist/schema/principal.js';
7
- import { type AuthenticationErrors, AuthenticationService } from '../authentication/authenticate.js';
8
- import { UserClient } from '../rpc/user.js';
9
- import { StorageService } from '../storage/storage.js';
10
- export type VerifyRequest = {
11
- code: string;
12
- };
13
- export type VerifyEmailErrors = RpcErrors | AuthenticationErrors;
14
- declare const URLQueryString_base: Context.TagClass<URLQueryString, "@utils/URLQueryString", E.Effect<string, never, never>>;
15
- export declare class URLQueryString extends URLQueryString_base {
16
- }
17
- declare const EmailService_base: Context.TagClass<EmailService, "@services/EmailService", {
18
- verifyEmailCode: (request: VerifyRequest) => E.Effect<Principal, VerifyEmailErrors>;
19
- verifyEmailLink: () => E.Effect<Principal, VerifyEmailErrors>;
20
- }>;
21
- export declare class EmailService extends EmailService_base {
22
- }
23
- export type Dependencies = StorageService | AuthenticationService | UserClient;
24
- /**
25
- * Look for ?code=<code> in the url
26
- * @returns
27
- */
28
- export declare const extractCodeFromHref: () => E.Effect<string, import("effect/Cause").NoSuchElementException, URLQueryString>;
29
- /**
30
- * Verify the mailbox using the given code
31
- * @param request
32
- * @returns
33
- */
34
- export declare const verifyEmail: (request: VerifyRequest) => E.Effect<Principal, VerifyEmailErrors, Dependencies>;
35
- /**
36
- * Look for a code in the current url and verify it
37
- * @returns
38
- */
39
- export declare const verifyEmailLink: () => E.Effect<{
40
- readonly email?: string;
41
- readonly givenName?: string;
42
- readonly familyName?: string;
43
- readonly emailVerified?: boolean;
44
- readonly user?: {
45
- readonly id: string;
46
- readonly email: string;
47
- readonly givenName: string;
48
- readonly familyName: string;
49
- readonly emailVerified: boolean;
50
- };
51
- readonly iss: string;
52
- readonly aud: string;
53
- readonly sub: string;
54
- readonly iat: Date;
55
- readonly nbf: Date;
56
- readonly exp: Date;
57
- readonly jti: string;
58
- readonly token: string;
59
- readonly userVerified: boolean;
60
- readonly authType: "email" | "apple" | "google" | "passkey";
61
- readonly authId: string;
62
- readonly authStatement: {
63
- readonly userVerified: boolean;
64
- readonly authType: "email" | "apple" | "google" | "passkey";
65
- readonly authTimestamp: Date;
66
- };
67
- readonly expireAt: Date;
68
- }, VerifyEmailErrors, URLQueryString | Dependencies>;
69
- export declare const EmailServiceLive: Layer.Layer<EmailService, never, StorageService | AuthenticationService | UserClient | URLQueryString>;
70
- export {};
@@ -1,46 +0,0 @@
1
- import { Layer as L } from 'effect';
2
- import { VerifyEmailReq, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
3
- import { AuthenticationService } from '../authentication/authenticate.js';
4
- import { UserClient } from '../rpc/user.js';
5
- import { URLQueryString } from './email.js';
6
- export declare const token = "token";
7
- export declare const code = "code";
8
- export declare const authType = "passkey";
9
- export declare const expireAt: number;
10
- export declare const locationSearchTest: L.Layer<URLQueryString, never, never>;
11
- export declare const authenticationServiceTest: L.Layer<AuthenticationService, never, never>;
12
- export declare const rpcVerifyEmailReq: VerifyEmailReq;
13
- export declare const rpcVerifyEmailRes: VerifyEmailRes;
14
- export declare const rpcClientTest: L.Layer<UserClient, never, never>;
15
- export declare const principal: {
16
- readonly email?: string;
17
- readonly givenName?: string;
18
- readonly familyName?: string;
19
- readonly emailVerified?: boolean;
20
- readonly user?: {
21
- readonly id: string;
22
- readonly email: string;
23
- readonly givenName: string;
24
- readonly familyName: string;
25
- readonly emailVerified: boolean;
26
- };
27
- readonly iss: string;
28
- readonly aud: string;
29
- readonly sub: string;
30
- readonly iat: Date;
31
- readonly nbf: Date;
32
- readonly exp: Date;
33
- readonly jti: string;
34
- readonly token: string;
35
- readonly userVerified: boolean;
36
- readonly authType: "email" | "apple" | "google" | "passkey";
37
- readonly authId: string;
38
- readonly authStatement: {
39
- readonly userVerified: boolean;
40
- readonly authType: "email" | "apple" | "google" | "passkey";
41
- readonly authTimestamp: Date;
42
- };
43
- readonly expireAt: Date;
44
- };
45
- export declare const storedToken: import("../index.js").StoredToken;
46
- export declare const storageServiceTest: L.Layer<import("../storage/storage.js").StorageService, never, never>;