@passflow/node 0.0.0-bootstrap.0 → 0.0.0-stage
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -179
- package/package.json +4 -104
- package/LICENSE +0 -21
- package/dist/claims-BHJhnzch.d.cts +0 -51
- package/dist/claims-BHJhnzch.d.mts +0 -51
- package/dist/evaluate-BTuol-Oa.mjs +0 -348
- package/dist/evaluate-C20MecTf.cjs +0 -491
- package/dist/express.cjs +0 -52
- package/dist/express.d.cts +0 -29
- package/dist/express.d.mts +0 -29
- package/dist/express.mjs +0 -49
- package/dist/fastify.cjs +0 -67
- package/dist/fastify.d.cts +0 -40
- package/dist/fastify.d.mts +0 -40
- package/dist/fastify.mjs +0 -63
- package/dist/hono.cjs +0 -51
- package/dist/hono.d.cts +0 -24
- package/dist/hono.d.mts +0 -24
- package/dist/hono.mjs +0 -48
- package/dist/index.cjs +0 -558
- package/dist/index.d.cts +0 -141
- package/dist/index.d.mts +0 -141
- package/dist/index.mjs +0 -539
package/dist/index.d.cts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { a as verifiedBy, i as rolesOf, n as TenantMembership, r as Verifier, t as PassflowClaims } from "./claims-BHJhnzch.cjs";
|
|
2
|
-
export declare const ACR_NONE = "0";
|
|
3
|
-
export declare const AAL1 = "1";
|
|
4
|
-
export declare const AAL2 = "2";
|
|
5
|
-
export declare const AAL3 = "3";
|
|
6
|
-
/**
|
|
7
|
-
* Whether a token's `acr` meets the required level. Both sides are compared as exact 64-bit integers,
|
|
8
|
-
* and a required side that parses to level 0 is never satisfied: a wrong configuration string fails
|
|
9
|
-
* closed here as well as at `requireACR` construction.
|
|
10
|
-
*/
|
|
11
|
-
export declare function acrSatisfies(acr: unknown, min: string): boolean;
|
|
12
|
-
/**
|
|
13
|
-
* The level as a `number`, for display and logging. It is exact only up to 2^53, and nothing in this
|
|
14
|
-
* library decides with it: use {@link acrSatisfies} to compare.
|
|
15
|
-
*/
|
|
16
|
-
export declare function acrLevel(acr: unknown): number;
|
|
17
|
-
/**
|
|
18
|
-
* The token from an `Authorization` header. The scheme is matched case-insensitively (RFC 9110). Any
|
|
19
|
-
* other scheme, an absent header, and a `Bearer` with an empty or whitespace-only remainder all give
|
|
20
|
-
* `undefined`.
|
|
21
|
-
*/
|
|
22
|
-
export declare function extractBearer(authorization: string | undefined | null): string | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* The constructor rule for a freshness limit (`freshness.json#max_age_input`): a finite number,
|
|
25
|
-
* truncated toward zero, at least 1 and a safe integer, or a `TypeError`. The bound means `String()`
|
|
26
|
-
* always yields plain decimal, so a challenge can never carry `max_age=1e+21`, which the browser
|
|
27
|
-
* SDK's `Number.parseInt` reads as 1. The returned value is both what is enforced and what the
|
|
28
|
-
* challenge carries.
|
|
29
|
-
*/
|
|
30
|
-
export declare function assertMaxAge(value: unknown): number;
|
|
31
|
-
/**
|
|
32
|
-
* The exact RFC 9470 `WWW-Authenticate` bytes the server's `SetInsufficientAuthChallenge` emits. This
|
|
33
|
-
* is a formatter, not a constructor: a `maxAge` that truncates to zero or below is omitted, as the
|
|
34
|
-
* server omits it, and it does not run {@link assertMaxAge}. A non-finite number, a non-number, or a
|
|
35
|
-
* positive value above `Number.MAX_SAFE_INTEGER` is a `TypeError`.
|
|
36
|
-
*
|
|
37
|
-
* `acrValues` is a space-separated list of acr tokens, inserted unescaped exactly as the server does.
|
|
38
|
-
*/
|
|
39
|
-
export declare function formatChallenge(c: {
|
|
40
|
-
acrValues?: string;
|
|
41
|
-
maxAge?: number;
|
|
42
|
-
}): string;
|
|
43
|
-
export declare const CHALLENGE_HEADER = "WWW-Authenticate";
|
|
44
|
-
export declare const CORS_EXPOSED_HEADERS: readonly string[];
|
|
45
|
-
type PassflowAuthErrorCode = 'missing_token' | 'invalid_token' | 'jwks_unavailable';
|
|
46
|
-
/** Why a token was refused. Only `invalid_token` carries one. */
|
|
47
|
-
type InvalidTokenReason = 'expired' | 'not_yet_valid' | 'exp_missing' | 'issuer' | 'audience' | 'type' | 'signature' | 'alg' | 'kid_missing' | 'key_unknown' | 'crit' | 'malformed';
|
|
48
|
-
/**
|
|
49
|
-
* An authentication failure. The message is fixed per code and carries nothing from the token, the
|
|
50
|
-
* request or the JWKS URL. A jose error is never attached as `cause`: jose's claim errors keep the
|
|
51
|
-
* whole payload on `.payload`.
|
|
52
|
-
*/
|
|
53
|
-
export declare class PassflowAuthError extends Error {
|
|
54
|
-
readonly code: PassflowAuthErrorCode;
|
|
55
|
-
readonly reason?: string;
|
|
56
|
-
readonly status: 401 | 503;
|
|
57
|
-
constructor(code: PassflowAuthErrorCode, reason?: InvalidTokenReason, options?: ErrorOptions);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* A programming error, such as reading the claims before any middleware ran. It is deliberately not
|
|
61
|
-
* a `PassflowAuthError`: those mean 401/503, which the browser SDK acts on, and this must reach the
|
|
62
|
-
* framework's error handling as a 500.
|
|
63
|
-
*/
|
|
64
|
-
export declare class PassflowUsageError extends Error {
|
|
65
|
-
constructor(message: string);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* True for a `PassflowAuthError`, including one from the other copy of this package when the ESM
|
|
69
|
-
* and CJS builds are both loaded, where `instanceof` alone would say no.
|
|
70
|
-
*/
|
|
71
|
-
export declare function isPassflowAuthError(e: unknown): e is PassflowAuthError;
|
|
72
|
-
type Requirement = {
|
|
73
|
-
kind: 'acr';
|
|
74
|
-
min: string;
|
|
75
|
-
} | {
|
|
76
|
-
kind: 'fresh';
|
|
77
|
-
maxAgeSeconds: number;
|
|
78
|
-
};
|
|
79
|
-
type Decision = {
|
|
80
|
-
kind: 'allow';
|
|
81
|
-
} | {
|
|
82
|
-
kind: 'reject';
|
|
83
|
-
status: 401 | 500 | 503;
|
|
84
|
-
headers: Record<string, string>;
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Decides one requirement against claims. No claims means the middleware was composed wrongly, so the answer
|
|
88
|
-
* is a 500 with no challenge: never a step-up, which the SDK would try to satisfy, and never a 401, because a
|
|
89
|
-
* wiring bug must not be reported as a bad token. Throws `TypeError` on an invalid requirement.
|
|
90
|
-
*/
|
|
91
|
-
export declare function evaluate(claims: PassflowClaims | undefined, requirement: Requirement): Decision;
|
|
92
|
-
/**
|
|
93
|
-
* Authenticates a request. `existing` claims are reused only when `verifier` produced that exact object;
|
|
94
|
-
* otherwise the presented header is verified with `verifier`, so a token outside this verifier's trust policy
|
|
95
|
-
* is rejected as not valid here, never as insufficient. Never rejects: a failure is a `{ reject }` value.
|
|
96
|
-
*/
|
|
97
|
-
export declare function authenticate(verifier: Verifier, authorization: string | undefined | null, existing?: PassflowClaims): Promise<{
|
|
98
|
-
claims: PassflowClaims;
|
|
99
|
-
} | {
|
|
100
|
-
reject: Decision;
|
|
101
|
-
}>;
|
|
102
|
-
type VerifierConfig = {
|
|
103
|
-
/** Required, exact match against `iss`. */
|
|
104
|
-
issuer: string;
|
|
105
|
-
/** Required: the Passflow application IDs that may call this API. A token must name at least one. */
|
|
106
|
-
audience: string | string[];
|
|
107
|
-
/** Default: `{issuer}/.well-known/jwks.json`, Passflow's fixed path. OIDC discovery is not fetched. */
|
|
108
|
-
jwksUrl?: string;
|
|
109
|
-
/** Permits `http://` on a non-loopback host, for private networks. Default false. */
|
|
110
|
-
allowInsecureJwksUrl?: boolean;
|
|
111
|
-
/** Applies to `exp` and `nbf` only; `iat` is not validated. Default 30. */
|
|
112
|
-
leewaySeconds?: number;
|
|
113
|
-
/** The accepted `type` claims. Default `['access']`. */
|
|
114
|
-
tokenTypes?: string[];
|
|
115
|
-
/** The clock for token checks, `verifiedAt` and the key cache. Default `new Date()`. */
|
|
116
|
-
now?: () => Date;
|
|
117
|
-
jwks?: {
|
|
118
|
-
/**
|
|
119
|
-
* A set older than this keeps answering while it reloads in the background. `0` starts a reload on every
|
|
120
|
-
* verification, gated by `minRefreshInterval`. Default 600000 ms.
|
|
121
|
-
*/
|
|
122
|
-
maxAge?: number;
|
|
123
|
-
/** At most one network attempt per interval for a background reload, after a failure or for an unknown `kid`. Default 30000 ms. */
|
|
124
|
-
minRefreshInterval?: number;
|
|
125
|
-
/** How long after the last successful fetch a stale set is still trusted. Must be `>= maxAge`. Default 3600000 ms. */
|
|
126
|
-
maxStale?: number;
|
|
127
|
-
/** Response body cap. Default 1048576. */
|
|
128
|
-
maxBytes?: number;
|
|
129
|
-
/** Reload timeout, an integer in `[1, 2147483647]` ms. Default 5000. */
|
|
130
|
-
timeout?: number;
|
|
131
|
-
/** Replaces the global `fetch`, for proxies and tests. */
|
|
132
|
-
fetch?: typeof fetch;
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* Builds a verifier from a validated configuration and touches no network: the key set loads on the first
|
|
137
|
-
* `verify`, or on `refresh`. Build one per trust policy, at startup: each owns a key cache, and a verifier
|
|
138
|
-
* built per request would defeat it.
|
|
139
|
-
*/
|
|
140
|
-
export declare function createVerifier(config: VerifierConfig): Verifier;
|
|
141
|
-
export { type Decision, type PassflowAuthErrorCode, type PassflowClaims, type Requirement, type TenantMembership, type Verifier, type VerifierConfig, rolesOf, verifiedBy };
|
package/dist/index.d.mts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { a as verifiedBy, i as rolesOf, n as TenantMembership, r as Verifier, t as PassflowClaims } from "./claims-BHJhnzch.mjs";
|
|
2
|
-
export declare const ACR_NONE = "0";
|
|
3
|
-
export declare const AAL1 = "1";
|
|
4
|
-
export declare const AAL2 = "2";
|
|
5
|
-
export declare const AAL3 = "3";
|
|
6
|
-
/**
|
|
7
|
-
* Whether a token's `acr` meets the required level. Both sides are compared as exact 64-bit integers,
|
|
8
|
-
* and a required side that parses to level 0 is never satisfied: a wrong configuration string fails
|
|
9
|
-
* closed here as well as at `requireACR` construction.
|
|
10
|
-
*/
|
|
11
|
-
export declare function acrSatisfies(acr: unknown, min: string): boolean;
|
|
12
|
-
/**
|
|
13
|
-
* The level as a `number`, for display and logging. It is exact only up to 2^53, and nothing in this
|
|
14
|
-
* library decides with it: use {@link acrSatisfies} to compare.
|
|
15
|
-
*/
|
|
16
|
-
export declare function acrLevel(acr: unknown): number;
|
|
17
|
-
/**
|
|
18
|
-
* The token from an `Authorization` header. The scheme is matched case-insensitively (RFC 9110). Any
|
|
19
|
-
* other scheme, an absent header, and a `Bearer` with an empty or whitespace-only remainder all give
|
|
20
|
-
* `undefined`.
|
|
21
|
-
*/
|
|
22
|
-
export declare function extractBearer(authorization: string | undefined | null): string | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* The constructor rule for a freshness limit (`freshness.json#max_age_input`): a finite number,
|
|
25
|
-
* truncated toward zero, at least 1 and a safe integer, or a `TypeError`. The bound means `String()`
|
|
26
|
-
* always yields plain decimal, so a challenge can never carry `max_age=1e+21`, which the browser
|
|
27
|
-
* SDK's `Number.parseInt` reads as 1. The returned value is both what is enforced and what the
|
|
28
|
-
* challenge carries.
|
|
29
|
-
*/
|
|
30
|
-
export declare function assertMaxAge(value: unknown): number;
|
|
31
|
-
/**
|
|
32
|
-
* The exact RFC 9470 `WWW-Authenticate` bytes the server's `SetInsufficientAuthChallenge` emits. This
|
|
33
|
-
* is a formatter, not a constructor: a `maxAge` that truncates to zero or below is omitted, as the
|
|
34
|
-
* server omits it, and it does not run {@link assertMaxAge}. A non-finite number, a non-number, or a
|
|
35
|
-
* positive value above `Number.MAX_SAFE_INTEGER` is a `TypeError`.
|
|
36
|
-
*
|
|
37
|
-
* `acrValues` is a space-separated list of acr tokens, inserted unescaped exactly as the server does.
|
|
38
|
-
*/
|
|
39
|
-
export declare function formatChallenge(c: {
|
|
40
|
-
acrValues?: string;
|
|
41
|
-
maxAge?: number;
|
|
42
|
-
}): string;
|
|
43
|
-
export declare const CHALLENGE_HEADER = "WWW-Authenticate";
|
|
44
|
-
export declare const CORS_EXPOSED_HEADERS: readonly string[];
|
|
45
|
-
type PassflowAuthErrorCode = 'missing_token' | 'invalid_token' | 'jwks_unavailable';
|
|
46
|
-
/** Why a token was refused. Only `invalid_token` carries one. */
|
|
47
|
-
type InvalidTokenReason = 'expired' | 'not_yet_valid' | 'exp_missing' | 'issuer' | 'audience' | 'type' | 'signature' | 'alg' | 'kid_missing' | 'key_unknown' | 'crit' | 'malformed';
|
|
48
|
-
/**
|
|
49
|
-
* An authentication failure. The message is fixed per code and carries nothing from the token, the
|
|
50
|
-
* request or the JWKS URL. A jose error is never attached as `cause`: jose's claim errors keep the
|
|
51
|
-
* whole payload on `.payload`.
|
|
52
|
-
*/
|
|
53
|
-
export declare class PassflowAuthError extends Error {
|
|
54
|
-
readonly code: PassflowAuthErrorCode;
|
|
55
|
-
readonly reason?: string;
|
|
56
|
-
readonly status: 401 | 503;
|
|
57
|
-
constructor(code: PassflowAuthErrorCode, reason?: InvalidTokenReason, options?: ErrorOptions);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* A programming error, such as reading the claims before any middleware ran. It is deliberately not
|
|
61
|
-
* a `PassflowAuthError`: those mean 401/503, which the browser SDK acts on, and this must reach the
|
|
62
|
-
* framework's error handling as a 500.
|
|
63
|
-
*/
|
|
64
|
-
export declare class PassflowUsageError extends Error {
|
|
65
|
-
constructor(message: string);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* True for a `PassflowAuthError`, including one from the other copy of this package when the ESM
|
|
69
|
-
* and CJS builds are both loaded, where `instanceof` alone would say no.
|
|
70
|
-
*/
|
|
71
|
-
export declare function isPassflowAuthError(e: unknown): e is PassflowAuthError;
|
|
72
|
-
type Requirement = {
|
|
73
|
-
kind: 'acr';
|
|
74
|
-
min: string;
|
|
75
|
-
} | {
|
|
76
|
-
kind: 'fresh';
|
|
77
|
-
maxAgeSeconds: number;
|
|
78
|
-
};
|
|
79
|
-
type Decision = {
|
|
80
|
-
kind: 'allow';
|
|
81
|
-
} | {
|
|
82
|
-
kind: 'reject';
|
|
83
|
-
status: 401 | 500 | 503;
|
|
84
|
-
headers: Record<string, string>;
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Decides one requirement against claims. No claims means the middleware was composed wrongly, so the answer
|
|
88
|
-
* is a 500 with no challenge: never a step-up, which the SDK would try to satisfy, and never a 401, because a
|
|
89
|
-
* wiring bug must not be reported as a bad token. Throws `TypeError` on an invalid requirement.
|
|
90
|
-
*/
|
|
91
|
-
export declare function evaluate(claims: PassflowClaims | undefined, requirement: Requirement): Decision;
|
|
92
|
-
/**
|
|
93
|
-
* Authenticates a request. `existing` claims are reused only when `verifier` produced that exact object;
|
|
94
|
-
* otherwise the presented header is verified with `verifier`, so a token outside this verifier's trust policy
|
|
95
|
-
* is rejected as not valid here, never as insufficient. Never rejects: a failure is a `{ reject }` value.
|
|
96
|
-
*/
|
|
97
|
-
export declare function authenticate(verifier: Verifier, authorization: string | undefined | null, existing?: PassflowClaims): Promise<{
|
|
98
|
-
claims: PassflowClaims;
|
|
99
|
-
} | {
|
|
100
|
-
reject: Decision;
|
|
101
|
-
}>;
|
|
102
|
-
type VerifierConfig = {
|
|
103
|
-
/** Required, exact match against `iss`. */
|
|
104
|
-
issuer: string;
|
|
105
|
-
/** Required: the Passflow application IDs that may call this API. A token must name at least one. */
|
|
106
|
-
audience: string | string[];
|
|
107
|
-
/** Default: `{issuer}/.well-known/jwks.json`, Passflow's fixed path. OIDC discovery is not fetched. */
|
|
108
|
-
jwksUrl?: string;
|
|
109
|
-
/** Permits `http://` on a non-loopback host, for private networks. Default false. */
|
|
110
|
-
allowInsecureJwksUrl?: boolean;
|
|
111
|
-
/** Applies to `exp` and `nbf` only; `iat` is not validated. Default 30. */
|
|
112
|
-
leewaySeconds?: number;
|
|
113
|
-
/** The accepted `type` claims. Default `['access']`. */
|
|
114
|
-
tokenTypes?: string[];
|
|
115
|
-
/** The clock for token checks, `verifiedAt` and the key cache. Default `new Date()`. */
|
|
116
|
-
now?: () => Date;
|
|
117
|
-
jwks?: {
|
|
118
|
-
/**
|
|
119
|
-
* A set older than this keeps answering while it reloads in the background. `0` starts a reload on every
|
|
120
|
-
* verification, gated by `minRefreshInterval`. Default 600000 ms.
|
|
121
|
-
*/
|
|
122
|
-
maxAge?: number;
|
|
123
|
-
/** At most one network attempt per interval for a background reload, after a failure or for an unknown `kid`. Default 30000 ms. */
|
|
124
|
-
minRefreshInterval?: number;
|
|
125
|
-
/** How long after the last successful fetch a stale set is still trusted. Must be `>= maxAge`. Default 3600000 ms. */
|
|
126
|
-
maxStale?: number;
|
|
127
|
-
/** Response body cap. Default 1048576. */
|
|
128
|
-
maxBytes?: number;
|
|
129
|
-
/** Reload timeout, an integer in `[1, 2147483647]` ms. Default 5000. */
|
|
130
|
-
timeout?: number;
|
|
131
|
-
/** Replaces the global `fetch`, for proxies and tests. */
|
|
132
|
-
fetch?: typeof fetch;
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* Builds a verifier from a validated configuration and touches no network: the key set loads on the first
|
|
137
|
-
* `verify`, or on `refresh`. Build one per trust policy, at startup: each owns a key cache, and a verifier
|
|
138
|
-
* built per request would defeat it.
|
|
139
|
-
*/
|
|
140
|
-
export declare function createVerifier(config: VerifierConfig): Verifier;
|
|
141
|
-
export { type Decision, type PassflowAuthErrorCode, type PassflowClaims, type Requirement, type TenantMembership, type Verifier, type VerifierConfig, rolesOf, verifiedBy };
|