@hadoku/service-kernel 0.1.103 → 0.1.104
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/auth/index.d.ts +7 -14
- package/dist/auth/index.js +10 -19
- package/dist/http/index.d.ts +1 -1
- package/package.json +2 -2
package/dist/auth/index.d.ts
CHANGED
|
@@ -78,22 +78,15 @@ export interface EdgeAuth {
|
|
|
78
78
|
/** Build the three functions that need the app's own edge-auth secret and dev hatch. */
|
|
79
79
|
export declare function createEdgeAuth(config: EdgeAuthConfig): EdgeAuth;
|
|
80
80
|
/**
|
|
81
|
-
* The caller's tier as the app's headers carry it, except that a
|
|
82
|
-
* member
|
|
83
|
-
*
|
|
84
|
-
* Never above friend: admin stays admin's, and a guest is
|
|
85
|
-
*
|
|
86
|
-
*
|
|
81
|
+
* The caller's tier as the app's headers carry it, except that a member IS a
|
|
82
|
+
* friend here: `member` is a guest the operator has verified, and an app that
|
|
83
|
+
* admits members alongside the tiers it hands out may treat that verification
|
|
84
|
+
* the same as a vouch. Never above friend: admin stays admin's, and a guest is
|
|
85
|
+
* never promoted. Read from the tier alone; the edge's `X-Hadoku-Verified` says
|
|
86
|
+
* nothing the tier does not. Pure — only `sanitizeHeaders` decides whether a
|
|
87
|
+
* header is trustworthy in the first place.
|
|
87
88
|
*/
|
|
88
89
|
export declare function tierOf(req: Request): string;
|
|
89
|
-
/**
|
|
90
|
-
* Is this caller verified (`X-Hadoku-Verified: 1`)? Absent means not
|
|
91
|
-
* verified. Pure: trustworthiness is `sanitizeHeaders`'s job, done before this
|
|
92
|
-
* is ever read.
|
|
93
|
-
*/
|
|
94
|
-
export declare function verifiedOf(req: Request): boolean;
|
|
95
|
-
/** `verifiedOf` for a socket's handshake, whose headers went through the same sanitizing. */
|
|
96
|
-
export declare function verifiedFromHeaders(headers: IncomingHttpHeaders): boolean;
|
|
97
90
|
/** The caller's userId as the edge stamped it; null when the edge named nobody. */
|
|
98
91
|
export declare function callerIdOf(req: Request): string | null;
|
|
99
92
|
export declare function userIdOf(req: Request): string;
|
package/dist/auth/index.js
CHANGED
|
@@ -107,6 +107,8 @@ export function createEdgeAuth(config) {
|
|
|
107
107
|
delete headers['x-user-id'];
|
|
108
108
|
delete headers['x-user-name'];
|
|
109
109
|
delete headers['x-user-key'];
|
|
110
|
+
// Nothing here reads X-Hadoku-Verified any more (the tier says it), but the edge still sends it
|
|
111
|
+
// until every repo has stopped reading it; a forged copy must never survive an unproven request.
|
|
110
112
|
delete headers['x-hadoku-verified'];
|
|
111
113
|
}
|
|
112
114
|
function edgeSealed(req) {
|
|
@@ -119,29 +121,18 @@ export function createEdgeAuth(config) {
|
|
|
119
121
|
return { sanitizeHeaders, edgeSealed, edgeProvenance };
|
|
120
122
|
}
|
|
121
123
|
/**
|
|
122
|
-
* The caller's tier as the app's headers carry it, except that a
|
|
123
|
-
* member
|
|
124
|
-
*
|
|
125
|
-
* Never above friend: admin stays admin's, and a guest is
|
|
126
|
-
*
|
|
127
|
-
*
|
|
124
|
+
* The caller's tier as the app's headers carry it, except that a member IS a
|
|
125
|
+
* friend here: `member` is a guest the operator has verified, and an app that
|
|
126
|
+
* admits members alongside the tiers it hands out may treat that verification
|
|
127
|
+
* the same as a vouch. Never above friend: admin stays admin's, and a guest is
|
|
128
|
+
* never promoted. Read from the tier alone; the edge's `X-Hadoku-Verified` says
|
|
129
|
+
* nothing the tier does not. Pure — only `sanitizeHeaders` decides whether a
|
|
130
|
+
* header is trustworthy in the first place.
|
|
128
131
|
*/
|
|
129
132
|
export function tierOf(req) {
|
|
130
133
|
const t = req.headers['x-hadoku-tier'];
|
|
131
134
|
const tier = typeof t === 'string' && t !== '' ? t : 'public';
|
|
132
|
-
return tier === 'member'
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Is this caller verified (`X-Hadoku-Verified: 1`)? Absent means not
|
|
136
|
-
* verified. Pure: trustworthiness is `sanitizeHeaders`'s job, done before this
|
|
137
|
-
* is ever read.
|
|
138
|
-
*/
|
|
139
|
-
export function verifiedOf(req) {
|
|
140
|
-
return verifiedFromHeaders(req.headers);
|
|
141
|
-
}
|
|
142
|
-
/** `verifiedOf` for a socket's handshake, whose headers went through the same sanitizing. */
|
|
143
|
-
export function verifiedFromHeaders(headers) {
|
|
144
|
-
return headers['x-hadoku-verified'] === '1';
|
|
135
|
+
return tier === 'member' ? 'friend' : tier;
|
|
145
136
|
}
|
|
146
137
|
/** The caller's userId as the edge stamped it; null when the edge named nobody. */
|
|
147
138
|
export function callerIdOf(req) {
|
package/dist/http/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface GateDeps {
|
|
|
22
22
|
sanitizeHeaders(headers: Record<string, unknown>): void;
|
|
23
23
|
/** Express/engine.io middleware that does the same, for a socket's handshake (the app's `createEdgeAuth(...).edgeProvenance`). */
|
|
24
24
|
edgeProvenance(req: Request, res: Response, next: NextFunction): void;
|
|
25
|
-
/** The app's own `tierOf` (its auth binding's, so a
|
|
25
|
+
/** The app's own `tierOf` (its auth binding's, so a member-to-friend promotion if any applies). */
|
|
26
26
|
tierOf(req: Request): string;
|
|
27
27
|
rankOf(tier: string): number;
|
|
28
28
|
reportSealRefused: SealRefusedReporter;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadoku/service-kernel",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "0.1.104",
|
|
4
|
+
"gitHead": "eb198fb94e7021c2f65fa71802c1dab746741a1b",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "The server parts any game keeps: edge auth and the tier gate, base path and bundle check, health and the busy probe, lifecycle, the JSON logger, the state directory, telemetry and capacity, per-caller limits, the browser relays, the erase registry, and createGameServer, which boots a game from its config and plugins. Knows no game; the app binds its service id, prefix and env names. MIT; imports only node built-ins, express, socket.io and @wolffm/*.",
|