@aiam/ciba 0.8.5 → 0.8.6

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.
Files changed (2) hide show
  1. package/ciba.mjs +4 -22
  2. package/package.json +1 -1
package/ciba.mjs CHANGED
@@ -439,22 +439,10 @@ function startDaemon(provider, deviceDoc, privateKey, serverUrl) {
439
439
  const requests = deviceDoc.getMap('requests');
440
440
  const resourcesMap = deviceDoc.getMap('resources');
441
441
 
442
+ // Pass attrs straight through — server resolves grant_type from resource URN.
442
443
  const attrs = { ...(req.attrs || {}) };
443
- const resourceUrn = attrs.resource;
444
- if (!attrs.grant_type && typeof resourceUrn === 'string') {
445
- if (resourceUrn.startsWith('urn:sap:destination:')) {
446
- attrs.grant_type = 'urn:sap:destination';
447
- if (!attrs.destination) attrs.destination = resourceUrn.slice('urn:sap:destination:'.length);
448
- } else if (resourceUrn.startsWith('urn:sap:identity:') || resourceUrn.startsWith('urn:ietf:params:oauth:resource:')) {
449
- attrs.grant_type = 'urn:ietf:params:oauth:grant-type:jwt-bearer';
450
- }
451
- }
452
-
453
444
  const defaultResource = `urn:sap:destination:${process.env.CIBA_DEFAULT_DESTINATION || 'WEBAGENTS_BACKEND'}`;
454
- const requestedResource =
455
- attrs.grant_type === 'urn:sap:destination' && attrs.destination
456
- ? `urn:sap:destination:${attrs.destination}`
457
- : attrs.resource ?? defaultResource;
445
+ const requestedResource = attrs.resource ?? defaultResource;
458
446
 
459
447
  const decryptFromTokenMap = (tokenMap) => {
460
448
  const ciphertext = tokenMap.get('ciphertext');
@@ -466,14 +454,8 @@ function startDaemon(provider, deviceDoc, privateKey, serverUrl) {
466
454
  };
467
455
 
468
456
  if (req.command === 'refresh') {
469
- // Fire-and-forget: write the request, return immediately.
470
- // Server exchanges async; result lands on device doc via Yjs.
471
- // Default to the same resource as `ciba token` when none specified.
472
- if (!attrs.grant_type && !attrs.resource && !attrs.destination) {
473
- attrs.resource = `urn:sap:destination:${process.env.CIBA_DEFAULT_DESTINATION || 'WEBAGENTS_BACKEND'}`;
474
- attrs.grant_type = 'urn:sap:destination';
475
- attrs.destination = process.env.CIBA_DEFAULT_DESTINATION || 'WEBAGENTS_BACKEND';
476
- }
457
+ // Fire-and-forget just set default resource if none given.
458
+ if (!attrs.resource) attrs.resource = defaultResource;
477
459
  const newRid = randomBytes(8).toString('base64url');
478
460
  dlog(`refresh; writing requests[${newRid}] attrs=${JSON.stringify(attrs)}`);
479
461
  requests.set(newRid, { ...attrs, status: 'pending', created_at: new Date().toISOString() });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiam/ciba",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "description": "OAuth 2.0 Device Authorization Grant CLI with cross-device push approval (Yjs sync, ECDH-encrypted token delivery, persistent device id)",
5
5
  "type": "module",
6
6
  "bin": {