@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/runtime.d.ts CHANGED
@@ -2787,8 +2787,10 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
2787
2787
  /** Deny a pending device login without creating a user or API key. */
2788
2788
  denyDeviceLogin(codeHash: string): Promise<boolean>;
2789
2789
  /** Approve a pending device login: mint a personal API key for the user and
2790
- * park its plaintext for the single claim. Returns false when the code is
2791
- * unknown, expired, or not pending. */
2790
+ * park its plaintext for the single claim. A retry by the same user remains
2791
+ * successful after the row is approved or claimed, without minting another
2792
+ * key. Returns false for unknown, expired, denied, or differently-owned
2793
+ * logins. */
2792
2794
  approveDeviceLogin(params: {
2793
2795
  code_hash: string;
2794
2796
  user_id: string;
package/dist/runtime.js CHANGED
@@ -21902,17 +21902,23 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
21902
21902
  return cursor.rowsWritten > 0;
21903
21903
  }
21904
21904
  /** Approve a pending device login: mint a personal API key for the user and
21905
- * park its plaintext for the single claim. Returns false when the code is
21906
- * unknown, expired, or not pending. */
21905
+ * park its plaintext for the single claim. A retry by the same user remains
21906
+ * successful after the row is approved or claimed, without minting another
21907
+ * key. Returns false for unknown, expired, denied, or differently-owned
21908
+ * logins. */
21907
21909
  async approveDeviceLogin(params) {
21908
21910
  await this.ensureMigrated();
21909
21911
  await this.sweepDeviceLogins();
21910
21912
  const cursor = await this.ctx.storage.sql.exec(
21911
- `SELECT status FROM device_logins WHERE code_hash = ?`,
21913
+ `SELECT status, user_id FROM device_logins WHERE code_hash = ?`,
21912
21914
  params.code_hash
21913
21915
  );
21914
21916
  const row = cursor.toArray()[0];
21915
- if (!row || row.status !== "pending") return false;
21917
+ if (!row) return false;
21918
+ if (row.status === "approved" || row.status === "claimed") {
21919
+ return row.user_id === params.user_id;
21920
+ }
21921
+ if (row.status !== "pending") return false;
21916
21922
  await this.createApiKey({
21917
21923
  name: params.key_name,
21918
21924
  key_hash: params.token_hash,