@standardagents/builder 0.40.2 → 0.40.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/dist/index.js CHANGED
@@ -30657,17 +30657,23 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
30657
30657
  return cursor.rowsWritten > 0;
30658
30658
  }
30659
30659
  /** Approve a pending device login: mint a personal API key for the user and
30660
- * park its plaintext for the single claim. Returns false when the code is
30661
- * unknown, expired, or not pending. */
30660
+ * park its plaintext for the single claim. A retry by the same user remains
30661
+ * successful after the row is approved or claimed, without minting another
30662
+ * key. Returns false for unknown, expired, denied, or differently-owned
30663
+ * logins. */
30662
30664
  async approveDeviceLogin(params) {
30663
30665
  await this.ensureMigrated();
30664
30666
  await this.sweepDeviceLogins();
30665
30667
  const cursor = await this.ctx.storage.sql.exec(
30666
- `SELECT status FROM device_logins WHERE code_hash = ?`,
30668
+ `SELECT status, user_id FROM device_logins WHERE code_hash = ?`,
30667
30669
  params.code_hash
30668
30670
  );
30669
30671
  const row = cursor.toArray()[0];
30670
- if (!row || row.status !== "pending") return false;
30672
+ if (!row) return false;
30673
+ if (row.status === "approved" || row.status === "claimed") {
30674
+ return row.user_id === params.user_id;
30675
+ }
30676
+ if (row.status !== "pending") return false;
30671
30677
  await this.createApiKey({
30672
30678
  name: params.key_name,
30673
30679
  key_hash: params.token_hash,