@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.
@@ -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 contact = nullIfEmpty(read(ACTOR_HEADERS.contact));
131
- const permissions = read(ACTOR_HEADERS.permissions).split(",").map((p) => p.trim()).filter(Boolean);
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: nullIfEmpty(read(ACTOR_HEADERS.organization)),
155
+ organization,
156
+ rep,
141
157
  permissions,
142
158
  trust,
143
159
  plane,