@waffo/waffo-node 2.0.4 → 2.2.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
@@ -176,7 +176,6 @@ declare enum WebhookEventType {
176
176
  PAYMENT_NOTIFICATION = "PAYMENT_NOTIFICATION",
177
177
  REFUND_NOTIFICATION = "REFUND_NOTIFICATION",
178
178
  SUBSCRIPTION_STATUS_NOTIFICATION = "SUBSCRIPTION_STATUS_NOTIFICATION",
179
- SUBSCRIPTION_PAYMENT_NOTIFICATION = "SUBSCRIPTION_PAYMENT_NOTIFICATION",
180
179
  SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION = "SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION"
181
180
  }
182
181
  /**
@@ -199,47 +198,104 @@ interface BaseNotification {
199
198
  eventType: string;
200
199
  }
201
200
  /**
202
- * Payment notification from Waffo.
201
+ * Payment notification result payload (21 fields).
203
202
  */
204
- interface PaymentNotification extends BaseNotification {
205
- eventType: 'PAYMENT_NOTIFICATION';
206
- acquiringOrderId?: string;
207
- merchantOrderId?: string;
203
+ interface PaymentNotificationResult {
208
204
  paymentRequestId?: string;
205
+ merchantOrderId?: string;
206
+ acquiringOrderId?: string;
209
207
  orderStatus?: string;
210
- orderAmount?: string;
208
+ orderAction?: string;
211
209
  orderCurrency?: string;
210
+ orderAmount?: string;
211
+ userCurrency?: string;
212
212
  finalDealAmount?: string;
213
+ orderDescription?: string;
214
+ merchantInfo?: Record<string, unknown>;
215
+ userInfo?: Record<string, unknown>;
216
+ goodsInfo?: Record<string, unknown>;
217
+ addressInfo?: Record<string, unknown>;
218
+ paymentInfo?: Record<string, unknown>;
219
+ orderRequestedAt?: string;
220
+ orderExpiredAt?: string;
221
+ orderUpdatedAt?: string;
222
+ orderCompletedAt?: string;
223
+ orderFailedReason?: Record<string, unknown>;
224
+ extendInfo?: string;
213
225
  [key: string]: unknown;
214
226
  }
215
227
  /**
216
- * Refund notification from Waffo.
228
+ * Refund notification result payload (17 fields).
217
229
  */
218
- interface RefundNotification extends BaseNotification {
219
- eventType: 'REFUND_NOTIFICATION';
220
- acquiringRefundOrderId?: string;
230
+ interface RefundNotificationResult {
221
231
  refundRequestId?: string;
222
- refundStatus?: string;
232
+ merchantRefundOrderId?: string;
233
+ acquiringOrderId?: string;
234
+ acquiringRefundOrderId?: string;
235
+ origPaymentRequestId?: string;
223
236
  refundAmount?: string;
237
+ refundStatus?: string;
238
+ remainingRefundAmount?: string;
239
+ userCurrency?: string;
240
+ finalDealAmount?: string;
241
+ refundReason?: string;
242
+ refundRequestedAt?: string;
243
+ refundUpdatedAt?: string;
244
+ refundCompletedAt?: string;
245
+ refundFailedReason?: Record<string, unknown>;
246
+ userInfo?: Record<string, unknown>;
247
+ extendInfo?: string;
224
248
  [key: string]: unknown;
225
249
  }
226
250
  /**
227
- * Subscription status notification from Waffo.
251
+ * Subscription notification result payload (20 fields).
252
+ * Shared by SubscriptionStatusNotification and SubscriptionPeriodChangedNotification.
228
253
  */
229
- interface SubscriptionStatusNotification extends BaseNotification {
230
- eventType: 'SUBSCRIPTION_STATUS_NOTIFICATION';
254
+ interface SubscriptionNotificationResult {
255
+ subscriptionRequest?: string;
256
+ merchantSubscriptionId?: string;
231
257
  subscriptionId?: string;
232
258
  subscriptionStatus?: string;
259
+ subscriptionAction?: string;
260
+ currency?: string;
261
+ amount?: string;
262
+ userCurrency?: string;
263
+ productInfo?: Record<string, unknown>;
264
+ merchantInfo?: Record<string, unknown>;
265
+ userInfo?: Record<string, unknown>;
266
+ goodsInfo?: Record<string, unknown>;
267
+ addressInfo?: Record<string, unknown>;
268
+ paymentInfo?: Record<string, unknown>;
269
+ requestedAt?: string;
270
+ updatedAt?: string;
271
+ failedReason?: Record<string, unknown>;
272
+ extendInfo?: string;
273
+ subscriptionManagementUrl?: string;
274
+ paymentDetails?: Record<string, unknown>[];
233
275
  [key: string]: unknown;
234
276
  }
235
277
  /**
236
- * Subscription payment notification from Waffo.
278
+ * Payment notification from Waffo.
237
279
  */
238
- interface SubscriptionPaymentNotification extends BaseNotification {
239
- eventType: 'SUBSCRIPTION_PAYMENT_NOTIFICATION';
240
- subscriptionId?: string;
241
- acquiringOrderId?: string;
242
- orderStatus?: string;
280
+ interface PaymentNotification extends BaseNotification {
281
+ eventType: 'PAYMENT_NOTIFICATION';
282
+ result?: PaymentNotificationResult;
283
+ [key: string]: unknown;
284
+ }
285
+ /**
286
+ * Refund notification from Waffo.
287
+ */
288
+ interface RefundNotification extends BaseNotification {
289
+ eventType: 'REFUND_NOTIFICATION';
290
+ result?: RefundNotificationResult;
291
+ [key: string]: unknown;
292
+ }
293
+ /**
294
+ * Subscription status notification from Waffo.
295
+ */
296
+ interface SubscriptionStatusNotification extends BaseNotification {
297
+ eventType: 'SUBSCRIPTION_STATUS_NOTIFICATION';
298
+ result?: SubscriptionNotificationResult;
243
299
  [key: string]: unknown;
244
300
  }
245
301
  /**
@@ -247,13 +303,13 @@ interface SubscriptionPaymentNotification extends BaseNotification {
247
303
  */
248
304
  interface SubscriptionPeriodChangedNotification extends BaseNotification {
249
305
  eventType: 'SUBSCRIPTION_PERIOD_CHANGED_NOTIFICATION';
250
- subscriptionId?: string;
306
+ result?: SubscriptionNotificationResult;
251
307
  [key: string]: unknown;
252
308
  }
253
309
  type PaymentHandler = (notification: PaymentNotification) => void | Promise<void>;
254
310
  type RefundHandler = (notification: RefundNotification) => void | Promise<void>;
255
311
  type SubscriptionStatusHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
256
- type SubscriptionPaymentHandler = (notification: SubscriptionPaymentNotification) => void | Promise<void>;
312
+ type SubscriptionPaymentHandler = (notification: SubscriptionStatusNotification) => void | Promise<void>;
257
313
  type SubscriptionPeriodChangedHandler = (notification: SubscriptionPeriodChangedNotification) => void | Promise<void>;
258
314
  /**
259
315
  * Webhook handler for processing Waffo webhook notifications.
@@ -263,10 +319,10 @@ type SubscriptionPeriodChangedHandler = (notification: SubscriptionPeriodChanged
263
319
  * // Setup handler
264
320
  * const handler = waffo.webhook()
265
321
  * .onPayment((notification) => {
266
- * console.log('Payment:', notification.orderStatus);
322
+ * console.log('Payment:', notification.result?.orderStatus);
267
323
  * })
268
324
  * .onRefund((notification) => {
269
- * console.log('Refund:', notification.refundStatus);
325
+ * console.log('Refund:', notification.result?.refundStatus);
270
326
  * });
271
327
  *
272
328
  * // Process webhook (e.g., in Express.js)
@@ -303,7 +359,8 @@ declare class WebhookHandler {
303
359
  */
304
360
  onSubscriptionStatus(handler: SubscriptionStatusHandler): this;
305
361
  /**
306
- * Registers a handler for subscription payment notifications.
362
+ * Registers a fallback handler for SUBSCRIPTION_STATUS_NOTIFICATION events.
363
+ * Only called when onSubscriptionStatus handler is not registered.
307
364
  */
308
365
  onSubscriptionPayment(handler: SubscriptionPaymentHandler): this;
309
366
  /**
@@ -525,6 +582,7 @@ interface CreateOrderData {
525
582
  interface InquiryOrderParams {
526
583
  paymentRequestId?: string;
527
584
  acquiringOrderId?: string;
585
+ merchantInfo?: MerchantInfo;
528
586
  [key: string]: unknown;
529
587
  }
530
588
  /**
@@ -550,8 +608,8 @@ interface InquiryOrderData {
550
608
  interface CancelOrderParams {
551
609
  paymentRequestId?: string;
552
610
  acquiringOrderId?: string;
553
- merchantId: string;
554
- orderRequestedAt: string;
611
+ merchantInfo?: MerchantInfo;
612
+ orderRequestedAt?: string;
555
613
  [key: string]: unknown;
556
614
  }
557
615
  /**
@@ -569,13 +627,14 @@ interface CancelOrderData {
569
627
  */
570
628
  interface RefundOrderParams {
571
629
  refundRequestId: string;
572
- acquiringOrderId: string;
630
+ paymentRequestId?: string;
631
+ acquiringOrderId?: string;
573
632
  merchantRefundOrderId?: string;
574
- merchantId: string;
633
+ merchantInfo?: MerchantInfo;
575
634
  refundAmount: string;
576
- refundReason: string;
577
- requestedAt: string;
578
- refundNotifyUrl?: string;
635
+ refundReason?: string;
636
+ requestedAt?: string;
637
+ notifyUrl?: string;
579
638
  userInfo?: RefundUserInfo;
580
639
  extendInfo?: string;
581
640
  [key: string]: unknown;
@@ -812,22 +871,33 @@ declare class OrderResource extends BaseResource {
812
871
  * Create subscription request parameters.
813
872
  */
814
873
  interface CreateSubscriptionParams {
815
- subscriptionRequestId: string;
874
+ /**
875
+ * Subscription request ID sent from Merchant (max 32 characters).
876
+ * Used for idempotent check.
877
+ */
878
+ subscriptionRequest: string;
816
879
  merchantSubscriptionId: string;
817
- orderCurrency: string;
818
- orderAmount: string;
819
- orderDescription: string;
880
+ currency: string;
881
+ amount: string;
820
882
  notifyUrl: string;
821
883
  productInfo: ProductInfo;
822
884
  userInfo: SubscriptionUserInfo;
823
885
  paymentInfo: SubscriptionPaymentInfo;
824
886
  merchantInfo?: SubscriptionMerchantInfo;
887
+ goodsInfo?: {
888
+ goodsId: string;
889
+ goodsName: string;
890
+ goodsCategory?: string;
891
+ goodsUrl?: string;
892
+ goodsQuantity?: number;
893
+ [key: string]: unknown;
894
+ };
825
895
  successRedirectUrl?: string;
826
896
  failedRedirectUrl?: string;
827
897
  cancelRedirectUrl?: string;
898
+ subscriptionManagementUrl?: string;
828
899
  requestedAt?: string;
829
900
  extendInfo?: string;
830
- metadata?: string;
831
901
  /**
832
902
  * Order expiry time (ISO 8601 format, max 24 characters).
833
903
  */
@@ -838,7 +908,7 @@ interface CreateSubscriptionParams {
838
908
  * Create subscription response data.
839
909
  */
840
910
  interface CreateSubscriptionData {
841
- subscriptionRequestId?: string;
911
+ subscriptionRequest?: string;
842
912
  merchantSubscriptionId?: string;
843
913
  subscriptionId?: string;
844
914
  subscriptionStatus?: SubscriptionStatus;
@@ -849,41 +919,41 @@ interface CreateSubscriptionData {
849
919
  * Inquiry subscription request parameters.
850
920
  */
851
921
  interface InquirySubscriptionParams {
852
- subscriptionRequestId?: string;
922
+ subscriptionRequest?: string;
853
923
  subscriptionId?: string;
924
+ merchantInfo?: SubscriptionMerchantInfo;
854
925
  [key: string]: unknown;
855
926
  }
856
927
  /**
857
928
  * Inquiry subscription response data.
858
929
  */
859
930
  interface InquirySubscriptionData {
860
- subscriptionRequestId?: string;
931
+ subscriptionRequest?: string;
861
932
  merchantSubscriptionId?: string;
862
933
  subscriptionId?: string;
934
+ payMethodSubscriptionId?: string;
863
935
  subscriptionStatus?: SubscriptionStatus;
864
- orderCurrency?: string;
865
- orderAmount?: string;
866
- currentPeriodStartAt?: string;
867
- currentPeriodEndAt?: string;
868
- nextBillingAt?: string;
936
+ subscriptionAction?: string;
937
+ currency?: string;
938
+ userCurrency?: string;
939
+ amount?: string;
940
+ productInfo?: ProductInfo;
869
941
  [key: string]: unknown;
870
942
  }
871
943
  /**
872
944
  * Cancel subscription request parameters.
873
945
  */
874
946
  interface CancelSubscriptionParams {
875
- subscriptionRequestId?: string;
876
947
  subscriptionId?: string;
877
- merchantId: string;
878
- cancelReason?: string;
879
- requestedAt: string;
948
+ merchantId?: string;
949
+ requestedAt?: string;
880
950
  [key: string]: unknown;
881
951
  }
882
952
  /**
883
953
  * Cancel subscription response data.
884
954
  */
885
955
  interface CancelSubscriptionData {
886
- subscriptionRequestId?: string;
956
+ subscriptionRequest?: string;
887
957
  merchantSubscriptionId?: string;
888
958
  subscriptionId?: string;
889
959
  subscriptionStatus?: SubscriptionStatus;
@@ -912,28 +982,78 @@ interface ManageSubscriptionData {
912
982
  }
913
983
  /**
914
984
  * Subscription status enum.
985
+ * Based on openapi.json SubscriptionInquiryResponse.subscriptionStatus.
915
986
  */
916
- type SubscriptionStatus = 'SUBSCRIPTION_IN_PROGRESS' | 'SUBSCRIPTION_ACTIVE' | 'SUBSCRIPTION_PAUSED' | 'SUBSCRIPTION_CANCELLED' | 'SUBSCRIPTION_EXPIRED';
987
+ type SubscriptionStatus = 'AUTHORIZATION_REQUIRED' | 'IN_PROGRESS' | 'ACTIVE' | 'CLOSE' | 'MERCHANT_CANCELLED' | 'USER_CANCELLED' | 'CHANNEL_CANCELLED' | 'EXPIRED';
917
988
  /**
918
989
  * Subscription manage action enum.
919
990
  */
920
991
  type SubscriptionManageAction = 'PAUSE' | 'RESUME' | 'UPDATE_AMOUNT' | 'UPDATE_PERIOD';
921
992
  /**
922
993
  * Period type enum.
994
+ * Values: DAILY, WEEKLY, MONTHLY
923
995
  */
924
- type PeriodType = 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
996
+ type PeriodType = 'DAILY' | 'WEEKLY' | 'MONTHLY';
925
997
  /**
926
998
  * Product information for subscription.
999
+ * Based on openapi.json ProductInfo schema.
927
1000
  */
928
1001
  interface ProductInfo {
929
- productId: string;
930
- productName: string;
931
- productDescription?: string;
1002
+ /**
1003
+ * Subscription product description (max 128 characters).
1004
+ * Often appearing to user when asking user's confirmation.
1005
+ */
1006
+ description: string;
1007
+ /**
1008
+ * Subscription product period type: DAILY, WEEKLY, MONTHLY.
1009
+ */
932
1010
  periodType: PeriodType;
933
- periodValue: number;
1011
+ /**
1012
+ * Period interval (max 12 characters).
1013
+ * - DAILY: 1-365
1014
+ * - WEEKLY: 1-4
1015
+ * - MONTHLY: 1-12
1016
+ */
1017
+ periodInterval: string;
1018
+ /**
1019
+ * Number of billing periods until subscription ends (max 24 characters).
1020
+ * Empty means no defined end period.
1021
+ */
1022
+ numberOfPeriod?: string;
1023
+ /**
1024
+ * Trial period amount (max 24 characters).
1025
+ */
1026
+ trialPeriodAmount?: string;
1027
+ /**
1028
+ * Number of trial periods (max 12 characters).
1029
+ */
1030
+ numberOfTrialPeriod?: string;
1031
+ /**
1032
+ * Trial period type: DAILY, WEEKLY, MONTHLY.
1033
+ * If omitted, uses periodType value by default.
1034
+ */
934
1035
  trialPeriodType?: PeriodType;
935
- trialPeriodValue?: number;
936
- trialAmount?: string;
1036
+ /**
1037
+ * Trial period interval (max 12 characters).
1038
+ * If omitted, uses periodInterval value by default.
1039
+ */
1040
+ trialPeriodInterval?: string;
1041
+ /**
1042
+ * When the subscription starts (ISO 8601 format).
1043
+ */
1044
+ startDateTime?: string;
1045
+ /**
1046
+ * When the subscription ends (ISO 8601 format).
1047
+ */
1048
+ endDateTime?: string;
1049
+ /**
1050
+ * When the next payment is due (ISO 8601 format).
1051
+ */
1052
+ nextPaymentDateTime?: string;
1053
+ /**
1054
+ * Current billing period number.
1055
+ */
1056
+ currentPeriod?: string;
937
1057
  [key: string]: unknown;
938
1058
  }
939
1059
  /**
@@ -1426,35 +1546,40 @@ declare class SubscriptionResource extends BaseResource {
1426
1546
  * Note: Full type definitions should be generated from openapi.json.
1427
1547
  * These are placeholder interfaces for the SDK structure.
1428
1548
  */
1549
+
1429
1550
  /**
1430
1551
  * Inquiry refund request parameters.
1431
1552
  */
1432
1553
  interface InquiryRefundParams {
1433
1554
  refundRequestId?: string;
1434
1555
  acquiringRefundOrderId?: string;
1556
+ merchantInfo?: MerchantInfo;
1435
1557
  [key: string]: unknown;
1436
1558
  }
1437
1559
  /**
1438
1560
  * Inquiry refund response data.
1561
+ * Based on openapi.json AcqOrderRefundInquiry schema.
1439
1562
  */
1440
1563
  interface InquiryRefundData {
1441
1564
  refundRequestId?: string;
1442
1565
  merchantRefundOrderId?: string;
1443
1566
  acquiringOrderId?: string;
1444
1567
  acquiringRefundOrderId?: string;
1568
+ origPaymentRequestId?: string;
1445
1569
  refundAmount?: string;
1570
+ refundCurrency?: string;
1446
1571
  refundStatus?: RefundStatus;
1447
- refundFailedReason?: RefundFailedReason;
1572
+ refundReason?: string;
1573
+ refundRequestedAt?: string;
1574
+ refundUpdatedAt?: string;
1575
+ refundFailedReason?: string;
1576
+ extendInfo?: string;
1448
1577
  [key: string]: unknown;
1449
1578
  }
1450
1579
  /**
1451
1580
  * Refund status enum.
1452
1581
  */
1453
1582
  type RefundStatus = 'REFUND_IN_PROGRESS' | 'ORDER_PARTIALLY_REFUNDED' | 'ORDER_FULLY_REFUNDED' | 'ORDER_REFUND_FAILED';
1454
- /**
1455
- * Refund failed reason enum.
1456
- */
1457
- type RefundFailedReason = 'INSUFFICIENT_BALANCE' | 'ORIGINAL_ORDER_NOT_FOUND' | 'REFUND_AMOUNT_EXCEEDED' | 'SYSTEM_ERROR' | 'OTHER';
1458
1583
 
1459
1584
  /**
1460
1585
  * Refund resource for querying refund status.
@@ -1712,13 +1837,13 @@ declare class Waffo {
1712
1837
  * // Setup webhook handler
1713
1838
  * const handler = waffo.webhook()
1714
1839
  * .onPayment((notification) => {
1715
- * console.log('Payment:', notification.orderStatus);
1840
+ * console.log('Payment:', notification.result?.orderStatus);
1716
1841
  * })
1717
1842
  * .onRefund((notification) => {
1718
- * console.log('Refund:', notification.refundStatus);
1843
+ * console.log('Refund:', notification.result?.refundStatus);
1719
1844
  * })
1720
1845
  * .onSubscriptionStatus((notification) => {
1721
- * console.log('Subscription:', notification.subscriptionStatus);
1846
+ * console.log('Subscription:', notification.result?.subscriptionStatus);
1722
1847
  * });
1723
1848
  *
1724
1849
  * // In Express.js route handler
@@ -1841,108 +1966,100 @@ declare class WaffoUnknownStatusError extends Error {
1841
1966
  }
1842
1967
 
1843
1968
  /**
1844
- * RSA cryptographic utilities for signing and verification.
1969
+ * Result of key pair generation.
1970
+ */
1971
+ interface KeyPairResult {
1972
+ /** Base64 encoded PKCS8 private key */
1973
+ privateKey: string;
1974
+ /** Base64 encoded X509 public key */
1975
+ publicKey: string;
1976
+ }
1977
+ /**
1978
+ * Signs data using RSA-SHA256.
1845
1979
  *
1846
- * Uses SHA256withRSA algorithm with 2048-bit key size.
1980
+ * @param data - The data to sign (UTF-8 string)
1981
+ * @param base64PrivateKey - Base64 encoded PKCS8 private key
1982
+ * @returns Base64 encoded signature
1983
+ * @throws WaffoError if signing fails (S0003)
1847
1984
  *
1848
- * **Key Formats:**
1849
- * - Private Key: PKCS#8 DER encoded, Base64 string
1850
- * - Public Key: X.509 SubjectPublicKeyInfo DER encoded, Base64 string
1985
+ * @example
1986
+ * ```typescript
1987
+ * const signature = sign('{"amount":"100.00"}', privateKey);
1988
+ * ```
1989
+ */
1990
+ declare function sign(data: string, base64PrivateKey: string): string;
1991
+ /**
1992
+ * Verifies a signature using RSA-SHA256.
1851
1993
  *
1852
- * **Security Best Practices:**
1994
+ * @param data - The original data (UTF-8 string)
1995
+ * @param base64Signature - Base64 encoded signature
1996
+ * @param base64PublicKey - Base64 encoded X509 public key
1997
+ * @returns true if signature is valid, false otherwise
1853
1998
  *
1854
- * When verifying Waffo's response signature fails:
1855
- * 1. Stop sending new transactions to Waffo until the issue is resolved
1856
- * 2. Investigate the cause and contact Waffo support
1857
- * 3. Note: Waffo may have already processed your request, but you failed to
1858
- * process the response due to signature verification failure
1999
+ * @example
2000
+ * ```typescript
2001
+ * const isValid = verify(responseBody, signature, waffoPublicKey);
2002
+ * if (!isValid) {
2003
+ * // Handle signature verification failure
2004
+ * }
2005
+ * ```
1859
2006
  */
1860
- declare namespace RsaUtils {
1861
- /**
1862
- * Result of key pair generation.
1863
- */
1864
- interface KeyPairResult {
1865
- /** Base64 encoded PKCS8 private key */
1866
- privateKey: string;
1867
- /** Base64 encoded X509 public key */
1868
- publicKey: string;
1869
- }
1870
- /**
1871
- * Signs data using RSA-SHA256.
1872
- *
1873
- * @param data - The data to sign (UTF-8 string)
1874
- * @param base64PrivateKey - Base64 encoded PKCS8 private key
1875
- * @returns Base64 encoded signature
1876
- * @throws WaffoError if signing fails (S0003)
1877
- *
1878
- * @example
1879
- * ```typescript
1880
- * const signature = RsaUtils.sign('{"amount":"100.00"}', privateKey);
1881
- * ```
1882
- */
1883
- function sign(data: string, base64PrivateKey: string): string;
1884
- /**
1885
- * Verifies a signature using RSA-SHA256.
1886
- *
1887
- * @param data - The original data (UTF-8 string)
1888
- * @param base64Signature - Base64 encoded signature
1889
- * @param base64PublicKey - Base64 encoded X509 public key
1890
- * @returns true if signature is valid, false otherwise
1891
- *
1892
- * @example
1893
- * ```typescript
1894
- * const isValid = RsaUtils.verify(responseBody, signature, waffoPublicKey);
1895
- * if (!isValid) {
1896
- * // Handle signature verification failure
1897
- * }
1898
- * ```
1899
- */
1900
- function verify(data: string, base64Signature: string, base64PublicKey: string): boolean;
1901
- /**
1902
- * Validates a Base64 encoded PKCS8 private key.
1903
- *
1904
- * This method attempts to parse the key to ensure it's a valid RSA private key.
1905
- * Use this at startup to fail fast if the private key is invalid.
1906
- *
1907
- * @param base64PrivateKey - Base64 encoded PKCS8 private key
1908
- * @throws WaffoError if the key is invalid (S0007)
1909
- *
1910
- * @example
1911
- * ```typescript
1912
- * // Validate at initialization
1913
- * RsaUtils.validatePrivateKey(config.privateKey);
1914
- * ```
1915
- */
1916
- function validatePrivateKey(base64PrivateKey: string): void;
1917
- /**
1918
- * Validates a Base64 encoded X509 public key.
1919
- *
1920
- * This method attempts to parse the key to ensure it's a valid RSA public key.
1921
- * Use this at startup to fail fast if the public key is invalid.
1922
- *
1923
- * @param base64PublicKey - Base64 encoded X509 public key
1924
- * @throws WaffoError if the key is invalid (S0002)
1925
- *
1926
- * @example
1927
- * ```typescript
1928
- * // Validate at initialization
1929
- * RsaUtils.validatePublicKey(config.waffoPublicKey);
1930
- * ```
1931
- */
1932
- function validatePublicKey(base64PublicKey: string): void;
1933
- /**
1934
- * Generates a new RSA key pair for testing or merchant key generation.
1935
- *
1936
- * @returns A new KeyPairResult containing Base64 encoded keys
1937
- *
1938
- * @example
1939
- * ```typescript
1940
- * const keyPair = RsaUtils.generateKeyPair();
1941
- * console.log('Private Key:', keyPair.privateKey);
1942
- * console.log('Public Key:', keyPair.publicKey);
1943
- * ```
1944
- */
1945
- function generateKeyPair(): KeyPairResult;
1946
- }
2007
+ declare function verify(data: string, base64Signature: string, base64PublicKey: string): boolean;
2008
+ /**
2009
+ * Validates a Base64 encoded PKCS8 private key.
2010
+ *
2011
+ * This method attempts to parse the key to ensure it's a valid RSA private key.
2012
+ * Use this at startup to fail fast if the private key is invalid.
2013
+ *
2014
+ * @param base64PrivateKey - Base64 encoded PKCS8 private key
2015
+ * @throws WaffoError if the key is invalid (S0007)
2016
+ *
2017
+ * @example
2018
+ * ```typescript
2019
+ * // Validate at initialization
2020
+ * validatePrivateKey(config.privateKey);
2021
+ * ```
2022
+ */
2023
+ declare function validatePrivateKey(base64PrivateKey: string): void;
2024
+ /**
2025
+ * Validates a Base64 encoded X509 public key.
2026
+ *
2027
+ * This method attempts to parse the key to ensure it's a valid RSA public key.
2028
+ * Use this at startup to fail fast if the public key is invalid.
2029
+ *
2030
+ * @param base64PublicKey - Base64 encoded X509 public key
2031
+ * @throws WaffoError if the key is invalid (S0002)
2032
+ *
2033
+ * @example
2034
+ * ```typescript
2035
+ * // Validate at initialization
2036
+ * validatePublicKey(config.waffoPublicKey);
2037
+ * ```
2038
+ */
2039
+ declare function validatePublicKey(base64PublicKey: string): void;
2040
+ /**
2041
+ * Generates a new RSA key pair for testing or merchant key generation.
2042
+ *
2043
+ * @returns A new KeyPairResult containing Base64 encoded keys
2044
+ *
2045
+ * @example
2046
+ * ```typescript
2047
+ * const keyPair = generateKeyPair();
2048
+ * console.log('Private Key:', keyPair.privateKey);
2049
+ * console.log('Public Key:', keyPair.publicKey);
2050
+ * ```
2051
+ */
2052
+ declare function generateKeyPair(): KeyPairResult;
2053
+ /**
2054
+ * RsaUtils namespace for backward compatibility.
2055
+ * @deprecated Use direct function imports instead.
2056
+ */
2057
+ declare const RsaUtils: {
2058
+ sign: typeof sign;
2059
+ verify: typeof verify;
2060
+ validatePrivateKey: typeof validatePrivateKey;
2061
+ validatePublicKey: typeof validatePublicKey;
2062
+ generateKeyPair: typeof generateKeyPair;
2063
+ };
1947
2064
 
1948
- export { type AddressInfo, ApiResponse, type BaseNotification, type CancelOrderData, type CancelOrderParams, type CancelSubscriptionData, type CancelSubscriptionParams, type CaptureOrderData, type CaptureOrderParams, type CardInfo, type CreateOrderData, type CreateOrderParams, type CreateSubscriptionData, type CreateSubscriptionParams, Environment, EnvironmentBaseUrl, type GoodsInfo, type HttpRequest, type HttpResponse, type HttpTransport, type InquiryMerchantConfigData, type InquiryMerchantConfigParams, type InquiryOrderData, type InquiryOrderParams, type InquiryPayMethodConfigData, type InquiryPayMethodConfigParams, type InquiryRefundData, type InquiryRefundParams, type InquirySubscriptionData, type InquirySubscriptionParams, type ManageSubscriptionData, type ManageSubscriptionParams, MerchantConfigResource, type MerchantInfo, OrderResource, type OrderStatus, PayMethodConfigResource, type PayMethodInfo, type PaymentInfo, type PaymentNotification, type PeriodType, type ProductInfo, type RefundFailedReason, type RefundNotification, type RefundOrderData, type RefundOrderParams, RefundResource, type RefundStatus$1 as RefundStatus, type RefundUserInfo, type RequestOptions, type RiskData, RsaUtils, type SubscriptionManageAction, type SubscriptionMerchantInfo, type SubscriptionPaymentInfo, type SubscriptionPaymentNotification, type SubscriptionPeriodChangedNotification, SubscriptionResource, type SubscriptionStatus, type SubscriptionStatusNotification, type SubscriptionUserInfo, type UserInfo, Waffo, type WaffoConfig, WaffoConfigDefaults, WaffoError, WaffoErrorCode, WaffoHttpClient, type WaffoLogger, WaffoUnknownStatusError, WebhookEventType, WebhookHandler, type WebhookResult };
2065
+ export { type AddressInfo, ApiResponse, type BaseNotification, type CancelOrderData, type CancelOrderParams, type CancelSubscriptionData, type CancelSubscriptionParams, type CaptureOrderData, type CaptureOrderParams, type CardInfo, type CreateOrderData, type CreateOrderParams, type CreateSubscriptionData, type CreateSubscriptionParams, Environment, EnvironmentBaseUrl, type GoodsInfo, type HttpRequest, type HttpResponse, type HttpTransport, type InquiryMerchantConfigData, type InquiryMerchantConfigParams, type InquiryOrderData, type InquiryOrderParams, type InquiryPayMethodConfigData, type InquiryPayMethodConfigParams, type InquiryRefundData, type InquiryRefundParams, type InquirySubscriptionData, type InquirySubscriptionParams, type ManageSubscriptionData, type ManageSubscriptionParams, MerchantConfigResource, type MerchantInfo, OrderResource, type OrderStatus, PayMethodConfigResource, type PayMethodInfo, type PaymentInfo, type PaymentNotification, type PaymentNotificationResult, type PeriodType, type ProductInfo, type RefundNotification, type RefundNotificationResult, type RefundOrderData, type RefundOrderParams, RefundResource, type RefundStatus$1 as RefundStatus, type RefundUserInfo, type RequestOptions, type RiskData, RsaUtils, type SubscriptionManageAction, type SubscriptionMerchantInfo, type SubscriptionNotificationResult, type SubscriptionPaymentInfo, type SubscriptionPeriodChangedNotification, SubscriptionResource, type SubscriptionStatus, type SubscriptionStatusNotification, type SubscriptionUserInfo, type UserInfo, Waffo, type WaffoConfig, WaffoConfigDefaults, WaffoError, WaffoErrorCode, WaffoHttpClient, type WaffoLogger, WaffoUnknownStatusError, WebhookEventType, WebhookHandler, type WebhookResult };