increase 0.24.3 → 0.25.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 (116) hide show
  1. package/CHANGELOG.md +18 -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/event-subscriptions.d.ts +18 -2
  23. package/resources/event-subscriptions.d.ts.map +1 -1
  24. package/resources/event-subscriptions.js.map +1 -1
  25. package/resources/event-subscriptions.mjs.map +1 -1
  26. package/resources/events.d.ts +10 -2
  27. package/resources/events.d.ts.map +1 -1
  28. package/resources/events.js.map +1 -1
  29. package/resources/events.mjs.map +1 -1
  30. package/resources/inbound-ach-transfers.d.ts +1 -1
  31. package/resources/inbound-wire-transfers.d.ts +107 -0
  32. package/resources/inbound-wire-transfers.d.ts.map +1 -0
  33. package/resources/inbound-wire-transfers.js +17 -0
  34. package/resources/inbound-wire-transfers.js.map +1 -0
  35. package/resources/inbound-wire-transfers.mjs +13 -0
  36. package/resources/inbound-wire-transfers.mjs.map +1 -0
  37. package/resources/index.d.ts +3 -1
  38. package/resources/index.d.ts.map +1 -1
  39. package/resources/index.js +7 -3
  40. package/resources/index.js.map +1 -1
  41. package/resources/index.mjs +3 -1
  42. package/resources/index.mjs.map +1 -1
  43. package/resources/oauth-connections.d.ts +14 -13
  44. package/resources/oauth-connections.d.ts.map +1 -1
  45. package/resources/oauth-connections.js +10 -10
  46. package/resources/oauth-connections.js.map +1 -1
  47. package/resources/oauth-connections.mjs +7 -7
  48. package/resources/oauth-connections.mjs.map +1 -1
  49. package/resources/oauth-tokens.d.ts +65 -0
  50. package/resources/oauth-tokens.d.ts.map +1 -0
  51. package/resources/oauth-tokens.js +17 -0
  52. package/resources/oauth-tokens.js.map +1 -0
  53. package/resources/oauth-tokens.mjs +13 -0
  54. package/resources/oauth-tokens.mjs.map +1 -0
  55. package/resources/physical-cards.d.ts +4 -0
  56. package/resources/physical-cards.d.ts.map +1 -1
  57. package/resources/physical-cards.js.map +1 -1
  58. package/resources/physical-cards.mjs.map +1 -1
  59. package/resources/simulations/ach-transfers.d.ts +14 -1
  60. package/resources/simulations/ach-transfers.d.ts.map +1 -1
  61. package/resources/simulations/ach-transfers.js.map +1 -1
  62. package/resources/simulations/ach-transfers.mjs.map +1 -1
  63. package/resources/simulations/interest-payments.d.ts +13 -0
  64. package/resources/simulations/interest-payments.d.ts.map +1 -1
  65. package/resources/simulations/interest-payments.js.map +1 -1
  66. package/resources/simulations/interest-payments.mjs.map +1 -1
  67. package/resources/simulations/real-time-payments-transfers.d.ts +13 -0
  68. package/resources/simulations/real-time-payments-transfers.d.ts.map +1 -1
  69. package/resources/simulations/real-time-payments-transfers.js.map +1 -1
  70. package/resources/simulations/real-time-payments-transfers.mjs.map +1 -1
  71. package/resources/simulations/wire-transfers.d.ts +13 -0
  72. package/resources/simulations/wire-transfers.d.ts.map +1 -1
  73. package/resources/simulations/wire-transfers.js.map +1 -1
  74. package/resources/simulations/wire-transfers.mjs.map +1 -1
  75. package/resources/transactions.d.ts +13 -0
  76. package/resources/transactions.d.ts.map +1 -1
  77. package/resources/transactions.js.map +1 -1
  78. package/resources/transactions.mjs.map +1 -1
  79. package/resources/webhooks.d.ts +18 -0
  80. package/resources/webhooks.d.ts.map +1 -1
  81. package/resources/webhooks.js +73 -0
  82. package/resources/webhooks.js.map +1 -1
  83. package/resources/webhooks.mjs +73 -0
  84. package/resources/webhooks.mjs.map +1 -1
  85. package/resources/wire-drawdown-requests.d.ts +40 -0
  86. package/resources/wire-drawdown-requests.d.ts.map +1 -1
  87. package/resources/wire-drawdown-requests.js.map +1 -1
  88. package/resources/wire-drawdown-requests.mjs.map +1 -1
  89. package/resources/wire-transfers.d.ts +36 -0
  90. package/resources/wire-transfers.d.ts.map +1 -1
  91. package/resources/wire-transfers.js.map +1 -1
  92. package/resources/wire-transfers.mjs.map +1 -1
  93. package/src/index.ts +14 -5
  94. package/src/resources/ach-prenotifications.ts +7 -2
  95. package/src/resources/ach-transfers.ts +7 -2
  96. package/src/resources/cards.ts +6 -2
  97. package/src/resources/event-subscriptions.ts +24 -0
  98. package/src/resources/events.ts +16 -0
  99. package/src/resources/inbound-ach-transfers.ts +1 -1
  100. package/src/resources/inbound-wire-transfers.ts +136 -0
  101. package/src/resources/index.ts +6 -4
  102. package/src/resources/oauth-connections.ts +18 -17
  103. package/src/resources/oauth-tokens.ts +78 -0
  104. package/src/resources/physical-cards.ts +5 -0
  105. package/src/resources/simulations/ach-transfers.ts +17 -1
  106. package/src/resources/simulations/interest-payments.ts +16 -0
  107. package/src/resources/simulations/real-time-payments-transfers.ts +16 -0
  108. package/src/resources/simulations/wire-transfers.ts +16 -0
  109. package/src/resources/transactions.ts +16 -0
  110. package/src/resources/webhooks.ts +107 -1
  111. package/src/resources/wire-drawdown-requests.ts +48 -0
  112. package/src/resources/wire-transfers.ts +44 -0
  113. package/src/version.ts +1 -1
  114. package/version.d.ts +1 -1
  115. package/version.js +1 -1
  116. package/version.mjs +1 -1
@@ -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
+ }
@@ -90,6 +90,26 @@ export interface WireDrawdownRequest {
90
90
  */
91
91
  message_to_recipient: string;
92
92
 
93
+ /**
94
+ * The originator's address line 1.
95
+ */
96
+ originator_address_line1: string | null;
97
+
98
+ /**
99
+ * The originator's address line 2.
100
+ */
101
+ originator_address_line2: string | null;
102
+
103
+ /**
104
+ * The originator's address line 3.
105
+ */
106
+ originator_address_line3: string | null;
107
+
108
+ /**
109
+ * The originator's name.
110
+ */
111
+ originator_name: string | null;
112
+
93
113
  /**
94
114
  * The drawdown request's recipient's account number.
95
115
  */
@@ -190,6 +210,34 @@ export interface WireDrawdownRequestCreateParams {
190
210
  */
191
211
  recipient_routing_number: string;
192
212
 
213
+ /**
214
+ * The drawdown request originator's address line 1. This is only necessary if
215
+ * you're requesting a payment to a commingled account. Otherwise, we'll use the
216
+ * associated entity's details.
217
+ */
218
+ originator_address_line1?: string;
219
+
220
+ /**
221
+ * The drawdown request originator's address line 2. This is only necessary if
222
+ * you're requesting a payment to a commingled account. Otherwise, we'll use the
223
+ * associated entity's details.
224
+ */
225
+ originator_address_line2?: string;
226
+
227
+ /**
228
+ * The drawdown request originator's address line 3. This is only necessary if
229
+ * you're requesting a payment to a commingled account. Otherwise, we'll use the
230
+ * associated entity's details.
231
+ */
232
+ originator_address_line3?: string;
233
+
234
+ /**
235
+ * The drawdown request originator's name. This is only necessary if you're
236
+ * requesting a payment to a commingled account. Otherwise, we'll use the
237
+ * associated entity's details.
238
+ */
239
+ originator_name?: string;
240
+
193
241
  /**
194
242
  * Line 1 of the drawdown request's recipient's address.
195
243
  */
@@ -166,6 +166,26 @@ export interface WireTransfer {
166
166
  */
167
167
  network: 'wire';
168
168
 
169
+ /**
170
+ * The originator's address line 1.
171
+ */
172
+ originator_address_line1: string | null;
173
+
174
+ /**
175
+ * The originator's address line 2.
176
+ */
177
+ originator_address_line2: string | null;
178
+
179
+ /**
180
+ * The originator's address line 3.
181
+ */
182
+ originator_address_line3: string | null;
183
+
184
+ /**
185
+ * The originator's name.
186
+ */
187
+ originator_name: string | null;
188
+
169
189
  /**
170
190
  * The ID for the pending transaction representing the transfer. A pending
171
191
  * transaction is created when the transfer
@@ -419,6 +439,30 @@ export interface WireTransferCreateParams {
419
439
  */
420
440
  external_account_id?: string;
421
441
 
442
+ /**
443
+ * The originator's address line 1. This is only necessary if you're transferring
444
+ * from a commingled account. Otherwise, we'll use the associated entity's details.
445
+ */
446
+ originator_address_line1?: string;
447
+
448
+ /**
449
+ * The originator's address line 2. This is only necessary if you're transferring
450
+ * from a commingled account. Otherwise, we'll use the associated entity's details.
451
+ */
452
+ originator_address_line2?: string;
453
+
454
+ /**
455
+ * The originator's address line 3. This is only necessary if you're transferring
456
+ * from a commingled account. Otherwise, we'll use the associated entity's details.
457
+ */
458
+ originator_address_line3?: string;
459
+
460
+ /**
461
+ * The originator's name. This is only necessary if you're transferring from a
462
+ * commingled account. Otherwise, we'll use the associated entity's details.
463
+ */
464
+ originator_name?: string;
465
+
422
466
  /**
423
467
  * Whether the transfer requires explicit approval via the dashboard or API.
424
468
  */
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.24.3'; // x-release-please-version
1
+ export const VERSION = '0.25.0'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.24.3";
1
+ export declare const VERSION = "0.25.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.24.3'; // x-release-please-version
4
+ exports.VERSION = '0.25.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.24.3'; // x-release-please-version
1
+ export const VERSION = '0.25.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map