@passflow/node 0.1.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@passflow/node",
3
- "version": "0.1.3",
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.",
3
+ "version": "0.3.0",
4
+ "description": "Passflow for Node.js: token verification, ACR floors, auth_time freshness and RFC 9470 step-up challenges for resource servers, with Express, Fastify and Hono adapters, and a server-side sign-in session core for framework adapters.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/usepassflow/go/tree/main/examples/resource-server",
7
7
  "bugs": {
@@ -58,13 +58,40 @@
58
58
  "default": "./dist/hono.cjs"
59
59
  }
60
60
  },
61
+ "./session": {
62
+ "workerd": {
63
+ "types": "./dist/session.d.mts",
64
+ "default": "./dist/session.mjs"
65
+ },
66
+ "worker": {
67
+ "types": "./dist/session.d.mts",
68
+ "default": "./dist/session.mjs"
69
+ },
70
+ "edge-light": {
71
+ "types": "./dist/session.d.mts",
72
+ "default": "./dist/session.mjs"
73
+ },
74
+ "browser": {
75
+ "types": "./dist/session-browser.d.mts",
76
+ "default": "./dist/session-browser.mjs"
77
+ },
78
+ "import": {
79
+ "types": "./dist/session.d.mts",
80
+ "default": "./dist/session.mjs"
81
+ },
82
+ "require": {
83
+ "types": "./dist/session.d.cts",
84
+ "default": "./dist/session.cjs"
85
+ }
86
+ },
61
87
  "./package.json": "./package.json"
62
88
  },
63
89
  "publishConfig": {
64
90
  "access": "public"
65
91
  },
66
92
  "dependencies": {
67
- "jose": "^6.2.14"
93
+ "jose": "^6.2.14",
94
+ "oauth4webapi": "^3.8.8"
68
95
  },
69
96
  "peerDependencies": {
70
97
  "express": "^4.18.0 || ^5.0.0",
@@ -1,51 +0,0 @@
1
- /** The `passflow_tm` wire shape, camelCased. `tenantRoles` is decoded for raw access; `rolesOf` does not read it. */
2
- type TenantMembership = {
3
- tenantId: string;
4
- tenantName?: string;
5
- tenantRoles?: string[];
6
- rootGroupId?: string;
7
- groups?: Record<string, string[]>;
8
- groupNames?: Record<string, string>;
9
- };
10
- type PassflowClaims = {
11
- sub: string;
12
- iss: string;
13
- aud: string[];
14
- exp: number;
15
- iat?: number;
16
- /** Whole Unix seconds. Absent when the claim is absent, not a number or beyond ±2^53. */
17
- authTime?: number;
18
- /** `'0'` when the claim is absent or not a string. */
19
- acr: string;
20
- amr: string[];
21
- scopes: string[];
22
- sid?: string;
23
- type: string;
24
- tenants: Record<string, TenantMembership>;
25
- /** The verifier's clock at verification, in Unix seconds. `requireFresh` measures from it. */
26
- verifiedAt: number;
27
- raw: Record<string, unknown>;
28
- };
29
- /**
30
- * The structural part of a verifier. Declared here, with `verifiedBy`, so that provenance needs nothing
31
- * from the verifier module.
32
- */
33
- interface Verifier {
34
- verify(token: string): Promise<PassflowClaims>;
35
- refresh(): Promise<void>;
36
- }
37
- /**
38
- * True only for the exact object `verifier.verify` returned. A spread or clone loses provenance, which
39
- * costs one more verification and never a bypass. So does any wrapper or decorator object that delegates
40
- * to `verifier.verify`: it is a different identity, and this verifier's adapter re-verifies claims it
41
- * returns. Two verifiers built from the same configuration are different identities too.
42
- */
43
- declare function verifiedBy(claims: PassflowClaims, verifier: Verifier): boolean;
44
- /**
45
- * The roles a user holds in a tenant: `groups[rootGroupId]`, the rule the server's `CalcTenantRoles` and
46
- * `@passflow/core`'s `parseMembership` apply. A missing tenant, root group or map gives an empty list.
47
- * So does an empty `rootGroupId`, unlike the server: no role is granted from a group keyed by "".
48
- * `tenantRoles` is a copy the server derives from the same root group, and is not consulted.
49
- */
50
- declare function rolesOf(claims: PassflowClaims, tenantId: string): string[];
51
- export { verifiedBy as a, rolesOf as i, TenantMembership as n, Verifier as r, PassflowClaims as t };
@@ -1,51 +0,0 @@
1
- /** The `passflow_tm` wire shape, camelCased. `tenantRoles` is decoded for raw access; `rolesOf` does not read it. */
2
- type TenantMembership = {
3
- tenantId: string;
4
- tenantName?: string;
5
- tenantRoles?: string[];
6
- rootGroupId?: string;
7
- groups?: Record<string, string[]>;
8
- groupNames?: Record<string, string>;
9
- };
10
- type PassflowClaims = {
11
- sub: string;
12
- iss: string;
13
- aud: string[];
14
- exp: number;
15
- iat?: number;
16
- /** Whole Unix seconds. Absent when the claim is absent, not a number or beyond ±2^53. */
17
- authTime?: number;
18
- /** `'0'` when the claim is absent or not a string. */
19
- acr: string;
20
- amr: string[];
21
- scopes: string[];
22
- sid?: string;
23
- type: string;
24
- tenants: Record<string, TenantMembership>;
25
- /** The verifier's clock at verification, in Unix seconds. `requireFresh` measures from it. */
26
- verifiedAt: number;
27
- raw: Record<string, unknown>;
28
- };
29
- /**
30
- * The structural part of a verifier. Declared here, with `verifiedBy`, so that provenance needs nothing
31
- * from the verifier module.
32
- */
33
- interface Verifier {
34
- verify(token: string): Promise<PassflowClaims>;
35
- refresh(): Promise<void>;
36
- }
37
- /**
38
- * True only for the exact object `verifier.verify` returned. A spread or clone loses provenance, which
39
- * costs one more verification and never a bypass. So does any wrapper or decorator object that delegates
40
- * to `verifier.verify`: it is a different identity, and this verifier's adapter re-verifies claims it
41
- * returns. Two verifiers built from the same configuration are different identities too.
42
- */
43
- declare function verifiedBy(claims: PassflowClaims, verifier: Verifier): boolean;
44
- /**
45
- * The roles a user holds in a tenant: `groups[rootGroupId]`, the rule the server's `CalcTenantRoles` and
46
- * `@passflow/core`'s `parseMembership` apply. A missing tenant, root group or map gives an empty list.
47
- * So does an empty `rootGroupId`, unlike the server: no role is granted from a group keyed by "".
48
- * `tenantRoles` is a copy the server derives from the same root group, and is not consulted.
49
- */
50
- declare function rolesOf(claims: PassflowClaims, tenantId: string): string[];
51
- export { verifiedBy as a, rolesOf as i, TenantMembership as n, Verifier as r, PassflowClaims as t };