@siglume/direct-request-payment 0.4.3 → 0.4.4

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
@@ -6,8 +6,124 @@ 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.4";
9
10
  type DirectRequestPaymentCurrency = "JPY" | "USD";
10
11
  type DirectRequestPaymentToken = "JPYC" | "USDC";
12
+ type DirectRequestPaymentMeteredPlanType = "micro" | "nano";
13
+ type DirectRequestPaymentMinorAmount = string | number;
14
+ interface DirectRequestPaymentBuyerMeteredQuery {
15
+ plan_type?: DirectRequestPaymentMeteredPlanType | string;
16
+ token_symbol?: DirectRequestPaymentToken | string;
17
+ }
18
+ interface DirectRequestPaymentMeteredListQuery extends DirectRequestPaymentBuyerMeteredQuery {
19
+ status?: string;
20
+ limit?: number;
21
+ }
22
+ interface DirectRequestPaymentProviderMeteredQuery extends DirectRequestPaymentBuyerMeteredQuery {
23
+ listing_id?: string;
24
+ capability_key?: string;
25
+ }
26
+ interface DirectRequestPaymentProviderMeteredListQuery extends DirectRequestPaymentProviderMeteredQuery {
27
+ status?: string;
28
+ limit?: number;
29
+ }
30
+ interface DirectRequestPaymentListResponse<T> {
31
+ items: T[];
32
+ next_cursor?: string | null;
33
+ [key: string]: unknown;
34
+ }
35
+ interface DirectRequestPaymentBuyerUsageEvent {
36
+ metered_usage_id: string;
37
+ created_at?: string | null;
38
+ plan_type: string;
39
+ settlement_cadence: string;
40
+ product_listing_id?: string | null;
41
+ listing_id?: string | null;
42
+ capability_key?: string | null;
43
+ operation_key?: string | null;
44
+ currency: string;
45
+ token_symbol: string;
46
+ provider_usage_amount_minor: DirectRequestPaymentMinorAmount;
47
+ protocol_fee_minor: DirectRequestPaymentMinorAmount;
48
+ gross_buyer_debit_minor: DirectRequestPaymentMinorAmount;
49
+ status: string;
50
+ period_start?: string | null;
51
+ period_end?: string | null;
52
+ settlement_batch_id?: string | null;
53
+ expected_scheduled_debit_at?: string | null;
54
+ [key: string]: unknown;
55
+ }
56
+ interface DirectRequestPaymentProviderUsageEvent {
57
+ metered_usage_id: string;
58
+ created_at?: string | null;
59
+ plan_type: string;
60
+ settlement_cadence: string;
61
+ product_listing_id?: string | null;
62
+ listing_id?: string | null;
63
+ capability_key?: string | null;
64
+ operation_key?: string | null;
65
+ currency: string;
66
+ token_symbol: string;
67
+ provider_receivable_minor: DirectRequestPaymentMinorAmount;
68
+ protocol_fee_minor: DirectRequestPaymentMinorAmount;
69
+ gross_buyer_debit_minor: DirectRequestPaymentMinorAmount;
70
+ status: string;
71
+ period_start?: string | null;
72
+ period_end?: string | null;
73
+ expected_scheduled_debit_at?: string | null;
74
+ settlement_batch_id?: string | null;
75
+ buyer_period_ref?: string | null;
76
+ [key: string]: unknown;
77
+ }
78
+ interface DirectRequestPaymentSettlementBatch {
79
+ settlement_batch_id: string;
80
+ plan_type: string;
81
+ settlement_cadence: string;
82
+ status: string;
83
+ notice_status?: string | null;
84
+ period_start?: string | null;
85
+ period_end?: string | null;
86
+ close_at?: string | null;
87
+ expected_scheduled_debit_at?: string | null;
88
+ scheduled_debit_at?: string | null;
89
+ not_before_attempt_at?: string | null;
90
+ execution_status?: string | null;
91
+ latest_execution_attempt_status?: string | null;
92
+ chain_receipt_id?: string | null;
93
+ usage_event_digest?: string | null;
94
+ protocol_fee_minor?: DirectRequestPaymentMinorAmount;
95
+ gross_buyer_debit_minor?: DirectRequestPaymentMinorAmount;
96
+ rounding_delta_minor?: DirectRequestPaymentMinorAmount;
97
+ buyer_debit_minor?: DirectRequestPaymentMinorAmount;
98
+ provider_usage_amount_minor?: DirectRequestPaymentMinorAmount;
99
+ provider_receivable_minor?: DirectRequestPaymentMinorAmount;
100
+ settled_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
101
+ unsettled_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
102
+ past_due_provider_receivable_minor?: DirectRequestPaymentMinorAmount;
103
+ buyer_period_ref?: string | null;
104
+ failure_reason_code?: string | null;
105
+ failure_reason_label?: string | null;
106
+ failure_reason_help?: string | null;
107
+ support_reference?: string | null;
108
+ [key: string]: unknown;
109
+ }
110
+ interface DirectRequestPaymentBuyerMeteredSummary {
111
+ role: "buyer";
112
+ open_periods: Array<Record<string, unknown>>;
113
+ settlement_batches: DirectRequestPaymentSettlementBatch[];
114
+ past_due_blocks: Array<Record<string, unknown>>;
115
+ balance_sufficiency?: Record<string, unknown>;
116
+ [key: string]: unknown;
117
+ }
118
+ interface DirectRequestPaymentProviderMeteredSummary {
119
+ role: "provider";
120
+ timezone?: string | null;
121
+ filters?: Record<string, unknown>;
122
+ open_periods: Array<Record<string, unknown>>;
123
+ periods: DirectRequestPaymentSettlementBatch[];
124
+ totals: Record<string, DirectRequestPaymentMinorAmount>;
125
+ [key: string]: unknown;
126
+ }
11
127
  interface DirectRequestPaymentChallengeInput {
12
128
  merchant: string;
13
129
  amount_minor: number;
@@ -78,11 +194,17 @@ interface DirectPaymentRequirement {
78
194
  capability_key: string;
79
195
  requirement_hash: string;
80
196
  request_hash: string;
197
+ request_hash_v2?: string | null;
81
198
  siglume_signature: string;
82
199
  token_symbol: string;
83
200
  currency: string;
84
201
  amount_minor: number;
85
202
  fee_bps: number;
203
+ pricing_band?: "standard" | DirectRequestPaymentMeteredPlanType | string | null;
204
+ settlement_cadence?: "per_payment" | "weekly" | "monthly" | string | null;
205
+ finality?: string | null;
206
+ protocol_fee_minor?: DirectRequestPaymentMinorAmount | null;
207
+ settlement_status?: string | null;
86
208
  status: string;
87
209
  expires_at?: string | null;
88
210
  confirmed_at?: string | null;
@@ -265,6 +387,12 @@ interface DirectRequestPaymentWebhookEvent {
265
387
  currency?: string;
266
388
  token_symbol?: string;
267
389
  status?: string;
390
+ request_hash_v2?: string | null;
391
+ pricing_band?: "standard" | DirectRequestPaymentMeteredPlanType | string | null;
392
+ settlement_cadence?: "per_payment" | "weekly" | "monthly" | string | null;
393
+ finality?: string | null;
394
+ protocol_fee_minor?: DirectRequestPaymentMinorAmount | null;
395
+ settlement_status?: string | null;
268
396
  [key: string]: unknown;
269
397
  };
270
398
  [key: string]: unknown;
@@ -310,6 +438,13 @@ declare class DirectRequestPaymentClient {
310
438
  await_finality?: boolean;
311
439
  metadata?: Record<string, unknown>;
312
440
  }): Promise<Web3PreparedTransactionExecuteResult>;
441
+ getBuyerMeteredSummary(input?: DirectRequestPaymentBuyerMeteredQuery): Promise<DirectRequestPaymentBuyerMeteredSummary>;
442
+ listBuyerUsageEvents(input?: DirectRequestPaymentMeteredListQuery): Promise<DirectRequestPaymentListResponse<DirectRequestPaymentBuyerUsageEvent>>;
443
+ listBuyerSettlementBatches(input?: DirectRequestPaymentMeteredListQuery): Promise<DirectRequestPaymentListResponse<DirectRequestPaymentSettlementBatch>>;
444
+ getProviderMeteredSummary(input?: DirectRequestPaymentProviderMeteredQuery): Promise<DirectRequestPaymentProviderMeteredSummary>;
445
+ listProviderUsageEvents(input?: DirectRequestPaymentProviderMeteredListQuery): Promise<DirectRequestPaymentListResponse<DirectRequestPaymentProviderUsageEvent>>;
446
+ listProviderSettlementBatches(input?: DirectRequestPaymentProviderMeteredListQuery): Promise<DirectRequestPaymentListResponse<DirectRequestPaymentSettlementBatch>>;
447
+ getProviderSettlementBatch(settlement_batch_id: string, input?: Pick<DirectRequestPaymentProviderMeteredQuery, "listing_id" | "capability_key">): Promise<DirectRequestPaymentSettlementBatch>;
313
448
  request<T>(method: string, path: string, json_body?: unknown): Promise<T>;
314
449
  }
315
450
  declare class DirectRequestPaymentMerchantClient {
@@ -383,6 +518,12 @@ declare function directRequestPaymentRequestHash(input: {
383
518
  currency: DirectRequestPaymentCurrency | string;
384
519
  challenge: string;
385
520
  }): Promise<string>;
521
+ declare function directRequestPaymentRequestHashV2(input: {
522
+ merchant: string;
523
+ amount_minor: number;
524
+ currency: DirectRequestPaymentCurrency | string;
525
+ challenge: string;
526
+ }): Promise<string>;
386
527
  declare function buildPaymentExecutionPayload(requirement: DirectPaymentRequirement, options?: {
387
528
  await_finality?: boolean;
388
529
  metadata?: Record<string, unknown>;
@@ -419,4 +560,4 @@ declare const verifyExternal402Challenge: typeof verifyDirectRequestPaymentChall
419
560
  declare const createExternal402RecurringChallenge: typeof createDirectRequestPaymentRecurringChallenge;
420
561
  declare const verifyExternal402RecurringChallenge: typeof verifyDirectRequestPaymentRecurringChallenge;
421
562
 
422
- export { DEFAULT_SIGLUME_API_BASE, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_MODE, DIRECT_REQUEST_PAYMENT_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_RECURRING_CHALLENGE_SCHEME, DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE, type DirectPaymentRequirement, type DirectPaymentRequirementCreateInput, type DirectPaymentVerifyInput, type DirectRequestPaymentBillingPlan, type DirectRequestPaymentChallenge, type DirectRequestPaymentChallengeInput, type DirectRequestPaymentCheckoutSetupInput, type DirectRequestPaymentCheckoutSetupResult, DirectRequestPaymentClient, type DirectRequestPaymentClientOptions, type DirectRequestPaymentCurrency, type DirectRequestPaymentMerchantAccount, type DirectRequestPaymentMerchantBillingMandateInput, DirectRequestPaymentMerchantClient, type DirectRequestPaymentMerchantResponse, type DirectRequestPaymentMerchantSetupInput, type DirectRequestPaymentRecurringCadence, type DirectRequestPaymentRecurringChallenge, type DirectRequestPaymentRecurringChallengeInput, 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, computeWebhookSignature, createDirectRequestPaymentChallenge, createDirectRequestPaymentChallengeSignature, createDirectRequestPaymentRecurringChallenge, createDirectRequestPaymentRecurringChallengeSignature, createExternal402Challenge, createExternal402RecurringChallenge, directRequestPaymentChallengeHash, directRequestPaymentRequestHash, parseDirectRequestPaymentChallenge, parseDirectRequestPaymentWebhookEvent, verifyDirectRequestPaymentChallenge, verifyDirectRequestPaymentRecurringChallenge, verifyDirectRequestPaymentWebhook, verifyExternal402Challenge, verifyExternal402RecurringChallenge, verifyWebhookSignature };
563
+ export { DEFAULT_SIGLUME_API_BASE, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, DIRECT_REQUEST_PAYMENT_ALLOWANCE_RECEIPT_KIND, DIRECT_REQUEST_PAYMENT_CHALLENGE_SCHEME, 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, type DirectPaymentRequirement, type DirectPaymentRequirementCreateInput, 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, computeWebhookSignature, createDirectRequestPaymentChallenge, createDirectRequestPaymentChallengeSignature, createDirectRequestPaymentRecurringChallenge, createDirectRequestPaymentRecurringChallengeSignature, createExternal402Challenge, createExternal402RecurringChallenge, directRequestPaymentChallengeHash, directRequestPaymentRequestHash, directRequestPaymentRequestHashV2, parseDirectRequestPaymentChallenge, parseDirectRequestPaymentWebhookEvent, verifyDirectRequestPaymentChallenge, verifyDirectRequestPaymentRecurringChallenge, verifyDirectRequestPaymentWebhook, verifyExternal402Challenge, verifyExternal402RecurringChallenge, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -7,6 +7,8 @@ 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.4";
11
+ var DIRECT_REQUEST_PAYMENT_CONFIRMED_WEBHOOK_MODES = /* @__PURE__ */ new Set([DIRECT_REQUEST_PAYMENT_MODE, "metered_settlement_batch"]);
10
12
  var SiglumeDirectRequestPaymentError = class extends Error {
11
13
  constructor(message) {
12
14
  super(message);
@@ -63,7 +65,7 @@ var DirectRequestPaymentClient = class {
63
65
  this.auth_token = authToken;
64
66
  this.base_url = (options.base_url ?? envValue("SIGLUME_API_BASE") ?? DEFAULT_SIGLUME_API_BASE).replace(/\/+$/, "");
65
67
  this.timeout_ms = Math.max(1, Math.trunc(options.timeout_ms ?? 15e3));
66
- this.user_agent = options.user_agent ?? "@siglume/direct-request-payment/0.4.3";
68
+ this.user_agent = options.user_agent ?? `@siglume/direct-request-payment/${DIRECT_REQUEST_PAYMENT_SDK_VERSION}`;
67
69
  this.fetch_impl = fetchImpl;
68
70
  }
69
71
  async createPaymentRequirement(input) {
@@ -111,6 +113,53 @@ var DirectRequestPaymentClient = class {
111
113
  async executeAllowanceTransaction(requirement, options = {}) {
112
114
  return this.executePreparedTransaction(buildAllowanceExecutionPayload(requirement, options));
113
115
  }
116
+ async getBuyerMeteredSummary(input = {}) {
117
+ return this.request(
118
+ "GET",
119
+ meteredQueryPath("/sdrp/metered/my-summary", input)
120
+ );
121
+ }
122
+ async listBuyerUsageEvents(input = {}) {
123
+ return this.request(
124
+ "GET",
125
+ meteredQueryPath("/sdrp/metered/my-usage-events", input)
126
+ );
127
+ }
128
+ async listBuyerSettlementBatches(input = {}) {
129
+ return this.request(
130
+ "GET",
131
+ meteredQueryPath("/sdrp/metered/my-settlement-batches", input)
132
+ );
133
+ }
134
+ async getProviderMeteredSummary(input = {}) {
135
+ return this.request(
136
+ "GET",
137
+ meteredQueryPath("/sdrp/metered/provider/summary", input)
138
+ );
139
+ }
140
+ async listProviderUsageEvents(input = {}) {
141
+ return this.request(
142
+ "GET",
143
+ meteredQueryPath("/sdrp/metered/provider/usage-events", input)
144
+ );
145
+ }
146
+ async listProviderSettlementBatches(input = {}) {
147
+ return this.request(
148
+ "GET",
149
+ meteredQueryPath("/sdrp/metered/provider/settlement-batches", input)
150
+ );
151
+ }
152
+ async getProviderSettlementBatch(settlement_batch_id, input = {}) {
153
+ return this.request(
154
+ "GET",
155
+ meteredQueryPath(
156
+ `/sdrp/metered/provider/settlement-batches/${encodeURIComponent(
157
+ requireNonEmpty(settlement_batch_id, "settlement_batch_id")
158
+ )}`,
159
+ input
160
+ )
161
+ );
162
+ }
114
163
  async request(method, path, json_body) {
115
164
  const controller = new AbortController();
116
165
  const timeout = setTimeout(() => controller.abort(), this.timeout_ms);
@@ -168,7 +217,7 @@ var DirectRequestPaymentMerchantClient = class {
168
217
  this.auth_token = authToken;
169
218
  this.base_url = (options.base_url ?? envValue("SIGLUME_API_BASE") ?? DEFAULT_SIGLUME_API_BASE).replace(/\/+$/, "");
170
219
  this.timeout_ms = Math.max(1, Math.trunc(options.timeout_ms ?? 15e3));
171
- this.user_agent = options.user_agent ?? "@siglume/direct-request-payment/0.4.3";
220
+ this.user_agent = options.user_agent ?? `@siglume/direct-request-payment/${DIRECT_REQUEST_PAYMENT_SDK_VERSION}`;
172
221
  this.fetch_impl = fetchImpl;
173
222
  }
174
223
  async setupMerchant(input) {
@@ -461,6 +510,16 @@ async function directRequestPaymentRequestHash(input) {
461
510
  const material = `${normalizeMerchant(input.merchant)}${positiveInteger(input.amount_minor, "amount_minor")}${normalizeCurrency(input.currency)}${requireNonEmpty(input.challenge, "challenge")}`;
462
511
  return sha256Prefixed(material);
463
512
  }
513
+ async function directRequestPaymentRequestHashV2(input) {
514
+ const material = JSON.stringify({
515
+ amount_minor: positiveInteger(input.amount_minor, "amount_minor"),
516
+ challenge: requireNonEmpty(input.challenge, "challenge"),
517
+ currency: normalizeCurrency(input.currency),
518
+ merchant: normalizeMerchant(input.merchant),
519
+ version: 2
520
+ });
521
+ return sha256Prefixed(material);
522
+ }
464
523
  function buildPaymentExecutionPayload(requirement, options = {}) {
465
524
  return buildPreparedTransactionExecutionPayload(requirement, requirement.transaction_request, {
466
525
  receipt_kind: DIRECT_REQUEST_PAYMENT_RECEIPT_KIND,
@@ -534,8 +593,10 @@ function parseDirectRequestPaymentWebhookEvent(payload) {
534
593
  occurred_at: requireNonEmpty(stringOrNull(event.occurred_at) ?? "", "webhook occurred_at"),
535
594
  data: { ...data }
536
595
  };
537
- if (parsed.type === "direct_payment.confirmed" && parsed.data.mode !== DIRECT_REQUEST_PAYMENT_MODE) {
538
- throw new SiglumeWebhookPayloadError("direct_payment.confirmed webhook must carry data.mode='external_402'.");
596
+ if (parsed.type === "direct_payment.confirmed" && !DIRECT_REQUEST_PAYMENT_CONFIRMED_WEBHOOK_MODES.has(String(parsed.data.mode ?? ""))) {
597
+ throw new SiglumeWebhookPayloadError(
598
+ "direct_payment.confirmed webhook must carry a supported Direct Request Payment mode."
599
+ );
539
600
  }
540
601
  return parsed;
541
602
  }
@@ -589,6 +650,13 @@ function normalizeToken(value) {
589
650
  }
590
651
  return token;
591
652
  }
653
+ function normalizeMeteredPlanType(value) {
654
+ const planType = requireNonEmpty(value, "plan_type").toLowerCase();
655
+ if (planType === "micro" || planType === "nano") {
656
+ return planType;
657
+ }
658
+ throw new SiglumeDirectRequestPaymentError("plan_type must be micro or nano.");
659
+ }
592
660
  function normalizeAllowedCurrencies(value) {
593
661
  const normalized = {};
594
662
  if (Array.isArray(value)) {
@@ -626,7 +694,15 @@ function normalizeOriginList(value) {
626
694
  "each checkout_allowed_origins entry must be an absolute origin such as https://shop.example.com."
627
695
  );
628
696
  }
629
- const origin = `${url.protocol.toLowerCase()}//${url.host.toLowerCase()}`;
697
+ if (url.username || url.password) {
698
+ throw new SiglumeDirectRequestPaymentError("checkout_allowed_origins entries must not include userinfo.");
699
+ }
700
+ if (!isAllowedCheckoutOriginScheme(url)) {
701
+ throw new SiglumeDirectRequestPaymentError(
702
+ "checkout_allowed_origins entries must use https, except http is allowed for localhost, 127.0.0.1, or [::1]."
703
+ );
704
+ }
705
+ const origin = url.origin.toLowerCase();
630
706
  if (!seen.has(origin)) {
631
707
  seen.add(origin);
632
708
  origins.push(origin);
@@ -634,8 +710,44 @@ function normalizeOriginList(value) {
634
710
  }
635
711
  return origins;
636
712
  }
713
+ function isAllowedCheckoutOriginScheme(url) {
714
+ if (url.protocol === "https:") {
715
+ return Boolean(url.hostname);
716
+ }
717
+ if (url.protocol !== "http:") {
718
+ return false;
719
+ }
720
+ const hostname = url.hostname.toLowerCase();
721
+ return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "::1";
722
+ }
723
+ function meteredQueryPath(path, input) {
724
+ const params = new URLSearchParams();
725
+ if (input.plan_type !== void 0) {
726
+ params.set("plan_type", normalizeMeteredPlanType(input.plan_type));
727
+ }
728
+ if (input.token_symbol !== void 0) {
729
+ params.set("token_symbol", normalizeToken(input.token_symbol));
730
+ }
731
+ if ("status" in input && input.status !== void 0) {
732
+ params.set("status", requireNonEmpty(input.status, "status"));
733
+ }
734
+ if ("listing_id" in input && input.listing_id !== void 0) {
735
+ params.set("listing_id", requireNonEmpty(input.listing_id, "listing_id"));
736
+ }
737
+ if ("capability_key" in input && input.capability_key !== void 0) {
738
+ params.set("capability_key", requireNonEmpty(input.capability_key, "capability_key"));
739
+ }
740
+ if ("limit" in input && input.limit !== void 0) {
741
+ params.set("limit", String(positiveInteger(input.limit, "limit")));
742
+ }
743
+ const query = params.toString();
744
+ return query ? `${path}?${query}` : path;
745
+ }
637
746
  function positiveInteger(value, name) {
638
- const parsed = Number(value);
747
+ if (typeof value !== "number") {
748
+ throw new SiglumeDirectRequestPaymentError(`${name} must be a positive safe integer.`);
749
+ }
750
+ const parsed = value;
639
751
  if (!Number.isSafeInteger(parsed) || parsed <= 0) {
640
752
  throw new SiglumeDirectRequestPaymentError(`${name} must be a positive safe integer.`);
641
753
  }
@@ -837,6 +949,7 @@ export {
837
949
  DIRECT_REQUEST_PAYMENT_RECEIPT_KIND,
838
950
  DIRECT_REQUEST_PAYMENT_RECURRING_CHALLENGE_SCHEME,
839
951
  DIRECT_REQUEST_PAYMENT_REFERENCE_TYPE,
952
+ DIRECT_REQUEST_PAYMENT_SDK_VERSION,
840
953
  DirectRequestPaymentClient,
841
954
  DirectRequestPaymentMerchantClient,
842
955
  HostedCheckoutNotAvailableError,
@@ -857,6 +970,7 @@ export {
857
970
  createExternal402RecurringChallenge,
858
971
  directRequestPaymentChallengeHash,
859
972
  directRequestPaymentRequestHash,
973
+ directRequestPaymentRequestHashV2,
860
974
  parseDirectRequestPaymentChallenge,
861
975
  parseDirectRequestPaymentWebhookEvent,
862
976
  verifyDirectRequestPaymentChallenge,