@passlock/client 0.9.11 → 0.9.12
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.map +1 -1
- package/dist/authentication/authenticate.fixture.d.ts +5 -5
- package/dist/authentication/authenticate.fixture.d.ts.map +1 -1
- package/dist/authentication/authenticate.fixture.js +9 -9
- package/dist/authentication/authenticate.fixture.js.map +1 -1
- package/dist/authentication/authenticate.js.map +1 -1
- package/dist/authentication/authenticate.test.js +7 -7
- package/dist/authentication/authenticate.test.js.map +1 -1
- package/dist/connection/connection.d.ts.map +1 -1
- package/dist/connection/connection.js.map +1 -1
- package/dist/connection/connection.test.js +1 -1
- package/dist/connection/connection.test.js.map +1 -1
- package/dist/effect.d.ts +5 -5
- package/dist/effect.d.ts.map +1 -1
- package/dist/effect.js +1 -1
- package/dist/effect.js.map +1 -1
- package/dist/email/email.d.ts +2 -2
- package/dist/email/email.d.ts.map +1 -1
- package/dist/email/email.fixture.d.ts +3 -3
- package/dist/email/email.fixture.d.ts.map +1 -1
- package/dist/email/email.fixture.js +4 -4
- package/dist/email/email.fixture.js.map +1 -1
- package/dist/email/email.js.map +1 -1
- package/dist/email/email.test.js +6 -6
- package/dist/email/email.test.js.map +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/registration/register.d.ts.map +1 -1
- package/dist/registration/register.fixture.d.ts +5 -5
- package/dist/registration/register.fixture.d.ts.map +1 -1
- package/dist/registration/register.fixture.js +8 -8
- package/dist/registration/register.fixture.js.map +1 -1
- package/dist/registration/register.js.map +1 -1
- package/dist/registration/register.test.js +7 -7
- package/dist/registration/register.test.js.map +1 -1
- package/dist/social/social.d.ts.map +1 -1
- package/dist/social/social.fixture.d.ts +34 -0
- package/dist/social/social.fixture.d.ts.map +1 -0
- package/dist/social/social.fixture.js +35 -0
- package/dist/social/social.fixture.js.map +1 -0
- package/dist/social/social.test.d.ts +2 -0
- package/dist/social/social.test.d.ts.map +1 -0
- package/dist/social/social.test.js +110 -0
- package/dist/social/social.test.js.map +1 -0
- package/dist/storage/storage.test.js +1 -1
- package/dist/storage/storage.test.js.map +1 -1
- package/dist/test/fixtures.d.ts +2 -2
- package/dist/test/fixtures.d.ts.map +1 -1
- package/dist/test/fixtures.js +2 -2
- package/dist/test/fixtures.js.map +1 -1
- package/dist/user/user.fixture.d.ts +5 -1
- package/dist/user/user.fixture.d.ts.map +1 -1
- package/dist/user/user.fixture.js +4 -1
- package/dist/user/user.fixture.js.map +1 -1
- package/dist/user/user.test.js +20 -1
- package/dist/user/user.test.js.map +1 -1
- package/package.json +10 -10
- package/src/authentication/authenticate.fixture.ts +12 -12
- package/src/authentication/authenticate.test.ts +8 -8
- package/src/authentication/authenticate.ts +7 -7
- package/src/connection/connection.test.ts +2 -2
- package/src/connection/connection.ts +3 -3
- package/src/effect.ts +26 -26
- package/src/email/email.fixture.ts +4 -4
- package/src/email/email.test.ts +7 -7
- package/src/email/email.ts +2 -2
- package/src/index.ts +15 -16
- package/src/registration/register.fixture.ts +12 -12
- package/src/registration/register.test.ts +8 -8
- package/src/registration/register.ts +6 -6
- package/src/social/social.fixture.ts +47 -0
- package/src/social/social.test.ts +193 -0
- package/src/social/social.ts +3 -3
- package/src/storage/storage.test.ts +1 -1
- package/src/test/fixtures.ts +2 -2
- package/src/user/user.fixture.ts +5 -1
- package/src/user/user.test.ts +36 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.fixture.d.ts","sourceRoot":"","sources":["../../src/user/user.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"user.fixture.d.ts","sourceRoot":"","sources":["../../src/user/user.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AACxI,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,kCAczB,CAAA"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { RpcClient } from '@passlock/shared/dist/rpc/rpc.js';
|
|
2
|
-
import { IsExistingUserReq, IsExistingUserRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
|
|
2
|
+
import { IsExistingUserReq, IsExistingUserRes, ResendEmailReq, ResendEmailRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
|
|
3
3
|
import { Effect as E, Layer as L } from 'effect';
|
|
4
4
|
import * as Fixtures from '../test/fixtures.js';
|
|
5
5
|
export const email = 'jdoe@gmail.com';
|
|
6
6
|
export const isRegisteredReq = new IsExistingUserReq({ email });
|
|
7
7
|
export const isRegisteredRes = new IsExistingUserRes({ existingUser: false });
|
|
8
8
|
export const verifyEmailRes = new VerifyEmailRes({ principal: Fixtures.principal });
|
|
9
|
+
export const resendEmailReq = { userId: '123', method: 'code' };
|
|
10
|
+
export const rpcResendEmailReq = new ResendEmailReq({ userId: '123', verifyEmail: { method: 'code' } });
|
|
11
|
+
export const rpcResendEmailRes = new ResendEmailRes({});
|
|
9
12
|
export const rpcClientTest = L.succeed(RpcClient, RpcClient.of({
|
|
10
13
|
preConnect: () => E.succeed({ warmed: true }),
|
|
11
14
|
isExistingUser: () => E.succeed({ existingUser: true }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.fixture.js","sourceRoot":"","sources":["../../src/user/user.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"user.fixture.js","sourceRoot":"","sources":["../../src/user/user.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AACxI,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,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.js
CHANGED
|
@@ -2,8 +2,8 @@ import { RpcClient } from '@passlock/shared/dist/rpc/rpc.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';
|
|
5
|
-
import { UserService, UserServiceLive } from './user.js';
|
|
6
5
|
import * as Fixture from './user.fixture.js';
|
|
6
|
+
import { UserService, UserServiceLive } from './user.js';
|
|
7
7
|
describe('isExistingUser should', () => {
|
|
8
8
|
test('return true when the user already has a passkey', async () => {
|
|
9
9
|
const assertions = E.gen(function* (_) {
|
|
@@ -34,4 +34,23 @@ describe('isExistingUser should', () => {
|
|
|
34
34
|
return E.runPromise(effect);
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
|
+
describe('resendVerificationEmail should', () => {
|
|
38
|
+
test('forward the request to the backend', async () => {
|
|
39
|
+
const assertions = E.gen(function* (_) {
|
|
40
|
+
const service = yield* _(UserService);
|
|
41
|
+
yield* _(service.resendVerificationEmail(Fixture.resendEmailReq));
|
|
42
|
+
const rpcClient = yield* _(RpcClient);
|
|
43
|
+
expect(rpcClient.resendVerificationEmail).toBeCalledWith(Fixture.rpcResendEmailReq);
|
|
44
|
+
});
|
|
45
|
+
const rpcClientTest = Layer.effect(RpcClient, E.sync(() => {
|
|
46
|
+
const rpcMock = mock();
|
|
47
|
+
rpcMock.resendVerificationEmail.mockReturnValue(E.succeed(Fixture.rpcResendEmailRes));
|
|
48
|
+
return rpcMock;
|
|
49
|
+
}));
|
|
50
|
+
const service = pipe(UserServiceLive, L.provide(rpcClientTest));
|
|
51
|
+
const layers = L.merge(service, rpcClientTest);
|
|
52
|
+
const effect = pipe(E.provide(assertions, layers), Logger.withMinimumLogLevel(LogLevel.None));
|
|
53
|
+
return E.runPromise(effect);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
37
56
|
//# sourceMappingURL=user.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.test.js","sourceRoot":"","sources":["../../src/user/user.test.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"user.test.js","sourceRoot":"","sources":["../../src/user/user.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,kCAAkC,CAAA;AAC5E,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;QAC3B,CAAC,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAA;QAEvE,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,C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AAK,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@passlock/client",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.12",
|
|
4
4
|
"description": "Easy WebAuthn/FIDO Passkey authentication for your web apps. This library works with pretty much any frontend/backend stack including React/Next.js, Vue, SvelteKit etc - check out the tutorial",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"passkey",
|
|
@@ -40,27 +40,27 @@
|
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@github/webauthn-json": "^2.1.1",
|
|
43
|
-
"effect": "
|
|
44
|
-
"@passlock/shared": "0.9.
|
|
43
|
+
"effect": "3.1.4",
|
|
44
|
+
"@passlock/shared": "0.9.12"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@tsconfig/node18": "^18.2.4",
|
|
48
|
-
"@types/node": "^20.12.
|
|
48
|
+
"@types/node": "^20.12.11",
|
|
49
49
|
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
50
50
|
"@typescript-eslint/parser": "^7.8.0",
|
|
51
|
-
"@vitest/coverage-v8": "^1.
|
|
52
|
-
"@vitest/ui": "^1.
|
|
51
|
+
"@vitest/coverage-v8": "^1.6.0",
|
|
52
|
+
"@vitest/ui": "^1.6.0",
|
|
53
53
|
"eslint": "^8.56.0",
|
|
54
54
|
"eslint-config-prettier": "^9.1.0",
|
|
55
55
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
56
56
|
"eslint-plugin-import": "^2.29.1",
|
|
57
57
|
"jsdom": "^24.0.0",
|
|
58
58
|
"prettier": "^3.2.5",
|
|
59
|
-
"rimraf": "^5.0.
|
|
59
|
+
"rimraf": "^5.0.7",
|
|
60
60
|
"tslib": "^2.6.2",
|
|
61
61
|
"typescript": "^5.4.5",
|
|
62
|
-
"vite": "^5.2.
|
|
63
|
-
"vitest": "^1.
|
|
62
|
+
"vite": "^5.2.11",
|
|
63
|
+
"vitest": "^1.6.0",
|
|
64
64
|
"vitest-mock-extended": "^1.3.1"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
@@ -78,6 +78,6 @@
|
|
|
78
78
|
"lint:fix": "pnpm run lint --fix",
|
|
79
79
|
"format": "prettier --write \"src/**/*.+(js|ts|json)\"",
|
|
80
80
|
"ncu": "ncu -x @passlock/shared",
|
|
81
|
-
"ncu:save": "ncu -u -x @passlock/shared -x eslint"
|
|
81
|
+
"ncu:save": "ncu -u -x @passlock/shared -x effect -x eslint"
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
OptionsRes,
|
|
3
|
+
VerificationReq,
|
|
4
|
+
VerificationRes,
|
|
5
5
|
} from '@passlock/shared/dist/rpc/authentication.js'
|
|
6
6
|
import { RpcClient } from '@passlock/shared/dist/rpc/rpc.js'
|
|
7
7
|
import { IsExistingUserRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js'
|
|
@@ -20,7 +20,7 @@ export const request: AuthenticationRequest = {
|
|
|
20
20
|
userVerification: 'preferred',
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export const
|
|
23
|
+
export const rpcOptionsRes = new OptionsRes({
|
|
24
24
|
session,
|
|
25
25
|
publicKey: {
|
|
26
26
|
rpId: 'passlock.dev',
|
|
@@ -44,13 +44,13 @@ export const credential: AuthenticationCredential = {
|
|
|
44
44
|
authenticatorAttachment: null,
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export const
|
|
47
|
+
export const rpcVerificationReq = new VerificationReq({ session, credential })
|
|
48
48
|
|
|
49
|
-
export const
|
|
49
|
+
export const rpcVerificationRes = new VerificationRes({ principal: Fixtures.principal })
|
|
50
50
|
|
|
51
|
-
export const
|
|
51
|
+
export const rpcIsExistingUserRes = new IsExistingUserRes({ existingUser: true })
|
|
52
52
|
|
|
53
|
-
export const
|
|
53
|
+
export const rpcVerifyEmailRes = new VerifyEmailRes({ principal: Fixtures.principal })
|
|
54
54
|
|
|
55
55
|
export const getCredentialTest = L.succeed(
|
|
56
56
|
GetCredential,
|
|
@@ -61,12 +61,12 @@ export const rpcClientTest = L.succeed(
|
|
|
61
61
|
RpcClient,
|
|
62
62
|
RpcClient.of({
|
|
63
63
|
preConnect: () => E.succeed(Fixtures.preConnectRes),
|
|
64
|
-
isExistingUser: () => E.succeed(
|
|
65
|
-
verifyEmail: () => E.succeed(
|
|
64
|
+
isExistingUser: () => E.succeed(rpcIsExistingUserRes),
|
|
65
|
+
verifyEmail: () => E.succeed(rpcVerifyEmailRes),
|
|
66
66
|
getRegistrationOptions: () => E.fail(Fixtures.notImplemented),
|
|
67
67
|
verifyRegistrationCredential: () => E.fail(Fixtures.notImplemented),
|
|
68
|
-
getAuthenticationOptions: () => E.succeed(
|
|
69
|
-
verifyAuthenticationCredential: () => E.succeed(
|
|
68
|
+
getAuthenticationOptions: () => E.succeed(rpcOptionsRes),
|
|
69
|
+
verifyAuthenticationCredential: () => E.succeed(rpcVerificationRes),
|
|
70
70
|
registerOidc: () => E.fail(Fixtures.notImplemented),
|
|
71
71
|
authenticateOidc: () => E.fail(Fixtures.notImplemented),
|
|
72
72
|
resendVerificationEmail: () => E.fail(Fixtures.notImplemented),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type RouterOps
|
|
1
|
+
import { RpcClient, type RouterOps } from '@passlock/shared/dist/rpc/rpc.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'
|
|
5
|
-
import { AuthenticateServiceLive, AuthenticationService, GetCredential } from './authenticate.js'
|
|
6
|
-
import * as Fixture from './authenticate.fixture.js'
|
|
7
5
|
import { StorageService } from '../storage/storage.js'
|
|
6
|
+
import * as Fixture from './authenticate.fixture.js'
|
|
7
|
+
import { AuthenticateServiceLive, AuthenticationService, GetCredential } from './authenticate.js'
|
|
8
8
|
|
|
9
9
|
describe('authenticate should', () => {
|
|
10
10
|
test('return a valid principal', async () => {
|
|
@@ -43,8 +43,8 @@ describe('authenticate should', () => {
|
|
|
43
43
|
E.sync(() => {
|
|
44
44
|
const rpcMock = mock<RouterOps>()
|
|
45
45
|
|
|
46
|
-
rpcMock.getAuthenticationOptions.mockReturnValue(E.succeed(Fixture.
|
|
47
|
-
rpcMock.verifyAuthenticationCredential.mockReturnValue(E.succeed(Fixture.
|
|
46
|
+
rpcMock.getAuthenticationOptions.mockReturnValue(E.succeed(Fixture.rpcOptionsRes))
|
|
47
|
+
rpcMock.verifyAuthenticationCredential.mockReturnValue(E.succeed(Fixture.rpcVerificationRes))
|
|
48
48
|
|
|
49
49
|
return rpcMock
|
|
50
50
|
}),
|
|
@@ -71,7 +71,7 @@ describe('authenticate should', () => {
|
|
|
71
71
|
|
|
72
72
|
const rpcClient = yield* _(RpcClient)
|
|
73
73
|
expect(rpcClient.getAuthenticationOptions).toHaveBeenCalledOnce()
|
|
74
|
-
expect(rpcClient.verifyAuthenticationCredential).toHaveBeenCalledWith(Fixture.
|
|
74
|
+
expect(rpcClient.verifyAuthenticationCredential).toHaveBeenCalledWith(Fixture.rpcVerificationReq)
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
const rpcClientTest = L.effect(
|
|
@@ -79,8 +79,8 @@ describe('authenticate should', () => {
|
|
|
79
79
|
E.sync(() => {
|
|
80
80
|
const rpcMock = mock<RouterOps>()
|
|
81
81
|
|
|
82
|
-
rpcMock.getAuthenticationOptions.mockReturnValue(E.succeed(Fixture.
|
|
83
|
-
rpcMock.verifyAuthenticationCredential.mockReturnValue(E.succeed(Fixture.
|
|
82
|
+
rpcMock.getAuthenticationOptions.mockReturnValue(E.succeed(Fixture.rpcOptionsRes))
|
|
83
|
+
rpcMock.verifyAuthenticationCredential.mockReturnValue(E.succeed(Fixture.rpcVerificationRes))
|
|
84
84
|
|
|
85
85
|
return rpcMock
|
|
86
86
|
}),
|
|
@@ -2,20 +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
13
|
import { OptionsReq, VerificationReq } from '@passlock/shared/dist/rpc/authentication.js'
|
|
14
14
|
import { RpcClient } from '@passlock/shared/dist/rpc/rpc.js'
|
|
15
15
|
import type {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
AuthenticationCredential,
|
|
17
|
+
Principal,
|
|
18
|
+
UserVerification,
|
|
19
19
|
} from '@passlock/shared/dist/schema/schema.js'
|
|
20
20
|
import { Context, Effect as E, Layer, flow, pipe } from 'effect'
|
|
21
21
|
import { Capabilities } from '../capabilities/capabilities.js'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Dispatcher,
|
|
1
|
+
import { Dispatcher, RpcClient, RpcConfig, type RouterOps } from '@passlock/shared/dist/rpc/rpc.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'
|
|
5
|
-
import { ConnectionService, ConnectionServiceLive } from './connection.js'
|
|
6
5
|
import * as Fixture from './connection.fixture.js'
|
|
6
|
+
import { ConnectionService, ConnectionServiceLive } from './connection.js'
|
|
7
7
|
|
|
8
8
|
describe('preConnect should', () => {
|
|
9
9
|
test('hit the rpc endpoint', async () => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hits the rpc endpoint to warm up a lambda
|
|
3
3
|
*/
|
|
4
|
-
import { PreConnectReq } from '@passlock/shared/dist/rpc/connection.js'
|
|
4
|
+
import { PreConnectReq } from '@passlock/shared/dist/rpc/connection.js';
|
|
5
5
|
import type { RpcConfig } from '@passlock/shared/dist/rpc/rpc.js';
|
|
6
|
-
import { Dispatcher, RpcClient } from '@passlock/shared/dist/rpc/rpc.js'
|
|
7
|
-
import { Context, Effect as E, Layer, flow, pipe } from 'effect'
|
|
6
|
+
import { Dispatcher, RpcClient } from '@passlock/shared/dist/rpc/rpc.js';
|
|
7
|
+
import { Context, Effect as E, Layer, flow, pipe } from 'effect';
|
|
8
8
|
|
|
9
9
|
/* Service */
|
|
10
10
|
|
package/src/effect.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { create, get as getCredential } from '@github/webauthn-json/browser-ponyfill'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
Duplicate,
|
|
5
|
+
InternalBrowserError,
|
|
6
|
+
type BadRequest,
|
|
7
|
+
type Disabled,
|
|
8
|
+
type Forbidden,
|
|
9
|
+
type NotFound,
|
|
10
|
+
type NotSupported,
|
|
11
|
+
type Unauthorized,
|
|
12
12
|
} from '@passlock/shared/dist/error/error.js'
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
DispatcherLive,
|
|
16
|
+
RetrySchedule,
|
|
17
|
+
RpcClientLive,
|
|
18
|
+
RpcConfig,
|
|
19
19
|
} from '@passlock/shared/dist/rpc/rpc.js'
|
|
20
20
|
|
|
21
21
|
import type { Principal } from '@passlock/shared/dist/schema/schema.js'
|
|
@@ -24,10 +24,10 @@ import { Context, Effect as E, Layer as L, Layer, Schedule, pipe } from 'effect'
|
|
|
24
24
|
import type { NoSuchElementException } from 'effect/Cause'
|
|
25
25
|
|
|
26
26
|
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
AuthenticateServiceLive,
|
|
28
|
+
AuthenticationService,
|
|
29
|
+
GetCredential,
|
|
30
|
+
type AuthenticationRequest,
|
|
31
31
|
} from './authentication/authenticate.js'
|
|
32
32
|
|
|
33
33
|
import { capabilitiesLive } from './capabilities/capabilities.js'
|
|
@@ -35,22 +35,22 @@ import { ConnectionService, ConnectionServiceLive } from './connection/connectio
|
|
|
35
35
|
import { EmailService, EmailServiceLive, URLQueryString, type VerifyRequest } from './email/email.js'
|
|
36
36
|
|
|
37
37
|
import {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
CreateCredential,
|
|
39
|
+
RegistrationService,
|
|
40
|
+
RegistrationServiceLive,
|
|
41
|
+
type RegistrationRequest,
|
|
42
42
|
} from './registration/register.js'
|
|
43
43
|
|
|
44
44
|
import {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
Storage,
|
|
46
|
+
StorageService,
|
|
47
|
+
StorageServiceLive,
|
|
48
|
+
type AuthType,
|
|
49
|
+
type StoredToken,
|
|
50
50
|
} from './storage/storage.js'
|
|
51
51
|
|
|
52
|
-
import { type Email, UserService, UserServiceLive } from './user/user.js'
|
|
53
52
|
import { SocialService, SocialServiceLive, type OidcRequest } from './social/social.js'
|
|
53
|
+
import { UserService, UserServiceLive, type Email } from './user/user.js'
|
|
54
54
|
|
|
55
55
|
/* Layers */
|
|
56
56
|
|
|
@@ -1,9 +1,9 @@
|
|
|
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 { Effect as E, Layer as L } from 'effect'
|
|
4
|
-
import { URLQueryString } from './email.js'
|
|
5
4
|
import { AuthenticationService } from '../authentication/authenticate.js'
|
|
6
5
|
import * as Fixtures from '../test/fixtures.js'
|
|
6
|
+
import { URLQueryString } from './email.js'
|
|
7
7
|
|
|
8
8
|
export const token = 'token'
|
|
9
9
|
export const code = 'code'
|
|
@@ -22,16 +22,16 @@ export const authenticationServiceTest = L.succeed(
|
|
|
22
22
|
}),
|
|
23
23
|
)
|
|
24
24
|
|
|
25
|
-
export const
|
|
25
|
+
export const rpcVerifyEmailReq = new VerifyEmailReq({ token, code })
|
|
26
26
|
|
|
27
|
-
export const
|
|
27
|
+
export const rpcVerifyEmailRes = new VerifyEmailRes({ principal: Fixtures.principal })
|
|
28
28
|
|
|
29
29
|
export const rpcClientTest = L.succeed(
|
|
30
30
|
RpcClient,
|
|
31
31
|
RpcClient.of({
|
|
32
32
|
preConnect: () => E.succeed({ warmed: true }),
|
|
33
33
|
isExistingUser: () => E.succeed({ existingUser: true }),
|
|
34
|
-
verifyEmail: () => E.succeed(
|
|
34
|
+
verifyEmail: () => E.succeed(rpcVerifyEmailRes),
|
|
35
35
|
getRegistrationOptions: () => E.fail(Fixtures.notImplemented),
|
|
36
36
|
verifyRegistrationCredential: () => E.fail(Fixtures.notImplemented),
|
|
37
37
|
getAuthenticationOptions: () => E.fail(Fixtures.notImplemented),
|
package/src/email/email.test.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { type RouterOps
|
|
1
|
+
import { RpcClient, type RouterOps } from '@passlock/shared/dist/rpc/rpc.js'
|
|
2
2
|
import { Effect as E, Layer as L, LogLevel, Logger, pipe } from 'effect'
|
|
3
3
|
import { NoSuchElementException } from 'effect/Cause'
|
|
4
4
|
import { describe, expect, test } from 'vitest'
|
|
5
5
|
import { mock } from 'vitest-mock-extended'
|
|
6
|
-
import { EmailService, EmailServiceLive } from './email.js'
|
|
7
|
-
import * as Fixture from './email.fixture.js'
|
|
8
6
|
import { AuthenticationService } from '../authentication/authenticate.js'
|
|
9
7
|
import { StorageService } from '../storage/storage.js'
|
|
8
|
+
import * as Fixture from './email.fixture.js'
|
|
9
|
+
import { EmailService, EmailServiceLive } from './email.js'
|
|
10
10
|
|
|
11
11
|
describe('verifyEmailCode should', () => {
|
|
12
12
|
test('return a principal when the verification is successful', async () => {
|
|
@@ -117,7 +117,7 @@ describe('verifyEmailCode should', () => {
|
|
|
117
117
|
yield* _(service.verifyEmailCode({ code: Fixture.code }))
|
|
118
118
|
|
|
119
119
|
const rpcClient = yield* _(RpcClient)
|
|
120
|
-
expect(rpcClient.verifyEmail).toHaveBeenCalledWith(Fixture.
|
|
120
|
+
expect(rpcClient.verifyEmail).toHaveBeenCalledWith(Fixture.rpcVerifyEmailReq)
|
|
121
121
|
})
|
|
122
122
|
|
|
123
123
|
const rpcClientTest = L.effect(
|
|
@@ -125,7 +125,7 @@ describe('verifyEmailCode should', () => {
|
|
|
125
125
|
E.sync(() => {
|
|
126
126
|
const rpcMock = mock<RouterOps>()
|
|
127
127
|
|
|
128
|
-
rpcMock.verifyEmail.mockReturnValue(E.succeed(Fixture.
|
|
128
|
+
rpcMock.verifyEmail.mockReturnValue(E.succeed(Fixture.rpcVerifyEmailRes))
|
|
129
129
|
|
|
130
130
|
return rpcMock
|
|
131
131
|
}),
|
|
@@ -155,7 +155,7 @@ describe('verifyEmailLink should', () => {
|
|
|
155
155
|
// LocationSearch return ?code=code
|
|
156
156
|
// and we expect rpcClient to be called with code
|
|
157
157
|
const rpcClient = yield* _(RpcClient)
|
|
158
|
-
expect(rpcClient.verifyEmail).toBeCalledWith(Fixture.
|
|
158
|
+
expect(rpcClient.verifyEmail).toBeCalledWith(Fixture.rpcVerifyEmailReq)
|
|
159
159
|
})
|
|
160
160
|
|
|
161
161
|
const rpcClientTest = L.effect(
|
|
@@ -163,7 +163,7 @@ describe('verifyEmailLink should', () => {
|
|
|
163
163
|
E.sync(() => {
|
|
164
164
|
const rpcMock = mock<RouterOps>()
|
|
165
165
|
|
|
166
|
-
rpcMock.verifyEmail.mockReturnValue(E.succeed(Fixture.
|
|
166
|
+
rpcMock.verifyEmail.mockReturnValue(E.succeed(Fixture.rpcVerifyEmailRes))
|
|
167
167
|
|
|
168
168
|
return rpcMock
|
|
169
169
|
}),
|
package/src/email/email.ts
CHANGED
|
@@ -5,10 +5,10 @@ import { BadRequest } from '@passlock/shared/dist/error/error.js'
|
|
|
5
5
|
import { RpcClient } from '@passlock/shared/dist/rpc/rpc.js'
|
|
6
6
|
import type { VerifyEmailErrors as RpcErrors } from '@passlock/shared/dist/rpc/user.js'
|
|
7
7
|
import { VerifyEmailReq } from '@passlock/shared/dist/rpc/user.js'
|
|
8
|
+
import type { Principal } from '@passlock/shared/dist/schema/schema.js'
|
|
8
9
|
import { Context, Effect as E, Layer, Option as O, flow, identity, pipe } from 'effect'
|
|
9
|
-
import { type AuthenticationErrors
|
|
10
|
+
import { AuthenticationService, type AuthenticationErrors } from '../authentication/authenticate.js'
|
|
10
11
|
import { StorageService } from '../storage/storage.js'
|
|
11
|
-
import type { Principal } from '@passlock/shared/dist/schema/schema.js'
|
|
12
12
|
|
|
13
13
|
/* Requests */
|
|
14
14
|
|
package/src/index.ts
CHANGED
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
BadRequest,
|
|
3
|
+
Disabled,
|
|
4
|
+
Duplicate,
|
|
5
|
+
Forbidden,
|
|
6
|
+
NotFound,
|
|
7
|
+
NotSupported,
|
|
8
|
+
Unauthorized,
|
|
9
9
|
} from '@passlock/shared/dist/error/error.js'
|
|
10
10
|
|
|
11
|
-
import type { Principal } from '@passlock/shared/dist/schema/schema.js'
|
|
12
11
|
import { ErrorCode } from '@passlock/shared/dist/error/error.js'
|
|
13
12
|
import { RpcConfig } from '@passlock/shared/dist/rpc/rpc.js'
|
|
13
|
+
import type { Principal } from '@passlock/shared/dist/schema/schema.js'
|
|
14
14
|
import { Effect as E, Layer as L, Layer, Option, Runtime, Scope, pipe } from 'effect'
|
|
15
|
-
import { type AuthenticationRequest
|
|
15
|
+
import { AuthenticationService, type AuthenticationRequest } from './authentication/authenticate.js'
|
|
16
16
|
import { Capabilities } from './capabilities/capabilities.js'
|
|
17
17
|
import { ConnectionService } from './connection/connection.js'
|
|
18
18
|
import { allRequirements } from './effect.js'
|
|
19
19
|
import { EmailService, type VerifyRequest } from './email/email.js'
|
|
20
|
-
import { type RegistrationRequest
|
|
21
|
-
import { type AuthType, Storage, StorageService, type StoredToken } from './storage/storage.js'
|
|
22
|
-
import { type Email, UserService, type ResendEmail } from './user/user.js'
|
|
20
|
+
import { RegistrationService, type RegistrationRequest } from './registration/register.js'
|
|
23
21
|
import { SocialService, type OidcRequest } from './social/social.js'
|
|
22
|
+
import { Storage, StorageService, type AuthType, type StoredToken } from './storage/storage.js'
|
|
23
|
+
import { UserService, type Email, type ResendEmail } from './user/user.js'
|
|
24
24
|
|
|
25
25
|
/* Exports */
|
|
26
26
|
|
|
27
27
|
export type Options = { signal?: AbortSignal }
|
|
28
|
-
export type {
|
|
29
|
-
export type { UserVerification, VerifyEmail } from '@passlock/shared/dist/schema/schema.js'
|
|
30
|
-
export type { RegistrationRequest } from './registration/register.js'
|
|
28
|
+
export type { Principal, UserVerification, VerifyEmail } from '@passlock/shared/dist/schema/schema.js'
|
|
31
29
|
export type { AuthenticationRequest } from './authentication/authenticate.js'
|
|
32
30
|
export type { VerifyRequest } from './email/email.js'
|
|
31
|
+
export type { RegistrationRequest } from './registration/register.js'
|
|
33
32
|
export type { AuthType, StoredToken } from './storage/storage.js'
|
|
34
|
-
export type {
|
|
33
|
+
export type { Email } from './user/user.js'
|
|
35
34
|
|
|
36
35
|
export { ErrorCode } from '@passlock/shared/dist/error/error.js'
|
|
37
36
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { PreConnectRes } from '@passlock/shared/dist/rpc/connection.js'
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
OptionsReq,
|
|
4
|
+
OptionsRes,
|
|
5
|
+
VerificationReq,
|
|
6
|
+
VerificationRes,
|
|
6
7
|
} from '@passlock/shared/dist/rpc/registration.js'
|
|
7
8
|
import { RpcClient } from '@passlock/shared/dist/rpc/rpc.js'
|
|
8
9
|
import type { RegistrationCredential } from '@passlock/shared/dist/schema/schema.js'
|
|
9
10
|
import { Effect as E, Layer as L } from 'effect'
|
|
10
|
-
import { CreateCredential, type RegistrationRequest } from './register.js'
|
|
11
11
|
import * as Fixtures from '../test/fixtures.js'
|
|
12
12
|
import { UserService } from '../user/user.js'
|
|
13
|
-
import {
|
|
13
|
+
import { CreateCredential, type RegistrationRequest } from './register.js'
|
|
14
14
|
|
|
15
15
|
export const session = 'session'
|
|
16
16
|
export const token = 'token'
|
|
@@ -24,7 +24,7 @@ export const registrationRequest: RegistrationRequest = {
|
|
|
24
24
|
familyName: 'doe',
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export const
|
|
27
|
+
export const rpcOptionsReq = new OptionsReq(registrationRequest)
|
|
28
28
|
|
|
29
29
|
export const registrationOptions: OptionsRes = {
|
|
30
30
|
session,
|
|
@@ -43,7 +43,7 @@ export const registrationOptions: OptionsRes = {
|
|
|
43
43
|
},
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export const
|
|
46
|
+
export const rpcOptionsRes = new OptionsRes(registrationOptions)
|
|
47
47
|
|
|
48
48
|
export const credential: RegistrationCredential = {
|
|
49
49
|
type: 'public-key',
|
|
@@ -57,9 +57,9 @@ export const credential: RegistrationCredential = {
|
|
|
57
57
|
clientExtensionResults: {},
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export const
|
|
60
|
+
export const rpcVerificationReq = new VerificationReq({ session, credential })
|
|
61
61
|
|
|
62
|
-
export const
|
|
62
|
+
export const rpcVerificationRes = new VerificationRes({ principal: Fixtures.principal })
|
|
63
63
|
|
|
64
64
|
export const createCredentialTest = L.succeed(
|
|
65
65
|
CreateCredential,
|
|
@@ -80,8 +80,8 @@ export const rpcClientTest = L.succeed(
|
|
|
80
80
|
preConnect: () => E.succeed(new PreConnectRes({ warmed: true })),
|
|
81
81
|
isExistingUser: () => E.fail(Fixtures.notImplemented),
|
|
82
82
|
verifyEmail: () => E.fail(Fixtures.notImplemented),
|
|
83
|
-
getRegistrationOptions: () => E.succeed(
|
|
84
|
-
verifyRegistrationCredential: () => E.succeed(
|
|
83
|
+
getRegistrationOptions: () => E.succeed(rpcOptionsRes),
|
|
84
|
+
verifyRegistrationCredential: () => E.succeed(rpcVerificationRes),
|
|
85
85
|
getAuthenticationOptions: () => E.fail(Fixtures.notImplemented),
|
|
86
86
|
verifyAuthenticationCredential: () => E.fail(Fixtures.notImplemented),
|
|
87
87
|
registerOidc: () => E.fail(Fixtures.notImplemented),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Duplicate, InternalBrowserError } from '@passlock/shared/dist/error/error.js'
|
|
2
|
-
import { type RouterOps
|
|
2
|
+
import { RpcClient, type RouterOps } from '@passlock/shared/dist/rpc/rpc.js'
|
|
3
3
|
import { Effect as E, Layer as L, Layer, LogLevel, Logger, pipe } from 'effect'
|
|
4
4
|
import { describe, expect, test, vi } from 'vitest'
|
|
5
5
|
import { mock } from 'vitest-mock-extended'
|
|
6
|
-
import { CreateCredential, RegistrationService, RegistrationServiceLive } from './register.js'
|
|
7
6
|
import * as Fixture from './register.fixture.js'
|
|
7
|
+
import { CreateCredential, RegistrationService, RegistrationServiceLive } from './register.js'
|
|
8
8
|
|
|
9
9
|
describe('register should', () => {
|
|
10
10
|
test('return a valid credential', async () => {
|
|
@@ -34,7 +34,7 @@ describe('register should', () => {
|
|
|
34
34
|
yield* _(service.registerPasskey(Fixture.registrationRequest))
|
|
35
35
|
|
|
36
36
|
const rpcClient = yield* _(RpcClient)
|
|
37
|
-
expect(rpcClient.getRegistrationOptions).toHaveBeenCalledWith(Fixture.
|
|
37
|
+
expect(rpcClient.getRegistrationOptions).toHaveBeenCalledWith(Fixture.rpcOptionsReq)
|
|
38
38
|
})
|
|
39
39
|
|
|
40
40
|
const rpcClientTest = L.effect(
|
|
@@ -42,8 +42,8 @@ describe('register should', () => {
|
|
|
42
42
|
E.sync(() => {
|
|
43
43
|
const rpcMock = mock<RouterOps>()
|
|
44
44
|
|
|
45
|
-
rpcMock.getRegistrationOptions.mockReturnValue(E.succeed(Fixture.
|
|
46
|
-
rpcMock.verifyRegistrationCredential.mockReturnValue(E.succeed(Fixture.
|
|
45
|
+
rpcMock.getRegistrationOptions.mockReturnValue(E.succeed(Fixture.rpcOptionsRes))
|
|
46
|
+
rpcMock.verifyRegistrationCredential.mockReturnValue(E.succeed(Fixture.rpcVerificationRes))
|
|
47
47
|
|
|
48
48
|
return rpcMock
|
|
49
49
|
}),
|
|
@@ -70,7 +70,7 @@ describe('register should', () => {
|
|
|
70
70
|
yield* _(service.registerPasskey(Fixture.registrationRequest))
|
|
71
71
|
|
|
72
72
|
const rpcClient = yield* _(RpcClient)
|
|
73
|
-
expect(rpcClient.verifyRegistrationCredential).toHaveBeenCalledWith(Fixture.
|
|
73
|
+
expect(rpcClient.verifyRegistrationCredential).toHaveBeenCalledWith(Fixture.rpcVerificationReq)
|
|
74
74
|
})
|
|
75
75
|
|
|
76
76
|
const rpcClientTest = L.effect(
|
|
@@ -78,8 +78,8 @@ describe('register should', () => {
|
|
|
78
78
|
E.sync(() => {
|
|
79
79
|
const rpcMock = mock<RouterOps>()
|
|
80
80
|
|
|
81
|
-
rpcMock.getRegistrationOptions.mockReturnValue(E.succeed(Fixture.
|
|
82
|
-
rpcMock.verifyRegistrationCredential.mockReturnValue(E.succeed(Fixture.
|
|
81
|
+
rpcMock.getRegistrationOptions.mockReturnValue(E.succeed(Fixture.rpcOptionsRes))
|
|
82
|
+
rpcMock.verifyRegistrationCredential.mockReturnValue(E.succeed(Fixture.rpcVerificationRes))
|
|
83
83
|
|
|
84
84
|
return rpcMock
|
|
85
85
|
}),
|