@passlock/client 0.9.21 → 0.9.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -0
- package/dist/authentication/authenticate.d.ts +15 -15
- package/dist/authentication/authenticate.fixture.d.ts +20 -6
- package/dist/authentication/authenticate.fixture.js +7 -5
- package/dist/authentication/authenticate.fixture.js.map +1 -1
- package/dist/authentication/authenticate.js +19 -8
- package/dist/authentication/authenticate.js.map +1 -1
- package/dist/capabilities/capabilities.d.ts +8 -4
- package/dist/capabilities/capabilities.js +10 -1
- package/dist/capabilities/capabilities.js.map +1 -1
- package/dist/connection/connection.d.ts +11 -7
- package/dist/connection/connection.fixture.d.ts +2 -2
- package/dist/connection/connection.fixture.js +2 -1
- package/dist/connection/connection.fixture.js.map +1 -1
- package/dist/connection/connection.js +12 -3
- package/dist/connection/connection.js.map +1 -1
- package/dist/effect.d.ts +22 -45
- package/dist/effect.js +55 -51
- package/dist/effect.js.map +1 -1
- package/dist/email/email.d.ts +38 -11
- package/dist/email/email.fixture.d.ts +19 -5
- package/dist/email/email.fixture.js +4 -3
- package/dist/email/email.fixture.js.map +1 -1
- package/dist/email/email.js +43 -7
- package/dist/email/email.js.map +1 -1
- package/dist/event/event.d.ts +3 -1
- package/dist/event/event.js +3 -0
- package/dist/event/event.js.map +1 -1
- package/dist/index.d.ts +105 -27
- package/dist/index.js +101 -50
- package/dist/index.js.map +1 -1
- package/dist/logging/eventLogger.d.ts +13 -1
- package/dist/logging/eventLogger.js +13 -0
- package/dist/logging/eventLogger.js.map +1 -1
- package/dist/registration/register.d.ts +18 -21
- package/dist/registration/register.fixture.d.ts +19 -5
- package/dist/registration/register.fixture.js +14 -7
- package/dist/registration/register.fixture.js.map +1 -1
- package/dist/registration/register.js +18 -9
- package/dist/registration/register.js.map +1 -1
- package/dist/rpc/authentication.d.ts +0 -1
- package/dist/rpc/authentication.js +1 -0
- package/dist/rpc/authentication.js.map +1 -1
- package/dist/rpc/client.d.ts +4 -1
- package/dist/rpc/client.js +12 -2
- package/dist/rpc/client.js.map +1 -1
- package/dist/rpc/config.d.ts +0 -1
- package/dist/rpc/connection.d.ts +0 -1
- package/dist/rpc/connection.js +1 -0
- package/dist/rpc/connection.js.map +1 -1
- package/dist/rpc/registration.d.ts +0 -1
- package/dist/rpc/registration.js +1 -0
- package/dist/rpc/registration.js.map +1 -1
- package/dist/rpc/social.d.ts +0 -1
- package/dist/rpc/social.js +1 -0
- package/dist/rpc/social.js.map +1 -1
- package/dist/rpc/user.d.ts +0 -1
- package/dist/rpc/user.js +1 -0
- package/dist/rpc/user.js.map +1 -1
- package/dist/social/social.d.ts +16 -23
- package/dist/social/social.fixture.d.ts +21 -9
- package/dist/social/social.fixture.js +8 -14
- package/dist/social/social.fixture.js.map +1 -1
- package/dist/social/social.js +14 -10
- package/dist/social/social.js.map +1 -1
- package/dist/storage/storage.d.ts +40 -12
- package/dist/storage/storage.fixture.d.ts +2 -2
- package/dist/storage/storage.fixture.js +2 -2
- package/dist/storage/storage.fixture.js.map +1 -1
- package/dist/storage/storage.js +48 -15
- package/dist/storage/storage.js.map +1 -1
- package/dist/test/fixtures.d.ts +1 -2
- package/dist/test/fixtures.js +20 -5
- package/dist/test/fixtures.js.map +1 -1
- package/dist/user/user.d.ts +8 -5
- package/dist/user/user.fixture.d.ts +2 -2
- package/dist/user/user.fixture.js +9 -5
- package/dist/user/user.fixture.js.map +1 -1
- package/dist/user/user.js +9 -3
- package/dist/user/user.js.map +1 -1
- package/dist/version.d.ts +1 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +39 -33
- package/src/authentication/authenticate.fixture.ts +8 -7
- package/src/authentication/authenticate.test.ts +59 -17
- package/src/authentication/authenticate.ts +34 -32
- package/src/capabilities/capabilities.ts +9 -8
- package/src/connection/connection.fixture.ts +2 -1
- package/src/connection/connection.test.ts +3 -3
- package/src/connection/connection.ts +9 -8
- package/src/effect.ts +129 -128
- package/src/email/email.fixture.ts +4 -3
- package/src/email/email.test.ts +4 -4
- package/src/email/email.ts +24 -16
- package/src/index.ts +225 -169
- package/src/logging/eventLogger.test.ts +1 -1
- package/src/logging/eventLogger.ts +2 -2
- package/src/registration/register.fixture.ts +14 -8
- package/src/registration/register.test.ts +13 -9
- package/src/registration/register.ts +37 -34
- package/src/rpc/authentication.ts +31 -0
- package/src/rpc/client.ts +173 -0
- package/src/rpc/config.ts +18 -0
- package/src/rpc/connection.ts +24 -0
- package/src/rpc/registration.ts +31 -0
- package/src/rpc/social.ts +36 -0
- package/src/rpc/user.ts +42 -0
- package/src/social/social.fixture.ts +10 -18
- package/src/social/social.test.ts +13 -29
- package/src/social/social.ts +20 -47
- package/src/storage/storage.fixture.ts +3 -4
- package/src/storage/storage.test.ts +28 -19
- package/src/storage/storage.ts +36 -36
- package/src/test/fixtures.ts +21 -6
- package/src/user/user.fixture.ts +17 -7
- package/src/user/user.test.ts +2 -5
- package/src/user/user.ts +13 -9
- package/src/version.ts +1 -0
- package/dist/authentication/authenticate.d.ts.map +0 -1
- package/dist/authentication/authenticate.fixture.d.ts.map +0 -1
- package/dist/authentication/authenticate.test.d.ts +0 -2
- package/dist/authentication/authenticate.test.d.ts.map +0 -1
- package/dist/authentication/authenticate.test.js +0 -111
- package/dist/authentication/authenticate.test.js.map +0 -1
- package/dist/capabilities/capabilities.d.ts.map +0 -1
- package/dist/config.d.ts +0 -18
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -20
- package/dist/config.js.map +0 -1
- package/dist/connection/connection.d.ts.map +0 -1
- package/dist/connection/connection.fixture.d.ts.map +0 -1
- package/dist/connection/connection.test.d.ts +0 -2
- package/dist/connection/connection.test.d.ts.map +0 -1
- package/dist/connection/connection.test.js +0 -36
- package/dist/connection/connection.test.js.map +0 -1
- package/dist/effect.d.ts.map +0 -1
- package/dist/email/email.d.ts.map +0 -1
- package/dist/email/email.fixture.d.ts.map +0 -1
- package/dist/email/email.test.d.ts +0 -2
- package/dist/email/email.test.d.ts.map +0 -1
- package/dist/email/email.test.js +0 -99
- package/dist/email/email.test.js.map +0 -1
- package/dist/event/event.d.ts.map +0 -1
- package/dist/event/event.node.test.d.ts +0 -2
- package/dist/event/event.node.test.d.ts.map +0 -1
- package/dist/event/event.node.test.js +0 -13
- package/dist/event/event.node.test.js.map +0 -1
- package/dist/event/event.test.d.ts +0 -2
- package/dist/event/event.test.d.ts.map +0 -1
- package/dist/event/event.test.js +0 -30
- package/dist/event/event.test.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/logging/eventLogger.d.ts.map +0 -1
- package/dist/logging/eventLogger.test.d.ts +0 -2
- package/dist/logging/eventLogger.test.d.ts.map +0 -1
- package/dist/logging/eventLogger.test.js +0 -67
- package/dist/logging/eventLogger.test.js.map +0 -1
- package/dist/registration/register.d.ts.map +0 -1
- package/dist/registration/register.fixture.d.ts.map +0 -1
- package/dist/registration/register.test.d.ts +0 -2
- package/dist/registration/register.test.d.ts.map +0 -1
- package/dist/registration/register.test.js +0 -104
- package/dist/registration/register.test.js.map +0 -1
- package/dist/rpc/authentication.d.ts.map +0 -1
- package/dist/rpc/client.d.ts.map +0 -1
- package/dist/rpc/config.d.ts.map +0 -1
- package/dist/rpc/connection.d.ts.map +0 -1
- package/dist/rpc/registration.d.ts.map +0 -1
- package/dist/rpc/social.d.ts.map +0 -1
- package/dist/rpc/user.d.ts.map +0 -1
- package/dist/social/social.d.ts.map +0 -1
- package/dist/social/social.fixture.d.ts.map +0 -1
- package/dist/social/social.test.d.ts +0 -2
- package/dist/social/social.test.d.ts.map +0 -1
- package/dist/social/social.test.js +0 -110
- package/dist/social/social.test.js.map +0 -1
- package/dist/storage/storage.d.ts.map +0 -1
- package/dist/storage/storage.fixture.d.ts.map +0 -1
- package/dist/storage/storage.test.d.ts +0 -2
- package/dist/storage/storage.test.d.ts.map +0 -1
- package/dist/storage/storage.test.js +0 -120
- package/dist/storage/storage.test.js.map +0 -1
- package/dist/test/fixtures.d.ts.map +0 -1
- package/dist/user/user.d.ts.map +0 -1
- package/dist/user/user.fixture.d.ts.map +0 -1
- package/dist/user/user.test.d.ts +0 -2
- package/dist/user/user.test.d.ts.map +0 -1
- package/dist/user/user.test.js +0 -56
- package/dist/user/user.test.js.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/src/config.ts +0 -42
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper around local storage that allows us to store
|
|
3
|
+
* authentication tokens in local storage for a short period.
|
|
4
|
+
*/
|
|
1
5
|
import type { Principal } from '@passlock/shared/dist/schema/principal.js';
|
|
2
6
|
import { Context, Effect as E, Layer, Option as O } from 'effect';
|
|
3
7
|
import type { NoSuchElementException } from 'effect/Cause';
|
|
@@ -5,24 +9,48 @@ export type AuthType = 'email' | 'passkey' | 'apple' | 'google';
|
|
|
5
9
|
export type StoredToken = {
|
|
6
10
|
token: string;
|
|
7
11
|
authType: AuthType;
|
|
8
|
-
|
|
12
|
+
expiry: number;
|
|
9
13
|
};
|
|
10
|
-
|
|
14
|
+
declare const StorageService_base: Context.TagClass<StorageService, "@services/StorageService", {
|
|
11
15
|
storeToken: (principal: Principal) => E.Effect<void>;
|
|
12
16
|
getToken: (authType: AuthType) => E.Effect<StoredToken, NoSuchElementException>;
|
|
13
17
|
clearToken: (authType: AuthType) => E.Effect<void>;
|
|
14
18
|
clearExpiredToken: (authType: AuthType) => E.Effect<void>;
|
|
15
19
|
clearExpiredTokens: E.Effect<void>;
|
|
16
|
-
}
|
|
17
|
-
export declare
|
|
18
|
-
|
|
20
|
+
}>;
|
|
21
|
+
export declare class StorageService extends StorageService_base {
|
|
22
|
+
}
|
|
23
|
+
declare const BrowserStorage_base: Context.TagClass<BrowserStorage, "@services/Storage", Storage>;
|
|
24
|
+
export declare class BrowserStorage extends BrowserStorage_base {
|
|
25
|
+
}
|
|
19
26
|
export declare const buildKey: (authType: AuthType) => string;
|
|
20
27
|
export declare const compressToken: (principal: Principal) => string;
|
|
21
28
|
export declare const expandToken: (authType: AuthType) => (s: string) => O.Option<StoredToken>;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export declare const
|
|
28
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Store compressed token in local storage
|
|
31
|
+
* @param principal
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
export declare const storeToken: (principal: Principal) => E.Effect<void, never, BrowserStorage>;
|
|
35
|
+
/**
|
|
36
|
+
* Get stored token from local storage
|
|
37
|
+
* @param authenticator
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
export declare const getToken: (authenticator: AuthType) => E.Effect<StoredToken, NoSuchElementException, BrowserStorage>;
|
|
41
|
+
/**
|
|
42
|
+
* Remove token from local storage
|
|
43
|
+
* @param authType
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
export declare const clearToken: (authType: AuthType) => E.Effect<void, never, BrowserStorage>;
|
|
47
|
+
/**
|
|
48
|
+
* Only clear if now > token.expireAt
|
|
49
|
+
* @param authType
|
|
50
|
+
* @param defer
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
export declare const clearExpiredToken: (authType: AuthType) => E.Effect<void, never, BrowserStorage>;
|
|
54
|
+
export declare const clearExpiredTokens: E.Effect<void, never, BrowserStorage>;
|
|
55
|
+
export declare const StorageServiceLive: Layer.Layer<StorageService, never, BrowserStorage>;
|
|
56
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Layer } from 'effect';
|
|
2
|
-
|
|
2
|
+
import { BrowserStorage } from './storage.js';
|
|
3
|
+
export declare const testLayers: (storage?: Layer.Layer<BrowserStorage>) => Layer.Layer<import("./storage.js").StorageService | BrowserStorage, never, never>;
|
|
3
4
|
export { principal } from '../test/fixtures.js';
|
|
4
|
-
//# sourceMappingURL=storage.fixture.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect as E, Layer, pipe } from 'effect';
|
|
2
2
|
import { mock } from 'vitest-mock-extended';
|
|
3
|
-
import {
|
|
4
|
-
const storageTest = Layer.effect(
|
|
3
|
+
import { BrowserStorage, StorageServiceLive } from './storage.js';
|
|
4
|
+
const storageTest = Layer.effect(BrowserStorage, E.sync(() => mock()));
|
|
5
5
|
export const testLayers = (storage = storageTest) => {
|
|
6
6
|
const storageService = pipe(StorageServiceLive, Layer.provide(storage));
|
|
7
7
|
return Layer.merge(storage, storageService);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.fixture.js","sourceRoot":"","sources":["../../src/storage/storage.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"storage.fixture.js","sourceRoot":"","sources":["../../src/storage/storage.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjE,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAC9B,cAAc,EACd,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,EAAW,CAAC,CAC9B,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAuC,WAAW,EAAE,EAAE;IAC/E,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;IACvE,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;AAC7C,CAAC,CAAA;AAED,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/storage/storage.js
CHANGED
|
@@ -1,55 +1,85 @@
|
|
|
1
1
|
import { Context, Effect as E, Layer, Option as O, flow, pipe } from 'effect';
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
/* Service */
|
|
3
|
+
export class StorageService extends Context.Tag('@services/StorageService')() {
|
|
4
|
+
}
|
|
5
|
+
export class BrowserStorage extends Context.Tag('@services/Storage')() {
|
|
6
|
+
}
|
|
4
7
|
export const buildKey = (authType) => `passlock:${authType}:token`;
|
|
8
|
+
// principal => token:expireAt
|
|
5
9
|
export const compressToken = (principal) => {
|
|
6
|
-
const expireAt = principal.
|
|
7
|
-
const token = principal.
|
|
8
|
-
return `${token}:${expireAt}`;
|
|
10
|
+
const expireAt = principal.exp.getTime();
|
|
11
|
+
const token = principal.jti;
|
|
12
|
+
return `${token}:${expireAt.toFixed(0)}`;
|
|
9
13
|
};
|
|
14
|
+
// token:expireAt => { authType, token, expireAt }
|
|
10
15
|
export const expandToken = (authType) => (s) => {
|
|
11
16
|
const tokens = s.split(':');
|
|
12
17
|
if (tokens.length !== 2)
|
|
13
18
|
return O.none();
|
|
14
19
|
const [token, expireAtString] = tokens;
|
|
20
|
+
if (token === undefined || expireAtString === undefined)
|
|
21
|
+
return O.none();
|
|
15
22
|
const parse = O.liftThrowable(Number.parseInt);
|
|
16
23
|
const expireAt = parse(expireAtString);
|
|
17
|
-
return O.map(expireAt,
|
|
24
|
+
return O.map(expireAt, expiry => ({ authType, token, expiry }));
|
|
18
25
|
};
|
|
26
|
+
/* Effects */
|
|
27
|
+
/**
|
|
28
|
+
* Store compressed token in local storage
|
|
29
|
+
* @param principal
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
19
32
|
export const storeToken = (principal) => {
|
|
20
33
|
return E.gen(function* (_) {
|
|
21
|
-
const localStorage = yield* _(
|
|
34
|
+
const localStorage = yield* _(BrowserStorage);
|
|
22
35
|
const storeEffect = E.try(() => {
|
|
23
36
|
const compressed = compressToken(principal);
|
|
24
|
-
const key = buildKey(principal.
|
|
37
|
+
const key = buildKey(principal.authType);
|
|
25
38
|
localStorage.setItem(key, compressed);
|
|
26
|
-
}).pipe(E.orElse(() => E.void));
|
|
39
|
+
}).pipe(E.orElse(() => E.void)); // We dont care if it fails
|
|
27
40
|
return yield* _(storeEffect);
|
|
28
41
|
});
|
|
29
42
|
};
|
|
30
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Get stored token from local storage
|
|
45
|
+
* @param authenticator
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
export const getToken = (authenticator) => {
|
|
31
49
|
return E.gen(function* (_) {
|
|
32
|
-
const localStorage = yield* _(
|
|
33
|
-
const getEffect = pipe(O.some(buildKey(
|
|
50
|
+
const localStorage = yield* _(BrowserStorage);
|
|
51
|
+
const getEffect = pipe(O.some(buildKey(authenticator)), O.flatMap(key => pipe(localStorage.getItem(key), O.fromNullable)), O.flatMap(expandToken(authenticator)), O.filter(({ expiry }) => expiry > Date.now()));
|
|
34
52
|
return yield* _(getEffect);
|
|
35
53
|
});
|
|
36
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Remove token from local storage
|
|
57
|
+
* @param authType
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
37
60
|
export const clearToken = (authType) => {
|
|
38
61
|
return E.gen(function* (_) {
|
|
39
|
-
const localStorage = yield* _(
|
|
62
|
+
const localStorage = yield* _(BrowserStorage);
|
|
40
63
|
localStorage.removeItem(buildKey(authType));
|
|
41
64
|
});
|
|
42
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* Only clear if now > token.expireAt
|
|
68
|
+
* @param authType
|
|
69
|
+
* @param defer
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
43
72
|
export const clearExpiredToken = (authType) => {
|
|
44
73
|
const key = buildKey(authType);
|
|
45
74
|
const effect = E.gen(function* (_) {
|
|
46
|
-
const storage = yield* _(
|
|
75
|
+
const storage = yield* _(BrowserStorage);
|
|
47
76
|
const item = yield* _(O.fromNullable(storage.getItem(key)));
|
|
48
77
|
const token = yield* _(expandToken(authType)(item));
|
|
49
|
-
if (token.
|
|
78
|
+
if (token.expiry < Date.now()) {
|
|
50
79
|
storage.removeItem(key);
|
|
51
80
|
}
|
|
52
81
|
});
|
|
82
|
+
// we don't care if it fails
|
|
53
83
|
return pipe(effect, E.match({
|
|
54
84
|
onSuccess: () => E.void,
|
|
55
85
|
onFailure: () => E.void,
|
|
@@ -61,6 +91,8 @@ export const clearExpiredTokens = E.all([
|
|
|
61
91
|
clearExpiredToken('google'),
|
|
62
92
|
clearExpiredToken('apple'),
|
|
63
93
|
]);
|
|
94
|
+
/* Live */
|
|
95
|
+
/* v8 ignore start */
|
|
64
96
|
export const StorageServiceLive = Layer.effect(StorageService, E.gen(function* (_) {
|
|
65
97
|
const context = yield* _(E.context());
|
|
66
98
|
return {
|
|
@@ -71,4 +103,5 @@ export const StorageServiceLive = Layer.effect(StorageService, E.gen(function* (
|
|
|
71
103
|
clearExpiredTokens: pipe(clearExpiredTokens, E.provide(context)),
|
|
72
104
|
};
|
|
73
105
|
}));
|
|
106
|
+
/* v8 ignore stop */
|
|
74
107
|
//# sourceMappingURL=storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/storage/storage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/storage/storage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,E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package/dist/test/fixtures.d.ts
CHANGED
|
@@ -7,10 +7,9 @@ export declare const session = "session";
|
|
|
7
7
|
export declare const token = "token";
|
|
8
8
|
export declare const code = "code";
|
|
9
9
|
export declare const authType = "passkey";
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const expiry: number;
|
|
11
11
|
export declare const principal: Principal;
|
|
12
12
|
export declare const capabilitiesTest: L.Layer<Capabilities, never, never>;
|
|
13
13
|
export declare const storedToken: StoredToken;
|
|
14
14
|
export declare const storageServiceTest: L.Layer<StorageService, never, never>;
|
|
15
15
|
export declare const notImplemented: BadRequest;
|
|
16
|
-
//# sourceMappingURL=fixtures.d.ts.map
|
package/dist/test/fixtures.js
CHANGED
|
@@ -6,15 +6,30 @@ export const session = 'session';
|
|
|
6
6
|
export const token = 'token';
|
|
7
7
|
export const code = 'code';
|
|
8
8
|
export const authType = 'passkey';
|
|
9
|
-
export const
|
|
9
|
+
export const expiry = Date.now() + 10000;
|
|
10
10
|
export const principal = {
|
|
11
|
+
jti: 'token',
|
|
11
12
|
token: 'token',
|
|
13
|
+
sub: 'user-1',
|
|
14
|
+
iss: 'idp.passlock.dev',
|
|
15
|
+
aud: 'tenancy_id',
|
|
16
|
+
iat: new Date(),
|
|
17
|
+
nbf: new Date(),
|
|
18
|
+
exp: new Date(Date.now() + 5 * 60 * 1000),
|
|
19
|
+
email: 'john.doe@gmail.com',
|
|
20
|
+
givenName: 'john',
|
|
21
|
+
familyName: 'doe',
|
|
22
|
+
emailVerified: false,
|
|
23
|
+
authType: 'passkey',
|
|
24
|
+
authId: 'auth-1',
|
|
25
|
+
userVerified: true,
|
|
26
|
+
// legacy
|
|
12
27
|
user: {
|
|
13
|
-
id: '1',
|
|
14
|
-
email: 'john.doe@gmail.com',
|
|
28
|
+
id: 'user-1',
|
|
15
29
|
givenName: 'john',
|
|
16
30
|
familyName: 'doe',
|
|
17
|
-
|
|
31
|
+
email: 'john.doe@gmail.com',
|
|
32
|
+
emailVerified: false
|
|
18
33
|
},
|
|
19
34
|
authStatement: {
|
|
20
35
|
authType: 'passkey',
|
|
@@ -29,7 +44,7 @@ export const capabilitiesTest = L.succeed(Capabilities, Capabilities.of({
|
|
|
29
44
|
autofillSupport: E.void,
|
|
30
45
|
isAutofillSupport: E.succeed(true),
|
|
31
46
|
}));
|
|
32
|
-
export const storedToken = { token, authType,
|
|
47
|
+
export const storedToken = { token, authType, expiry };
|
|
33
48
|
export const storageServiceTest = L.succeed(StorageService, StorageService.of({
|
|
34
49
|
storeToken: () => E.void,
|
|
35
50
|
getToken: () => E.succeed(storedToken),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../src/test/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAA;AAEjE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAoB,MAAM,uBAAuB,CAAA;AAExE,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,
|
|
1
|
+
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../src/test/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAA;AAEjE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAoB,MAAM,uBAAuB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c,EAAE,CAAC,CAAC,IAAI;IACtB,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;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,MAAM,EAAE,CAAA;AAEnE,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,7 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check for an existing user
|
|
3
|
+
*/
|
|
1
4
|
import type { BadRequest, Disabled, NotFound } from '@passlock/shared/dist/error/error.js';
|
|
2
|
-
import { UserClient } from '@passlock/shared/dist/rpc/user.js';
|
|
3
5
|
import type { VerifyEmail } from '@passlock/shared/dist/schema/email.js';
|
|
4
6
|
import { Context, Effect as E, Layer } from 'effect';
|
|
7
|
+
import { UserClient } from '../rpc/user.js';
|
|
5
8
|
export type Email = {
|
|
6
9
|
email: string;
|
|
7
10
|
};
|
|
@@ -9,14 +12,14 @@ export type ResendEmail = VerifyEmail & {
|
|
|
9
12
|
userId: string;
|
|
10
13
|
};
|
|
11
14
|
export type ResendEmailErrors = BadRequest | NotFound | Disabled;
|
|
12
|
-
|
|
15
|
+
declare const UserService_base: Context.TagClass<UserService, "@services/UserService", {
|
|
13
16
|
isExistingUser: (request: Email) => E.Effect<boolean, BadRequest>;
|
|
14
17
|
resendVerificationEmail: (request: ResendEmail) => E.Effect<void, ResendEmailErrors>;
|
|
15
|
-
}
|
|
16
|
-
export declare
|
|
18
|
+
}>;
|
|
19
|
+
export declare class UserService extends UserService_base {
|
|
20
|
+
}
|
|
17
21
|
type Dependencies = UserClient;
|
|
18
22
|
export declare const isExistingUser: (request: Email) => E.Effect<boolean, BadRequest, Dependencies>;
|
|
19
23
|
export declare const resendVerificationEmail: (request: ResendEmail) => E.Effect<void, ResendEmailErrors, Dependencies>;
|
|
20
24
|
export declare const UserServiceLive: Layer.Layer<UserService, never, UserClient>;
|
|
21
25
|
export {};
|
|
22
|
-
//# sourceMappingURL=user.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IsExistingUserReq, IsExistingUserRes, ResendEmailReq, ResendEmailRes,
|
|
1
|
+
import { IsExistingUserReq, IsExistingUserRes, ResendEmailReq, ResendEmailRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
|
|
2
2
|
import { Layer as L } from 'effect';
|
|
3
|
+
import { UserClient } from '../rpc/user.js';
|
|
3
4
|
import type { ResendEmail } from './user.js';
|
|
4
5
|
export declare const email = "jdoe@gmail.com";
|
|
5
6
|
export declare const isRegisteredReq: IsExistingUserReq;
|
|
@@ -9,4 +10,3 @@ export declare const resendEmailReq: ResendEmail;
|
|
|
9
10
|
export declare const rpcResendEmailReq: ResendEmailReq;
|
|
10
11
|
export declare const rpcResendEmailRes: ResendEmailRes;
|
|
11
12
|
export declare const rpcClientTest: L.Layer<UserClient, never, never>;
|
|
12
|
-
//# sourceMappingURL=user.fixture.d.ts.map
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import { IsExistingUserReq, IsExistingUserRes, ResendEmailReq, ResendEmailRes,
|
|
2
|
-
import { Effect as E, Layer as L } from 'effect';
|
|
1
|
+
import { IsExistingUserReq, IsExistingUserRes, ResendEmailReq, ResendEmailRes, VerifyEmailRes, } from '@passlock/shared/dist/rpc/user.js';
|
|
2
|
+
import { Effect as E, Layer as L, Option as O } from 'effect';
|
|
3
|
+
import { UserClient } from '../rpc/user.js';
|
|
3
4
|
import * as Fixtures from '../test/fixtures.js';
|
|
4
5
|
export const email = 'jdoe@gmail.com';
|
|
5
6
|
export const isRegisteredReq = new IsExistingUserReq({ email });
|
|
6
|
-
export const isRegisteredRes = new IsExistingUserRes({ existingUser: false });
|
|
7
|
+
export const isRegisteredRes = new IsExistingUserRes({ existingUser: false, detail: O.none() });
|
|
7
8
|
export const verifyEmailRes = new VerifyEmailRes({ principal: Fixtures.principal });
|
|
8
9
|
export const resendEmailReq = { userId: '123', method: 'code' };
|
|
9
|
-
export const rpcResendEmailReq = new ResendEmailReq({
|
|
10
|
+
export const rpcResendEmailReq = new ResendEmailReq({
|
|
11
|
+
userId: '123',
|
|
12
|
+
verifyEmail: { method: 'code' },
|
|
13
|
+
});
|
|
10
14
|
export const rpcResendEmailRes = new ResendEmailRes({});
|
|
11
15
|
export const rpcClientTest = L.succeed(UserClient, UserClient.of({
|
|
12
|
-
isExistingUser: () => E.succeed({ existingUser: true }),
|
|
16
|
+
isExistingUser: () => E.succeed({ existingUser: true, detail: O.none() }),
|
|
13
17
|
verifyEmail: () => E.succeed(verifyEmailRes),
|
|
14
18
|
resendVerificationEmail: () => E.fail(Fixtures.notImplemented),
|
|
15
19
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.fixture.js","sourceRoot":"","sources":["../../src/user/user.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"user.fixture.js","sourceRoot":"","sources":["../../src/user/user.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,i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;IACzE,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,6 +1,9 @@
|
|
|
1
|
-
import { IsExistingUserReq, ResendEmailReq
|
|
1
|
+
import { IsExistingUserReq, ResendEmailReq } from '@passlock/shared/dist/rpc/user.js';
|
|
2
2
|
import { Context, Effect as E, Layer, flow } from 'effect';
|
|
3
|
-
|
|
3
|
+
import { UserClient } from '../rpc/user.js';
|
|
4
|
+
/* Service */
|
|
5
|
+
export class UserService extends Context.Tag('@services/UserService')() {
|
|
6
|
+
}
|
|
4
7
|
export const isExistingUser = (request) => {
|
|
5
8
|
return E.gen(function* (_) {
|
|
6
9
|
yield* _(E.logInfo('Checking registration status'));
|
|
@@ -19,11 +22,14 @@ export const resendVerificationEmail = (request) => {
|
|
|
19
22
|
yield* _(rpcClient.resendVerificationEmail(new ResendEmailReq({ userId, verifyEmail })));
|
|
20
23
|
});
|
|
21
24
|
};
|
|
25
|
+
/* Live */
|
|
26
|
+
/* v8 ignore start */
|
|
22
27
|
export const UserServiceLive = Layer.effect(UserService, E.gen(function* (_) {
|
|
23
28
|
const context = yield* _(E.context());
|
|
24
29
|
return UserService.of({
|
|
25
30
|
isExistingUser: flow(isExistingUser, E.provide(context)),
|
|
26
|
-
resendVerificationEmail: flow(resendVerificationEmail, E.provide(context))
|
|
31
|
+
resendVerificationEmail: flow(resendVerificationEmail, E.provide(context)),
|
|
27
32
|
});
|
|
28
33
|
}));
|
|
34
|
+
/* v8 ignore stop */
|
|
29
35
|
//# sourceMappingURL=user.js.map
|
package/dist/user/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/user/user.ts"],"names":[],"mappings":"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,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;QAEtC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAA;QAC1C,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAA;QAC1C,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,uBAAuB,CAAC,IAAI,cAAc,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAA;IAC1F,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,UAAU;AAEV,qBAAqB;AACrB,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CACzC,WAAW,EACX,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;IAChB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAc,CAAC,CAAA;IACjD,OAAO,WAAW,CAAC,EAAE,CAAC;QACpB,cAAc,EAAE,IAAI,CAAC,cAAc,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;AACD,oBAAoB"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
//# sourceMappingURL=version.d.ts.map
|
|
1
|
+
export declare const PASSLOCK_CLIENT_VERSION = "0.9.23";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const PASSLOCK_CLIENT_VERSION = '0.9.23';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,YAAY,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@passlock/client",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.9.23",
|
|
4
|
+
"description": "Passkey authentication and social login for web apps (Typescript). Framework agnostic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"passkey",
|
|
7
7
|
"passkeys",
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
"google one tap",
|
|
10
10
|
"sign in with google",
|
|
11
11
|
"sign in with apple",
|
|
12
|
+
"svelte",
|
|
13
|
+
"sveltekit",
|
|
12
14
|
"react",
|
|
13
15
|
"next",
|
|
14
16
|
"vue",
|
|
@@ -20,65 +22,69 @@
|
|
|
20
22
|
},
|
|
21
23
|
"license": "MIT",
|
|
22
24
|
"homepage": "https://passlock.dev",
|
|
23
|
-
"repository":
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/passlock-dev/ts-clients.git"
|
|
28
|
+
},
|
|
24
29
|
"bugs": {
|
|
25
|
-
"url": "https://github.com/passlock-dev/
|
|
30
|
+
"url": "https://github.com/passlock-dev/ts-clients/issues",
|
|
26
31
|
"email": "team@passlock.dev"
|
|
27
32
|
},
|
|
28
33
|
"type": "module",
|
|
29
34
|
"exports": {
|
|
30
35
|
".": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
},
|
|
34
|
-
"./effect": {
|
|
35
|
-
"import": "./dist/effect.js",
|
|
36
|
-
"types": "./dist/effect.d.ts"
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.js"
|
|
37
38
|
}
|
|
38
39
|
},
|
|
39
40
|
"files": [
|
|
40
41
|
"src",
|
|
41
|
-
"dist"
|
|
42
|
+
"dist",
|
|
43
|
+
"!dist/**/*.test.*",
|
|
44
|
+
"!dist/**/*.spec.*"
|
|
42
45
|
],
|
|
43
46
|
"dependencies": {
|
|
47
|
+
"@effect/schema": "0.70.4",
|
|
44
48
|
"@github/webauthn-json": "^2.1.1",
|
|
45
|
-
"effect": "
|
|
46
|
-
"@passlock/shared": "0.9.
|
|
49
|
+
"effect": "3.6.3",
|
|
50
|
+
"@passlock/shared": "0.9.23"
|
|
47
51
|
},
|
|
48
52
|
"devDependencies": {
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"@
|
|
55
|
-
"eslint": "^8.
|
|
53
|
+
"@qetza/replacetokens": "^1.7.0",
|
|
54
|
+
"@total-typescript/tsconfig": "^1.0.4",
|
|
55
|
+
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
|
56
|
+
"@tsconfig/node20": "^20.1.4",
|
|
57
|
+
"@types/node": "^22.2.0",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^8.0.1",
|
|
59
|
+
"@typescript-eslint/parser": "^8.0.1",
|
|
60
|
+
"@vitest/coverage-v8": "^2.0.5",
|
|
61
|
+
"@vitest/ui": "^2.0.5",
|
|
62
|
+
"eslint": "^9.9.0",
|
|
56
63
|
"eslint-config-prettier": "^9.1.0",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"rimraf": "^5.0.8",
|
|
64
|
+
"jsdom": "^24.1.1",
|
|
65
|
+
"prettier": "^3.3.3",
|
|
66
|
+
"publint": "^0.2.9",
|
|
67
|
+
"rimraf": "^6.0.1",
|
|
62
68
|
"tslib": "^2.6.3",
|
|
63
|
-
"typescript": "^5.5.
|
|
64
|
-
"vite": "^5.
|
|
65
|
-
"vitest": "^2.0.
|
|
66
|
-
"vitest-mock-extended": "^
|
|
69
|
+
"typescript": "^5.5.4",
|
|
70
|
+
"vite": "^5.4.0",
|
|
71
|
+
"vitest": "^2.0.5",
|
|
72
|
+
"vitest-mock-extended": "^2.0.0"
|
|
67
73
|
},
|
|
68
74
|
"scripts": {
|
|
69
|
-
"clean": "
|
|
75
|
+
"clean": "rimraf ./dist",
|
|
70
76
|
"typecheck": "tsc --noEmit",
|
|
71
77
|
"test": "vitest run",
|
|
72
78
|
"test:watch": "vitest dev",
|
|
73
79
|
"test:ui": "vitest --coverage.enabled=true --ui",
|
|
74
80
|
"test:coverage": "vitest run --coverage",
|
|
75
|
-
"
|
|
81
|
+
"replaceTokens": "LATEST=${npm_package_version} replacetokens --sources ./dist/version.* --log-level error --missing-var-action keep --use-env > /dev/null",
|
|
82
|
+
"build": "tsc --build && pnpm run replaceTokens && publint",
|
|
76
83
|
"build:clean": "pnpm run clean && pnpm run build",
|
|
77
84
|
"build:watch": "tsc --build --watch",
|
|
78
85
|
"format": "prettier --write \"src/**/*.+(js|ts|json)\"",
|
|
79
86
|
"lint": "eslint --ext .ts src",
|
|
80
87
|
"lint:fix": "pnpm run lint --fix",
|
|
81
|
-
"
|
|
82
|
-
"ncu:save": "ncu --peer -x @effect/* -x effect -u"
|
|
88
|
+
"upgrade:deps": "ncu --peer -x effect -x @effect/* -u"
|
|
83
89
|
}
|
|
84
90
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AuthenticationClient,
|
|
3
2
|
OptionsRes,
|
|
4
3
|
VerificationReq,
|
|
5
4
|
VerificationRes,
|
|
6
5
|
} from '@passlock/shared/dist/rpc/authentication.js'
|
|
7
6
|
import { IsExistingUserRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js'
|
|
8
7
|
import type { AuthenticationCredential } from '@passlock/shared/dist/schema/passkey.js'
|
|
9
|
-
import { Effect as E, Layer as L } from 'effect'
|
|
8
|
+
import { Effect as E, Layer as L, Option as O } from 'effect'
|
|
9
|
+
import { AuthenticationClient } from '../rpc/authentication.js'
|
|
10
10
|
import * as Fixtures from '../test/fixtures.js'
|
|
11
|
-
import {
|
|
11
|
+
import { type AuthenticationRequest, GetCredential } from './authenticate.js'
|
|
12
12
|
|
|
13
13
|
export const session = 'session'
|
|
14
14
|
export const token = 'token'
|
|
@@ -17,7 +17,8 @@ export const authType = 'passkey'
|
|
|
17
17
|
export const expireAt = Date.now() + 10000
|
|
18
18
|
|
|
19
19
|
export const request: AuthenticationRequest = {
|
|
20
|
-
userVerification: 'preferred',
|
|
20
|
+
userVerification: O.some('preferred'),
|
|
21
|
+
email: O.none(),
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export const rpcOptionsRes = new OptionsRes({
|
|
@@ -48,13 +49,13 @@ export const rpcVerificationReq = new VerificationReq({ session, credential })
|
|
|
48
49
|
|
|
49
50
|
export const rpcVerificationRes = new VerificationRes({ principal: Fixtures.principal })
|
|
50
51
|
|
|
51
|
-
export const rpcIsExistingUserRes = new IsExistingUserRes({ existingUser: true })
|
|
52
|
+
export const rpcIsExistingUserRes = new IsExistingUserRes({ existingUser: true, detail: O.none() })
|
|
52
53
|
|
|
53
54
|
export const rpcVerifyEmailRes = new VerifyEmailRes({ principal: Fixtures.principal })
|
|
54
55
|
|
|
55
56
|
export const getCredentialTest = L.succeed(
|
|
56
57
|
GetCredential,
|
|
57
|
-
GetCredential.of(() => E.succeed(credential)),
|
|
58
|
+
GetCredential.of({ getCredential: () => E.succeed(credential) }),
|
|
58
59
|
)
|
|
59
60
|
|
|
60
61
|
export const rpcClientTest = L.succeed(
|
|
@@ -62,7 +63,7 @@ export const rpcClientTest = L.succeed(
|
|
|
62
63
|
AuthenticationClient.of({
|
|
63
64
|
getAuthenticationOptions: () => E.succeed(rpcOptionsRes),
|
|
64
65
|
verifyAuthenticationCredential: () => E.succeed(rpcVerificationRes),
|
|
65
|
-
})
|
|
66
|
+
}),
|
|
66
67
|
)
|
|
67
68
|
|
|
68
69
|
export const principal = Fixtures.principal
|