@passflow/node 0.1.2 → 0.1.3
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 +1 -1
- package/dist/express.cjs +2 -2
- package/dist/express.mjs +2 -2
- package/dist/fastify.cjs +2 -2
- package/dist/fastify.mjs +2 -2
- package/dist/hono.cjs +1 -2
- package/dist/hono.mjs +1 -2
- package/dist/index.d.cts +6 -2
- package/dist/index.d.mts +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ app.get('/invoices', passflow.requireACR(AAL2), (req, res) => res.json({ sub: ge
|
|
|
21
21
|
app.post('/transfers', passflow.requireFresh(300), (_req, res) => res.json({ ok: true }));
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
`audience` is the ID of a Passflow application, or a list of them. The Passflow documentation has step-by-step tutorials for Express, Fastify and Hono (
|
|
24
|
+
`audience` is the ID of a Passflow application, or a list of them. The Passflow documentation has step-by-step tutorials for Express, Fastify and Hono ([Protect a Node API](https://docs.usepassflow.com/get-started/node-api)) and a runnable API in [`examples/resource-server`](https://github.com/usepassflow/go/tree/main/examples/resource-server).
|
|
25
25
|
|
|
26
26
|
## Use it with a framework
|
|
27
27
|
|
package/dist/express.cjs
CHANGED
|
@@ -2,8 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_evaluate = require("./evaluate-C20MecTf.cjs");
|
|
3
3
|
// src/express.ts
|
|
4
4
|
/** Written directly and never through `next(err)`: a custom error handler would drop `WWW-Authenticate`. */
|
|
5
|
-
function send(res,
|
|
6
|
-
|
|
5
|
+
function send(res, rejection) {
|
|
6
|
+
res.status(rejection.status).set(rejection.headers).end();
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Express 4 and 5 middleware. `authenticate` always verifies the presented token and replaces any claims on the
|
package/dist/express.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as guard, d as withChallengeHeader, n as assertVerifier, s as PassflowUsageError, t as assertRequirement } from "./evaluate-BTuol-Oa.mjs";
|
|
2
2
|
// src/express.ts
|
|
3
3
|
/** Written directly and never through `next(err)`: a custom error handler would drop `WWW-Authenticate`. */
|
|
4
|
-
function send(res,
|
|
5
|
-
|
|
4
|
+
function send(res, rejection) {
|
|
5
|
+
res.status(rejection.status).set(rejection.headers).end();
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Express 4 and 5 middleware. `authenticate` always verifies the presented token and replaces any claims on the
|
package/dist/fastify.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_evaluate = require("./evaluate-C20MecTf.cjs");
|
|
3
3
|
// src/fastify.ts
|
|
4
|
-
function send(reply,
|
|
5
|
-
|
|
4
|
+
function send(reply, rejection) {
|
|
5
|
+
reply.code(rejection.status).headers(rejection.headers).send();
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Hooks for one verifier, with no plugin and no decoration, callable any number of times: the way to use a second
|
package/dist/fastify.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as guard, d as withChallengeHeader, n as assertVerifier, s as PassflowUsageError, t as assertRequirement } from "./evaluate-BTuol-Oa.mjs";
|
|
2
2
|
// src/fastify.ts
|
|
3
|
-
function send(reply,
|
|
4
|
-
|
|
3
|
+
function send(reply, rejection) {
|
|
4
|
+
reply.code(rejection.status).headers(rejection.headers).send();
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* Hooks for one verifier, with no plugin and no decoration, callable any number of times: the way to use a second
|
package/dist/hono.cjs
CHANGED
|
@@ -2,8 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_evaluate = require("./evaluate-C20MecTf.cjs");
|
|
3
3
|
// src/hono.ts
|
|
4
4
|
/** `c.body` rather than a thrown HTTPException, so headers `hono/cors` already set survive the rejection. */
|
|
5
|
-
function send(c,
|
|
6
|
-
const { status, headers } = decision;
|
|
5
|
+
function send(c, { status, headers }) {
|
|
7
6
|
return c.body(null, status, headers);
|
|
8
7
|
}
|
|
9
8
|
/**
|
package/dist/hono.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { a as guard, d as withChallengeHeader, n as assertVerifier, s as PassflowUsageError, t as assertRequirement } from "./evaluate-BTuol-Oa.mjs";
|
|
2
2
|
// src/hono.ts
|
|
3
3
|
/** `c.body` rather than a thrown HTTPException, so headers `hono/cors` already set survive the rejection. */
|
|
4
|
-
function send(c,
|
|
5
|
-
const { status, headers } = decision;
|
|
4
|
+
function send(c, { status, headers }) {
|
|
6
5
|
return c.body(null, status, headers);
|
|
7
6
|
}
|
|
8
7
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -83,6 +83,10 @@ type Decision = {
|
|
|
83
83
|
status: 401 | 500 | 503;
|
|
84
84
|
headers: Record<string, string>;
|
|
85
85
|
};
|
|
86
|
+
/** A rejected `Decision`: a `ResponseInit` as it stands (`new Response(null, rejection)`). */
|
|
87
|
+
type Rejection = Extract<Decision, {
|
|
88
|
+
kind: 'reject';
|
|
89
|
+
}>;
|
|
86
90
|
/**
|
|
87
91
|
* Decides one requirement against claims. No claims means the middleware was composed wrongly, so the answer
|
|
88
92
|
* is a 500 with no challenge: never a step-up, which the SDK would try to satisfy, and never a 401, because a
|
|
@@ -97,7 +101,7 @@ export declare function evaluate(claims: PassflowClaims | undefined, requirement
|
|
|
97
101
|
export declare function authenticate(verifier: Verifier, authorization: string | undefined | null, existing?: PassflowClaims): Promise<{
|
|
98
102
|
claims: PassflowClaims;
|
|
99
103
|
} | {
|
|
100
|
-
reject:
|
|
104
|
+
reject: Rejection;
|
|
101
105
|
}>;
|
|
102
106
|
type VerifierConfig = {
|
|
103
107
|
/** Required, exact match against `iss`. */
|
|
@@ -138,4 +142,4 @@ type VerifierConfig = {
|
|
|
138
142
|
* built per request would defeat it.
|
|
139
143
|
*/
|
|
140
144
|
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 };
|
|
145
|
+
export { type Decision, type PassflowAuthErrorCode, type PassflowClaims, type Rejection, type Requirement, type TenantMembership, type Verifier, type VerifierConfig, rolesOf, verifiedBy };
|
package/dist/index.d.mts
CHANGED
|
@@ -83,6 +83,10 @@ type Decision = {
|
|
|
83
83
|
status: 401 | 500 | 503;
|
|
84
84
|
headers: Record<string, string>;
|
|
85
85
|
};
|
|
86
|
+
/** A rejected `Decision`: a `ResponseInit` as it stands (`new Response(null, rejection)`). */
|
|
87
|
+
type Rejection = Extract<Decision, {
|
|
88
|
+
kind: 'reject';
|
|
89
|
+
}>;
|
|
86
90
|
/**
|
|
87
91
|
* Decides one requirement against claims. No claims means the middleware was composed wrongly, so the answer
|
|
88
92
|
* is a 500 with no challenge: never a step-up, which the SDK would try to satisfy, and never a 401, because a
|
|
@@ -97,7 +101,7 @@ export declare function evaluate(claims: PassflowClaims | undefined, requirement
|
|
|
97
101
|
export declare function authenticate(verifier: Verifier, authorization: string | undefined | null, existing?: PassflowClaims): Promise<{
|
|
98
102
|
claims: PassflowClaims;
|
|
99
103
|
} | {
|
|
100
|
-
reject:
|
|
104
|
+
reject: Rejection;
|
|
101
105
|
}>;
|
|
102
106
|
type VerifierConfig = {
|
|
103
107
|
/** Required, exact match against `iss`. */
|
|
@@ -138,4 +142,4 @@ type VerifierConfig = {
|
|
|
138
142
|
* built per request would defeat it.
|
|
139
143
|
*/
|
|
140
144
|
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 };
|
|
145
|
+
export { type Decision, type PassflowAuthErrorCode, type PassflowClaims, type Rejection, type Requirement, type TenantMembership, type Verifier, type VerifierConfig, rolesOf, verifiedBy };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@passflow/node",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Passflow authorization primitives for Node.js resource servers: token verification, ACR floors, auth_time freshness and RFC 9470 step-up challenges, with Express, Fastify and Hono adapters.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/usepassflow/go/tree/main/examples/resource-server",
|