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.
- package/CHANGELOG.md +18 -0
- package/index.d.mts +12 -5
- package/index.d.ts +12 -5
- package/index.d.ts.map +1 -1
- package/index.js +7 -3
- package/index.js.map +1 -1
- package/index.mjs +7 -3
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/ach-prenotifications.d.ts +7 -2
- package/resources/ach-prenotifications.d.ts.map +1 -1
- package/resources/ach-prenotifications.js.map +1 -1
- package/resources/ach-prenotifications.mjs.map +1 -1
- package/resources/ach-transfers.d.ts +7 -2
- package/resources/ach-transfers.d.ts.map +1 -1
- package/resources/ach-transfers.js.map +1 -1
- package/resources/ach-transfers.mjs.map +1 -1
- package/resources/cards.d.ts +5 -2
- package/resources/cards.d.ts.map +1 -1
- package/resources/cards.js.map +1 -1
- package/resources/cards.mjs.map +1 -1
- package/resources/event-subscriptions.d.ts +18 -2
- package/resources/event-subscriptions.d.ts.map +1 -1
- package/resources/event-subscriptions.js.map +1 -1
- package/resources/event-subscriptions.mjs.map +1 -1
- package/resources/events.d.ts +10 -2
- package/resources/events.d.ts.map +1 -1
- package/resources/events.js.map +1 -1
- package/resources/events.mjs.map +1 -1
- package/resources/inbound-ach-transfers.d.ts +1 -1
- package/resources/inbound-wire-transfers.d.ts +107 -0
- package/resources/inbound-wire-transfers.d.ts.map +1 -0
- package/resources/inbound-wire-transfers.js +17 -0
- package/resources/inbound-wire-transfers.js.map +1 -0
- package/resources/inbound-wire-transfers.mjs +13 -0
- package/resources/inbound-wire-transfers.mjs.map +1 -0
- package/resources/index.d.ts +3 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +7 -3
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +3 -1
- package/resources/index.mjs.map +1 -1
- package/resources/oauth-connections.d.ts +14 -13
- package/resources/oauth-connections.d.ts.map +1 -1
- package/resources/oauth-connections.js +10 -10
- package/resources/oauth-connections.js.map +1 -1
- package/resources/oauth-connections.mjs +7 -7
- package/resources/oauth-connections.mjs.map +1 -1
- package/resources/oauth-tokens.d.ts +65 -0
- package/resources/oauth-tokens.d.ts.map +1 -0
- package/resources/oauth-tokens.js +17 -0
- package/resources/oauth-tokens.js.map +1 -0
- package/resources/oauth-tokens.mjs +13 -0
- package/resources/oauth-tokens.mjs.map +1 -0
- package/resources/physical-cards.d.ts +4 -0
- package/resources/physical-cards.d.ts.map +1 -1
- package/resources/physical-cards.js.map +1 -1
- package/resources/physical-cards.mjs.map +1 -1
- package/resources/simulations/ach-transfers.d.ts +14 -1
- package/resources/simulations/ach-transfers.d.ts.map +1 -1
- package/resources/simulations/ach-transfers.js.map +1 -1
- package/resources/simulations/ach-transfers.mjs.map +1 -1
- package/resources/simulations/interest-payments.d.ts +13 -0
- package/resources/simulations/interest-payments.d.ts.map +1 -1
- package/resources/simulations/interest-payments.js.map +1 -1
- package/resources/simulations/interest-payments.mjs.map +1 -1
- package/resources/simulations/real-time-payments-transfers.d.ts +13 -0
- package/resources/simulations/real-time-payments-transfers.d.ts.map +1 -1
- package/resources/simulations/real-time-payments-transfers.js.map +1 -1
- package/resources/simulations/real-time-payments-transfers.mjs.map +1 -1
- package/resources/simulations/wire-transfers.d.ts +13 -0
- package/resources/simulations/wire-transfers.d.ts.map +1 -1
- package/resources/simulations/wire-transfers.js.map +1 -1
- package/resources/simulations/wire-transfers.mjs.map +1 -1
- package/resources/transactions.d.ts +13 -0
- package/resources/transactions.d.ts.map +1 -1
- package/resources/transactions.js.map +1 -1
- package/resources/transactions.mjs.map +1 -1
- package/resources/webhooks.d.ts +18 -0
- package/resources/webhooks.d.ts.map +1 -1
- package/resources/webhooks.js +73 -0
- package/resources/webhooks.js.map +1 -1
- package/resources/webhooks.mjs +73 -0
- package/resources/webhooks.mjs.map +1 -1
- package/resources/wire-drawdown-requests.d.ts +40 -0
- package/resources/wire-drawdown-requests.d.ts.map +1 -1
- package/resources/wire-drawdown-requests.js.map +1 -1
- package/resources/wire-drawdown-requests.mjs.map +1 -1
- package/resources/wire-transfers.d.ts +36 -0
- package/resources/wire-transfers.d.ts.map +1 -1
- package/resources/wire-transfers.js.map +1 -1
- package/resources/wire-transfers.mjs.map +1 -1
- package/src/index.ts +14 -5
- package/src/resources/ach-prenotifications.ts +7 -2
- package/src/resources/ach-transfers.ts +7 -2
- package/src/resources/cards.ts +6 -2
- package/src/resources/event-subscriptions.ts +24 -0
- package/src/resources/events.ts +16 -0
- package/src/resources/inbound-ach-transfers.ts +1 -1
- package/src/resources/inbound-wire-transfers.ts +136 -0
- package/src/resources/index.ts +6 -4
- package/src/resources/oauth-connections.ts +18 -17
- package/src/resources/oauth-tokens.ts +78 -0
- package/src/resources/physical-cards.ts +5 -0
- package/src/resources/simulations/ach-transfers.ts +17 -1
- package/src/resources/simulations/interest-payments.ts +16 -0
- package/src/resources/simulations/real-time-payments-transfers.ts +16 -0
- package/src/resources/simulations/wire-transfers.ts +16 -0
- package/src/resources/transactions.ts +16 -0
- package/src/resources/webhooks.ts +107 -1
- package/src/resources/wire-drawdown-requests.ts +48 -0
- package/src/resources/wire-transfers.ts +44 -0
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- 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.
|
|
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.
|
|
1
|
+
export declare const VERSION = "0.25.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.25.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|