@passlock/client 0.9.19 → 0.9.21
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 +5 -4
- package/dist/authentication/authenticate.d.ts.map +1 -1
- package/dist/authentication/authenticate.fixture.d.ts +3 -4
- package/dist/authentication/authenticate.fixture.d.ts.map +1 -1
- package/dist/authentication/authenticate.fixture.js +2 -11
- package/dist/authentication/authenticate.fixture.js.map +1 -1
- package/dist/authentication/authenticate.js +4 -4
- package/dist/authentication/authenticate.js.map +1 -1
- package/dist/authentication/authenticate.test.js +5 -5
- package/dist/authentication/authenticate.test.js.map +1 -1
- package/dist/connection/connection.d.ts +4 -3
- package/dist/connection/connection.d.ts.map +1 -1
- package/dist/connection/connection.fixture.d.ts +3 -5
- package/dist/connection/connection.fixture.d.ts.map +1 -1
- package/dist/connection/connection.fixture.js +3 -15
- package/dist/connection/connection.fixture.js.map +1 -1
- package/dist/connection/connection.js +3 -3
- package/dist/connection/connection.js.map +1 -1
- package/dist/connection/connection.test.js +6 -5
- package/dist/connection/connection.test.js.map +1 -1
- package/dist/effect.d.ts +1 -1
- package/dist/effect.d.ts.map +1 -1
- package/dist/effect.js +17 -8
- package/dist/effect.js.map +1 -1
- package/dist/email/email.d.ts +4 -4
- package/dist/email/email.d.ts.map +1 -1
- package/dist/email/email.fixture.d.ts +2 -3
- package/dist/email/email.fixture.d.ts.map +1 -1
- package/dist/email/email.fixture.js +2 -10
- package/dist/email/email.fixture.js.map +1 -1
- package/dist/email/email.js +2 -3
- package/dist/email/email.js.map +1 -1
- package/dist/email/email.test.js +5 -5
- package/dist/email/email.test.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/logging/eventLogger.d.ts.map +1 -1
- package/dist/logging/eventLogger.js +15 -9
- package/dist/logging/eventLogger.js.map +1 -1
- package/dist/logging/eventLogger.test.js.map +1 -1
- package/dist/registration/register.d.ts +6 -4
- package/dist/registration/register.d.ts.map +1 -1
- package/dist/registration/register.fixture.d.ts +3 -4
- package/dist/registration/register.fixture.d.ts.map +1 -1
- package/dist/registration/register.fixture.js +2 -12
- package/dist/registration/register.fixture.js.map +1 -1
- package/dist/registration/register.js +5 -4
- package/dist/registration/register.js.map +1 -1
- package/dist/registration/register.test.js +6 -6
- package/dist/registration/register.test.js.map +1 -1
- package/dist/rpc/authentication.d.ts +9 -0
- package/dist/rpc/authentication.d.ts.map +1 -0
- package/dist/rpc/authentication.js +15 -0
- package/dist/rpc/authentication.js.map +1 -0
- package/dist/rpc/client.d.ts +27 -0
- package/dist/rpc/client.d.ts.map +1 -0
- package/dist/rpc/client.js +92 -0
- package/dist/rpc/client.js.map +1 -0
- package/dist/rpc/config.d.ts +16 -0
- package/dist/rpc/config.d.ts.map +1 -0
- package/dist/rpc/config.js +6 -0
- package/dist/rpc/config.js.map +1 -0
- package/dist/rpc/connection.d.ts +9 -0
- package/dist/rpc/connection.d.ts.map +1 -0
- package/dist/rpc/connection.js +14 -0
- package/dist/rpc/connection.js.map +1 -0
- package/dist/rpc/registration.d.ts +9 -0
- package/dist/rpc/registration.d.ts.map +1 -0
- package/dist/rpc/registration.js +15 -0
- package/dist/rpc/registration.js.map +1 -0
- package/dist/rpc/social.d.ts +11 -0
- package/dist/rpc/social.d.ts.map +1 -0
- package/dist/rpc/social.js +17 -0
- package/dist/rpc/social.js.map +1 -0
- package/dist/rpc/user.d.ts +9 -0
- package/dist/rpc/user.d.ts.map +1 -0
- package/dist/rpc/user.js +18 -0
- package/dist/rpc/user.js.map +1 -0
- package/dist/social/social.d.ts +4 -4
- package/dist/social/social.d.ts.map +1 -1
- package/dist/social/social.fixture.d.ts +1 -2
- package/dist/social/social.fixture.d.ts.map +1 -1
- package/dist/social/social.fixture.js +5 -14
- package/dist/social/social.fixture.js.map +1 -1
- package/dist/social/social.js +6 -6
- package/dist/social/social.js.map +1 -1
- package/dist/social/social.test.js +9 -9
- package/dist/social/social.test.js.map +1 -1
- package/dist/storage/storage.d.ts +1 -1
- package/dist/storage/storage.d.ts.map +1 -1
- package/dist/test/fixtures.d.ts +1 -3
- package/dist/test/fixtures.d.ts.map +1 -1
- package/dist/test/fixtures.js +0 -2
- package/dist/test/fixtures.js.map +1 -1
- package/dist/user/user.d.ts +4 -4
- package/dist/user/user.d.ts.map +1 -1
- package/dist/user/user.fixture.d.ts +2 -3
- package/dist/user/user.fixture.d.ts.map +1 -1
- package/dist/user/user.fixture.js +2 -10
- package/dist/user/user.fixture.js.map +1 -1
- package/dist/user/user.js +3 -4
- package/dist/user/user.js.map +1 -1
- package/dist/user/user.test.js +5 -5
- package/dist/user/user.test.js.map +1 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/package.json +10 -11
- package/src/authentication/authenticate.fixture.ts +8 -16
- package/src/authentication/authenticate.test.ts +7 -7
- package/src/authentication/authenticate.ts +13 -14
- package/src/connection/connection.fixture.ts +4 -16
- package/src/connection/connection.test.ts +7 -6
- package/src/connection/connection.ts +5 -5
- package/src/effect.ts +20 -14
- package/src/email/email.fixture.ts +3 -11
- package/src/email/email.test.ts +7 -7
- package/src/email/email.ts +5 -6
- package/src/index.ts +5 -2
- package/src/logging/eventLogger.test.ts +1 -0
- package/src/logging/eventLogger.ts +16 -10
- package/src/registration/register.fixture.ts +9 -18
- package/src/registration/register.test.ts +9 -9
- package/src/registration/register.ts +12 -13
- package/src/social/social.fixture.ts +7 -16
- package/src/social/social.test.ts +15 -15
- package/src/social/social.ts +9 -9
- package/src/storage/storage.ts +1 -1
- package/src/test/fixtures.ts +1 -3
- package/src/user/user.fixture.ts +3 -11
- package/src/user/user.test.ts +7 -7
- package/src/user/user.ts +6 -7
- package/README.md +0 -116
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../src/test/fixtures.ts"],"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AC;IACjC,eAAe,EAAE,CAAC,CAAC,IAAI;IACvB,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;CACnC,CAAC,CACH,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAgB,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAA;AAErE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,OAAO,CACzC,cAAc,EACd,cAAc,CAAC,EAAE,CAAC;IAChB,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI;IACxB,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;IACtC,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI;IACxB,iBAAiB,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI;IAC/B,kBAAkB,EAAE,CAAC,CAAC,IAAI;CAC3B,CAAC,CACH,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC,CAAA"}
|
package/dist/user/user.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BadRequest, Disabled, NotFound } from '@passlock/shared/dist/error/error.js';
|
|
2
|
-
import {
|
|
3
|
-
import type { VerifyEmail } from '@passlock/shared/dist/schema/
|
|
2
|
+
import { UserClient } from '@passlock/shared/dist/rpc/user.js';
|
|
3
|
+
import type { VerifyEmail } from '@passlock/shared/dist/schema/email.js';
|
|
4
4
|
import { Context, Effect as E, Layer } from 'effect';
|
|
5
5
|
export type Email = {
|
|
6
6
|
email: string;
|
|
@@ -14,9 +14,9 @@ export type UserService = {
|
|
|
14
14
|
resendVerificationEmail: (request: ResendEmail) => E.Effect<void, ResendEmailErrors>;
|
|
15
15
|
};
|
|
16
16
|
export declare const UserService: Context.Tag<UserService, UserService>;
|
|
17
|
-
type Dependencies =
|
|
17
|
+
type Dependencies = UserClient;
|
|
18
18
|
export declare const isExistingUser: (request: Email) => E.Effect<boolean, BadRequest, Dependencies>;
|
|
19
19
|
export declare const resendVerificationEmail: (request: ResendEmail) => E.Effect<void, ResendEmailErrors, Dependencies>;
|
|
20
|
-
export declare const UserServiceLive: Layer.Layer<UserService, never,
|
|
20
|
+
export declare const UserServiceLive: Layer.Layer<UserService, never, UserClient>;
|
|
21
21
|
export {};
|
|
22
22
|
//# sourceMappingURL=user.d.ts.map
|
package/dist/user/user.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/user/user.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAA;AAC1F,OAAO,
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/user/user.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAA;AAC1F,OAAO,EAAqC,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACjG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAQ,MAAM,QAAQ,CAAA;AAI1D,MAAM,MAAM,KAAK,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AACrC,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAI1D,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAIhE,MAAM,MAAM,WAAW,GAAG;IACxB,cAAc,EAAE,CAAC,OAAO,EAAE,KAAK,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;IACjE,uBAAuB,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAA;CACrF,CAAA;AAED,eAAO,MAAM,WAAW,uCAA2D,CAAA;AAInF,KAAK,YAAY,GAAG,UAAU,CAAA;AAE9B,eAAO,MAAM,cAAc,YAAa,KAAK,KAAG,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,YAAY,CAUzF,CAAA;AAED,eAAO,MAAM,uBAAuB,YAAa,WAAW,KAAG,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,iBAAiB,EAAE,YAAY,CAS5G,CAAA;AAKD,eAAO,MAAM,eAAe,6CAS3B,CAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IsExistingUserReq, IsExistingUserRes, ResendEmailReq, ResendEmailRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
|
|
1
|
+
import { IsExistingUserReq, IsExistingUserRes, ResendEmailReq, ResendEmailRes, UserClient, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
|
|
3
2
|
import { Layer as L } from 'effect';
|
|
4
3
|
import type { ResendEmail } from './user.js';
|
|
5
4
|
export declare const email = "jdoe@gmail.com";
|
|
@@ -9,5 +8,5 @@ export declare const verifyEmailRes: VerifyEmailRes;
|
|
|
9
8
|
export declare const resendEmailReq: ResendEmail;
|
|
10
9
|
export declare const rpcResendEmailReq: ResendEmailReq;
|
|
11
10
|
export declare const rpcResendEmailRes: ResendEmailRes;
|
|
12
|
-
export declare const rpcClientTest: L.Layer<
|
|
11
|
+
export declare const rpcClientTest: L.Layer<UserClient, never, never>;
|
|
13
12
|
//# sourceMappingURL=user.fixture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.fixture.d.ts","sourceRoot":"","sources":["../../src/user/user.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"user.fixture.d.ts","sourceRoot":"","sources":["../../src/user/user.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AACpJ,OAAO,EAAe,KAAK,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,eAAO,MAAM,KAAK,mBAAmB,CAAA;AACrC,eAAO,MAAM,eAAe,mBAAmC,CAAA;AAC/D,eAAO,MAAM,eAAe,mBAAiD,CAAA;AAC7E,eAAO,MAAM,cAAc,gBAAwD,CAAA;AACnF,eAAO,MAAM,cAAc,EAAE,WAA+C,CAAA;AAC5E,eAAO,MAAM,iBAAiB,gBAAwE,CAAA;AACtG,eAAO,MAAM,iBAAiB,gBAA0B,CAAA;AAExD,eAAO,MAAM,aAAa,mCAOzB,CAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IsExistingUserReq, IsExistingUserRes, ResendEmailReq, ResendEmailRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
|
|
1
|
+
import { IsExistingUserReq, IsExistingUserRes, ResendEmailReq, ResendEmailRes, UserClient, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
|
|
3
2
|
import { Effect as E, Layer as L } from 'effect';
|
|
4
3
|
import * as Fixtures from '../test/fixtures.js';
|
|
5
4
|
export const email = 'jdoe@gmail.com';
|
|
@@ -9,16 +8,9 @@ export const verifyEmailRes = new VerifyEmailRes({ principal: Fixtures.principal
|
|
|
9
8
|
export const resendEmailReq = { userId: '123', method: 'code' };
|
|
10
9
|
export const rpcResendEmailReq = new ResendEmailReq({ userId: '123', verifyEmail: { method: 'code' } });
|
|
11
10
|
export const rpcResendEmailRes = new ResendEmailRes({});
|
|
12
|
-
export const rpcClientTest = L.succeed(
|
|
13
|
-
preConnect: () => E.succeed({ warmed: true }),
|
|
11
|
+
export const rpcClientTest = L.succeed(UserClient, UserClient.of({
|
|
14
12
|
isExistingUser: () => E.succeed({ existingUser: true }),
|
|
15
13
|
verifyEmail: () => E.succeed(verifyEmailRes),
|
|
16
|
-
getRegistrationOptions: () => E.fail(Fixtures.notImplemented),
|
|
17
|
-
verifyRegistrationCredential: () => E.fail(Fixtures.notImplemented),
|
|
18
|
-
getAuthenticationOptions: () => E.fail(Fixtures.notImplemented),
|
|
19
|
-
verifyAuthenticationCredential: () => E.fail(Fixtures.notImplemented),
|
|
20
|
-
registerOidc: () => E.fail(Fixtures.notImplemented),
|
|
21
|
-
authenticateOidc: () => E.fail(Fixtures.notImplemented),
|
|
22
14
|
resendVerificationEmail: () => E.fail(Fixtures.notImplemented),
|
|
23
15
|
}));
|
|
24
16
|
//# sourceMappingURL=user.fixture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.fixture.js","sourceRoot":"","sources":["../../src/user/user.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"user.fixture.js","sourceRoot":"","sources":["../../src/user/user.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AACpJ,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAG/C,MAAM,CAAC,MAAM,KAAK,GAAG,gBAAgB,CAAA;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,iBAAiB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;AAC/D,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,iBAAiB,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAA;AAC7E,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAA;AACnF,MAAM,CAAC,MAAM,cAAc,GAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AAC5E,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,cAAc,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAC,CAAC,CAAA;AACtG,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,cAAc,CAAC,EAAG,CAAC,CAAA;AAExD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,OAAO,CACpC,UAAU,EACV,UAAU,CAAC,EAAE,CAAC;IACZ,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACvD,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;IAC5C,uBAAuB,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;CAC/D,CAAC,CACH,CAAA"}
|
package/dist/user/user.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IsExistingUserReq, ResendEmailReq } from '@passlock/shared/dist/rpc/user.js';
|
|
1
|
+
import { IsExistingUserReq, ResendEmailReq, UserClient } from '@passlock/shared/dist/rpc/user.js';
|
|
3
2
|
import { Context, Effect as E, Layer, flow } from 'effect';
|
|
4
3
|
export const UserService = Context.GenericTag('@services/UserService');
|
|
5
4
|
export const isExistingUser = (request) => {
|
|
6
5
|
return E.gen(function* (_) {
|
|
7
6
|
yield* _(E.logInfo('Checking registration status'));
|
|
8
|
-
const rpcClient = yield* _(
|
|
7
|
+
const rpcClient = yield* _(UserClient);
|
|
9
8
|
yield* _(E.logDebug('Making RPC request'));
|
|
10
9
|
const { existingUser } = yield* _(rpcClient.isExistingUser(new IsExistingUserReq(request)));
|
|
11
10
|
return existingUser;
|
|
@@ -14,7 +13,7 @@ export const isExistingUser = (request) => {
|
|
|
14
13
|
export const resendVerificationEmail = (request) => {
|
|
15
14
|
return E.gen(function* (_) {
|
|
16
15
|
yield* _(E.logInfo('Resending verification email'));
|
|
17
|
-
const rpcClient = yield* _(
|
|
16
|
+
const rpcClient = yield* _(UserClient);
|
|
18
17
|
yield* _(E.logDebug('Making RPC request'));
|
|
19
18
|
const { userId, ...verifyEmail } = request;
|
|
20
19
|
yield* _(rpcClient.resendVerificationEmail(new ResendEmailReq({ userId, verifyEmail })));
|
package/dist/user/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/user/user.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/user/user.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEjG,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAkB1D,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAc,uBAAuB,CAAC,CAAA;AAMnF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAc,EAA+C,EAAE;IAC5F,OAAO,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC,CAAA;QACnD,MAAM,SAAS,GAAG,KAAK,CAAC,C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AAc,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACxD,uBAAuB,EAAE,IAAI,CAAC,uBAAuB,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;KAC3E,CAAC,CAAA;AACJ,CAAC,CAAC,CACH,CAAA"}
|
package/dist/user/user.test.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UserClient } from '@passlock/shared/dist/rpc/user.js';
|
|
2
2
|
import { Effect as E, Layer as L, Layer, LogLevel, Logger, pipe } from 'effect';
|
|
3
3
|
import { describe, expect, test } from 'vitest';
|
|
4
4
|
import { mock } from 'vitest-mock-extended';
|
|
@@ -20,10 +20,10 @@ describe('isExistingUser should', () => {
|
|
|
20
20
|
const service = yield* _(UserService);
|
|
21
21
|
const result = yield* _(service.isExistingUser({ email: Fixture.email }));
|
|
22
22
|
expect(result).toBe(false);
|
|
23
|
-
const rpcClient = yield* _(
|
|
23
|
+
const rpcClient = yield* _(UserClient);
|
|
24
24
|
expect(rpcClient.isExistingUser).toBeCalledWith(Fixture.isRegisteredReq);
|
|
25
25
|
});
|
|
26
|
-
const rpcClientTest = Layer.effect(
|
|
26
|
+
const rpcClientTest = Layer.effect(UserClient, E.sync(() => {
|
|
27
27
|
const rpcMock = mock();
|
|
28
28
|
rpcMock.isExistingUser.mockReturnValue(E.succeed(Fixture.isRegisteredRes));
|
|
29
29
|
return rpcMock;
|
|
@@ -39,10 +39,10 @@ describe('resendVerificationEmail should', () => {
|
|
|
39
39
|
const assertions = E.gen(function* (_) {
|
|
40
40
|
const service = yield* _(UserService);
|
|
41
41
|
yield* _(service.resendVerificationEmail(Fixture.resendEmailReq));
|
|
42
|
-
const rpcClient = yield* _(
|
|
42
|
+
const rpcClient = yield* _(UserClient);
|
|
43
43
|
expect(rpcClient.resendVerificationEmail).toBeCalledWith(Fixture.rpcResendEmailReq);
|
|
44
44
|
});
|
|
45
|
-
const rpcClientTest = Layer.effect(
|
|
45
|
+
const rpcClientTest = Layer.effect(UserClient, E.sync(() => {
|
|
46
46
|
const rpcMock = mock();
|
|
47
47
|
rpcMock.resendVerificationEmail.mockReturnValue(E.succeed(Fixture.rpcResendEmailRes));
|
|
48
48
|
return rpcMock;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.test.js","sourceRoot":"","sources":["../../src/user/user.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"user.test.js","sourceRoot":"","sources":["../../src/user/user.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAC9D,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAExD,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,IAAI,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;QACjE,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;YACrC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;YAEzE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;Q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AAA;YAErF,OAAO,OAAO,CAAA;QAChB,CAAC,CAAC,CACH,CAAA;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAA;QAE/D,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,CAAA;QAE9C,MAAM,MAAM,GAAG,IAAI,CACjB,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,EAC7B,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC1C,CAAA;QAED,OAAO,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,eAAe,CAAA"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@passlock/client",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.21",
|
|
4
4
|
"description": "Easy WebAuthn/FIDO Passkey authentication and social login for web apps. This library works with pretty much any frontend/backend stack including React/Next.js, Vue etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"passkey",
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@github/webauthn-json": "^2.1.1",
|
|
45
45
|
"effect": "^3.4.8",
|
|
46
|
-
"@passlock/shared": "0.9.
|
|
46
|
+
"@passlock/shared": "0.9.21"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@tsconfig/node18": "^18.2.4",
|
|
50
50
|
"@types/node": "^20.14.10",
|
|
51
51
|
"@typescript-eslint/eslint-plugin": "^7.15.0",
|
|
52
52
|
"@typescript-eslint/parser": "^7.15.0",
|
|
53
|
-
"@vitest/coverage-v8": "^
|
|
54
|
-
"@vitest/ui": "^
|
|
53
|
+
"@vitest/coverage-v8": "^2.0.3",
|
|
54
|
+
"@vitest/ui": "^2.0.3",
|
|
55
55
|
"eslint": "^8.57.0",
|
|
56
56
|
"eslint-config-prettier": "^9.1.0",
|
|
57
57
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
@@ -62,24 +62,23 @@
|
|
|
62
62
|
"tslib": "^2.6.3",
|
|
63
63
|
"typescript": "^5.5.3",
|
|
64
64
|
"vite": "^5.3.3",
|
|
65
|
-
"vitest": "^
|
|
65
|
+
"vitest": "^2.0.3",
|
|
66
66
|
"vitest-mock-extended": "^1.3.1"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"clean": "tsc --build --clean",
|
|
70
|
-
"
|
|
70
|
+
"typecheck": "tsc --noEmit",
|
|
71
71
|
"test": "vitest run",
|
|
72
72
|
"test:watch": "vitest dev",
|
|
73
73
|
"test:ui": "vitest --coverage.enabled=true --ui",
|
|
74
74
|
"test:coverage": "vitest run --coverage",
|
|
75
75
|
"build": "tsc --build",
|
|
76
76
|
"build:clean": "pnpm run clean && pnpm run build",
|
|
77
|
-
"watch": "tsc --build --watch",
|
|
78
|
-
"
|
|
77
|
+
"build:watch": "tsc --build --watch",
|
|
78
|
+
"format": "prettier --write \"src/**/*.+(js|ts|json)\"",
|
|
79
79
|
"lint": "eslint --ext .ts src",
|
|
80
80
|
"lint:fix": "pnpm run lint --fix",
|
|
81
|
-
"
|
|
82
|
-
"ncu": "ncu --peer -x @
|
|
83
|
-
"ncu:save": "ncu --peer -x @passlock/* -x effect -u"
|
|
81
|
+
"ncu": "ncu --peer -x @effect/* -x effect",
|
|
82
|
+
"ncu:save": "ncu --peer -x @effect/* -x effect -u"
|
|
84
83
|
}
|
|
85
84
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
AuthenticationClient,
|
|
3
|
+
OptionsRes,
|
|
4
|
+
VerificationReq,
|
|
5
|
+
VerificationRes,
|
|
5
6
|
} from '@passlock/shared/dist/rpc/authentication.js'
|
|
6
|
-
import { RpcClient } from '@passlock/shared/dist/rpc/rpc.js'
|
|
7
7
|
import { IsExistingUserRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js'
|
|
8
|
-
import type { AuthenticationCredential } from '@passlock/shared/dist/schema/
|
|
8
|
+
import type { AuthenticationCredential } from '@passlock/shared/dist/schema/passkey.js'
|
|
9
9
|
import { Effect as E, Layer as L } from 'effect'
|
|
10
10
|
import * as Fixtures from '../test/fixtures.js'
|
|
11
11
|
import { GetCredential, type AuthenticationRequest } from './authenticate.js'
|
|
@@ -58,19 +58,11 @@ export const getCredentialTest = L.succeed(
|
|
|
58
58
|
)
|
|
59
59
|
|
|
60
60
|
export const rpcClientTest = L.succeed(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
preConnect: () => E.succeed(Fixtures.preConnectRes),
|
|
64
|
-
isExistingUser: () => E.succeed(rpcIsExistingUserRes),
|
|
65
|
-
verifyEmail: () => E.succeed(rpcVerifyEmailRes),
|
|
66
|
-
getRegistrationOptions: () => E.fail(Fixtures.notImplemented),
|
|
67
|
-
verifyRegistrationCredential: () => E.fail(Fixtures.notImplemented),
|
|
61
|
+
AuthenticationClient,
|
|
62
|
+
AuthenticationClient.of({
|
|
68
63
|
getAuthenticationOptions: () => E.succeed(rpcOptionsRes),
|
|
69
64
|
verifyAuthenticationCredential: () => E.succeed(rpcVerificationRes),
|
|
70
|
-
|
|
71
|
-
authenticateOidc: () => E.fail(Fixtures.notImplemented),
|
|
72
|
-
resendVerificationEmail: () => E.fail(Fixtures.notImplemented),
|
|
73
|
-
}),
|
|
65
|
+
})
|
|
74
66
|
)
|
|
75
67
|
|
|
76
68
|
export const principal = Fixtures.principal
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AuthenticationClient } from '@passlock/shared/dist/rpc/authentication.js'
|
|
2
2
|
import { Effect as E, Layer as L, Layer, LogLevel, Logger, pipe } from 'effect'
|
|
3
3
|
import { describe, expect, test, vi } from 'vitest'
|
|
4
4
|
import { mock } from 'vitest-mock-extended'
|
|
@@ -33,15 +33,15 @@ describe('authenticate should', () => {
|
|
|
33
33
|
const service = yield* _(AuthenticationService)
|
|
34
34
|
yield* _(service.authenticatePasskey({ userVerification: 'preferred' }))
|
|
35
35
|
|
|
36
|
-
const rpcClient = yield* _(
|
|
36
|
+
const rpcClient = yield* _(AuthenticationClient)
|
|
37
37
|
expect(rpcClient.getAuthenticationOptions).toHaveBeenCalledOnce()
|
|
38
38
|
expect(rpcClient.verifyAuthenticationCredential).toHaveBeenCalledOnce()
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
const rpcClientTest = L.effect(
|
|
42
|
-
|
|
42
|
+
AuthenticationClient,
|
|
43
43
|
E.sync(() => {
|
|
44
|
-
const rpcMock = mock<
|
|
44
|
+
const rpcMock = mock<AuthenticationClient['Type']>()
|
|
45
45
|
|
|
46
46
|
rpcMock.getAuthenticationOptions.mockReturnValue(E.succeed(Fixture.rpcOptionsRes))
|
|
47
47
|
rpcMock.verifyAuthenticationCredential.mockReturnValue(E.succeed(Fixture.rpcVerificationRes))
|
|
@@ -69,15 +69,15 @@ describe('authenticate should', () => {
|
|
|
69
69
|
const service = yield* _(AuthenticationService)
|
|
70
70
|
yield* _(service.authenticatePasskey({ userVerification: 'preferred' }))
|
|
71
71
|
|
|
72
|
-
const rpcClient = yield* _(
|
|
72
|
+
const rpcClient = yield* _(AuthenticationClient)
|
|
73
73
|
expect(rpcClient.getAuthenticationOptions).toHaveBeenCalledOnce()
|
|
74
74
|
expect(rpcClient.verifyAuthenticationCredential).toHaveBeenCalledWith(Fixture.rpcVerificationReq)
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
const rpcClientTest = L.effect(
|
|
78
|
-
|
|
78
|
+
AuthenticationClient,
|
|
79
79
|
E.sync(() => {
|
|
80
|
-
const rpcMock = mock<
|
|
80
|
+
const rpcMock = mock<AuthenticationClient['Type']>()
|
|
81
81
|
|
|
82
82
|
rpcMock.getAuthenticationOptions.mockReturnValue(E.succeed(Fixture.rpcOptionsRes))
|
|
83
83
|
rpcMock.verifyAuthenticationCredential.mockReturnValue(E.succeed(Fixture.rpcVerificationRes))
|
|
@@ -2,21 +2,20 @@
|
|
|
2
2
|
* Passkey authentication effects
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
parseRequestOptionsFromJSON,
|
|
6
|
+
type CredentialRequestOptionsJSON,
|
|
7
7
|
} from '@github/webauthn-json/browser-ponyfill'
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
InternalBrowserError,
|
|
10
|
+
type NotSupported,
|
|
11
11
|
} from '@passlock/shared/dist/error/error.js'
|
|
12
12
|
import type { OptionsErrors, VerificationErrors } from '@passlock/shared/dist/rpc/authentication.js'
|
|
13
|
-
import { OptionsReq, VerificationReq } from '@passlock/shared/dist/rpc/authentication.js'
|
|
14
|
-
import { RpcClient } from '@passlock/shared/dist/rpc/rpc.js'
|
|
13
|
+
import { AuthenticationClient, OptionsReq, VerificationReq } from '@passlock/shared/dist/rpc/authentication.js'
|
|
15
14
|
import type {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from '@passlock/shared/dist/schema/
|
|
15
|
+
AuthenticationCredential,
|
|
16
|
+
UserVerification,
|
|
17
|
+
} from '@passlock/shared/dist/schema/passkey.js'
|
|
18
|
+
import { Principal } from '@passlock/shared/dist/schema/principal.js'
|
|
20
19
|
import { Context, Effect as E, Layer, flow, pipe } from 'effect'
|
|
21
20
|
import { Capabilities } from '../capabilities/capabilities.js'
|
|
22
21
|
import { StorageService } from '../storage/storage.js'
|
|
@@ -56,7 +55,7 @@ const fetchOptions = (request: OptionsReq) => {
|
|
|
56
55
|
return E.gen(function* (_) {
|
|
57
56
|
yield* _(E.logDebug('Making request'))
|
|
58
57
|
|
|
59
|
-
const rpcClient = yield* _(
|
|
58
|
+
const rpcClient = yield* _(AuthenticationClient)
|
|
60
59
|
const { publicKey, session } = yield* _(rpcClient.getAuthenticationOptions(request))
|
|
61
60
|
|
|
62
61
|
yield* _(E.logDebug('Converting Passlock options to CredentialRequestOptions'))
|
|
@@ -83,7 +82,7 @@ const verifyCredential = (request: VerificationReq) => {
|
|
|
83
82
|
return E.gen(function* (_) {
|
|
84
83
|
yield* _(E.logDebug('Making request'))
|
|
85
84
|
|
|
86
|
-
const rpcClient = yield* _(
|
|
85
|
+
const rpcClient = yield* _(AuthenticationClient)
|
|
87
86
|
const { principal } = yield* _(rpcClient.verifyAuthenticationCredential(request))
|
|
88
87
|
|
|
89
88
|
return principal
|
|
@@ -92,7 +91,7 @@ const verifyCredential = (request: VerificationReq) => {
|
|
|
92
91
|
|
|
93
92
|
/* Effects */
|
|
94
93
|
|
|
95
|
-
type Dependencies = GetCredential | Capabilities | StorageService |
|
|
94
|
+
type Dependencies = GetCredential | Capabilities | StorageService | AuthenticationClient
|
|
96
95
|
|
|
97
96
|
export const authenticatePasskey = (
|
|
98
97
|
request: AuthenticationRequest,
|
|
@@ -136,7 +135,7 @@ export const authenticatePasskey = (
|
|
|
136
135
|
export const AuthenticateServiceLive = Layer.effect(
|
|
137
136
|
AuthenticationService,
|
|
138
137
|
E.gen(function* (_) {
|
|
139
|
-
const context = yield* _(E.context<GetCredential |
|
|
138
|
+
const context = yield* _(E.context<GetCredential | AuthenticationClient | Capabilities | StorageService>())
|
|
140
139
|
|
|
141
140
|
return AuthenticationService.of({
|
|
142
141
|
authenticatePasskey: flow(authenticatePasskey, E.provide(context)),
|
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RpcClient } from '@passlock/shared/dist/rpc/rpc.js'
|
|
1
|
+
import { ConnectionClient, ConnectRes } from '@passlock/shared/dist/rpc/connection.js'
|
|
3
2
|
import { Effect as E, Layer as L } from 'effect'
|
|
4
|
-
import * as Fixtures from '../test/fixtures.js'
|
|
5
3
|
|
|
6
|
-
export const
|
|
7
|
-
export const preConnectRes = new PreConnectRes({ warmed: true })
|
|
4
|
+
export const preConnectRes = new ConnectRes({ warmed: true })
|
|
8
5
|
|
|
9
6
|
export const rpcClientTest = L.succeed(
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
ConnectionClient,
|
|
8
|
+
ConnectionClient.of({
|
|
12
9
|
preConnect: () => E.succeed(preConnectRes),
|
|
13
|
-
isExistingUser: () => E.fail(Fixtures.notImplemented),
|
|
14
|
-
verifyEmail: () => E.fail(Fixtures.notImplemented),
|
|
15
|
-
getRegistrationOptions: () => E.fail(Fixtures.notImplemented),
|
|
16
|
-
verifyRegistrationCredential: () => E.fail(Fixtures.notImplemented),
|
|
17
|
-
getAuthenticationOptions: () => E.fail(Fixtures.notImplemented),
|
|
18
|
-
verifyAuthenticationCredential: () => E.fail(Fixtures.notImplemented),
|
|
19
|
-
registerOidc: () => E.fail(Fixtures.notImplemented),
|
|
20
|
-
authenticateOidc: () => E.fail(Fixtures.notImplemented),
|
|
21
|
-
resendVerificationEmail: () => E.fail(Fixtures.notImplemented),
|
|
22
10
|
}),
|
|
23
11
|
)
|
|
24
12
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RpcConfig } from '@passlock/shared/dist/rpc/config.js'
|
|
2
|
-
import {
|
|
2
|
+
import { ConnectionClient } from '@passlock/shared/dist/rpc/connection.js'
|
|
3
|
+
import { Dispatcher } from '@passlock/shared/dist/rpc/dispatcher.js'
|
|
3
4
|
import { Effect as E, Layer as L, Layer, LogLevel, Logger, pipe } from 'effect'
|
|
4
5
|
import { describe, expect, test } from 'vitest'
|
|
5
6
|
import { mock } from 'vitest-mock-extended'
|
|
@@ -12,17 +13,17 @@ describe('preConnect should', () => {
|
|
|
12
13
|
const service = yield* _(ConnectionService)
|
|
13
14
|
yield* _(service.preConnect())
|
|
14
15
|
|
|
15
|
-
const rpcClient = yield* _(
|
|
16
|
-
expect(rpcClient.preConnect).
|
|
16
|
+
const rpcClient = yield* _(ConnectionClient)
|
|
17
|
+
expect(rpcClient.preConnect).toBeCalled()
|
|
17
18
|
|
|
18
19
|
const dispatcher = yield* _(Dispatcher)
|
|
19
20
|
expect(dispatcher.get).toBeCalledWith(`/token/token?warm=true`)
|
|
20
21
|
})
|
|
21
22
|
|
|
22
23
|
const rpcClientTest = Layer.effect(
|
|
23
|
-
|
|
24
|
+
ConnectionClient,
|
|
24
25
|
E.sync(() => {
|
|
25
|
-
const rpcMock = mock<
|
|
26
|
+
const rpcMock = mock<ConnectionClient['Type']>()
|
|
26
27
|
|
|
27
28
|
rpcMock.preConnect.mockReturnValue(E.succeed(Fixture.preConnectRes))
|
|
28
29
|
|
|
@@ -37,7 +38,7 @@ describe('preConnect should', () => {
|
|
|
37
38
|
E.sync(() => {
|
|
38
39
|
const dispatcherMock = mock<Dispatcher['Type']>()
|
|
39
40
|
|
|
40
|
-
dispatcherMock.get.mockReturnValue(E.succeed({}))
|
|
41
|
+
dispatcherMock.get.mockReturnValue(E.succeed({ status: 200, body: {} }))
|
|
41
42
|
|
|
42
43
|
return dispatcherMock
|
|
43
44
|
}),
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Hits the rpc endpoint to warm up a lambda
|
|
3
3
|
*/
|
|
4
4
|
import type { RpcConfig } from '@passlock/shared/dist/rpc/config.js'
|
|
5
|
-
import {
|
|
6
|
-
import { Dispatcher
|
|
5
|
+
import { ConnectionClient } from '@passlock/shared/dist/rpc/connection.js'
|
|
6
|
+
import { Dispatcher } from '@passlock/shared/dist/rpc/dispatcher.js'
|
|
7
7
|
import { Context, Effect as E, Layer, flow, pipe } from 'effect'
|
|
8
8
|
|
|
9
9
|
/* Service */
|
|
@@ -26,8 +26,8 @@ const hitPrincipal = pipe(
|
|
|
26
26
|
|
|
27
27
|
const hitRpc = pipe(
|
|
28
28
|
E.logInfo('Pre-connecting to RPC endpoint'),
|
|
29
|
-
E.zipRight(
|
|
30
|
-
E.flatMap(rpcClient => rpcClient.preConnect(
|
|
29
|
+
E.zipRight(ConnectionClient),
|
|
30
|
+
E.flatMap(rpcClient => rpcClient.preConnect()),
|
|
31
31
|
E.asVoid,
|
|
32
32
|
)
|
|
33
33
|
|
|
@@ -39,7 +39,7 @@ export const preConnect = () => pipe(E.all([hitPrincipal, hitRpc], { concurrency
|
|
|
39
39
|
export const ConnectionServiceLive = Layer.effect(
|
|
40
40
|
ConnectionService,
|
|
41
41
|
E.gen(function* (_) {
|
|
42
|
-
const context = yield* _(E.context<
|
|
42
|
+
const context = yield* _(E.context<ConnectionClient | Dispatcher | RpcConfig>())
|
|
43
43
|
|
|
44
44
|
return ConnectionService.of({
|
|
45
45
|
preConnect: flow(preConnect, E.provide(context)),
|
package/src/effect.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { create, get as getCredential } from '@github/webauthn-json/browser-ponyfill'
|
|
2
2
|
|
|
3
|
+
import { AuthenticationClientLive } from '@passlock/shared/dist/rpc/authentication.js'
|
|
4
|
+
import { ConnectionClientLive } from '@passlock/shared/dist/rpc/connection.js'
|
|
5
|
+
import { RegistrationClientLive } from '@passlock/shared/dist/rpc/registration.js'
|
|
6
|
+
import { SocialClientLive } from '@passlock/shared/dist/rpc/social.js'
|
|
7
|
+
import { UserClientLive } from '@passlock/shared/dist/rpc/user.js'
|
|
8
|
+
|
|
3
9
|
import {
|
|
4
10
|
Duplicate,
|
|
5
11
|
InternalBrowserError,
|
|
@@ -11,12 +17,7 @@ import {
|
|
|
11
17
|
type Unauthorized,
|
|
12
18
|
} from '@passlock/shared/dist/error/error.js'
|
|
13
19
|
|
|
14
|
-
import {
|
|
15
|
-
DispatcherLive,
|
|
16
|
-
RpcClientLive,
|
|
17
|
-
} from '@passlock/shared/dist/rpc/rpc.js'
|
|
18
|
-
|
|
19
|
-
import type { Principal } from '@passlock/shared/dist/schema/schema.js'
|
|
20
|
+
import type { Principal } from '@passlock/shared/dist/schema/principal.js'
|
|
20
21
|
|
|
21
22
|
import { Context, Effect as E, Layer as L, Layer, Schedule, pipe } from 'effect'
|
|
22
23
|
import type { NoSuchElementException } from 'effect/Cause'
|
|
@@ -48,6 +49,7 @@ import {
|
|
|
48
49
|
} from './storage/storage.js'
|
|
49
50
|
|
|
50
51
|
import { RetrySchedule, RpcConfig } from '@passlock/shared/dist/rpc/config.js'
|
|
52
|
+
import { DispatcherLive } from '@passlock/shared/dist/rpc/dispatcher.js'
|
|
51
53
|
import { SocialService, SocialServiceLive, type RegisterOidcReq } from './social/social.js'
|
|
52
54
|
import { UserService, UserServiceLive, type Email } from './user/user.js'
|
|
53
55
|
|
|
@@ -98,17 +100,21 @@ const schedule = Schedule.intersect(Schedule.recurs(3), Schedule.exponential('10
|
|
|
98
100
|
|
|
99
101
|
const retryScheduleLive = L.succeed(RetrySchedule, RetrySchedule.of({ schedule }))
|
|
100
102
|
|
|
103
|
+
/* RPC Clients */
|
|
101
104
|
const dispatcherLive = pipe(DispatcherLive, L.provide(retryScheduleLive))
|
|
102
|
-
|
|
103
|
-
const
|
|
105
|
+
const connectClientLive = pipe(ConnectionClientLive, L.provide(dispatcherLive))
|
|
106
|
+
const registerClientLive = pipe(RegistrationClientLive, L.provide(dispatcherLive))
|
|
107
|
+
const authenticateClientLive = pipe(AuthenticationClientLive, L.provide(dispatcherLive))
|
|
108
|
+
const socialClientLive = pipe(SocialClientLive, L.provide(dispatcherLive))
|
|
109
|
+
const userClientLive = pipe(UserClientLive, L.provide(dispatcherLive))
|
|
104
110
|
|
|
105
111
|
const storageServiceLive = StorageServiceLive
|
|
106
112
|
|
|
107
|
-
const userServiceLive = pipe(UserServiceLive, L.provide(
|
|
113
|
+
const userServiceLive = pipe(UserServiceLive, L.provide(userClientLive))
|
|
108
114
|
|
|
109
115
|
const registrationServiceLive = pipe(
|
|
110
116
|
RegistrationServiceLive,
|
|
111
|
-
L.provide(
|
|
117
|
+
L.provide(registerClientLive),
|
|
112
118
|
L.provide(userServiceLive),
|
|
113
119
|
L.provide(capabilitiesLive),
|
|
114
120
|
L.provide(createCredentialLive),
|
|
@@ -117,7 +123,7 @@ const registrationServiceLive = pipe(
|
|
|
117
123
|
|
|
118
124
|
const authenticationServiceLive = pipe(
|
|
119
125
|
AuthenticateServiceLive,
|
|
120
|
-
L.provide(
|
|
126
|
+
L.provide(authenticateClientLive),
|
|
121
127
|
L.provide(capabilitiesLive),
|
|
122
128
|
L.provide(getCredentialLive),
|
|
123
129
|
L.provide(storageServiceLive),
|
|
@@ -125,7 +131,7 @@ const authenticationServiceLive = pipe(
|
|
|
125
131
|
|
|
126
132
|
const connectionServiceLive = pipe(
|
|
127
133
|
ConnectionServiceLive,
|
|
128
|
-
L.provide(
|
|
134
|
+
L.provide(connectClientLive),
|
|
129
135
|
L.provide(dispatcherLive),
|
|
130
136
|
)
|
|
131
137
|
|
|
@@ -137,7 +143,7 @@ const urlQueryStringLive = Layer.succeed(
|
|
|
137
143
|
const emailServiceLive = pipe(
|
|
138
144
|
EmailServiceLive,
|
|
139
145
|
L.provide(urlQueryStringLive),
|
|
140
|
-
L.provide(
|
|
146
|
+
L.provide(userClientLive),
|
|
141
147
|
L.provide(capabilitiesLive),
|
|
142
148
|
L.provide(authenticationServiceLive),
|
|
143
149
|
L.provide(storageServiceLive),
|
|
@@ -145,7 +151,7 @@ const emailServiceLive = pipe(
|
|
|
145
151
|
|
|
146
152
|
const socialServiceLive = pipe(
|
|
147
153
|
SocialServiceLive,
|
|
148
|
-
L.provide(
|
|
154
|
+
L.provide(socialClientLive),
|
|
149
155
|
)
|
|
150
156
|
|
|
151
157
|
export const allRequirements = Layer.mergeAll(
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { VerifyEmailReq, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js'
|
|
1
|
+
import { UserClient, VerifyEmailReq, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js'
|
|
3
2
|
import { Effect as E, Layer as L } from 'effect'
|
|
4
3
|
import { AuthenticationService } from '../authentication/authenticate.js'
|
|
5
4
|
import * as Fixtures from '../test/fixtures.js'
|
|
@@ -27,17 +26,10 @@ export const rpcVerifyEmailReq = new VerifyEmailReq({ token, code })
|
|
|
27
26
|
export const rpcVerifyEmailRes = new VerifyEmailRes({ principal: Fixtures.principal })
|
|
28
27
|
|
|
29
28
|
export const rpcClientTest = L.succeed(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
preConnect: () => E.succeed({ warmed: true }),
|
|
29
|
+
UserClient,
|
|
30
|
+
UserClient.of({
|
|
33
31
|
isExistingUser: () => E.succeed({ existingUser: true }),
|
|
34
32
|
verifyEmail: () => E.succeed(rpcVerifyEmailRes),
|
|
35
|
-
getRegistrationOptions: () => E.fail(Fixtures.notImplemented),
|
|
36
|
-
verifyRegistrationCredential: () => E.fail(Fixtures.notImplemented),
|
|
37
|
-
getAuthenticationOptions: () => E.fail(Fixtures.notImplemented),
|
|
38
|
-
verifyAuthenticationCredential: () => E.fail(Fixtures.notImplemented),
|
|
39
|
-
registerOidc: () => E.fail(Fixtures.notImplemented),
|
|
40
|
-
authenticateOidc: () => E.fail(Fixtures.notImplemented),
|
|
41
33
|
resendVerificationEmail: () => E.fail(Fixtures.notImplemented),
|
|
42
34
|
}),
|
|
43
35
|
)
|