@passlock/client 0.9.6 → 0.9.7
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/README.md +1 -1
- package/dist/authentication/authenticate.d.ts +6 -5
- package/dist/authentication/authenticate.d.ts.map +1 -1
- package/dist/authentication/authenticate.fixture.d.ts +8 -5
- package/dist/authentication/authenticate.fixture.d.ts.map +1 -1
- package/dist/authentication/authenticate.fixture.js +12 -7
- package/dist/authentication/authenticate.fixture.js.map +1 -1
- package/dist/authentication/authenticate.js +6 -6
- package/dist/authentication/authenticate.js.map +1 -1
- package/dist/authentication/authenticate.test.js +4 -4
- package/dist/capabilities/capabilities.js +3 -3
- package/dist/connection/connection.fixture.d.ts +1 -1
- package/dist/connection/connection.fixture.d.ts.map +1 -1
- package/dist/connection/connection.fixture.js +13 -10
- package/dist/connection/connection.fixture.js.map +1 -1
- package/dist/connection/connection.js +3 -3
- package/dist/effect.d.ts +21 -5
- package/dist/effect.d.ts.map +1 -1
- package/dist/effect.js +12 -9
- package/dist/effect.js.map +1 -1
- package/dist/email/email.d.ts +24 -8
- package/dist/email/email.d.ts.map +1 -1
- package/dist/email/email.fixture.d.ts +8 -8
- package/dist/email/email.fixture.d.ts.map +1 -1
- package/dist/email/email.fixture.js +12 -10
- package/dist/email/email.fixture.js.map +1 -1
- package/dist/email/email.js +5 -5
- package/dist/email/email.js.map +1 -1
- package/dist/email/email.test.js +4 -4
- package/dist/email/email.test.js.map +1 -1
- package/dist/index.d.ts +52 -37
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -14
- package/dist/index.js.map +1 -1
- package/dist/registration/register.d.ts +3 -4
- package/dist/registration/register.d.ts.map +1 -1
- package/dist/registration/register.fixture.d.ts +4 -4
- package/dist/registration/register.fixture.d.ts.map +1 -1
- package/dist/registration/register.fixture.js +12 -8
- package/dist/registration/register.fixture.js.map +1 -1
- package/dist/registration/register.js +4 -13
- package/dist/registration/register.js.map +1 -1
- package/dist/social/social.d.ts +22 -0
- package/dist/social/social.d.ts.map +1 -0
- package/dist/social/social.js +29 -0
- package/dist/social/social.js.map +1 -0
- package/dist/storage/storage.d.ts +1 -1
- package/dist/storage/storage.d.ts.map +1 -1
- package/dist/storage/storage.fixture.d.ts +1 -2
- package/dist/storage/storage.fixture.d.ts.map +1 -1
- package/dist/storage/storage.fixture.js +1 -16
- package/dist/storage/storage.fixture.js.map +1 -1
- package/dist/storage/storage.js +4 -3
- package/dist/storage/storage.js.map +1 -1
- package/dist/test/fixtures.d.ts +4 -0
- package/dist/test/fixtures.d.ts.map +1 -1
- package/dist/test/fixtures.js +13 -9
- package/dist/test/fixtures.js.map +1 -1
- package/dist/user/user.d.ts +9 -2
- package/dist/user/user.d.ts.map +1 -1
- package/dist/user/user.fixture.d.ts +3 -2
- package/dist/user/user.fixture.d.ts.map +1 -1
- package/dist/user/user.fixture.js +13 -9
- package/dist/user/user.fixture.js.map +1 -1
- package/dist/user/user.js +11 -1
- package/dist/user/user.js.map +1 -1
- package/package.json +14 -13
- package/src/authentication/authenticate.fixture.ts +14 -7
- package/src/authentication/authenticate.test.ts +4 -4
- package/src/authentication/authenticate.ts +15 -12
- package/src/capabilities/capabilities.ts +3 -3
- package/src/connection/connection.fixture.ts +14 -11
- package/src/connection/connection.ts +4 -4
- package/src/effect.ts +28 -26
- package/src/email/email.fixture.ts +15 -13
- package/src/email/email.test.ts +4 -4
- package/src/email/email.ts +13 -12
- package/src/index.ts +91 -34
- package/src/registration/register.fixture.ts +12 -8
- package/src/registration/register.test.ts +8 -43
- package/src/registration/register.ts +8 -24
- package/src/social/social.ts +86 -0
- package/src/storage/storage.fixture.ts +2 -19
- package/src/storage/storage.ts +5 -4
- package/src/test/fixtures.ts +15 -10
- package/src/user/user.fixture.ts +14 -11
- package/src/user/user.ts +22 -3
- package/dist/exit.d.ts +0 -64
- package/dist/exit.d.ts.map +0 -1
- package/dist/exit.js +0 -106
- package/dist/exit.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { VerificationErrors } from '@passlock/shared/dist/rpc/authentication.js';
|
|
1
|
+
import { InternalBrowserError, type NotSupported } from '@passlock/shared/dist/error/error.js';
|
|
2
|
+
import type { OptionsErrors, VerificationErrors } from '@passlock/shared/dist/rpc/authentication.js';
|
|
3
3
|
import { RpcClient } from '@passlock/shared/dist/rpc/rpc.js';
|
|
4
4
|
import type { AuthenticationCredential, Principal, UserVerification } from '@passlock/shared/dist/schema/schema.js';
|
|
5
5
|
import { Context, Effect as E, Layer } from 'effect';
|
|
6
6
|
import { Capabilities } from '../capabilities/capabilities.js';
|
|
7
7
|
import { StorageService } from '../storage/storage.js';
|
|
8
8
|
export type AuthenticationRequest = {
|
|
9
|
+
email?: string;
|
|
9
10
|
userVerification?: UserVerification;
|
|
10
11
|
};
|
|
11
|
-
export type AuthenticationErrors = NotSupported |
|
|
12
|
-
export type GetCredential = (
|
|
12
|
+
export type AuthenticationErrors = NotSupported | OptionsErrors | VerificationErrors;
|
|
13
|
+
export type GetCredential = (request: CredentialRequestOptions) => E.Effect<AuthenticationCredential, InternalBrowserError>;
|
|
13
14
|
export declare const GetCredential: Context.Tag<GetCredential, GetCredential>;
|
|
14
15
|
export type AuthenticationService = {
|
|
15
|
-
authenticatePasskey: (
|
|
16
|
+
authenticatePasskey: (request: AuthenticationRequest) => E.Effect<Principal, AuthenticationErrors>;
|
|
16
17
|
};
|
|
17
18
|
export declare const AuthenticationService: Context.Tag<AuthenticationService, AuthenticationService>;
|
|
18
19
|
type Dependencies = GetCredential | Capabilities | StorageService | RpcClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../src/authentication/authenticate.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../src/authentication/authenticate.ts"],"names":[],"mappings":"AAOA,OAAO,EAC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|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { OptionsRes, VerificationReq, VerificationRes } from '@passlock/shared/dist/rpc/authentication.js';
|
|
2
2
|
import { RpcClient } from '@passlock/shared/dist/rpc/rpc.js';
|
|
3
|
+
import { IsExistingUserRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
|
|
3
4
|
import type { AuthenticationCredential } from '@passlock/shared/dist/schema/schema.js';
|
|
4
5
|
import { Layer as L } from 'effect';
|
|
5
|
-
import { type AuthenticationRequest
|
|
6
|
+
import { GetCredential, type AuthenticationRequest } from './authenticate.js';
|
|
6
7
|
export declare const session = "session";
|
|
7
8
|
export declare const token = "token";
|
|
8
9
|
export declare const code = "code";
|
|
@@ -13,19 +14,21 @@ export declare const optionsRes: OptionsRes;
|
|
|
13
14
|
export declare const credential: AuthenticationCredential;
|
|
14
15
|
export declare const verificationReq: VerificationReq;
|
|
15
16
|
export declare const verificationRes: VerificationRes;
|
|
17
|
+
export declare const isExistingUserRes: IsExistingUserRes;
|
|
18
|
+
export declare const verifyEmailRes: VerifyEmailRes;
|
|
16
19
|
export declare const getCredentialTest: L.Layer<GetCredential, never, never>;
|
|
17
20
|
export declare const rpcClientTest: L.Layer<RpcClient, never, never>;
|
|
18
21
|
export declare const principal: {
|
|
19
22
|
readonly token: string;
|
|
20
|
-
readonly
|
|
23
|
+
readonly user: {
|
|
21
24
|
readonly email: string;
|
|
22
25
|
readonly id: string;
|
|
23
|
-
readonly
|
|
24
|
-
readonly
|
|
26
|
+
readonly givenName: string;
|
|
27
|
+
readonly familyName: string;
|
|
25
28
|
readonly emailVerified: boolean;
|
|
26
29
|
};
|
|
27
30
|
readonly authStatement: {
|
|
28
|
-
readonly authType: "email" | "passkey";
|
|
31
|
+
readonly authType: "email" | "passkey" | "google";
|
|
29
32
|
readonly userVerified: boolean;
|
|
30
33
|
readonly authTimestamp: Date;
|
|
31
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.fixture.d.ts","sourceRoot":"","sources":["../../src/authentication/authenticate.fixture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"authenticate.fixture.d.ts","sourceRoot":"","sources":["../../src/authentication/authenticate.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,eAAe,EACf,eAAe,EAChB,MAAM,6CAA6C,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AACrF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAA;AACtF,OAAO,EAAe,KAAK,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAEhD,OAAO,EAAE,aAAa,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE7E,eAAO,MAAM,OAAO,YAAY,CAAA;AAChC,eAAO,MAAM,KAAK,UAAU,CAAA;AAC5B,eAAO,MAAM,IAAI,SAAS,CAAA;AAC1B,eAAO,MAAM,QAAQ,YAAY,CAAA;AACjC,eAAO,MAAM,QAAQ,QAAqB,CAAA;AAE1C,eAAO,MAAM,OAAO,EAAE,qBAErB,CAAA;AAED,eAAO,MAAM,UAAU,YAQrB,CAAA;AAEF,eAAO,MAAM,UAAU,EAAE,wBAYxB,CAAA;AAED,eAAO,MAAM,eAAe,iBAA+C,CAAA;AAE3E,eAAO,MAAM,eAAe,iBAAyD,CAAA;AAErF,eAAO,MAAM,iBAAiB,mBAAgD,CAAA;AAE9E,eAAO,MAAM,cAAc,gBAAwD,CAAA;AAEnF,eAAO,MAAM,iBAAiB,sCAG7B,CAAA;AAED,eAAO,MAAM,aAAa,kCAczB,CAAA;AAED,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;CAAqB,CAAA;AAC3C,eAAO,MAAM,gBAAgB,+EAA4B,CAAA;AACzD,eAAO,MAAM,kBAAkB,uEAA8B,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BadRequest } from '@passlock/shared/dist/error/error.js';
|
|
2
1
|
import { OptionsRes, VerificationReq, VerificationRes, } from '@passlock/shared/dist/rpc/authentication.js';
|
|
3
2
|
import { RpcClient } from '@passlock/shared/dist/rpc/rpc.js';
|
|
3
|
+
import { IsExistingUserRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
|
|
4
4
|
import { Effect as E, Layer as L } from 'effect';
|
|
5
|
-
import { GetCredential } from './authenticate.js';
|
|
6
5
|
import * as Fixtures from '../test/fixtures.js';
|
|
6
|
+
import { GetCredential } from './authenticate.js';
|
|
7
7
|
export const session = 'session';
|
|
8
8
|
export const token = 'token';
|
|
9
9
|
export const code = 'code';
|
|
@@ -36,15 +36,20 @@ export const credential = {
|
|
|
36
36
|
};
|
|
37
37
|
export const verificationReq = new VerificationReq({ session, credential });
|
|
38
38
|
export const verificationRes = new VerificationRes({ principal: Fixtures.principal });
|
|
39
|
+
export const isExistingUserRes = new IsExistingUserRes({ existingUser: true });
|
|
40
|
+
export const verifyEmailRes = new VerifyEmailRes({ principal: Fixtures.principal });
|
|
39
41
|
export const getCredentialTest = L.succeed(GetCredential, GetCredential.of(() => E.succeed(credential)));
|
|
40
42
|
export const rpcClientTest = L.succeed(RpcClient, RpcClient.of({
|
|
41
|
-
preConnect: () => E.succeed(
|
|
42
|
-
isExistingUser: () => E.succeed(
|
|
43
|
-
verifyEmail: () => E.succeed(
|
|
44
|
-
getRegistrationOptions: () => E.fail(
|
|
45
|
-
verifyRegistrationCredential: () => E.fail(
|
|
43
|
+
preConnect: () => E.succeed(Fixtures.preConnectRes),
|
|
44
|
+
isExistingUser: () => E.succeed(isExistingUserRes),
|
|
45
|
+
verifyEmail: () => E.succeed(verifyEmailRes),
|
|
46
|
+
getRegistrationOptions: () => E.fail(Fixtures.notImplemented),
|
|
47
|
+
verifyRegistrationCredential: () => E.fail(Fixtures.notImplemented),
|
|
46
48
|
getAuthenticationOptions: () => E.succeed(optionsRes),
|
|
47
49
|
verifyAuthenticationCredential: () => E.succeed(verificationRes),
|
|
50
|
+
registerOidc: () => E.fail(Fixtures.notImplemented),
|
|
51
|
+
authenticateOidc: () => E.fail(Fixtures.notImplemented),
|
|
52
|
+
resendVerificationEmail: () => E.fail(Fixtures.notImplemented),
|
|
48
53
|
}));
|
|
49
54
|
export const principal = Fixtures.principal;
|
|
50
55
|
export const capabilitiesTest = Fixtures.capabilitiesTest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.fixture.js","sourceRoot":"","sources":["../../src/authentication/authenticate.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"authenticate.fixture.js","sourceRoot":"","sources":["../../src/authentication/authenticate.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,eAAe,EACf,eAAe,GAChB,MAAM,6CAA6C,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAErF,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAA8B,MAAM,mBAAmB,CAAA;AAE7E,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAA;AAChC,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAA;AAC5B,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAA;AAC1B,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAA;AACjC,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAA;AAE1C,MAAM,CAAC,MAAM,OAAO,GAA0B;IAC5C,gBAAgB,EAAE,WAAW;CAC9B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AAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;IACnD,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC;IAClD,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;IAC5C,sBAAsB,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;IAC7D,4BAA4B,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;IACnE,wBAAwB,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IACrD,8BAA8B,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;IAChE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;IACnD,gBAAgB,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;IACvD,uBAAuB,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;CAC/D,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"}
|
|
@@ -7,27 +7,27 @@ import { Capabilities } from '../capabilities/capabilities.js';
|
|
|
7
7
|
import { StorageService } from '../storage/storage.js';
|
|
8
8
|
export const GetCredential = Context.GenericTag('@services/Get');
|
|
9
9
|
export const AuthenticationService = Context.GenericTag('@services/AuthenticationService');
|
|
10
|
-
const fetchOptions = (
|
|
10
|
+
const fetchOptions = (request) => {
|
|
11
11
|
return E.gen(function* (_) {
|
|
12
12
|
yield* _(E.logDebug('Making request'));
|
|
13
13
|
const rpcClient = yield* _(RpcClient);
|
|
14
|
-
const { publicKey, session } = yield* _(rpcClient.getAuthenticationOptions(
|
|
14
|
+
const { publicKey, session } = yield* _(rpcClient.getAuthenticationOptions(request));
|
|
15
15
|
yield* _(E.logDebug('Converting Passlock options to CredentialRequestOptions'));
|
|
16
16
|
const options = yield* _(toRequestOptions({ publicKey }));
|
|
17
17
|
return { options, session };
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
|
-
const toRequestOptions = (
|
|
21
|
-
return pipe(E.try(() => parseRequestOptionsFromJSON(
|
|
20
|
+
const toRequestOptions = (request) => {
|
|
21
|
+
return pipe(E.try(() => parseRequestOptionsFromJSON(request)), E.mapError(error => new InternalBrowserError({
|
|
22
22
|
message: 'Browser was unable to create credential request options',
|
|
23
23
|
detail: String(error.error),
|
|
24
24
|
})));
|
|
25
25
|
};
|
|
26
|
-
const verifyCredential = (
|
|
26
|
+
const verifyCredential = (request) => {
|
|
27
27
|
return E.gen(function* (_) {
|
|
28
28
|
yield* _(E.logDebug('Making request'));
|
|
29
29
|
const rpcClient = yield* _(RpcClient);
|
|
30
|
-
const { principal } = yield* _(rpcClient.verifyAuthenticationCredential(
|
|
30
|
+
const { principal } = yield* _(rpcClient.verifyAuthenticationCredential(request));
|
|
31
31
|
return principal;
|
|
32
32
|
});
|
|
33
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../src/authentication/authenticate.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,2BAA2B,GAC5B,MAAM,wCAAwC,CAAA;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../src/authentication/authenticate.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,2BAA2B,GAC5B,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EACL,oBAAoB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,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,sBAAsB,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AAClE,CAAC,CAAA;AAKD,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,CAAC,CAAC,CAAC,OAAO,EAA6D,CAAC,CAAA;IAEhG,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"}
|
|
@@ -63,8 +63,8 @@ describe('authenticate should', () => {
|
|
|
63
63
|
});
|
|
64
64
|
const storageServiceTest = L.effect(StorageService, E.sync(() => {
|
|
65
65
|
const storageMock = mock();
|
|
66
|
-
storageMock.storeToken.mockReturnValue(E.
|
|
67
|
-
storageMock.clearExpiredToken.mockReturnValue(E.
|
|
66
|
+
storageMock.storeToken.mockReturnValue(E.void);
|
|
67
|
+
storageMock.clearExpiredToken.mockReturnValue(E.void);
|
|
68
68
|
return storageMock;
|
|
69
69
|
}));
|
|
70
70
|
const service = pipe(AuthenticateServiceLive, L.provide(Fixture.getCredentialTest), L.provide(Fixture.capabilitiesTest), L.provide(Fixture.rpcClientTest), L.provide(storageServiceTest));
|
|
@@ -81,8 +81,8 @@ describe('authenticate should', () => {
|
|
|
81
81
|
});
|
|
82
82
|
const storageServiceTest = L.effect(StorageService, E.sync(() => {
|
|
83
83
|
const storageMock = mock();
|
|
84
|
-
storageMock.storeToken.mockReturnValue(E.
|
|
85
|
-
storageMock.clearExpiredToken.mockReturnValue(E.
|
|
84
|
+
storageMock.storeToken.mockReturnValue(E.void);
|
|
85
|
+
storageMock.clearExpiredToken.mockReturnValue(E.void);
|
|
86
86
|
return storageMock;
|
|
87
87
|
}));
|
|
88
88
|
const service = pipe(AuthenticateServiceLive, L.provide(Fixture.getCredentialTest), L.provide(Fixture.capabilitiesTest), L.provide(Fixture.rpcClientTest), L.provide(storageServiceTest));
|
|
@@ -2,13 +2,13 @@ import { NotSupported } from '@passlock/shared/dist/error/error.js';
|
|
|
2
2
|
import { Context, Effect as E, Layer, identity, pipe } from 'effect';
|
|
3
3
|
export const Capabilities = Context.GenericTag('@services/Capabilities');
|
|
4
4
|
const hasWebAuthn = E.suspend(() => typeof window.PublicKeyCredential === 'function'
|
|
5
|
-
? E.
|
|
5
|
+
? E.void
|
|
6
6
|
: new NotSupported({ message: 'WebAuthn API is not supported on this device' }));
|
|
7
|
-
const hasPlatformAuth = pipe(E.tryPromise(() => window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()), E.filterOrFail(identity, () => new NotSupported({ message: 'No platform authenticator available on this device' })), E.
|
|
7
|
+
const hasPlatformAuth = pipe(E.tryPromise(() => window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()), E.filterOrFail(identity, () => new NotSupported({ message: 'No platform authenticator available on this device' })), E.asVoid);
|
|
8
8
|
const hasConditionalUi = pipe(E.tryPromise({
|
|
9
9
|
try: () => window.PublicKeyCredential.isConditionalMediationAvailable(),
|
|
10
10
|
catch: () => new NotSupported({ message: 'Conditional mediation not available on this device' }),
|
|
11
|
-
}), E.filterOrFail(identity, () => new NotSupported({ message: 'Conditional mediation not available on this device' })), E.
|
|
11
|
+
}), E.filterOrFail(identity, () => new NotSupported({ message: 'Conditional mediation not available on this device' })), E.asVoid);
|
|
12
12
|
export const passkeySupport = pipe(hasWebAuthn, E.andThen(hasPlatformAuth), E.catchTag('UnknownException', e => E.die(e)));
|
|
13
13
|
export const isPasskeySupport = pipe(passkeySupport, E.match({
|
|
14
14
|
onFailure: () => false,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PreConnectReq, PreConnectRes } from '@passlock/shared/dist/rpc/connection.js';
|
|
2
2
|
import { RpcClient } from '@passlock/shared/dist/rpc/rpc.js';
|
|
3
3
|
import { Layer as L } from 'effect';
|
|
4
|
-
export declare const rpcClientTest: L.Layer<RpcClient, never, never>;
|
|
5
4
|
export declare const preConnectReq: PreConnectReq;
|
|
6
5
|
export declare const preConnectRes: PreConnectRes;
|
|
6
|
+
export declare const rpcClientTest: L.Layer<RpcClient, never, never>;
|
|
7
7
|
export declare const rpcConfig: {
|
|
8
8
|
endpoint: string;
|
|
9
9
|
tenancyId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.fixture.d.ts","sourceRoot":"","sources":["../../src/connection/connection.fixture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connection.fixture.d.ts","sourceRoot":"","sources":["../../src/connection/connection.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAA;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAe,KAAK,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAGhD,eAAO,MAAM,aAAa,eAAwB,CAAA;AAClD,eAAO,MAAM,aAAa,eAAsC,CAAA;AAEhE,eAAO,MAAM,aAAa,kCAczB,CAAA;AAED,eAAO,MAAM,SAAS;;;;CAIrB,CAAA"}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { BadRequest } from '@passlock/shared/dist/error/error.js';
|
|
2
1
|
import { PreConnectReq, PreConnectRes } from '@passlock/shared/dist/rpc/connection.js';
|
|
3
2
|
import { RpcClient } from '@passlock/shared/dist/rpc/rpc.js';
|
|
4
3
|
import { Effect as E, Layer as L } from 'effect';
|
|
5
|
-
|
|
6
|
-
preConnect: () => E.succeed({ warmed: true }),
|
|
7
|
-
isExistingUser: () => E.succeed({ existingUser: true }),
|
|
8
|
-
verifyEmail: () => E.succeed({ verified: true }),
|
|
9
|
-
getRegistrationOptions: () => E.fail(new BadRequest({ message: 'Not implemeneted' })),
|
|
10
|
-
verifyRegistrationCredential: () => E.fail(new BadRequest({ message: 'Not implemeneted' })),
|
|
11
|
-
getAuthenticationOptions: () => E.fail(new BadRequest({ message: 'Not implemeneted' })),
|
|
12
|
-
verifyAuthenticationCredential: () => E.fail(new BadRequest({ message: 'Not implemeneted' })),
|
|
13
|
-
}));
|
|
4
|
+
import * as Fixtures from '../test/fixtures.js';
|
|
14
5
|
export const preConnectReq = new PreConnectReq({});
|
|
15
6
|
export const preConnectRes = new PreConnectRes({ warmed: true });
|
|
7
|
+
export const rpcClientTest = L.succeed(RpcClient, RpcClient.of({
|
|
8
|
+
preConnect: () => E.succeed(preConnectRes),
|
|
9
|
+
isExistingUser: () => E.fail(Fixtures.notImplemented),
|
|
10
|
+
verifyEmail: () => E.fail(Fixtures.notImplemented),
|
|
11
|
+
getRegistrationOptions: () => E.fail(Fixtures.notImplemented),
|
|
12
|
+
verifyRegistrationCredential: () => E.fail(Fixtures.notImplemented),
|
|
13
|
+
getAuthenticationOptions: () => E.fail(Fixtures.notImplemented),
|
|
14
|
+
verifyAuthenticationCredential: () => E.fail(Fixtures.notImplemented),
|
|
15
|
+
registerOidc: () => E.fail(Fixtures.notImplemented),
|
|
16
|
+
authenticateOidc: () => E.fail(Fixtures.notImplemented),
|
|
17
|
+
resendVerificationEmail: () => E.fail(Fixtures.notImplemented),
|
|
18
|
+
}));
|
|
16
19
|
export const rpcConfig = {
|
|
17
20
|
endpoint: 'https://example.com',
|
|
18
21
|
tenancyId: 'tenancyId',
|
|
@@ -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"],"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EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;IACvD,uBAAuB,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;CAC/D,CAAC,CACH,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,QAAQ,EAAE,qBAAqB;IAC/B,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;CACrB,CAAA"}
|
|
@@ -2,9 +2,9 @@ import { PreConnectReq } from '@passlock/shared/dist/rpc/connection.js';
|
|
|
2
2
|
import { Dispatcher, RpcClient } from '@passlock/shared/dist/rpc/rpc.js';
|
|
3
3
|
import { Context, Effect as E, Layer, flow, pipe } from 'effect';
|
|
4
4
|
export const ConnectionService = Context.GenericTag('@services/ConnectService');
|
|
5
|
-
const hitPrincipal = pipe(E.logInfo('Pre-connecting to Principal endpoint'), E.zipRight(Dispatcher), E.flatMap(dispatcher => dispatcher.get('/token/token?warm=true')), E.
|
|
6
|
-
const hitRpc = pipe(E.logInfo('Pre-connecting to RPC endpoint'), E.zipRight(RpcClient), E.flatMap(rpcClient => rpcClient.preConnect(new PreConnectReq({}))), E.
|
|
7
|
-
export const preConnect = () => pipe(E.all([hitPrincipal, hitRpc], { concurrency: 2 }), E.
|
|
5
|
+
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
|
+
const hitRpc = pipe(E.logInfo('Pre-connecting to RPC endpoint'), E.zipRight(RpcClient), E.flatMap(rpcClient => rpcClient.preConnect(new PreConnectReq({}))), E.asVoid);
|
|
7
|
+
export const preConnect = () => pipe(E.all([hitPrincipal, hitRpc], { concurrency: 2 }), E.asVoid);
|
|
8
8
|
export const ConnectionServiceLive = Layer.effect(ConnectionService, E.gen(function* (_) {
|
|
9
9
|
const context = yield* _(E.context());
|
|
10
10
|
return ConnectionService.of({
|
package/dist/effect.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export type { BadRequest, Disabled, Duplicate, Forbidden, InternalBrowserError, NotFound, NotSupported, Unauthorized, } from '@passlock/shared/dist/error/error.js';
|
|
2
|
-
export type { Principal } from '@passlock/shared/dist/schema/schema.js';
|
|
3
1
|
import { type BadRequest, type Disabled, Duplicate, type Forbidden, type NotFound, type NotSupported, type Unauthorized } from '@passlock/shared/dist/error/error.js';
|
|
4
2
|
import { RpcConfig } from '@passlock/shared/dist/rpc/rpc.js';
|
|
5
3
|
import type { Principal } from '@passlock/shared/dist/schema/schema.js';
|
|
@@ -11,7 +9,8 @@ import { EmailService, type VerifyRequest } from './email/email.js';
|
|
|
11
9
|
import { type RegistrationRequest, RegistrationService } from './registration/register.js';
|
|
12
10
|
import { type AuthType, StorageService, type StoredToken } from './storage/storage.js';
|
|
13
11
|
import { type Email, UserService } from './user/user.js';
|
|
14
|
-
|
|
12
|
+
import { SocialService, type OidcRequest } from './social/social.js';
|
|
13
|
+
export declare const allRequirements: L.Layer<import("./capabilities/capabilities.js").Capabilities | StorageService | AuthenticationService | ConnectionService | EmailService | UserService | RegistrationService | SocialService, never, Storage | RpcConfig>;
|
|
15
14
|
declare const Config_base: Context.TagClass<Config, "Config", {
|
|
16
15
|
tenancyId: string;
|
|
17
16
|
clientId: string;
|
|
@@ -26,8 +25,25 @@ export declare const registerPasskey: (request: RegistrationRequest) => E.Effect
|
|
|
26
25
|
export type AuthenticationErrors = NotSupported | BadRequest | NotFound | Disabled | Unauthorized | Forbidden;
|
|
27
26
|
export declare const authenticatePasskey: (request: AuthenticationRequest) => E.Effect<Principal, AuthenticationErrors, Config>;
|
|
28
27
|
export type VerifyEmailErrors = NotSupported | BadRequest | NotFound | Disabled | Unauthorized | Forbidden;
|
|
29
|
-
export declare const verifyEmailCode: (request: VerifyRequest) => E.Effect<
|
|
30
|
-
export declare const verifyEmailLink: () => E.Effect<
|
|
28
|
+
export declare const verifyEmailCode: (request: VerifyRequest) => E.Effect<Principal, VerifyEmailErrors, Config>;
|
|
29
|
+
export declare const verifyEmailLink: () => E.Effect<Principal, VerifyEmailErrors, Config>;
|
|
31
30
|
export declare const getSessionToken: (authType: AuthType) => E.Effect<StoredToken, NoSuchElementException>;
|
|
32
31
|
export declare const clearExpiredTokens: () => E.Effect<void>;
|
|
32
|
+
export declare const authenticateOIDC: (request: OidcRequest) => E.Effect<{
|
|
33
|
+
readonly token: string;
|
|
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" | "google";
|
|
43
|
+
readonly userVerified: boolean;
|
|
44
|
+
readonly authTimestamp: Date;
|
|
45
|
+
};
|
|
46
|
+
readonly expireAt: Date;
|
|
47
|
+
}, import("./social/social.js").RegistrationErrors, RpcConfig>;
|
|
48
|
+
export {};
|
|
33
49
|
//# sourceMappingURL=effect.d.ts.map
|
package/dist/effect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,SAAS,EACT,KAAK,SAAS,EAEd,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,sCAAsC,CAAA;AAE7C,OAAO,EAIL,SAAS,EACV,MAAM,kCAAkC,CAAA;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAA;AAEvE,OAAO,EAAE,OAAO,EAAE,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GACZ,SAAS,CAAA;AAEb,eAAO,MAAM,mBAAmB,YACrB,qBAAqB,KAC7B,EAAE,MAAM,CAAC,SAAS,EAAE,oBAAoB,EAAE,MAAM,CAMhD,CAAA;AAEH,MAAM,MAAM,iBAAiB,GACzB,YAAY,GACZ,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,YAAY,GACZ,SAAS,CAAA;AAEb,eAAO,MAAM,eAAe,YACjB,aAAa,KACrB,EAAE,MAAM,CAAC,SAAS,EAAE,iBAAiB,EAAE,MAAM,CAM7C,CAAA;AAEH,eAAO,MAAM,eAAe,QAAO,EAAE,MAAM,CAAC,SAAS,EAAE,iBAAiB,EAAE,MAAM,CAM7E,CAAA;AAEH,eAAO,MAAM,eAAe,aAChB,QAAQ,KACjB,EAAE,MAAM,CAAC,WAAW,EAAE,sBAAsB,CAM5C,CAAA;AAEH,eAAO,MAAM,kBAAkB,QAAO,EAAE,MAAM,CAAC,IAAI,CAMhD,CAAA;AAEH,eAAO,MAAM,gBAAgB,YAAa,WAAW;;;;;;;;;;;;;;;8DAKlD,CAAA"}
|
package/dist/effect.js
CHANGED
|
@@ -5,16 +5,17 @@ import { Context, Effect as E, Layer as L, Layer, Schedule, pipe } from 'effect'
|
|
|
5
5
|
import { AuthenticateServiceLive, AuthenticationService, GetCredential, } from './authentication/authenticate.js';
|
|
6
6
|
import { capabilitiesLive } from './capabilities/capabilities.js';
|
|
7
7
|
import { ConnectionService, ConnectionServiceLive } from './connection/connection.js';
|
|
8
|
-
import { EmailService, EmailServiceLive,
|
|
8
|
+
import { EmailService, EmailServiceLive, URLQueryString } from './email/email.js';
|
|
9
9
|
import { CreateCredential, RegistrationService, RegistrationServiceLive, } from './registration/register.js';
|
|
10
10
|
import { Storage, StorageService, StorageServiceLive, } from './storage/storage.js';
|
|
11
11
|
import { UserService, UserServiceLive } from './user/user.js';
|
|
12
|
-
|
|
12
|
+
import { SocialService, SocialServiceLive } from './social/social.js';
|
|
13
|
+
const createCredentialLive = L.succeed(CreateCredential, CreateCredential.of((options) => pipe(E.tryPromise({
|
|
13
14
|
try: () => create(options),
|
|
14
15
|
catch: e => {
|
|
15
16
|
if (e instanceof Error && e.message.includes('excludeCredentials')) {
|
|
16
17
|
return new Duplicate({
|
|
17
|
-
message: 'Passkey already registered
|
|
18
|
+
message: 'Passkey already registered to this device or cloud account',
|
|
18
19
|
});
|
|
19
20
|
}
|
|
20
21
|
else {
|
|
@@ -25,7 +26,7 @@ const createLive = L.succeed(CreateCredential, CreateCredential.of((options) =>
|
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
28
|
}), E.map(credential => credential.toJSON()))));
|
|
28
|
-
const
|
|
29
|
+
const getCredentialLive = L.succeed(GetCredential, GetCredential.of((options) => pipe(E.tryPromise({
|
|
29
30
|
try: () => getCredential(options),
|
|
30
31
|
catch: e => new InternalBrowserError({
|
|
31
32
|
message: 'Unable to get authentication credential',
|
|
@@ -38,12 +39,13 @@ const dispatcherLive = pipe(DispatcherLive, L.provide(retryScheduleLive));
|
|
|
38
39
|
const rpcClientLive = pipe(RpcClientLive, L.provide(dispatcherLive));
|
|
39
40
|
const storageServiceLive = StorageServiceLive;
|
|
40
41
|
const userServiceLive = pipe(UserServiceLive, L.provide(rpcClientLive));
|
|
41
|
-
const registrationServiceLive = pipe(RegistrationServiceLive, L.provide(rpcClientLive), L.provide(userServiceLive), L.provide(capabilitiesLive), L.provide(
|
|
42
|
-
const authenticationServiceLive = pipe(AuthenticateServiceLive, L.provide(rpcClientLive), L.provide(capabilitiesLive), L.provide(
|
|
42
|
+
const registrationServiceLive = pipe(RegistrationServiceLive, L.provide(rpcClientLive), L.provide(userServiceLive), L.provide(capabilitiesLive), L.provide(createCredentialLive), L.provide(storageServiceLive));
|
|
43
|
+
const authenticationServiceLive = pipe(AuthenticateServiceLive, L.provide(rpcClientLive), L.provide(capabilitiesLive), L.provide(getCredentialLive), L.provide(storageServiceLive));
|
|
43
44
|
const connectionServiceLive = pipe(ConnectionServiceLive, L.provide(rpcClientLive), L.provide(dispatcherLive));
|
|
44
|
-
const
|
|
45
|
-
const emailServiceLive = pipe(EmailServiceLive, L.provide(
|
|
46
|
-
|
|
45
|
+
const urlQueryStringLive = Layer.succeed(URLQueryString, URLQueryString.of(E.sync(() => globalThis.window.location.search)));
|
|
46
|
+
const emailServiceLive = pipe(EmailServiceLive, L.provide(urlQueryStringLive), L.provide(rpcClientLive), L.provide(capabilitiesLive), L.provide(authenticationServiceLive), L.provide(storageServiceLive));
|
|
47
|
+
const socialServiceLive = pipe(SocialServiceLive, L.provide(rpcClientLive));
|
|
48
|
+
export const allRequirements = Layer.mergeAll(capabilitiesLive, userServiceLive, registrationServiceLive, authenticationServiceLive, connectionServiceLive, emailServiceLive, storageServiceLive, socialServiceLive);
|
|
47
49
|
export class Config extends Context.Tag('Config')() {
|
|
48
50
|
}
|
|
49
51
|
const storageLive = Layer.effect(Storage, E.sync(() => Storage.of(globalThis.localStorage)));
|
|
@@ -58,4 +60,5 @@ export const verifyEmailCode = (request) => pipe(EmailService, E.flatMap(service
|
|
|
58
60
|
export const verifyEmailLink = () => pipe(EmailService, E.flatMap(service => service.verifyEmailLink()), E.provide(emailServiceLive), exchangeConfig);
|
|
59
61
|
export const getSessionToken = (authType) => pipe(StorageService, E.flatMap(service => service.getToken(authType)), E.provide(storageServiceLive), E.provide(storageLive));
|
|
60
62
|
export const clearExpiredTokens = () => pipe(StorageService, E.flatMap(service => service.clearExpiredTokens), E.provide(storageServiceLive), E.provide(storageLive));
|
|
63
|
+
export const authenticateOIDC = (request) => pipe(SocialService, E.flatMap(service => service.registerOidc(request)), E.provide(socialServiceLive));
|
|
61
64
|
//# sourceMappingURL=effect.js.map
|
package/dist/effect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.js","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,aAAa,EAAE,MAAM,wCAAwC,CAAA;
|
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AE,CAAC,EAC/C,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAC3B,cAAc,CACf,CAAA;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,QAAkB,EAC6B,EAAE,CACjD,IAAI,CACF,cAAc,EACd,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAChD,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAC7B,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CACvB,CAAA;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAmB,EAAE,CACrD,IAAI,CACF,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,WAAW,CAAC,CACvB,CAAA;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAoB,EAAE,EAAE,CACvD,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"}
|
package/dist/email/email.d.ts
CHANGED
|
@@ -3,22 +3,38 @@ import type { VerifyEmailErrors as RpcErrors } from '@passlock/shared/dist/rpc/u
|
|
|
3
3
|
import { Context, Effect as E, Layer } from 'effect';
|
|
4
4
|
import { type AuthenticationErrors, AuthenticationService } from '../authentication/authenticate.js';
|
|
5
5
|
import { StorageService } from '../storage/storage.js';
|
|
6
|
+
import type { Principal } from '@passlock/shared/dist/schema/schema.js';
|
|
6
7
|
export type VerifyRequest = {
|
|
7
8
|
code: string;
|
|
8
9
|
};
|
|
9
10
|
export type VerifyEmailErrors = RpcErrors | AuthenticationErrors;
|
|
10
|
-
declare const
|
|
11
|
-
export declare class
|
|
11
|
+
declare const URLQueryString_base: Context.TagClass<URLQueryString, "URLQueryString", E.Effect<string, never, never>>;
|
|
12
|
+
export declare class URLQueryString extends URLQueryString_base {
|
|
12
13
|
}
|
|
13
14
|
export type EmailService = {
|
|
14
|
-
verifyEmailCode: (request: VerifyRequest) => E.Effect<
|
|
15
|
-
verifyEmailLink: () => E.Effect<
|
|
15
|
+
verifyEmailCode: (request: VerifyRequest) => E.Effect<Principal, VerifyEmailErrors>;
|
|
16
|
+
verifyEmailLink: () => E.Effect<Principal, VerifyEmailErrors>;
|
|
16
17
|
};
|
|
17
18
|
export declare const EmailService: Context.Tag<EmailService, EmailService>;
|
|
18
19
|
export type Dependencies = StorageService | AuthenticationService | RpcClient;
|
|
19
|
-
export declare const extractCodeFromHref: () => E.Effect<string, import("effect/Cause").NoSuchElementException,
|
|
20
|
-
export declare const verifyEmail: (
|
|
21
|
-
export declare const verifyEmailLink: () => E.Effect<
|
|
22
|
-
|
|
20
|
+
export declare const extractCodeFromHref: () => E.Effect<string, import("effect/Cause").NoSuchElementException, URLQueryString>;
|
|
21
|
+
export declare const verifyEmail: (request: VerifyRequest) => E.Effect<Principal, VerifyEmailErrors, Dependencies>;
|
|
22
|
+
export declare const verifyEmailLink: () => E.Effect<{
|
|
23
|
+
readonly token: string;
|
|
24
|
+
readonly user: {
|
|
25
|
+
readonly email: string;
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly givenName: string;
|
|
28
|
+
readonly familyName: string;
|
|
29
|
+
readonly emailVerified: boolean;
|
|
30
|
+
};
|
|
31
|
+
readonly authStatement: {
|
|
32
|
+
readonly authType: "email" | "passkey" | "google";
|
|
33
|
+
readonly userVerified: boolean;
|
|
34
|
+
readonly authTimestamp: Date;
|
|
35
|
+
};
|
|
36
|
+
readonly expireAt: Date;
|
|
37
|
+
}, VerifyEmailErrors, URLQueryString | Dependencies>;
|
|
38
|
+
export declare const EmailServiceLive: Layer.Layer<EmailService, never, StorageService | AuthenticationService | RpcClient | URLQueryString>;
|
|
23
39
|
export {};
|
|
24
40
|
//# sourceMappingURL=email.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/email/email.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,KAAK,EAAE,iBAAiB,IAAI,SAAS,EAAE,MAAM,mCAAmC,CAAA;AAEvF,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAqC,MAAM,QAAQ,CAAA;AACvF,OAAO,EAAE,KAAK,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/email/email.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,KAAK,EAAE,iBAAiB,IAAI,SAAS,EAAE,MAAM,mCAAmC,CAAA;AAEvF,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAqC,MAAM,QAAQ,CAAA;AACvF,OAAO,EAAE,KAAK,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAA;AAIvE,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAID,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,oBAAoB,CAAA;;AAIhE,qBAAa,cAAe,SAAQ,mBAGjC;CAAG;AAIN,MAAM,MAAM,YAAY,GAAG;IACzB,eAAe,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAA;IACnF,eAAe,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAA;CAC9D,CAAA;AAED,eAAO,MAAM,YAAY,yCAA6D,CAAA;AAItF,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,qBAAqB,GAAG,SAAS,CAAA;AAuC7E,eAAO,MAAM,mBAAmB,uFAO/B,CAAA;AASD,eAAO,MAAM,WAAW,YACb,aAAa,KACrB,EAAE,MAAM,CAAC,SAAS,EAAE,iBAAiB,EAAE,YAAY,CAarD,CAAA;AAMD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;oDAKzB,CAAA;AAKH,eAAO,MAAM,gBAAgB,uGAW5B,CAAA"}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { RpcClient } from '@passlock/shared/dist/rpc/rpc.js';
|
|
2
2
|
import { VerifyEmailReq, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
|
|
3
3
|
import { Layer as L } from 'effect';
|
|
4
|
-
import {
|
|
4
|
+
import { URLQueryString } from './email.js';
|
|
5
5
|
import { AuthenticationService } from '../authentication/authenticate.js';
|
|
6
6
|
export declare const token = "token";
|
|
7
7
|
export declare const code = "code";
|
|
8
8
|
export declare const authType = "passkey";
|
|
9
9
|
export declare const expireAt: number;
|
|
10
|
-
export declare const locationSearchTest: L.Layer<
|
|
10
|
+
export declare const locationSearchTest: L.Layer<URLQueryString, never, never>;
|
|
11
11
|
export declare const authenticationServiceTest: L.Layer<AuthenticationService, never, never>;
|
|
12
|
-
export declare const rpcClientTest: L.Layer<RpcClient, never, never>;
|
|
13
12
|
export declare const verifyEmailReq: VerifyEmailReq;
|
|
14
13
|
export declare const verifyEmailRes: VerifyEmailRes;
|
|
14
|
+
export declare const rpcClientTest: L.Layer<RpcClient, never, never>;
|
|
15
15
|
export declare const principal: {
|
|
16
16
|
readonly token: string;
|
|
17
|
-
readonly
|
|
17
|
+
readonly user: {
|
|
18
18
|
readonly email: string;
|
|
19
19
|
readonly id: string;
|
|
20
|
-
readonly
|
|
21
|
-
readonly
|
|
20
|
+
readonly givenName: string;
|
|
21
|
+
readonly familyName: string;
|
|
22
22
|
readonly emailVerified: boolean;
|
|
23
23
|
};
|
|
24
24
|
readonly authStatement: {
|
|
25
|
-
readonly authType: "email" | "passkey";
|
|
25
|
+
readonly authType: "email" | "passkey" | "google";
|
|
26
26
|
readonly userVerified: boolean;
|
|
27
27
|
readonly authTimestamp: Date;
|
|
28
28
|
};
|
|
29
29
|
readonly expireAt: Date;
|
|
30
30
|
};
|
|
31
|
-
export declare const storedToken: import("../
|
|
31
|
+
export declare const storedToken: import("../index.js").StoredToken;
|
|
32
32
|
export declare const storageServiceTest: L.Layer<import("../storage/storage.js").StorageService, never, never>;
|
|
33
33
|
//# sourceMappingURL=email.fixture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.fixture.d.ts","sourceRoot":"","sources":["../../src/email/email.fixture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"email.fixture.d.ts","sourceRoot":"","sources":["../../src/email/email.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAClF,OAAO,EAAe,KAAK,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AAGzE,eAAO,MAAM,KAAK,UAAU,CAAA;AAC5B,eAAO,MAAM,IAAI,SAAS,CAAA;AAC1B,eAAO,MAAM,QAAQ,YAAY,CAAA;AACjC,eAAO,MAAM,QAAQ,QAAqB,CAAA;AAE1C,eAAO,MAAM,kBAAkB,uCAG9B,CAAA;AAED,eAAO,MAAM,yBAAyB,8CAKrC,CAAA;AAED,eAAO,MAAM,cAAc,gBAAsC,CAAA;AAEjE,eAAO,MAAM,cAAc,gBAAwD,CAAA;AAEnF,eAAO,MAAM,aAAa,kCAczB,CAAA;AAED,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;CAAqB,CAAA;AAE3C,eAAO,MAAM,WAAW,mCAAuB,CAAA;AAE/C,eAAO,MAAM,kBAAkB,uEAA8B,CAAA"}
|