@passlock/client 0.9.22 → 0.9.23
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.
- package/dist/authentication/authenticate.d.ts +15 -15
- package/dist/authentication/authenticate.fixture.d.ts +20 -6
- package/dist/authentication/authenticate.fixture.js +7 -5
- package/dist/authentication/authenticate.fixture.js.map +1 -1
- package/dist/authentication/authenticate.js +19 -8
- package/dist/authentication/authenticate.js.map +1 -1
- package/dist/capabilities/capabilities.d.ts +8 -4
- package/dist/capabilities/capabilities.js +10 -1
- package/dist/capabilities/capabilities.js.map +1 -1
- package/dist/connection/connection.d.ts +11 -7
- package/dist/connection/connection.fixture.d.ts +2 -2
- package/dist/connection/connection.fixture.js +2 -1
- package/dist/connection/connection.fixture.js.map +1 -1
- package/dist/connection/connection.js +12 -3
- package/dist/connection/connection.js.map +1 -1
- package/dist/effect.d.ts +22 -45
- package/dist/effect.js +55 -51
- package/dist/effect.js.map +1 -1
- package/dist/email/email.d.ts +38 -11
- package/dist/email/email.fixture.d.ts +19 -5
- package/dist/email/email.fixture.js +4 -3
- package/dist/email/email.fixture.js.map +1 -1
- package/dist/email/email.js +43 -7
- package/dist/email/email.js.map +1 -1
- package/dist/event/event.d.ts +3 -1
- package/dist/event/event.js +3 -0
- package/dist/event/event.js.map +1 -1
- package/dist/index.d.ts +105 -27
- package/dist/index.js +101 -50
- package/dist/index.js.map +1 -1
- package/dist/logging/eventLogger.d.ts +13 -1
- package/dist/logging/eventLogger.js +13 -0
- package/dist/logging/eventLogger.js.map +1 -1
- package/dist/registration/register.d.ts +18 -21
- package/dist/registration/register.fixture.d.ts +19 -5
- package/dist/registration/register.fixture.js +14 -7
- package/dist/registration/register.fixture.js.map +1 -1
- package/dist/registration/register.js +18 -9
- package/dist/registration/register.js.map +1 -1
- package/dist/rpc/authentication.d.ts +0 -1
- package/dist/rpc/authentication.js +1 -0
- package/dist/rpc/authentication.js.map +1 -1
- package/dist/rpc/client.d.ts +4 -1
- package/dist/rpc/client.js +12 -2
- package/dist/rpc/client.js.map +1 -1
- package/dist/rpc/config.d.ts +0 -1
- package/dist/rpc/connection.d.ts +0 -1
- package/dist/rpc/connection.js +1 -0
- package/dist/rpc/connection.js.map +1 -1
- package/dist/rpc/registration.d.ts +0 -1
- package/dist/rpc/registration.js +1 -0
- package/dist/rpc/registration.js.map +1 -1
- package/dist/rpc/social.d.ts +0 -1
- package/dist/rpc/social.js +1 -0
- package/dist/rpc/social.js.map +1 -1
- package/dist/rpc/user.d.ts +0 -1
- package/dist/rpc/user.js +1 -0
- package/dist/rpc/user.js.map +1 -1
- package/dist/social/social.d.ts +16 -23
- package/dist/social/social.fixture.d.ts +21 -9
- package/dist/social/social.fixture.js +8 -14
- package/dist/social/social.fixture.js.map +1 -1
- package/dist/social/social.js +14 -10
- package/dist/social/social.js.map +1 -1
- package/dist/storage/storage.d.ts +40 -12
- package/dist/storage/storage.fixture.d.ts +2 -2
- package/dist/storage/storage.fixture.js +2 -2
- package/dist/storage/storage.fixture.js.map +1 -1
- package/dist/storage/storage.js +48 -15
- package/dist/storage/storage.js.map +1 -1
- package/dist/test/fixtures.d.ts +1 -2
- package/dist/test/fixtures.js +20 -5
- package/dist/test/fixtures.js.map +1 -1
- package/dist/user/user.d.ts +8 -5
- package/dist/user/user.fixture.d.ts +2 -2
- package/dist/user/user.fixture.js +9 -5
- package/dist/user/user.fixture.js.map +1 -1
- package/dist/user/user.js +9 -3
- package/dist/user/user.js.map +1 -1
- package/dist/version.d.ts +1 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +30 -26
- package/src/authentication/authenticate.fixture.ts +8 -7
- package/src/authentication/authenticate.test.ts +59 -17
- package/src/authentication/authenticate.ts +34 -32
- package/src/capabilities/capabilities.ts +9 -8
- package/src/connection/connection.fixture.ts +2 -1
- package/src/connection/connection.test.ts +3 -3
- package/src/connection/connection.ts +9 -8
- package/src/effect.ts +129 -128
- package/src/email/email.fixture.ts +4 -3
- package/src/email/email.test.ts +4 -4
- package/src/email/email.ts +24 -16
- package/src/index.ts +225 -169
- package/src/logging/eventLogger.test.ts +1 -1
- package/src/logging/eventLogger.ts +2 -2
- package/src/registration/register.fixture.ts +14 -8
- package/src/registration/register.test.ts +13 -9
- package/src/registration/register.ts +37 -34
- package/src/rpc/authentication.ts +31 -0
- package/src/rpc/client.ts +173 -0
- package/src/rpc/config.ts +18 -0
- package/src/rpc/connection.ts +24 -0
- package/src/rpc/registration.ts +31 -0
- package/src/rpc/social.ts +36 -0
- package/src/rpc/user.ts +42 -0
- package/src/social/social.fixture.ts +10 -18
- package/src/social/social.test.ts +13 -29
- package/src/social/social.ts +20 -47
- package/src/storage/storage.fixture.ts +3 -4
- package/src/storage/storage.test.ts +28 -19
- package/src/storage/storage.ts +36 -36
- package/src/test/fixtures.ts +21 -6
- package/src/user/user.fixture.ts +17 -7
- package/src/user/user.test.ts +2 -5
- package/src/user/user.ts +13 -9
- package/src/version.ts +1 -0
- package/dist/authentication/authenticate.d.ts.map +0 -1
- package/dist/authentication/authenticate.fixture.d.ts.map +0 -1
- package/dist/capabilities/capabilities.d.ts.map +0 -1
- package/dist/config.d.ts +0 -18
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -20
- package/dist/config.js.map +0 -1
- package/dist/connection/connection.d.ts.map +0 -1
- package/dist/connection/connection.fixture.d.ts.map +0 -1
- package/dist/effect.d.ts.map +0 -1
- package/dist/email/email.d.ts.map +0 -1
- package/dist/email/email.fixture.d.ts.map +0 -1
- package/dist/event/event.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/logging/eventLogger.d.ts.map +0 -1
- package/dist/registration/register.d.ts.map +0 -1
- package/dist/registration/register.fixture.d.ts.map +0 -1
- package/dist/rpc/authentication.d.ts.map +0 -1
- package/dist/rpc/client.d.ts.map +0 -1
- package/dist/rpc/config.d.ts.map +0 -1
- package/dist/rpc/connection.d.ts.map +0 -1
- package/dist/rpc/registration.d.ts.map +0 -1
- package/dist/rpc/social.d.ts.map +0 -1
- package/dist/rpc/user.d.ts.map +0 -1
- package/dist/social/social.d.ts.map +0 -1
- package/dist/social/social.fixture.d.ts.map +0 -1
- package/dist/storage/storage.d.ts.map +0 -1
- package/dist/storage/storage.fixture.d.ts.map +0 -1
- package/dist/test/fixtures.d.ts.map +0 -1
- package/dist/user/user.d.ts.map +0 -1
- package/dist/user/user.fixture.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/src/config.ts +0 -42
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { InternalBrowserError, type NotSupported } from '@passlock/shared/dist/error/error.js';
|
|
2
|
-
import type
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
import { Principal } from '@passlock/shared/dist/schema/principal.js';
|
|
2
|
+
import { type OptionsErrors, type OptionsReq, type VerificationErrors } from '@passlock/shared/dist/rpc/authentication.js';
|
|
3
|
+
import type { AuthenticationCredential } from '@passlock/shared/dist/schema/passkey.js';
|
|
4
|
+
import type { Principal } from '@passlock/shared/dist/schema/principal.js';
|
|
6
5
|
import { Context, Effect as E, Layer } from 'effect';
|
|
7
6
|
import { Capabilities } from '../capabilities/capabilities.js';
|
|
7
|
+
import { AuthenticationClient } from '../rpc/authentication.js';
|
|
8
8
|
import { StorageService } from '../storage/storage.js';
|
|
9
|
-
export type AuthenticationRequest =
|
|
10
|
-
email?: string;
|
|
11
|
-
userVerification?: UserVerification;
|
|
12
|
-
};
|
|
9
|
+
export type AuthenticationRequest = OptionsReq;
|
|
13
10
|
export type AuthenticationErrors = NotSupported | OptionsErrors | VerificationErrors;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
17
|
authenticatePasskey: (request: AuthenticationRequest) => E.Effect<Principal, AuthenticationErrors>;
|
|
18
|
-
}
|
|
19
|
-
export declare
|
|
18
|
+
}>;
|
|
19
|
+
export declare class AuthenticationService extends AuthenticationService_base {
|
|
20
|
+
}
|
|
20
21
|
type Dependencies = GetCredential | Capabilities | StorageService | AuthenticationClient;
|
|
21
22
|
export declare const authenticatePasskey: (request: AuthenticationRequest) => E.Effect<Principal, AuthenticationErrors, Dependencies>;
|
|
22
|
-
export declare const AuthenticateServiceLive: Layer.Layer<AuthenticationService, never, Capabilities | StorageService | GetCredential
|
|
23
|
+
export declare const AuthenticateServiceLive: Layer.Layer<AuthenticationService, never, AuthenticationClient | Capabilities | StorageService | GetCredential>;
|
|
23
24
|
export {};
|
|
24
|
-
//# sourceMappingURL=authenticate.d.ts.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OptionsRes, VerificationReq, VerificationRes } from '@passlock/shared/dist/rpc/authentication.js';
|
|
2
2
|
import { IsExistingUserRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
|
|
3
3
|
import type { AuthenticationCredential } from '@passlock/shared/dist/schema/passkey.js';
|
|
4
4
|
import { Layer as L } from 'effect';
|
|
5
|
-
import {
|
|
5
|
+
import { AuthenticationClient } from '../rpc/authentication.js';
|
|
6
|
+
import { type AuthenticationRequest, GetCredential } from './authenticate.js';
|
|
6
7
|
export declare const session = "session";
|
|
7
8
|
export declare const token = "token";
|
|
8
9
|
export declare const code = "code";
|
|
@@ -18,21 +19,34 @@ export declare const rpcVerifyEmailRes: VerifyEmailRes;
|
|
|
18
19
|
export declare const getCredentialTest: L.Layer<GetCredential, never, never>;
|
|
19
20
|
export declare const rpcClientTest: L.Layer<AuthenticationClient, never, never>;
|
|
20
21
|
export declare const principal: {
|
|
22
|
+
readonly email?: string;
|
|
23
|
+
readonly givenName?: string;
|
|
24
|
+
readonly familyName?: string;
|
|
25
|
+
readonly emailVerified?: boolean;
|
|
26
|
+
readonly iss: string;
|
|
27
|
+
readonly aud: string;
|
|
28
|
+
readonly sub: string;
|
|
29
|
+
readonly iat: Date;
|
|
30
|
+
readonly nbf: Date;
|
|
31
|
+
readonly exp: Date;
|
|
32
|
+
readonly jti: string;
|
|
21
33
|
readonly token: string;
|
|
22
|
-
readonly
|
|
23
|
-
|
|
34
|
+
readonly userVerified: boolean;
|
|
35
|
+
readonly authType: "email" | "apple" | "google" | "passkey";
|
|
36
|
+
readonly authId: string;
|
|
37
|
+
readonly user?: {
|
|
24
38
|
readonly id: string;
|
|
39
|
+
readonly email: string;
|
|
25
40
|
readonly givenName: string;
|
|
26
41
|
readonly familyName: string;
|
|
27
42
|
readonly emailVerified: boolean;
|
|
28
43
|
};
|
|
29
44
|
readonly authStatement: {
|
|
30
|
-
readonly authType: "email" | "passkey" | "apple" | "google";
|
|
31
45
|
readonly userVerified: boolean;
|
|
46
|
+
readonly authType: "email" | "apple" | "google" | "passkey";
|
|
32
47
|
readonly authTimestamp: Date;
|
|
33
48
|
};
|
|
34
49
|
readonly expireAt: Date;
|
|
35
50
|
};
|
|
36
51
|
export declare const capabilitiesTest: L.Layer<import("../capabilities/capabilities.js").Capabilities, never, never>;
|
|
37
52
|
export declare const storageServiceTest: L.Layer<import("../storage/storage.js").StorageService, never, never>;
|
|
38
|
-
//# sourceMappingURL=authenticate.fixture.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OptionsRes, VerificationReq, VerificationRes, } from '@passlock/shared/dist/rpc/authentication.js';
|
|
2
2
|
import { IsExistingUserRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
|
|
3
|
-
import { Effect as E, Layer as L } from 'effect';
|
|
3
|
+
import { Effect as E, Layer as L, Option as O } from 'effect';
|
|
4
|
+
import { AuthenticationClient } from '../rpc/authentication.js';
|
|
4
5
|
import * as Fixtures from '../test/fixtures.js';
|
|
5
6
|
import { GetCredential } from './authenticate.js';
|
|
6
7
|
export const session = 'session';
|
|
@@ -9,7 +10,8 @@ export const code = 'code';
|
|
|
9
10
|
export const authType = 'passkey';
|
|
10
11
|
export const expireAt = Date.now() + 10000;
|
|
11
12
|
export const request = {
|
|
12
|
-
userVerification: 'preferred',
|
|
13
|
+
userVerification: O.some('preferred'),
|
|
14
|
+
email: O.none(),
|
|
13
15
|
};
|
|
14
16
|
export const rpcOptionsRes = new OptionsRes({
|
|
15
17
|
session,
|
|
@@ -35,9 +37,9 @@ export const credential = {
|
|
|
35
37
|
};
|
|
36
38
|
export const rpcVerificationReq = new VerificationReq({ session, credential });
|
|
37
39
|
export const rpcVerificationRes = new VerificationRes({ principal: Fixtures.principal });
|
|
38
|
-
export const rpcIsExistingUserRes = new IsExistingUserRes({ existingUser: true });
|
|
40
|
+
export const rpcIsExistingUserRes = new IsExistingUserRes({ existingUser: true, detail: O.none() });
|
|
39
41
|
export const rpcVerifyEmailRes = new VerifyEmailRes({ principal: Fixtures.principal });
|
|
40
|
-
export const getCredentialTest = L.succeed(GetCredential, GetCredential.of(() => E.succeed(credential)));
|
|
42
|
+
export const getCredentialTest = L.succeed(GetCredential, GetCredential.of({ getCredential: () => E.succeed(credential) }));
|
|
41
43
|
export const rpcClientTest = L.succeed(AuthenticationClient, AuthenticationClient.of({
|
|
42
44
|
getAuthenticationOptions: () => E.succeed(rpcOptionsRes),
|
|
43
45
|
verifyAuthenticationCredential: () => E.succeed(rpcVerificationRes),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.fixture.js","sourceRoot":"","sources":["../../src/authentication/authenticate.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"authenticate.fixture.js","sourceRoot":"","sources":["../../src/authentication/authenticate.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,eAAe,EACf,eAA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2
|
+
* Passkey authentication effects
|
|
3
|
+
*/
|
|
1
4
|
import { parseRequestOptionsFromJSON, } from '@github/webauthn-json/browser-ponyfill';
|
|
2
|
-
import { InternalBrowserError
|
|
3
|
-
import {
|
|
4
|
-
import { Principal } from '@passlock/shared/dist/schema/principal.js';
|
|
5
|
+
import { InternalBrowserError } from '@passlock/shared/dist/error/error.js';
|
|
6
|
+
import { VerificationReq, } from '@passlock/shared/dist/rpc/authentication.js';
|
|
5
7
|
import { Context, Effect as E, Layer, flow, pipe } from 'effect';
|
|
6
8
|
import { Capabilities } from '../capabilities/capabilities.js';
|
|
9
|
+
import { AuthenticationClient } from '../rpc/authentication.js';
|
|
7
10
|
import { StorageService } from '../storage/storage.js';
|
|
8
|
-
|
|
9
|
-
export
|
|
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 */
|
|
10
18
|
const fetchOptions = (request) => {
|
|
11
19
|
return E.gen(function* (_) {
|
|
12
20
|
yield* _(E.logDebug('Making request'));
|
|
@@ -37,10 +45,10 @@ export const authenticatePasskey = (request) => {
|
|
|
37
45
|
const capabilities = yield* _(Capabilities);
|
|
38
46
|
yield* _(capabilities.passkeySupport);
|
|
39
47
|
yield* _(E.logInfo('Fetching authentication options from Passlock'));
|
|
40
|
-
const { options, session } = yield* _(fetchOptions(
|
|
48
|
+
const { options, session } = yield* _(fetchOptions(request));
|
|
41
49
|
yield* _(E.logInfo('Looking up credential'));
|
|
42
|
-
const
|
|
43
|
-
const credential = yield* _(
|
|
50
|
+
const { getCredential } = yield* _(GetCredential);
|
|
51
|
+
const credential = yield* _(getCredential(options));
|
|
44
52
|
yield* _(E.logInfo('Verifying credential with Passlock'));
|
|
45
53
|
const principal = yield* _(verifyCredential(new VerificationReq({ credential, session })));
|
|
46
54
|
const storageService = yield* _(StorageService);
|
|
@@ -53,10 +61,13 @@ export const authenticatePasskey = (request) => {
|
|
|
53
61
|
});
|
|
54
62
|
return E.catchTag(effect, 'InternalBrowserError', e => E.die(e));
|
|
55
63
|
};
|
|
64
|
+
/* Live */
|
|
65
|
+
/* v8 ignore start */
|
|
56
66
|
export const AuthenticateServiceLive = Layer.effect(AuthenticationService, E.gen(function* (_) {
|
|
57
67
|
const context = yield* _(E.context());
|
|
58
68
|
return AuthenticationService.of({
|
|
59
69
|
authenticatePasskey: flow(authenticatePasskey, E.provide(context)),
|
|
60
70
|
});
|
|
61
71
|
}));
|
|
72
|
+
/* v8 ignore stop */
|
|
62
73
|
//# sourceMappingURL=authenticate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../src/authentication/authenticate.ts"],"names":[],"mappings":"
|
|
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,oBAAoB,EAAqB,MAAM,sCAAsC,CAAA;AAC9F,OAAO,EAIL,eAAe,GAChB,MAAM,6CAA6C,CAAA;AAGpD,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAChE,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,CA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CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;KACnE,CAAC,CAAA;AACJ,CAAC,CAAC,CACH,CAAA;AACD,oBAAoB"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test if the browser supports passkeys, conditional UI etc
|
|
3
|
+
*/
|
|
1
4
|
import { NotSupported } from '@passlock/shared/dist/error/error.js';
|
|
2
5
|
import { Context, Effect as E, Layer } from 'effect';
|
|
3
|
-
|
|
6
|
+
declare const Capabilities_base: Context.TagClass<Capabilities, "@services/Capabilities", {
|
|
4
7
|
passkeySupport: E.Effect<void, NotSupported>;
|
|
5
8
|
isPasskeySupport: E.Effect<boolean>;
|
|
6
9
|
autofillSupport: E.Effect<void, NotSupported>;
|
|
7
10
|
isAutofillSupport: E.Effect<boolean>;
|
|
8
|
-
}
|
|
9
|
-
export declare
|
|
11
|
+
}>;
|
|
12
|
+
export declare class Capabilities extends Capabilities_base {
|
|
13
|
+
}
|
|
10
14
|
export declare const passkeySupport: E.Effect<void, NotSupported, never>;
|
|
11
15
|
export declare const isPasskeySupport: E.Effect<boolean, never, never>;
|
|
12
16
|
export declare const autofillSupport: E.Effect<void, NotSupported, never>;
|
|
13
17
|
export declare const isAutofillSupport: E.Effect<boolean, never, never>;
|
|
14
18
|
export declare const capabilitiesLive: Layer.Layer<Capabilities, never, never>;
|
|
15
|
-
|
|
19
|
+
export {};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test if the browser supports passkeys, conditional UI etc
|
|
3
|
+
*/
|
|
1
4
|
import { NotSupported } from '@passlock/shared/dist/error/error.js';
|
|
2
5
|
import { Context, Effect as E, Layer, identity, pipe } from 'effect';
|
|
3
|
-
|
|
6
|
+
/* Service */
|
|
7
|
+
export class Capabilities extends Context.Tag('@services/Capabilities')() {
|
|
8
|
+
}
|
|
9
|
+
/* Effects */
|
|
4
10
|
const hasWebAuthn = E.suspend(() => typeof window.PublicKeyCredential === 'function'
|
|
5
11
|
? E.void
|
|
6
12
|
: new NotSupported({ message: 'WebAuthn API is not supported on this device' }));
|
|
@@ -19,10 +25,13 @@ export const isAutofillSupport = pipe(autofillSupport, E.match({
|
|
|
19
25
|
onFailure: () => false,
|
|
20
26
|
onSuccess: () => true,
|
|
21
27
|
}));
|
|
28
|
+
/* Live */
|
|
29
|
+
/* v8 ignore start */
|
|
22
30
|
export const capabilitiesLive = Layer.succeed(Capabilities, {
|
|
23
31
|
passkeySupport,
|
|
24
32
|
isPasskeySupport,
|
|
25
33
|
autofillSupport,
|
|
26
34
|
isAutofillSupport,
|
|
27
35
|
});
|
|
36
|
+
/* v8 ignore stop */
|
|
28
37
|
//# sourceMappingURL=capabilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/capabilities/capabilities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/capabilities/capabilities.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAEpE,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,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,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,11 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Hits the rpc endpoint to warm up a lambda
|
|
3
|
+
*/
|
|
4
4
|
import { Context, Effect as E, Layer } from 'effect';
|
|
5
|
-
|
|
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", {
|
|
6
9
|
preConnect: () => E.Effect<void>;
|
|
7
|
-
}
|
|
8
|
-
export declare
|
|
10
|
+
}>;
|
|
11
|
+
export declare class ConnectionService extends ConnectionService_base {
|
|
12
|
+
}
|
|
9
13
|
export declare const preConnect: () => E.Effect<void, never, Dispatcher | ConnectionClient>;
|
|
10
14
|
export declare const ConnectionServiceLive: Layer.Layer<ConnectionService, never, RpcConfig | Dispatcher | ConnectionClient>;
|
|
11
|
-
|
|
15
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConnectRes } from '@passlock/shared/dist/rpc/connection.js';
|
|
2
2
|
import { Layer as L } from 'effect';
|
|
3
|
+
import { ConnectionClient } from '../rpc/connection.js';
|
|
3
4
|
export declare const preConnectRes: ConnectRes;
|
|
4
5
|
export declare const rpcClientTest: L.Layer<ConnectionClient, never, never>;
|
|
5
6
|
export declare const rpcConfig: {
|
|
@@ -7,4 +8,3 @@ export declare const rpcConfig: {
|
|
|
7
8
|
tenancyId: string;
|
|
8
9
|
clientId: string;
|
|
9
10
|
};
|
|
10
|
-
//# sourceMappingURL=connection.fixture.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConnectRes } from '@passlock/shared/dist/rpc/connection.js';
|
|
2
2
|
import { Effect as E, Layer as L } from 'effect';
|
|
3
|
+
import { ConnectionClient } from '../rpc/connection.js';
|
|
3
4
|
export const preConnectRes = new ConnectRes({ warmed: true });
|
|
4
5
|
export const rpcClientTest = L.succeed(ConnectionClient, ConnectionClient.of({
|
|
5
6
|
preConnect: () => E.succeed(preConnectRes),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.fixture.js","sourceRoot":"","sources":["../../src/connection/connection.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"connection.fixture.js","sourceRoot":"","sources":["../../src/connection/connection.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAA;AACpE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAChD,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,14 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Hits the rpc endpoint to warm up a lambda
|
|
3
|
+
*/
|
|
3
4
|
import { Context, Effect as E, Layer, flow, pipe } from 'effect';
|
|
4
|
-
|
|
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 */
|
|
5
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));
|
|
6
12
|
const hitRpc = pipe(E.logInfo('Pre-connecting to RPC endpoint'), E.zipRight(ConnectionClient), E.flatMap(rpcClient => rpcClient.preConnect()), E.asVoid);
|
|
7
13
|
export const preConnect = () => pipe(E.all([hitPrincipal, hitRpc], { concurrency: 2 }), E.asVoid);
|
|
14
|
+
/* Live */
|
|
15
|
+
/* v8 ignore start */
|
|
8
16
|
export const ConnectionServiceLive = Layer.effect(ConnectionService, E.gen(function* (_) {
|
|
9
17
|
const context = yield* _(E.context());
|
|
10
18
|
return ConnectionService.of({
|
|
11
19
|
preConnect: flow(preConnect, E.provide(context)),
|
|
12
20
|
});
|
|
13
21
|
}));
|
|
22
|
+
/* v8 ignore stop */
|
|
14
23
|
//# sourceMappingURL=connection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/connection/connection.ts"],"names":[],"mappings":"
|
|
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,IA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AO,EAA6C,CAAC,CAAA;IAEhF,OAAO,iBAAiB,CAAC,EAAE,CAAC;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
CHANGED
|
@@ -1,49 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type BadRequest } from '@passlock/shared/dist/error/error.js';
|
|
2
|
+
import type { RpcConfig } from './rpc/config.js';
|
|
2
3
|
import type { Principal } from '@passlock/shared/dist/schema/principal.js';
|
|
3
|
-
import {
|
|
4
|
+
import { Effect as E, Layer as L } from 'effect';
|
|
4
5
|
import type { NoSuchElementException } from 'effect/Cause';
|
|
5
|
-
import {
|
|
6
|
+
import { type AuthenticationErrors, type AuthenticationRequest, AuthenticationService } from './authentication/authenticate.js';
|
|
7
|
+
import { Capabilities } from './capabilities/capabilities.js';
|
|
6
8
|
import { ConnectionService } from './connection/connection.js';
|
|
7
|
-
import { EmailService, type VerifyRequest } from './email/email.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
export declare const
|
|
14
|
-
declare const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export declare
|
|
20
|
-
|
|
21
|
-
export declare const preConnect: () => E.Effect<void, never, Config>;
|
|
22
|
-
export declare const isRegistered: (email: Email) => E.Effect<boolean, BadRequest, Config>;
|
|
23
|
-
export type RegistrationErrors = NotSupported | BadRequest | Duplicate | Unauthorized | Forbidden;
|
|
24
|
-
export declare const registerPasskey: (request: RegistrationRequest) => E.Effect<Principal, RegistrationErrors, Config>;
|
|
25
|
-
export type AuthenticationErrors = NotSupported | BadRequest | NotFound | Disabled | Unauthorized | Forbidden;
|
|
26
|
-
export declare const authenticatePasskey: (request: AuthenticationRequest) => E.Effect<Principal, AuthenticationErrors, Config>;
|
|
27
|
-
export type VerifyEmailErrors = NotSupported | BadRequest | NotFound | Disabled | Unauthorized | Forbidden;
|
|
28
|
-
export declare const verifyEmailCode: (request: VerifyRequest) => E.Effect<Principal, VerifyEmailErrors, Config>;
|
|
29
|
-
export declare const verifyEmailLink: () => E.Effect<Principal, VerifyEmailErrors, Config>;
|
|
9
|
+
import { EmailService, type VerifyEmailErrors, type VerifyRequest } from './email/email.js';
|
|
10
|
+
import { type RegistrationErrors, type RegistrationRequest, RegistrationService } from './registration/register.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>;
|
|
30
23
|
export declare const getSessionToken: (authType: AuthType) => E.Effect<StoredToken, NoSuchElementException>;
|
|
31
|
-
export declare const clearExpiredTokens:
|
|
32
|
-
export declare const
|
|
33
|
-
|
|
34
|
-
readonly user: {
|
|
35
|
-
readonly email: string;
|
|
36
|
-
readonly id: string;
|
|
37
|
-
readonly givenName: string;
|
|
38
|
-
readonly familyName: string;
|
|
39
|
-
readonly emailVerified: boolean;
|
|
40
|
-
};
|
|
41
|
-
readonly authStatement: {
|
|
42
|
-
readonly authType: "email" | "passkey" | "apple" | "google";
|
|
43
|
-
readonly userVerified: boolean;
|
|
44
|
-
readonly authTimestamp: Date;
|
|
45
|
-
};
|
|
46
|
-
readonly expireAt: Date;
|
|
47
|
-
}, import("./social/social.js").RegistrationErrors, RpcConfig>;
|
|
48
|
-
export {};
|
|
49
|
-
//# sourceMappingURL=effect.d.ts.map
|
|
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
CHANGED
|
@@ -1,46 +1,52 @@
|
|
|
1
1
|
import { create, get as getCredential } from '@github/webauthn-json/browser-ponyfill';
|
|
2
|
-
import { AuthenticationClientLive } from '@passlock/shared/dist/rpc/authentication.js';
|
|
3
|
-
import { ConnectionClientLive } from '@passlock/shared/dist/rpc/connection.js';
|
|
4
|
-
import { RegistrationClientLive } from '@passlock/shared/dist/rpc/registration.js';
|
|
5
|
-
import { SocialClientLive } from '@passlock/shared/dist/rpc/social.js';
|
|
6
|
-
import { UserClientLive } from '@passlock/shared/dist/rpc/user.js';
|
|
7
2
|
import { Duplicate, InternalBrowserError, } from '@passlock/shared/dist/error/error.js';
|
|
8
|
-
import {
|
|
3
|
+
import { AuthenticationClientLive } from './rpc/authentication.js';
|
|
4
|
+
import { DispatcherLive } from './rpc/client.js';
|
|
5
|
+
import { RetrySchedule } from './rpc/config.js';
|
|
6
|
+
import { ConnectionClientLive } from './rpc/connection.js';
|
|
7
|
+
import { RegistrationClientLive } from './rpc/registration.js';
|
|
8
|
+
import { SocialClientLive } from './rpc/social.js';
|
|
9
|
+
import { UserClientLive } from './rpc/user.js';
|
|
10
|
+
import { Effect as E, Layer as L, Layer, Schedule, pipe } from 'effect';
|
|
9
11
|
import { AuthenticateServiceLive, AuthenticationService, GetCredential, } from './authentication/authenticate.js';
|
|
10
|
-
import { capabilitiesLive } from './capabilities/capabilities.js';
|
|
12
|
+
import { Capabilities, capabilitiesLive } from './capabilities/capabilities.js';
|
|
11
13
|
import { ConnectionService, ConnectionServiceLive } from './connection/connection.js';
|
|
12
|
-
import { EmailService, EmailServiceLive, URLQueryString } from './email/email.js';
|
|
14
|
+
import { EmailService, EmailServiceLive, URLQueryString, } from './email/email.js';
|
|
13
15
|
import { CreateCredential, RegistrationService, RegistrationServiceLive, } from './registration/register.js';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}), E.map(credential => credential.toJSON()))
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
+
}));
|
|
42
47
|
const schedule = Schedule.intersect(Schedule.recurs(3), Schedule.exponential('100 millis'));
|
|
43
48
|
const retryScheduleLive = L.succeed(RetrySchedule, RetrySchedule.of({ schedule }));
|
|
49
|
+
/* Services */
|
|
44
50
|
const dispatcherLive = pipe(DispatcherLive, L.provide(retryScheduleLive));
|
|
45
51
|
const connectClientLive = pipe(ConnectionClientLive, L.provide(dispatcherLive));
|
|
46
52
|
const registerClientLive = pipe(RegistrationClientLive, L.provide(dispatcherLive));
|
|
@@ -56,19 +62,17 @@ const urlQueryStringLive = Layer.succeed(URLQueryString, URLQueryString.of(E.syn
|
|
|
56
62
|
const emailServiceLive = pipe(EmailServiceLive, L.provide(urlQueryStringLive), L.provide(userClientLive), L.provide(capabilitiesLive), L.provide(authenticationServiceLive), L.provide(storageServiceLive));
|
|
57
63
|
const socialServiceLive = pipe(SocialServiceLive, L.provide(socialClientLive));
|
|
58
64
|
export const allRequirements = Layer.mergeAll(capabilitiesLive, userServiceLive, registrationServiceLive, authenticationServiceLive, connectionServiceLive, emailServiceLive, storageServiceLive, socialServiceLive);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
export const
|
|
66
|
-
export const
|
|
67
|
-
export const
|
|
68
|
-
export const
|
|
69
|
-
export const
|
|
70
|
-
export const
|
|
71
|
-
export const
|
|
72
|
-
export const clearExpiredTokens = () => pipe(StorageService, E.flatMap(service => service.clearExpiredTokens), E.provide(storageServiceLive), E.provide(storageLive));
|
|
73
|
-
export const authenticateOIDC = (request) => pipe(SocialService, E.flatMap(service => service.registerOidc(request)), E.provide(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(socialServiceLive));
|
|
74
78
|
//# sourceMappingURL=effect.js.map
|