@passlock/node 2.0.2 → 2.0.4
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/effect.d.ts +2 -2
- package/dist/effect.d.ts.map +1 -1
- package/dist/effect.js +1 -1
- package/dist/effect.js.map +1 -1
- package/dist/errors.d.ts +21 -21
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +16 -11
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +39 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -14
- package/dist/index.js.map +1 -1
- package/dist/network.d.ts +134 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +172 -0
- package/dist/network.js.map +1 -0
- package/dist/passkey/passkey.d.ts +33 -17
- package/dist/passkey/passkey.d.ts.map +1 -1
- package/dist/passkey/passkey.js +113 -66
- package/dist/passkey/passkey.js.map +1 -1
- package/dist/principal/principal.d.ts +7 -7
- package/dist/principal/principal.d.ts.map +1 -1
- package/dist/principal/principal.js +23 -22
- package/dist/principal/principal.js.map +1 -1
- package/dist/safe.d.ts +39 -21
- package/dist/safe.d.ts.map +1 -1
- package/dist/safe.js +30 -13
- package/dist/safe.js.map +1 -1
- package/dist/schemas/errors.d.ts +1 -24
- package/dist/schemas/errors.d.ts.map +1 -1
- package/dist/schemas/errors.js +28 -40
- package/dist/schemas/errors.js.map +1 -1
- package/dist/schemas/passkey.d.ts +33 -9
- package/dist/schemas/passkey.d.ts.map +1 -1
- package/dist/schemas/passkey.js +8 -9
- package/dist/schemas/passkey.js.map +1 -1
- package/package.json +6 -10
package/dist/effect.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type { AssignUserOptions
|
|
1
|
+
export type { AssignUserOptions, ListPasskeyOptions, } from "./passkey/passkey.js";
|
|
2
2
|
export { assignUser, deletePasskey, getPasskey, listPasskeys, } from "./passkey/passkey.js";
|
|
3
3
|
export type {} from "./principal/principal.js";
|
|
4
|
-
export { exchangeCode,
|
|
4
|
+
export { exchangeCode, VerificationError, verifyIdToken, } from "./principal/principal.js";
|
|
5
5
|
export * from "./schemas/index.js";
|
|
6
6
|
export type { AuthenticatedOptions, PasslockOptions, } from "./shared.js";
|
|
7
7
|
//# sourceMappingURL=effect.d.ts.map
|
package/dist/effect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,
|
|
1
|
+
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,GACb,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC9C,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,GACd,MAAM,0BAA0B,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,YAAY,EACV,oBAAoB,EACpB,eAAe,GAChB,MAAM,aAAa,CAAA"}
|
package/dist/effect.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { assignUser, deletePasskey, getPasskey, listPasskeys, } from "./passkey/passkey.js";
|
|
2
|
-
export { exchangeCode,
|
|
2
|
+
export { exchangeCode, VerificationError, verifyIdToken, } from "./principal/principal.js";
|
|
3
3
|
export * from "./schemas/index.js";
|
|
4
4
|
//# sourceMappingURL=effect.js.map
|
package/dist/effect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.js","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,GACb,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EACL,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"effect.js","sourceRoot":"","sources":["../src/effect.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,GACb,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,GACd,MAAM,0BAA0B,CAAA;AACjC,cAAc,oBAAoB,CAAA","sourcesContent":["export type {\n AssignUserOptions,\n ListPasskeyOptions,\n} from \"./passkey/passkey.js\"\nexport {\n assignUser,\n deletePasskey,\n getPasskey,\n listPasskeys,\n} from \"./passkey/passkey.js\"\nexport type {} from \"./principal/principal.js\"\nexport {\n exchangeCode,\n VerificationError,\n verifyIdToken,\n} from \"./principal/principal.js\"\nexport * from \"./schemas/index.js\"\nexport type {\n AuthenticatedOptions,\n PasslockOptions,\n} from \"./shared.js\"\n"]}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @category Authentication
|
|
3
3
|
*/
|
|
4
|
-
export type
|
|
4
|
+
export type UnauthorizedError = {
|
|
5
5
|
_tag: "@error/Unauthorized";
|
|
6
6
|
message: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const isUnauthorizedError: (payload: unknown) => payload is UnauthorizedError;
|
|
9
9
|
/**
|
|
10
10
|
* @category Authentication
|
|
11
11
|
*/
|
|
12
|
-
export type
|
|
12
|
+
export type ForbiddenError = {
|
|
13
13
|
_tag: "@error/Forbidden";
|
|
14
14
|
message: string;
|
|
15
15
|
};
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const isForbiddenError: (payload: unknown) => payload is ForbiddenError;
|
|
17
17
|
/**
|
|
18
18
|
* @category Principal
|
|
19
19
|
*/
|
|
20
|
-
export type
|
|
20
|
+
export type InvalidCodeError = {
|
|
21
21
|
_tag: "@error/InvalidCode";
|
|
22
22
|
message: string;
|
|
23
23
|
};
|
|
24
|
-
export declare const
|
|
24
|
+
export declare const isInvalidCodeError: (payload: unknown) => payload is InvalidCodeError;
|
|
25
25
|
/**
|
|
26
26
|
* @category Principal
|
|
27
27
|
*/
|
|
28
|
-
export type
|
|
29
|
-
_tag: "@error/
|
|
28
|
+
export type VerificationError = {
|
|
29
|
+
_tag: "@error/Verification";
|
|
30
30
|
message: string;
|
|
31
31
|
};
|
|
32
|
-
export declare const
|
|
33
|
-
export type
|
|
32
|
+
export declare const isVerificationError: (payload: unknown) => payload is VerificationError;
|
|
33
|
+
export type InvalidTenancyError = {
|
|
34
34
|
_tag: "@error/InvalidTenancy";
|
|
35
35
|
message: string;
|
|
36
36
|
};
|
|
37
|
-
export declare const
|
|
37
|
+
export declare const isInvalidTenancyError: (payload: unknown) => payload is InvalidTenancyError;
|
|
38
38
|
/**
|
|
39
39
|
* Error payload returned when a passkey cannot be found for a given
|
|
40
40
|
* authentication attempt.
|
|
41
41
|
*
|
|
42
42
|
* @category Passkeys
|
|
43
43
|
*/
|
|
44
|
-
export type
|
|
44
|
+
export type PasskeyNotFoundError = {
|
|
45
45
|
_tag: "@error/PasskeyNotFound";
|
|
46
46
|
message: string;
|
|
47
47
|
credentialId: string;
|
|
48
48
|
rpId: string;
|
|
49
49
|
};
|
|
50
|
-
export declare const
|
|
51
|
-
export type
|
|
50
|
+
export declare const isPasskeyNotFoundError: (payload: unknown) => payload is PasskeyNotFoundError;
|
|
51
|
+
export type NotFoundError = {
|
|
52
52
|
_tag: "@error/NotFound";
|
|
53
53
|
message: string;
|
|
54
54
|
};
|
|
55
|
-
export declare const
|
|
56
|
-
export type
|
|
55
|
+
export declare const isNotFoundError: (payload: unknown) => payload is NotFoundError;
|
|
56
|
+
export type InvalidEmailError = {
|
|
57
57
|
_tag: "@error/InvalidEmail";
|
|
58
58
|
message: string;
|
|
59
59
|
};
|
|
60
|
-
export declare const
|
|
61
|
-
export type
|
|
60
|
+
export declare const isInvalidEmailError: (payload: unknown) => payload is InvalidEmailError;
|
|
61
|
+
export type DuplicateEmailError = {
|
|
62
62
|
_tag: "@error/DuplicateEmail";
|
|
63
63
|
message: string;
|
|
64
64
|
};
|
|
65
|
-
export declare const
|
|
66
|
-
export type
|
|
65
|
+
export declare const isDuplicateEmailError: (payload: unknown) => payload is DuplicateEmailError;
|
|
66
|
+
export type BadRequestError = {
|
|
67
67
|
_tag: "@error/BadRequest";
|
|
68
68
|
message: string;
|
|
69
69
|
};
|
|
70
|
-
export declare const
|
|
70
|
+
export declare const isBadRequestError: (payload: unknown) => payload is BadRequestError;
|
|
71
71
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAA;IAC3B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,mBAAmB,YArBpB,OAAO,KAAG,OAAO,qBAuB5B,CAAA;AAID;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,kBAAkB,CAAA;IACxB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,gBAAgB,YAnCjB,OAAO,KAAG,OAAO,kBAmC+C,CAAA;AAI5E;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,oBAAoB,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,kBAAkB,YA/CnB,OAAO,KAAG,OAAO,oBAgDqB,CAAA;AAIlD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAA;IAC3B,OAAO,EAAE,M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@ -1,4 +1,9 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/*
|
|
2
|
+
* Publicly exposed errors.
|
|
3
|
+
* The errors we receive from the API live in the schemas/errors.ts module.
|
|
4
|
+
* The errors here have the same shape but they are simple types
|
|
5
|
+
* so are easier for non Effect consumers to handle.
|
|
6
|
+
*/
|
|
2
7
|
const isTagged = (tag) => (payload) => {
|
|
3
8
|
if (typeof payload !== "object")
|
|
4
9
|
return false;
|
|
@@ -12,14 +17,14 @@ const isTagged = (tag) => (payload) => {
|
|
|
12
17
|
return false;
|
|
13
18
|
return true;
|
|
14
19
|
};
|
|
15
|
-
export const
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
19
|
-
export const
|
|
20
|
-
export const
|
|
21
|
-
export const
|
|
22
|
-
export const
|
|
23
|
-
export const
|
|
24
|
-
export const
|
|
20
|
+
export const isUnauthorizedError = isTagged("@error/Unauthorized");
|
|
21
|
+
export const isForbiddenError = isTagged("@error/Forbidden");
|
|
22
|
+
export const isInvalidCodeError = isTagged("@error/InvalidCode");
|
|
23
|
+
export const isVerificationError = isTagged("@error/Verification");
|
|
24
|
+
export const isInvalidTenancyError = isTagged("@error/InvalidTenancy");
|
|
25
|
+
export const isPasskeyNotFoundError = isTagged("@error/PasskeyNotFound");
|
|
26
|
+
export const isNotFoundError = isTagged("@error/NotFound");
|
|
27
|
+
export const isInvalidEmailError = isTagged("@error/InvalidEmail");
|
|
28
|
+
export const isDuplicateEmailError = isTagged("@error/DuplicateEmail");
|
|
29
|
+
export const isBadRequestError = isTagged("@error/BadRequest");
|
|
25
30
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAE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.ts module.\n * The errors here have the same shape but they are simple types\n * so are easier for non Effect consumers to handle.\n */\n\nconst isTagged =\n <A extends { _tag: string }>(tag: A[\"_tag\"]) =>\n (payload: unknown): payload is A => {\n if (typeof payload !== \"object\") return false\n if (payload === null) return false\n\n if (!(\"_tag\" in payload)) return false\n if (typeof payload._tag !== \"string\") return false\n if (payload._tag !== tag) return false\n\n return true\n }\n\n/* Unauthorized */\n\n/**\n * @category Authentication\n */\nexport type UnauthorizedError = {\n _tag: \"@error/Unauthorized\"\n message: string\n}\n\nexport const isUnauthorizedError = isTagged<UnauthorizedError>(\n \"@error/Unauthorized\"\n)\n\n/* Forbidden */\n\n/**\n * @category Authentication\n */\nexport type ForbiddenError = {\n _tag: \"@error/Forbidden\"\n message: string\n}\n\nexport const isForbiddenError = isTagged<ForbiddenError>(\"@error/Forbidden\")\n\n/* InvalidCode */\n\n/**\n * @category Principal\n */\nexport type InvalidCodeError = {\n _tag: \"@error/InvalidCode\"\n message: string\n}\n\nexport const isInvalidCodeError =\n isTagged<InvalidCodeError>(\"@error/InvalidCode\")\n\n/* VerificationFailure */\n\n/**\n * @category Principal\n */\nexport type VerificationError = {\n _tag: \"@error/Verification\"\n message: string\n}\n\nexport const isVerificationError = isTagged<VerificationError>(\n \"@error/Verification\"\n)\n\n/* InvalidTenancy */\n\nexport type InvalidTenancyError = {\n _tag: \"@error/InvalidTenancy\"\n message: string\n}\n\nexport const isInvalidTenancyError = isTagged<InvalidTenancyError>(\n \"@error/InvalidTenancy\"\n)\n\n/* PasskeyNotFound */\n\n/**\n * Error payload returned when a passkey cannot be found for a given\n * authentication attempt.\n *\n * @category Passkeys\n */\nexport type PasskeyNotFoundError = {\n _tag: \"@error/PasskeyNotFound\"\n message: string\n credentialId: string\n rpId: string\n}\n\nexport const isPasskeyNotFoundError = isTagged<PasskeyNotFoundError>(\n \"@error/PasskeyNotFound\"\n)\n\n/* NotFound */\n\nexport type NotFoundError = {\n _tag: \"@error/NotFound\"\n message: string\n}\n\nexport const isNotFoundError = isTagged<NotFoundError>(\"@error/NotFound\")\n\n/* InvalidEmail */\n\nexport type InvalidEmailError = {\n _tag: \"@error/InvalidEmail\"\n message: string\n}\n\nexport const isInvalidEmailError = isTagged<InvalidEmailError>(\n \"@error/InvalidEmail\"\n)\n\n/* DuplicateEmail */\n\nexport type DuplicateEmailError = {\n _tag: \"@error/DuplicateEmail\"\n message: string\n}\n\nexport const isDuplicateEmailError = isTagged<DuplicateEmailError>(\n \"@error/DuplicateEmail\"\n)\n\n/* BadRequest */\n\nexport type BadRequestError = {\n _tag: \"@error/BadRequest\"\n message: string\n}\n\nexport const isBadRequestError = isTagged<BadRequestError>(\"@error/BadRequest\")\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @module unsafe
|
|
10
10
|
*/
|
|
11
|
-
import type { AssignUserOptions,
|
|
11
|
+
import type { AssignUserOptions, DeletePasskeyOptions, FindAllPasskeys, GetPasskeyOptions, ListPasskeyOptions, Passkey, UpdatedPasskeyUsernames, UpdatePasskeyOptions, UpdatePasskeyUsernamesOptions } from "./passkey/passkey.js";
|
|
12
12
|
import type { ExchangeCodeOptions, VerifyIdTokenOptions } from "./principal/principal.js";
|
|
13
13
|
import type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
|
|
14
14
|
/**
|
|
@@ -16,8 +16,8 @@ import type { ExtendedPrincipal, Principal } from "./schemas/principal.js";
|
|
|
16
16
|
*
|
|
17
17
|
* @param request
|
|
18
18
|
* @returns A promise resolving to the updated passkey.
|
|
19
|
-
* @throws {@link
|
|
20
|
-
* @throws {@link
|
|
19
|
+
* @throws {@link NotFoundError} if passkey does not exist
|
|
20
|
+
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
21
21
|
*
|
|
22
22
|
* @category Passkeys
|
|
23
23
|
*/
|
|
@@ -27,23 +27,43 @@ export declare const assignUser: (request: AssignUserOptions) => Promise<Passkey
|
|
|
27
27
|
*
|
|
28
28
|
* @param request
|
|
29
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
|
|
30
32
|
*
|
|
31
33
|
* @category Passkeys
|
|
32
34
|
*/
|
|
33
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>;
|
|
34
47
|
/**
|
|
35
48
|
* Call the Passlock backend API to delete an authenticator
|
|
36
49
|
*
|
|
37
50
|
* @param options
|
|
38
|
-
* @returns A promise resolving to the deleted passkey
|
|
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
|
|
39
54
|
*
|
|
40
55
|
* @category Passkeys
|
|
41
56
|
*/
|
|
42
|
-
export declare const deletePasskey: (options: DeletePasskeyOptions) => Promise<
|
|
57
|
+
export declare const deletePasskey: (options: DeletePasskeyOptions) => Promise<Passkey>;
|
|
43
58
|
/**
|
|
44
59
|
* Call the Passlock backend API to fetch an authenticator
|
|
60
|
+
*
|
|
45
61
|
* @param options
|
|
46
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
|
|
47
67
|
*/
|
|
48
68
|
export declare const getPasskey: (options: GetPasskeyOptions) => Promise<Passkey>;
|
|
49
69
|
/**
|
|
@@ -52,36 +72,41 @@ export declare const getPasskey: (options: GetPasskeyOptions) => Promise<Passkey
|
|
|
52
72
|
*
|
|
53
73
|
* @param options
|
|
54
74
|
* @returns A promise resolving to a page of passkey summaries.
|
|
75
|
+
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
55
76
|
*
|
|
56
77
|
* @category Passkeys
|
|
57
78
|
*/
|
|
58
79
|
export declare const listPasskeys: (options: ListPasskeyOptions) => Promise<FindAllPasskeys>;
|
|
59
80
|
/**
|
|
60
|
-
* Call the Passlock backend API to exchange a code for
|
|
81
|
+
* Call the Passlock backend API to exchange a code for an ExtendedPrincipal
|
|
61
82
|
*
|
|
62
83
|
* @param options
|
|
63
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
|
|
64
87
|
*
|
|
65
88
|
* @category Principal
|
|
66
89
|
*/
|
|
67
90
|
export declare const exchangeCode: (options: ExchangeCodeOptions) => Promise<ExtendedPrincipal>;
|
|
68
91
|
/**
|
|
69
|
-
* Decode and verify a Passlock
|
|
70
|
-
* Note: This will make a network call to
|
|
71
|
-
*
|
|
72
|
-
*
|
|
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
|
|
73
97
|
* cold start so might actually be slower than {@link exchangeCode}
|
|
74
98
|
*
|
|
75
99
|
* @param options
|
|
76
100
|
* @returns A promise resolving to the verified principal.
|
|
101
|
+
* @throws {@link VerificationError} if token verification fails
|
|
77
102
|
*
|
|
78
103
|
* @category Principal
|
|
79
104
|
*/
|
|
80
105
|
export declare const verifyIdToken: (options: VerifyIdTokenOptions) => Promise<Principal>;
|
|
81
|
-
export type {
|
|
82
|
-
export {
|
|
83
|
-
export type { AssignUserOptions, Credential,
|
|
84
|
-
export {
|
|
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";
|
|
85
110
|
export type { ExchangeCodeOptions, VerifyIdTokenOptions, } from "./principal/principal.js";
|
|
86
111
|
export type { CredentialDeviceType, Transports, } from "./schemas/passkey.js";
|
|
87
112
|
export type { ExtendedPrincipal, Principal } from "./schemas/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;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,k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CAAA;AACpB,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,aAAa,CAAA;AACpB,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,OAAO,EACP,cAAc,EACd,QAAQ,EACR,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EACV,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,0BAA0B,CAAA;AACjC,YAAY,EACV,oBAAoB,EACpB,UAAU,GACX,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAC1E,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzE,YAAY,EACV,oBAAoB,EACpB,eAAe,GAChB,MAAM,aAAa,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -8,17 +8,16 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @module unsafe
|
|
10
10
|
*/
|
|
11
|
-
import { FetchHttpClient } from "@effect/platform";
|
|
12
11
|
import { Effect, pipe } from "effect";
|
|
13
|
-
import { assignUser as assignUserE, deletePasskey as deletePasskeyE, getPasskey as getPasskeyE, listPasskeys as listPasskeysE, updatePasskey as updatePasskeyE, } from "./passkey/passkey.js";
|
|
12
|
+
import { assignUser as assignUserE, deletePasskey as deletePasskeyE, getPasskey as getPasskeyE, listPasskeys as listPasskeysE, updatePasskey as updatePasskeyE, updatePasskeyUsernames as updatePasskeyUsernamesE, } from "./passkey/passkey.js";
|
|
14
13
|
import { exchangeCode as exchangeCodeE, verifyIdToken as verifyIdTokenE, } from "./principal/principal.js";
|
|
15
14
|
/**
|
|
16
15
|
* Call the Passlock backend API to assign a userId to an authenticator
|
|
17
16
|
*
|
|
18
17
|
* @param request
|
|
19
18
|
* @returns A promise resolving to the updated passkey.
|
|
20
|
-
* @throws {@link
|
|
21
|
-
* @throws {@link
|
|
19
|
+
* @throws {@link NotFoundError} if passkey does not exist
|
|
20
|
+
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
22
21
|
*
|
|
23
22
|
* @category Passkeys
|
|
24
23
|
*/
|
|
@@ -28,23 +27,43 @@ export const assignUser = (request) => pipe(assignUserE(request), Effect.runProm
|
|
|
28
27
|
*
|
|
29
28
|
* @param request
|
|
30
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
|
|
31
32
|
*
|
|
32
33
|
* @category Passkeys
|
|
33
34
|
*/
|
|
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);
|
|
35
47
|
/**
|
|
36
48
|
* Call the Passlock backend API to delete an authenticator
|
|
37
49
|
*
|
|
38
50
|
* @param options
|
|
39
|
-
* @returns A promise resolving to the deleted passkey
|
|
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
|
|
40
54
|
*
|
|
41
55
|
* @category Passkeys
|
|
42
56
|
*/
|
|
43
57
|
export const deletePasskey = (options) => pipe(deletePasskeyE(options), Effect.runPromise);
|
|
44
58
|
/**
|
|
45
59
|
* Call the Passlock backend API to fetch an authenticator
|
|
60
|
+
*
|
|
46
61
|
* @param options
|
|
47
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
|
|
48
67
|
*/
|
|
49
68
|
export const getPasskey = (options) => pipe(getPasskeyE(options), Effect.runPromise);
|
|
50
69
|
/**
|
|
@@ -53,33 +72,38 @@ export const getPasskey = (options) => pipe(getPasskeyE(options), Effect.runProm
|
|
|
53
72
|
*
|
|
54
73
|
* @param options
|
|
55
74
|
* @returns A promise resolving to a page of passkey summaries.
|
|
75
|
+
* @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid
|
|
56
76
|
*
|
|
57
77
|
* @category Passkeys
|
|
58
78
|
*/
|
|
59
79
|
export const listPasskeys = (options) => pipe(listPasskeysE(options), Effect.runPromise);
|
|
60
80
|
/**
|
|
61
|
-
* Call the Passlock backend API to exchange a code for
|
|
81
|
+
* Call the Passlock backend API to exchange a code for an ExtendedPrincipal
|
|
62
82
|
*
|
|
63
83
|
* @param options
|
|
64
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
|
|
65
87
|
*
|
|
66
88
|
* @category Principal
|
|
67
89
|
*/
|
|
68
|
-
export const exchangeCode = (options) => pipe(exchangeCodeE(options), Effect.
|
|
90
|
+
export const exchangeCode = (options) => pipe(exchangeCodeE(options), Effect.runPromise);
|
|
69
91
|
/**
|
|
70
|
-
* Decode and verify a Passlock
|
|
71
|
-
* Note: This will make a network call to
|
|
72
|
-
*
|
|
73
|
-
*
|
|
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
|
|
74
97
|
* cold start so might actually be slower than {@link exchangeCode}
|
|
75
98
|
*
|
|
76
99
|
* @param options
|
|
77
100
|
* @returns A promise resolving to the verified principal.
|
|
101
|
+
* @throws {@link VerificationError} if token verification fails
|
|
78
102
|
*
|
|
79
103
|
* @category Principal
|
|
80
104
|
*/
|
|
81
|
-
export const verifyIdToken = (options) => pipe(verifyIdTokenE(options), Effect.
|
|
82
|
-
export {
|
|
83
|
-
export {
|
|
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";
|
|
84
108
|
export { isExtendedPrincipal, isPrincipal } from "./schemas/principal.js";
|
|
85
109
|
//# 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;;;;;;;;;GASG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,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AO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAE9E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAA4B,EACA,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAEhF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAA6B,EACT,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;AAgBzE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,aAAa,CAAA;AAgBpB,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAU7B,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA","sourcesContent":["/**\n * Unsafe functions that could potentially throw errors.\n *\n * @categoryDescription Passkeys\n * Functions and related types for managing passkeys\n *\n * @showCategories\n *\n * @module unsafe\n */\n\nimport { Effect, pipe } from \"effect\"\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 * Call the Passlock backend API to assign a userId to an authenticator\n *\n * @param request\n * @returns A promise resolving to the updated passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const assignUser = (request: AssignUserOptions): Promise<Passkey> =>\n pipe(assignUserE(request), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to update passkey properties\n *\n * @param request\n * @returns A promise resolving to the updated passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const updatePasskey = (\n request: UpdatePasskeyOptions\n): Promise<Passkey> => pipe(updatePasskeyE(request), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to update all passkeys for a given user\n *\n * @param request\n * @returns A promise resolving to updated usernames for matching passkeys.\n * @throws {@link NotFoundError} if no passkeys are found for the given user\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const updatePasskeyUsernames = (\n request: UpdatePasskeyUsernamesOptions\n): Promise<UpdatedPasskeyUsernames> =>\n pipe(updatePasskeyUsernamesE(request), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to delete an authenticator\n *\n * @param options\n * @returns A promise resolving to the deleted passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const deletePasskey = (\n options: DeletePasskeyOptions\n): Promise<Passkey> => pipe(deletePasskeyE(options), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to fetch an authenticator\n *\n * @param options\n * @returns A promise resolving to the passkey.\n * @throws {@link NotFoundError} if passkey does not exist\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const getPasskey = (options: GetPasskeyOptions): Promise<Passkey> =>\n pipe(getPasskeyE(options), Effect.runPromise)\n\n/**\n * List passkeys for the given tenancy. Note this could return a cursor,\n * in which case the function should be called again with the given cursor.\n *\n * @param options\n * @returns A promise resolving to a page of passkey summaries.\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Passkeys\n */\nexport const listPasskeys = (\n options: ListPasskeyOptions\n): Promise<FindAllPasskeys> => pipe(listPasskeysE(options), Effect.runPromise)\n\n/**\n * Call the Passlock backend API to exchange a code for an ExtendedPrincipal\n *\n * @param options\n * @returns A promise resolving to an extended principal.\n * @throws {@link InvalidCodeError} if the code is invalid or expired\n * @throws {@link ForbiddenError} if the Tenancy ID or API key is invalid\n *\n * @category Principal\n */\nexport const exchangeCode = (\n options: ExchangeCodeOptions\n): Promise<ExtendedPrincipal> => pipe(exchangeCodeE(options), Effect.runPromise)\n\n/**\n * Decode and verify a Passlock `id_token` (JWT).\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 * @param options\n * @returns A promise resolving to the verified principal.\n * @throws {@link VerificationError} if token verification fails\n *\n * @category Principal\n */\nexport const verifyIdToken = (\n options: VerifyIdTokenOptions\n): Promise<Principal> => pipe(verifyIdTokenE(options), Effect.runPromise)\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"]}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Supported HTTP methods accepted by {@link fetchNetwork}.
|
|
4
|
+
*/
|
|
5
|
+
export type NetworkMethod = "get" | "post" | "delete" | "patch";
|
|
6
|
+
/**
|
|
7
|
+
* Lightweight response model used by this package.
|
|
8
|
+
*
|
|
9
|
+
* Invariants:
|
|
10
|
+
* - `json` is lazy: parsing only happens when the effect is run.
|
|
11
|
+
* - `json` is memoized per response wrapper, so repeated evaluation does not
|
|
12
|
+
* parse the same payload multiple times.
|
|
13
|
+
*/
|
|
14
|
+
export interface NetworkResponse {
|
|
15
|
+
readonly status: number;
|
|
16
|
+
readonly statusText: string;
|
|
17
|
+
readonly statusMessage: string;
|
|
18
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
19
|
+
readonly json: Effect.Effect<unknown, NetworkResponseError>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Accepted request header input formats.
|
|
23
|
+
*/
|
|
24
|
+
export type NetworkHeaders = Headers | Readonly<Record<string, string>> | Array<[string, string]>;
|
|
25
|
+
/**
|
|
26
|
+
* Optional request options for {@link fetchNetwork}.
|
|
27
|
+
*/
|
|
28
|
+
export interface FetchNetworkOptions {
|
|
29
|
+
readonly headers?: NetworkHeaders;
|
|
30
|
+
}
|
|
31
|
+
declare const NetworkFetch_base: Context.TagClass<NetworkFetch, "@passlock/node/network/Fetch", typeof fetch>;
|
|
32
|
+
/**
|
|
33
|
+
* Effect service tag for the fetch implementation.
|
|
34
|
+
*
|
|
35
|
+
* Supply this service with `Effect.provide` / layers to swap fetch behavior
|
|
36
|
+
* in tests or alternate runtimes.
|
|
37
|
+
*/
|
|
38
|
+
export declare class NetworkFetch extends NetworkFetch_base {
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Default live fetch layer backed by `globalThis.fetch`.
|
|
42
|
+
*/
|
|
43
|
+
export declare const NetworkFetchLive: Layer.Layer<NetworkFetch>;
|
|
44
|
+
/**
|
|
45
|
+
* HTTP status buckets used by {@link matchStatus}.
|
|
46
|
+
*/
|
|
47
|
+
export type NetworkResponseStatusCase = "2xx" | "3xx" | "4xx" | "5xx";
|
|
48
|
+
type MatchStatusHandler<Resp extends NetworkResponse = NetworkResponse, A = unknown, E = unknown> = (response: Resp) => Effect.Effect<A, E, never>;
|
|
49
|
+
type HandlerEffect<Cases extends MatchStatusCases<Resp>, Resp extends NetworkResponse, Case extends NetworkResponseStatusCase | "orElse"> = Case extends keyof Cases ? NonNullable<Cases[Case]> extends MatchStatusHandler<Resp> ? ReturnType<NonNullable<Cases[Case]>> : never : never;
|
|
50
|
+
type MatchStatusEffectUnion<Cases extends MatchStatusCases<Resp>, Resp extends NetworkResponse> = HandlerEffect<Cases, Resp, "2xx"> | HandlerEffect<Cases, Resp, "3xx"> | HandlerEffect<Cases, Resp, "4xx"> | HandlerEffect<Cases, Resp, "5xx"> | HandlerEffect<Cases, Resp, "orElse">;
|
|
51
|
+
type EffectSuccess<T> = T extends Effect.Effect<infer A, unknown, unknown> ? A : never;
|
|
52
|
+
type EffectError<T> = T extends Effect.Effect<unknown, infer E, unknown> ? E : never;
|
|
53
|
+
type EffectContext<T> = T extends Effect.Effect<unknown, unknown, infer R> ? R : never;
|
|
54
|
+
/**
|
|
55
|
+
* Handlers used by {@link matchStatus}.
|
|
56
|
+
*
|
|
57
|
+
* Invariants:
|
|
58
|
+
* - `orElse` is always required.
|
|
59
|
+
* - Specific status family handlers are optional and fall back to `orElse`
|
|
60
|
+
* when missing.
|
|
61
|
+
*/
|
|
62
|
+
export interface MatchStatusCases<Resp extends NetworkResponse = NetworkResponse> {
|
|
63
|
+
readonly "2xx"?: MatchStatusHandler<Resp>;
|
|
64
|
+
readonly "3xx"?: MatchStatusHandler<Resp>;
|
|
65
|
+
readonly "4xx"?: MatchStatusHandler<Resp>;
|
|
66
|
+
readonly "5xx"?: MatchStatusHandler<Resp>;
|
|
67
|
+
readonly orElse: MatchStatusHandler<Resp>;
|
|
68
|
+
}
|
|
69
|
+
declare const NetworkRequestError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
70
|
+
readonly _tag: "@error/NetworkRequest";
|
|
71
|
+
} & Readonly<A>;
|
|
72
|
+
/**
|
|
73
|
+
* Raised when the underlying fetch call fails before a response is received.
|
|
74
|
+
*/
|
|
75
|
+
export declare class NetworkRequestError extends NetworkRequestError_base<{
|
|
76
|
+
readonly method: NetworkMethod;
|
|
77
|
+
readonly url: string;
|
|
78
|
+
readonly message: string;
|
|
79
|
+
}> {
|
|
80
|
+
}
|
|
81
|
+
declare const NetworkPayloadError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
82
|
+
readonly _tag: "@error/NetworkPayload";
|
|
83
|
+
} & Readonly<A>;
|
|
84
|
+
/**
|
|
85
|
+
* Raised when request payload serialization fails.
|
|
86
|
+
*/
|
|
87
|
+
export declare class NetworkPayloadError extends NetworkPayloadError_base<{
|
|
88
|
+
readonly method: NetworkMethod;
|
|
89
|
+
readonly message: string;
|
|
90
|
+
}> {
|
|
91
|
+
}
|
|
92
|
+
declare const NetworkResponseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
93
|
+
readonly _tag: "@error/NetworkResponse";
|
|
94
|
+
} & Readonly<A>;
|
|
95
|
+
/**
|
|
96
|
+
* Raised when response body parsing fails.
|
|
97
|
+
*/
|
|
98
|
+
export declare class NetworkResponseError extends NetworkResponseError_base<{
|
|
99
|
+
readonly method: NetworkMethod;
|
|
100
|
+
readonly url: string;
|
|
101
|
+
readonly message: string;
|
|
102
|
+
}> {
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Convert an HTTP status code into its status family bucket.
|
|
106
|
+
*
|
|
107
|
+
* Returns `undefined` for codes outside the 2xx-5xx families.
|
|
108
|
+
*/
|
|
109
|
+
export declare const statusToCase: (status: number) => NetworkResponseStatusCase | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Route a {@link NetworkResponse} to the first matching status-family handler.
|
|
112
|
+
*
|
|
113
|
+
* Invariants:
|
|
114
|
+
* - `2xx`/`3xx`/`4xx`/`5xx` handlers are matched by status family.
|
|
115
|
+
* - `orElse` is always used as a fallback when no specific family handler exists.
|
|
116
|
+
* - The returned effect type is inferred as the union of all handler effects.
|
|
117
|
+
*/
|
|
118
|
+
export declare const matchStatus: <Resp extends NetworkResponse, Cases extends MatchStatusCases<Resp>>(response: Resp, cases: Cases) => Effect.Effect<EffectSuccess<MatchStatusEffectUnion<Cases, Resp>>, EffectError<MatchStatusEffectUnion<Cases, Resp>>, EffectContext<MatchStatusEffectUnion<Cases, Resp>>>;
|
|
119
|
+
/**
|
|
120
|
+
* Convert `Headers` into a readonly plain record.
|
|
121
|
+
*/
|
|
122
|
+
export declare const headersToRecord: (headers: Headers) => Readonly<Record<string, string>>;
|
|
123
|
+
/**
|
|
124
|
+
* Execute a fetch request using the injected {@link NetworkFetch} service.
|
|
125
|
+
*
|
|
126
|
+
* Invariants:
|
|
127
|
+
* - method is always normalized to upper-case before dispatch.
|
|
128
|
+
* - JSON payload (if present) is serialized before request execution.
|
|
129
|
+
* - caller headers override payload-derived headers when keys overlap.
|
|
130
|
+
* - the returned `NetworkResponse.json` remains lazy.
|
|
131
|
+
*/
|
|
132
|
+
export declare const fetchNetwork: (url: string | URL, method: NetworkMethod, payload?: unknown, options?: FetchNetworkOptions) => Effect.Effect<NetworkResponse, NetworkRequestError | NetworkPayloadError, NetworkFetch>;
|
|
133
|
+
export {};
|
|
134
|
+
//# sourceMappingURL=network.d.ts.map
|