@byok-sdk/cloud 0.9.0 → 0.10.0

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.
@@ -29,6 +29,8 @@ export interface PairInput {
29
29
  readonly pairingCode: string;
30
30
  readonly deviceName: string;
31
31
  readonly devicePublicKey: string;
32
+ /** Optional client-hashed machine identity (protocol §6.1). Carried into registration verbatim; it is never a tenant or product authority. */
33
+ readonly machineId?: string;
32
34
  }
33
35
  export interface MintedAccessToken {
34
36
  readonly accessToken: string;
package/dist/index.js CHANGED
@@ -190,7 +190,8 @@ function createAuthPlane(deps) {
190
190
  deviceName: input.deviceName,
191
191
  devicePublicKey: input.devicePublicKey,
192
192
  proofKeyId: DEVICE_IDENTITY_PROOF_KEY_ID,
193
- proofKeyEpoch: DEVICE_IDENTITY_PROOF_KEY_EPOCH
193
+ proofKeyEpoch: DEVICE_IDENTITY_PROOF_KEY_EPOCH,
194
+ ...input.machineId === void 0 ? {} : { machineId: input.machineId }
194
195
  });
195
196
  },
196
197
  async resolveDevice(deviceId) {
@@ -833,7 +834,12 @@ function pairHandler(deps) {
833
834
  return async (c) => {
834
835
  const parsed = PairRequestSchema.safeParse(await readJsonBody(c));
835
836
  if (!parsed.success) {
836
- return c.json({ error: "pairingCode, deviceName, and devicePublicKey are required strings" }, 400);
837
+ return c.json(
838
+ {
839
+ error: "pairingCode, deviceName, and devicePublicKey are required strings; optional machineId must be 64 lowercase hex characters"
840
+ },
841
+ 400
842
+ );
837
843
  }
838
844
  const device = await deps.auth.redeemAndRegister(parsed.data);
839
845
  if (device === void 0) return c.json({ error: "invalid pairing code" }, 401);
@@ -3304,8 +3310,19 @@ var InMemoryDeviceDirectory = class {
3304
3310
  devicePublicKey: input.devicePublicKey,
3305
3311
  proofKeyId: input.proofKeyId,
3306
3312
  proofKeyEpoch: input.proofKeyEpoch,
3307
- revoked: false
3313
+ revoked: false,
3314
+ ...input.machineId === void 0 ? {} : { machineId: input.machineId }
3308
3315
  };
3316
+ if (input.machineId !== void 0) {
3317
+ for (const [key2, existing] of this.#byTenant) {
3318
+ if (existing.revoked) continue;
3319
+ if (existing.deviceId === record.deviceId) continue;
3320
+ if (existing.tenantId !== tenant) continue;
3321
+ if (existing.productId !== input.productId) continue;
3322
+ if (existing.machineId !== input.machineId) continue;
3323
+ this.#byTenant.set(key2, { ...existing, revoked: true });
3324
+ }
3325
+ }
3309
3326
  const key = tenantKey(tenant, record.deviceId);
3310
3327
  this.#byTenant.set(key, record);
3311
3328
  this.#byDeviceId.set(record.deviceId, key);