@siglume/direct-request-payment 0.4.14 → 0.4.15

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.cts CHANGED
@@ -6,7 +6,7 @@ declare const DIRECT_REQUEST_PAYMENT_RECEIPT_KIND = "sdrp_direct_payment";
6
6
  declare const DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND = "sdrp_direct_payment_allowance";
7
7
  declare const DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE = "sdrp_direct_payment_requirement";
8
8
  declare const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
9
- declare const DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.13";
9
+ declare const DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.15";
10
10
  declare const DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS = "settled";
11
11
  declare const DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS = "pending_settlement";
12
12
  declare const DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY = "per_payment_onchain";
@@ -15,6 +15,8 @@ type DirectRequestPaymentCurrency = "JPY" | "USD";
15
15
  type DirectRequestPaymentToken = "JPYC" | "USDC";
16
16
  type DirectRequestPaymentMeteredPlanType = "micro" | "nano";
17
17
  type DirectRequestPaymentMinorAmount = string;
18
+ type DirectRequestPaymentRawWebhookBody = Uint8Array | ArrayBuffer | string;
19
+ type DirectRequestPaymentWebhookSignatureBody = DirectRequestPaymentRawWebhookBody | Record<string, unknown>;
18
20
  interface DirectRequestPaymentBuyerMeteredQuery {
19
21
  plan_type?: DirectRequestPaymentMeteredPlanType | string;
20
22
  token_symbol?: DirectRequestPaymentToken | string;
@@ -49,9 +51,12 @@ interface DirectRequestPaymentBuyerUsageEvent {
49
51
  operation_key?: string | null;
50
52
  currency: string;
51
53
  token_symbol: string;
54
+ provider_gross_amount_minor: DirectRequestPaymentMinorAmount;
52
55
  provider_usage_amount_minor: DirectRequestPaymentMinorAmount;
53
56
  protocol_fee_minor: DirectRequestPaymentMinorAmount;
54
57
  gross_buyer_debit_minor: DirectRequestPaymentMinorAmount;
58
+ buyer_debit_minor?: DirectRequestPaymentMinorAmount;
59
+ rounding_delta_minor?: DirectRequestPaymentMinorAmount;
55
60
  status: string;
56
61
  period_start?: string | null;
57
62
  period_end?: string | null;
@@ -70,10 +75,13 @@ interface DirectRequestPaymentProviderUsageEvent {
70
75
  operation_key?: string | null;
71
76
  currency: string;
72
77
  token_symbol: string;
78
+ provider_gross_amount_minor: DirectRequestPaymentMinorAmount;
73
79
  provider_usage_amount_minor: DirectRequestPaymentMinorAmount;
74
80
  provider_receivable_minor: DirectRequestPaymentMinorAmount;
75
81
  protocol_fee_minor: DirectRequestPaymentMinorAmount;
76
82
  gross_buyer_debit_minor: DirectRequestPaymentMinorAmount;
83
+ buyer_debit_minor?: DirectRequestPaymentMinorAmount;
84
+ rounding_delta_minor?: DirectRequestPaymentMinorAmount;
77
85
  status: string;
78
86
  period_start?: string | null;
79
87
  period_end?: string | null;
@@ -108,6 +116,7 @@ interface DirectRequestPaymentSettlementBatch {
108
116
  gross_buyer_debit_minor?: DirectRequestPaymentMinorAmount;
109
117
  rounding_delta_minor?: DirectRequestPaymentMinorAmount;
110
118
  buyer_debit_minor?: DirectRequestPaymentMinorAmount;
119
+ provider_gross_amount_minor?: DirectRequestPaymentMinorAmount;
111
120
  provider_usage_amount_minor?: DirectRequestPaymentMinorAmount;
112
121
  provider_receivable_minor?: DirectRequestPaymentMinorAmount;
113
122
  settled_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
@@ -605,19 +614,19 @@ declare function buildPreparedTransactionExecutionPayload(requirement: DirectPay
605
614
  await_finality?: boolean;
606
615
  metadata?: Record<string, unknown>;
607
616
  }): Web3PreparedTransactionExecutePayload;
608
- declare function computeWebhookSignature(signing_secret: string, body: Uint8Array | ArrayBuffer | string | Record<string, unknown>, options: {
617
+ declare function computeWebhookSignature(signing_secret: string, body: DirectRequestPaymentWebhookSignatureBody, options: {
609
618
  timestamp: number;
610
619
  }): Promise<string>;
611
- declare function buildWebhookSignatureHeader(signing_secret: string, body: Uint8Array | ArrayBuffer | string | Record<string, unknown>, options?: {
620
+ declare function buildWebhookSignatureHeader(signing_secret: string, body: DirectRequestPaymentWebhookSignatureBody, options?: {
612
621
  timestamp?: number;
613
622
  }): Promise<string>;
614
- declare function verifyWebhookSignature(signing_secret: string, body: Uint8Array | ArrayBuffer | string | Record<string, unknown>, signature_header: string, options?: {
623
+ declare function verifyWebhookSignature(signing_secret: string, body: DirectRequestPaymentRawWebhookBody, signature_header: string, options?: {
615
624
  tolerance_seconds?: number;
616
625
  now?: number;
617
626
  }): Promise<WebhookSignatureVerification>;
618
627
  declare function parseDirectRequestPaymentWebhookEvent(payload: unknown): DirectRequestPaymentWebhookEvent;
619
628
  declare function classifyDirectPaymentConfirmation(event: DirectRequestPaymentWebhookEvent): DirectPaymentConfirmationClassification;
620
- declare function verifyDirectRequestPaymentWebhook(signing_secret: string, body: Uint8Array | ArrayBuffer | string | Record<string, unknown>, signature_header: string, options?: {
629
+ declare function verifyDirectRequestPaymentWebhook(signing_secret: string, body: DirectRequestPaymentRawWebhookBody, signature_header: string, options?: {
621
630
  tolerance_seconds?: number;
622
631
  now?: number;
623
632
  }): Promise<{
@@ -629,4 +638,4 @@ declare const verifyExternal402Challenge: typeof verifyDirectRequestPaymentChall
629
638
  declare const createExternal402RecurringChallenge: typeof createDirectRequestPaymentRecurringChallenge;
630
639
  declare const verifyExternal402RecurringChallenge: typeof verifyDirectRequestPaymentRecurringChallenge;
631
640
 
632
- export { DEFAULT_SIGLUME_API_BASE, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS, DIRECT_REQUEST_PAYMENT_METERED_FINALITY, DIRECT_REQUEST_PAYMENT_MODE, DIRECT_REQUEST_PAYMENT_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_RECURRING_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE, DIRECT_REQUEST_PAYMENT_SDK_VERSION, DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY, DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS, type DirectPaymentConfirmationClassification, type DirectPaymentConfirmationKind, type DirectPaymentConfirmationUnknownReason, type DirectPaymentMeteredBatchSettledClassification, type DirectPaymentMeteredUsageAcceptedClassification, type DirectPaymentRequirement, type DirectPaymentRequirementCreateInput, type DirectPaymentStandardSettledClassification, type DirectPaymentUnknownClassification, type DirectPaymentVerifyInput, type DirectRequestPaymentBillingPlan, type DirectRequestPaymentBuyerMeteredQuery, type DirectRequestPaymentBuyerMeteredSummary, type DirectRequestPaymentBuyerUsageEvent, type DirectRequestPaymentChallenge, type DirectRequestPaymentChallengeInput, type DirectRequestPaymentCheckoutSetupInput, type DirectRequestPaymentCheckoutSetupResult, DirectRequestPaymentClient, type DirectRequestPaymentClientOptions, type DirectRequestPaymentCurrency, type DirectRequestPaymentListResponse, type DirectRequestPaymentMerchantAccount, type DirectRequestPaymentMerchantBillingMandateInput, DirectRequestPaymentMerchantClient, type DirectRequestPaymentMerchantResponse, type DirectRequestPaymentMerchantSetupInput, type DirectRequestPaymentMeteredListQuery, type DirectRequestPaymentMeteredPlanType, type DirectRequestPaymentMinorAmount, type DirectRequestPaymentProviderMeteredListQuery, type DirectRequestPaymentProviderMeteredQuery, type DirectRequestPaymentProviderMeteredSummary, type DirectRequestPaymentProviderUsageEvent, type DirectRequestPaymentRecurringCadence, type DirectRequestPaymentRecurringChallenge, type DirectRequestPaymentRecurringChallengeInput, type DirectRequestPaymentSettlementBatch, type DirectRequestPaymentToken, type DirectRequestPaymentWebhookEvent, type DirectRequestPaymentWebhookSubscription, type DirectRequestPaymentWebhookSubscriptionInput, HostedCheckoutNotAvailableError, type HostedCheckoutSession, type HostedCheckoutSessionCreateInput, type HostedCheckoutSessionCreateResult, type ParsedDirectRequestPaymentChallenge, SiglumeApiError, SiglumeDirectRequestPaymentError, type SiglumeEnvelopeMeta, SiglumeWebhookPayloadError, SiglumeWebhookSignatureError, type Web3PreparedTransactionExecutePayload, type Web3PreparedTransactionExecuteResult, type Web3TransactionRequest, type WebhookSignatureVerification, buildAllowanceExecutionPayload, buildPaymentExecutionPayload, buildPreparedTransactionExecutionPayload, buildWebhookSignatureHeader, classifyDirectPaymentConfirmation, computeWebhookSignature, createDirectRequestPaymentChallenge, createDirectRequestPaymentChallengeSignature, createDirectRequestPaymentRecurringChallenge, createDirectRequestPaymentRecurringChallengeSignature, createExternal402Challenge, createExternal402RecurringChallenge, directRequestPaymentChallengeHash, directRequestPaymentRequestHash, directRequestPaymentRequestHashV2, parseDirectRequestPaymentChallenge, parseDirectRequestPaymentWebhookEvent, verifyDirectRequestPaymentChallenge, verifyDirectRequestPaymentRecurringChallenge, verifyDirectRequestPaymentWebhook, verifyExternal402Challenge, verifyExternal402RecurringChallenge, verifyWebhookSignature };
641
+ export { DEFAULT_SIGLUME_API_BASE, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS, DIRECT_REQUEST_PAYMENT_METERED_FINALITY, DIRECT_REQUEST_PAYMENT_MODE, DIRECT_REQUEST_PAYMENT_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_RECURRING_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE, DIRECT_REQUEST_PAYMENT_SDK_VERSION, DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY, DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS, type DirectPaymentConfirmationClassification, type DirectPaymentConfirmationKind, type DirectPaymentConfirmationUnknownReason, type DirectPaymentMeteredBatchSettledClassification, type DirectPaymentMeteredUsageAcceptedClassification, type DirectPaymentRequirement, type DirectPaymentRequirementCreateInput, type DirectPaymentStandardSettledClassification, type DirectPaymentUnknownClassification, type DirectPaymentVerifyInput, type DirectRequestPaymentBillingPlan, type DirectRequestPaymentBuyerMeteredQuery, type DirectRequestPaymentBuyerMeteredSummary, type DirectRequestPaymentBuyerUsageEvent, type DirectRequestPaymentChallenge, type DirectRequestPaymentChallengeInput, type DirectRequestPaymentCheckoutSetupInput, type DirectRequestPaymentCheckoutSetupResult, DirectRequestPaymentClient, type DirectRequestPaymentClientOptions, type DirectRequestPaymentCurrency, type DirectRequestPaymentListResponse, type DirectRequestPaymentMerchantAccount, type DirectRequestPaymentMerchantBillingMandateInput, DirectRequestPaymentMerchantClient, type DirectRequestPaymentMerchantResponse, type DirectRequestPaymentMerchantSetupInput, type DirectRequestPaymentMeteredListQuery, type DirectRequestPaymentMeteredPlanType, type DirectRequestPaymentMinorAmount, type DirectRequestPaymentProviderMeteredListQuery, type DirectRequestPaymentProviderMeteredQuery, type DirectRequestPaymentProviderMeteredSummary, type DirectRequestPaymentProviderUsageEvent, type DirectRequestPaymentRawWebhookBody, type DirectRequestPaymentRecurringCadence, type DirectRequestPaymentRecurringChallenge, type DirectRequestPaymentRecurringChallengeInput, type DirectRequestPaymentSettlementBatch, type DirectRequestPaymentToken, type DirectRequestPaymentWebhookEvent, type DirectRequestPaymentWebhookSignatureBody, type DirectRequestPaymentWebhookSubscription, type DirectRequestPaymentWebhookSubscriptionInput, HostedCheckoutNotAvailableError, type HostedCheckoutSession, type HostedCheckoutSessionCreateInput, type HostedCheckoutSessionCreateResult, type ParsedDirectRequestPaymentChallenge, SiglumeApiError, SiglumeDirectRequestPaymentError, type SiglumeEnvelopeMeta, SiglumeWebhookPayloadError, SiglumeWebhookSignatureError, type Web3PreparedTransactionExecutePayload, type Web3PreparedTransactionExecuteResult, type Web3TransactionRequest, type WebhookSignatureVerification, buildAllowanceExecutionPayload, buildPaymentExecutionPayload, buildPreparedTransactionExecutionPayload, buildWebhookSignatureHeader, classifyDirectPaymentConfirmation, computeWebhookSignature, createDirectRequestPaymentChallenge, createDirectRequestPaymentChallengeSignature, createDirectRequestPaymentRecurringChallenge, createDirectRequestPaymentRecurringChallengeSignature, createExternal402Challenge, createExternal402RecurringChallenge, directRequestPaymentChallengeHash, directRequestPaymentRequestHash, directRequestPaymentRequestHashV2, parseDirectRequestPaymentChallenge, parseDirectRequestPaymentWebhookEvent, verifyDirectRequestPaymentChallenge, verifyDirectRequestPaymentRecurringChallenge, verifyDirectRequestPaymentWebhook, verifyExternal402Challenge, verifyExternal402RecurringChallenge, verifyWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ declare const DIRECT_REQUEST_PAYMENT_RECEIPT_KIND = "sdrp_direct_payment";
6
6
  declare const DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND = "sdrp_direct_payment_allowance";
7
7
  declare const DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE = "sdrp_direct_payment_requirement";
8
8
  declare const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
9
- declare const DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.13";
9
+ declare const DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.15";
10
10
  declare const DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS = "settled";
11
11
  declare const DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS = "pending_settlement";
12
12
  declare const DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY = "per_payment_onchain";
@@ -15,6 +15,8 @@ type DirectRequestPaymentCurrency = "JPY" | "USD";
15
15
  type DirectRequestPaymentToken = "JPYC" | "USDC";
16
16
  type DirectRequestPaymentMeteredPlanType = "micro" | "nano";
17
17
  type DirectRequestPaymentMinorAmount = string;
18
+ type DirectRequestPaymentRawWebhookBody = Uint8Array | ArrayBuffer | string;
19
+ type DirectRequestPaymentWebhookSignatureBody = DirectRequestPaymentRawWebhookBody | Record<string, unknown>;
18
20
  interface DirectRequestPaymentBuyerMeteredQuery {
19
21
  plan_type?: DirectRequestPaymentMeteredPlanType | string;
20
22
  token_symbol?: DirectRequestPaymentToken | string;
@@ -49,9 +51,12 @@ interface DirectRequestPaymentBuyerUsageEvent {
49
51
  operation_key?: string | null;
50
52
  currency: string;
51
53
  token_symbol: string;
54
+ provider_gross_amount_minor: DirectRequestPaymentMinorAmount;
52
55
  provider_usage_amount_minor: DirectRequestPaymentMinorAmount;
53
56
  protocol_fee_minor: DirectRequestPaymentMinorAmount;
54
57
  gross_buyer_debit_minor: DirectRequestPaymentMinorAmount;
58
+ buyer_debit_minor?: DirectRequestPaymentMinorAmount;
59
+ rounding_delta_minor?: DirectRequestPaymentMinorAmount;
55
60
  status: string;
56
61
  period_start?: string | null;
57
62
  period_end?: string | null;
@@ -70,10 +75,13 @@ interface DirectRequestPaymentProviderUsageEvent {
70
75
  operation_key?: string | null;
71
76
  currency: string;
72
77
  token_symbol: string;
78
+ provider_gross_amount_minor: DirectRequestPaymentMinorAmount;
73
79
  provider_usage_amount_minor: DirectRequestPaymentMinorAmount;
74
80
  provider_receivable_minor: DirectRequestPaymentMinorAmount;
75
81
  protocol_fee_minor: DirectRequestPaymentMinorAmount;
76
82
  gross_buyer_debit_minor: DirectRequestPaymentMinorAmount;
83
+ buyer_debit_minor?: DirectRequestPaymentMinorAmount;
84
+ rounding_delta_minor?: DirectRequestPaymentMinorAmount;
77
85
  status: string;
78
86
  period_start?: string | null;
79
87
  period_end?: string | null;
@@ -108,6 +116,7 @@ interface DirectRequestPaymentSettlementBatch {
108
116
  gross_buyer_debit_minor?: DirectRequestPaymentMinorAmount;
109
117
  rounding_delta_minor?: DirectRequestPaymentMinorAmount;
110
118
  buyer_debit_minor?: DirectRequestPaymentMinorAmount;
119
+ provider_gross_amount_minor?: DirectRequestPaymentMinorAmount;
111
120
  provider_usage_amount_minor?: DirectRequestPaymentMinorAmount;
112
121
  provider_receivable_minor?: DirectRequestPaymentMinorAmount;
113
122
  settled_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
@@ -605,19 +614,19 @@ declare function buildPreparedTransactionExecutionPayload(requirement: DirectPay
605
614
  await_finality?: boolean;
606
615
  metadata?: Record<string, unknown>;
607
616
  }): Web3PreparedTransactionExecutePayload;
608
- declare function computeWebhookSignature(signing_secret: string, body: Uint8Array | ArrayBuffer | string | Record<string, unknown>, options: {
617
+ declare function computeWebhookSignature(signing_secret: string, body: DirectRequestPaymentWebhookSignatureBody, options: {
609
618
  timestamp: number;
610
619
  }): Promise<string>;
611
- declare function buildWebhookSignatureHeader(signing_secret: string, body: Uint8Array | ArrayBuffer | string | Record<string, unknown>, options?: {
620
+ declare function buildWebhookSignatureHeader(signing_secret: string, body: DirectRequestPaymentWebhookSignatureBody, options?: {
612
621
  timestamp?: number;
613
622
  }): Promise<string>;
614
- declare function verifyWebhookSignature(signing_secret: string, body: Uint8Array | ArrayBuffer | string | Record<string, unknown>, signature_header: string, options?: {
623
+ declare function verifyWebhookSignature(signing_secret: string, body: DirectRequestPaymentRawWebhookBody, signature_header: string, options?: {
615
624
  tolerance_seconds?: number;
616
625
  now?: number;
617
626
  }): Promise<WebhookSignatureVerification>;
618
627
  declare function parseDirectRequestPaymentWebhookEvent(payload: unknown): DirectRequestPaymentWebhookEvent;
619
628
  declare function classifyDirectPaymentConfirmation(event: DirectRequestPaymentWebhookEvent): DirectPaymentConfirmationClassification;
620
- declare function verifyDirectRequestPaymentWebhook(signing_secret: string, body: Uint8Array | ArrayBuffer | string | Record<string, unknown>, signature_header: string, options?: {
629
+ declare function verifyDirectRequestPaymentWebhook(signing_secret: string, body: DirectRequestPaymentRawWebhookBody, signature_header: string, options?: {
621
630
  tolerance_seconds?: number;
622
631
  now?: number;
623
632
  }): Promise<{
@@ -629,4 +638,4 @@ declare const verifyExternal402Challenge: typeof verifyDirectRequestPaymentChall
629
638
  declare const createExternal402RecurringChallenge: typeof createDirectRequestPaymentRecurringChallenge;
630
639
  declare const verifyExternal402RecurringChallenge: typeof verifyDirectRequestPaymentRecurringChallenge;
631
640
 
632
- export { DEFAULT_SIGLUME_API_BASE, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS, DIRECT_REQUEST_PAYMENT_METERED_FINALITY, DIRECT_REQUEST_PAYMENT_MODE, DIRECT_REQUEST_PAYMENT_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_RECURRING_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE, DIRECT_REQUEST_PAYMENT_SDK_VERSION, DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY, DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS, type DirectPaymentConfirmationClassification, type DirectPaymentConfirmationKind, type DirectPaymentConfirmationUnknownReason, type DirectPaymentMeteredBatchSettledClassification, type DirectPaymentMeteredUsageAcceptedClassification, type DirectPaymentRequirement, type DirectPaymentRequirementCreateInput, type DirectPaymentStandardSettledClassification, type DirectPaymentUnknownClassification, type DirectPaymentVerifyInput, type DirectRequestPaymentBillingPlan, type DirectRequestPaymentBuyerMeteredQuery, type DirectRequestPaymentBuyerMeteredSummary, type DirectRequestPaymentBuyerUsageEvent, type DirectRequestPaymentChallenge, type DirectRequestPaymentChallengeInput, type DirectRequestPaymentCheckoutSetupInput, type DirectRequestPaymentCheckoutSetupResult, DirectRequestPaymentClient, type DirectRequestPaymentClientOptions, type DirectRequestPaymentCurrency, type DirectRequestPaymentListResponse, type DirectRequestPaymentMerchantAccount, type DirectRequestPaymentMerchantBillingMandateInput, DirectRequestPaymentMerchantClient, type DirectRequestPaymentMerchantResponse, type DirectRequestPaymentMerchantSetupInput, type DirectRequestPaymentMeteredListQuery, type DirectRequestPaymentMeteredPlanType, type DirectRequestPaymentMinorAmount, type DirectRequestPaymentProviderMeteredListQuery, type DirectRequestPaymentProviderMeteredQuery, type DirectRequestPaymentProviderMeteredSummary, type DirectRequestPaymentProviderUsageEvent, type DirectRequestPaymentRecurringCadence, type DirectRequestPaymentRecurringChallenge, type DirectRequestPaymentRecurringChallengeInput, type DirectRequestPaymentSettlementBatch, type DirectRequestPaymentToken, type DirectRequestPaymentWebhookEvent, type DirectRequestPaymentWebhookSubscription, type DirectRequestPaymentWebhookSubscriptionInput, HostedCheckoutNotAvailableError, type HostedCheckoutSession, type HostedCheckoutSessionCreateInput, type HostedCheckoutSessionCreateResult, type ParsedDirectRequestPaymentChallenge, SiglumeApiError, SiglumeDirectRequestPaymentError, type SiglumeEnvelopeMeta, SiglumeWebhookPayloadError, SiglumeWebhookSignatureError, type Web3PreparedTransactionExecutePayload, type Web3PreparedTransactionExecuteResult, type Web3TransactionRequest, type WebhookSignatureVerification, buildAllowanceExecutionPayload, buildPaymentExecutionPayload, buildPreparedTransactionExecutionPayload, buildWebhookSignatureHeader, classifyDirectPaymentConfirmation, computeWebhookSignature, createDirectRequestPaymentChallenge, createDirectRequestPaymentChallengeSignature, createDirectRequestPaymentRecurringChallenge, createDirectRequestPaymentRecurringChallengeSignature, createExternal402Challenge, createExternal402RecurringChallenge, directRequestPaymentChallengeHash, directRequestPaymentRequestHash, directRequestPaymentRequestHashV2, parseDirectRequestPaymentChallenge, parseDirectRequestPaymentWebhookEvent, verifyDirectRequestPaymentChallenge, verifyDirectRequestPaymentRecurringChallenge, verifyDirectRequestPaymentWebhook, verifyExternal402Challenge, verifyExternal402RecurringChallenge, verifyWebhookSignature };
641
+ export { DEFAULT_SIGLUME_API_BASE, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS, DIRECT_REQUEST_PAYMENT_METERED_FINALITY, DIRECT_REQUEST_PAYMENT_MODE, DIRECT_REQUEST_PAYMENT_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_RECURRING_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE, DIRECT_REQUEST_PAYMENT_SDK_VERSION, DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY, DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS, type DirectPaymentConfirmationClassification, type DirectPaymentConfirmationKind, type DirectPaymentConfirmationUnknownReason, type DirectPaymentMeteredBatchSettledClassification, type DirectPaymentMeteredUsageAcceptedClassification, type DirectPaymentRequirement, type DirectPaymentRequirementCreateInput, type DirectPaymentStandardSettledClassification, type DirectPaymentUnknownClassification, type DirectPaymentVerifyInput, type DirectRequestPaymentBillingPlan, type DirectRequestPaymentBuyerMeteredQuery, type DirectRequestPaymentBuyerMeteredSummary, type DirectRequestPaymentBuyerUsageEvent, type DirectRequestPaymentChallenge, type DirectRequestPaymentChallengeInput, type DirectRequestPaymentCheckoutSetupInput, type DirectRequestPaymentCheckoutSetupResult, DirectRequestPaymentClient, type DirectRequestPaymentClientOptions, type DirectRequestPaymentCurrency, type DirectRequestPaymentListResponse, type DirectRequestPaymentMerchantAccount, type DirectRequestPaymentMerchantBillingMandateInput, DirectRequestPaymentMerchantClient, type DirectRequestPaymentMerchantResponse, type DirectRequestPaymentMerchantSetupInput, type DirectRequestPaymentMeteredListQuery, type DirectRequestPaymentMeteredPlanType, type DirectRequestPaymentMinorAmount, type DirectRequestPaymentProviderMeteredListQuery, type DirectRequestPaymentProviderMeteredQuery, type DirectRequestPaymentProviderMeteredSummary, type DirectRequestPaymentProviderUsageEvent, type DirectRequestPaymentRawWebhookBody, type DirectRequestPaymentRecurringCadence, type DirectRequestPaymentRecurringChallenge, type DirectRequestPaymentRecurringChallengeInput, type DirectRequestPaymentSettlementBatch, type DirectRequestPaymentToken, type DirectRequestPaymentWebhookEvent, type DirectRequestPaymentWebhookSignatureBody, type DirectRequestPaymentWebhookSubscription, type DirectRequestPaymentWebhookSubscriptionInput, HostedCheckoutNotAvailableError, type HostedCheckoutSession, type HostedCheckoutSessionCreateInput, type HostedCheckoutSessionCreateResult, type ParsedDirectRequestPaymentChallenge, SiglumeApiError, SiglumeDirectRequestPaymentError, type SiglumeEnvelopeMeta, SiglumeWebhookPayloadError, SiglumeWebhookSignatureError, type Web3PreparedTransactionExecutePayload, type Web3PreparedTransactionExecuteResult, type Web3TransactionRequest, type WebhookSignatureVerification, buildAllowanceExecutionPayload, buildPaymentExecutionPayload, buildPreparedTransactionExecutionPayload, buildWebhookSignatureHeader, classifyDirectPaymentConfirmation, computeWebhookSignature, createDirectRequestPaymentChallenge, createDirectRequestPaymentChallengeSignature, createDirectRequestPaymentRecurringChallenge, createDirectRequestPaymentRecurringChallengeSignature, createExternal402Challenge, createExternal402RecurringChallenge, directRequestPaymentChallengeHash, directRequestPaymentRequestHash, directRequestPaymentRequestHashV2, parseDirectRequestPaymentChallenge, parseDirectRequestPaymentWebhookEvent, verifyDirectRequestPaymentChallenge, verifyDirectRequestPaymentRecurringChallenge, verifyDirectRequestPaymentWebhook, verifyExternal402Challenge, verifyExternal402RecurringChallenge, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var DIRECT_REQUEST_PAYMENT_RECEIPT_KIND = "sdrp_direct_payment";
7
7
  var DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND = "sdrp_direct_payment_allowance";
8
8
  var DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE = "sdrp_direct_payment_requirement";
9
9
  var DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
10
- var DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.13";
10
+ var DIRECT_REQUEST_PAYMENT_SDK_VERSION = "0.4.15";
11
11
  var DIRECT_REQUEST_PAYMENT_STANDARD_SETTLED_STATUS = "settled";
12
12
  var DIRECT_REQUEST_PAYMENT_METERED_ACCEPTED_STATUS = "pending_settlement";
13
13
  var DIRECT_REQUEST_PAYMENT_STANDARD_FINALITY = "per_payment_onchain";
@@ -580,7 +580,8 @@ async function verifyWebhookSignature(signing_secret, body, signature_header, op
580
580
  if (Math.abs(nowSeconds - timestamp) > toleranceSeconds) {
581
581
  throw new SiglumeWebhookSignatureError("Webhook timestamp is outside the allowed tolerance window.");
582
582
  }
583
- const expected = await computeWebhookSignature(signing_secret, body, { timestamp });
583
+ const rawBody = rawWebhookBodyBytes(body);
584
+ const expected = await computeWebhookSignature(signing_secret, rawBody, { timestamp });
584
585
  if (!await timingSafeEqualHex(expected, signature)) {
585
586
  throw new SiglumeWebhookSignatureError("Webhook signature did not match.");
586
587
  }
@@ -721,7 +722,7 @@ function classifyDirectPaymentConfirmation(event) {
721
722
  }
722
723
  async function verifyDirectRequestPaymentWebhook(signing_secret, body, signature_header, options = {}) {
723
724
  const verification = await verifyWebhookSignature(signing_secret, body, signature_header, options);
724
- const text = new TextDecoder().decode(bodyBytes(body));
725
+ const text = new TextDecoder().decode(rawWebhookBodyBytes(body));
725
726
  let parsed;
726
727
  try {
727
728
  parsed = JSON.parse(text);
@@ -968,6 +969,20 @@ function bodyBytes(body) {
968
969
  }
969
970
  throw new SiglumeWebhookPayloadError("Webhook body must be raw bytes, a string, or a JSON object.");
970
971
  }
972
+ function rawWebhookBodyBytes(body) {
973
+ if (body instanceof Uint8Array) {
974
+ return body;
975
+ }
976
+ if (body instanceof ArrayBuffer) {
977
+ return new Uint8Array(body);
978
+ }
979
+ if (typeof body === "string") {
980
+ return new TextEncoder().encode(body);
981
+ }
982
+ throw new SiglumeWebhookPayloadError(
983
+ "Webhook verification requires the exact raw request body bytes or raw body string; JSON objects are only accepted by buildWebhookSignatureHeader for tests."
984
+ );
985
+ }
971
986
  function parseSignatureHeader(signatureHeader) {
972
987
  let timestamp = null;
973
988
  let signature = null;