@passlock/client 2.1.0 → 2.3.0
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/index.d.ts +118 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +123 -21
- package/dist/index.js.map +1 -1
- package/dist/internal/network.d.ts +14 -1
- package/dist/internal/network.d.ts.map +1 -1
- package/dist/internal/network.js +11 -1
- package/dist/internal/network.js.map +1 -1
- package/dist/internal/promise.d.ts +7 -3
- package/dist/internal/promise.d.ts.map +1 -1
- package/dist/internal/promise.js +9 -5
- package/dist/internal/promise.js.map +1 -1
- package/dist/internal/result.d.ts +33 -0
- package/dist/internal/result.d.ts.map +1 -0
- package/dist/internal/result.js +35 -0
- package/dist/internal/result.js.map +1 -0
- package/dist/logger.d.ts +11 -5
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +11 -5
- package/dist/logger.js.map +1 -1
- package/dist/options.d.ts +5 -5
- package/dist/options.d.ts.map +1 -1
- package/dist/passkey/authentication/authentication.d.ts +11 -4
- package/dist/passkey/authentication/authentication.d.ts.map +1 -1
- package/dist/passkey/authentication/authentication.js +5 -2
- package/dist/passkey/authentication/authentication.js.map +1 -1
- package/dist/passkey/errors.d.ts +19 -13
- package/dist/passkey/errors.d.ts.map +1 -1
- package/dist/passkey/errors.js +16 -16
- package/dist/passkey/errors.js.map +1 -1
- package/dist/passkey/registration/registration.d.ts +7 -4
- package/dist/passkey/registration/registration.d.ts.map +1 -1
- package/dist/passkey/registration/registration.js +4 -4
- package/dist/passkey/registration/registration.js.map +1 -1
- package/dist/passkey/shared.d.ts +16 -4
- package/dist/passkey/shared.d.ts.map +1 -1
- package/dist/passkey/signals/signals.d.ts +219 -29
- package/dist/passkey/signals/signals.d.ts.map +1 -1
- package/dist/passkey/signals/signals.js +144 -24
- package/dist/passkey/signals/signals.js.map +1 -1
- package/dist/safe.d.ts +181 -60
- package/dist/safe.d.ts.map +1 -1
- package/dist/safe.js +179 -54
- package/dist/safe.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
* Testing for browser capabilities related to passkeys, type guards and other utilities.
|
|
11
11
|
*
|
|
12
12
|
* @showCategories
|
|
13
|
-
* @module unsafe
|
|
13
|
+
* @module unsafe (default)
|
|
14
14
|
*/
|
|
15
15
|
import { Logger } from "./logger.js";
|
|
16
16
|
import type { AuthenticationOptions, AuthenticationSuccess } from "./passkey/authentication/authentication.js";
|
|
17
17
|
import type { RegistrationOptions, RegistrationSuccess } from "./passkey/registration/registration.js";
|
|
18
|
-
import type { DeleteCredentialOptions, DeletePasskeyOptions, DeleteSuccess, PrunePasskeyOptions, PruningSuccess, UpdateCredentialOptions, UpdatePasskeyOptions, UpdateSuccess } from "./passkey/signals/signals.js";
|
|
18
|
+
import type { Credential, DeleteCredentialOptions, DeletePasskeyOptions, DeleteSuccess, PrunePasskeyOptions, PruningSuccess, UpdateCredentialOptions, UpdatePasskeyOptions, UpdateSuccess } from "./passkey/signals/signals.js";
|
|
19
19
|
import type { OrphanedPasskeyError } from "./safe.js";
|
|
20
20
|
/**
|
|
21
21
|
* Registers a passkey on the user's device, then saves the server-side component in your vault.
|
|
@@ -25,7 +25,7 @@ import type { OrphanedPasskeyError } from "./safe.js";
|
|
|
25
25
|
*
|
|
26
26
|
* @param options
|
|
27
27
|
*
|
|
28
|
-
* @returns A
|
|
28
|
+
* @returns A promise resolving to a {@link RegistrationSuccess}.
|
|
29
29
|
*
|
|
30
30
|
* @see {@link isRegistrationSuccess}
|
|
31
31
|
* @see {@link isPasskeyUnsupportedError}
|
|
@@ -68,7 +68,7 @@ logger?: typeof Logger.Service) => Promise<RegistrationSuccess>;
|
|
|
68
68
|
*
|
|
69
69
|
* @param options
|
|
70
70
|
*
|
|
71
|
-
* @returns A
|
|
71
|
+
* @returns A promise resolving to an {@link AuthenticationSuccess}.
|
|
72
72
|
*
|
|
73
73
|
* @see {@link isAuthenticationSuccess}
|
|
74
74
|
* @see {@link isPasskeyUnsupportedError}
|
|
@@ -112,11 +112,18 @@ logger?: typeof Logger.Service) => Promise<AuthenticationSuccess>;
|
|
|
112
112
|
*
|
|
113
113
|
* By calling this function and supplying a new username/display name, their local
|
|
114
114
|
* password manager will align with their updated account identifier.
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
115
|
+
* Support and metadata lookup failures are thrown as {@link UpdateError}.
|
|
116
|
+
* Browser-side signalling failures are logged as warnings and are not thrown.
|
|
117
|
+
*
|
|
118
|
+
* @param options You will typically supply a target `passkeyId` via
|
|
119
|
+
* {@link UpdatePasskeyOptions}. {@link UpdateCredentialOptions} is intended
|
|
120
|
+
* for credential-scoped updates, for example when replaying data returned by
|
|
121
|
+
* `@passlock/server`.
|
|
122
|
+
* @returns A promise resolving to an {@link UpdateSuccess} once the browser
|
|
123
|
+
* update workflow has been started.
|
|
118
124
|
* @see {@link isUpdateError}
|
|
119
|
-
* @throws {@link UpdateError} if
|
|
125
|
+
* @throws {@link UpdateError} if update support is unavailable or required
|
|
126
|
+
* credential metadata cannot be loaded
|
|
120
127
|
*
|
|
121
128
|
* @example
|
|
122
129
|
* // from your Passlock console settings
|
|
@@ -127,7 +134,7 @@ logger?: typeof Logger.Service) => Promise<AuthenticationSuccess>;
|
|
|
127
134
|
*
|
|
128
135
|
* try {
|
|
129
136
|
* const result = await updatePasskey({ tenancyId, passkeyId, username, displayName });
|
|
130
|
-
* console.log("passkey
|
|
137
|
+
* console.log("passkey update requested");
|
|
131
138
|
* } catch (error) {
|
|
132
139
|
* console.log(error);
|
|
133
140
|
* }
|
|
@@ -138,7 +145,86 @@ export declare const updatePasskey: (options: UpdatePasskeyOptions | UpdateCrede
|
|
|
138
145
|
/** @hidden */
|
|
139
146
|
logger?: typeof Logger.Service) => Promise<UpdateSuccess>;
|
|
140
147
|
/**
|
|
141
|
-
*
|
|
148
|
+
* Attempt to update the username or display name for multiple passkeys (client-side only).
|
|
149
|
+
*
|
|
150
|
+
* Useful if the user has changed their account identifier. For example, they register
|
|
151
|
+
* using jdoe@gmail.com but later change their account username to jdoe@yahoo.com.
|
|
152
|
+
* Even after you update their account details in your backend, their local password
|
|
153
|
+
* manager will continue to display jdoe@gmail.com.
|
|
154
|
+
*
|
|
155
|
+
* By calling this function and supplying a new username/display name, their local
|
|
156
|
+
* password manager will align with their updated account identifier.
|
|
157
|
+
* Support failures are thrown as {@link UpdateError}. Browser-side signalling
|
|
158
|
+
* failures are logged as warnings and are not thrown.
|
|
159
|
+
*
|
|
160
|
+
* @param options The `credentials` array returned by
|
|
161
|
+
* `@passlock/server`'s `updatePasskeyUsernames`.
|
|
162
|
+
* @returns A promise resolving to an {@link UpdateSuccess} once the browser
|
|
163
|
+
* update workflows have been started.
|
|
164
|
+
* @throws {@link UpdateError} if update support is unavailable
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* // server code
|
|
168
|
+
* import { updatePasskeyUsernames as updatePasskeyUsernamesOnServer } from "@passlock/server";
|
|
169
|
+
*
|
|
170
|
+
* // send the backendResult to your frontend
|
|
171
|
+
* const backendResult = await updatePasskeyUsernamesOnServer({
|
|
172
|
+
* tenancyId,
|
|
173
|
+
* userId,
|
|
174
|
+
* username,
|
|
175
|
+
* displayName,
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* // client code
|
|
179
|
+
* import { updatePasskeyUsernames } from "@passlock/client";
|
|
180
|
+
*
|
|
181
|
+
* const credentialsFromBackend = backendResult.credentials;
|
|
182
|
+
* const result = await updatePasskeyUsernames(credentialsFromBackend);
|
|
183
|
+
*
|
|
184
|
+
* @category Passkeys (core)
|
|
185
|
+
*/
|
|
186
|
+
export declare const updatePasskeyUsernames: (options: ReadonlyArray<UpdateCredentialOptions>,
|
|
187
|
+
/** @hidden */
|
|
188
|
+
logger?: typeof Logger.Service) => Promise<UpdateSuccess>;
|
|
189
|
+
/**
|
|
190
|
+
* Attempt to signal removal of multiple passkeys from a local device.
|
|
191
|
+
*
|
|
192
|
+
* Use this after deleting the server-side passkeys. The `deleted` array returned
|
|
193
|
+
* by `@passlock/server` already has the right shape, so you can pass it straight
|
|
194
|
+
* into this function.
|
|
195
|
+
* Support failures are thrown as {@link DeleteError}. Browser-side signalling
|
|
196
|
+
* failures are logged as warnings and are not thrown.
|
|
197
|
+
*
|
|
198
|
+
* @param options Credentials derived from deleted backend passkeys.
|
|
199
|
+
* @returns A promise resolving to a {@link DeleteSuccess} once the browser
|
|
200
|
+
* removal workflows have been started.
|
|
201
|
+
* @see {@link isDeleteError}
|
|
202
|
+
* @throws {@link DeleteError} if deletion support is unavailable
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* // server code
|
|
206
|
+
* import { deleteUserPasskeys as deleteUserPasskeysOnServer } from "@passlock/server";
|
|
207
|
+
*
|
|
208
|
+
* const deletedPasskeys = await deleteUserPasskeysOnServer({
|
|
209
|
+
* tenancyId,
|
|
210
|
+
* userId,
|
|
211
|
+
* apiKey,
|
|
212
|
+
* });
|
|
213
|
+
*
|
|
214
|
+
* // client code
|
|
215
|
+
* import { deleteUserPasskeys } from "@passlock/client";
|
|
216
|
+
*
|
|
217
|
+
* const deletedCredentials = deletedPasskeys.deleted;
|
|
218
|
+
* const result = await deleteUserPasskeys(deletedCredentials);
|
|
219
|
+
*
|
|
220
|
+
* @category Passkeys (core)
|
|
221
|
+
*/
|
|
222
|
+
export declare const deleteUserPasskeys: (options: ReadonlyArray<Credential>,
|
|
223
|
+
/** @hidden */
|
|
224
|
+
logger?: typeof Logger.Service) => Promise<DeleteSuccess>;
|
|
225
|
+
/**
|
|
226
|
+
* Attempts to signal removal of a passkey from a local device. There are two
|
|
227
|
+
* scenarios in which this function proves useful:
|
|
142
228
|
*
|
|
143
229
|
* 1. **Deleting a passkey**. Use the `@passlock/server` package or make vanilla REST calls from your
|
|
144
230
|
* backend to delete the server-side component, then use this function to delete the client-side component.
|
|
@@ -148,11 +234,17 @@ logger?: typeof Logger.Service) => Promise<UpdateSuccess>;
|
|
|
148
234
|
*
|
|
149
235
|
* See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) and
|
|
150
236
|
* [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/) in the documentation.
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
237
|
+
* Support and metadata lookup failures are thrown as {@link DeleteError}.
|
|
238
|
+
* Browser-side signalling failures are logged as warnings and are not thrown.
|
|
239
|
+
*
|
|
240
|
+
* @param options You typically pass a {@link DeletePasskeyOptions}. Use
|
|
241
|
+
* {@link DeleteCredentialOptions} or {@link OrphanedPasskeyError} when you
|
|
242
|
+
* already have the credential metadata.
|
|
243
|
+
* @returns A {@link DeleteSuccess} payload once the local removal workflow has
|
|
244
|
+
* been started.
|
|
154
245
|
* @see {@link isDeleteError}
|
|
155
|
-
* @throws {@link DeleteError} if
|
|
246
|
+
* @throws {@link DeleteError} if deletion support is unavailable or required
|
|
247
|
+
* credential metadata cannot be loaded
|
|
156
248
|
*
|
|
157
249
|
* @example
|
|
158
250
|
* // from your Passlock console settings
|
|
@@ -161,7 +253,7 @@ logger?: typeof Logger.Service) => Promise<UpdateSuccess>;
|
|
|
161
253
|
*
|
|
162
254
|
* try {
|
|
163
255
|
* const result = await deletePasskey({ tenancyId, passkeyId });
|
|
164
|
-
* console.log("passkey
|
|
256
|
+
* console.log("passkey removal requested");
|
|
165
257
|
* } catch (error) {
|
|
166
258
|
* console.log(error);
|
|
167
259
|
* }
|
|
@@ -176,12 +268,16 @@ logger?: typeof Logger.Service) => Promise<DeleteSuccess>;
|
|
|
176
268
|
*
|
|
177
269
|
* This is useful when your backend is the source of truth for which passkeys
|
|
178
270
|
* should still exist for a given account on this device.
|
|
271
|
+
* Support and metadata lookup failures are thrown as {@link PruningError}.
|
|
272
|
+
* Browser-side signalling failures are logged as warnings and are not thrown.
|
|
179
273
|
*
|
|
180
274
|
* @param options Pass the passkeys you want to retain.
|
|
181
|
-
* @returns A {@link PruningSuccess} payload
|
|
275
|
+
* @returns A {@link PruningSuccess} payload once the accepted-credentials
|
|
276
|
+
* signalling attempt has completed.
|
|
182
277
|
* @see {@link isPruningError}
|
|
183
278
|
*
|
|
184
|
-
* @throws {@link PruningError}
|
|
279
|
+
* @throws {@link PruningError} if pruning support is unavailable or required
|
|
280
|
+
* credential metadata cannot be loaded
|
|
185
281
|
*
|
|
186
282
|
* @example
|
|
187
283
|
* // from your Passlock console settings
|
|
@@ -190,7 +286,7 @@ logger?: typeof Logger.Service) => Promise<DeleteSuccess>;
|
|
|
190
286
|
*
|
|
191
287
|
* try {
|
|
192
288
|
* const result = await prunePasskeys({ tenancyId, allowablePasskeyIds });
|
|
193
|
-
* console.log("
|
|
289
|
+
* console.log("accepted credentials sync requested", result);
|
|
194
290
|
* } catch (error) {
|
|
195
291
|
* if (isPruningError(error)) {
|
|
196
292
|
* console.log(error.code);
|
|
@@ -205,7 +301,7 @@ export declare const prunePasskeys: (options: PrunePasskeyOptions,
|
|
|
205
301
|
/** @hidden */
|
|
206
302
|
logger?: typeof Logger.Service) => Promise<PruningSuccess>;
|
|
207
303
|
/**
|
|
208
|
-
* Does the local device support programmatic passkey deletion
|
|
304
|
+
* Does the local device support programmatic passkey deletion?
|
|
209
305
|
*
|
|
210
306
|
* @returns `true` if local passkey deletion is supported.
|
|
211
307
|
*
|
|
@@ -213,7 +309,7 @@ logger?: typeof Logger.Service) => Promise<PruningSuccess>;
|
|
|
213
309
|
*/
|
|
214
310
|
export declare const isPasskeyDeleteSupport: () => boolean;
|
|
215
311
|
/**
|
|
216
|
-
* Does the local device support programmatic passkey pruning
|
|
312
|
+
* Does the local device support programmatic passkey pruning?
|
|
217
313
|
*
|
|
218
314
|
* @returns `true` if local passkey pruning is supported.
|
|
219
315
|
*
|
|
@@ -221,7 +317,7 @@ export declare const isPasskeyDeleteSupport: () => boolean;
|
|
|
221
317
|
*/
|
|
222
318
|
export declare const isPasskeyPruningSupport: () => boolean;
|
|
223
319
|
/**
|
|
224
|
-
* Does the local device support programmatic passkey updates
|
|
320
|
+
* Does the local device support programmatic passkey updates?
|
|
225
321
|
*
|
|
226
322
|
* @returns `true` if local passkey updates are supported.
|
|
227
323
|
*
|
|
@@ -238,7 +334,7 @@ export { DeleteError, DuplicatePasskeyError, isDeleteError, isDuplicatePasskeyEr
|
|
|
238
334
|
export type { OnRegistrationEvent, RegistrationError, RegistrationEvent, RegistrationOptions, RegistrationSuccess, } from "./passkey/registration/registration.js";
|
|
239
335
|
export { isRegistrationSuccess, RegistrationHelper, } from "./passkey/registration/registration.js";
|
|
240
336
|
export type { UserVerification } from "./passkey/shared.js";
|
|
241
|
-
export type {
|
|
337
|
+
export type { Credential, DeleteCredentialOptions, DeletePasskeyOptions, DeleteSuccess, PrunePasskeyOptions, PruningSuccess, UpdateCredentialOptions, UpdatePasskeyOptions, UpdateSuccess, } from "./passkey/signals/signals.js";
|
|
242
338
|
export { isDeleteSuccess, isPruningSuccess, isUpdateSuccess, } from "./passkey/signals/signals.js";
|
|
243
339
|
export { isAutofillSupport, isPasskeySupport, } from "./passkey/support.js";
|
|
244
340
|
export type { Principal } from "./principal.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAe,MAAM,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,4CAA4C,CAAA;AAKnD,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,wCAAwC,CAAA;AAK/C,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACd,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"index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B,CAAA;AACpD,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,YAAY,EACZ,WAAW,GACZ,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EACL,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,wCAAwC,CAAA;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,YAAY,EACV,UAAU,EACV,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,GACd,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
* Testing for browser capabilities related to passkeys, type guards and other utilities.
|
|
11
11
|
*
|
|
12
12
|
* @showCategories
|
|
13
|
-
* @module unsafe
|
|
13
|
+
* @module unsafe (default)
|
|
14
14
|
*/
|
|
15
15
|
import { Micro, pipe } from "effect";
|
|
16
16
|
import { runToPromiseUnsafe } from "./internal/index.js";
|
|
17
17
|
import { eventLogger, Logger } from "./logger.js";
|
|
18
18
|
import { AuthenticationHelper, authenticatePasskey as authenticatePasskeyM, } from "./passkey/authentication/authentication.js";
|
|
19
19
|
import { RegistrationHelper, registerPasskey as registerPasskeyM, } from "./passkey/registration/registration.js";
|
|
20
|
-
import { deletePasskey as deletePasskeyM, isPasskeyDeleteSupport as isPasskeyDeleteSupportM, isPasskeyPruningSupport as isPasskeyPruningSupportM, isPasskeyUpdateSupport as isPasskeyUpdateSupportM, prunePasskeys as prunePasskeysM, updatePasskey as updatePasskeyM, } from "./passkey/signals/signals.js";
|
|
20
|
+
import { deletePasskey as deletePasskeyM, deleteUserPasskeys as deleteUserPasskeysM, isPasskeyDeleteSupport as isPasskeyDeleteSupportM, isPasskeyPruningSupport as isPasskeyPruningSupportM, isPasskeyUpdateSupport as isPasskeyUpdateSupportM, prunePasskeys as prunePasskeysM, updatePasskey as updatePasskeyM, updatePasskeyUsernames as updatePasskeyUsernamesM, } from "./passkey/signals/signals.js";
|
|
21
21
|
/* Registration */
|
|
22
22
|
/**
|
|
23
23
|
* Registers a passkey on the user's device, then saves the server-side component in your vault.
|
|
@@ -27,7 +27,7 @@ import { deletePasskey as deletePasskeyM, isPasskeyDeleteSupport as isPasskeyDel
|
|
|
27
27
|
*
|
|
28
28
|
* @param options
|
|
29
29
|
*
|
|
30
|
-
* @returns A
|
|
30
|
+
* @returns A promise resolving to a {@link RegistrationSuccess}.
|
|
31
31
|
*
|
|
32
32
|
* @see {@link isRegistrationSuccess}
|
|
33
33
|
* @see {@link isPasskeyUnsupportedError}
|
|
@@ -71,7 +71,7 @@ logger = eventLogger) => pipe(registerPasskeyM(options), Micro.provideService(Re
|
|
|
71
71
|
*
|
|
72
72
|
* @param options
|
|
73
73
|
*
|
|
74
|
-
* @returns A
|
|
74
|
+
* @returns A promise resolving to an {@link AuthenticationSuccess}.
|
|
75
75
|
*
|
|
76
76
|
* @see {@link isAuthenticationSuccess}
|
|
77
77
|
* @see {@link isPasskeyUnsupportedError}
|
|
@@ -116,11 +116,18 @@ logger = eventLogger) => pipe(authenticatePasskeyM(options), Micro.provideServic
|
|
|
116
116
|
*
|
|
117
117
|
* By calling this function and supplying a new username/display name, their local
|
|
118
118
|
* password manager will align with their updated account identifier.
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
119
|
+
* Support and metadata lookup failures are thrown as {@link UpdateError}.
|
|
120
|
+
* Browser-side signalling failures are logged as warnings and are not thrown.
|
|
121
|
+
*
|
|
122
|
+
* @param options You will typically supply a target `passkeyId` via
|
|
123
|
+
* {@link UpdatePasskeyOptions}. {@link UpdateCredentialOptions} is intended
|
|
124
|
+
* for credential-scoped updates, for example when replaying data returned by
|
|
125
|
+
* `@passlock/server`.
|
|
126
|
+
* @returns A promise resolving to an {@link UpdateSuccess} once the browser
|
|
127
|
+
* update workflow has been started.
|
|
122
128
|
* @see {@link isUpdateError}
|
|
123
|
-
* @throws {@link UpdateError} if
|
|
129
|
+
* @throws {@link UpdateError} if update support is unavailable or required
|
|
130
|
+
* credential metadata cannot be loaded
|
|
124
131
|
*
|
|
125
132
|
* @example
|
|
126
133
|
* // from your Passlock console settings
|
|
@@ -131,7 +138,7 @@ logger = eventLogger) => pipe(authenticatePasskeyM(options), Micro.provideServic
|
|
|
131
138
|
*
|
|
132
139
|
* try {
|
|
133
140
|
* const result = await updatePasskey({ tenancyId, passkeyId, username, displayName });
|
|
134
|
-
* console.log("passkey
|
|
141
|
+
* console.log("passkey update requested");
|
|
135
142
|
* } catch (error) {
|
|
136
143
|
* console.log(error);
|
|
137
144
|
* }
|
|
@@ -145,7 +152,92 @@ logger = eventLogger) => {
|
|
|
145
152
|
return pipe(micro, Micro.provideService(Logger, logger), runToPromiseUnsafe);
|
|
146
153
|
};
|
|
147
154
|
/**
|
|
148
|
-
*
|
|
155
|
+
* Attempt to update the username or display name for multiple passkeys (client-side only).
|
|
156
|
+
*
|
|
157
|
+
* Useful if the user has changed their account identifier. For example, they register
|
|
158
|
+
* using jdoe@gmail.com but later change their account username to jdoe@yahoo.com.
|
|
159
|
+
* Even after you update their account details in your backend, their local password
|
|
160
|
+
* manager will continue to display jdoe@gmail.com.
|
|
161
|
+
*
|
|
162
|
+
* By calling this function and supplying a new username/display name, their local
|
|
163
|
+
* password manager will align with their updated account identifier.
|
|
164
|
+
* Support failures are thrown as {@link UpdateError}. Browser-side signalling
|
|
165
|
+
* failures are logged as warnings and are not thrown.
|
|
166
|
+
*
|
|
167
|
+
* @param options The `credentials` array returned by
|
|
168
|
+
* `@passlock/server`'s `updatePasskeyUsernames`.
|
|
169
|
+
* @returns A promise resolving to an {@link UpdateSuccess} once the browser
|
|
170
|
+
* update workflows have been started.
|
|
171
|
+
* @throws {@link UpdateError} if update support is unavailable
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* // server code
|
|
175
|
+
* import { updatePasskeyUsernames as updatePasskeyUsernamesOnServer } from "@passlock/server";
|
|
176
|
+
*
|
|
177
|
+
* // send the backendResult to your frontend
|
|
178
|
+
* const backendResult = await updatePasskeyUsernamesOnServer({
|
|
179
|
+
* tenancyId,
|
|
180
|
+
* userId,
|
|
181
|
+
* username,
|
|
182
|
+
* displayName,
|
|
183
|
+
* });
|
|
184
|
+
*
|
|
185
|
+
* // client code
|
|
186
|
+
* import { updatePasskeyUsernames } from "@passlock/client";
|
|
187
|
+
*
|
|
188
|
+
* const credentialsFromBackend = backendResult.credentials;
|
|
189
|
+
* const result = await updatePasskeyUsernames(credentialsFromBackend);
|
|
190
|
+
*
|
|
191
|
+
* @category Passkeys (core)
|
|
192
|
+
*/
|
|
193
|
+
export const updatePasskeyUsernames = (options,
|
|
194
|
+
/** @hidden */
|
|
195
|
+
logger = eventLogger) => {
|
|
196
|
+
const micro = updatePasskeyUsernamesM(options);
|
|
197
|
+
return pipe(micro, Micro.provideService(Logger, logger), runToPromiseUnsafe);
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Attempt to signal removal of multiple passkeys from a local device.
|
|
201
|
+
*
|
|
202
|
+
* Use this after deleting the server-side passkeys. The `deleted` array returned
|
|
203
|
+
* by `@passlock/server` already has the right shape, so you can pass it straight
|
|
204
|
+
* into this function.
|
|
205
|
+
* Support failures are thrown as {@link DeleteError}. Browser-side signalling
|
|
206
|
+
* failures are logged as warnings and are not thrown.
|
|
207
|
+
*
|
|
208
|
+
* @param options Credentials derived from deleted backend passkeys.
|
|
209
|
+
* @returns A promise resolving to a {@link DeleteSuccess} once the browser
|
|
210
|
+
* removal workflows have been started.
|
|
211
|
+
* @see {@link isDeleteError}
|
|
212
|
+
* @throws {@link DeleteError} if deletion support is unavailable
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* // server code
|
|
216
|
+
* import { deleteUserPasskeys as deleteUserPasskeysOnServer } from "@passlock/server";
|
|
217
|
+
*
|
|
218
|
+
* const deletedPasskeys = await deleteUserPasskeysOnServer({
|
|
219
|
+
* tenancyId,
|
|
220
|
+
* userId,
|
|
221
|
+
* apiKey,
|
|
222
|
+
* });
|
|
223
|
+
*
|
|
224
|
+
* // client code
|
|
225
|
+
* import { deleteUserPasskeys } from "@passlock/client";
|
|
226
|
+
*
|
|
227
|
+
* const deletedCredentials = deletedPasskeys.deleted;
|
|
228
|
+
* const result = await deleteUserPasskeys(deletedCredentials);
|
|
229
|
+
*
|
|
230
|
+
* @category Passkeys (core)
|
|
231
|
+
*/
|
|
232
|
+
export const deleteUserPasskeys = (options,
|
|
233
|
+
/** @hidden */
|
|
234
|
+
logger = eventLogger) => {
|
|
235
|
+
const micro = deleteUserPasskeysM(options);
|
|
236
|
+
return pipe(micro, Micro.provideService(Logger, logger), runToPromiseUnsafe);
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Attempts to signal removal of a passkey from a local device. There are two
|
|
240
|
+
* scenarios in which this function proves useful:
|
|
149
241
|
*
|
|
150
242
|
* 1. **Deleting a passkey**. Use the `@passlock/server` package or make vanilla REST calls from your
|
|
151
243
|
* backend to delete the server-side component, then use this function to delete the client-side component.
|
|
@@ -155,11 +247,17 @@ logger = eventLogger) => {
|
|
|
155
247
|
*
|
|
156
248
|
* See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) and
|
|
157
249
|
* [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/) in the documentation.
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
250
|
+
* Support and metadata lookup failures are thrown as {@link DeleteError}.
|
|
251
|
+
* Browser-side signalling failures are logged as warnings and are not thrown.
|
|
252
|
+
*
|
|
253
|
+
* @param options You typically pass a {@link DeletePasskeyOptions}. Use
|
|
254
|
+
* {@link DeleteCredentialOptions} or {@link OrphanedPasskeyError} when you
|
|
255
|
+
* already have the credential metadata.
|
|
256
|
+
* @returns A {@link DeleteSuccess} payload once the local removal workflow has
|
|
257
|
+
* been started.
|
|
161
258
|
* @see {@link isDeleteError}
|
|
162
|
-
* @throws {@link DeleteError} if
|
|
259
|
+
* @throws {@link DeleteError} if deletion support is unavailable or required
|
|
260
|
+
* credential metadata cannot be loaded
|
|
163
261
|
*
|
|
164
262
|
* @example
|
|
165
263
|
* // from your Passlock console settings
|
|
@@ -168,7 +266,7 @@ logger = eventLogger) => {
|
|
|
168
266
|
*
|
|
169
267
|
* try {
|
|
170
268
|
* const result = await deletePasskey({ tenancyId, passkeyId });
|
|
171
|
-
* console.log("passkey
|
|
269
|
+
* console.log("passkey removal requested");
|
|
172
270
|
* } catch (error) {
|
|
173
271
|
* console.log(error);
|
|
174
272
|
* }
|
|
@@ -186,12 +284,16 @@ logger = eventLogger) => {
|
|
|
186
284
|
*
|
|
187
285
|
* This is useful when your backend is the source of truth for which passkeys
|
|
188
286
|
* should still exist for a given account on this device.
|
|
287
|
+
* Support and metadata lookup failures are thrown as {@link PruningError}.
|
|
288
|
+
* Browser-side signalling failures are logged as warnings and are not thrown.
|
|
189
289
|
*
|
|
190
290
|
* @param options Pass the passkeys you want to retain.
|
|
191
|
-
* @returns A {@link PruningSuccess} payload
|
|
291
|
+
* @returns A {@link PruningSuccess} payload once the accepted-credentials
|
|
292
|
+
* signalling attempt has completed.
|
|
192
293
|
* @see {@link isPruningError}
|
|
193
294
|
*
|
|
194
|
-
* @throws {@link PruningError}
|
|
295
|
+
* @throws {@link PruningError} if pruning support is unavailable or required
|
|
296
|
+
* credential metadata cannot be loaded
|
|
195
297
|
*
|
|
196
298
|
* @example
|
|
197
299
|
* // from your Passlock console settings
|
|
@@ -200,7 +302,7 @@ logger = eventLogger) => {
|
|
|
200
302
|
*
|
|
201
303
|
* try {
|
|
202
304
|
* const result = await prunePasskeys({ tenancyId, allowablePasskeyIds });
|
|
203
|
-
* console.log("
|
|
305
|
+
* console.log("accepted credentials sync requested", result);
|
|
204
306
|
* } catch (error) {
|
|
205
307
|
* if (isPruningError(error)) {
|
|
206
308
|
* console.log(error.code);
|
|
@@ -219,7 +321,7 @@ logger = eventLogger) => {
|
|
|
219
321
|
};
|
|
220
322
|
/* Support */
|
|
221
323
|
/**
|
|
222
|
-
* Does the local device support programmatic passkey deletion
|
|
324
|
+
* Does the local device support programmatic passkey deletion?
|
|
223
325
|
*
|
|
224
326
|
* @returns `true` if local passkey deletion is supported.
|
|
225
327
|
*
|
|
@@ -227,7 +329,7 @@ logger = eventLogger) => {
|
|
|
227
329
|
*/
|
|
228
330
|
export const isPasskeyDeleteSupport = () => pipe(isPasskeyDeleteSupportM, Micro.runSync);
|
|
229
331
|
/**
|
|
230
|
-
* Does the local device support programmatic passkey pruning
|
|
332
|
+
* Does the local device support programmatic passkey pruning?
|
|
231
333
|
*
|
|
232
334
|
* @returns `true` if local passkey pruning is supported.
|
|
233
335
|
*
|
|
@@ -235,7 +337,7 @@ export const isPasskeyDeleteSupport = () => pipe(isPasskeyDeleteSupportM, Micro.
|
|
|
235
337
|
*/
|
|
236
338
|
export const isPasskeyPruningSupport = () => pipe(isPasskeyPruningSupportM, Micro.runSync);
|
|
237
339
|
/**
|
|
238
|
-
* Does the local device support programmatic passkey updates
|
|
340
|
+
* Does the local device support programmatic passkey updates?
|
|
239
341
|
*
|
|
240
342
|
* @returns `true` if local passkey updates are supported.
|
|
241
343
|
*
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAKjD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,IAAI,oBAAoB,GAC5C,MAAM,4CAA4C,CAAA;AAKnD,OAAO,EACL,kBAAkB,EAClB,eAAe,IAAI,gBAAgB,GACpC,MAAM,wCAAwC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAKjD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,IAAI,oBAAoB,GAC5C,MAAM,4CAA4C,CAAA;AAKnD,OAAO,EACL,kBAAkB,EAClB,eAAe,IAAI,gBAAgB,GACpC,MAAM,wCAAwC,CAAA;AAY/C,OAAO,EACL,aAAa,IAAI,cAAc,EAC/B,kBAAkB,IAAI,mBAAmB,EACzC,sBAAsB,IAAI,uBAAuB,EACjD,uBAAuB,IAAI,wBAAwB,EACnD,sBAAsB,IAAI,uBAAuB,EACjD,aAAa,IAAI,cAAc,EAC/B,aAAa,IAAI,cAAc,EAC/B,sBAAsB,IAAI,uBAAuB,GAClD,MAAM,8BAA8B,CAAA;AAGrC,kBAAkB;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KA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CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE,CAC1C,IAAI,CAAC,wBAAwB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;AAE/C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE,CACzC,IAAI,CAAC,uBAAuB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;AAE9C,gBAAgB;AAEhB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,GACT,MAAM,aAAa,CAAA;AAUpB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,4CAA4C,CAAA;AAEnD,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,YAAY,EACZ,WAAW,GACZ,MAAM,qBAAqB,CAAA;AAQ5B,OAAO,EACL,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,wCAAwC,CAAA;AAa/C,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAA"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { Context, Micro } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Type guard for {@link NetworkError}.
|
|
4
|
+
*/
|
|
2
5
|
export declare const isNetworkError: (payload: unknown) => payload is NetworkError;
|
|
6
|
+
/**
|
|
7
|
+
* Error raised when a request to the Passlock API fails or returns an
|
|
8
|
+
* unexpected response payload.
|
|
9
|
+
*/
|
|
3
10
|
export declare class NetworkError extends Error {
|
|
4
11
|
readonly _tag: "@error/Network";
|
|
5
12
|
readonly message: string;
|
|
@@ -14,13 +21,19 @@ declare const Endpoint_base: Context.TagClass<Endpoint, "Endpoint", {
|
|
|
14
21
|
readonly endpoint: string;
|
|
15
22
|
}>;
|
|
16
23
|
/**
|
|
17
|
-
* Passlock API
|
|
24
|
+
* Effect service that provides the Passlock API base URL.
|
|
18
25
|
*/
|
|
19
26
|
export declare class Endpoint extends Endpoint_base {
|
|
20
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Create an {@link Endpoint} service from an optional base URL override.
|
|
30
|
+
*/
|
|
21
31
|
export declare const makeEndpoint: ({ endpoint, }: {
|
|
22
32
|
endpoint?: string;
|
|
23
33
|
}) => Endpoint["Type"];
|
|
34
|
+
/**
|
|
35
|
+
* Options for {@link makeRequest}.
|
|
36
|
+
*/
|
|
24
37
|
export type RequestOptions<A extends object, E = never> = {
|
|
25
38
|
url: URL;
|
|
26
39
|
/** Request payload */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/internal/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEvC,eAAO,MAAM,cAAc,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,YAI5D,CAAA;AAED,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAG,gBAAgB,CAAS;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;gBAER,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAM9D,MAAM,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/internal/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEvC;;GAEG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AC,CAAC,EAAE,CAAC,GAAG,YAAY,CA0ErD,CAAA"}
|
package/dist/internal/network.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Context, Micro } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Type guard for {@link NetworkError}.
|
|
4
|
+
*/
|
|
2
5
|
export const isNetworkError = (payload) => {
|
|
3
6
|
if (typeof payload !== "object")
|
|
4
7
|
return false;
|
|
@@ -6,6 +9,10 @@ export const isNetworkError = (payload) => {
|
|
|
6
9
|
return false;
|
|
7
10
|
return payload instanceof NetworkError;
|
|
8
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Error raised when a request to the Passlock API fails or returns an
|
|
14
|
+
* unexpected response payload.
|
|
15
|
+
*/
|
|
9
16
|
export class NetworkError extends Error {
|
|
10
17
|
_tag = "@error/Network";
|
|
11
18
|
message;
|
|
@@ -28,10 +35,13 @@ export class NetworkError extends Error {
|
|
|
28
35
|
*/
|
|
29
36
|
const DEFAULT_ENDPOINT = "https://api.passlock.dev";
|
|
30
37
|
/**
|
|
31
|
-
* Passlock API
|
|
38
|
+
* Effect service that provides the Passlock API base URL.
|
|
32
39
|
*/
|
|
33
40
|
export class Endpoint extends Context.Tag("Endpoint")() {
|
|
34
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Create an {@link Endpoint} service from an optional base URL override.
|
|
44
|
+
*/
|
|
35
45
|
export const makeEndpoint = ({ endpoint = DEFAULT_ENDPOINT, }) => Endpoint.of({ endpoint });
|
|
36
46
|
const isErrorResponse = (payload) => {
|
|
37
47
|
if (typeof payload !== "object")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/internal/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEvC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAgB,EAA2B,EAAE;IAC1E,IAAI,OAAO,OA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ACH,CAAC;SAAM,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAA;QAChE,OAAO,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CACtB,IAAI,YAAY,CAAC;YACf,OAAO;YACP,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC;SACjB,CAAC,CACH,CAAA;IACH,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;QACnC,GAAG,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,EAAsB;QACnD,KAAK,EAAE,GAAG,EAAE,CAAC,UAAU;KACxB,CAAC,CAAA;IAEF,OAAO,iBAAiB,CAAC,IAAI,CAAC;QAC5B,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;AAC/C,CAAC,CAAC,CAAA"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Micro } from "effect";
|
|
2
|
+
import { type Result } from "./result.js";
|
|
2
3
|
/**
|
|
3
|
-
* Run a Micro and return a
|
|
4
|
+
* Run a Micro and return a result envelope containing either
|
|
5
|
+
* the successful value or the expected error value.
|
|
6
|
+
*
|
|
4
7
|
* Note: function could still throw for an unexpected error.
|
|
8
|
+
*
|
|
5
9
|
* @param micro
|
|
6
|
-
* @returns Promise resolving to
|
|
10
|
+
* @returns Promise resolving to a result envelope.
|
|
7
11
|
*/
|
|
8
|
-
export declare const runToPromise: <A, E>(micro: Micro.Micro<A, E>) => Promise<A
|
|
12
|
+
export declare const runToPromise: <A extends object, E extends object>(micro: Micro.Micro<A, E>) => Promise<Result<A, E>>;
|
|
9
13
|
/**
|
|
10
14
|
* Run a Micro and return a success or throw an error
|
|
11
15
|
* @param micro
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../src/internal/promise.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../src/internal/promise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAQ,MAAM,QAAQ,CAAA;AAE5C,OAAO,EAAE,KAAK,MAAM,EAA2B,MAAM,aAAa,CAAA;AAElE;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GAAU,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EACnE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KACvB,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAOtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAU,CAAC,EAAE,CAAC,EAC3C,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KACvB,OAAO,CAAC,CAAC,CAqBX,CAAA"}
|