@aiam/ciba 0.9.4 → 0.9.5
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 +1 -1
- package/token.mjs +16 -5
package/package.json
CHANGED
package/token.mjs
CHANGED
|
@@ -30,11 +30,22 @@ const args = process.argv.slice(2);
|
|
|
30
30
|
const get = (flag) => { const i = args.indexOf(flag); return i !== -1 ? args[i + 1] : undefined; };
|
|
31
31
|
const has = (flag) => args.includes(flag);
|
|
32
32
|
|
|
33
|
-
const resource
|
|
34
|
-
const jsonOut
|
|
35
|
-
const envOut
|
|
33
|
+
const resource = get('--resource') ?? `urn:sap:destination:${process.env.CIBA_DEFAULT_DESTINATION || 'WEBAGENTS_BACKEND'}`;
|
|
34
|
+
const jsonOut = has('--json');
|
|
35
|
+
const envOut = has('--env');
|
|
36
36
|
const isRefresh = has('--refresh');
|
|
37
37
|
|
|
38
|
+
// Collect all unrecognised --key value pairs as extra request attrs.
|
|
39
|
+
// Server uses them for login-hint, tenant, scope, app_tid, etc.
|
|
40
|
+
const KNOWN = new Set(['--resource', '--url', '--json', '--env', '--refresh']);
|
|
41
|
+
const extraAttrs = {};
|
|
42
|
+
for (let i = 0; i < args.length; i++) {
|
|
43
|
+
if (args[i].startsWith('--') && !KNOWN.has(args[i]) && i + 1 < args.length && !args[i + 1].startsWith('--')) {
|
|
44
|
+
extraAttrs[args[i].slice(2).replace(/-/g, '_')] = args[i + 1];
|
|
45
|
+
i++;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
38
49
|
// ─── Config ───────────────────────────────────────────────────────────────────
|
|
39
50
|
|
|
40
51
|
function loadConfig() {
|
|
@@ -198,7 +209,7 @@ if (isRefresh) {
|
|
|
198
209
|
const requests = deviceDoc.getMap('requests');
|
|
199
210
|
const newRid = randomBytes(8).toString('base64url');
|
|
200
211
|
log(`→ refresh — writing request ${newRid}`);
|
|
201
|
-
requests.set(newRid, { resource, status: 'pending', created_at: new Date().toISOString() });
|
|
212
|
+
requests.set(newRid, { ...extraAttrs, resource, status: 'pending', created_at: new Date().toISOString() });
|
|
202
213
|
provider.destroy();
|
|
203
214
|
process.exit(0);
|
|
204
215
|
}
|
|
@@ -217,7 +228,7 @@ if (found) {
|
|
|
217
228
|
const requests = deviceDoc.getMap('requests');
|
|
218
229
|
const newRid = randomBytes(8).toString('base64url');
|
|
219
230
|
log(`→ cache miss — writing request ${newRid} resource=${resolvedResource}`);
|
|
220
|
-
requests.set(newRid, { resource: resolvedResource, status: 'pending', created_at: new Date().toISOString() });
|
|
231
|
+
requests.set(newRid, { ...extraAttrs, resource: resolvedResource, status: 'pending', created_at: new Date().toISOString() });
|
|
221
232
|
|
|
222
233
|
// Wait for resources to update
|
|
223
234
|
log('→ waiting for token...');
|