@passlock/client 0.9.0 → 0.9.2
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 +83 -11
- package/dist/authentication/authenticate.d.ts.map +1 -1
- package/dist/authentication/authenticate.fixture.d.ts +1 -1
- package/dist/authentication/authenticate.fixture.d.ts.map +1 -1
- package/dist/authentication/authenticate.fixture.js.map +1 -1
- package/dist/authentication/authenticate.js +1 -8
- package/dist/authentication/authenticate.js.map +1 -1
- package/dist/authentication/authenticate.test.js.map +1 -1
- package/dist/capabilities/capabilities.d.ts +0 -3
- package/dist/capabilities/capabilities.d.ts.map +1 -1
- package/dist/capabilities/capabilities.js +0 -7
- package/dist/capabilities/capabilities.js.map +1 -1
- package/dist/config.d.ts +0 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/connection/connection.d.ts +4 -3
- package/dist/connection/connection.d.ts.map +1 -1
- package/dist/connection/connection.fixture.d.ts.map +1 -1
- package/dist/connection/connection.fixture.js +2 -1
- package/dist/connection/connection.fixture.js.map +1 -1
- package/dist/connection/connection.js +2 -9
- package/dist/connection/connection.js.map +1 -1
- package/dist/connection/connection.test.js +9 -9
- package/dist/connection/connection.test.js.map +1 -1
- package/dist/effect.js +4 -5
- package/dist/effect.js.map +1 -1
- package/dist/email/email.d.ts +0 -13
- package/dist/email/email.d.ts.map +1 -1
- package/dist/email/email.fixture.d.ts +1 -1
- package/dist/email/email.fixture.d.ts.map +1 -1
- package/dist/email/email.fixture.js.map +1 -1
- package/dist/email/email.js +1 -31
- package/dist/email/email.js.map +1 -1
- package/dist/email/email.test.js +0 -2
- package/dist/email/email.test.js.map +1 -1
- package/dist/event/event.d.ts +0 -3
- package/dist/event/event.d.ts.map +1 -1
- package/dist/event/event.js +0 -3
- package/dist/event/event.js.map +1 -1
- package/dist/event/event.node.test.js +0 -1
- package/dist/event/event.node.test.js.map +1 -1
- package/dist/event/event.test.js.map +1 -1
- package/dist/index.d.ts +24 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -19
- package/dist/index.js.map +1 -1
- package/dist/logging/eventLogger.d.ts +0 -13
- package/dist/logging/eventLogger.d.ts.map +1 -1
- package/dist/logging/eventLogger.js +0 -13
- package/dist/logging/eventLogger.js.map +1 -1
- package/dist/logging/eventLogger.test.js +0 -7
- package/dist/logging/eventLogger.test.js.map +1 -1
- package/dist/registration/register.d.ts.map +1 -1
- package/dist/registration/register.fixture.d.ts +1 -1
- package/dist/registration/register.fixture.d.ts.map +1 -1
- package/dist/registration/register.fixture.js.map +1 -1
- package/dist/registration/register.js +1 -8
- package/dist/registration/register.js.map +1 -1
- package/dist/registration/register.test.js.map +1 -1
- package/dist/storage/storage.d.ts +0 -25
- package/dist/storage/storage.d.ts.map +1 -1
- package/dist/storage/storage.fixture.js +0 -1
- package/dist/storage/storage.fixture.js.map +1 -1
- package/dist/storage/storage.js +1 -31
- package/dist/storage/storage.js.map +1 -1
- package/dist/storage/storage.test.js +0 -2
- package/dist/storage/storage.test.js.map +1 -1
- package/dist/test/fixtures.d.ts.map +1 -1
- package/dist/test/fixtures.js.map +1 -1
- package/dist/user/user.d.ts +0 -3
- package/dist/user/user.d.ts.map +1 -1
- package/dist/user/user.fixture.d.ts.map +1 -1
- package/dist/user/user.fixture.js.map +1 -1
- package/dist/user/user.js +0 -3
- package/dist/user/user.js.map +1 -1
- package/dist/user/user.test.js.map +1 -1
- package/package.json +12 -18
- package/src/authentication/authenticate.fixture.ts +0 -1
- package/src/authentication/authenticate.test.ts +0 -1
- package/src/authentication/authenticate.ts +4 -8
- package/src/config.ts +0 -1
- package/src/connection/connection.fixture.ts +4 -5
- package/src/connection/connection.test.ts +14 -18
- package/src/connection/connection.ts +8 -10
- package/src/effect.ts +6 -6
- package/src/email/email.fixture.ts +0 -2
- package/src/email/email.test.ts +0 -1
- package/src/email/email.ts +1 -2
- package/src/event/event.test.ts +0 -1
- package/src/event/event.ts +0 -1
- package/src/index.ts +54 -42
- package/src/registration/register.fixture.ts +0 -1
- package/src/registration/register.test.ts +0 -1
- package/src/registration/register.ts +3 -8
- package/src/test/fixtures.ts +0 -1
- package/src/user/user.fixture.ts +0 -1
- package/src/user/user.test.ts +0 -1
- package/src/user/user.ts +0 -1
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Hits the rpc endpoint to warm up a lambda
|
|
3
3
|
*/
|
|
4
4
|
import { PreConnectReq } from '@passlock/shared/dist/rpc/connection'
|
|
5
|
-
import {
|
|
5
|
+
import type { RpcConfig } from '@passlock/shared/dist/rpc/rpc';
|
|
6
|
+
import { Dispatcher, RpcClient } from '@passlock/shared/dist/rpc/rpc'
|
|
6
7
|
import { Context, Effect as E, Layer, flow, pipe } from 'effect'
|
|
7
8
|
|
|
8
9
|
/* Service */
|
|
@@ -17,23 +18,20 @@ export const ConnectionService = Context.GenericTag<ConnectionService>('@service
|
|
|
17
18
|
|
|
18
19
|
const hitPrincipal = pipe(
|
|
19
20
|
E.logInfo('Pre-connecting to Principal endpoint'),
|
|
20
|
-
E.zipRight(
|
|
21
|
-
E.flatMap(
|
|
21
|
+
E.zipRight(Dispatcher),
|
|
22
|
+
E.flatMap(dispatcher => dispatcher.get('/token/token?warm=true')),
|
|
22
23
|
E.asUnit,
|
|
23
|
-
E.catchAll(() => E.unit)
|
|
24
|
+
E.catchAll(() => E.unit),
|
|
24
25
|
)
|
|
25
26
|
|
|
26
27
|
const hitRpc = pipe(
|
|
27
28
|
E.logInfo('Pre-connecting to RPC endpoint'),
|
|
28
29
|
E.zipRight(RpcClient),
|
|
29
30
|
E.flatMap(rpcClient => rpcClient.preConnect(new PreConnectReq({}))),
|
|
30
|
-
E.asUnit
|
|
31
|
+
E.asUnit,
|
|
31
32
|
)
|
|
32
33
|
|
|
33
|
-
export const preConnect = () => pipe(
|
|
34
|
-
E.all([hitPrincipal, hitRpc], { concurrency: 2 }),
|
|
35
|
-
E.asUnit
|
|
36
|
-
)
|
|
34
|
+
export const preConnect = () => pipe(E.all([hitPrincipal, hitRpc], { concurrency: 2 }), E.asUnit)
|
|
37
35
|
|
|
38
36
|
/* Live */
|
|
39
37
|
|
|
@@ -41,7 +39,7 @@ export const preConnect = () => pipe(
|
|
|
41
39
|
export const ConnectionServiceLive = Layer.effect(
|
|
42
40
|
ConnectionService,
|
|
43
41
|
E.gen(function* (_) {
|
|
44
|
-
const context = yield* _(E.context<RpcClient |
|
|
42
|
+
const context = yield* _(E.context<RpcClient | Dispatcher | RpcConfig>())
|
|
45
43
|
|
|
46
44
|
return ConnectionService.of({
|
|
47
45
|
preConnect: flow(preConnect, E.provide(context)),
|
package/src/effect.ts
CHANGED
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
} from '@passlock/shared/dist/error/error'
|
|
26
26
|
|
|
27
27
|
import {
|
|
28
|
-
|
|
28
|
+
DispatcherLive,
|
|
29
29
|
RetrySchedule,
|
|
30
30
|
RpcClientLive,
|
|
31
31
|
RpcConfig,
|
|
@@ -110,9 +110,9 @@ const schedule = Schedule.intersect(Schedule.recurs(3), Schedule.exponential('10
|
|
|
110
110
|
|
|
111
111
|
const retryScheduleLive = L.succeed(RetrySchedule, RetrySchedule.of({ schedule }))
|
|
112
112
|
|
|
113
|
-
const
|
|
113
|
+
const dispatcherLive = pipe(DispatcherLive, L.provide(retryScheduleLive))
|
|
114
114
|
|
|
115
|
-
const rpcClientLive = pipe(RpcClientLive, L.provide(
|
|
115
|
+
const rpcClientLive = pipe(RpcClientLive, L.provide(dispatcherLive))
|
|
116
116
|
|
|
117
117
|
const storageServiceLive = StorageServiceLive
|
|
118
118
|
|
|
@@ -136,9 +136,9 @@ const authenticationServiceLive = pipe(
|
|
|
136
136
|
)
|
|
137
137
|
|
|
138
138
|
const connectionServiceLive = pipe(
|
|
139
|
-
ConnectionServiceLive,
|
|
140
|
-
L.provide(rpcClientLive),
|
|
141
|
-
L.provide(
|
|
139
|
+
ConnectionServiceLive,
|
|
140
|
+
L.provide(rpcClientLive),
|
|
141
|
+
L.provide(dispatcherLive),
|
|
142
142
|
)
|
|
143
143
|
|
|
144
144
|
const locationSearchLive = Layer.succeed(
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { BadRequest } from '@passlock/shared/dist/error/error'
|
|
3
2
|
import { RpcClient } from '@passlock/shared/dist/rpc/rpc'
|
|
4
3
|
import { VerifyEmailReq, VerifyEmailRes } from '@passlock/shared/dist/rpc/user'
|
|
@@ -7,7 +6,6 @@ import { LocationSearch } from './email'
|
|
|
7
6
|
import { AuthenticationService } from '../authentication/authenticate'
|
|
8
7
|
import * as Fixtures from '../test/fixtures'
|
|
9
8
|
|
|
10
|
-
|
|
11
9
|
export const token = 'token'
|
|
12
10
|
export const code = 'code'
|
|
13
11
|
export const authType = 'passkey'
|
package/src/email/email.test.ts
CHANGED
|
@@ -8,7 +8,6 @@ import * as Fixture from './email.fixture'
|
|
|
8
8
|
import { AuthenticationService } from '../authentication/authenticate'
|
|
9
9
|
import { StorageService } from '../storage/storage'
|
|
10
10
|
|
|
11
|
-
|
|
12
11
|
describe('verifyEmailCode should', () => {
|
|
13
12
|
test('return true when the verification is successful', async () => {
|
|
14
13
|
const assertions = E.gen(function* (_) {
|
package/src/email/email.ts
CHANGED
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { BadRequest } from '@passlock/shared/dist/error/error'
|
|
5
5
|
import { RpcClient } from '@passlock/shared/dist/rpc/rpc'
|
|
6
|
-
import type { VerifyEmailErrors as RpcErrors} from '@passlock/shared/dist/rpc/user'
|
|
6
|
+
import type { VerifyEmailErrors as RpcErrors } from '@passlock/shared/dist/rpc/user'
|
|
7
7
|
import { VerifyEmailReq } from '@passlock/shared/dist/rpc/user'
|
|
8
8
|
import { Context, Effect as E, Layer, Option as O, flow, identity, pipe } from 'effect'
|
|
9
9
|
import { type AuthenticationErrors, AuthenticationService } from '../authentication/authenticate'
|
|
10
10
|
import { StorageService } from '../storage/storage'
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
/* Requests */
|
|
14
13
|
|
|
15
14
|
export type VerifyRequest = {
|
package/src/event/event.test.ts
CHANGED
package/src/event/event.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
NotSupported,
|
|
8
8
|
Unauthorized,
|
|
9
9
|
} from '@passlock/shared/dist/error/error'
|
|
10
|
+
import { ErrorCode } from '@passlock/shared/dist/error/error'
|
|
10
11
|
import { RpcConfig } from '@passlock/shared/dist/rpc/rpc'
|
|
11
12
|
import { Effect as E, Layer as L, Layer, Option, Runtime, Scope, pipe } from 'effect'
|
|
12
13
|
import { type AuthenticationRequest, AuthenticationService } from './authentication/authenticate'
|
|
@@ -17,7 +18,7 @@ import { EmailService, type VerifyRequest } from './email/email'
|
|
|
17
18
|
import { type RegistrationRequest, RegistrationService } from './registration/register'
|
|
18
19
|
import { type AuthType, Storage, StorageService } from './storage/storage'
|
|
19
20
|
import { type Email, UserService } from './user/user'
|
|
20
|
-
|
|
21
|
+
|
|
21
22
|
export { ErrorCode } from '@passlock/shared/dist/error/error'
|
|
22
23
|
|
|
23
24
|
export class PasslockError extends Error {
|
|
@@ -85,12 +86,16 @@ const transformErrors = <A, R>(
|
|
|
85
86
|
|
|
86
87
|
Sequential: errors => {
|
|
87
88
|
console.error(errors)
|
|
88
|
-
return E.succeed(
|
|
89
|
+
return E.succeed(
|
|
90
|
+
new PasslockError('Sorry, something went wrong', ErrorCode.InternalServerError),
|
|
91
|
+
)
|
|
89
92
|
},
|
|
90
93
|
|
|
91
94
|
Parallel: errors => {
|
|
92
95
|
console.error(errors)
|
|
93
|
-
return E.succeed(
|
|
96
|
+
return E.succeed(
|
|
97
|
+
new PasslockError('Sorry, something went wrong', ErrorCode.InternalServerError),
|
|
98
|
+
)
|
|
94
99
|
},
|
|
95
100
|
})
|
|
96
101
|
|
|
@@ -106,10 +111,12 @@ type Requirements =
|
|
|
106
111
|
| StorageService
|
|
107
112
|
| Capabilities
|
|
108
113
|
|
|
109
|
-
export
|
|
114
|
+
export type Options = { signal?: AbortSignal }
|
|
115
|
+
|
|
116
|
+
export class PasslockUnsafe {
|
|
110
117
|
private readonly runtime: Runtime.Runtime<Requirements>
|
|
111
118
|
|
|
112
|
-
constructor(config: { tenancyId: string; clientId: string; endpoint
|
|
119
|
+
constructor(config: { tenancyId: string; clientId: string; endpoint?: string }) {
|
|
113
120
|
const rpcConfig = Layer.succeed(RpcConfig, RpcConfig.of(config))
|
|
114
121
|
const storage = Layer.succeed(Storage, Storage.of(globalThis.localStorage))
|
|
115
122
|
const allLayers = pipe(allRequirements, L.provide(rpcConfig), L.provide(storage))
|
|
@@ -119,19 +126,20 @@ export class Passlock {
|
|
|
119
126
|
|
|
120
127
|
private readonly runPromise = <A, R extends Requirements>(
|
|
121
128
|
effect: E.Effect<A, PasslockErrors, R>,
|
|
129
|
+
options: Options | undefined = undefined
|
|
122
130
|
) => {
|
|
123
131
|
return pipe(
|
|
124
132
|
transformErrors(effect),
|
|
125
133
|
E.flatMap(result => (PasslockError.isError(result) ? E.fail(result) : E.succeed(result))),
|
|
126
|
-
effect => Runtime.runPromise(this.runtime)(effect),
|
|
134
|
+
effect => Runtime.runPromise(this.runtime)(effect, options),
|
|
127
135
|
)
|
|
128
136
|
}
|
|
129
137
|
|
|
130
|
-
preConnect = () =>
|
|
138
|
+
preConnect = (options?: Options) =>
|
|
131
139
|
pipe(
|
|
132
140
|
ConnectionService,
|
|
133
141
|
E.flatMap(service => service.preConnect()),
|
|
134
|
-
effect => Runtime.runPromise(this.runtime)(effect),
|
|
142
|
+
effect => Runtime.runPromise(this.runtime)(effect, options),
|
|
135
143
|
)
|
|
136
144
|
|
|
137
145
|
isPasskeySupport = () =>
|
|
@@ -141,39 +149,39 @@ export class Passlock {
|
|
|
141
149
|
effect => Runtime.runPromise(this.runtime)(effect),
|
|
142
150
|
)
|
|
143
151
|
|
|
144
|
-
isExistingPasskey = (email: Email) =>
|
|
152
|
+
isExistingPasskey = (email: Email, options?: Options) =>
|
|
145
153
|
pipe(
|
|
146
154
|
UserService,
|
|
147
155
|
E.flatMap(service => service.isExistingUser(email)),
|
|
148
|
-
effect => this.runPromise(effect),
|
|
156
|
+
effect => this.runPromise(effect, options),
|
|
149
157
|
)
|
|
150
158
|
|
|
151
|
-
registerPasskey = (request: RegistrationRequest) =>
|
|
159
|
+
registerPasskey = (request: RegistrationRequest, options?: Options) =>
|
|
152
160
|
pipe(
|
|
153
161
|
RegistrationService,
|
|
154
162
|
E.flatMap(service => service.registerPasskey(request)),
|
|
155
|
-
effect => this.runPromise(effect),
|
|
163
|
+
effect => this.runPromise(effect, options),
|
|
156
164
|
)
|
|
157
165
|
|
|
158
|
-
authenticatePasskey = (request: AuthenticationRequest) =>
|
|
166
|
+
authenticatePasskey = (request: AuthenticationRequest, options?: Options) =>
|
|
159
167
|
pipe(
|
|
160
168
|
AuthenticationService,
|
|
161
169
|
E.flatMap(service => service.authenticatePasskey(request)),
|
|
162
|
-
effect => this.runPromise(effect),
|
|
170
|
+
effect => this.runPromise(effect, options),
|
|
163
171
|
)
|
|
164
172
|
|
|
165
|
-
verifyEmailCode = (request: VerifyRequest) =>
|
|
173
|
+
verifyEmailCode = (request: VerifyRequest, options?: Options) =>
|
|
166
174
|
pipe(
|
|
167
175
|
EmailService,
|
|
168
176
|
E.flatMap(service => service.verifyEmailCode(request)),
|
|
169
|
-
effect => this.runPromise(effect),
|
|
177
|
+
effect => this.runPromise(effect, options),
|
|
170
178
|
)
|
|
171
179
|
|
|
172
|
-
verifyEmailLink = () =>
|
|
180
|
+
verifyEmailLink = (options?: Options) =>
|
|
173
181
|
pipe(
|
|
174
182
|
EmailService,
|
|
175
183
|
E.flatMap(service => service.verifyEmailLink()),
|
|
176
|
-
effect => this.runPromise(effect),
|
|
184
|
+
effect => this.runPromise(effect, options),
|
|
177
185
|
)
|
|
178
186
|
|
|
179
187
|
getSessionToken = (authType: AuthType) =>
|
|
@@ -181,21 +189,21 @@ export class Passlock {
|
|
|
181
189
|
StorageService,
|
|
182
190
|
E.flatMap(service => service.getToken(authType).pipe(effect => E.option(effect))),
|
|
183
191
|
E.map(Option.getOrUndefined),
|
|
184
|
-
effect => Runtime.runSync(this.runtime)(effect)
|
|
192
|
+
effect => Runtime.runSync(this.runtime)(effect),
|
|
185
193
|
)
|
|
186
194
|
|
|
187
195
|
clearExpiredTokens = () =>
|
|
188
196
|
pipe(
|
|
189
197
|
StorageService,
|
|
190
198
|
E.flatMap(service => service.clearExpiredTokens),
|
|
191
|
-
effect => Runtime.runPromise(this.runtime)(effect)
|
|
199
|
+
effect => Runtime.runPromise(this.runtime)(effect),
|
|
192
200
|
)
|
|
193
201
|
}
|
|
194
202
|
|
|
195
|
-
export class
|
|
203
|
+
export class Passlock {
|
|
196
204
|
private readonly runtime: Runtime.Runtime<Requirements>
|
|
197
205
|
|
|
198
|
-
constructor(config: { tenancyId: string; clientId: string; endpoint
|
|
206
|
+
constructor(config: { tenancyId: string; clientId: string; endpoint?: string }) {
|
|
199
207
|
const rpcConfig = Layer.succeed(RpcConfig, RpcConfig.of(config))
|
|
200
208
|
const storage = Layer.succeed(Storage, Storage.of(globalThis.localStorage))
|
|
201
209
|
const allLayers = pipe(allRequirements, L.provide(rpcConfig), L.provide(storage))
|
|
@@ -205,10 +213,21 @@ export class PasslockSafe {
|
|
|
205
213
|
|
|
206
214
|
private readonly runPromise = <A, R extends Requirements>(
|
|
207
215
|
effect: E.Effect<A, PasslockErrors, R>,
|
|
216
|
+
options: Options | undefined = undefined
|
|
208
217
|
) => {
|
|
209
|
-
return pipe(
|
|
218
|
+
return pipe(
|
|
219
|
+
transformErrors(effect),
|
|
220
|
+
effect => Runtime.runPromise(this.runtime)(effect, options)
|
|
221
|
+
)
|
|
210
222
|
}
|
|
211
223
|
|
|
224
|
+
preConnect = (options?: Options) =>
|
|
225
|
+
pipe(
|
|
226
|
+
ConnectionService,
|
|
227
|
+
E.flatMap(service => service.preConnect()),
|
|
228
|
+
effect => this.runPromise(effect, options),
|
|
229
|
+
)
|
|
230
|
+
|
|
212
231
|
isPasskeySupport = () =>
|
|
213
232
|
pipe(
|
|
214
233
|
Capabilities,
|
|
@@ -216,46 +235,39 @@ export class PasslockSafe {
|
|
|
216
235
|
effect => Runtime.runPromise(this.runtime)(effect),
|
|
217
236
|
)
|
|
218
237
|
|
|
219
|
-
|
|
220
|
-
pipe(
|
|
221
|
-
ConnectionService,
|
|
222
|
-
E.flatMap(service => service.preConnect()),
|
|
223
|
-
effect => this.runPromise(effect),
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
isExistingPasskey = (email: Email) =>
|
|
238
|
+
isExistingPasskey = (email: Email, options?: Options) =>
|
|
227
239
|
pipe(
|
|
228
240
|
UserService,
|
|
229
241
|
E.flatMap(service => service.isExistingUser(email)),
|
|
230
|
-
effect => this.runPromise(effect),
|
|
242
|
+
effect => this.runPromise(effect, options),
|
|
231
243
|
)
|
|
232
244
|
|
|
233
|
-
registerPasskey = (request: RegistrationRequest) =>
|
|
245
|
+
registerPasskey = (request: RegistrationRequest, options?: Options) =>
|
|
234
246
|
pipe(
|
|
235
247
|
RegistrationService,
|
|
236
248
|
E.flatMap(service => service.registerPasskey(request)),
|
|
237
|
-
effect => this.runPromise(effect),
|
|
249
|
+
effect => this.runPromise(effect, options),
|
|
238
250
|
)
|
|
239
251
|
|
|
240
|
-
authenticatePasskey = (request: AuthenticationRequest = {}) =>
|
|
252
|
+
authenticatePasskey = (request: AuthenticationRequest = {}, options?: Options) =>
|
|
241
253
|
pipe(
|
|
242
254
|
AuthenticationService,
|
|
243
255
|
E.flatMap(service => service.authenticatePasskey(request)),
|
|
244
|
-
effect => this.runPromise(effect),
|
|
256
|
+
effect => this.runPromise(effect, options),
|
|
245
257
|
)
|
|
246
258
|
|
|
247
|
-
verifyEmailCode = (request: VerifyRequest) =>
|
|
259
|
+
verifyEmailCode = (request: VerifyRequest, options?: Options) =>
|
|
248
260
|
pipe(
|
|
249
261
|
EmailService,
|
|
250
262
|
E.flatMap(service => service.verifyEmailCode(request)),
|
|
251
|
-
effect => this.runPromise(effect),
|
|
263
|
+
effect => this.runPromise(effect, options),
|
|
252
264
|
)
|
|
253
265
|
|
|
254
|
-
verifyEmailLink = () =>
|
|
266
|
+
verifyEmailLink = (options?: Options) =>
|
|
255
267
|
pipe(
|
|
256
268
|
EmailService,
|
|
257
269
|
E.flatMap(service => service.verifyEmailLink()),
|
|
258
|
-
effect => this.runPromise(effect),
|
|
270
|
+
effect => this.runPromise(effect, options),
|
|
259
271
|
)
|
|
260
272
|
|
|
261
273
|
getSessionToken = (authType: AuthType) =>
|
|
@@ -263,13 +275,13 @@ export class PasslockSafe {
|
|
|
263
275
|
StorageService,
|
|
264
276
|
E.flatMap(service => service.getToken(authType).pipe(effect => E.option(effect))),
|
|
265
277
|
E.map(maybeToken => Option.getOrUndefined(maybeToken)),
|
|
266
|
-
effect => Runtime.runSync(this.runtime)(effect)
|
|
278
|
+
effect => Runtime.runSync(this.runtime)(effect),
|
|
267
279
|
)
|
|
268
280
|
|
|
269
281
|
clearExpiredTokens = () =>
|
|
270
282
|
pipe(
|
|
271
283
|
StorageService,
|
|
272
284
|
E.flatMap(service => service.clearExpiredTokens),
|
|
273
|
-
effect => Runtime.runPromise(this.runtime)(effect)
|
|
285
|
+
effect => Runtime.runPromise(this.runtime)(effect),
|
|
274
286
|
)
|
|
275
287
|
}
|
|
@@ -12,7 +12,6 @@ import { CreateCredential, type RegistrationRequest } from './register'
|
|
|
12
12
|
import * as Fixtures from '../test/fixtures'
|
|
13
13
|
import { UserService } from '../user/user'
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
export const session = 'session'
|
|
17
16
|
export const token = 'token'
|
|
18
17
|
export const code = 'code'
|
|
@@ -7,7 +7,6 @@ import { CreateCredential, RegistrationService, RegistrationServiceLive } from '
|
|
|
7
7
|
import * as Fixture from './register.fixture'
|
|
8
8
|
import { UserService } from '../user/user'
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
describe('register should', () => {
|
|
12
11
|
test('return a valid credential', async () => {
|
|
13
12
|
const assertions = E.gen(function* (_) {
|
|
@@ -5,15 +5,10 @@ import {
|
|
|
5
5
|
type CredentialCreationOptionsJSON,
|
|
6
6
|
parseCreationOptionsFromJSON,
|
|
7
7
|
} from '@github/webauthn-json/browser-ponyfill'
|
|
8
|
-
import type { NotSupported } from '@passlock/shared/dist/error/error'
|
|
8
|
+
import type { NotSupported } from '@passlock/shared/dist/error/error'
|
|
9
9
|
import { Duplicate, InternalBrowserError } from '@passlock/shared/dist/error/error'
|
|
10
|
-
import type {
|
|
11
|
-
|
|
12
|
-
VerificationErrors} from '@passlock/shared/dist/rpc/registration';
|
|
13
|
-
import {
|
|
14
|
-
OptionsReq,
|
|
15
|
-
VerificationReq,
|
|
16
|
-
} from '@passlock/shared/dist/rpc/registration'
|
|
10
|
+
import type { OptionsErrors, VerificationErrors } from '@passlock/shared/dist/rpc/registration'
|
|
11
|
+
import { OptionsReq, VerificationReq } from '@passlock/shared/dist/rpc/registration'
|
|
17
12
|
import { RpcClient } from '@passlock/shared/dist/rpc/rpc'
|
|
18
13
|
import type {
|
|
19
14
|
Principal,
|
package/src/test/fixtures.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { Effect as E, Layer as L } from 'effect'
|
|
|
3
3
|
import { Capabilities } from '../capabilities/capabilities'
|
|
4
4
|
import { StorageService, type StoredToken } from '../storage/storage'
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
export const session = 'session'
|
|
8
7
|
export const token = 'token'
|
|
9
8
|
export const code = 'code'
|
package/src/user/user.fixture.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { RpcClient } from '@passlock/shared/dist/rpc/rpc'
|
|
|
3
3
|
import { IsExistingUserReq, IsExistingUserRes } from '@passlock/shared/dist/rpc/user'
|
|
4
4
|
import { Effect as E, Layer as L } from 'effect'
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
export const email = 'jdoe@gmail.com'
|
|
8
7
|
|
|
9
8
|
export const rpcClientTest = L.succeed(
|
package/src/user/user.test.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { mock } from 'vitest-mock-extended'
|
|
|
5
5
|
import { UserService, UserServiceLive } from './user'
|
|
6
6
|
import * as Fixture from './user.fixture'
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
describe('isExistingUser should', () => {
|
|
10
9
|
test('return true when the user already has a passkey', async () => {
|
|
11
10
|
const assertions = E.gen(function* (_) {
|
package/src/user/user.ts
CHANGED