@burnt-labs/abstraxion 1.0.0-alpha.76 → 1.0.0-alpha.78

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.
Files changed (47) hide show
  1. package/.turbo/turbo-build.log +16 -16
  2. package/CHANGELOG.md +138 -0
  3. package/dist/index.d.ts +763 -16
  4. package/dist/index.js +1952 -146
  5. package/dist/index.mjs +1945 -155
  6. package/package.json +8 -5
  7. package/src/AbstraxionProvider.tsx +102 -7
  8. package/src/components/AbstraxionEmbed.tsx +370 -0
  9. package/src/controllers/IframeController.ts +834 -0
  10. package/src/controllers/PopupController.ts +566 -0
  11. package/src/controllers/RedirectController.ts +334 -28
  12. package/src/controllers/RequireSigningClient.ts +92 -0
  13. package/src/controllers/SignerController.ts +92 -11
  14. package/src/controllers/__tests__/IframeController.connect.test.ts +382 -0
  15. package/src/controllers/__tests__/IframeController.test.ts +144 -0
  16. package/src/controllers/__tests__/PopupController.connect.test.ts +546 -0
  17. package/src/controllers/__tests__/PopupController.test.ts +178 -0
  18. package/src/controllers/__tests__/RedirectController.callback.test.ts +477 -0
  19. package/src/controllers/__tests__/RedirectController.test.ts +153 -0
  20. package/src/controllers/__tests__/SignerController.test.ts +333 -0
  21. package/src/controllers/__tests__/SigningClients.test.ts +186 -0
  22. package/src/controllers/factory.ts +18 -2
  23. package/src/controllers/index.ts +8 -0
  24. package/src/controllers/types.ts +34 -3
  25. package/src/controllers/utils.ts +44 -0
  26. package/src/hooks/__tests__/useManageAuthenticators.test.ts +241 -0
  27. package/src/hooks/index.ts +9 -1
  28. package/src/hooks/useAbstraxionAccount.ts +5 -1
  29. package/src/hooks/useAbstraxionSigningClient.ts +342 -7
  30. package/src/hooks/useManageAuthenticators.ts +88 -0
  31. package/src/index.ts +36 -1
  32. package/src/types.ts +148 -8
  33. package/src/utils/__tests__/resolveAutoAuth.test.ts +201 -0
  34. package/src/utils/normalizeAbstraxionConfig.ts +33 -11
  35. package/src/utils/resolveAutoAuth.ts +62 -0
  36. package/tests/integration/auth-flows/session-management.integration.test.ts +6 -6
  37. package/tests/integration/auth-flows/signer-auth.integration.test.ts +2 -2
  38. package/tests/integration/fixtures.ts +2 -3
  39. package/tests/integration/grant-management/treasury-decoding.integration.test.ts +640 -0
  40. package/tests/integration/message-contract.integration.test.ts +1007 -0
  41. package/tests/integration/react/AbstraxionEmbed.integration.test.tsx +316 -0
  42. package/tests/integration/react/AbstraxionProvider-popup-no-grants.integration.test.tsx +250 -0
  43. package/tests/integration/response-shapes.integration.test.ts +255 -0
  44. package/tests/integration/treasury_address_list.txt +86 -0
  45. package/tsup.config.ts +1 -1
  46. package/vitest.config.contract.ts +34 -0
  47. package/vitest.config.integration.ts +8 -1
@@ -1,19 +1,19 @@
1
1
 
2
- > @burnt-labs/abstraxion@1.0.0-alpha.76 build /home/runner/work/xion.js/xion.js/packages/abstraxion
2
+ > @burnt-labs/abstraxion@1.0.0-alpha.78 build /home/runner/work/xion.js/xion.js/packages/abstraxion
3
3
  > tsup
4
4
 
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v6.7.0
8
- CLI Using tsup config: /home/runner/work/xion.js/xion.js/packages/abstraxion/tsup.config.ts
9
- CLI Target: esnext
10
- CLI Cleaning output folder
11
- ESM Build start
12
- CJS Build start
13
- ESM dist/index.mjs 25.34 KB
14
- ESM ⚡️ Build success in 146ms
15
- CJS dist/index.js 25.87 KB
16
- CJS ⚡️ Build success in 146ms
17
- DTS Build start
18
- DTS ⚡️ Build success in 1629ms
19
- DTS dist/index.d.ts 7.27 KB
5
+ CLI Building entry: src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v6.7.0
8
+ CLI Using tsup config: /home/runner/work/xion.js/xion.js/packages/abstraxion/tsup.config.ts
9
+ CLI Target: esnext
10
+ CLI Cleaning output folder
11
+ ESM Build start
12
+ CJS Build start
13
+ CJS dist/index.js 85.87 KB
14
+ CJS ⚡️ Build success in 340ms
15
+ ESM dist/index.mjs 84.43 KB
16
+ ESM ⚡️ Build success in 340ms
17
+ DTS Build start
18
+ DTS ⚡️ Build success in 2672ms
19
+ DTS dist/index.d.ts 36.27 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,143 @@
1
1
  # @burnt-labs/abstraxion
2
2
 
3
+ ## 1.0.0-alpha.78
4
+
5
+ ### Minor Changes
6
+
7
+ - [#355](https://github.com/burnt-labs/xion.js/pull/355) [`e466751`](https://github.com/burnt-labs/xion.js/commit/e46675174d71aabd6ff24cc59016713938168ea2) Thanks [@ertemann](https://github.com/ertemann)! - Adopt `@burnt-labs/xion-types` as the source of truth for protobuf and contract types, consolidate the popup/redirect/iframe signing clients into a single `RequireSigningClient`, expose the manage-authenticators flow through the SDK, and tighten the SDK ↔ Dashboard message contract.
8
+
9
+ ## Breaking changes (`@burnt-labs/abstraxion-core`)
10
+ - **`IframeMessageType.ADD_AUTHENTICATORS`** and the `DashboardMessageType.ADD_AUTHENTICATORS_*` enum values have been **renamed** to `MANAGE_AUTHENTICATORS` / `MANAGE_AUTHENTICATORS_*` with no backward-compat aliases. These enums are the wire contract between the SDK and the Abstraxion Dashboard; the dashboard bundle on testnet/mainnet must be redeployed before this SDK version is published. The contract probe in `packages/abstraxion/tests/integration/message-contract.integration.test.ts` is the canonical pre-release gate.
11
+ - **`PopupSigningClient`, `RedirectSigningClient`, and `IframeSigningClient` have been removed** and replaced by a single `RequireSigningClient` that handles all three transports behind one interface, including proper transaction simulation. Consumers that imported the per-mode clients directly must switch to `RequireSigningClient`.
12
+ - **Protobuf types are no longer vendored.** All manually generated/kept protobuf and contract types have been removed in favor of `@burnt-labs/xion-types`. Consumers importing protobuf message types from `abstraxion-core` internals must import from `@burnt-labs/xion-types` instead.
13
+
14
+ ## Migration to `@burnt-labs/xion-types`
15
+ - `@burnt-labs/xion-types` is pinned to `29.0.0-rc1` across all packages (pnpm override + per-package `dependencies`).
16
+ - `@burnt-labs/signers`: imports `AbstractAccount` and `MsgRegisterAccount` from `xion-types` subpaths; `uint64FromProto` widened to accept `Long | bigint` for cross-boundary compat.
17
+ - `@burnt-labs/account-management`: `GrantConfigByTypeUrl` now extends `GrantConfig` from `xion-types`; the local `Any` interface has been removed and `TreasuryAny` from `xion-types` is used instead. `Params` is re-exported as `TreasuryParamsV2` for forward-compat with the upcoming chain upgrade.
18
+ - `@burnt-labs/abstraxion-core`: adds a `ChainGrant` interface and uses `import type` for authz types from `xion-types`.
19
+
20
+ ## New public API — Manage Authenticators flow (`@burnt-labs/abstraxion`)
21
+ - **`useManageAuthenticators()`** — new hook that opens the dashboard manage-authenticators flow (add or remove) in popup, iframe (embedded), and redirect modes. Returns `{ manageAuthenticators, isSupported, manageAuthResult, clearManageAuthResult }`.
22
+ - **`ManageAuthResult`** — exported type for the redirect-mode result (`{ success: true } | { success: false; error: string }`).
23
+ - **`UseManageAuthenticatorsReturn`** — type export for the hook's return shape.
24
+
25
+ ## SDK internals (`@burnt-labs/abstraxion-core`)
26
+ - `PopupController.promptManageAuthenticators(signerAddress)` — opens a popup to the dashboard `manage-authenticators` view; resolves on `MANAGE_AUTHENTICATORS_SUCCESS`, rejects on cancel/error. Timeout: 10 min.
27
+ - `IframeController.promptManageAuthenticators(signerAddress)` — sends `MANAGE_AUTHENTICATORS` via `MessageChannelManager` to the embedded iframe; resolves when the user completes the flow.
28
+ - `RedirectController.promptManageAuthenticators(signerAddress)` — navigates to the dashboard manage-auth page; result available via `manageAuthResult` store after return.
29
+ - `RedirectController.manageAuthResult` — new `ResultStore<ManageAuthResult>` (parallel to `signResult`). Subscribe, snapshot, and clear follow the same `useSyncExternalStore`-compatible pattern.
30
+ - `waitForPopupMessage<T>` — shared private helper in `PopupController` that eliminates duplicated popup-message-waiting boilerplate across sign and manage-auth flows.
31
+ - `DashboardMessageType` — three new enum values: `MANAGE_AUTHENTICATORS_SUCCESS`, `MANAGE_AUTHENTICATORS_REJECTED`, `MANAGE_AUTHENTICATORS_ERROR`.
32
+
33
+ ## Direct grant decoding pipeline (`@burnt-labs/abstraxion-core`)
34
+ - `fetchChainGrantsDecoded()` decodes chain grants directly from protobuf, eliminating the REST intermediate step that caused multiple session-invalidation bugs (#290, #336).
35
+ - `compareChainGrantsToTreasuryGrants` now returns a typed `GrantComparisonResult` with reasons (`grant_missing`, `grant_mismatch`, `decode_error`); `decode_error` is non-fatal — session is preserved and a warning is logged.
36
+ - Unknown limit/filter type URLs preserve raw bytes and fall back to byte-level comparison instead of returning `false`.
37
+ - `decodeAuthorization` is wrapped in try/catch — corrupted bytes return `Unsupported` instead of throwing, preventing malformed treasury data from crashing session restore.
38
+
39
+ ## TX payload utilities (`@burnt-labs/signers`)
40
+ - **`validateTxPayload(payload, context)`** — pre-flight validation for transaction payloads before encoding/transport; logs issues without throwing so dev mistakes surface early.
41
+ - **`normalizeMessages(messages)`** — dashboard-side normalization that converts post-JSON-transport CosmWasm `msg` fields from plain objects back to `Uint8Array` for protobuf encoding.
42
+ - **`TxTransportPayload`** — shared type for the wire format used by popup, redirect, and iframe signing flows.
43
+ - **`getTreasuryParamsMetadata(params)`** — backward-compat helper that returns `metadata` with fallback to `display_url` for pre-upgrade indexer responses.
44
+ - Coins are sorted in grant encoding for deterministic comparison.
45
+ - `NilPubKey` protobuf encoding fixed.
46
+ - `AAClient` upgraded from `Tendermint37Client` to `Comet38Client` for consistency with `GranteeSignerClient`/`rpcClient` and proper CometBFT 0.38+ support.
47
+ - `MsgInstantiateContract2` validation fixed.
48
+
49
+ ## DaoDAO indexer typing (`@burnt-labs/signers`)
50
+ - Generated typed API paths from the DaoDAO indexer OpenAPI spec.
51
+ - Manually maintained response types with runtime type guards.
52
+ - `xion-types` compatibility test for bigint boundary validation.
53
+ - New scripts: `generate:daodao-indexer-types`, `generate:daodao-indexer-types:local`.
54
+
55
+ ## Treasury strategy improvements (`@burnt-labs/account-management`)
56
+ - `CompositeTreasuryStrategy` gains a racing mode (`Promise.any()` parallel execution) that resolves on first success, eliminating waits for slow DAODAO indexer timeouts. Constructor signature changed to `(strategies[], options)`.
57
+ - DAODAO indexer treasury strategy is end-to-end typed against the generated indexer schema.
58
+
59
+ ## Refactors
60
+ - `resolveAuthAppUrl` and `buildDashboardUrl` extracted to `controllers/utils.ts`; used by both `PopupController` and `RedirectController`, removing duplicated `fetchConfig` call sites.
61
+ - `ResultStore<T>` in `RedirectController` replaces the bespoke `signResult_` / `signResultSubscribers_` pattern, making both sign and manage-auth results consistent.
62
+
63
+ ## Constants (`@burnt-labs/constants`)
64
+ - Mainnet dashboard / iframe URL changed from `https://settings.mainnet.burnt.com` to `https://settings.burnt.com`.
65
+
66
+ ### Patch Changes
67
+
68
+ - Updated dependencies [[`e466751`](https://github.com/burnt-labs/xion.js/commit/e46675174d71aabd6ff24cc59016713938168ea2)]:
69
+ - @burnt-labs/abstraxion-core@1.0.0-alpha.69
70
+ - @burnt-labs/signers@1.0.0-alpha.8
71
+ - @burnt-labs/account-management@1.0.0-alpha.10
72
+ - @burnt-labs/constants@0.1.0-alpha.24
73
+
74
+ ## 1.0.0-alpha.77
75
+
76
+ ### Minor Changes
77
+
78
+ - [#340](https://github.com/burnt-labs/xion.js/pull/340) [`1a387ca`](https://github.com/burnt-labs/xion.js/commit/1a387cabe46a20c6a88fc32e51c8f88f99ccddf1) Thanks [@ertemann](https://github.com/ertemann)! - Add embedded wallets with popup, auto, and embedded authentication modes. Also add direct signing (`requireAuth`) for transactions that need meta-account authorization instead of session keys.
79
+
80
+ ## What's new
81
+ - **Popup mode** — opens auth app in a popup window; user stays on the dApp page, popup closes on success
82
+ - **Auto mode** — automatically picks popup (desktop) or redirect (mobile/PWA) based on device detection
83
+ - **Embedded mode** (`type: "embedded"`) — embeds dashboard inside your page via `MessageChannel`-based communication. New `<AbstraxionEmbed>` drop-in component handles all wiring — just place it in your layout and use hooks like any other mode
84
+ - **Direct signing (`requireAuth: true`)** — meta-account signs transactions directly instead of using session keys; user pays gas from their XION balance. For txs that won't be secure using session keys, like big transfers, smart account management etc.
85
+ - **`isDisconnected` flag** — `useAbstraxionAccount` now returns `isDisconnected: boolean`, true only after an explicit user logout. Prevents `<AbstraxionEmbed autoConnect>` from silently re-authenticating after logout
86
+ - **`isAwaitingApproval` flag** — context exposes `isAwaitingApproval: boolean`, true while a `requireAuth` signing request is pending and the iframe needs to be visible
87
+
88
+ Non user facing:
89
+ - **Signing clients per auth mode** — `PopupSigningClient`, `RedirectSigningClient`, `IframeSigningClient` for direct signing in each mode
90
+ - **`resolveAutoAuth` utility** — mobile/standalone detection heuristic (user-agent, touch, viewport, orientation, PWA)
91
+ - **Wrong-wallet signing guard** — prevents signing from a wallet that doesn't match the connected account
92
+ - **UTF-8-safe base64 encoding** — `toBase64`/`fromBase64` in `@burnt-labs/signers` for safe encoding of Unicode payloads (emoji, non-Latin scripts)
93
+ - **Treasury grant restoration fix** — handles ABCI REST format change that broke session restoration (`decodeRestFormatAuthorization` in abstraxion-core)
94
+ - **Embedded URL constants** — `getIframeUrl(chainId)` added to `@burnt-labs/constants` for per-chain dashboard URLs
95
+ - **New core exports** — `MessageChannelManager`, `TypedEventEmitter`, `IframeMessageType`, `MessageTarget` from abstraxion-core; `AAClient`, `IframeController` from abstraxion
96
+ - **`disconnected` state in account state machine** — new `AccountState` status distinct from `idle`, set only after an explicit logout. New `EXPLICITLY_DISCONNECTED` action and `AccountStateGuards.isDisconnected()` type guard. All four controllers dispatch this instead of `RESET` on disconnect
97
+ - **`authMode` derived from controller instance** — `AbstraxionProvider` now derives `authMode` from the live controller type instead of re-running `resolveAutoAuth` on every render, preventing SSR/client hydration mismatches and viewport-resize flips
98
+
99
+ ## AbstraxionEmbed redesign
100
+
101
+ `<AbstraxionEmbed>` has been redesigned with full lifecycle control props replacing the single `autoConnect` boolean:
102
+ - **`idleView`** (`"button" | "fullview" | "hidden"`, default `"button"`) — what to show before the user logs in
103
+ - **`disconnectedView`** (same options, default: same as `idleView`) — what to show after an explicit logout
104
+ - **`connectedView`** (`"hidden" | "visible"`, default `"hidden"`) — whether to keep the iframe visible after connecting
105
+ - **`approvalView`** (`"modal" | "inline"`, default `"modal"`) — how to display the iframe when a `requireAuth` signing request is pending
106
+ - **`loginLabel`**, **`loginButtonClassName`**, **`loginButtonStyle`** — customise the login button
107
+ - **`modalClassName`**, **`modalStyle`** — customise the approval modal wrapper
108
+
109
+ ## Dashboard changes (xion-dashboard-app `feat/embedded-wallets`)
110
+
111
+ These dashboard changes are required for the new SDK modes to work:
112
+ - **Popup mode support** — dashboard can now run inside a popup window opened by the SDK, communicating auth results back via `postMessage` and closing automatically on success
113
+ - **Redirect-within-popup for OAuth** — when using popup mode, OAuth providers (Stytch) redirect inside the popup instead of opening yet another popup
114
+ - **SignTransactionView** — new view for approving individual transactions sent via `requireAuth` / direct signing (popup, redirect, and embedded modes)
115
+ - **Embedded mode** — dashboard renders inside an iframe with transparent background; old `IframeApp/` components removed in favor of the main app with `?iframe=true` search param
116
+ - **LoginConnectConfirm** — new approval screen for no-grant-config flows (empty treasury or direct-signing-only grantee); shows app branding and "Connect / Deny / Use a different account"
117
+ - **Empty treasury support** — treasury address present but no grant configs no longer throws; dashboard routes to `LoginConnectConfirm` instead of `LoginGrantApproval`
118
+ - **SDK-only disconnect** — disconnect from the SDK side sends `HARD_DISCONNECT` and tears down the iframe; "Use a different account" stays within the iframe (no parent notification) so the user can re-login without a white-screen flash
119
+ - **`switchAccount()`** hook function — new export from `useXionDisconnect`; clears session locally without notifying parent, used by "Use a different account" buttons
120
+ - **Origin validation on callbacks** — `postMessage` origin checks upgraded for security in embedded/popup communication
121
+ - **Wrong-address signing guard** — dashboard rejects signing requests if the requested signer doesn't match the logged-in account
122
+
123
+ ## Packages changed
124
+ - **`@burnt-labs/abstraxion`** — new `<AbstraxionEmbed>` component (redesigned), new controllers (`PopupController`, `IframeController`), signing clients, auto mode resolution, expanded `useAbstraxionSigningClient` with `requireAuth` support, `isDisconnected`/`isAwaitingApproval` context values, `authMode` derived from controller instance, new type exports (`EmbeddedAuthentication`, `PopupAuthentication`, `AutoAuthentication`, `SignResult`, `SigningClient`)
125
+ - **`@burnt-labs/abstraxion-core`** — `MessageChannelManager`, `TypedEventEmitter`, iframe message types, `decodeRestFormatAuthorization` grant decoding, treasury grant restoration fix
126
+ - **`@burnt-labs/account-management`** — `disconnected` account state, `EXPLICITLY_DISCONNECTED` action, `AccountStateGuards.isDisconnected()` type guard
127
+ - **`@burnt-labs/constants`** — `getIframeUrl(chainId)`, per-chain dashboard URL constants for mainnet/testnet
128
+ - **`@burnt-labs/signers`** — `toBase64`/`fromBase64` encoding utils, `ZKEmail` authenticator type support
129
+ - **`demo-app`** — new demos: `popup-demo/`, `embedded-dynamic/`, `embedded-inline/`, `direct-signing-demo/` (with MetaMask via `useMetamask` hook); removed old `inline-demo/`
130
+
131
+ For full details, usage examples, and migration guide see [`LATEST_VERSION_OVERVIEW.md`](../LATEST_VERSION_OVERVIEW.md) and the demo apps in [`apps/demo-app/`](../apps/demo-app/).
132
+
133
+ ### Patch Changes
134
+
135
+ - Updated dependencies [[`1a387ca`](https://github.com/burnt-labs/xion.js/commit/1a387cabe46a20c6a88fc32e51c8f88f99ccddf1)]:
136
+ - @burnt-labs/abstraxion-core@1.0.0-alpha.68
137
+ - @burnt-labs/account-management@1.0.0-alpha.9
138
+ - @burnt-labs/constants@0.1.0-alpha.23
139
+ - @burnt-labs/signers@1.0.0-alpha.7
140
+
3
141
  ## 1.0.0-alpha.76
4
142
 
5
143
  ### Patch Changes