@aiam/ciba 0.9.3 → 0.9.4
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 +11 -0
package/package.json
CHANGED
package/token.mjs
CHANGED
|
@@ -224,6 +224,7 @@ log('→ waiting for token...');
|
|
|
224
224
|
const token = await new Promise((resolve, reject) => {
|
|
225
225
|
const timer = setTimeout(() => {
|
|
226
226
|
resourcesMap.unobserve(observer);
|
|
227
|
+
log(`→ timeout — resources at that point: ${JSON.stringify([...resourcesMap.entries()])}`);
|
|
227
228
|
reject(new Error('Timeout waiting for token'));
|
|
228
229
|
}, 30_000);
|
|
229
230
|
|
|
@@ -237,6 +238,16 @@ const token = await new Promise((resolve, reject) => {
|
|
|
237
238
|
}
|
|
238
239
|
};
|
|
239
240
|
resourcesMap.observe(observer);
|
|
241
|
+
// Also observe provider synced events in case doc re-syncs
|
|
242
|
+
provider.on('synced', () => {
|
|
243
|
+
log(`→ re-synced — resources: ${JSON.stringify([...resourcesMap.entries()])}`);
|
|
244
|
+
const found = tryGet(resourcesMap, deviceDoc, resolvedResource);
|
|
245
|
+
if (found) {
|
|
246
|
+
clearTimeout(timer);
|
|
247
|
+
resourcesMap.unobserve(observer);
|
|
248
|
+
resolve(decrypt(found));
|
|
249
|
+
}
|
|
250
|
+
});
|
|
240
251
|
});
|
|
241
252
|
|
|
242
253
|
provider.destroy();
|