@chipi-stack/backend 14.7.0 → 14.8.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.mts CHANGED
@@ -281,6 +281,143 @@ declare class ChipiExchanges {
281
281
  getUsdAmount(currencyAmount: number, currency: Currency, bearerToken: string): Promise<number>;
282
282
  }
283
283
 
284
+ /**
285
+ * SHHH multisig treasury coordination client (Plus Wave 9 / P1).
286
+ *
287
+ * A thin, typed HTTP client for the chipi-back `/v1/treasuries/:id/...`
288
+ * endpoints. It implements the same transport contract `@chipi-stack/chipi-react`
289
+ * injects into `useProposeAction` / `useTreasuryProposals` (`MultisigTransport`),
290
+ * so an integrator can wire `sdk.treasury.forTreasury(...)` straight into those
291
+ * hooks instead of hand-writing fetch glue.
292
+ *
293
+ * Auth model (decision §11.2 — owner-signature-as-authorization):
294
+ * - propose / sign: `pk_` (the public api key) PLUS the owner's V2_SNIP12
295
+ * envelope (already inside the proposal body) AND the owner's STARK
296
+ * `ownerPubkey`. chipi-back's OwnerSignatureVerifier proves the request
297
+ * came from a current on-chain owner, so no secret is needed — these are
298
+ * safe to call from the browser.
299
+ * - execute / list / allowance: `sk_` (a secret key bearer). execute relays
300
+ * through the paymaster and meters; reads are org-private. Call these from
301
+ * a server (a Next.js route handler / your backend), never the browser.
302
+ *
303
+ * The types below mirror `@chipi-stack/chipi-react/multisig`'s `TreasuryProposal`
304
+ * / `ProposeBody` field-for-field (post-#324: OE `executeAfter` is derived from
305
+ * `executeBefore`, never sent or stored). They're duplicated (not imported) so
306
+ * the server SDK never depends on the React package; TypeScript's structural
307
+ * typing makes a `TreasuryTransport` assignable to the hook's `MultisigTransport`.
308
+ */
309
+ /** One owner's collected signature on a proposal. */
310
+ interface TreasuryProposalSignature {
311
+ ownerId: number;
312
+ signerKind: string;
313
+ /** The owner's serialized inner V2_SNIP12 envelope (comma-joined felts). */
314
+ signature: string;
315
+ }
316
+ /** A treasury proposal as returned by the coordination backend. */
317
+ interface TreasuryProposal {
318
+ id: string;
319
+ /** Set for generalized actions (vote / call any contract); null for payments. */
320
+ calls?: {
321
+ to: string;
322
+ entrypoint: string;
323
+ calldata: string[];
324
+ }[] | null;
325
+ /** Human label for an action ("Vote YES on Proposal #5"). */
326
+ title?: string | null;
327
+ /** Arbitrary integrator context. chipi-back has no column for it today, so
328
+ * it is absent on every proposal it returns (kept for contract parity). */
329
+ meta?: Record<string, string | number> | null;
330
+ oeMessageHash: string;
331
+ oeNonce: string | null;
332
+ /** chipi-back persists only `oeExecuteBefore`; the OE `executeAfter` is
333
+ * re-derived as `executeBefore - 2h` by executors (see chipi-react #324). */
334
+ oeExecuteBefore: string | null;
335
+ requiredApprovals: number;
336
+ status: "PROPOSED" | "APPROVED" | "EXECUTED" | "CANCELED" | "EXPIRED";
337
+ executedTxHash?: string | null;
338
+ signatures: TreasuryProposalSignature[];
339
+ }
340
+ /** The body the coordination backend's `propose` endpoint accepts. */
341
+ interface ProposeBody {
342
+ proposerOwnerId: number;
343
+ recipient: string;
344
+ tokenAddress: string;
345
+ amount: string;
346
+ title: string;
347
+ calls: {
348
+ to: string;
349
+ entrypoint: string;
350
+ calldata: string[];
351
+ }[];
352
+ /** Arbitrary integrator context. NOTE: not persisted by chipi-back today
353
+ * (no column) — the global ValidationPipe strips it. Kept for parity. */
354
+ meta?: Record<string, string | number>;
355
+ oeMessageHash: string;
356
+ oeNonce: string;
357
+ oeExecuteBefore: string;
358
+ requiredApprovals: number;
359
+ proposerSignature: string;
360
+ proposerSignerKind: string;
361
+ }
362
+ /** The approver's body for `sign` (mirrors chipi-react's call site). */
363
+ interface ApproveBody {
364
+ ownerId: number;
365
+ signature: string;
366
+ signerKind: string;
367
+ }
368
+ /** Result of relaying an execute through the paymaster. */
369
+ interface ExecuteResult {
370
+ executedTxHash?: string;
371
+ transactionHash?: string;
372
+ }
373
+ /** Free-execute meter for the org (shape owned by chipi-back's treasury svc). */
374
+ interface MultisigAllowance {
375
+ freeExecutesRemaining?: number;
376
+ priceUsd?: number;
377
+ creditsUsd?: number;
378
+ canExecuteNow?: boolean;
379
+ [key: string]: unknown;
380
+ }
381
+ /**
382
+ * A transport bound to one treasury + the local owner's STARK pubkey.
383
+ * Structurally compatible with `@chipi-stack/chipi-react`'s `MultisigTransport`.
384
+ */
385
+ interface TreasuryTransport {
386
+ list(): Promise<{
387
+ items: TreasuryProposal[];
388
+ }>;
389
+ propose(body: ProposeBody): Promise<TreasuryProposal>;
390
+ sign(proposalId: string, body: ApproveBody): Promise<unknown>;
391
+ execute(proposalId: string, calldata: string[]): Promise<ExecuteResult>;
392
+ /** Read the org's free-execute meter (sk_). Not part of MultisigTransport. */
393
+ getMultisigAllowance(): Promise<MultisigAllowance>;
394
+ }
395
+ interface ForTreasuryConfig {
396
+ /** The org treasury id (the multisig wallet's row id in chipi-back). */
397
+ treasuryId: string;
398
+ /** The local owner's STARK public key (one 0x-hex felt). Sent with propose /
399
+ * sign so the backend can verify the envelope commits to a current owner. */
400
+ ownerPubkey: string;
401
+ /** A secret key (`sk_`) for execute / list / allowance. Falls back to the
402
+ * SDK's configured `apiSecretKey`. Required only for those three; propose /
403
+ * sign authenticate with `pk_` + the owner signature. */
404
+ bearerToken?: string;
405
+ }
406
+ declare class ChipiTreasury {
407
+ private client;
408
+ private apiSecretKey?;
409
+ constructor(client: ChipiClient, apiSecretKey?: string | undefined);
410
+ private base;
411
+ /** Resolve a `sk_` for the secret-gated reads/execute, or fail loudly. */
412
+ private secret;
413
+ /**
414
+ * Build a {@link TreasuryTransport} for one treasury + owner. Wire the
415
+ * returned object directly into chipi-react's `useProposeAction` /
416
+ * `useTreasuryProposals` `transport` prop, or call its methods yourself.
417
+ */
418
+ forTreasury(config: ForTreasuryConfig): TreasuryTransport;
419
+ }
420
+
284
421
  /**
285
422
  * PaymasterAdapter implementation that uses Chipi's backend API for gasless transactions.
286
423
  *
@@ -382,6 +519,7 @@ declare class ChipiSDK {
382
519
  readonly skus: ChipiSkus;
383
520
  readonly sessions: ChipiSessions;
384
521
  readonly exchanges: ChipiExchanges;
522
+ readonly treasury: ChipiTreasury;
385
523
  constructor(config: ChipiSDKConfig);
386
524
  /**
387
525
  * Resolve bearer token - uses provided token or falls back to apiSecretKey
@@ -2248,4 +2386,4 @@ declare function executeShhhSponsoredRaw(params: {
2248
2386
  chainId?: bigint | string;
2249
2387
  }): Promise<string>;
2250
2388
 
2251
- export { ANY_CALLER_FELT, APPLE_ISSUER, type AppleTokenResponse, BOOTSTRAP_DOMAIN_SEPARATOR, type BootstrapMessageParams, type BuildBootstrapSignedCallParams, type BuildMigrationCallsParams, ChipiBrowserSDK, ChipiClient, ChipiPaymasterAdapter, ChipiSDK, ChipiServerSDK, ChipiSessions, ChipiSkuPurchases, ChipiSkus, ChipiTransactions, ChipiWallets, type ComputeAddressInput, DEFAULT_OP_EXPIRY_SECONDS, type Eip191Pubkey, ISIGNER_CANONICAL_LABEL, ISIGNER_ID, ISRC9_V2_ID, type JwtAppleSubPubkey, MAX_OE_VALIDITY_WINDOW_SECONDS, MIN_THRESHOLD_OWNERS, 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, ROLE_GUARDIAN, ROLE_OWNER, SIG_VERSION_V1_HEX_ASCII, SIG_VERSION_V2_SNIP12, SIG_VERSION_V2_THRESHOLD, STARKNET_MESSAGE_PREFIX, type ShhhX402Wallet, TIMELOCK_SECONDS, VIEW_SELECTORS, type WebAuthnPubkey, X402Facilitator, type X402FacilitatorCreateOptions, type X402MiddlewareConfig, type X402MiddlewareFlatConfig, X402ShhhClient, type X402ShhhClientConfig, assertValidV2Snip12Envelope, buildBootstrapSignedCall, buildCancelPendingOpCall, buildCancelRecoveryCall, buildEd25519Envelope, buildEd25519EnvelopeFromSignature, buildEip191EnvelopeFromPrivateKey, buildEip191EnvelopeFromSignature, buildExecuteAddOwnerCall, buildExecuteRemoveOwnerCall, buildExecuteRotateOwnerCall, buildExecuteSetThresholdCall, buildFinalizeRecoveryCall, buildInitiateRecoveryCall, buildJwtAppleSubEnvelopeFromTestKey, buildJwtAppleSubEnvelopeFromTokenResponse, buildMigrationCalls, buildOutsideExecution, buildProposeAddOwnerCall, buildProposeRemoveOwnerCall, buildProposeRotateOwnerCall, buildProposeSetThresholdCall, buildStarkEnvelope, buildThresholdEnvelope, buildWebAuthnEnvelopeFromAssertion, buildWebAuthnEnvelopeFromPrivateKey, byteArrayToFelts, computeAddressSalt, computeBootstrapMessage, computeISignerId, computeOeHash, computeShhhAddress, computeSnip12Hash, decryptPrivateKey, ed25519OwnerId, ed25519PubkeyFelts, ed25519SignedBytes, eip191OwnerId, eip191PubkeyFelts, encryptPrivateKey, estimateThresholdGasOverhead, executeShhhSponsoredRaw, hashCall, hashCalls, hashOutsideExecutionStruct, hashStarknetDomain, isReadyToExecute, jwtAppleSubHash, jwtAppleSubOwnerId, jwtAppleSubPubkeyFelts, labelToFelt, locateSubClaim, messageHashToNonceB64url, ownerCommitment, parseAppleIdToken, parseDerEcdsaSignature, parseEip191Signature, parseThresholdEnvelope, resolveShhhChainId, secondsUntilExecutable, serializeExecuteFromOutsideV2Calldata, signBootstrapMessage, signTypedData, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, webauthnOwnerId, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };
2389
+ export { ANY_CALLER_FELT, APPLE_ISSUER, type AppleTokenResponse, type ApproveBody, BOOTSTRAP_DOMAIN_SEPARATOR, type BootstrapMessageParams, type BuildBootstrapSignedCallParams, type BuildMigrationCallsParams, ChipiBrowserSDK, ChipiClient, ChipiPaymasterAdapter, ChipiSDK, ChipiServerSDK, ChipiSessions, ChipiSkuPurchases, ChipiSkus, ChipiTransactions, ChipiTreasury, ChipiWallets, type ComputeAddressInput, DEFAULT_OP_EXPIRY_SECONDS, type Eip191Pubkey, type ExecuteResult, type ForTreasuryConfig, ISIGNER_CANONICAL_LABEL, ISIGNER_ID, ISRC9_V2_ID, type JwtAppleSubPubkey, 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, STARKNET_MESSAGE_PREFIX, type ShhhX402Wallet, TIMELOCK_SECONDS, type TreasuryProposal, type TreasuryProposalSignature, type TreasuryTransport, VIEW_SELECTORS, type WebAuthnPubkey, X402Facilitator, type X402FacilitatorCreateOptions, type X402MiddlewareConfig, type X402MiddlewareFlatConfig, X402ShhhClient, type X402ShhhClientConfig, assertValidV2Snip12Envelope, buildBootstrapSignedCall, buildCancelPendingOpCall, buildCancelRecoveryCall, buildEd25519Envelope, buildEd25519EnvelopeFromSignature, buildEip191EnvelopeFromPrivateKey, buildEip191EnvelopeFromSignature, buildExecuteAddOwnerCall, buildExecuteRemoveOwnerCall, buildExecuteRotateOwnerCall, buildExecuteSetThresholdCall, buildFinalizeRecoveryCall, buildInitiateRecoveryCall, buildJwtAppleSubEnvelopeFromTestKey, buildJwtAppleSubEnvelopeFromTokenResponse, buildMigrationCalls, buildOutsideExecution, buildProposeAddOwnerCall, buildProposeRemoveOwnerCall, buildProposeRotateOwnerCall, buildProposeSetThresholdCall, buildStarkEnvelope, buildThresholdEnvelope, buildWebAuthnEnvelopeFromAssertion, buildWebAuthnEnvelopeFromPrivateKey, byteArrayToFelts, computeAddressSalt, computeBootstrapMessage, computeISignerId, computeOeHash, computeShhhAddress, computeSnip12Hash, decryptPrivateKey, ed25519OwnerId, ed25519PubkeyFelts, ed25519SignedBytes, eip191OwnerId, eip191PubkeyFelts, encryptPrivateKey, estimateThresholdGasOverhead, executeShhhSponsoredRaw, hashCall, hashCalls, hashOutsideExecutionStruct, hashStarknetDomain, isReadyToExecute, jwtAppleSubHash, jwtAppleSubOwnerId, jwtAppleSubPubkeyFelts, labelToFelt, locateSubClaim, messageHashToNonceB64url, ownerCommitment, parseAppleIdToken, parseDerEcdsaSignature, parseEip191Signature, parseThresholdEnvelope, resolveShhhChainId, secondsUntilExecutable, serializeExecuteFromOutsideV2Calldata, signBootstrapMessage, signTypedData, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, webauthnOwnerId, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };
package/dist/index.d.ts CHANGED
@@ -281,6 +281,143 @@ declare class ChipiExchanges {
281
281
  getUsdAmount(currencyAmount: number, currency: Currency, bearerToken: string): Promise<number>;
282
282
  }
283
283
 
284
+ /**
285
+ * SHHH multisig treasury coordination client (Plus Wave 9 / P1).
286
+ *
287
+ * A thin, typed HTTP client for the chipi-back `/v1/treasuries/:id/...`
288
+ * endpoints. It implements the same transport contract `@chipi-stack/chipi-react`
289
+ * injects into `useProposeAction` / `useTreasuryProposals` (`MultisigTransport`),
290
+ * so an integrator can wire `sdk.treasury.forTreasury(...)` straight into those
291
+ * hooks instead of hand-writing fetch glue.
292
+ *
293
+ * Auth model (decision §11.2 — owner-signature-as-authorization):
294
+ * - propose / sign: `pk_` (the public api key) PLUS the owner's V2_SNIP12
295
+ * envelope (already inside the proposal body) AND the owner's STARK
296
+ * `ownerPubkey`. chipi-back's OwnerSignatureVerifier proves the request
297
+ * came from a current on-chain owner, so no secret is needed — these are
298
+ * safe to call from the browser.
299
+ * - execute / list / allowance: `sk_` (a secret key bearer). execute relays
300
+ * through the paymaster and meters; reads are org-private. Call these from
301
+ * a server (a Next.js route handler / your backend), never the browser.
302
+ *
303
+ * The types below mirror `@chipi-stack/chipi-react/multisig`'s `TreasuryProposal`
304
+ * / `ProposeBody` field-for-field (post-#324: OE `executeAfter` is derived from
305
+ * `executeBefore`, never sent or stored). They're duplicated (not imported) so
306
+ * the server SDK never depends on the React package; TypeScript's structural
307
+ * typing makes a `TreasuryTransport` assignable to the hook's `MultisigTransport`.
308
+ */
309
+ /** One owner's collected signature on a proposal. */
310
+ interface TreasuryProposalSignature {
311
+ ownerId: number;
312
+ signerKind: string;
313
+ /** The owner's serialized inner V2_SNIP12 envelope (comma-joined felts). */
314
+ signature: string;
315
+ }
316
+ /** A treasury proposal as returned by the coordination backend. */
317
+ interface TreasuryProposal {
318
+ id: string;
319
+ /** Set for generalized actions (vote / call any contract); null for payments. */
320
+ calls?: {
321
+ to: string;
322
+ entrypoint: string;
323
+ calldata: string[];
324
+ }[] | null;
325
+ /** Human label for an action ("Vote YES on Proposal #5"). */
326
+ title?: string | null;
327
+ /** Arbitrary integrator context. chipi-back has no column for it today, so
328
+ * it is absent on every proposal it returns (kept for contract parity). */
329
+ meta?: Record<string, string | number> | null;
330
+ oeMessageHash: string;
331
+ oeNonce: string | null;
332
+ /** chipi-back persists only `oeExecuteBefore`; the OE `executeAfter` is
333
+ * re-derived as `executeBefore - 2h` by executors (see chipi-react #324). */
334
+ oeExecuteBefore: string | null;
335
+ requiredApprovals: number;
336
+ status: "PROPOSED" | "APPROVED" | "EXECUTED" | "CANCELED" | "EXPIRED";
337
+ executedTxHash?: string | null;
338
+ signatures: TreasuryProposalSignature[];
339
+ }
340
+ /** The body the coordination backend's `propose` endpoint accepts. */
341
+ interface ProposeBody {
342
+ proposerOwnerId: number;
343
+ recipient: string;
344
+ tokenAddress: string;
345
+ amount: string;
346
+ title: string;
347
+ calls: {
348
+ to: string;
349
+ entrypoint: string;
350
+ calldata: string[];
351
+ }[];
352
+ /** Arbitrary integrator context. NOTE: not persisted by chipi-back today
353
+ * (no column) — the global ValidationPipe strips it. Kept for parity. */
354
+ meta?: Record<string, string | number>;
355
+ oeMessageHash: string;
356
+ oeNonce: string;
357
+ oeExecuteBefore: string;
358
+ requiredApprovals: number;
359
+ proposerSignature: string;
360
+ proposerSignerKind: string;
361
+ }
362
+ /** The approver's body for `sign` (mirrors chipi-react's call site). */
363
+ interface ApproveBody {
364
+ ownerId: number;
365
+ signature: string;
366
+ signerKind: string;
367
+ }
368
+ /** Result of relaying an execute through the paymaster. */
369
+ interface ExecuteResult {
370
+ executedTxHash?: string;
371
+ transactionHash?: string;
372
+ }
373
+ /** Free-execute meter for the org (shape owned by chipi-back's treasury svc). */
374
+ interface MultisigAllowance {
375
+ freeExecutesRemaining?: number;
376
+ priceUsd?: number;
377
+ creditsUsd?: number;
378
+ canExecuteNow?: boolean;
379
+ [key: string]: unknown;
380
+ }
381
+ /**
382
+ * A transport bound to one treasury + the local owner's STARK pubkey.
383
+ * Structurally compatible with `@chipi-stack/chipi-react`'s `MultisigTransport`.
384
+ */
385
+ interface TreasuryTransport {
386
+ list(): Promise<{
387
+ items: TreasuryProposal[];
388
+ }>;
389
+ propose(body: ProposeBody): Promise<TreasuryProposal>;
390
+ sign(proposalId: string, body: ApproveBody): Promise<unknown>;
391
+ execute(proposalId: string, calldata: string[]): Promise<ExecuteResult>;
392
+ /** Read the org's free-execute meter (sk_). Not part of MultisigTransport. */
393
+ getMultisigAllowance(): Promise<MultisigAllowance>;
394
+ }
395
+ interface ForTreasuryConfig {
396
+ /** The org treasury id (the multisig wallet's row id in chipi-back). */
397
+ treasuryId: string;
398
+ /** The local owner's STARK public key (one 0x-hex felt). Sent with propose /
399
+ * sign so the backend can verify the envelope commits to a current owner. */
400
+ ownerPubkey: string;
401
+ /** A secret key (`sk_`) for execute / list / allowance. Falls back to the
402
+ * SDK's configured `apiSecretKey`. Required only for those three; propose /
403
+ * sign authenticate with `pk_` + the owner signature. */
404
+ bearerToken?: string;
405
+ }
406
+ declare class ChipiTreasury {
407
+ private client;
408
+ private apiSecretKey?;
409
+ constructor(client: ChipiClient, apiSecretKey?: string | undefined);
410
+ private base;
411
+ /** Resolve a `sk_` for the secret-gated reads/execute, or fail loudly. */
412
+ private secret;
413
+ /**
414
+ * Build a {@link TreasuryTransport} for one treasury + owner. Wire the
415
+ * returned object directly into chipi-react's `useProposeAction` /
416
+ * `useTreasuryProposals` `transport` prop, or call its methods yourself.
417
+ */
418
+ forTreasury(config: ForTreasuryConfig): TreasuryTransport;
419
+ }
420
+
284
421
  /**
285
422
  * PaymasterAdapter implementation that uses Chipi's backend API for gasless transactions.
286
423
  *
@@ -382,6 +519,7 @@ declare class ChipiSDK {
382
519
  readonly skus: ChipiSkus;
383
520
  readonly sessions: ChipiSessions;
384
521
  readonly exchanges: ChipiExchanges;
522
+ readonly treasury: ChipiTreasury;
385
523
  constructor(config: ChipiSDKConfig);
386
524
  /**
387
525
  * Resolve bearer token - uses provided token or falls back to apiSecretKey
@@ -2248,4 +2386,4 @@ declare function executeShhhSponsoredRaw(params: {
2248
2386
  chainId?: bigint | string;
2249
2387
  }): Promise<string>;
2250
2388
 
2251
- export { ANY_CALLER_FELT, APPLE_ISSUER, type AppleTokenResponse, BOOTSTRAP_DOMAIN_SEPARATOR, type BootstrapMessageParams, type BuildBootstrapSignedCallParams, type BuildMigrationCallsParams, ChipiBrowserSDK, ChipiClient, ChipiPaymasterAdapter, ChipiSDK, ChipiServerSDK, ChipiSessions, ChipiSkuPurchases, ChipiSkus, ChipiTransactions, ChipiWallets, type ComputeAddressInput, DEFAULT_OP_EXPIRY_SECONDS, type Eip191Pubkey, ISIGNER_CANONICAL_LABEL, ISIGNER_ID, ISRC9_V2_ID, type JwtAppleSubPubkey, MAX_OE_VALIDITY_WINDOW_SECONDS, MIN_THRESHOLD_OWNERS, 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, ROLE_GUARDIAN, ROLE_OWNER, SIG_VERSION_V1_HEX_ASCII, SIG_VERSION_V2_SNIP12, SIG_VERSION_V2_THRESHOLD, STARKNET_MESSAGE_PREFIX, type ShhhX402Wallet, TIMELOCK_SECONDS, VIEW_SELECTORS, type WebAuthnPubkey, X402Facilitator, type X402FacilitatorCreateOptions, type X402MiddlewareConfig, type X402MiddlewareFlatConfig, X402ShhhClient, type X402ShhhClientConfig, assertValidV2Snip12Envelope, buildBootstrapSignedCall, buildCancelPendingOpCall, buildCancelRecoveryCall, buildEd25519Envelope, buildEd25519EnvelopeFromSignature, buildEip191EnvelopeFromPrivateKey, buildEip191EnvelopeFromSignature, buildExecuteAddOwnerCall, buildExecuteRemoveOwnerCall, buildExecuteRotateOwnerCall, buildExecuteSetThresholdCall, buildFinalizeRecoveryCall, buildInitiateRecoveryCall, buildJwtAppleSubEnvelopeFromTestKey, buildJwtAppleSubEnvelopeFromTokenResponse, buildMigrationCalls, buildOutsideExecution, buildProposeAddOwnerCall, buildProposeRemoveOwnerCall, buildProposeRotateOwnerCall, buildProposeSetThresholdCall, buildStarkEnvelope, buildThresholdEnvelope, buildWebAuthnEnvelopeFromAssertion, buildWebAuthnEnvelopeFromPrivateKey, byteArrayToFelts, computeAddressSalt, computeBootstrapMessage, computeISignerId, computeOeHash, computeShhhAddress, computeSnip12Hash, decryptPrivateKey, ed25519OwnerId, ed25519PubkeyFelts, ed25519SignedBytes, eip191OwnerId, eip191PubkeyFelts, encryptPrivateKey, estimateThresholdGasOverhead, executeShhhSponsoredRaw, hashCall, hashCalls, hashOutsideExecutionStruct, hashStarknetDomain, isReadyToExecute, jwtAppleSubHash, jwtAppleSubOwnerId, jwtAppleSubPubkeyFelts, labelToFelt, locateSubClaim, messageHashToNonceB64url, ownerCommitment, parseAppleIdToken, parseDerEcdsaSignature, parseEip191Signature, parseThresholdEnvelope, resolveShhhChainId, secondsUntilExecutable, serializeExecuteFromOutsideV2Calldata, signBootstrapMessage, signTypedData, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, webauthnOwnerId, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };
2389
+ export { ANY_CALLER_FELT, APPLE_ISSUER, type AppleTokenResponse, type ApproveBody, BOOTSTRAP_DOMAIN_SEPARATOR, type BootstrapMessageParams, type BuildBootstrapSignedCallParams, type BuildMigrationCallsParams, ChipiBrowserSDK, ChipiClient, ChipiPaymasterAdapter, ChipiSDK, ChipiServerSDK, ChipiSessions, ChipiSkuPurchases, ChipiSkus, ChipiTransactions, ChipiTreasury, ChipiWallets, type ComputeAddressInput, DEFAULT_OP_EXPIRY_SECONDS, type Eip191Pubkey, type ExecuteResult, type ForTreasuryConfig, ISIGNER_CANONICAL_LABEL, ISIGNER_ID, ISRC9_V2_ID, type JwtAppleSubPubkey, 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, STARKNET_MESSAGE_PREFIX, type ShhhX402Wallet, TIMELOCK_SECONDS, type TreasuryProposal, type TreasuryProposalSignature, type TreasuryTransport, VIEW_SELECTORS, type WebAuthnPubkey, X402Facilitator, type X402FacilitatorCreateOptions, type X402MiddlewareConfig, type X402MiddlewareFlatConfig, X402ShhhClient, type X402ShhhClientConfig, assertValidV2Snip12Envelope, buildBootstrapSignedCall, buildCancelPendingOpCall, buildCancelRecoveryCall, buildEd25519Envelope, buildEd25519EnvelopeFromSignature, buildEip191EnvelopeFromPrivateKey, buildEip191EnvelopeFromSignature, buildExecuteAddOwnerCall, buildExecuteRemoveOwnerCall, buildExecuteRotateOwnerCall, buildExecuteSetThresholdCall, buildFinalizeRecoveryCall, buildInitiateRecoveryCall, buildJwtAppleSubEnvelopeFromTestKey, buildJwtAppleSubEnvelopeFromTokenResponse, buildMigrationCalls, buildOutsideExecution, buildProposeAddOwnerCall, buildProposeRemoveOwnerCall, buildProposeRotateOwnerCall, buildProposeSetThresholdCall, buildStarkEnvelope, buildThresholdEnvelope, buildWebAuthnEnvelopeFromAssertion, buildWebAuthnEnvelopeFromPrivateKey, byteArrayToFelts, computeAddressSalt, computeBootstrapMessage, computeISignerId, computeOeHash, computeShhhAddress, computeSnip12Hash, decryptPrivateKey, ed25519OwnerId, ed25519PubkeyFelts, ed25519SignedBytes, eip191OwnerId, eip191PubkeyFelts, encryptPrivateKey, estimateThresholdGasOverhead, executeShhhSponsoredRaw, hashCall, hashCalls, hashOutsideExecutionStruct, hashStarknetDomain, isReadyToExecute, jwtAppleSubHash, jwtAppleSubOwnerId, jwtAppleSubPubkeyFelts, labelToFelt, locateSubClaim, messageHashToNonceB64url, ownerCommitment, parseAppleIdToken, parseDerEcdsaSignature, parseEip191Signature, parseThresholdEnvelope, resolveShhhChainId, secondsUntilExecutable, serializeExecuteFromOutsideV2Calldata, signBootstrapMessage, signTypedData, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, webauthnOwnerId, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };
package/dist/index.js CHANGED
@@ -2826,6 +2826,79 @@ var ChipiSessions = class {
2826
2826
  }
2827
2827
  }
2828
2828
  };
2829
+ var ChipiTreasury = class {
2830
+ constructor(client, apiSecretKey) {
2831
+ this.client = client;
2832
+ this.apiSecretKey = apiSecretKey;
2833
+ }
2834
+ base(treasuryId) {
2835
+ return `${shared.API_ENDPOINTS.TREASURIES}/${treasuryId}/transactions`;
2836
+ }
2837
+ /** Resolve a `sk_` for the secret-gated reads/execute, or fail loudly. */
2838
+ secret(bearerToken) {
2839
+ const token = bearerToken ?? this.apiSecretKey;
2840
+ if (!token) {
2841
+ throw new Error(
2842
+ "A secret key (sk_) is required for treasury execute / list / allowance. Pass `bearerToken` to forTreasury(...) or configure the SDK with apiSecretKey. Call these from a server, never the browser."
2843
+ );
2844
+ }
2845
+ return token;
2846
+ }
2847
+ /**
2848
+ * Build a {@link TreasuryTransport} for one treasury + owner. Wire the
2849
+ * returned object directly into chipi-react's `useProposeAction` /
2850
+ * `useTreasuryProposals` `transport` prop, or call its methods yourself.
2851
+ */
2852
+ forTreasury(config) {
2853
+ const { treasuryId, ownerPubkey } = config;
2854
+ const base = this.base(treasuryId);
2855
+ return {
2856
+ // sk_ — read the proposal list. chipi-back returns
2857
+ // { items, total, page, limit, hasMore }; the hook only reads `items`.
2858
+ list: async () => {
2859
+ const res = await this.client.get({
2860
+ endpoint: base,
2861
+ bearerToken: this.secret(config.bearerToken)
2862
+ });
2863
+ return { ...res, items: res.items ?? [] };
2864
+ },
2865
+ // pk_ + owner sig — no secret. `ownerPubkey` lets the backend verify the
2866
+ // proposer envelope. `meta` (if present) is stripped server-side.
2867
+ propose: async (body) => {
2868
+ return this.client.post({
2869
+ endpoint: base,
2870
+ // Empty string → no Authorization header; the pk_ travels in
2871
+ // x-api-key, which ApiKeyGuard accepts for propose.
2872
+ bearerToken: "",
2873
+ body: { ...body, ownerPubkey }
2874
+ });
2875
+ },
2876
+ // pk_ + owner sig — approve an existing proposal.
2877
+ sign: async (proposalId, body) => {
2878
+ return this.client.post({
2879
+ endpoint: `${base}/${proposalId}/sign`,
2880
+ bearerToken: "",
2881
+ body: { ...body, ownerPubkey }
2882
+ });
2883
+ },
2884
+ // sk_ — relay the assembled threshold calldata through the paymaster.
2885
+ execute: async (proposalId, calldata) => {
2886
+ return this.client.post({
2887
+ endpoint: `${base}/${proposalId}/execute`,
2888
+ bearerToken: this.secret(config.bearerToken),
2889
+ body: { calldata }
2890
+ });
2891
+ },
2892
+ // sk_ — the free-execute meter (org-scoped).
2893
+ getMultisigAllowance: async () => {
2894
+ return this.client.get({
2895
+ endpoint: `${shared.API_ENDPOINTS.TREASURIES}/${treasuryId}/multisig-allowance`,
2896
+ bearerToken: this.secret(config.bearerToken)
2897
+ });
2898
+ }
2899
+ };
2900
+ }
2901
+ };
2829
2902
  var InMemoryNonceStore = class {
2830
2903
  constructor() {
2831
2904
  this.used = /* @__PURE__ */ new Set();
@@ -3105,6 +3178,7 @@ var ChipiSDK = class {
3105
3178
  this.skus = new ChipiSkus(this.client);
3106
3179
  this.sessions = new ChipiSessions(this.client);
3107
3180
  this.exchanges = new ChipiExchanges(this.client);
3181
+ this.treasury = new ChipiTreasury(this.client, config.apiSecretKey);
3108
3182
  this.executeTransaction = this.executeTransaction.bind(this);
3109
3183
  this.executeTransactionWithSession = this.executeTransactionWithSession.bind(this);
3110
3184
  this.transfer = this.transfer.bind(this);
@@ -4565,6 +4639,7 @@ exports.ChipiSessions = ChipiSessions;
4565
4639
  exports.ChipiSkuPurchases = ChipiSkuPurchases;
4566
4640
  exports.ChipiSkus = ChipiSkus;
4567
4641
  exports.ChipiTransactions = ChipiTransactions;
4642
+ exports.ChipiTreasury = ChipiTreasury;
4568
4643
  exports.ChipiWallets = ChipiWallets;
4569
4644
  exports.DEFAULT_OP_EXPIRY_SECONDS = DEFAULT_OP_EXPIRY_SECONDS;
4570
4645
  exports.OP_ADD_OWNER = OP_ADD_OWNER;