@passlock/node 2.0.7 → 2.1.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 +1 -114
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -108
- package/dist/index.js.map +1 -1
- package/dist/safe.d.ts +1 -153
- package/dist/safe.d.ts.map +1 -1
- package/dist/safe.js +8 -146
- package/dist/safe.js.map +1 -1
- package/package.json +9 -14
- package/dist/effect.d.ts +0 -7
- package/dist/effect.d.ts.map +0 -1
- package/dist/effect.js +0 -4
- package/dist/effect.js.map +0 -1
- package/dist/errors.d.ts +0 -71
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -30
- package/dist/errors.js.map +0 -1
- package/dist/network.d.ts +0 -134
- package/dist/network.d.ts.map +0 -1
- package/dist/network.js +0 -172
- package/dist/network.js.map +0 -1
- package/dist/passkey/passkey.d.ts +0 -132
- package/dist/passkey/passkey.d.ts.map +0 -1
- package/dist/passkey/passkey.js +0 -158
- package/dist/passkey/passkey.js.map +0 -1
- package/dist/principal/principal.d.ts +0 -22
- package/dist/principal/principal.d.ts.map +0 -1
- package/dist/principal/principal.js +0 -65
- package/dist/principal/principal.js.map +0 -1
- package/dist/schemas/errors.d.ts +0 -2
- package/dist/schemas/errors.d.ts.map +0 -1
- package/dist/schemas/errors.js +0 -72
- package/dist/schemas/errors.js.map +0 -1
- package/dist/schemas/index.d.ts +0 -5
- package/dist/schemas/index.d.ts.map +0 -1
- package/dist/schemas/index.js +0 -5
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/passkey.d.ts +0 -85
- package/dist/schemas/passkey.d.ts.map +0 -1
- package/dist/schemas/passkey.js +0 -64
- package/dist/schemas/passkey.js.map +0 -1
- package/dist/schemas/principal.d.ts +0 -88
- package/dist/schemas/principal.d.ts.map +0 -1
- package/dist/schemas/principal.js +0 -46
- package/dist/schemas/principal.js.map +0 -1
- package/dist/schemas/satisfy.d.ts +0 -2
- package/dist/schemas/satisfy.d.ts.map +0 -1
- package/dist/schemas/satisfy.js +0 -2
- package/dist/schemas/satisfy.js.map +0 -1
- package/dist/schemas/signup.d.ts +0 -13
- package/dist/schemas/signup.d.ts.map +0 -1
- package/dist/schemas/signup.js +0 -11
- package/dist/schemas/signup.js.map +0 -1
- package/dist/shared.d.ts +0 -19
- package/dist/shared.d.ts.map +0 -1
- package/dist/shared.js +0 -9
- package/dist/shared.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,115 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Unsafe functions that could potentially throw errors.
|
|
3
|
-
*
|
|
4
|
-
* @categoryDescription Passkeys
|
|
5
|
-
* Functions and related types for managing passkeys
|
|
6
|
-
*
|
|
7
|
-
* @showCategories
|
|
8
|
-
*
|
|
9
|
-
* @module unsafe
|
|
10
|
-
*/
|
|
11
|
-
import type { AssignUserOptions, DeletePasskeyOptions, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey, UpdatedPasskeyUsernames, UpdatePasskeyOptions, UpdatePasskeyUsernamesOptions } from "./passkey/passkey.js";
|
|
12
|
-
import type { ExchangeCodeOptions, VerifyIdTokenOptions } from "./principal/principal.js";
|
|
13
|
-
import type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
|
|
14
|
-
/**
|
|
15
|
-
* Call the Passlock backend API to assign a userId to an authenticator
|
|
16
|
-
*
|
|
17
|
-
* @param request
|
|
18
|
-
* @returns A promise resolving to the updated passkey.
|
|
19
|
-
* @throws {@link NotFoundError} if passkey does not exist
|
|
20
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
21
|
-
*
|
|
22
|
-
* @category Passkeys
|
|
23
|
-
*/
|
|
24
|
-
export declare const assignUser: (request: AssignUserOptions) => Promise<Passkey>;
|
|
25
|
-
/**
|
|
26
|
-
* Call the Passlock backend API to update passkey properties
|
|
27
|
-
*
|
|
28
|
-
* @param request
|
|
29
|
-
* @returns A promise resolving to the updated passkey.
|
|
30
|
-
* @throws {@link NotFoundError} if passkey does not exist
|
|
31
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
32
|
-
*
|
|
33
|
-
* @category Passkeys
|
|
34
|
-
*/
|
|
35
|
-
export declare const updatePasskey: (request: UpdatePasskeyOptions) => Promise<Passkey>;
|
|
36
|
-
/**
|
|
37
|
-
* Call the Passlock backend API to update all passkeys for a given user
|
|
38
|
-
*
|
|
39
|
-
* @param request
|
|
40
|
-
* @returns A promise resolving to updated usernames for matching passkeys.
|
|
41
|
-
* @throws {@link NotFoundError} if no passkeys are found for the given user
|
|
42
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
43
|
-
*
|
|
44
|
-
* @category Passkeys
|
|
45
|
-
*/
|
|
46
|
-
export declare const updatePasskeyUsernames: (request: UpdatePasskeyUsernamesOptions) => Promise<UpdatedPasskeyUsernames>;
|
|
47
|
-
/**
|
|
48
|
-
* Call the Passlock backend API to delete an authenticator
|
|
49
|
-
*
|
|
50
|
-
* @param options
|
|
51
|
-
* @returns A promise resolving to the deleted passkey.
|
|
52
|
-
* @throws {@link NotFoundError} if passkey does not exist
|
|
53
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
54
|
-
*
|
|
55
|
-
* @category Passkeys
|
|
56
|
-
*/
|
|
57
|
-
export declare const deletePasskey: (options: DeletePasskeyOptions) => Promise<Passkey>;
|
|
58
|
-
/**
|
|
59
|
-
* Call the Passlock backend API to fetch an authenticator
|
|
60
|
-
*
|
|
61
|
-
* @param options
|
|
62
|
-
* @returns A promise resolving to the passkey.
|
|
63
|
-
* @throws {@link NotFoundError} if passkey does not exist
|
|
64
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
65
|
-
*
|
|
66
|
-
* @category Passkeys
|
|
67
|
-
*/
|
|
68
|
-
export declare const getPasskey: (options: GetPasskeyOptions) => Promise<Passkey>;
|
|
69
|
-
/**
|
|
70
|
-
* List passkeys for the given tenancy. Note this could return a cursor,
|
|
71
|
-
* in which case the function should be called again with the given cursor.
|
|
72
|
-
*
|
|
73
|
-
* @param options
|
|
74
|
-
* @returns A promise resolving to a page of passkey summaries.
|
|
75
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
76
|
-
*
|
|
77
|
-
* @category Passkeys
|
|
78
|
-
*/
|
|
79
|
-
export declare const listPasskeys: (options: ListPasskeyOptions) => Promise<FindAllPasskeys>;
|
|
80
|
-
/**
|
|
81
|
-
* Call the Passlock backend API to exchange a code for an ExtendedPrincipal
|
|
82
|
-
*
|
|
83
|
-
* @param options
|
|
84
|
-
* @returns A promise resolving to an extended principal.
|
|
85
|
-
* @throws {@link InvalidCodeError} if the code is invalid or expired
|
|
86
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
87
|
-
*
|
|
88
|
-
* @category Principal
|
|
89
|
-
*/
|
|
90
|
-
export declare const exchangeCode: (options: ExchangeCodeOptions) => Promise<ExtendedPrincipal>;
|
|
91
|
-
/**
|
|
92
|
-
* Decode and verify a Passlock `id_token` (JWT).
|
|
93
|
-
* Note: This will make a network call to
|
|
94
|
-
* `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)
|
|
95
|
-
* to fetch the relevant public key. The response will be cached, however
|
|
96
|
-
* bear in mind that for something like AWS Lambda it will make the call on every
|
|
97
|
-
* cold start so might actually be slower than {@link exchangeCode}
|
|
98
|
-
*
|
|
99
|
-
* @param options
|
|
100
|
-
* @returns A promise resolving to the verified principal.
|
|
101
|
-
* @throws {@link VerificationError} if token verification fails
|
|
102
|
-
*
|
|
103
|
-
* @category Principal
|
|
104
|
-
*/
|
|
105
|
-
export declare const verifyIdToken: (options: VerifyIdTokenOptions) => Promise<Principal>;
|
|
106
|
-
export type { BadRequestError, DuplicateEmailError, ForbiddenError, InvalidCodeError, InvalidEmailError, InvalidTenancyError, NotFoundError, PasskeyNotFoundError, UnauthorizedError, VerificationError, } from "./errors.js";
|
|
107
|
-
export { isBadRequestError, isDuplicateEmailError, isForbiddenError, isInvalidCodeError, isInvalidEmailError, isInvalidTenancyError, isNotFoundError, isPasskeyNotFoundError, isUnauthorizedError, isVerificationError, } from "./errors.js";
|
|
108
|
-
export type { AssignUserOptions, Credential, DeletePasskeyOptions, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey, PasskeySummary, Platform, UpdatedPasskeys, UpdatedPasskeyUsernames, UpdatePasskeyOptions, UpdatePasskeyUsernamesOptions, } from "./passkey/passkey.js";
|
|
109
|
-
export { isPasskey, isPasskeySummary, isUpdatedPasskeys, isUpdatedPasskeyUsernames, } from "./passkey/passkey.js";
|
|
110
|
-
export type { ExchangeCodeOptions, VerifyIdTokenOptions, } from "./principal/principal.js";
|
|
111
|
-
export type { CredentialDeviceType, Transports, } from "./schemas/passkey.js";
|
|
112
|
-
export type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
|
|
113
|
-
export { isExtendedPrincipal, isPrincipal } from "./schemas/principal.js";
|
|
114
|
-
export type { AuthenticatedOptions, PasslockOptions, } from "./shared.js";
|
|
1
|
+
export {};
|
|
115
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -1,109 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* @module unsafe
|
|
10
|
-
*/
|
|
11
|
-
import { Effect, pipe } from "effect";
|
|
12
|
-
import { assignUser as assignUserE, deletePasskey as deletePasskeyE, getPasskey as getPasskeyE, listPasskeys as listPasskeysE, updatePasskey as updatePasskeyE, updatePasskeyUsernames as updatePasskeyUsernamesE, } from "./passkey/passkey.js";
|
|
13
|
-
import { exchangeCode as exchangeCodeE, verifyIdToken as verifyIdTokenE, } from "./principal/principal.js";
|
|
14
|
-
/**
|
|
15
|
-
* Call the Passlock backend API to assign a userId to an authenticator
|
|
16
|
-
*
|
|
17
|
-
* @param request
|
|
18
|
-
* @returns A promise resolving to the updated passkey.
|
|
19
|
-
* @throws {@link NotFoundError} if passkey does not exist
|
|
20
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
21
|
-
*
|
|
22
|
-
* @category Passkeys
|
|
23
|
-
*/
|
|
24
|
-
export const assignUser = (request) => pipe(assignUserE(request), Effect.runPromise);
|
|
25
|
-
/**
|
|
26
|
-
* Call the Passlock backend API to update passkey properties
|
|
27
|
-
*
|
|
28
|
-
* @param request
|
|
29
|
-
* @returns A promise resolving to the updated passkey.
|
|
30
|
-
* @throws {@link NotFoundError} if passkey does not exist
|
|
31
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
32
|
-
*
|
|
33
|
-
* @category Passkeys
|
|
34
|
-
*/
|
|
35
|
-
export const updatePasskey = (request) => pipe(updatePasskeyE(request), Effect.runPromise);
|
|
36
|
-
/**
|
|
37
|
-
* Call the Passlock backend API to update all passkeys for a given user
|
|
38
|
-
*
|
|
39
|
-
* @param request
|
|
40
|
-
* @returns A promise resolving to updated usernames for matching passkeys.
|
|
41
|
-
* @throws {@link NotFoundError} if no passkeys are found for the given user
|
|
42
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
43
|
-
*
|
|
44
|
-
* @category Passkeys
|
|
45
|
-
*/
|
|
46
|
-
export const updatePasskeyUsernames = (request) => pipe(updatePasskeyUsernamesE(request), Effect.runPromise);
|
|
47
|
-
/**
|
|
48
|
-
* Call the Passlock backend API to delete an authenticator
|
|
49
|
-
*
|
|
50
|
-
* @param options
|
|
51
|
-
* @returns A promise resolving to the deleted passkey.
|
|
52
|
-
* @throws {@link NotFoundError} if passkey does not exist
|
|
53
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
54
|
-
*
|
|
55
|
-
* @category Passkeys
|
|
56
|
-
*/
|
|
57
|
-
export const deletePasskey = (options) => pipe(deletePasskeyE(options), Effect.runPromise);
|
|
58
|
-
/**
|
|
59
|
-
* Call the Passlock backend API to fetch an authenticator
|
|
60
|
-
*
|
|
61
|
-
* @param options
|
|
62
|
-
* @returns A promise resolving to the passkey.
|
|
63
|
-
* @throws {@link NotFoundError} if passkey does not exist
|
|
64
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
65
|
-
*
|
|
66
|
-
* @category Passkeys
|
|
67
|
-
*/
|
|
68
|
-
export const getPasskey = (options) => pipe(getPasskeyE(options), Effect.runPromise);
|
|
69
|
-
/**
|
|
70
|
-
* List passkeys for the given tenancy. Note this could return a cursor,
|
|
71
|
-
* in which case the function should be called again with the given cursor.
|
|
72
|
-
*
|
|
73
|
-
* @param options
|
|
74
|
-
* @returns A promise resolving to a page of passkey summaries.
|
|
75
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
76
|
-
*
|
|
77
|
-
* @category Passkeys
|
|
78
|
-
*/
|
|
79
|
-
export const listPasskeys = (options) => pipe(listPasskeysE(options), Effect.runPromise);
|
|
80
|
-
/**
|
|
81
|
-
* Call the Passlock backend API to exchange a code for an ExtendedPrincipal
|
|
82
|
-
*
|
|
83
|
-
* @param options
|
|
84
|
-
* @returns A promise resolving to an extended principal.
|
|
85
|
-
* @throws {@link InvalidCodeError} if the code is invalid or expired
|
|
86
|
-
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
87
|
-
*
|
|
88
|
-
* @category Principal
|
|
89
|
-
*/
|
|
90
|
-
export const exchangeCode = (options) => pipe(exchangeCodeE(options), Effect.runPromise);
|
|
91
|
-
/**
|
|
92
|
-
* Decode and verify a Passlock `id_token` (JWT).
|
|
93
|
-
* Note: This will make a network call to
|
|
94
|
-
* `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)
|
|
95
|
-
* to fetch the relevant public key. The response will be cached, however
|
|
96
|
-
* bear in mind that for something like AWS Lambda it will make the call on every
|
|
97
|
-
* cold start so might actually be slower than {@link exchangeCode}
|
|
98
|
-
*
|
|
99
|
-
* @param options
|
|
100
|
-
* @returns A promise resolving to the verified principal.
|
|
101
|
-
* @throws {@link VerificationError} if token verification fails
|
|
102
|
-
*
|
|
103
|
-
* @category Principal
|
|
104
|
-
*/
|
|
105
|
-
export const verifyIdToken = (options) => pipe(verifyIdTokenE(options), Effect.runPromise);
|
|
106
|
-
export { isBadRequestError, isDuplicateEmailError, isForbiddenError, isInvalidCodeError, isInvalidEmailError, isInvalidTenancyError, isNotFoundError, isPasskeyNotFoundError, isUnauthorizedError, isVerificationError, } from "./errors.js";
|
|
107
|
-
export { isPasskey, isPasskeySummary, isUpdatedPasskeys, isUpdatedPasskeyUsernames, } from "./passkey/passkey.js";
|
|
108
|
-
export { isExtendedPrincipal, isPrincipal } from "./schemas/principal.js";
|
|
1
|
+
const isProd = process.env.NODE_ENV === "production";
|
|
2
|
+
const warnedKey = Symbol.for("passlock.node.deprecation.warned");
|
|
3
|
+
const g = globalThis;
|
|
4
|
+
if (!isProd && !g[warnedKey]) {
|
|
5
|
+
g[warnedKey] = true;
|
|
6
|
+
console.warn("[DEPRECATED] @passlock/node has been renamed to @passlock/server. Please update your imports.");
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
109
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;AAErD,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAMjE,MAAM,CAAC,GAAG,UAAgC,CAAC;AAE3C,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC;IAC7B,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IAEpB,OAAO,CAAC,IAAI,CACV,+FAA+F,CAChG,CAAC;AACJ,CAAC","sourcesContent":["const isProd = process.env.NODE_ENV === \"production\";\n\nconst warnedKey = Symbol.for(\"passlock.node.deprecation.warned\");\n\ntype GlobalWithWarnFlag = typeof globalThis & {\n [warnedKey]?: boolean;\n};\n\nconst g = globalThis as GlobalWithWarnFlag;\n\nif (!isProd && !g[warnedKey]) {\n g[warnedKey] = true;\n\n console.warn(\n \"[DEPRECATED] @passlock/node has been renamed to @passlock/server. Please update your imports.\"\n );\n}"]}
|
package/dist/safe.d.ts
CHANGED
|
@@ -1,154 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Safe functions that return discriminated unions representing
|
|
3
|
-
* the successful outcome or expected failures.
|
|
4
|
-
*
|
|
5
|
-
* Note: unexpected runtime failures may still throw.
|
|
6
|
-
*
|
|
7
|
-
* @categoryDescription Passkeys
|
|
8
|
-
* Functions and related types for managing passkeys
|
|
9
|
-
*
|
|
10
|
-
* @showCategories
|
|
11
|
-
*
|
|
12
|
-
* @module safe
|
|
13
|
-
*/
|
|
14
|
-
import type { ForbiddenError, InvalidCodeError, NotFoundError, VerificationError } from "./errors.js";
|
|
15
|
-
import type { AssignUserOptions, DeletePasskeyOptions, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey, UpdatedPasskeyUsernames, UpdatePasskeyOptions, UpdatePasskeyUsernamesOptions } from "./passkey/passkey.js";
|
|
16
|
-
import type { ExchangeCodeOptions, VerifyIdTokenOptions } from "./principal/principal.js";
|
|
17
|
-
import type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
|
|
18
|
-
/**
|
|
19
|
-
* Assign a custom User ID to a passkey. Will be reflected in the next
|
|
20
|
-
* {@link Principal} or {@link ExtendedPrincipal} generated.
|
|
21
|
-
*
|
|
22
|
-
* **Note:** This does not change the underlying WebAuthn credential's `userId`.
|
|
23
|
-
* Instead we apply a layer of indirection.
|
|
24
|
-
*
|
|
25
|
-
* @see {@link Principal}
|
|
26
|
-
* @see {@link ExtendedPrincipal}
|
|
27
|
-
* @see [credential](https://passlock.dev/rest-api/credential/)
|
|
28
|
-
*
|
|
29
|
-
* @param request
|
|
30
|
-
* @returns A promise resolving to either a passkey or an API error.
|
|
31
|
-
*
|
|
32
|
-
* @category Passkeys
|
|
33
|
-
*/
|
|
34
|
-
export declare const assignUser: (request: AssignUserOptions) => Promise<Passkey | NotFoundError | ForbiddenError>;
|
|
35
|
-
/**
|
|
36
|
-
* Can also be used to assign a custom User ID, but also allows you to update
|
|
37
|
-
* the username.
|
|
38
|
-
*
|
|
39
|
-
* **Important:** changing the username has no bearing on authentication, as
|
|
40
|
-
* it's typically only used in the client-side component of the passkey
|
|
41
|
-
* (so the user knows which account the passkey relates to).
|
|
42
|
-
*
|
|
43
|
-
* However you might choose to align the username in your vault with the
|
|
44
|
-
* client-side component to simplify end user support.
|
|
45
|
-
*
|
|
46
|
-
* @param request
|
|
47
|
-
* @returns A promise resolving to either a passkey or an API error.
|
|
48
|
-
*
|
|
49
|
-
* @category Passkeys
|
|
50
|
-
*/
|
|
51
|
-
export declare const updatePasskey: (request: UpdatePasskeyOptions) => Promise<Passkey | NotFoundError | ForbiddenError>;
|
|
52
|
-
/**
|
|
53
|
-
* Update the username for all passkeys belonging to a given user.
|
|
54
|
-
*
|
|
55
|
-
* **Important:** changing the username has no bearing on authentication, as
|
|
56
|
-
* it's typically only used in the client-side component of the passkey
|
|
57
|
-
* (so the user knows which account the passkey relates to).
|
|
58
|
-
*
|
|
59
|
-
* However you might choose to align the username in your vault with the
|
|
60
|
-
* client-side component to simplify end user support.
|
|
61
|
-
*
|
|
62
|
-
* @param request
|
|
63
|
-
* @returns A promise resolving to either updated passkey usernames or an API error.
|
|
64
|
-
*
|
|
65
|
-
* @category Passkeys
|
|
66
|
-
*/
|
|
67
|
-
export declare const updatePasskeyUsernames: (request: UpdatePasskeyUsernamesOptions) => Promise<UpdatedPasskeyUsernames | NotFoundError | ForbiddenError>;
|
|
68
|
-
/**
|
|
69
|
-
* Delete a passkey from your vault.
|
|
70
|
-
*
|
|
71
|
-
* **Note:** The user will still retain the passkey on their device so
|
|
72
|
-
* you will need to either:
|
|
73
|
-
*
|
|
74
|
-
* a) Use the @passlock/client functions to delete the passkey from the user's device.
|
|
75
|
-
* b) Remind the user to delete the passkey
|
|
76
|
-
*
|
|
77
|
-
* See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) in the documentation.
|
|
78
|
-
*
|
|
79
|
-
* In addition, during authentication you should handle a missing passkey scenario.
|
|
80
|
-
* This happens when a user tries to authenticate with a passkey that is missing from
|
|
81
|
-
* your vault. The @passlock/client library can help with this. See
|
|
82
|
-
* [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)
|
|
83
|
-
*
|
|
84
|
-
* @see [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/)
|
|
85
|
-
* @see [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)
|
|
86
|
-
*
|
|
87
|
-
* @param options
|
|
88
|
-
* @returns A promise resolving to either the deleted passkey or an API error.
|
|
89
|
-
*
|
|
90
|
-
* @category Passkeys
|
|
91
|
-
*/
|
|
92
|
-
export declare const deletePasskey: (options: DeletePasskeyOptions) => Promise<Passkey | ForbiddenError | NotFoundError>;
|
|
93
|
-
/**
|
|
94
|
-
* Fetch details about a passkey. **Important**: Not to be confused with
|
|
95
|
-
* the {@link exchangeCode} or {@link verifyIdToken} functions, which
|
|
96
|
-
* return details about specific authentication or registration operations.
|
|
97
|
-
* Use this function for passkey management, not authentication.
|
|
98
|
-
*
|
|
99
|
-
* @param options
|
|
100
|
-
* @returns A promise resolving to either passkey details or an API error.
|
|
101
|
-
*
|
|
102
|
-
* @category Passkeys
|
|
103
|
-
*/
|
|
104
|
-
export declare const getPasskey: (options: GetPasskeyOptions) => Promise<Passkey | ForbiddenError | NotFoundError>;
|
|
105
|
-
/**
|
|
106
|
-
* List passkeys for the given tenancy. Note: This could return a cursor.
|
|
107
|
-
* If so, call again, passing the cursor back in.
|
|
108
|
-
*
|
|
109
|
-
* @param options
|
|
110
|
-
* @returns A promise resolving to a page of passkey summaries or an API error.
|
|
111
|
-
*
|
|
112
|
-
* @category Passkeys
|
|
113
|
-
*/
|
|
114
|
-
export declare const listPasskeys: (options: ListPasskeyOptions) => Promise<FindAllPasskeys | ForbiddenError>;
|
|
115
|
-
/**
|
|
116
|
-
* The @passlock/client library generates codes, which you should send to
|
|
117
|
-
* your backend. Use this function to exchange the code for details about
|
|
118
|
-
* the registration or authentication operation. **Note:** a code is valid
|
|
119
|
-
* for 5 minutes.
|
|
120
|
-
*
|
|
121
|
-
* @see {@link ExtendedPrincipal}
|
|
122
|
-
*
|
|
123
|
-
* @param options
|
|
124
|
-
* @returns A promise resolving to an extended principal or an API error.
|
|
125
|
-
*
|
|
126
|
-
* @category Principal
|
|
127
|
-
*/
|
|
128
|
-
export declare const exchangeCode: (options: ExchangeCodeOptions) => Promise<ExtendedPrincipal | ForbiddenError | InvalidCodeError>;
|
|
129
|
-
/**
|
|
130
|
-
* Decode and verify an id_token (JWT) locally.
|
|
131
|
-
* **Note:** This will make a network call to
|
|
132
|
-
* `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)
|
|
133
|
-
* to fetch the relevant public key. The response will be cached, however
|
|
134
|
-
* bear in mind that for something like AWS Lambda it will make the call on every
|
|
135
|
-
* cold start so might actually be slower than {@link exchangeCode}
|
|
136
|
-
*
|
|
137
|
-
* @see {@link Principal}
|
|
138
|
-
*
|
|
139
|
-
* @param options
|
|
140
|
-
* @returns A promise resolving to a verified principal or verification failure.
|
|
141
|
-
*
|
|
142
|
-
* @category Principal
|
|
143
|
-
*/
|
|
144
|
-
export declare const verifyIdToken: (options: VerifyIdTokenOptions) => Promise<Principal | VerificationError>;
|
|
145
|
-
export type { BadRequestError, DuplicateEmailError, ForbiddenError, InvalidCodeError, InvalidEmailError, InvalidTenancyError, NotFoundError, PasskeyNotFoundError, UnauthorizedError, VerificationError, } from "./errors.js";
|
|
146
|
-
export { isBadRequestError, isDuplicateEmailError, isForbiddenError, isInvalidCodeError, isInvalidEmailError, isInvalidTenancyError, isNotFoundError, isPasskeyNotFoundError, isUnauthorizedError, isVerificationError, } from "./errors.js";
|
|
147
|
-
export type { AssignUserOptions, Credential, DeletePasskeyOptions, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey, PasskeySummary, Platform, UpdatedPasskeys, UpdatedPasskeyUsernames, UpdatePasskeyOptions, UpdatePasskeyUsernamesOptions, } from "./passkey/passkey.js";
|
|
148
|
-
export { isPasskey, isPasskeySummary, isUpdatedPasskeys, isUpdatedPasskeyUsernames, } from "./passkey/passkey.js";
|
|
149
|
-
export type { ExchangeCodeOptions, VerifyIdTokenOptions, } from "./principal/principal.js";
|
|
150
|
-
export type { CredentialDeviceType, Transports, } from "./schemas/passkey.js";
|
|
151
|
-
export type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
|
|
152
|
-
export { isExtendedPrincipal, isPrincipal } from "./schemas/principal.js";
|
|
153
|
-
export type { AuthenticatedOptions, PasslockOptions, } from "./shared.js";
|
|
1
|
+
export {};
|
|
154
2
|
//# sourceMappingURL=safe.d.ts.map
|
package/dist/safe.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../src/safe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../src/safe.ts"],"names":[],"mappings":""}
|
package/dist/safe.js
CHANGED
|
@@ -1,147 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* @showCategories
|
|
11
|
-
*
|
|
12
|
-
* @module safe
|
|
13
|
-
*/
|
|
14
|
-
import { Effect, identity, pipe } from "effect";
|
|
15
|
-
import { assignUser as assignUserE, deletePasskey as deletePasskeyE, getPasskey as getPasskeyE, listPasskeys as listPasskeysE, updatePasskey as updatePasskeyE, updatePasskeyUsernames as updatePasskeyUsernamesE, } from "./passkey/passkey.js";
|
|
16
|
-
import { exchangeCode as exchangeCodeE, verifyIdToken as verifyIdTokenE, } from "./principal/principal.js";
|
|
17
|
-
/**
|
|
18
|
-
* Assign a custom User ID to a passkey. Will be reflected in the next
|
|
19
|
-
* {@link Principal} or {@link ExtendedPrincipal} generated.
|
|
20
|
-
*
|
|
21
|
-
* **Note:** This does not change the underlying WebAuthn credential's `userId`.
|
|
22
|
-
* Instead we apply a layer of indirection.
|
|
23
|
-
*
|
|
24
|
-
* @see {@link Principal}
|
|
25
|
-
* @see {@link ExtendedPrincipal}
|
|
26
|
-
* @see [credential](https://passlock.dev/rest-api/credential/)
|
|
27
|
-
*
|
|
28
|
-
* @param request
|
|
29
|
-
* @returns A promise resolving to either a passkey or an API error.
|
|
30
|
-
*
|
|
31
|
-
* @category Passkeys
|
|
32
|
-
*/
|
|
33
|
-
export const assignUser = (request) => pipe(assignUserE(request), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
|
|
34
|
-
/**
|
|
35
|
-
* Can also be used to assign a custom User ID, but also allows you to update
|
|
36
|
-
* the username.
|
|
37
|
-
*
|
|
38
|
-
* **Important:** changing the username has no bearing on authentication, as
|
|
39
|
-
* it's typically only used in the client-side component of the passkey
|
|
40
|
-
* (so the user knows which account the passkey relates to).
|
|
41
|
-
*
|
|
42
|
-
* However you might choose to align the username in your vault with the
|
|
43
|
-
* client-side component to simplify end user support.
|
|
44
|
-
*
|
|
45
|
-
* @param request
|
|
46
|
-
* @returns A promise resolving to either a passkey or an API error.
|
|
47
|
-
*
|
|
48
|
-
* @category Passkeys
|
|
49
|
-
*/
|
|
50
|
-
export const updatePasskey = (request) => pipe(updatePasskeyE(request), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
|
|
51
|
-
/**
|
|
52
|
-
* Update the username for all passkeys belonging to a given user.
|
|
53
|
-
*
|
|
54
|
-
* **Important:** changing the username has no bearing on authentication, as
|
|
55
|
-
* it's typically only used in the client-side component of the passkey
|
|
56
|
-
* (so the user knows which account the passkey relates to).
|
|
57
|
-
*
|
|
58
|
-
* However you might choose to align the username in your vault with the
|
|
59
|
-
* client-side component to simplify end user support.
|
|
60
|
-
*
|
|
61
|
-
* @param request
|
|
62
|
-
* @returns A promise resolving to either updated passkey usernames or an API error.
|
|
63
|
-
*
|
|
64
|
-
* @category Passkeys
|
|
65
|
-
*/
|
|
66
|
-
export const updatePasskeyUsernames = (request) => pipe(updatePasskeyUsernamesE(request), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
|
|
67
|
-
/**
|
|
68
|
-
* Delete a passkey from your vault.
|
|
69
|
-
*
|
|
70
|
-
* **Note:** The user will still retain the passkey on their device so
|
|
71
|
-
* you will need to either:
|
|
72
|
-
*
|
|
73
|
-
* a) Use the @passlock/client functions to delete the passkey from the user's device.
|
|
74
|
-
* b) Remind the user to delete the passkey
|
|
75
|
-
*
|
|
76
|
-
* See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) in the documentation.
|
|
77
|
-
*
|
|
78
|
-
* In addition, during authentication you should handle a missing passkey scenario.
|
|
79
|
-
* This happens when a user tries to authenticate with a passkey that is missing from
|
|
80
|
-
* your vault. The @passlock/client library can help with this. See
|
|
81
|
-
* [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)
|
|
82
|
-
*
|
|
83
|
-
* @see [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/)
|
|
84
|
-
* @see [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)
|
|
85
|
-
*
|
|
86
|
-
* @param options
|
|
87
|
-
* @returns A promise resolving to either the deleted passkey or an API error.
|
|
88
|
-
*
|
|
89
|
-
* @category Passkeys
|
|
90
|
-
*/
|
|
91
|
-
export const deletePasskey = (options) => pipe(deletePasskeyE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
|
|
92
|
-
/**
|
|
93
|
-
* Fetch details about a passkey. **Important**: Not to be confused with
|
|
94
|
-
* the {@link exchangeCode} or {@link verifyIdToken} functions, which
|
|
95
|
-
* return details about specific authentication or registration operations.
|
|
96
|
-
* Use this function for passkey management, not authentication.
|
|
97
|
-
*
|
|
98
|
-
* @param options
|
|
99
|
-
* @returns A promise resolving to either passkey details or an API error.
|
|
100
|
-
*
|
|
101
|
-
* @category Passkeys
|
|
102
|
-
*/
|
|
103
|
-
export const getPasskey = (options) => pipe(getPasskeyE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
|
|
104
|
-
/**
|
|
105
|
-
* List passkeys for the given tenancy. Note: This could return a cursor.
|
|
106
|
-
* If so, call again, passing the cursor back in.
|
|
107
|
-
*
|
|
108
|
-
* @param options
|
|
109
|
-
* @returns A promise resolving to a page of passkey summaries or an API error.
|
|
110
|
-
*
|
|
111
|
-
* @category Passkeys
|
|
112
|
-
*/
|
|
113
|
-
export const listPasskeys = (options) => pipe(listPasskeysE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
|
|
114
|
-
/**
|
|
115
|
-
* The @passlock/client library generates codes, which you should send to
|
|
116
|
-
* your backend. Use this function to exchange the code for details about
|
|
117
|
-
* the registration or authentication operation. **Note:** a code is valid
|
|
118
|
-
* for 5 minutes.
|
|
119
|
-
*
|
|
120
|
-
* @see {@link ExtendedPrincipal}
|
|
121
|
-
*
|
|
122
|
-
* @param options
|
|
123
|
-
* @returns A promise resolving to an extended principal or an API error.
|
|
124
|
-
*
|
|
125
|
-
* @category Principal
|
|
126
|
-
*/
|
|
127
|
-
export const exchangeCode = (options) => pipe(exchangeCodeE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
|
|
128
|
-
/**
|
|
129
|
-
* Decode and verify an id_token (JWT) locally.
|
|
130
|
-
* **Note:** This will make a network call to
|
|
131
|
-
* `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)
|
|
132
|
-
* to fetch the relevant public key. The response will be cached, however
|
|
133
|
-
* bear in mind that for something like AWS Lambda it will make the call on every
|
|
134
|
-
* cold start so might actually be slower than {@link exchangeCode}
|
|
135
|
-
*
|
|
136
|
-
* @see {@link Principal}
|
|
137
|
-
*
|
|
138
|
-
* @param options
|
|
139
|
-
* @returns A promise resolving to a verified principal or verification failure.
|
|
140
|
-
*
|
|
141
|
-
* @category Principal
|
|
142
|
-
*/
|
|
143
|
-
export const verifyIdToken = (options) => pipe(verifyIdTokenE(options), Effect.match({ onFailure: identity, onSuccess: identity }), Effect.runPromise);
|
|
144
|
-
export { isBadRequestError, isDuplicateEmailError, isForbiddenError, isInvalidCodeError, isInvalidEmailError, isInvalidTenancyError, isNotFoundError, isPasskeyNotFoundError, isUnauthorizedError, isVerificationError, } from "./errors.js";
|
|
145
|
-
export { isPasskey, isPasskeySummary, isUpdatedPasskeys, isUpdatedPasskeyUsernames, } from "./passkey/passkey.js";
|
|
146
|
-
export { isExtendedPrincipal, isPrincipal } from "./schemas/principal.js";
|
|
1
|
+
const isProd = process.env.NODE_ENV === "production";
|
|
2
|
+
const warnedKey = Symbol.for("passlock.node.deprecation.warned");
|
|
3
|
+
const g = globalThis;
|
|
4
|
+
if (!isProd && !g[warnedKey]) {
|
|
5
|
+
g[warnedKey] = true;
|
|
6
|
+
console.warn("[DEPRECATED] @passlock/node has been renamed to @passlock/server. Please update your imports.");
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
147
9
|
//# sourceMappingURL=safe.js.map
|
package/dist/safe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe.js","sourceRoot":"","sources":["../src/safe.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Safe functions that return discriminated unions representing\n * the successful outcome or expected failures.\n *\n * Note: unexpected runtime failures may still throw.\n *\n * @categoryDescription Passkeys\n * Functions and related types for managing passkeys\n *\n * @showCategories\n *\n * @module safe\n */\n\nimport { Effect, identity, pipe } from \"effect\"\nimport type {\n ForbiddenError,\n InvalidCodeError,\n NotFoundError,\n VerificationError,\n} from \"./errors.js\"\nimport type {\n AssignUserOptions,\n DeletePasskeyOptions,\n FindAllPasskeys,\n GetPasskeyOptions,\n ListPasskeyOptions,\n Passkey,\n UpdatedPasskeyUsernames,\n UpdatePasskeyOptions,\n UpdatePasskeyUsernamesOptions,\n} from \"./passkey/passkey.js\"\nimport {\n assignUser as assignUserE,\n deletePasskey as deletePasskeyE,\n getPasskey as getPasskeyE,\n listPasskeys as listPasskeysE,\n updatePasskey as updatePasskeyE,\n updatePasskeyUsernames as updatePasskeyUsernamesE,\n} from \"./passkey/passkey.js\"\nimport type {\n ExchangeCodeOptions,\n VerifyIdTokenOptions,\n} from \"./principal/principal.js\"\nimport {\n exchangeCode as exchangeCodeE,\n verifyIdToken as verifyIdTokenE,\n} from \"./principal/principal.js\"\nimport type { ExtendedPrincipal, Principal } from \"./schemas/principal.js\"\n\n/**\n * Assign a custom User ID to a passkey. Will be reflected in the next\n * {@link Principal} or {@link ExtendedPrincipal} generated.\n *\n * **Note:** This does not change the underlying WebAuthn credential's `userId`.\n * Instead we apply a layer of indirection.\n *\n * @see {@link Principal}\n * @see {@link ExtendedPrincipal}\n * @see [credential](https://passlock.dev/rest-api/credential/)\n *\n * @param request\n * @returns A promise resolving to either a passkey or an API error.\n *\n * @category Passkeys\n */\nexport const assignUser = (\n request: AssignUserOptions\n): Promise<Passkey | NotFoundError | ForbiddenError> =>\n pipe(\n assignUserE(request),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Can also be used to assign a custom User ID, but also allows you to update\n * the username.\n *\n * **Important:** changing the username has no bearing on authentication, as\n * it's typically only used in the client-side component of the passkey\n * (so the user knows which account the passkey relates to).\n *\n * However you might choose to align the username in your vault with the\n * client-side component to simplify end user support.\n *\n * @param request\n * @returns A promise resolving to either a passkey or an API error.\n *\n * @category Passkeys\n */\nexport const updatePasskey = (\n request: UpdatePasskeyOptions\n): Promise<Passkey | NotFoundError | ForbiddenError> =>\n pipe(\n updatePasskeyE(request),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Update the username for all passkeys belonging to a given user.\n *\n * **Important:** changing the username has no bearing on authentication, as\n * it's typically only used in the client-side component of the passkey\n * (so the user knows which account the passkey relates to).\n *\n * However you might choose to align the username in your vault with the\n * client-side component to simplify end user support.\n *\n * @param request\n * @returns A promise resolving to either updated passkey usernames or an API error.\n *\n * @category Passkeys\n */\nexport const updatePasskeyUsernames = (\n request: UpdatePasskeyUsernamesOptions\n): Promise<UpdatedPasskeyUsernames | NotFoundError | ForbiddenError> =>\n pipe(\n updatePasskeyUsernamesE(request),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Delete a passkey from your vault.\n *\n * **Note:** The user will still retain the passkey on their device so\n * you will need to either:\n *\n * a) Use the @passlock/client functions to delete the passkey from the user's device.\n * b) Remind the user to delete the passkey\n *\n * See [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/) in the documentation.\n *\n * In addition, during authentication you should handle a missing passkey scenario.\n * This happens when a user tries to authenticate with a passkey that is missing from\n * your vault. The @passlock/client library can help with this. See\n * [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)\n *\n * @see [deleting passkeys](https://passlock.dev/passkeys/passkey-removal/)\n * @see [handling missing passkeys](https://passlock.dev/handling-missing-passkeys/)\n *\n * @param options\n * @returns A promise resolving to either the deleted passkey or an API error.\n *\n * @category Passkeys\n */\nexport const deletePasskey = (\n options: DeletePasskeyOptions\n): Promise<Passkey | ForbiddenError | NotFoundError> =>\n pipe(\n deletePasskeyE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Fetch details about a passkey. **Important**: Not to be confused with\n * the {@link exchangeCode} or {@link verifyIdToken} functions, which\n * return details about specific authentication or registration operations.\n * Use this function for passkey management, not authentication.\n *\n * @param options\n * @returns A promise resolving to either passkey details or an API error.\n *\n * @category Passkeys\n */\nexport const getPasskey = (\n options: GetPasskeyOptions\n): Promise<Passkey | ForbiddenError | NotFoundError> =>\n pipe(\n getPasskeyE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * List passkeys for the given tenancy. Note: This could return a cursor.\n * If so, call again, passing the cursor back in.\n *\n * @param options\n * @returns A promise resolving to a page of passkey summaries or an API error.\n *\n * @category Passkeys\n */\nexport const listPasskeys = (\n options: ListPasskeyOptions\n): Promise<FindAllPasskeys | ForbiddenError> =>\n pipe(\n listPasskeysE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * The @passlock/client library generates codes, which you should send to\n * your backend. Use this function to exchange the code for details about\n * the registration or authentication operation. **Note:** a code is valid\n * for 5 minutes.\n *\n * @see {@link ExtendedPrincipal}\n *\n * @param options\n * @returns A promise resolving to an extended principal or an API error.\n *\n * @category Principal\n */\nexport const exchangeCode = (\n options: ExchangeCodeOptions\n): Promise<ExtendedPrincipal | ForbiddenError | InvalidCodeError> =>\n pipe(\n exchangeCodeE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/**\n * Decode and verify an id_token (JWT) locally.\n * **Note:** This will make a network call to\n * `https://api.passlock.dev/.well-known/jwks.json` (or your configured `endpoint`)\n * to fetch the relevant public key. The response will be cached, however\n * bear in mind that for something like AWS Lambda it will make the call on every\n * cold start so might actually be slower than {@link exchangeCode}\n *\n * @see {@link Principal}\n *\n * @param options\n * @returns A promise resolving to a verified principal or verification failure.\n *\n * @category Principal\n */\nexport const verifyIdToken = (\n options: VerifyIdTokenOptions\n): Promise<Principal | VerificationError> =>\n pipe(\n verifyIdTokenE(options),\n Effect.match({ onFailure: identity, onSuccess: identity }),\n Effect.runPromise\n )\n\n/* Re-exports */\n\nexport type {\n BadRequestError,\n DuplicateEmailError,\n ForbiddenError,\n InvalidCodeError,\n InvalidEmailError,\n InvalidTenancyError,\n NotFoundError,\n PasskeyNotFoundError,\n UnauthorizedError,\n VerificationError,\n} from \"./errors.js\"\nexport {\n isBadRequestError,\n isDuplicateEmailError,\n isForbiddenError,\n isInvalidCodeError,\n isInvalidEmailError,\n isInvalidTenancyError,\n isNotFoundError,\n isPasskeyNotFoundError,\n isUnauthorizedError,\n isVerificationError,\n} from \"./errors.js\"\nexport type {\n AssignUserOptions,\n Credential,\n DeletePasskeyOptions,\n FindAllPasskeys,\n GetPasskeyOptions,\n ListPasskeyOptions,\n Passkey,\n PasskeySummary,\n Platform,\n UpdatedPasskeys,\n UpdatedPasskeyUsernames,\n UpdatePasskeyOptions,\n UpdatePasskeyUsernamesOptions,\n} from \"./passkey/passkey.js\"\nexport {\n isPasskey,\n isPasskeySummary,\n isUpdatedPasskeys,\n isUpdatedPasskeyUsernames,\n} from \"./passkey/passkey.js\"\nexport type {\n ExchangeCodeOptions,\n VerifyIdTokenOptions,\n} from \"./principal/principal.js\"\nexport type {\n CredentialDeviceType,\n Transports,\n} from \"./schemas/passkey.js\"\nexport type { ExtendedPrincipal, Principal } from \"./schemas/principal.js\"\nexport { isExtendedPrincipal, isPrincipal } from \"./schemas/principal.js\"\nexport type {\n AuthenticatedOptions,\n PasslockOptions,\n} from \"./shared.js\"\n"]}
|
|
1
|
+
{"version":3,"file":"safe.js","sourceRoot":"","sources":["../src/safe.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;AAErD,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAMjE,MAAM,CAAC,GAAG,UAAgC,CAAC;AAE3C,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC;IAC7B,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IAEpB,OAAO,CAAC,IAAI,CACV,+FAA+F,CAChG,CAAC;AACJ,CAAC","sourcesContent":["const isProd = process.env.NODE_ENV === \"production\";\n\nconst warnedKey = Symbol.for(\"passlock.node.deprecation.warned\");\n\ntype GlobalWithWarnFlag = typeof globalThis & {\n [warnedKey]?: boolean;\n};\n\nconst g = globalThis as GlobalWithWarnFlag;\n\nif (!isProd && !g[warnedKey]) {\n g[warnedKey] = true;\n\n console.warn(\n \"[DEPRECATED] @passlock/node has been renamed to @passlock/server. Please update your imports.\"\n );\n}"]}
|