@byok-sdk/cloud 0.10.1 → 0.10.2
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/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/dist/stores/in-memory/device-directory.d.ts +13 -3
- package/dist/stores/ports.d.ts +33 -8
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3310,17 +3310,18 @@ var InMemoryDeviceDirectory = class {
|
|
|
3310
3310
|
devicePublicKey: input.devicePublicKey,
|
|
3311
3311
|
proofKeyId: input.proofKeyId,
|
|
3312
3312
|
proofKeyEpoch: input.proofKeyEpoch,
|
|
3313
|
+
// Always false, and there is no writer that sets it true — see the file
|
|
3314
|
+
// header. The field stays because every auth path reads it.
|
|
3313
3315
|
revoked: false,
|
|
3314
3316
|
...input.machineId === void 0 ? {} : { machineId: input.machineId }
|
|
3315
3317
|
};
|
|
3316
3318
|
if (input.machineId !== void 0) {
|
|
3317
|
-
for (const [key2, existing] of this.#byTenant) {
|
|
3318
|
-
if (existing.revoked) continue;
|
|
3319
|
+
for (const [key2, existing] of [...this.#byTenant]) {
|
|
3319
3320
|
if (existing.deviceId === record.deviceId) continue;
|
|
3320
3321
|
if (existing.tenantId !== tenant) continue;
|
|
3321
3322
|
if (existing.productId !== input.productId) continue;
|
|
3322
3323
|
if (existing.machineId !== input.machineId) continue;
|
|
3323
|
-
this.#
|
|
3324
|
+
this.#forget(key2, existing.deviceId);
|
|
3324
3325
|
}
|
|
3325
3326
|
}
|
|
3326
3327
|
const key = tenantKey(tenant, record.deviceId);
|
|
@@ -3331,11 +3332,24 @@ var InMemoryDeviceDirectory = class {
|
|
|
3331
3332
|
async get(tenant, deviceId) {
|
|
3332
3333
|
return this.#byTenant.get(tenantKey(tenant, deviceId));
|
|
3333
3334
|
}
|
|
3335
|
+
/**
|
|
3336
|
+
* Revocation removes the registration. A no-op for a device this tenant does
|
|
3337
|
+
* not own: revoking what you cannot address changes nothing.
|
|
3338
|
+
*/
|
|
3334
3339
|
async revoke(tenant, deviceId) {
|
|
3335
3340
|
const key = tenantKey(tenant, deviceId);
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3341
|
+
if (!this.#byTenant.has(key)) return;
|
|
3342
|
+
this.#forget(key, deviceId);
|
|
3343
|
+
}
|
|
3344
|
+
/**
|
|
3345
|
+
* Drops a record from the composite map and, only when it still points here,
|
|
3346
|
+
* from the pre-tenant index. A re-registration under the same deviceId has
|
|
3347
|
+
* already re-pointed that index, and a stale delete would blind
|
|
3348
|
+
* `/byok/challenge` to a device that is currently paired.
|
|
3349
|
+
*/
|
|
3350
|
+
#forget(key, deviceId) {
|
|
3351
|
+
this.#byTenant.delete(key);
|
|
3352
|
+
if (this.#byDeviceId.get(deviceId) === key) this.#byDeviceId.delete(deviceId);
|
|
3339
3353
|
}
|
|
3340
3354
|
async recordCapabilities(tenant, input) {
|
|
3341
3355
|
const key = tenantKey(tenant, input.deviceId);
|