@aiam/ciba 0.9.2 → 0.9.3
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 +9 -32
package/package.json
CHANGED
package/token.mjs
CHANGED
|
@@ -106,38 +106,15 @@ function decrypt(map) {
|
|
|
106
106
|
// ─── tryGet ───────────────────────────────────────────────────────────────────
|
|
107
107
|
|
|
108
108
|
function tryGet(resourcesMap, deviceDoc, res) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (res === 'webagents') aliases.push('urn:sap:destination:WEBAGENTS_BACKEND', 'urn:sap:destination:web_agents_gateway');
|
|
119
|
-
if (res === 'a2a') aliases.push('urn:sap:identity:application:provider:name:agent-gateway');
|
|
120
|
-
}
|
|
121
|
-
// No resource = try first entry
|
|
122
|
-
if (!res) {
|
|
123
|
-
const first = [...resourcesMap.values()][0];
|
|
124
|
-
if (!first) return null;
|
|
125
|
-
const map = deviceDoc.getMap(first);
|
|
126
|
-
const expiresAt = map.get('expires_at');
|
|
127
|
-
if (expiresAt && expiresAt < Date.now()) return null;
|
|
128
|
-
if (!map.get('ciphertext')) return null;
|
|
129
|
-
return map;
|
|
130
|
-
}
|
|
131
|
-
for (const alias of aliases) {
|
|
132
|
-
const key = resourcesMap.get(alias);
|
|
133
|
-
if (!key) continue;
|
|
134
|
-
const map = deviceDoc.getMap(key);
|
|
135
|
-
const expiresAt = map.get('expires_at');
|
|
136
|
-
if (expiresAt && expiresAt < Date.now()) continue;
|
|
137
|
-
if (!map.get('ciphertext')) continue;
|
|
138
|
-
return map;
|
|
139
|
-
}
|
|
140
|
-
return null;
|
|
109
|
+
const key = res
|
|
110
|
+
? resourcesMap.get(res)
|
|
111
|
+
: [...resourcesMap.values()][0];
|
|
112
|
+
if (!key) return null;
|
|
113
|
+
const map = deviceDoc.getMap(key);
|
|
114
|
+
const expiresAt = map.get('expires_at');
|
|
115
|
+
if (expiresAt && expiresAt < Date.now()) return null; // expired
|
|
116
|
+
if (!map.get('ciphertext')) return null;
|
|
117
|
+
return map;
|
|
141
118
|
}
|
|
142
119
|
|
|
143
120
|
// ─── Output ───────────────────────────────────────────────────────────────────
|