@chipi-stack/backend 14.16.0 → 14.17.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.
package/dist/index.d.ts CHANGED
@@ -787,6 +787,150 @@ declare class X402Facilitator {
787
787
  settle(payment: PaymentPayload): Promise<SettleResponse>;
788
788
  }
789
789
 
790
+ /**
791
+ * SNIP-12 typed-data hash for `OutsideExecution` — TypeScript reference.
792
+ *
793
+ * Vendored from haycarlitos/shhh-wallet-cairo @ v8.4 commit 3975532
794
+ * source: scripts/ts/snip12-hash.ts
795
+ * license: MIT (Copyright (c) 2026 Carlos Castillo and contributors)
796
+ *
797
+ * MUST produce byte-identical output to `compute_snip12_hash` in
798
+ * `src/outside_execution.cairo` at the same commit. If the canonical
799
+ * Cairo source ships a breaking change, the upstream Shhh maintainer
800
+ * will open a PR against this file (per Q3 of SHHH_INTEGRATION_ANSWERS.md).
801
+ */
802
+
803
+ declare const STARKNET_MESSAGE_PREFIX: string;
804
+ declare const OE_DOMAIN_NAME: string;
805
+ declare const OE_DOMAIN_VERSION = 2n;
806
+ declare const OE_DOMAIN_REVISION = 1n;
807
+ declare const SIG_VERSION_V1_HEX_ASCII: string;
808
+ declare const SIG_VERSION_V2_SNIP12: string;
809
+ declare const SIG_VERSION_V2_THRESHOLD: string;
810
+ declare const ISRC9_V2_ID: bigint;
811
+ declare const ISIGNER_ID: bigint;
812
+ declare const ISIGNER_CANONICAL_LABEL = "ISigner_V1";
813
+ /** Recomputes the canonical `ISIGNER_ID` at runtime. */
814
+ declare function computeISignerId(): bigint;
815
+ type OutsideExecution = {
816
+ caller: bigint | string;
817
+ nonce: bigint | string;
818
+ execute_after: bigint;
819
+ execute_before: bigint;
820
+ calls: Call[];
821
+ };
822
+ declare function hashCall(call: Call): bigint;
823
+ declare function hashCalls(calls: Call[]): bigint;
824
+ declare function hashStarknetDomain(chainIdFelt: bigint | string): bigint;
825
+ declare function hashOutsideExecutionStruct(oe: OutsideExecution): bigint;
826
+ /**
827
+ * The authoritative SNIP-12 message hash for an OutsideExecution.
828
+ * Signers sign over this felt252 (or its hex-ASCII re-encoding for
829
+ * Phantom UX compatibility — see snip12HashToHexAsciiBytes).
830
+ */
831
+ declare function computeSnip12Hash(oe: OutsideExecution, contractAddress: bigint | string, chainIdFelt: bigint | string): bigint;
832
+ /**
833
+ * Phantom hex-ASCII envelope helper. Phantom signs a string; we give it
834
+ * a 64-byte hex-ASCII representation of the SNIP-12 hash, and the Cairo
835
+ * verifier re-computes the hash and compares byte-by-byte.
836
+ */
837
+ declare function snip12HashToHexAsciiBytes(h: bigint): Uint8Array;
838
+
839
+ /**
840
+ * Run calls on a SHHH wallet signed by an EXTERNAL Starknet wallet that is
841
+ * one of its owners or guardians: Bramble, Braavos, Ready/Argent, an
842
+ * OpenZeppelin account or another Chipi wallet, registered with the
843
+ * `STARK_SNIP12` kind.
844
+ *
845
+ * The external wallet signs an `Approval { Wallet, Hash }` typed data with
846
+ * `wallet_signTypedData` (see `signers/stark-snip12.ts`). Nothing is
847
+ * decrypted: the key stays in the external wallet. Chipi's paymaster
848
+ * relays the outside execution gaslessly, like any other SHHH OE.
849
+ *
850
+ * Two steps so the signing can happen wherever the wallet lives:
851
+ * 1. `prepareExternalOwnerExecution` → `{ outsideExecution, typedData }`
852
+ * 2. `submitExternalOwnerExecution` with the wallet's signature
853
+ * `executeShhhWithExternalSigner` does both with a `signTypedData` callback.
854
+ */
855
+
856
+ interface PreparedExternalOwnerExecution {
857
+ walletAddress: string;
858
+ outsideExecution: OutsideExecution;
859
+ /** SNIP-12 hash of the OE (what the Approval carries as `Hash`). */
860
+ messageHash: bigint;
861
+ /** What the external wallet signs with `wallet_signTypedData`. */
862
+ typedData: TypedData;
863
+ chainId: string;
864
+ }
865
+ /** Step 1: build the OE (max 2h window) and the typed data to sign. */
866
+ declare function prepareExternalOwnerExecution(params: {
867
+ /** The SHHH wallet's address. */
868
+ walletAddress: string;
869
+ calls: Call[];
870
+ nonce?: bigint;
871
+ /** Defaults to mainnet. */
872
+ chainId?: bigint | string;
873
+ }): PreparedExternalOwnerExecution;
874
+ /**
875
+ * Step 2: wrap the wallet's signature and relay the OE through Chipi's
876
+ * paymaster (`/transactions/execute-sponsored-raw`). Returns the tx hash;
877
+ * wait for it before treating the call as done.
878
+ */
879
+ declare function submitExternalOwnerExecution(params: {
880
+ client: ChipiClient;
881
+ bearerToken: string;
882
+ prepared: PreparedExternalOwnerExecution;
883
+ /** The external wallet's `wallet_signTypedData` result, as returned. */
884
+ signature: Array<string | number | bigint>;
885
+ /** u32 index of the external wallet in the SHHH wallet's owner_set. */
886
+ ownerIndex: number | bigint;
887
+ /**
888
+ * The external wallet's address and STARK key (from `resolveStarkSnip12Signer`).
889
+ * When given, the signature is checked off-chain first, so a wrong wallet or
890
+ * key fails here. Without it nothing is checked before relaying, and a wrong
891
+ * signature only shows up as a reverted transaction. Pass it whenever you can.
892
+ */
893
+ signer?: {
894
+ address: string;
895
+ starkPubkey: bigint | string;
896
+ };
897
+ externalUserId?: string;
898
+ }): Promise<string>;
899
+ /** Both steps, with the external wallet's `signTypedData` as a callback. */
900
+ declare function executeShhhWithExternalSigner(params: {
901
+ client: ChipiClient;
902
+ bearerToken: string;
903
+ walletAddress: string;
904
+ calls: Call[];
905
+ ownerIndex: number | bigint;
906
+ signTypedData: (typedData: TypedData) => Promise<Array<string | number | bigint>>;
907
+ signer?: {
908
+ address: string;
909
+ starkPubkey: bigint | string;
910
+ };
911
+ nonce?: bigint;
912
+ chainId?: bigint | string;
913
+ externalUserId?: string;
914
+ }): Promise<string>;
915
+ /**
916
+ * Run calls signed by a raw STARK key that is owner `ownerIndex` of the
917
+ * wallet, relayed gaslessly. For the step right after a guardian recovery:
918
+ * the recovered key is a new owner (recovery adds, it never replaces), and
919
+ * it signs `propose_rotate_owner` to move owner 0 onto a fresh key, which is
920
+ * the key every other SDK call signs with. Keep `privateKey` in memory only.
921
+ */
922
+ declare function executeShhhWithStarkKey(params: {
923
+ client: ChipiClient;
924
+ bearerToken: string;
925
+ walletAddress: string;
926
+ calls: Call[];
927
+ privateKey: string | bigint;
928
+ ownerIndex: number | bigint;
929
+ nonce?: bigint;
930
+ chainId?: bigint | string;
931
+ externalUserId?: string;
932
+ }): Promise<string>;
933
+
790
934
  /**
791
935
  * Main Chipi SDK class
792
936
  */
@@ -913,6 +1057,33 @@ declare class ChipiSDK {
913
1057
  signTypedDataArray({ params }: {
914
1058
  params: SignTypedDataParams;
915
1059
  }): Promise<string[]>;
1060
+ /**
1061
+ * Run calls on a SHHH wallet, signed by an external Starknet wallet that is
1062
+ * one of its `STARK_SNIP12` owners (Bramble, Braavos, Ready/Argent, OZ, or
1063
+ * another Chipi wallet). The wallet signs an `Approval` typed data through
1064
+ * `signTypedData` (its `wallet_signTypedData`); Chipi's paymaster relays the
1065
+ * outside execution gaslessly. Returns the tx hash: wait for it.
1066
+ *
1067
+ * @example
1068
+ * ```typescript
1069
+ * // Bramble approves an agent session on the user's Chipi wallet.
1070
+ * const bramble = window.starknet_bramble;
1071
+ * const txHash = await sdk.executeWithExternalSigner({
1072
+ * params: {
1073
+ * walletAddress: wallet.publicKey,
1074
+ * ownerIndex: 1, // Bramble's index in the wallet's owner set
1075
+ * calls: buildSessionSetupCalls(wallet.publicKey, sessionConfig, policies),
1076
+ * signTypedData: (typedData) =>
1077
+ * bramble.request({ type: "wallet_signTypedData", params: typedData }),
1078
+ * },
1079
+ * bearerToken,
1080
+ * });
1081
+ * ```
1082
+ */
1083
+ executeWithExternalSigner({ params, bearerToken, }: {
1084
+ params: Omit<Parameters<typeof executeShhhWithExternalSigner>[0], "client" | "bearerToken">;
1085
+ bearerToken?: string;
1086
+ }): Promise<string>;
916
1087
  /**
917
1088
  * Transfer tokens
918
1089
  */
@@ -1621,55 +1792,6 @@ type VerifyStarknetSignInResult = {
1621
1792
  */
1622
1793
  declare function verifyStarknetSignIn(params: VerifyStarknetSignInParams): Promise<VerifyStarknetSignInResult>;
1623
1794
 
1624
- /**
1625
- * SNIP-12 typed-data hash for `OutsideExecution` — TypeScript reference.
1626
- *
1627
- * Vendored from haycarlitos/shhh-wallet-cairo @ v8.4 commit 3975532
1628
- * source: scripts/ts/snip12-hash.ts
1629
- * license: MIT (Copyright (c) 2026 Carlos Castillo and contributors)
1630
- *
1631
- * MUST produce byte-identical output to `compute_snip12_hash` in
1632
- * `src/outside_execution.cairo` at the same commit. If the canonical
1633
- * Cairo source ships a breaking change, the upstream Shhh maintainer
1634
- * will open a PR against this file (per Q3 of SHHH_INTEGRATION_ANSWERS.md).
1635
- */
1636
-
1637
- declare const STARKNET_MESSAGE_PREFIX: string;
1638
- declare const OE_DOMAIN_NAME: string;
1639
- declare const OE_DOMAIN_VERSION = 2n;
1640
- declare const OE_DOMAIN_REVISION = 1n;
1641
- declare const SIG_VERSION_V1_HEX_ASCII: string;
1642
- declare const SIG_VERSION_V2_SNIP12: string;
1643
- declare const SIG_VERSION_V2_THRESHOLD: string;
1644
- declare const ISRC9_V2_ID: bigint;
1645
- declare const ISIGNER_ID: bigint;
1646
- declare const ISIGNER_CANONICAL_LABEL = "ISigner_V1";
1647
- /** Recomputes the canonical `ISIGNER_ID` at runtime. */
1648
- declare function computeISignerId(): bigint;
1649
- type OutsideExecution = {
1650
- caller: bigint | string;
1651
- nonce: bigint | string;
1652
- execute_after: bigint;
1653
- execute_before: bigint;
1654
- calls: Call[];
1655
- };
1656
- declare function hashCall(call: Call): bigint;
1657
- declare function hashCalls(calls: Call[]): bigint;
1658
- declare function hashStarknetDomain(chainIdFelt: bigint | string): bigint;
1659
- declare function hashOutsideExecutionStruct(oe: OutsideExecution): bigint;
1660
- /**
1661
- * The authoritative SNIP-12 message hash for an OutsideExecution.
1662
- * Signers sign over this felt252 (or its hex-ASCII re-encoding for
1663
- * Phantom UX compatibility — see snip12HashToHexAsciiBytes).
1664
- */
1665
- declare function computeSnip12Hash(oe: OutsideExecution, contractAddress: bigint | string, chainIdFelt: bigint | string): bigint;
1666
- /**
1667
- * Phantom hex-ASCII envelope helper. Phantom signs a string; we give it
1668
- * a 64-byte hex-ASCII representation of the SNIP-12 hash, and the Cairo
1669
- * verifier re-computes the hash and compares byte-by-byte.
1670
- */
1671
- declare function snip12HashToHexAsciiBytes(h: bigint): Uint8Array;
1672
-
1673
1795
  /**
1674
1796
  * Deterministic ShhhAccount (V8.4) address derivation.
1675
1797
  *
@@ -1875,6 +1997,128 @@ declare function starkOwnerId(starkPubKey: bigint): bigint;
1875
1997
  */
1876
1998
  declare function starkPubkeyFelts(starkPubKey: bigint | string): bigint[];
1877
1999
 
2000
+ /**
2001
+ * STARK_SNIP12 signer for SHHH V8.4 ShhhAccount: Starknet browser wallets
2002
+ * (Bramble, Braavos, Ready/Argent, OpenZeppelin accounts) and Chipi wallets
2003
+ * as co-owners or guardians of a SHHH wallet.
2004
+ *
2005
+ * Why not the `STARK` kind: these wallets never sign a raw hash. Their only
2006
+ * signing method, `wallet_signTypedData`, signs the SNIP-12 message hash,
2007
+ * which always folds in the signing wallet's own address. So the OE hash is
2008
+ * wrapped in an `Approval { Wallet, Hash }` typed data that the wallet signs
2009
+ * as-is, and `StarkSnip12Verifier` rebuilds it on-chain (the Starknet twin of
2010
+ * the EIP-712 verifier MetaMask uses).
2011
+ *
2012
+ * Reference: shhh-wallet-cairo `src/signer/stark_snip12/verifier.cairo` and
2013
+ * `scripts/ts/gen-stark-snip12-fixture.mjs` (same typed data, same hash).
2014
+ *
2015
+ * Pubkey layout: `[stark_pubkey, signer_account_address]`. Payload: `[r, s]`.
2016
+ */
2017
+
2018
+ declare const STARK_SNIP12_KIND_TAG = "STARK_SNIP12";
2019
+ /**
2020
+ * The typed data the external wallet signs (`wallet_signTypedData`) to
2021
+ * approve the OE whose SNIP-12 hash is `messageHash` on `walletAddress`.
2022
+ * Plain ASCII, revision 1, `chainId` in the domain: Bramble's strict rules.
2023
+ */
2024
+ declare function starkSnip12ApprovalTypedData(params: {
2025
+ /** The SHHH wallet being approved (the account address). */
2026
+ walletAddress: string;
2027
+ /** SNIP-12 hash of the OutsideExecution (`computeOeHash`). */
2028
+ messageHash: bigint | string;
2029
+ /** Defaults to "SN_MAIN". Hex chain ids are converted. */
2030
+ chainId?: bigint | string;
2031
+ }): TypedData;
2032
+ /** The hash the external wallet's key signs (what the verifier checks). */
2033
+ declare function starkSnip12ApprovalHash(params: {
2034
+ walletAddress: string;
2035
+ messageHash: bigint | string;
2036
+ /** The external wallet's account address. */
2037
+ signerAddress: string;
2038
+ chainId?: bigint | string;
2039
+ }): bigint;
2040
+ /** Pubkey felts for `propose_add_owner` / `initiate_recovery`. */
2041
+ declare function starkSnip12PubkeyFelts(starkPubkey: bigint | string, signerAddress: string): bigint[];
2042
+ /** On-chain owner id commitment for a STARK_SNIP12 owner (dedupe key). */
2043
+ declare function starkSnip12OwnerCommitment(starkPubkey: bigint | string, signerAddress: string): bigint;
2044
+ /** What a wallet returned from `wallet_signTypedData`, split into its parts. */
2045
+ interface ParsedStarknetWalletSignature {
2046
+ r: bigint;
2047
+ s: bigint;
2048
+ /** Argent / Ready include the signer's public key. */
2049
+ pubkey?: bigint;
2050
+ /** A Chipi (SHHH) wallet returns its own V2_SNIP12 envelope: the owner index. */
2051
+ shhhOwnerId?: bigint;
2052
+ }
2053
+ /**
2054
+ * Reads the signature shapes Starknet wallets return:
2055
+ * - `[r, s]`: OpenZeppelin (Bramble), Braavos with a STARK signer;
2056
+ * - `[1, 0, pubkey, r, s]`: Argent / Ready (one Starknet signer);
2057
+ * - `[V2_SNIP12, owner_id, 'STARK', r, s]`: a Chipi (SHHH) wallet.
2058
+ * Anything else (multisig, hardware or webauthn signers) is refused.
2059
+ */
2060
+ declare function parseStarknetWalletSignature(signature: Array<string | number | bigint>): ParsedStarknetWalletSignature;
2061
+ /** Off-chain check of an approval signature, before relaying it. */
2062
+ declare function verifyStarkSnip12Approval(params: {
2063
+ walletAddress: string;
2064
+ messageHash: bigint | string;
2065
+ signerAddress: string;
2066
+ starkPubkey: bigint | string;
2067
+ signature: Array<string | number | bigint>;
2068
+ chainId?: bigint | string;
2069
+ }): boolean;
2070
+ /**
2071
+ * The V2_SNIP12 envelope for a STARK_SNIP12 owner: pass the wallet's raw
2072
+ * `wallet_signTypedData` result; it is normalized to `[r, s]`.
2073
+ */
2074
+ declare function buildStarkSnip12Envelope(params: {
2075
+ signature: Array<string | number | bigint>;
2076
+ /** u32 index of this owner in the SHHH wallet's owner_set. */
2077
+ ownerIndex: bigint;
2078
+ }): bigint[];
2079
+ /**
2080
+ * Which STARK key signs for `signerAddress`, proven by an approval signature
2081
+ * the wallet just produced (e.g. for the "add trusted wallet" step). Sources,
2082
+ * in order:
2083
+ * - Argent / Ready: the key inside the signature;
2084
+ * - Chipi (SHHH) wallet: the key whose commitment matches `get_owner(id)`;
2085
+ * - an undeployed account: `wallet_deploymentData` (OpenZeppelin, Argent 0.4);
2086
+ * - OpenZeppelin (Bramble): `get_public_key`;
2087
+ * - Braavos: `get_signers` (STARK only, no hardware or webauthn signers).
2088
+ * The chosen key must verify the approval, or this throws.
2089
+ */
2090
+ declare function resolveStarkSnip12Signer(params: {
2091
+ provider: StarknetCallProvider;
2092
+ signerAddress: string;
2093
+ walletAddress: string;
2094
+ messageHash: bigint | string;
2095
+ signature: Array<string | number | bigint>;
2096
+ deploymentData?: StarknetDeploymentData;
2097
+ chainId?: bigint | string;
2098
+ }): Promise<{
2099
+ starkPubkey: bigint;
2100
+ pubkeyFelts: bigint[];
2101
+ }>;
2102
+
2103
+ /**
2104
+ * Whether a SHHH verifier class is declared on the network. A wallet can
2105
+ * register a kind whose class is not declared (`propose_add_verifier_class`
2106
+ * stores only the hash), and every signature of that kind would then fail.
2107
+ * Check before proposing a kind that is new on the network, such as
2108
+ * `STARK_SNIP12` before its mainnet declare.
2109
+ */
2110
+
2111
+ /** Anything with a starknet.js-style `getClassByHash` (e.g. `RpcProvider`). */
2112
+ interface StarknetClassProvider {
2113
+ getClassByHash(classHash: string): Promise<unknown>;
2114
+ }
2115
+ /**
2116
+ * `true` when the verifier class for `kind` (or `classHash`) is declared,
2117
+ * `false` when the RPC answers CLASS_HASH_NOT_FOUND (28). Other RPC errors
2118
+ * are thrown: an outage is not "not declared".
2119
+ */
2120
+ declare function isShhhVerifierDeclared(provider: StarknetClassProvider, kind: ShhhSignerKind, classHash?: string): Promise<boolean>;
2121
+
1878
2122
  /**
1879
2123
  * Ed25519 signer for SHHH V8.4 ShhhAccount.
1880
2124
  *
@@ -2414,9 +2658,10 @@ declare function buildJwtAppleSubEnvelopeFromTestKey(params: {
2414
2658
  *
2415
2659
  * Wave B PR B1. The V8.4 ShhhAccount gates every owner-set mutation
2416
2660
  * through a propose → wait-timelock → execute flow (`@external` fns
2417
- * in `src/account.cairo`). Each entrypoint is `_assert_self_call`-gated,
2418
- * which means callers wrap these `Call`s inside an OutsideExecution and
2419
- * submit through the paymaster.
2661
+ * in `src/account.cairo`). The propose and cancel entrypoints are
2662
+ * `_assert_self_call`-gated, which means callers wrap these `Call`s inside
2663
+ * an OutsideExecution and submit through the paymaster (see below for the
2664
+ * permissionless ones).
2420
2665
  *
2421
2666
  * This module produces the `Call` (`{ contractAddress, entrypoint,
2422
2667
  * calldata }`) shape that `oe.ts:buildOutsideExecution` expects. It
@@ -2453,11 +2698,15 @@ declare function buildJwtAppleSubEnvelopeFromTestKey(params: {
2453
2698
  * but does not remove existing ones. The integrator's UI is expected
2454
2699
  * to follow with `propose_remove_owner` for stale devices.
2455
2700
  *
2456
- * finalize_recovery is the only entrypoint here that is NOT
2457
- * `_assert_self_call`-gated — it's permissionless after the 7d window,
2458
- * so anyone can call it directly without an OE wrapper. The function
2459
- * still returns a Call so the integrator can dispatch via their
2460
- * normal account abstraction layer.
2701
+ * Not every entrypoint here is `_assert_self_call`-gated. The
2702
+ * propose_* calls, cancel_pending_op, initiate_recovery and
2703
+ * cancel_recovery are (they need an OE signed by an owner, or by a
2704
+ * guardian for a single-call initiate_recovery). Every execute_* call
2705
+ * and finalize_recovery are permissionless once their timelock has
2706
+ * elapsed: anyone can submit them, directly or inside an owner's OE, because
2707
+ * the wallet re-checks the stored payload commitment. The builders still
2708
+ * return a Call so the integrator can dispatch via their normal account
2709
+ * abstraction layer.
2461
2710
  */
2462
2711
 
2463
2712
  /** `src/owner_set/interface.cairo:10` — `pub const ROLE_OWNER: felt252 = 'OWNER'`. */
@@ -2469,6 +2718,8 @@ declare const OP_ADD_OWNER: bigint;
2469
2718
  declare const OP_REMOVE_OWNER: bigint;
2470
2719
  declare const OP_ROTATE_OWNER: bigint;
2471
2720
  declare const OP_SET_THRESHOLD: bigint;
2721
+ /** `src/governance/pending_ops.cairo:23` — `OP_ADD_VERIFIER_CLASS: felt252 = 'ADD_VERIFIER'`. */
2722
+ declare const OP_ADD_VERIFIER_CLASS: bigint;
2472
2723
  /**
2473
2724
  * Per-op timelocks in seconds. Match `src/governance/pending_ops.cairo:42-50`
2474
2725
  * exactly. Exposed so SDK consumers can predict timelock expiry without
@@ -2488,11 +2739,16 @@ declare const TIMELOCK_SECONDS: {
2488
2739
  /** `DEFAULT_OP_EXPIRY_SECONDS` from `pending_ops.cairo:78`. The window is
2489
2740
  * measured from `valid_after`, not from propose time:
2490
2741
  * `expires_at = now + timelock + DEFAULT_OP_EXPIRY_SECONDS`
2491
- * (governance/component.cairo). So a 48h op (add_owner, set_threshold) lives
2492
- * 16 days from propose and a 7d recovery lives 21. Read `get_pending_op` for
2742
+ * (governance/component.cairo). So a 48h op (add_owner, set_threshold,
2743
+ * add_verifier) lives 16 days from propose and a 24h op 15. Read
2744
+ * `get_pending_op` (or the `OpProposed` event, `parseOpProposedEvents`) for
2493
2745
  * the exact `expires_at` instead of adding 14d to the propose timestamp. The
2494
2746
  * op auto-expires at that point even if no one calls cancel; UI should
2495
- * reflect it so users don't sit on a stale op. */
2747
+ * reflect it so users don't sit on a stale op.
2748
+ *
2749
+ * Recovery is not a pending op and has no expiry: an initiated recovery
2750
+ * stays pending until an owner cancels it or anyone finalizes it after the
2751
+ * 7d timelock. */
2496
2752
  declare const DEFAULT_OP_EXPIRY_SECONDS = 1209600;
2497
2753
  /** Owner role on-chain. ROLE_OWNER can sign OEs; ROLE_GUARDIAN can
2498
2754
  * only `initiate_recovery` (no general signing power). */
@@ -2578,6 +2834,32 @@ declare function buildCancelPendingOpCall(args: {
2578
2834
  walletAddress: bigint | string;
2579
2835
  opId: bigint | string;
2580
2836
  }): Call;
2837
+ /**
2838
+ * Build a `propose_add_verifier_class(proposer, kind, class_hash)` call.
2839
+ *
2840
+ * A wallet only verifies the kinds in its `verifier_classes` map; a Chipi
2841
+ * passkey wallet starts with `STARK` only. To add an owner or guardian of
2842
+ * another kind (e.g. `STARK_SNIP12` for Bramble), put this call and
2843
+ * `buildProposeAddOwnerCall` in the same owner-signed OE, wait 48h, then
2844
+ * run `buildExecuteAddVerifierClassCall` BEFORE `buildExecuteAddOwnerCall`
2845
+ * (execute_add_owner validates the new pubkey through the verifier).
2846
+ * Reverts with `'SHHH: verifier already set'` if the kind is registered;
2847
+ * check `readVerifierClass` first.
2848
+ */
2849
+ declare function buildProposeAddVerifierClassCall(args: {
2850
+ walletAddress: bigint | string;
2851
+ proposer: number;
2852
+ kind: ShhhSignerKind;
2853
+ /** Defaults to `SHHH_VERIFIER_CLASS_HASHES[kind]`. */
2854
+ classHash?: bigint | string;
2855
+ }): Call;
2856
+ /** Build an `execute_add_verifier_class(op_id, kind, class_hash)` call (permissionless after 48h). */
2857
+ declare function buildExecuteAddVerifierClassCall(args: {
2858
+ walletAddress: bigint | string;
2859
+ opId: bigint | string;
2860
+ kind: ShhhSignerKind;
2861
+ classHash?: bigint | string;
2862
+ }): Call;
2581
2863
  /**
2582
2864
  * Build an `initiate_recovery(proposer, new_owner_kind, new_pubkey_bytes,
2583
2865
  * new_role, new_weight, new_label)` call.
@@ -2655,6 +2937,51 @@ declare function isReadyToExecute(validAfterSecs: number | bigint, nowSecs: numb
2655
2937
  * `number` seconds — truncates via floor.
2656
2938
  */
2657
2939
  declare function secondsUntilExecutable(validAfterSecs: number | bigint, nowSecs: number): number;
2940
+ /** One entry of a wallet's owner_set (`get_owner`). */
2941
+ interface ShhhOwnerRecord {
2942
+ /** u32 index: what `owner_id` means in envelopes and governance calls. */
2943
+ ownerId: number;
2944
+ kind: string;
2945
+ /** poseidon(kind, pubkey...) — compare with `ownerCommitment`. */
2946
+ pubkeyHash: bigint;
2947
+ role: "OWNER" | "GUARDIAN" | "RECOVERY_ONLY" | string;
2948
+ weight: number;
2949
+ addedAt: number;
2950
+ label: string;
2951
+ revoked: boolean;
2952
+ }
2953
+ /** A governance op from an `OpProposed` event. */
2954
+ interface ShhhProposedOp {
2955
+ opId: bigint;
2956
+ opKind: string;
2957
+ proposer: number;
2958
+ payload: bigint;
2959
+ validAfter: number;
2960
+ expiresAt: number;
2961
+ }
2962
+ /** `get_pending_recovery` decoded. */
2963
+ interface ShhhPendingRecovery {
2964
+ initiatedAt: number;
2965
+ validAfter: number;
2966
+ newOwnerHash: bigint;
2967
+ isActive: boolean;
2968
+ }
2969
+ /** Every owner and guardian of a SHHH wallet, revoked ones included (ids stay stable). */
2970
+ declare function readShhhOwners(provider: StarknetCallProvider, walletAddress: bigint | string): Promise<ShhhOwnerRecord[]>;
2971
+ /** The class hash registered for `kind` on this wallet, or 0n if none. */
2972
+ declare function readVerifierClass(provider: StarknetCallProvider, walletAddress: bigint | string, kind: ShhhSignerKind): Promise<bigint>;
2973
+ /** The wallet's pending recovery (`isActive: false` when there is none). */
2974
+ declare function readPendingRecovery(provider: StarknetCallProvider, walletAddress: bigint | string): Promise<ShhhPendingRecovery>;
2975
+ /**
2976
+ * Governance ops proposed in a transaction, from its receipt events. The
2977
+ * op_id mixes in the block timestamp and a counter, so it can only be read
2978
+ * back after the propose lands: pass `receipt.events` here.
2979
+ */
2980
+ declare function parseOpProposedEvents(events: Array<{
2981
+ from_address?: string;
2982
+ keys: string[];
2983
+ data: string[];
2984
+ }>, walletAddress?: bigint | string): ShhhProposedOp[];
2658
2985
 
2659
2986
  /**
2660
2987
  * SHHH V8.4 threshold envelope assembly + gas estimation.
@@ -2681,11 +3008,12 @@ declare function secondsUntilExecutable(validAfterSecs: number | bigint, nowSecs
2681
3008
  * ...env_n,
2682
3009
  * ]
2683
3010
  *
2684
- * Each inner envelope is a V2_SNIP12 single-owner envelope
2685
- * (`wrap_v2_snip12_envelope` output) from a different owner. Nested
2686
- * threshold envelopes are NOT permitted — the Cairo `_verify_sub_envelope`
2687
- * recursively checks the inner tag and rejects anything except
2688
- * V2_SNIP12.
3011
+ * Each inner frame is `[owner_id, kind_tag, ...payload]`: a single-owner
3012
+ * envelope WITHOUT its V2_SNIP12 tag, which the outer V2_THRESHOLD tag
3013
+ * replaces (`_verify_sub_envelope` reads `owner_id` at index 0). Callers
3014
+ * still pass the per-kind builders' V2_SNIP12 envelopes; the builder strips
3015
+ * the tag and `parseThresholdEnvelope` puts it back. Nested threshold
3016
+ * envelopes are not permitted.
2689
3017
  *
2690
3018
  * Cairo-enforced invariants this module replicates client-side so
2691
3019
  * mis-shaped envelopes fail at the SDK boundary with a clear message
@@ -2738,7 +3066,8 @@ declare function buildThresholdEnvelope(args: {
2738
3066
  }): bigint[];
2739
3067
  /**
2740
3068
  * Split a V2_THRESHOLD envelope back into its constituent inner
2741
- * V2_SNIP12 envelopes. Inverse of `buildThresholdEnvelope`.
3069
+ * V2_SNIP12 envelopes (the tag is restored on each frame). Inverse of
3070
+ * `buildThresholdEnvelope`.
2742
3071
  *
2743
3072
  * Useful for UI flows that need to display "N of M signers signed
2744
3073
  * so far" status without re-deriving from individual envelopes. Also
@@ -3198,4 +3527,4 @@ declare class ShhhAccount {
3198
3527
  */
3199
3528
  declare function submitViaAccount(funded: Account): ShhhSubmit;
3200
3529
 
3201
- export { ANY_CALLER_FELT, APPLE_ISSUER, type AppleTokenResponse, type ApproveBody, BOOTSTRAP_DOMAIN_SEPARATOR, type BootstrapMessageParams, type BuildBootstrapSignedCallParams, type BuildMigrationCallsParams, COUNTERFACTUAL_ACCOUNT_CLASSES, ChipiAi, ChipiBrowserSDK, ChipiClient, ChipiPaymasterAdapter, ChipiSDK, ChipiServerSDK, ChipiSessions, ChipiSkuPurchases, ChipiSkus, ChipiTransactions, ChipiTreasury, ChipiWallets, type ComputeAddressInput, type ContractEventLog, DEFAULT_OP_EXPIRY_SECONDS, type Eip191Pubkey, type ExecuteResult, type ForTreasuryConfig, ISIGNER_CANONICAL_LABEL, ISIGNER_ID, ISRC9_V2_ID, type JwtAppleSubPubkey, type ListTreasuriesOptions, type ListTreasuriesResult, MAX_OE_VALIDITY_WINDOW_SECONDS, MIN_THRESHOLD_OWNERS, type MultisigAllowance, type NewOwnerInput, OE_DOMAIN_NAME, OE_DOMAIN_REVISION, OE_DOMAIN_VERSION, OP_ADD_OWNER, OP_REMOVE_OWNER, OP_ROTATE_OWNER, OP_SET_THRESHOLD, type OutsideExecution, type OwnerRole, type ProposeBody, ROLE_GUARDIAN, ROLE_OWNER, SIG_VERSION_V1_HEX_ASCII, SIG_VERSION_V2_SNIP12, SIG_VERSION_V2_THRESHOLD, SIWS_CHAIN_ID, SIWS_DOMAIN_NAME, SIWS_DOMAIN_VERSION, STARKNET_MESSAGE_PREFIX, STARKNET_SIGNATURE_VALID, SessionTxVerifier, type SessionTxVerifierConfig, type SetTreasuryPolicyOptions, ShhhAccount, type ShhhAccountOptions, type ShhhExecuteOptions, type ShhhSignedExecution, type ShhhSubmit, type ShhhX402Wallet, type StarknetCallProvider, type StarknetDeploymentData, type StarknetSignInFailure, type StarknetSignInMessage, type StarknetSignInParams, type StarknetSignatureCheck, TIMELOCK_SECONDS, type TreasuryPolicy, type TreasuryProposal, type TreasuryProposalSignature, type TreasurySummary, type TreasuryTransport, type TxHashStore, type UndeployedSignatureCheck, VIEW_SELECTORS, type VerifyStarknetSignInParams, type VerifyStarknetSignInResult, type VerifyTransferFailure, type VerifyTransferParams, type VerifyTransferResult, type WaitForTransactionOptions, type WaitForTransactionResult, type WebAuthnPubkey, X402Facilitator, type X402FacilitatorCreateOptions, type X402MiddlewareConfig, type X402MiddlewareFlatConfig, X402ShhhClient, type X402ShhhClientConfig, assertValidV2Snip12Envelope, buildAddSessionKeyCall, buildBootstrapSignedCall, buildCancelPendingOpCall, buildCancelRecoveryCall, buildEd25519Envelope, buildEd25519EnvelopeFromSignature, buildEip191EnvelopeFromPrivateKey, buildEip191EnvelopeFromSignature, buildExecuteAddOwnerCall, buildExecuteRemoveOwnerCall, buildExecuteRotateOwnerCall, buildExecuteSetThresholdCall, buildFinalizeRecoveryCall, buildInitiateRecoveryCall, buildJwtAppleSubEnvelopeFromTestKey, buildJwtAppleSubEnvelopeFromTokenResponse, buildMigrationCalls, buildOutsideExecution, buildProposeAddOwnerCall, buildProposeRemoveOwnerCall, buildProposeRotateOwnerCall, buildProposeSetThresholdCall, buildRemoveSpendingPolicyCall, buildRevokeSessionKeyCall, buildSessionSetupCalls, buildSetSpendingPolicyCall, buildStarkEnvelope, buildThresholdEnvelope, buildWebAuthnEnvelopeFromAssertion, buildWebAuthnEnvelopeFromPrivateKey, byteArrayToFelts, computeAddressSalt, computeBootstrapMessage, computeISignerId, computeOeHash, computeShhhAddress, computeSnip12Hash, createStarknetSignInTypedData, decryptPrivateKey, ed25519OwnerId, ed25519OwnerPubkeyParam, ed25519PubkeyFelts, ed25519SignedBytes, eip191OwnerId, eip191OwnerPubkeyParam, eip191PubkeyFelts, encryptPrivateKey, estimateThresholdGasOverhead, executeShhhSponsoredRaw, hashCall, hashCalls, hashOutsideExecutionStruct, hashStarknetDomain, isReadyToExecute, isThinkDecision, isValidStarknetSignature, jwtAppleSubHash, jwtAppleSubOwnerId, jwtAppleSubPubkeyFelts, labelToFelt, locateSubClaim, messageHashToNonceB64url, normalizeEntrypoints, normalizeStarknetAddress, ownerCommitment, parseAppleIdToken, parseDerEcdsaSignature, parseEip191Signature, parseThresholdEnvelope, resolveShhhChainId, secondsUntilExecutable, serializeExecuteFromOutsideV2Calldata, signBootstrapMessage, signTypedData, signTypedDataArray, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, submitViaAccount, validateSpendingPolicyConfig, verifyStarknetSignIn, verifyUndeployedStarknetSignature, waitForTransaction, webauthnOwnerId, webauthnOwnerPubkeyParam, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };
3530
+ export { ANY_CALLER_FELT, APPLE_ISSUER, type AppleTokenResponse, type ApproveBody, BOOTSTRAP_DOMAIN_SEPARATOR, type BootstrapMessageParams, type BuildBootstrapSignedCallParams, type BuildMigrationCallsParams, COUNTERFACTUAL_ACCOUNT_CLASSES, ChipiAi, ChipiBrowserSDK, ChipiClient, ChipiPaymasterAdapter, ChipiSDK, ChipiServerSDK, ChipiSessions, ChipiSkuPurchases, ChipiSkus, ChipiTransactions, ChipiTreasury, ChipiWallets, type ComputeAddressInput, type ContractEventLog, DEFAULT_OP_EXPIRY_SECONDS, type Eip191Pubkey, type ExecuteResult, type ForTreasuryConfig, ISIGNER_CANONICAL_LABEL, ISIGNER_ID, ISRC9_V2_ID, type JwtAppleSubPubkey, type ListTreasuriesOptions, type ListTreasuriesResult, MAX_OE_VALIDITY_WINDOW_SECONDS, MIN_THRESHOLD_OWNERS, type MultisigAllowance, type NewOwnerInput, OE_DOMAIN_NAME, OE_DOMAIN_REVISION, OE_DOMAIN_VERSION, OP_ADD_OWNER, OP_ADD_VERIFIER_CLASS, OP_REMOVE_OWNER, OP_ROTATE_OWNER, OP_SET_THRESHOLD, type OutsideExecution, type OwnerRole, type ParsedStarknetWalletSignature, type PreparedExternalOwnerExecution, type ProposeBody, ROLE_GUARDIAN, ROLE_OWNER, SIG_VERSION_V1_HEX_ASCII, SIG_VERSION_V2_SNIP12, SIG_VERSION_V2_THRESHOLD, SIWS_CHAIN_ID, SIWS_DOMAIN_NAME, SIWS_DOMAIN_VERSION, STARKNET_MESSAGE_PREFIX, STARKNET_SIGNATURE_VALID, STARK_SNIP12_KIND_TAG, SessionTxVerifier, type SessionTxVerifierConfig, type SetTreasuryPolicyOptions, ShhhAccount, type ShhhAccountOptions, type ShhhExecuteOptions, type ShhhOwnerRecord, type ShhhPendingRecovery, type ShhhProposedOp, type ShhhSignedExecution, type ShhhSubmit, type ShhhX402Wallet, type StarknetCallProvider, type StarknetClassProvider, type StarknetDeploymentData, type StarknetSignInFailure, type StarknetSignInMessage, type StarknetSignInParams, type StarknetSignatureCheck, TIMELOCK_SECONDS, type TreasuryPolicy, type TreasuryProposal, type TreasuryProposalSignature, type TreasurySummary, type TreasuryTransport, type TxHashStore, type UndeployedSignatureCheck, VIEW_SELECTORS, type VerifyStarknetSignInParams, type VerifyStarknetSignInResult, type VerifyTransferFailure, type VerifyTransferParams, type VerifyTransferResult, type WaitForTransactionOptions, type WaitForTransactionResult, type WebAuthnPubkey, X402Facilitator, type X402FacilitatorCreateOptions, type X402MiddlewareConfig, type X402MiddlewareFlatConfig, X402ShhhClient, type X402ShhhClientConfig, assertValidV2Snip12Envelope, buildAddSessionKeyCall, buildBootstrapSignedCall, buildCancelPendingOpCall, buildCancelRecoveryCall, buildEd25519Envelope, buildEd25519EnvelopeFromSignature, buildEip191EnvelopeFromPrivateKey, buildEip191EnvelopeFromSignature, buildExecuteAddOwnerCall, buildExecuteAddVerifierClassCall, buildExecuteRemoveOwnerCall, buildExecuteRotateOwnerCall, buildExecuteSetThresholdCall, buildFinalizeRecoveryCall, buildInitiateRecoveryCall, buildJwtAppleSubEnvelopeFromTestKey, buildJwtAppleSubEnvelopeFromTokenResponse, buildMigrationCalls, buildOutsideExecution, buildProposeAddOwnerCall, buildProposeAddVerifierClassCall, buildProposeRemoveOwnerCall, buildProposeRotateOwnerCall, buildProposeSetThresholdCall, buildRemoveSpendingPolicyCall, buildRevokeSessionKeyCall, buildSessionSetupCalls, buildSetSpendingPolicyCall, buildStarkEnvelope, buildStarkSnip12Envelope, buildThresholdEnvelope, buildWebAuthnEnvelopeFromAssertion, buildWebAuthnEnvelopeFromPrivateKey, byteArrayToFelts, computeAddressSalt, computeBootstrapMessage, computeISignerId, computeOeHash, computeShhhAddress, computeSnip12Hash, createStarknetSignInTypedData, decryptPrivateKey, ed25519OwnerId, ed25519OwnerPubkeyParam, ed25519PubkeyFelts, ed25519SignedBytes, eip191OwnerId, eip191OwnerPubkeyParam, eip191PubkeyFelts, encryptPrivateKey, estimateThresholdGasOverhead, executeShhhSponsoredRaw, executeShhhWithExternalSigner, executeShhhWithStarkKey, hashCall, hashCalls, hashOutsideExecutionStruct, hashStarknetDomain, isReadyToExecute, isShhhVerifierDeclared, isThinkDecision, isValidStarknetSignature, jwtAppleSubHash, jwtAppleSubOwnerId, jwtAppleSubPubkeyFelts, labelToFelt, locateSubClaim, messageHashToNonceB64url, normalizeEntrypoints, normalizeStarknetAddress, ownerCommitment, parseAppleIdToken, parseDerEcdsaSignature, parseEip191Signature, parseOpProposedEvents, parseStarknetWalletSignature, parseThresholdEnvelope, prepareExternalOwnerExecution, readPendingRecovery, readShhhOwners, readVerifierClass, resolveShhhChainId, resolveStarkSnip12Signer, secondsUntilExecutable, serializeExecuteFromOutsideV2Calldata, signBootstrapMessage, signTypedData, signTypedDataArray, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, starkSnip12ApprovalHash, starkSnip12ApprovalTypedData, starkSnip12OwnerCommitment, starkSnip12PubkeyFelts, submitExternalOwnerExecution, submitViaAccount, validateSpendingPolicyConfig, verifyStarkSnip12Approval, verifyStarknetSignIn, verifyUndeployedStarknetSignature, waitForTransaction, webauthnOwnerId, webauthnOwnerPubkeyParam, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };