@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 +139 -1
- package/dist/index.d.ts +139 -1
- package/dist/index.js +75 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -2821,6 +2821,79 @@ var ChipiSessions = class {
|
|
|
2821
2821
|
}
|
|
2822
2822
|
}
|
|
2823
2823
|
};
|
|
2824
|
+
var ChipiTreasury = class {
|
|
2825
|
+
constructor(client, apiSecretKey) {
|
|
2826
|
+
this.client = client;
|
|
2827
|
+
this.apiSecretKey = apiSecretKey;
|
|
2828
|
+
}
|
|
2829
|
+
base(treasuryId) {
|
|
2830
|
+
return `${API_ENDPOINTS.TREASURIES}/${treasuryId}/transactions`;
|
|
2831
|
+
}
|
|
2832
|
+
/** Resolve a `sk_` for the secret-gated reads/execute, or fail loudly. */
|
|
2833
|
+
secret(bearerToken) {
|
|
2834
|
+
const token = bearerToken ?? this.apiSecretKey;
|
|
2835
|
+
if (!token) {
|
|
2836
|
+
throw new Error(
|
|
2837
|
+
"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."
|
|
2838
|
+
);
|
|
2839
|
+
}
|
|
2840
|
+
return token;
|
|
2841
|
+
}
|
|
2842
|
+
/**
|
|
2843
|
+
* Build a {@link TreasuryTransport} for one treasury + owner. Wire the
|
|
2844
|
+
* returned object directly into chipi-react's `useProposeAction` /
|
|
2845
|
+
* `useTreasuryProposals` `transport` prop, or call its methods yourself.
|
|
2846
|
+
*/
|
|
2847
|
+
forTreasury(config) {
|
|
2848
|
+
const { treasuryId, ownerPubkey } = config;
|
|
2849
|
+
const base = this.base(treasuryId);
|
|
2850
|
+
return {
|
|
2851
|
+
// sk_ — read the proposal list. chipi-back returns
|
|
2852
|
+
// { items, total, page, limit, hasMore }; the hook only reads `items`.
|
|
2853
|
+
list: async () => {
|
|
2854
|
+
const res = await this.client.get({
|
|
2855
|
+
endpoint: base,
|
|
2856
|
+
bearerToken: this.secret(config.bearerToken)
|
|
2857
|
+
});
|
|
2858
|
+
return { ...res, items: res.items ?? [] };
|
|
2859
|
+
},
|
|
2860
|
+
// pk_ + owner sig — no secret. `ownerPubkey` lets the backend verify the
|
|
2861
|
+
// proposer envelope. `meta` (if present) is stripped server-side.
|
|
2862
|
+
propose: async (body) => {
|
|
2863
|
+
return this.client.post({
|
|
2864
|
+
endpoint: base,
|
|
2865
|
+
// Empty string → no Authorization header; the pk_ travels in
|
|
2866
|
+
// x-api-key, which ApiKeyGuard accepts for propose.
|
|
2867
|
+
bearerToken: "",
|
|
2868
|
+
body: { ...body, ownerPubkey }
|
|
2869
|
+
});
|
|
2870
|
+
},
|
|
2871
|
+
// pk_ + owner sig — approve an existing proposal.
|
|
2872
|
+
sign: async (proposalId, body) => {
|
|
2873
|
+
return this.client.post({
|
|
2874
|
+
endpoint: `${base}/${proposalId}/sign`,
|
|
2875
|
+
bearerToken: "",
|
|
2876
|
+
body: { ...body, ownerPubkey }
|
|
2877
|
+
});
|
|
2878
|
+
},
|
|
2879
|
+
// sk_ — relay the assembled threshold calldata through the paymaster.
|
|
2880
|
+
execute: async (proposalId, calldata) => {
|
|
2881
|
+
return this.client.post({
|
|
2882
|
+
endpoint: `${base}/${proposalId}/execute`,
|
|
2883
|
+
bearerToken: this.secret(config.bearerToken),
|
|
2884
|
+
body: { calldata }
|
|
2885
|
+
});
|
|
2886
|
+
},
|
|
2887
|
+
// sk_ — the free-execute meter (org-scoped).
|
|
2888
|
+
getMultisigAllowance: async () => {
|
|
2889
|
+
return this.client.get({
|
|
2890
|
+
endpoint: `${API_ENDPOINTS.TREASURIES}/${treasuryId}/multisig-allowance`,
|
|
2891
|
+
bearerToken: this.secret(config.bearerToken)
|
|
2892
|
+
});
|
|
2893
|
+
}
|
|
2894
|
+
};
|
|
2895
|
+
}
|
|
2896
|
+
};
|
|
2824
2897
|
var InMemoryNonceStore = class {
|
|
2825
2898
|
constructor() {
|
|
2826
2899
|
this.used = /* @__PURE__ */ new Set();
|
|
@@ -3100,6 +3173,7 @@ var ChipiSDK = class {
|
|
|
3100
3173
|
this.skus = new ChipiSkus(this.client);
|
|
3101
3174
|
this.sessions = new ChipiSessions(this.client);
|
|
3102
3175
|
this.exchanges = new ChipiExchanges(this.client);
|
|
3176
|
+
this.treasury = new ChipiTreasury(this.client, config.apiSecretKey);
|
|
3103
3177
|
this.executeTransaction = this.executeTransaction.bind(this);
|
|
3104
3178
|
this.executeTransactionWithSession = this.executeTransactionWithSession.bind(this);
|
|
3105
3179
|
this.transfer = this.transfer.bind(this);
|
|
@@ -4537,6 +4611,6 @@ function secondsUntilExecutable(validAfterSecs, nowSecs) {
|
|
|
4537
4611
|
init_threshold();
|
|
4538
4612
|
init_execute_paymaster_raw();
|
|
4539
4613
|
|
|
4540
|
-
export { ANY_CALLER_FELT, APPLE_ISSUER, BOOTSTRAP_DOMAIN_SEPARATOR, ChipiBrowserSDK, ChipiClient, ChipiPaymasterAdapter, ChipiSDK, ChipiServerSDK, ChipiSessions, ChipiSkuPurchases, ChipiSkus, ChipiTransactions, ChipiWallets, DEFAULT_OP_EXPIRY_SECONDS, ISIGNER_CANONICAL_LABEL, ISIGNER_ID, ISRC9_V2_ID, MAX_OE_VALIDITY_WINDOW_SECONDS, MIN_THRESHOLD_OWNERS, OE_DOMAIN_NAME, OE_DOMAIN_REVISION, OE_DOMAIN_VERSION, OP_ADD_OWNER, OP_REMOVE_OWNER, OP_ROTATE_OWNER, OP_SET_THRESHOLD, ROLE_GUARDIAN, ROLE_OWNER, SIG_VERSION_V1_HEX_ASCII, SIG_VERSION_V2_SNIP12, SIG_VERSION_V2_THRESHOLD, STARKNET_MESSAGE_PREFIX, TIMELOCK_SECONDS, VIEW_SELECTORS, X402Facilitator, X402ShhhClient, 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, migrateChipiWalletToShhh, ownerCommitment, parseAppleIdToken, parseDerEcdsaSignature, parseEip191Signature, parseThresholdEnvelope, resolveShhhChainId, secondsUntilExecutable, serializeExecuteFromOutsideV2Calldata, signBootstrapMessage, signTypedData, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, webauthnOwnerId, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };
|
|
4614
|
+
export { ANY_CALLER_FELT, APPLE_ISSUER, BOOTSTRAP_DOMAIN_SEPARATOR, ChipiBrowserSDK, ChipiClient, ChipiPaymasterAdapter, ChipiSDK, ChipiServerSDK, ChipiSessions, ChipiSkuPurchases, ChipiSkus, ChipiTransactions, ChipiTreasury, ChipiWallets, DEFAULT_OP_EXPIRY_SECONDS, ISIGNER_CANONICAL_LABEL, ISIGNER_ID, ISRC9_V2_ID, MAX_OE_VALIDITY_WINDOW_SECONDS, MIN_THRESHOLD_OWNERS, OE_DOMAIN_NAME, OE_DOMAIN_REVISION, OE_DOMAIN_VERSION, OP_ADD_OWNER, OP_REMOVE_OWNER, OP_ROTATE_OWNER, OP_SET_THRESHOLD, ROLE_GUARDIAN, ROLE_OWNER, SIG_VERSION_V1_HEX_ASCII, SIG_VERSION_V2_SNIP12, SIG_VERSION_V2_THRESHOLD, STARKNET_MESSAGE_PREFIX, TIMELOCK_SECONDS, VIEW_SELECTORS, X402Facilitator, X402ShhhClient, 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, migrateChipiWalletToShhh, ownerCommitment, parseAppleIdToken, parseDerEcdsaSignature, parseEip191Signature, parseThresholdEnvelope, resolveShhhChainId, secondsUntilExecutable, serializeExecuteFromOutsideV2Calldata, signBootstrapMessage, signTypedData, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, webauthnOwnerId, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };
|
|
4541
4615
|
//# sourceMappingURL=index.mjs.map
|
|
4542
4616
|
//# sourceMappingURL=index.mjs.map
|