@mysten-incubation/suipay-buyer 0.3.0-dev.21 → 0.3.0-dev.22

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
@@ -1815,4 +1815,22 @@ interface VerifyPreparedSettlementInput {
1815
1815
  */
1816
1816
  declare function verifyPreparedPayment(input: VerifyPreparedSettlementInput): Promise<PreparedSettlement>;
1817
1817
 
1818
- export { type AccountApi, type AccountsApi, type AgentConnectionManifest, type AgentGrantBinding, type AgentProfile, type AgentSessionBinding, type AgentsApi, type AssetScopeInput, type BuyerAccount, type BuyerClient, type BuyerClientError, type BuyerClientOptions, type BuyerConnection, type BuyerPolicy, type BuyerResult, type CatalogApi, type CatalogService, type CreateAndActivateResult, type CreateDelegatedSignerInput, type CreateDelegatedSignerResponse, type CreatePolicyInput, type CreatePolicyResponse, type CreateProfileInput, type CreateProfileResponse, type DashboardBridgeResolvers, type DashboardConnectionManifest, type DelegatedSigner, type DelegatedSignerGrant, type DelegatedSignerGrantStatus, type DelegatedSignerSession, type DelegatedSignerStatus, type DelegatedSignersApi, ErrorCode, type ExecuteIntentKind, type ExecuteIntentResult, type FinalizeGrantResponse, type FinalizeIntentResult, type FinalizeSessionResponse, type FundHistoryItem, type GrantsApi, type ManifestError, type ManifestResult, NextAction, type PatchProfileInput, type PayInput, type PayResult, type Payer, type PayerOptions, type PaymentMethod, type PaymentReceipt, type PaymentRow, PaymentState, type PaymentStatusValue, type PaymentsApi, type PoliciesApi, type PolicyStatus, type PolicyTarget, type PrepareCreateGrantInput, type PrepareCreateSessionInput, type PreparedConsentGrant, type PreparedGrantTxKind, type PreparedIntent, type PreparedRevokeTxKind, type PreparedSessionTxKind, type ProfileStatus, type ProfilesApi, type ReceiptsApi, type RegistryApi, type RegistryService, type RevokeDelegatedSignerResponse, type ServiceRail, type ServicesApi, type SessionsApi, type SettlementRow, type SettlementsApi, type SpendAccount, type SpendAccountStatus, type SpendAccountsApi, type SponsoredTx, type SubmittedGrantCreate, type TransactionSigner, type TrustSignal, createBuyer, createBuyerControlPlane, createMemoryLedger, createPayer, createReader, dashboardManifestToAgentManifest, manifestToSession, parseAgentManifest, personalMessageSigner, verifyPreparedPayment };
1818
+ interface OAuthDelegateBinding {
1819
+ clientId: string;
1820
+ redirectUri: string;
1821
+ resource: string;
1822
+ scope: string;
1823
+ codeChallenge: string;
1824
+ delegateAddress: string | null;
1825
+ }
1826
+ interface OAuthDelegateProof {
1827
+ signature: string;
1828
+ expiresAtMs: number;
1829
+ ownerAddress: string;
1830
+ }
1831
+ declare const OAUTH_DELEGATE_PROOF_TTL_MS: number;
1832
+ /** Exact text values are signed; the Sui address alone is normalized. */
1833
+ declare function encodeOAuthDelegateProof(binding: OAuthDelegateBinding, expiresAtMs: number, ownerAddress: string): Uint8Array;
1834
+ declare function verifyOAuthDelegateProof(binding: OAuthDelegateBinding, proof: unknown, nowMs?: number, expectedOwner?: string): Promise<boolean>;
1835
+
1836
+ export { type AccountApi, type AccountsApi, type AgentConnectionManifest, type AgentGrantBinding, type AgentProfile, type AgentSessionBinding, type AgentsApi, type AssetScopeInput, type BuyerAccount, type BuyerClient, type BuyerClientError, type BuyerClientOptions, type BuyerConnection, type BuyerPolicy, type BuyerResult, type CatalogApi, type CatalogService, type CreateAndActivateResult, type CreateDelegatedSignerInput, type CreateDelegatedSignerResponse, type CreatePolicyInput, type CreatePolicyResponse, type CreateProfileInput, type CreateProfileResponse, type DashboardBridgeResolvers, type DashboardConnectionManifest, type DelegatedSigner, type DelegatedSignerGrant, type DelegatedSignerGrantStatus, type DelegatedSignerSession, type DelegatedSignerStatus, type DelegatedSignersApi, ErrorCode, type ExecuteIntentKind, type ExecuteIntentResult, type FinalizeGrantResponse, type FinalizeIntentResult, type FinalizeSessionResponse, type FundHistoryItem, type GrantsApi, type ManifestError, type ManifestResult, NextAction, OAUTH_DELEGATE_PROOF_TTL_MS, type OAuthDelegateBinding, type OAuthDelegateProof, type PatchProfileInput, type PayInput, type PayResult, type Payer, type PayerOptions, type PaymentMethod, type PaymentReceipt, type PaymentRow, PaymentState, type PaymentStatusValue, type PaymentsApi, type PoliciesApi, type PolicyStatus, type PolicyTarget, type PrepareCreateGrantInput, type PrepareCreateSessionInput, type PreparedConsentGrant, type PreparedGrantTxKind, type PreparedIntent, type PreparedRevokeTxKind, type PreparedSessionTxKind, type ProfileStatus, type ProfilesApi, type ReceiptsApi, type RegistryApi, type RegistryService, type RevokeDelegatedSignerResponse, type ServiceRail, type ServicesApi, type SessionsApi, type SettlementRow, type SettlementsApi, type SpendAccount, type SpendAccountStatus, type SpendAccountsApi, type SponsoredTx, type SubmittedGrantCreate, type TransactionSigner, type TrustSignal, createBuyer, createBuyerControlPlane, createMemoryLedger, createPayer, createReader, dashboardManifestToAgentManifest, encodeOAuthDelegateProof, manifestToSession, parseAgentManifest, personalMessageSigner, verifyOAuthDelegateProof, verifyPreparedPayment };
package/dist/index.js CHANGED
@@ -10618,8 +10618,44 @@ async function createPayer(options) {
10618
10618
  value: { address, deployment, grant: binding, session, pay, verifySettlement }
10619
10619
  };
10620
10620
  }
10621
+
10622
+ // ../sdk/dist/oauth/delegate-proof.js
10623
+ import { normalizeSuiAddress as normalizeSuiAddress12 } from "@mysten/sui/utils";
10624
+ import { verifyPersonalMessageSignature as verifyPersonalMessageSignature3 } from "@mysten/sui/verify";
10625
+ var OAUTH_DELEGATE_PROOF_TTL_MS = 15 * 6e4;
10626
+ function encodeOAuthDelegateProof(binding, expiresAtMs, ownerAddress) {
10627
+ if (!binding.delegateAddress || !Number.isSafeInteger(expiresAtMs) || expiresAtMs <= 0) {
10628
+ throw new Error("Invalid delegate proof binding.");
10629
+ }
10630
+ return new TextEncoder().encode(JSON.stringify([
10631
+ "suipay:oauth-delegate:v1",
10632
+ binding.clientId,
10633
+ binding.redirectUri,
10634
+ binding.resource,
10635
+ binding.scope,
10636
+ binding.codeChallenge,
10637
+ normalizeSuiAddress12(binding.delegateAddress),
10638
+ normalizeSuiAddress12(ownerAddress),
10639
+ expiresAtMs
10640
+ ]));
10641
+ }
10642
+ async function verifyOAuthDelegateProof(binding, proof, nowMs = Date.now(), expectedOwner) {
10643
+ try {
10644
+ const p = proof;
10645
+ const message = encodeOAuthDelegateProof(binding, p.expiresAtMs, p.ownerAddress);
10646
+ if (typeof p.signature !== "string" || p.signature.length > 8192 || p.expiresAtMs <= nowMs || p.expiresAtMs > nowMs + OAUTH_DELEGATE_PROOF_TTL_MS)
10647
+ return false;
10648
+ if (expectedOwner && normalizeSuiAddress12(p.ownerAddress) !== normalizeSuiAddress12(expectedOwner))
10649
+ return false;
10650
+ const publicKey = await verifyPersonalMessageSignature3(message, p.signature);
10651
+ return publicKey.toSuiAddress() === normalizeSuiAddress12(binding.delegateAddress);
10652
+ } catch {
10653
+ return false;
10654
+ }
10655
+ }
10621
10656
  export {
10622
10657
  NativeTransferError,
10658
+ OAUTH_DELEGATE_PROOF_TTL_MS,
10623
10659
  SuiPayError,
10624
10660
  buildMcpPaymentPayload,
10625
10661
  buildNativeTransferBytes,
@@ -10630,10 +10666,12 @@ export {
10630
10666
  createPayer,
10631
10667
  createReader,
10632
10668
  dashboardManifestToAgentManifest,
10669
+ encodeOAuthDelegateProof,
10633
10670
  inspectNativeTransfer,
10634
10671
  manifestToSession,
10635
10672
  parseAgentManifest,
10636
10673
  personalMessageSigner,
10637
10674
  toErrorFields,
10675
+ verifyOAuthDelegateProof,
10638
10676
  verifyPreparedPayment
10639
10677
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten-incubation/suipay-buyer",
3
- "version": "0.3.0-dev.21",
3
+ "version": "0.3.0-dev.22",
4
4
  "type": "module",
5
5
  "description": "SuiPay buyer SDK — delegated spend-account pay plus a typed /v1 control-plane client.",
6
6
  "license": "MIT",