@aiam/ciba 0.9.1 → 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 +4 -5
package/package.json
CHANGED
package/token.mjs
CHANGED
|
@@ -106,14 +106,13 @@ function decrypt(map) {
|
|
|
106
106
|
// ─── tryGet ───────────────────────────────────────────────────────────────────
|
|
107
107
|
|
|
108
108
|
function tryGet(resourcesMap, deviceDoc, res) {
|
|
109
|
-
const key = res
|
|
109
|
+
const key = res
|
|
110
|
+
? resourcesMap.get(res)
|
|
111
|
+
: [...resourcesMap.values()][0];
|
|
110
112
|
if (!key) return null;
|
|
111
113
|
const map = deviceDoc.getMap(key);
|
|
112
114
|
const expiresAt = map.get('expires_at');
|
|
113
|
-
if (expiresAt && expiresAt < Date.now())
|
|
114
|
-
log(` token for ${res ?? 'default'} found but expired`);
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
115
|
+
if (expiresAt && expiresAt < Date.now()) return null; // expired
|
|
117
116
|
if (!map.get('ciphertext')) return null;
|
|
118
117
|
return map;
|
|
119
118
|
}
|