@flow-industries/id 0.2.8 → 0.3.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.
@@ -94,7 +94,6 @@ export function createFlow(options = {}) {
94
94
  address: result.address,
95
95
  });
96
96
  await idb.set("flow.activeCredential", result.credential);
97
- await idb.set("flow.lastActiveCredential", result.credential);
98
97
  return true;
99
98
  }
100
99
  catch {
@@ -168,7 +168,7 @@ export function createDialogHost(options) {
168
168
  return dispatchRequest(method, params);
169
169
  }
170
170
  /**
171
- * Dispatches an RPC without showing the dialog UI. Used for headless flows
171
+ * Dispatches an RPC without showing the dialog UI. Used for signInHeadless flows
172
172
  * (silent restore, refresh, sign-out) where the dialog route runs invisibly
173
173
  * and resolves immediately. The iframe is still mounted so postMessage
174
174
  * works, but its `display` stays `none`.
@@ -13,14 +13,9 @@ export declare function restoreCredential(store: Store<FlowState>): Promise<void
13
13
  * Drives the interactive `wallet_connect` flow through the dialog and
14
14
  * commits the result to local state.
15
15
  *
16
- * The capabilities bag is built from the call site (signUp/signIn intent +
17
- * any extras like accessKeyHash) plus a "last credential" hint pulled from
18
- * IDB. The hint lets the dialog pre-fill the username and skip a step when
19
- * the user has signed in here before — without it every login looks like a
20
- * first-time sign-in.
21
- *
22
- * Persists the credential under both `activeCredential` (current session)
23
- * and `lastActiveCredential` (next-time hint) so the hint survives logout.
16
+ * Capabilities are intent only (signUp / signIn / signInHeadless / extras like
17
+ * accessKeyHash). Remembering "which account did this user use last" is
18
+ * the dialog's job — the client doesn't track or pass credentialIds.
24
19
  */
25
20
  export declare function runLogin(params: RunLoginParams): Promise<RunLoginResult>;
26
21
  /**
@@ -28,9 +23,6 @@ export declare function runLogin(params: RunLoginParams): Promise<RunLoginResult
28
23
  * the current address (if any), and the in-memory store. Does NOT touch the
29
24
  * server cookie session — the caller (createFlow.logout) handles that
30
25
  * separately via `wallet_signout`.
31
- *
32
- * The `lastActiveCredential` IDB key is intentionally preserved so the next
33
- * login can pre-fill the username.
34
26
  */
35
27
  export declare function runLogout(store: Store<FlowState>): Promise<void>;
36
28
  /**
@@ -4,7 +4,6 @@ import { idb } from "./idb";
4
4
  import { METHODS } from "./methods";
5
5
  import { initialFlowState } from "./store";
6
6
  const CREDENTIAL_KEY = "flow.activeCredential";
7
- const LAST_CREDENTIAL_KEY = "flow.lastActiveCredential";
8
7
  /**
9
8
  * Reads the active credential from IndexedDB and seeds the in-memory store
10
9
  * with `{ credential, address }`. Run on every page load so signing operations
@@ -25,26 +24,17 @@ export async function restoreCredential(store) {
25
24
  * Drives the interactive `wallet_connect` flow through the dialog and
26
25
  * commits the result to local state.
27
26
  *
28
- * The capabilities bag is built from the call site (signUp/signIn intent +
29
- * any extras like accessKeyHash) plus a "last credential" hint pulled from
30
- * IDB. The hint lets the dialog pre-fill the username and skip a step when
31
- * the user has signed in here before — without it every login looks like a
32
- * first-time sign-in.
33
- *
34
- * Persists the credential under both `activeCredential` (current session)
35
- * and `lastActiveCredential` (next-time hint) so the hint survives logout.
27
+ * Capabilities are intent only (signUp / signIn / signInHeadless / extras like
28
+ * accessKeyHash). Remembering "which account did this user use last" is
29
+ * the dialog's job — the client doesn't track or pass credentialIds.
36
30
  */
37
31
  export async function runLogin(params) {
38
32
  const { dialog, store, options, extraCapabilities } = params;
39
- const lastCredential = await idb.get(LAST_CREDENTIAL_KEY);
40
33
  const signUp = Boolean(options?.signUp);
41
34
  const capabilities = {
42
35
  ...(signUp ? { createAccount: true } : {}),
43
36
  ...(!signUp && options?.signIn ? { signIn: true } : {}),
44
- ...(!signUp && options?.headless ? { headless: true } : {}),
45
- ...(lastCredential && !signUp
46
- ? { credentialId: lastCredential.id }
47
- : {}),
37
+ ...(!signUp && options?.signInHeadless ? { signInHeadless: true } : {}),
48
38
  ...(extraCapabilities ?? {}),
49
39
  };
50
40
  const result = (await dialog.request(METHODS.connect, [
@@ -53,7 +43,6 @@ export async function runLogin(params) {
53
43
  const { jwt, user, credential, webauthn } = result;
54
44
  const address = credentialToAddress(credential);
55
45
  await idb.set(CREDENTIAL_KEY, credential);
56
- await idb.set(LAST_CREDENTIAL_KEY, credential);
57
46
  store.setState({ user, jwt, credential, address });
58
47
  return {
59
48
  session: { user, jwt, credential, address },
@@ -65,9 +54,6 @@ export async function runLogin(params) {
65
54
  * the current address (if any), and the in-memory store. Does NOT touch the
66
55
  * server cookie session — the caller (createFlow.logout) handles that
67
56
  * separately via `wallet_signout`.
68
- *
69
- * The `lastActiveCredential` IDB key is intentionally preserved so the next
70
- * login can pre-fill the username.
71
57
  */
72
58
  export async function runLogout(store) {
73
59
  const state = store.getSnapshot();
@@ -5,7 +5,7 @@ export type ConnectCapabilities = {
5
5
  createAccount?: boolean;
6
6
  signIn?: boolean;
7
7
  accessKeyHash?: string;
8
- headless?: boolean;
8
+ signInHeadless?: boolean;
9
9
  credentialId?: string;
10
10
  };
11
11
  export type ConnectRequest = [{
@@ -74,7 +74,7 @@ export type LoginOptions = {
74
74
  mode?: "iframe" | "popup";
75
75
  signUp?: boolean;
76
76
  signIn?: boolean;
77
- headless?: boolean;
77
+ signInHeadless?: boolean;
78
78
  };
79
79
  export type Session = {
80
80
  user: FlowUser;
@@ -8,8 +8,8 @@ function loginOptionsFromCapabilities(capabilities) {
8
8
  return {
9
9
  ...(signUp ? { signUp: true } : {}),
10
10
  ...(!signUp && signIn ? { signIn: true } : {}),
11
- ...(!signUp && (capabilities?.headless || capabilities?.type === "sign-in")
12
- ? { headless: true }
11
+ ...(!signUp && (capabilities?.signInHeadless || capabilities?.type === "sign-in")
12
+ ? { signInHeadless: true }
13
13
  : {}),
14
14
  };
15
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flow-industries/id",
3
- "version": "0.2.8",
3
+ "version": "0.3.0",
4
4
  "main": "./dist/sdk/client/index.js",
5
5
  "module": "./dist/sdk/client/index.js",
6
6
  "types": "./dist/sdk/client/index.d.ts",
@@ -81,7 +81,7 @@
81
81
  "vite": "^7.3.1"
82
82
  },
83
83
  "dependencies": {
84
- "@flow-industries/ui": "^0.11.1",
84
+ "@flow-industries/ui": "^0.15.2",
85
85
  "@tanstack/query-sync-storage-persister": "^5.90.22",
86
86
  "@tanstack/react-query": "^5.90.20",
87
87
  "@tanstack/react-query-persist-client": "^5.90.22",