@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,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Effect as E, Layer as L, Layer, LogLevel, Logger, pipe } from 'effect'
|
|
1
|
+
import { Effect as E, Layer as L, Layer, LogLevel, Logger, Option as O, pipe } from 'effect'
|
|
3
2
|
import { describe, expect, test, vi } from 'vitest'
|
|
4
3
|
import { mock } from 'vitest-mock-extended'
|
|
4
|
+
import { AuthenticationClient } from '../rpc/authentication.js'
|
|
5
5
|
import { StorageService } from '../storage/storage.js'
|
|
6
6
|
import * as Fixture from './authenticate.fixture.js'
|
|
7
7
|
import { AuthenticateServiceLive, AuthenticationService, GetCredential } from './authenticate.js'
|
|
@@ -10,7 +10,13 @@ describe('authenticate should', () => {
|
|
|
10
10
|
test('return a valid principal', async () => {
|
|
11
11
|
const assertions = E.gen(function* (_) {
|
|
12
12
|
const service = yield* _(AuthenticationService)
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
const result = yield* _(
|
|
15
|
+
service.authenticatePasskey({
|
|
16
|
+
email: O.none(),
|
|
17
|
+
userVerification: O.some('preferred'),
|
|
18
|
+
}),
|
|
19
|
+
)
|
|
14
20
|
|
|
15
21
|
expect(result).toEqual(Fixture.principal)
|
|
16
22
|
})
|
|
@@ -31,7 +37,13 @@ describe('authenticate should', () => {
|
|
|
31
37
|
test('pass the authentication request to the backend', async () => {
|
|
32
38
|
const assertions = E.gen(function* (_) {
|
|
33
39
|
const service = yield* _(AuthenticationService)
|
|
34
|
-
|
|
40
|
+
|
|
41
|
+
yield* _(
|
|
42
|
+
service.authenticatePasskey({
|
|
43
|
+
email: O.none(),
|
|
44
|
+
userVerification: O.some('preferred'),
|
|
45
|
+
}),
|
|
46
|
+
)
|
|
35
47
|
|
|
36
48
|
const rpcClient = yield* _(AuthenticationClient)
|
|
37
49
|
expect(rpcClient.getAuthenticationOptions).toHaveBeenCalledOnce()
|
|
@@ -44,7 +56,9 @@ describe('authenticate should', () => {
|
|
|
44
56
|
const rpcMock = mock<AuthenticationClient['Type']>()
|
|
45
57
|
|
|
46
58
|
rpcMock.getAuthenticationOptions.mockReturnValue(E.succeed(Fixture.rpcOptionsRes))
|
|
47
|
-
rpcMock.verifyAuthenticationCredential.mockReturnValue(
|
|
59
|
+
rpcMock.verifyAuthenticationCredential.mockReturnValue(
|
|
60
|
+
E.succeed(Fixture.rpcVerificationRes),
|
|
61
|
+
)
|
|
48
62
|
|
|
49
63
|
return rpcMock
|
|
50
64
|
}),
|
|
@@ -67,11 +81,19 @@ describe('authenticate should', () => {
|
|
|
67
81
|
test('send the credential to the backend', async () => {
|
|
68
82
|
const assertions = E.gen(function* (_) {
|
|
69
83
|
const service = yield* _(AuthenticationService)
|
|
70
|
-
|
|
84
|
+
|
|
85
|
+
yield* _(
|
|
86
|
+
service.authenticatePasskey({
|
|
87
|
+
email: O.none(),
|
|
88
|
+
userVerification: O.some('preferred'),
|
|
89
|
+
}),
|
|
90
|
+
)
|
|
71
91
|
|
|
72
92
|
const rpcClient = yield* _(AuthenticationClient)
|
|
73
93
|
expect(rpcClient.getAuthenticationOptions).toHaveBeenCalledOnce()
|
|
74
|
-
expect(rpcClient.verifyAuthenticationCredential).toHaveBeenCalledWith(
|
|
94
|
+
expect(rpcClient.verifyAuthenticationCredential).toHaveBeenCalledWith(
|
|
95
|
+
Fixture.rpcVerificationReq,
|
|
96
|
+
)
|
|
75
97
|
})
|
|
76
98
|
|
|
77
99
|
const rpcClientTest = L.effect(
|
|
@@ -80,7 +102,9 @@ describe('authenticate should', () => {
|
|
|
80
102
|
const rpcMock = mock<AuthenticationClient['Type']>()
|
|
81
103
|
|
|
82
104
|
rpcMock.getAuthenticationOptions.mockReturnValue(E.succeed(Fixture.rpcOptionsRes))
|
|
83
|
-
rpcMock.verifyAuthenticationCredential.mockReturnValue(
|
|
105
|
+
rpcMock.verifyAuthenticationCredential.mockReturnValue(
|
|
106
|
+
E.succeed(Fixture.rpcVerificationRes),
|
|
107
|
+
)
|
|
84
108
|
|
|
85
109
|
return rpcMock
|
|
86
110
|
}),
|
|
@@ -103,7 +127,13 @@ describe('authenticate should', () => {
|
|
|
103
127
|
test('store the credential in local storage', async () => {
|
|
104
128
|
const assertions = E.gen(function* (_) {
|
|
105
129
|
const service = yield* _(AuthenticationService)
|
|
106
|
-
|
|
130
|
+
|
|
131
|
+
yield* _(
|
|
132
|
+
service.authenticatePasskey({
|
|
133
|
+
email: O.none(),
|
|
134
|
+
userVerification: O.some('preferred'),
|
|
135
|
+
}),
|
|
136
|
+
)
|
|
107
137
|
|
|
108
138
|
const storageService = yield* _(StorageService)
|
|
109
139
|
expect(storageService.storeToken).toHaveBeenCalledWith(Fixture.principal)
|
|
@@ -112,7 +142,7 @@ describe('authenticate should', () => {
|
|
|
112
142
|
const storageServiceTest = L.effect(
|
|
113
143
|
StorageService,
|
|
114
144
|
E.sync(() => {
|
|
115
|
-
const storageMock = mock<StorageService>()
|
|
145
|
+
const storageMock = mock<StorageService['Type']>()
|
|
116
146
|
|
|
117
147
|
storageMock.storeToken.mockReturnValue(E.void)
|
|
118
148
|
storageMock.clearExpiredToken.mockReturnValue(E.void)
|
|
@@ -138,7 +168,13 @@ describe('authenticate should', () => {
|
|
|
138
168
|
test('schedule deletion of the local token', async () => {
|
|
139
169
|
const assertions = E.gen(function* (_) {
|
|
140
170
|
const service = yield* _(AuthenticationService)
|
|
141
|
-
|
|
171
|
+
|
|
172
|
+
yield* _(
|
|
173
|
+
service.authenticatePasskey({
|
|
174
|
+
email: O.none(),
|
|
175
|
+
userVerification: O.some('preferred'),
|
|
176
|
+
}),
|
|
177
|
+
)
|
|
142
178
|
|
|
143
179
|
const storageService = yield* _(StorageService)
|
|
144
180
|
expect(storageService.clearExpiredToken).toHaveBeenCalledWith('passkey')
|
|
@@ -147,7 +183,7 @@ describe('authenticate should', () => {
|
|
|
147
183
|
const storageServiceTest = L.effect(
|
|
148
184
|
StorageService,
|
|
149
185
|
E.sync(() => {
|
|
150
|
-
const storageMock = mock<StorageService>()
|
|
186
|
+
const storageMock = mock<StorageService['Type']>()
|
|
151
187
|
|
|
152
188
|
storageMock.storeToken.mockReturnValue(E.void)
|
|
153
189
|
storageMock.clearExpiredToken.mockReturnValue(E.void)
|
|
@@ -173,20 +209,26 @@ describe('authenticate should', () => {
|
|
|
173
209
|
test("return an error if the browser can't create a credential", async () => {
|
|
174
210
|
const assertions = E.gen(function* (_) {
|
|
175
211
|
const service = yield* _(AuthenticationService)
|
|
176
|
-
yield* _(service.authenticatePasskey({ userVerification: 'preferred' }))
|
|
177
212
|
|
|
178
|
-
|
|
213
|
+
yield* _(
|
|
214
|
+
service.authenticatePasskey({
|
|
215
|
+
email: O.none(),
|
|
216
|
+
userVerification: O.some('preferred'),
|
|
217
|
+
}),
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
const { getCredential } = yield* _(GetCredential)
|
|
179
221
|
expect(getCredential).toHaveBeenCalledOnce()
|
|
180
222
|
})
|
|
181
223
|
|
|
182
224
|
const getCredentialTest = L.effect(
|
|
183
225
|
GetCredential,
|
|
184
226
|
E.sync(() => {
|
|
185
|
-
const
|
|
227
|
+
const getCredential = vi.fn()
|
|
186
228
|
|
|
187
|
-
|
|
229
|
+
getCredential.mockReturnValue(E.succeed(Fixture.credential))
|
|
188
230
|
|
|
189
|
-
return
|
|
231
|
+
return { getCredential }
|
|
190
232
|
}),
|
|
191
233
|
)
|
|
192
234
|
|
|
@@ -2,52 +2,51 @@
|
|
|
2
2
|
* Passkey authentication effects
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
-
parseRequestOptionsFromJSON,
|
|
6
5
|
type CredentialRequestOptionsJSON,
|
|
6
|
+
parseRequestOptionsFromJSON,
|
|
7
7
|
} from '@github/webauthn-json/browser-ponyfill'
|
|
8
|
+
import { InternalBrowserError, type NotSupported } from '@passlock/shared/dist/error/error.js'
|
|
8
9
|
import {
|
|
9
|
-
|
|
10
|
-
type
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import type {
|
|
15
|
-
|
|
16
|
-
UserVerification,
|
|
17
|
-
} from '@passlock/shared/dist/schema/passkey.js'
|
|
18
|
-
import { Principal } from '@passlock/shared/dist/schema/principal.js'
|
|
10
|
+
type OptionsErrors,
|
|
11
|
+
type OptionsReq,
|
|
12
|
+
type VerificationErrors,
|
|
13
|
+
VerificationReq,
|
|
14
|
+
} from '@passlock/shared/dist/rpc/authentication.js'
|
|
15
|
+
import type { AuthenticationCredential } from '@passlock/shared/dist/schema/passkey.js'
|
|
16
|
+
import type { Principal } from '@passlock/shared/dist/schema/principal.js'
|
|
19
17
|
import { Context, Effect as E, Layer, flow, pipe } from 'effect'
|
|
20
18
|
import { Capabilities } from '../capabilities/capabilities.js'
|
|
19
|
+
import { AuthenticationClient } from '../rpc/authentication.js'
|
|
21
20
|
import { StorageService } from '../storage/storage.js'
|
|
22
21
|
|
|
23
22
|
/* Requests */
|
|
24
23
|
|
|
25
|
-
export type AuthenticationRequest =
|
|
26
|
-
email?: string,
|
|
27
|
-
userVerification?: UserVerification
|
|
28
|
-
}
|
|
29
|
-
|
|
24
|
+
export type AuthenticationRequest = OptionsReq
|
|
30
25
|
/* Errors */
|
|
31
26
|
|
|
32
27
|
export type AuthenticationErrors = NotSupported | OptionsErrors | VerificationErrors
|
|
33
28
|
|
|
34
29
|
/* Dependencies */
|
|
35
30
|
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
export class GetCredential extends Context.Tag('@services/GetCredential')<
|
|
32
|
+
GetCredential,
|
|
33
|
+
{
|
|
34
|
+
getCredential: (
|
|
35
|
+
request: CredentialRequestOptions,
|
|
36
|
+
) => E.Effect<AuthenticationCredential, InternalBrowserError>
|
|
37
|
+
}
|
|
38
|
+
>() {}
|
|
41
39
|
|
|
42
40
|
/* Service */
|
|
43
41
|
|
|
44
|
-
export
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
export class AuthenticationService extends Context.Tag('@services/AuthenticationService')<
|
|
43
|
+
AuthenticationService,
|
|
44
|
+
{
|
|
45
|
+
authenticatePasskey: (
|
|
46
|
+
request: AuthenticationRequest,
|
|
47
|
+
) => E.Effect<Principal, AuthenticationErrors>
|
|
48
|
+
}
|
|
49
|
+
>() {}
|
|
51
50
|
|
|
52
51
|
/* Utilities */
|
|
53
52
|
|
|
@@ -102,11 +101,12 @@ export const authenticatePasskey = (
|
|
|
102
101
|
yield* _(capabilities.passkeySupport)
|
|
103
102
|
|
|
104
103
|
yield* _(E.logInfo('Fetching authentication options from Passlock'))
|
|
105
|
-
|
|
104
|
+
|
|
105
|
+
const { options, session } = yield* _(fetchOptions(request))
|
|
106
106
|
|
|
107
107
|
yield* _(E.logInfo('Looking up credential'))
|
|
108
|
-
const
|
|
109
|
-
const credential = yield* _(
|
|
108
|
+
const { getCredential } = yield* _(GetCredential)
|
|
109
|
+
const credential = yield* _(getCredential(options))
|
|
110
110
|
|
|
111
111
|
yield* _(E.logInfo('Verifying credential with Passlock'))
|
|
112
112
|
const principal = yield* _(verifyCredential(new VerificationReq({ credential, session })))
|
|
@@ -135,7 +135,9 @@ export const authenticatePasskey = (
|
|
|
135
135
|
export const AuthenticateServiceLive = Layer.effect(
|
|
136
136
|
AuthenticationService,
|
|
137
137
|
E.gen(function* (_) {
|
|
138
|
-
const context = yield* _(
|
|
138
|
+
const context = yield* _(
|
|
139
|
+
E.context<GetCredential | AuthenticationClient | Capabilities | StorageService>(),
|
|
140
|
+
)
|
|
139
141
|
|
|
140
142
|
return AuthenticationService.of({
|
|
141
143
|
authenticatePasskey: flow(authenticatePasskey, E.provide(context)),
|
|
@@ -6,14 +6,15 @@ import { Context, Effect as E, Layer, identity, pipe } from 'effect'
|
|
|
6
6
|
|
|
7
7
|
/* Service */
|
|
8
8
|
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
export class Capabilities extends Context.Tag('@services/Capabilities')<
|
|
10
|
+
Capabilities,
|
|
11
|
+
{
|
|
12
|
+
passkeySupport: E.Effect<void, NotSupported>
|
|
13
|
+
isPasskeySupport: E.Effect<boolean>
|
|
14
|
+
autofillSupport: E.Effect<void, NotSupported>
|
|
15
|
+
isAutofillSupport: E.Effect<boolean>
|
|
16
|
+
}
|
|
17
|
+
>() {}
|
|
17
18
|
|
|
18
19
|
/* Effects */
|
|
19
20
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConnectRes } from '@passlock/shared/dist/rpc/connection.js'
|
|
2
2
|
import { Effect as E, Layer as L } from 'effect'
|
|
3
|
+
import { ConnectionClient } from '../rpc/connection.js'
|
|
3
4
|
|
|
4
5
|
export const preConnectRes = new ConnectRes({ warmed: true })
|
|
5
6
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { RpcConfig } from '@passlock/shared/dist/rpc/config.js'
|
|
2
|
-
import { ConnectionClient } from '@passlock/shared/dist/rpc/connection.js'
|
|
3
|
-
import { Dispatcher } from '@passlock/shared/dist/rpc/dispatcher.js'
|
|
4
1
|
import { Effect as E, Layer as L, Layer, LogLevel, Logger, pipe } from 'effect'
|
|
5
2
|
import { describe, expect, test } from 'vitest'
|
|
6
3
|
import { mock } from 'vitest-mock-extended'
|
|
4
|
+
import { Dispatcher } from '../rpc/client.js'
|
|
5
|
+
import { RpcConfig } from '../rpc/config.js'
|
|
6
|
+
import { ConnectionClient } from '../rpc/connection.js'
|
|
7
7
|
import * as Fixture from './connection.fixture.js'
|
|
8
8
|
import { ConnectionService, ConnectionServiceLive } from './connection.js'
|
|
9
9
|
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hits the rpc endpoint to warm up a lambda
|
|
3
3
|
*/
|
|
4
|
-
import type { RpcConfig } from '@passlock/shared/dist/rpc/config.js'
|
|
5
|
-
import { ConnectionClient } from '@passlock/shared/dist/rpc/connection.js'
|
|
6
|
-
import { Dispatcher } from '@passlock/shared/dist/rpc/dispatcher.js'
|
|
7
4
|
import { Context, Effect as E, Layer, flow, pipe } from 'effect'
|
|
5
|
+
import { Dispatcher } from '../rpc/client.js'
|
|
6
|
+
import type { RpcConfig } from '../rpc/config.js'
|
|
7
|
+
import { ConnectionClient } from '../rpc/connection.js'
|
|
8
8
|
|
|
9
9
|
/* Service */
|
|
10
10
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
export class ConnectionService extends Context.Tag('@services/ConnectionService')<
|
|
12
|
+
ConnectionService,
|
|
13
|
+
{
|
|
14
|
+
preConnect: () => E.Effect<void>
|
|
15
|
+
}
|
|
16
|
+
>() {}
|
|
16
17
|
|
|
17
18
|
/* Effects */
|
|
18
19
|
|