@revenexx/app-sdk 1.5.0 → 1.6.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/README.md +18 -5
- package/dist/{chunk-PXQA7E4F.js → chunk-FMHCS3ZH.js} +10 -3
- package/dist/chunk-FMHCS3ZH.js.map +1 -0
- package/dist/index.cjs +9 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/router/index.cjs +22 -6
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +30 -6
- package/dist/router/index.d.ts +30 -6
- package/dist/router/index.js +23 -7
- package/dist/router/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-PXQA7E4F.js.map +0 -1
package/dist/router/index.cjs
CHANGED
|
@@ -118,26 +118,42 @@ var ACTOR_HEADERS = {
|
|
|
118
118
|
trust: "x-revenexx-actor-trust",
|
|
119
119
|
contact: "x-revenexx-contact",
|
|
120
120
|
organization: "x-revenexx-organization",
|
|
121
|
-
permissions: "x-revenexx-permissions"
|
|
121
|
+
permissions: "x-revenexx-permissions",
|
|
122
|
+
/** `contact` or `rep` — the kind of person the gateway resolved. */
|
|
123
|
+
caller: "x-revenexx-caller",
|
|
124
|
+
/** The rep's code, beside `caller: rep`, percent-encoded as UTF-8 (RFC 3986). */
|
|
125
|
+
rep: "x-revenexx-rep"
|
|
122
126
|
};
|
|
123
127
|
var nullIfEmpty = (v) => v.trim() === "" ? null : v.trim();
|
|
128
|
+
var decodeRep = (v) => {
|
|
129
|
+
if (v === null) return null;
|
|
130
|
+
try {
|
|
131
|
+
return nullIfEmpty(decodeURIComponent(v));
|
|
132
|
+
} catch {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
124
136
|
function actorFrom(header) {
|
|
125
137
|
const read = (name) => {
|
|
126
138
|
const v = header(name);
|
|
127
139
|
return typeof v === "string" ? v : "";
|
|
128
140
|
};
|
|
129
141
|
const user = nullIfEmpty(read(ACTOR_HEADERS.user));
|
|
130
|
-
const
|
|
131
|
-
const
|
|
142
|
+
const isRepCall = read(ACTOR_HEADERS.caller).trim().toLowerCase() === "rep";
|
|
143
|
+
const rep = isRepCall ? decodeRep(nullIfEmpty(read(ACTOR_HEADERS.rep))) : null;
|
|
144
|
+
const contact = isRepCall ? null : nullIfEmpty(read(ACTOR_HEADERS.contact));
|
|
145
|
+
const organization = isRepCall ? null : nullIfEmpty(read(ACTOR_HEADERS.organization));
|
|
146
|
+
const permissions = isRepCall && rep === null ? [] : read(ACTOR_HEADERS.permissions).split(",").map((p) => p.trim()).filter(Boolean);
|
|
132
147
|
const raw = read(ACTOR_HEADERS.trust).trim().toLowerCase();
|
|
133
|
-
const trust = user === null && contact === null ? "none" : user !== null && raw === "authenticated" ? "authenticated" : "asserted";
|
|
134
|
-
const plane = contact !== null ? "contact" : user !== null ? "operator" : "system";
|
|
148
|
+
const trust = user === null && contact === null && rep === null ? "none" : !isRepCall && user !== null && raw === "authenticated" ? "authenticated" : "asserted";
|
|
149
|
+
const plane = rep !== null ? "rep" : contact !== null ? "contact" : user !== null ? "operator" : "system";
|
|
135
150
|
const held = new Set(permissions);
|
|
136
151
|
return {
|
|
137
152
|
user,
|
|
138
153
|
email: nullIfEmpty(read(ACTOR_HEADERS.email)),
|
|
139
154
|
contact,
|
|
140
|
-
organization
|
|
155
|
+
organization,
|
|
156
|
+
rep,
|
|
141
157
|
permissions,
|
|
142
158
|
trust,
|
|
143
159
|
plane,
|