increase 0.24.3 → 0.26.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/index.d.mts +12 -5
  3. package/index.d.ts +12 -5
  4. package/index.d.ts.map +1 -1
  5. package/index.js +7 -3
  6. package/index.js.map +1 -1
  7. package/index.mjs +7 -3
  8. package/index.mjs.map +1 -1
  9. package/package.json +1 -1
  10. package/resources/ach-prenotifications.d.ts +7 -2
  11. package/resources/ach-prenotifications.d.ts.map +1 -1
  12. package/resources/ach-prenotifications.js.map +1 -1
  13. package/resources/ach-prenotifications.mjs.map +1 -1
  14. package/resources/ach-transfers.d.ts +7 -2
  15. package/resources/ach-transfers.d.ts.map +1 -1
  16. package/resources/ach-transfers.js.map +1 -1
  17. package/resources/ach-transfers.mjs.map +1 -1
  18. package/resources/cards.d.ts +5 -2
  19. package/resources/cards.d.ts.map +1 -1
  20. package/resources/cards.js.map +1 -1
  21. package/resources/cards.mjs.map +1 -1
  22. package/resources/declined-transactions.d.ts +2 -70
  23. package/resources/declined-transactions.d.ts.map +1 -1
  24. package/resources/declined-transactions.js.map +1 -1
  25. package/resources/declined-transactions.mjs.map +1 -1
  26. package/resources/event-subscriptions.d.ts +18 -2
  27. package/resources/event-subscriptions.d.ts.map +1 -1
  28. package/resources/event-subscriptions.js.map +1 -1
  29. package/resources/event-subscriptions.mjs.map +1 -1
  30. package/resources/events.d.ts +10 -2
  31. package/resources/events.d.ts.map +1 -1
  32. package/resources/events.js.map +1 -1
  33. package/resources/events.mjs.map +1 -1
  34. package/resources/inbound-ach-transfers.d.ts +1 -1
  35. package/resources/inbound-wire-transfers.d.ts +103 -0
  36. package/resources/inbound-wire-transfers.d.ts.map +1 -0
  37. package/resources/inbound-wire-transfers.js +17 -0
  38. package/resources/inbound-wire-transfers.js.map +1 -0
  39. package/resources/inbound-wire-transfers.mjs +13 -0
  40. package/resources/inbound-wire-transfers.mjs.map +1 -0
  41. package/resources/index.d.ts +3 -1
  42. package/resources/index.d.ts.map +1 -1
  43. package/resources/index.js +7 -3
  44. package/resources/index.js.map +1 -1
  45. package/resources/index.mjs +3 -1
  46. package/resources/index.mjs.map +1 -1
  47. package/resources/oauth-connections.d.ts +14 -13
  48. package/resources/oauth-connections.d.ts.map +1 -1
  49. package/resources/oauth-connections.js +10 -10
  50. package/resources/oauth-connections.js.map +1 -1
  51. package/resources/oauth-connections.mjs +7 -7
  52. package/resources/oauth-connections.mjs.map +1 -1
  53. package/resources/oauth-tokens.d.ts +65 -0
  54. package/resources/oauth-tokens.d.ts.map +1 -0
  55. package/resources/oauth-tokens.js +17 -0
  56. package/resources/oauth-tokens.js.map +1 -0
  57. package/resources/oauth-tokens.mjs +13 -0
  58. package/resources/oauth-tokens.mjs.map +1 -0
  59. package/resources/physical-cards.d.ts +4 -0
  60. package/resources/physical-cards.d.ts.map +1 -1
  61. package/resources/physical-cards.js.map +1 -1
  62. package/resources/physical-cards.mjs.map +1 -1
  63. package/resources/simulations/ach-transfers.d.ts +13 -77
  64. package/resources/simulations/ach-transfers.d.ts.map +1 -1
  65. package/resources/simulations/ach-transfers.js.map +1 -1
  66. package/resources/simulations/ach-transfers.mjs.map +1 -1
  67. package/resources/simulations/cards.d.ts +2 -70
  68. package/resources/simulations/cards.d.ts.map +1 -1
  69. package/resources/simulations/cards.js.map +1 -1
  70. package/resources/simulations/cards.mjs.map +1 -1
  71. package/resources/simulations/interest-payments.d.ts +10 -6
  72. package/resources/simulations/interest-payments.d.ts.map +1 -1
  73. package/resources/simulations/interest-payments.js.map +1 -1
  74. package/resources/simulations/interest-payments.mjs.map +1 -1
  75. package/resources/simulations/real-time-payments-transfers.d.ts +12 -76
  76. package/resources/simulations/real-time-payments-transfers.d.ts.map +1 -1
  77. package/resources/simulations/real-time-payments-transfers.js.map +1 -1
  78. package/resources/simulations/real-time-payments-transfers.mjs.map +1 -1
  79. package/resources/simulations/wire-transfers.d.ts +10 -6
  80. package/resources/simulations/wire-transfers.d.ts.map +1 -1
  81. package/resources/simulations/wire-transfers.js.map +1 -1
  82. package/resources/simulations/wire-transfers.mjs.map +1 -1
  83. package/resources/transactions.d.ts +10 -6
  84. package/resources/transactions.d.ts.map +1 -1
  85. package/resources/transactions.js.map +1 -1
  86. package/resources/transactions.mjs.map +1 -1
  87. package/resources/webhooks.d.ts +18 -0
  88. package/resources/webhooks.d.ts.map +1 -1
  89. package/resources/webhooks.js +73 -0
  90. package/resources/webhooks.js.map +1 -1
  91. package/resources/webhooks.mjs +73 -0
  92. package/resources/webhooks.mjs.map +1 -1
  93. package/resources/wire-drawdown-requests.d.ts +40 -0
  94. package/resources/wire-drawdown-requests.d.ts.map +1 -1
  95. package/resources/wire-drawdown-requests.js.map +1 -1
  96. package/resources/wire-drawdown-requests.mjs.map +1 -1
  97. package/resources/wire-transfers.d.ts +36 -0
  98. package/resources/wire-transfers.d.ts.map +1 -1
  99. package/resources/wire-transfers.js.map +1 -1
  100. package/resources/wire-transfers.mjs.map +1 -1
  101. package/src/index.ts +14 -5
  102. package/src/resources/ach-prenotifications.ts +7 -2
  103. package/src/resources/ach-transfers.ts +7 -2
  104. package/src/resources/cards.ts +6 -2
  105. package/src/resources/declined-transactions.ts +2 -86
  106. package/src/resources/event-subscriptions.ts +24 -0
  107. package/src/resources/events.ts +16 -0
  108. package/src/resources/inbound-ach-transfers.ts +1 -1
  109. package/src/resources/inbound-wire-transfers.ts +131 -0
  110. package/src/resources/index.ts +6 -4
  111. package/src/resources/oauth-connections.ts +18 -17
  112. package/src/resources/oauth-tokens.ts +78 -0
  113. package/src/resources/physical-cards.ts +5 -0
  114. package/src/resources/simulations/ach-transfers.ts +14 -93
  115. package/src/resources/simulations/cards.ts +2 -86
  116. package/src/resources/simulations/interest-payments.ts +11 -6
  117. package/src/resources/simulations/real-time-payments-transfers.ts +13 -92
  118. package/src/resources/simulations/wire-transfers.ts +11 -6
  119. package/src/resources/transactions.ts +11 -6
  120. package/src/resources/webhooks.ts +107 -1
  121. package/src/resources/wire-drawdown-requests.ts +48 -0
  122. package/src/resources/wire-transfers.ts +44 -0
  123. package/src/version.ts +1 -1
  124. package/version.d.ts +1 -1
  125. package/version.js +1 -1
  126. package/version.mjs +1 -1
@@ -1142,93 +1142,9 @@ export namespace ACHTransferSimulation {
1142
1142
  */
1143
1143
  export interface WireDecline {
1144
1144
  /**
1145
- * The declined amount in the minor unit of the destination account currency. For
1146
- * dollars, for example, this is cents.
1147
- */
1148
- amount: number;
1149
-
1150
- /**
1151
- * A free-form address field set by the sender.
1152
- */
1153
- beneficiary_address_line1: string | null;
1154
-
1155
- /**
1156
- * A free-form address field set by the sender.
1145
+ * The identifier of the Inbound Wire Transfer that was declined.
1157
1146
  */
1158
- beneficiary_address_line2: string | null;
1159
-
1160
- /**
1161
- * A free-form address field set by the sender.
1162
- */
1163
- beneficiary_address_line3: string | null;
1164
-
1165
- /**
1166
- * A name set by the sender.
1167
- */
1168
- beneficiary_name: string | null;
1169
-
1170
- /**
1171
- * A free-form reference string set by the sender, to help identify the transfer.
1172
- */
1173
- beneficiary_reference: string | null;
1174
-
1175
- /**
1176
- * An Increase-constructed description of the declined transaction.
1177
- */
1178
- description: string;
1179
-
1180
- /**
1181
- * A unique identifier available to the originating and receiving banks, commonly
1182
- * abbreviated as IMAD. It is created when the wire is submitted to the Fedwire
1183
- * service and is helpful when debugging wires with the originating bank.
1184
- */
1185
- input_message_accountability_data: string | null;
1186
-
1187
- /**
1188
- * The address of the wire originator, set by the sending bank.
1189
- */
1190
- originator_address_line1: string | null;
1191
-
1192
- /**
1193
- * The address of the wire originator, set by the sending bank.
1194
- */
1195
- originator_address_line2: string | null;
1196
-
1197
- /**
1198
- * The address of the wire originator, set by the sending bank.
1199
- */
1200
- originator_address_line3: string | null;
1201
-
1202
- /**
1203
- * The originator of the wire, set by the sending bank.
1204
- */
1205
- originator_name: string | null;
1206
-
1207
- /**
1208
- * The American Banking Association (ABA) routing number of the bank originating
1209
- * the transfer.
1210
- */
1211
- originator_routing_number: string | null;
1212
-
1213
- /**
1214
- * A free-form message set by the wire originator.
1215
- */
1216
- originator_to_beneficiary_information_line1: string | null;
1217
-
1218
- /**
1219
- * A free-form message set by the wire originator.
1220
- */
1221
- originator_to_beneficiary_information_line2: string | null;
1222
-
1223
- /**
1224
- * A free-form message set by the wire originator.
1225
- */
1226
- originator_to_beneficiary_information_line3: string | null;
1227
-
1228
- /**
1229
- * A free-form message set by the wire originator.
1230
- */
1231
- originator_to_beneficiary_information_line4: string | null;
1147
+ inbound_wire_transfer_id: string;
1232
1148
 
1233
1149
  /**
1234
1150
  * Why the wire transfer was declined.
@@ -1435,8 +1351,8 @@ export namespace ACHTransferSimulation {
1435
1351
  * be under the `inbound_wire_drawdown_payment` object.
1436
1352
  * - `inbound_wire_reversal` - Inbound Wire Reversal: details will be under the
1437
1353
  * `inbound_wire_reversal` object.
1438
- * - `inbound_wire_transfer` - Inbound Wire Transfer: details will be under the
1439
- * `inbound_wire_transfer` object.
1354
+ * - `inbound_wire_transfer` - Inbound Wire Transfer Intention: details will be
1355
+ * under the `inbound_wire_transfer` object.
1440
1356
  * - `interest_payment` - Interest Payment: details will be under the
1441
1357
  * `interest_payment` object.
1442
1358
  * - `internal_source` - Internal Source: details will be under the
@@ -1567,8 +1483,8 @@ export namespace ACHTransferSimulation {
1567
1483
  inbound_wire_reversal: Source.InboundWireReversal | null;
1568
1484
 
1569
1485
  /**
1570
- * An Inbound Wire Transfer object. This field will be present in the JSON response
1571
- * if and only if `category` is equal to `inbound_wire_transfer`.
1486
+ * An Inbound Wire Transfer Intention object. This field will be present in the
1487
+ * JSON response if and only if `category` is equal to `inbound_wire_transfer`.
1572
1488
  */
1573
1489
  inbound_wire_transfer: Source.InboundWireTransfer | null;
1574
1490
 
@@ -4394,8 +4310,8 @@ export namespace ACHTransferSimulation {
4394
4310
  }
4395
4311
 
4396
4312
  /**
4397
- * An Inbound Wire Transfer object. This field will be present in the JSON response
4398
- * if and only if `category` is equal to `inbound_wire_transfer`.
4313
+ * An Inbound Wire Transfer Intention object. This field will be present in the
4314
+ * JSON response if and only if `category` is equal to `inbound_wire_transfer`.
4399
4315
  */
4400
4316
  export interface InboundWireTransfer {
4401
4317
  /**
@@ -4490,6 +4406,11 @@ export namespace ACHTransferSimulation {
4490
4406
  * A free-form message set by the wire originator.
4491
4407
  */
4492
4408
  originator_to_beneficiary_information_line4: string | null;
4409
+
4410
+ /**
4411
+ * The ID of the Inbound Wire Transfer object that resulted in this Transaction.
4412
+ */
4413
+ transfer_id: string;
4493
4414
  }
4494
4415
 
4495
4416
  /**
@@ -4682,7 +4603,7 @@ export namespace ACHTransferSimulation {
4682
4603
  */
4683
4604
  export interface Transfer {
4684
4605
  /**
4685
- * The inbound ach transfer's identifier.
4606
+ * The inbound ACH transfer's identifier.
4686
4607
  */
4687
4608
  id: string;
4688
4609
 
@@ -1123,93 +1123,9 @@ export namespace CardAuthorizationSimulation {
1123
1123
  */
1124
1124
  export interface WireDecline {
1125
1125
  /**
1126
- * The declined amount in the minor unit of the destination account currency. For
1127
- * dollars, for example, this is cents.
1128
- */
1129
- amount: number;
1130
-
1131
- /**
1132
- * A free-form address field set by the sender.
1133
- */
1134
- beneficiary_address_line1: string | null;
1135
-
1136
- /**
1137
- * A free-form address field set by the sender.
1138
- */
1139
- beneficiary_address_line2: string | null;
1140
-
1141
- /**
1142
- * A free-form address field set by the sender.
1143
- */
1144
- beneficiary_address_line3: string | null;
1145
-
1146
- /**
1147
- * A name set by the sender.
1148
- */
1149
- beneficiary_name: string | null;
1150
-
1151
- /**
1152
- * A free-form reference string set by the sender, to help identify the transfer.
1153
- */
1154
- beneficiary_reference: string | null;
1155
-
1156
- /**
1157
- * An Increase-constructed description of the declined transaction.
1158
- */
1159
- description: string;
1160
-
1161
- /**
1162
- * A unique identifier available to the originating and receiving banks, commonly
1163
- * abbreviated as IMAD. It is created when the wire is submitted to the Fedwire
1164
- * service and is helpful when debugging wires with the originating bank.
1165
- */
1166
- input_message_accountability_data: string | null;
1167
-
1168
- /**
1169
- * The address of the wire originator, set by the sending bank.
1170
- */
1171
- originator_address_line1: string | null;
1172
-
1173
- /**
1174
- * The address of the wire originator, set by the sending bank.
1175
- */
1176
- originator_address_line2: string | null;
1177
-
1178
- /**
1179
- * The address of the wire originator, set by the sending bank.
1180
- */
1181
- originator_address_line3: string | null;
1182
-
1183
- /**
1184
- * The originator of the wire, set by the sending bank.
1185
- */
1186
- originator_name: string | null;
1187
-
1188
- /**
1189
- * The American Banking Association (ABA) routing number of the bank originating
1190
- * the transfer.
1191
- */
1192
- originator_routing_number: string | null;
1193
-
1194
- /**
1195
- * A free-form message set by the wire originator.
1196
- */
1197
- originator_to_beneficiary_information_line1: string | null;
1198
-
1199
- /**
1200
- * A free-form message set by the wire originator.
1201
- */
1202
- originator_to_beneficiary_information_line2: string | null;
1203
-
1204
- /**
1205
- * A free-form message set by the wire originator.
1206
- */
1207
- originator_to_beneficiary_information_line3: string | null;
1208
-
1209
- /**
1210
- * A free-form message set by the wire originator.
1126
+ * The identifier of the Inbound Wire Transfer that was declined.
1211
1127
  */
1212
- originator_to_beneficiary_information_line4: string | null;
1128
+ inbound_wire_transfer_id: string;
1213
1129
 
1214
1130
  /**
1215
1131
  * Why the wire transfer was declined.
@@ -217,8 +217,8 @@ export namespace InterestPaymentSimulationResult {
217
217
  * be under the `inbound_wire_drawdown_payment` object.
218
218
  * - `inbound_wire_reversal` - Inbound Wire Reversal: details will be under the
219
219
  * `inbound_wire_reversal` object.
220
- * - `inbound_wire_transfer` - Inbound Wire Transfer: details will be under the
221
- * `inbound_wire_transfer` object.
220
+ * - `inbound_wire_transfer` - Inbound Wire Transfer Intention: details will be
221
+ * under the `inbound_wire_transfer` object.
222
222
  * - `interest_payment` - Interest Payment: details will be under the
223
223
  * `interest_payment` object.
224
224
  * - `internal_source` - Internal Source: details will be under the
@@ -349,8 +349,8 @@ export namespace InterestPaymentSimulationResult {
349
349
  inbound_wire_reversal: Source.InboundWireReversal | null;
350
350
 
351
351
  /**
352
- * An Inbound Wire Transfer object. This field will be present in the JSON response
353
- * if and only if `category` is equal to `inbound_wire_transfer`.
352
+ * An Inbound Wire Transfer Intention object. This field will be present in the
353
+ * JSON response if and only if `category` is equal to `inbound_wire_transfer`.
354
354
  */
355
355
  inbound_wire_transfer: Source.InboundWireTransfer | null;
356
356
 
@@ -3176,8 +3176,8 @@ export namespace InterestPaymentSimulationResult {
3176
3176
  }
3177
3177
 
3178
3178
  /**
3179
- * An Inbound Wire Transfer object. This field will be present in the JSON response
3180
- * if and only if `category` is equal to `inbound_wire_transfer`.
3179
+ * An Inbound Wire Transfer Intention object. This field will be present in the
3180
+ * JSON response if and only if `category` is equal to `inbound_wire_transfer`.
3181
3181
  */
3182
3182
  export interface InboundWireTransfer {
3183
3183
  /**
@@ -3272,6 +3272,11 @@ export namespace InterestPaymentSimulationResult {
3272
3272
  * A free-form message set by the wire originator.
3273
3273
  */
3274
3274
  originator_to_beneficiary_information_line4: string | null;
3275
+
3276
+ /**
3277
+ * The ID of the Inbound Wire Transfer object that resulted in this Transaction.
3278
+ */
3279
+ transfer_id: string;
3275
3280
  }
3276
3281
 
3277
3282
  /**
@@ -1122,93 +1122,9 @@ export namespace InboundRealTimePaymentsTransferSimulationResult {
1122
1122
  */
1123
1123
  export interface WireDecline {
1124
1124
  /**
1125
- * The declined amount in the minor unit of the destination account currency. For
1126
- * dollars, for example, this is cents.
1127
- */
1128
- amount: number;
1129
-
1130
- /**
1131
- * A free-form address field set by the sender.
1132
- */
1133
- beneficiary_address_line1: string | null;
1134
-
1135
- /**
1136
- * A free-form address field set by the sender.
1125
+ * The identifier of the Inbound Wire Transfer that was declined.
1137
1126
  */
1138
- beneficiary_address_line2: string | null;
1139
-
1140
- /**
1141
- * A free-form address field set by the sender.
1142
- */
1143
- beneficiary_address_line3: string | null;
1144
-
1145
- /**
1146
- * A name set by the sender.
1147
- */
1148
- beneficiary_name: string | null;
1149
-
1150
- /**
1151
- * A free-form reference string set by the sender, to help identify the transfer.
1152
- */
1153
- beneficiary_reference: string | null;
1154
-
1155
- /**
1156
- * An Increase-constructed description of the declined transaction.
1157
- */
1158
- description: string;
1159
-
1160
- /**
1161
- * A unique identifier available to the originating and receiving banks, commonly
1162
- * abbreviated as IMAD. It is created when the wire is submitted to the Fedwire
1163
- * service and is helpful when debugging wires with the originating bank.
1164
- */
1165
- input_message_accountability_data: string | null;
1166
-
1167
- /**
1168
- * The address of the wire originator, set by the sending bank.
1169
- */
1170
- originator_address_line1: string | null;
1171
-
1172
- /**
1173
- * The address of the wire originator, set by the sending bank.
1174
- */
1175
- originator_address_line2: string | null;
1176
-
1177
- /**
1178
- * The address of the wire originator, set by the sending bank.
1179
- */
1180
- originator_address_line3: string | null;
1181
-
1182
- /**
1183
- * The originator of the wire, set by the sending bank.
1184
- */
1185
- originator_name: string | null;
1186
-
1187
- /**
1188
- * The American Banking Association (ABA) routing number of the bank originating
1189
- * the transfer.
1190
- */
1191
- originator_routing_number: string | null;
1192
-
1193
- /**
1194
- * A free-form message set by the wire originator.
1195
- */
1196
- originator_to_beneficiary_information_line1: string | null;
1197
-
1198
- /**
1199
- * A free-form message set by the wire originator.
1200
- */
1201
- originator_to_beneficiary_information_line2: string | null;
1202
-
1203
- /**
1204
- * A free-form message set by the wire originator.
1205
- */
1206
- originator_to_beneficiary_information_line3: string | null;
1207
-
1208
- /**
1209
- * A free-form message set by the wire originator.
1210
- */
1211
- originator_to_beneficiary_information_line4: string | null;
1127
+ inbound_wire_transfer_id: string;
1212
1128
 
1213
1129
  /**
1214
1130
  * Why the wire transfer was declined.
@@ -1415,8 +1331,8 @@ export namespace InboundRealTimePaymentsTransferSimulationResult {
1415
1331
  * be under the `inbound_wire_drawdown_payment` object.
1416
1332
  * - `inbound_wire_reversal` - Inbound Wire Reversal: details will be under the
1417
1333
  * `inbound_wire_reversal` object.
1418
- * - `inbound_wire_transfer` - Inbound Wire Transfer: details will be under the
1419
- * `inbound_wire_transfer` object.
1334
+ * - `inbound_wire_transfer` - Inbound Wire Transfer Intention: details will be
1335
+ * under the `inbound_wire_transfer` object.
1420
1336
  * - `interest_payment` - Interest Payment: details will be under the
1421
1337
  * `interest_payment` object.
1422
1338
  * - `internal_source` - Internal Source: details will be under the
@@ -1547,8 +1463,8 @@ export namespace InboundRealTimePaymentsTransferSimulationResult {
1547
1463
  inbound_wire_reversal: Source.InboundWireReversal | null;
1548
1464
 
1549
1465
  /**
1550
- * An Inbound Wire Transfer object. This field will be present in the JSON response
1551
- * if and only if `category` is equal to `inbound_wire_transfer`.
1466
+ * An Inbound Wire Transfer Intention object. This field will be present in the
1467
+ * JSON response if and only if `category` is equal to `inbound_wire_transfer`.
1552
1468
  */
1553
1469
  inbound_wire_transfer: Source.InboundWireTransfer | null;
1554
1470
 
@@ -4374,8 +4290,8 @@ export namespace InboundRealTimePaymentsTransferSimulationResult {
4374
4290
  }
4375
4291
 
4376
4292
  /**
4377
- * An Inbound Wire Transfer object. This field will be present in the JSON response
4378
- * if and only if `category` is equal to `inbound_wire_transfer`.
4293
+ * An Inbound Wire Transfer Intention object. This field will be present in the
4294
+ * JSON response if and only if `category` is equal to `inbound_wire_transfer`.
4379
4295
  */
4380
4296
  export interface InboundWireTransfer {
4381
4297
  /**
@@ -4470,6 +4386,11 @@ export namespace InboundRealTimePaymentsTransferSimulationResult {
4470
4386
  * A free-form message set by the wire originator.
4471
4387
  */
4472
4388
  originator_to_beneficiary_information_line4: string | null;
4389
+
4390
+ /**
4391
+ * The ID of the Inbound Wire Transfer object that resulted in this Transaction.
4392
+ */
4393
+ transfer_id: string;
4473
4394
  }
4474
4395
 
4475
4396
  /**
@@ -218,8 +218,8 @@ export namespace WireTransferSimulation {
218
218
  * be under the `inbound_wire_drawdown_payment` object.
219
219
  * - `inbound_wire_reversal` - Inbound Wire Reversal: details will be under the
220
220
  * `inbound_wire_reversal` object.
221
- * - `inbound_wire_transfer` - Inbound Wire Transfer: details will be under the
222
- * `inbound_wire_transfer` object.
221
+ * - `inbound_wire_transfer` - Inbound Wire Transfer Intention: details will be
222
+ * under the `inbound_wire_transfer` object.
223
223
  * - `interest_payment` - Interest Payment: details will be under the
224
224
  * `interest_payment` object.
225
225
  * - `internal_source` - Internal Source: details will be under the
@@ -350,8 +350,8 @@ export namespace WireTransferSimulation {
350
350
  inbound_wire_reversal: Source.InboundWireReversal | null;
351
351
 
352
352
  /**
353
- * An Inbound Wire Transfer object. This field will be present in the JSON response
354
- * if and only if `category` is equal to `inbound_wire_transfer`.
353
+ * An Inbound Wire Transfer Intention object. This field will be present in the
354
+ * JSON response if and only if `category` is equal to `inbound_wire_transfer`.
355
355
  */
356
356
  inbound_wire_transfer: Source.InboundWireTransfer | null;
357
357
 
@@ -3177,8 +3177,8 @@ export namespace WireTransferSimulation {
3177
3177
  }
3178
3178
 
3179
3179
  /**
3180
- * An Inbound Wire Transfer object. This field will be present in the JSON response
3181
- * if and only if `category` is equal to `inbound_wire_transfer`.
3180
+ * An Inbound Wire Transfer Intention object. This field will be present in the
3181
+ * JSON response if and only if `category` is equal to `inbound_wire_transfer`.
3182
3182
  */
3183
3183
  export interface InboundWireTransfer {
3184
3184
  /**
@@ -3273,6 +3273,11 @@ export namespace WireTransferSimulation {
3273
3273
  * A free-form message set by the wire originator.
3274
3274
  */
3275
3275
  originator_to_beneficiary_information_line4: string | null;
3276
+
3277
+ /**
3278
+ * The ID of the Inbound Wire Transfer object that resulted in this Transaction.
3279
+ */
3280
+ transfer_id: string;
3276
3281
  }
3277
3282
 
3278
3283
  /**
@@ -217,8 +217,8 @@ export namespace Transaction {
217
217
  * be under the `inbound_wire_drawdown_payment` object.
218
218
  * - `inbound_wire_reversal` - Inbound Wire Reversal: details will be under the
219
219
  * `inbound_wire_reversal` object.
220
- * - `inbound_wire_transfer` - Inbound Wire Transfer: details will be under the
221
- * `inbound_wire_transfer` object.
220
+ * - `inbound_wire_transfer` - Inbound Wire Transfer Intention: details will be
221
+ * under the `inbound_wire_transfer` object.
222
222
  * - `interest_payment` - Interest Payment: details will be under the
223
223
  * `interest_payment` object.
224
224
  * - `internal_source` - Internal Source: details will be under the
@@ -349,8 +349,8 @@ export namespace Transaction {
349
349
  inbound_wire_reversal: Source.InboundWireReversal | null;
350
350
 
351
351
  /**
352
- * An Inbound Wire Transfer object. This field will be present in the JSON response
353
- * if and only if `category` is equal to `inbound_wire_transfer`.
352
+ * An Inbound Wire Transfer Intention object. This field will be present in the
353
+ * JSON response if and only if `category` is equal to `inbound_wire_transfer`.
354
354
  */
355
355
  inbound_wire_transfer: Source.InboundWireTransfer | null;
356
356
 
@@ -3176,8 +3176,8 @@ export namespace Transaction {
3176
3176
  }
3177
3177
 
3178
3178
  /**
3179
- * An Inbound Wire Transfer object. This field will be present in the JSON response
3180
- * if and only if `category` is equal to `inbound_wire_transfer`.
3179
+ * An Inbound Wire Transfer Intention object. This field will be present in the
3180
+ * JSON response if and only if `category` is equal to `inbound_wire_transfer`.
3181
3181
  */
3182
3182
  export interface InboundWireTransfer {
3183
3183
  /**
@@ -3272,6 +3272,11 @@ export namespace Transaction {
3272
3272
  * A free-form message set by the wire originator.
3273
3273
  */
3274
3274
  originator_to_beneficiary_information_line4: string | null;
3275
+
3276
+ /**
3277
+ * The ID of the Inbound Wire Transfer object that resulted in this Transaction.
3278
+ */
3279
+ transfer_id: string;
3275
3280
  }
3276
3281
 
3277
3282
  /**
@@ -1,5 +1,111 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
3
  import { APIResource } from "../resource";
4
+ import { HeadersLike } from "../core";
5
+ import { createHmac } from 'crypto';
6
+ import { getRequiredHeader } from "../core";
4
7
 
5
- export class Webhooks extends APIResource {}
8
+ export class Webhooks extends APIResource {
9
+ /**
10
+ * Validates that the given payload was sent by Increase and parses the payload.
11
+ */
12
+ unwrap(
13
+ payload: string,
14
+ headers: HeadersLike,
15
+ secret: string | undefined | null = this._client.webhookSecret,
16
+ ): Record<string, unknown> {
17
+ if (secret) {
18
+ this.verifySignature(payload, headers, secret);
19
+ }
20
+
21
+ return JSON.parse(payload);
22
+ }
23
+
24
+ private validateSecret(secret: string | null | undefined): asserts secret is string {
25
+ if (typeof secret !== 'string') {
26
+ throw new Error(
27
+ `The webhook secret must either be set using the env var, INCREASE_WEBHOOK_SECRET, on the client class, Increase({ webhook_secret: '123' }), or passed to this function`,
28
+ );
29
+ }
30
+ }
31
+
32
+ private signPayload(payload: string, { timestamp, secret }: { timestamp: string; secret: string }) {
33
+ const hmac = createHmac('sha256', secret);
34
+ hmac.update(`${timestamp}.${payload}`);
35
+
36
+ return hmac.digest('hex');
37
+ }
38
+
39
+ /** Make an assertion, if not `true`, then throw. */
40
+ private assert(expr: unknown, msg = ''): asserts expr {
41
+ if (!expr) {
42
+ throw new Error(msg);
43
+ }
44
+ }
45
+
46
+ /** Compare to array buffers or data views in a way that timing based attacks
47
+ * cannot gain information about the platform. */
48
+ private timingSafeEqual(
49
+ a: ArrayBufferView | ArrayBufferLike | DataView,
50
+ b: ArrayBufferView | ArrayBufferLike | DataView,
51
+ ): boolean {
52
+ if (a.byteLength !== b.byteLength) {
53
+ return false;
54
+ }
55
+ if (!(a instanceof DataView)) {
56
+ a = new DataView(ArrayBuffer.isView(a) ? a.buffer : a);
57
+ }
58
+ if (!(b instanceof DataView)) {
59
+ b = new DataView(ArrayBuffer.isView(b) ? b.buffer : b);
60
+ }
61
+ this.assert(a instanceof DataView);
62
+ this.assert(b instanceof DataView);
63
+ const length = a.byteLength;
64
+ let out = 0;
65
+ let i = -1;
66
+ while (++i < length) {
67
+ out |= a.getUint8(i) ^ b.getUint8(i);
68
+ }
69
+ return out === 0;
70
+ }
71
+
72
+ /**
73
+ * Validates whether or not the webhook payload was sent by Increase.
74
+ *
75
+ * An error will be raised if the webhook payload was not sent by Increase.
76
+ */
77
+ verifySignature(
78
+ payload: string,
79
+ headers: HeadersLike,
80
+ secret: string | undefined | null = this._client.webhookSecret,
81
+ ): void {
82
+ this.validateSecret(secret);
83
+
84
+ interface ParsedSignature {
85
+ t?: string;
86
+ v1?: string;
87
+ }
88
+
89
+ const { t: timestamp, v1: signature } = getRequiredHeader(headers, 'Increase-Webhook-Signature')
90
+ .split(',')
91
+ .map((kv) => kv.split('='))
92
+ .reduce((acc, [k, v]) => ({ ...acc, [k as string]: v }), {} as ParsedSignature);
93
+
94
+ if (timestamp === undefined) {
95
+ throw new Error('Unable to verify signature, missing timestamp');
96
+ }
97
+
98
+ if (signature === undefined) {
99
+ throw new Error('Unable to verify signature, missing signature');
100
+ }
101
+
102
+ const expectedSignature = this.signPayload(payload, { timestamp, secret });
103
+
104
+ const textEncoder = new TextEncoder();
105
+ if (this.timingSafeEqual(textEncoder.encode(signature), textEncoder.encode(expectedSignature))) {
106
+ return;
107
+ }
108
+
109
+ throw new Error('The given webhook signature does not match the expected signature');
110
+ }
111
+ }