@tryfinch/finch-api 5.22.6 → 5.22.8
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 +16 -0
- package/client.d.ts +0 -203
- package/client.d.ts.map +1 -1
- package/client.js +0 -216
- package/client.js.map +1 -1
- package/client.mjs +1 -190
- package/client.mjs.map +1 -1
- package/index.d.mts +203 -2
- package/index.d.ts +203 -2
- package/index.d.ts.map +1 -1
- package/index.js +192 -6
- package/index.js.map +1 -1
- package/index.mjs +189 -2
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +0 -369
- package/src/index.ts +367 -4
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtF,gDAA+B;AAC/B,mDAAkC;AAElC,sDAAqC;AACrC,2EAA6D;AAC7D,yEAA2D;AAuF3D,qDAAqD;AACrD,MAAa,KAAM,SAAQ,IAAI,CAAC,SAAS;IAUvC;;;;;;;;;;;;;;;;OAgBG;IACH,YAAY,EACV,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EACxC,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,IAAI,EAClD,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,IAAI,EAC1D,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,IAAI,IAAI,EACjE,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,6BAA6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IBUTING.md for details.
|
|
2
|
+
var _a;
|
|
3
|
+
import * as Core from "./core.mjs";
|
|
2
4
|
import * as Errors from "./error.mjs";
|
|
3
5
|
import * as Uploads from "./uploads.mjs";
|
|
6
|
+
import * as Pagination from '@tryfinch/finch-api/pagination';
|
|
7
|
+
import * as API from '@tryfinch/finch-api/resources/index';
|
|
8
|
+
/** API Client for interfacing with the Finch API. */
|
|
9
|
+
export class Finch extends Core.APIClient {
|
|
10
|
+
/**
|
|
11
|
+
* API Client for interfacing with the Finch API.
|
|
12
|
+
*
|
|
13
|
+
* @param {string | null | undefined} [opts.accessToken]
|
|
14
|
+
* @param {string | null | undefined} [opts.clientId=process.env['FINCH_CLIENT_ID'] ?? null]
|
|
15
|
+
* @param {string | null | undefined} [opts.clientSecret=process.env['FINCH_CLIENT_SECRET'] ?? null]
|
|
16
|
+
* @param {string | null | undefined} [opts.sandboxClientId=process.env['FINCH_SANDBOX_CLIENT_ID'] ?? null]
|
|
17
|
+
* @param {string | null | undefined} [opts.sandboxClientSecret=process.env['FINCH_SANDBOX_CLIENT_SECRET'] ?? null]
|
|
18
|
+
* @param {string | null | undefined} [opts.webhookSecret=process.env['FINCH_WEBHOOK_SECRET'] ?? null]
|
|
19
|
+
* @param {string} [opts.baseURL=process.env['FINCH_BASE_URL'] ?? https://api.tryfinch.com] - Override the default base URL for the API.
|
|
20
|
+
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
21
|
+
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
22
|
+
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
23
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
24
|
+
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
25
|
+
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
26
|
+
*/
|
|
27
|
+
constructor({ baseURL = Core.readEnv('FINCH_BASE_URL'), accessToken = null, clientId = Core.readEnv('FINCH_CLIENT_ID') ?? null, clientSecret = Core.readEnv('FINCH_CLIENT_SECRET') ?? null, sandboxClientId = Core.readEnv('FINCH_SANDBOX_CLIENT_ID') ?? null, sandboxClientSecret = Core.readEnv('FINCH_SANDBOX_CLIENT_SECRET') ?? null, webhookSecret = Core.readEnv('FINCH_WEBHOOK_SECRET') ?? null, ...opts } = {}) {
|
|
28
|
+
const options = {
|
|
29
|
+
accessToken,
|
|
30
|
+
clientId,
|
|
31
|
+
clientSecret,
|
|
32
|
+
sandboxClientId,
|
|
33
|
+
sandboxClientSecret,
|
|
34
|
+
webhookSecret,
|
|
35
|
+
...opts,
|
|
36
|
+
baseURL: baseURL || `https://api.tryfinch.com`,
|
|
37
|
+
};
|
|
38
|
+
super({
|
|
39
|
+
baseURL: options.baseURL,
|
|
40
|
+
timeout: options.timeout ?? 60000 /* 1 minute */,
|
|
41
|
+
httpAgent: options.httpAgent,
|
|
42
|
+
maxRetries: options.maxRetries,
|
|
43
|
+
fetch: options.fetch,
|
|
44
|
+
});
|
|
45
|
+
this.accessTokens = new API.AccessTokens(this);
|
|
46
|
+
this.hris = new API.HRIS(this);
|
|
47
|
+
this.providers = new API.Providers(this);
|
|
48
|
+
this.account = new API.Account(this);
|
|
49
|
+
this.webhooks = new API.Webhooks(this);
|
|
50
|
+
this.requestForwarding = new API.RequestForwarding(this);
|
|
51
|
+
this.jobs = new API.Jobs(this);
|
|
52
|
+
this.sandbox = new API.Sandbox(this);
|
|
53
|
+
this._options = options;
|
|
54
|
+
this.accessToken = accessToken;
|
|
55
|
+
this.clientId = clientId;
|
|
56
|
+
this.clientSecret = clientSecret;
|
|
57
|
+
this.sandboxClientId = sandboxClientId;
|
|
58
|
+
this.sandboxClientSecret = sandboxClientSecret;
|
|
59
|
+
this.webhookSecret = webhookSecret;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* DEPRECATED: use client.accessTokens.create instead.
|
|
63
|
+
*/
|
|
64
|
+
getAccessToken(code, options) {
|
|
65
|
+
if (!this.clientId) {
|
|
66
|
+
throw new Error('Expected the clientId to be set in order to call getAccessToken');
|
|
67
|
+
}
|
|
68
|
+
if (!this.clientSecret) {
|
|
69
|
+
throw new Error('Expected the clientSecret to be set in order to call getAccessToken');
|
|
70
|
+
}
|
|
71
|
+
return this.post('/auth/token', {
|
|
72
|
+
body: {
|
|
73
|
+
client_id: this.clientId,
|
|
74
|
+
client_secret: this.clientSecret,
|
|
75
|
+
code: code,
|
|
76
|
+
redirect_uri: options?.redirectUri,
|
|
77
|
+
},
|
|
78
|
+
headers: {
|
|
79
|
+
authorization: null,
|
|
80
|
+
},
|
|
81
|
+
}).then((response) => response.access_token);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns the authorization url which can be visited in order to obtain an
|
|
85
|
+
* authorization code from Finch. The authorization code can then be exchanged for
|
|
86
|
+
* an access token for the Finch api by calling get_access_token().
|
|
87
|
+
*/
|
|
88
|
+
getAuthURL({ products, redirectUri, sandbox, }) {
|
|
89
|
+
if (!this.clientId) {
|
|
90
|
+
throw new Error('Expected the clientId to be set in order to call getAuthUrl');
|
|
91
|
+
}
|
|
92
|
+
const url = new URL('/authorize', 'https://connect.tryfinch.com/authorize');
|
|
93
|
+
url.search = this.stringifyQuery({
|
|
94
|
+
client_id: this.clientId,
|
|
95
|
+
products: products,
|
|
96
|
+
redirect_uri: redirectUri,
|
|
97
|
+
sandbox: sandbox,
|
|
98
|
+
});
|
|
99
|
+
return url.toString();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns a copy of the current Finch client with the given access token for
|
|
103
|
+
* authentication.
|
|
104
|
+
*/
|
|
105
|
+
withAccessToken(accessToken) {
|
|
106
|
+
return new Finch({ ...this._options, accessToken });
|
|
107
|
+
}
|
|
108
|
+
defaultQuery() {
|
|
109
|
+
return this._options.defaultQuery;
|
|
110
|
+
}
|
|
111
|
+
defaultHeaders(opts) {
|
|
112
|
+
return {
|
|
113
|
+
...super.defaultHeaders(opts),
|
|
114
|
+
'Finch-API-Version': '2020-09-17',
|
|
115
|
+
...this._options.defaultHeaders,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
validateHeaders(headers, customHeaders) {
|
|
119
|
+
if (this.accessToken && headers['authorization']) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (customHeaders['authorization'] === null) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (this.sandboxClientId && this.sandboxClientSecret && headers['authorization']) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (customHeaders['authorization'] === null) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
throw new Error('Could not resolve authentication method. Expected either accessToken, sandboxClientId or sandboxClientSecret to be set. Or for one of the "Authorization" or "Authorization" headers to be explicitly omitted');
|
|
132
|
+
}
|
|
133
|
+
authHeaders(opts) {
|
|
134
|
+
const bearerAuth = this.bearerAuth(opts);
|
|
135
|
+
const basicAuth = this.basicAuth(opts);
|
|
136
|
+
if (bearerAuth != null && !Core.isEmptyObj(bearerAuth)) {
|
|
137
|
+
return bearerAuth;
|
|
138
|
+
}
|
|
139
|
+
return {};
|
|
140
|
+
}
|
|
141
|
+
bearerAuth(opts) {
|
|
142
|
+
if (this.accessToken == null) {
|
|
143
|
+
return {};
|
|
144
|
+
}
|
|
145
|
+
return { Authorization: `Bearer ${this.accessToken}` };
|
|
146
|
+
}
|
|
147
|
+
basicAuth(opts) {
|
|
148
|
+
if (!this.sandboxClientId) {
|
|
149
|
+
return {};
|
|
150
|
+
}
|
|
151
|
+
if (!this.sandboxClientSecret) {
|
|
152
|
+
return {};
|
|
153
|
+
}
|
|
154
|
+
const credentials = `${this.sandboxClientId}:${this.sandboxClientSecret}`;
|
|
155
|
+
const Authorization = `Basic ${Core.toBase64(credentials)}`;
|
|
156
|
+
return { Authorization };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
_a = Finch;
|
|
160
|
+
Finch.Finch = _a;
|
|
161
|
+
Finch.FinchError = Errors.FinchError;
|
|
162
|
+
Finch.APIError = Errors.APIError;
|
|
163
|
+
Finch.APIConnectionError = Errors.APIConnectionError;
|
|
164
|
+
Finch.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
165
|
+
Finch.APIUserAbortError = Errors.APIUserAbortError;
|
|
166
|
+
Finch.NotFoundError = Errors.NotFoundError;
|
|
167
|
+
Finch.ConflictError = Errors.ConflictError;
|
|
168
|
+
Finch.RateLimitError = Errors.RateLimitError;
|
|
169
|
+
Finch.BadRequestError = Errors.BadRequestError;
|
|
170
|
+
Finch.AuthenticationError = Errors.AuthenticationError;
|
|
171
|
+
Finch.InternalServerError = Errors.InternalServerError;
|
|
172
|
+
Finch.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
173
|
+
Finch.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
174
|
+
Finch.toFile = Uploads.toFile;
|
|
175
|
+
Finch.fileFromPath = Uploads.fileFromPath;
|
|
176
|
+
export const { FinchError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } = Errors;
|
|
4
177
|
export var toFile = Uploads.toFile;
|
|
5
178
|
export var fileFromPath = Uploads.fileFromPath;
|
|
6
|
-
|
|
7
|
-
|
|
179
|
+
(function (Finch) {
|
|
180
|
+
Finch.SinglePage = Pagination.SinglePage;
|
|
181
|
+
Finch.ResponsesPage = Pagination.ResponsesPage;
|
|
182
|
+
Finch.IndividualsPage = Pagination.IndividualsPage;
|
|
183
|
+
Finch.Page = Pagination.Page;
|
|
184
|
+
Finch.AccessTokens = API.AccessTokens;
|
|
185
|
+
Finch.HRIS = API.HRIS;
|
|
186
|
+
Finch.Providers = API.Providers;
|
|
187
|
+
Finch.ProvidersSinglePage = API.ProvidersSinglePage;
|
|
188
|
+
Finch.Account = API.Account;
|
|
189
|
+
Finch.Webhooks = API.Webhooks;
|
|
190
|
+
Finch.RequestForwarding = API.RequestForwarding;
|
|
191
|
+
Finch.Jobs = API.Jobs;
|
|
192
|
+
Finch.Sandbox = API.Sandbox;
|
|
193
|
+
})(Finch || (Finch = {}));
|
|
194
|
+
export default Finch;
|
|
8
195
|
//# sourceMappingURL=index.mjs.map
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;;OAE/E,KAAK,IAAI;OACT,KAAK,MAAM;OAEX,KAAK,OAAO;OACZ,KAAK,UAAU,MAAM,gCAAgC;OACrD,KAAK,GAAG,MAAM,qCAAqC;AAuF1D,qDAAqD;AACrD,MAAM,OAAO,KAAM,SAAQ,IAAI,CAAC,SAAS;IAUvC;;;;;;;;;;;;;;;;OAgBG;IACH,YAAY,EACV,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EACxC,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,IAAI,EAClD,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,IAAI,EAC1D,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,IAAI,IAAI,EACjE,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,IAAI,IAAI,EACzE,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,IAAI,IAAI,EAC5D,GAAG,IAAI,KACU,EAAE;QACnB,MAAM,OAAO,GAAkB;YAC7B,WAAW;YACX,QAAQ;YACR,YAAY;YACZ,eA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AAG,MAAM,CAAC;AAEX,MAAM,KAAQ,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACtC,MAAM,KAAQ,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;AAElD,WAAiB,KAAK;IAGN,gBAAU,GAAG,UAAU,CAAC,UAAU,CAAC;IAGnC,mBAAa,GAAG,UAAU,CAAC,aAAa,CAAC;IAGzC,qBAAe,GAAG,UAAU,CAAC,eAAe,CAAC;IAI7C,UAAI,GAAG,UAAU,CAAC,IAAI,CAAC;IAIvB,kBAAY,GAAG,GAAG,CAAC,YAAY,CAAC;IAIhC,UAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAKhB,eAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IAE1B,yBAAmB,GAAG,GAAG,CAAC,mBAAmB,CAAC;IAE9C,aAAO,GAAG,GAAG,CAAC,OAAO,CAAC;IAItB,cAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAYxB,uBAAiB,GAAG,GAAG,CAAC,iBAAiB,CAAC;IAI1C,UAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAEhB,aAAO,GAAG,GAAG,CAAC,OAAO,CAAC;AAMtC,CAAC,EA1DgB,KAAK,KAAL,KAAK,QA0DrB;AAED,eAAe,KAAK,CAAC"}
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
|
|
3
|
-
import * as Core from './core';
|
|
4
|
-
import * as Errors from './error';
|
|
5
|
-
import { type Agent } from './_shims/index';
|
|
6
|
-
import * as Uploads from './uploads';
|
|
7
|
-
import * as Pagination from "./pagination";
|
|
8
|
-
import * as API from "./resources/index";
|
|
9
|
-
|
|
10
|
-
export interface ClientOptions {
|
|
11
|
-
accessToken?: string | null | undefined;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Defaults to process.env['FINCH_CLIENT_ID'].
|
|
15
|
-
*/
|
|
16
|
-
clientId?: string | null | undefined;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Defaults to process.env['FINCH_CLIENT_SECRET'].
|
|
20
|
-
*/
|
|
21
|
-
clientSecret?: string | null | undefined;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Defaults to process.env['FINCH_SANDBOX_CLIENT_ID'].
|
|
25
|
-
*/
|
|
26
|
-
sandboxClientId?: string | null | undefined;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Defaults to process.env['FINCH_SANDBOX_CLIENT_SECRET'].
|
|
30
|
-
*/
|
|
31
|
-
sandboxClientSecret?: string | null | undefined;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Defaults to process.env['FINCH_WEBHOOK_SECRET'].
|
|
35
|
-
*/
|
|
36
|
-
webhookSecret?: string | null | undefined;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
40
|
-
*
|
|
41
|
-
* Defaults to process.env['FINCH_BASE_URL'].
|
|
42
|
-
*/
|
|
43
|
-
baseURL?: string | null | undefined;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
47
|
-
* from the server before timing out a single request.
|
|
48
|
-
*
|
|
49
|
-
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
50
|
-
* much longer than this timeout before the promise succeeds or fails.
|
|
51
|
-
*/
|
|
52
|
-
timeout?: number;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* An HTTP agent used to manage HTTP(S) connections.
|
|
56
|
-
*
|
|
57
|
-
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
58
|
-
* otherwise no agent is used.
|
|
59
|
-
*/
|
|
60
|
-
httpAgent?: Agent;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Specify a custom `fetch` function implementation.
|
|
64
|
-
*
|
|
65
|
-
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
66
|
-
* defined globally.
|
|
67
|
-
*/
|
|
68
|
-
fetch?: Core.Fetch | undefined;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* The maximum number of times that the client will retry a request in case of a
|
|
72
|
-
* temporary failure, like a network error or a 5XX error from the server.
|
|
73
|
-
*
|
|
74
|
-
* @default 2
|
|
75
|
-
*/
|
|
76
|
-
maxRetries?: number;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Default headers to include with every request to the API.
|
|
80
|
-
*
|
|
81
|
-
* These can be removed in individual requests by explicitly setting the
|
|
82
|
-
* header to `undefined` or `null` in request options.
|
|
83
|
-
*/
|
|
84
|
-
defaultHeaders?: Core.Headers;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Default query parameters to include with every request to the API.
|
|
88
|
-
*
|
|
89
|
-
* These can be removed in individual requests by explicitly setting the
|
|
90
|
-
* param to `undefined` in request options.
|
|
91
|
-
*/
|
|
92
|
-
defaultQuery?: Core.DefaultQuery;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** API Client for interfacing with the Finch API. */
|
|
96
|
-
export class Finch extends Core.APIClient {
|
|
97
|
-
accessToken: string | null;
|
|
98
|
-
clientId: string | null;
|
|
99
|
-
clientSecret: string | null;
|
|
100
|
-
sandboxClientId: string | null;
|
|
101
|
-
sandboxClientSecret: string | null;
|
|
102
|
-
webhookSecret: string | null;
|
|
103
|
-
|
|
104
|
-
private _options: ClientOptions;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* API Client for interfacing with the Finch API.
|
|
108
|
-
*
|
|
109
|
-
* @param {string | null | undefined} [opts.accessToken]
|
|
110
|
-
* @param {string | null | undefined} [opts.clientId=process.env['FINCH_CLIENT_ID'] ?? null]
|
|
111
|
-
* @param {string | null | undefined} [opts.clientSecret=process.env['FINCH_CLIENT_SECRET'] ?? null]
|
|
112
|
-
* @param {string | null | undefined} [opts.sandboxClientId=process.env['FINCH_SANDBOX_CLIENT_ID'] ?? null]
|
|
113
|
-
* @param {string | null | undefined} [opts.sandboxClientSecret=process.env['FINCH_SANDBOX_CLIENT_SECRET'] ?? null]
|
|
114
|
-
* @param {string | null | undefined} [opts.webhookSecret=process.env['FINCH_WEBHOOK_SECRET'] ?? null]
|
|
115
|
-
* @param {string} [opts.baseURL=process.env['FINCH_BASE_URL'] ?? https://api.tryfinch.com] - Override the default base URL for the API.
|
|
116
|
-
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
117
|
-
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
118
|
-
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
119
|
-
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
120
|
-
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
121
|
-
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
122
|
-
*/
|
|
123
|
-
constructor({
|
|
124
|
-
baseURL = Core.readEnv('FINCH_BASE_URL'),
|
|
125
|
-
accessToken = null,
|
|
126
|
-
clientId = Core.readEnv('FINCH_CLIENT_ID') ?? null,
|
|
127
|
-
clientSecret = Core.readEnv('FINCH_CLIENT_SECRET') ?? null,
|
|
128
|
-
sandboxClientId = Core.readEnv('FINCH_SANDBOX_CLIENT_ID') ?? null,
|
|
129
|
-
sandboxClientSecret = Core.readEnv('FINCH_SANDBOX_CLIENT_SECRET') ?? null,
|
|
130
|
-
webhookSecret = Core.readEnv('FINCH_WEBHOOK_SECRET') ?? null,
|
|
131
|
-
...opts
|
|
132
|
-
}: ClientOptions = {}) {
|
|
133
|
-
const options: ClientOptions = {
|
|
134
|
-
accessToken,
|
|
135
|
-
clientId,
|
|
136
|
-
clientSecret,
|
|
137
|
-
sandboxClientId,
|
|
138
|
-
sandboxClientSecret,
|
|
139
|
-
webhookSecret,
|
|
140
|
-
...opts,
|
|
141
|
-
baseURL: baseURL || `https://api.tryfinch.com`,
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
super({
|
|
145
|
-
baseURL: options.baseURL!,
|
|
146
|
-
timeout: options.timeout ?? 60000 /* 1 minute */,
|
|
147
|
-
httpAgent: options.httpAgent,
|
|
148
|
-
maxRetries: options.maxRetries,
|
|
149
|
-
fetch: options.fetch,
|
|
150
|
-
});
|
|
151
|
-
this._options = options;
|
|
152
|
-
|
|
153
|
-
this.accessToken = accessToken;
|
|
154
|
-
this.clientId = clientId;
|
|
155
|
-
this.clientSecret = clientSecret;
|
|
156
|
-
this.sandboxClientId = sandboxClientId;
|
|
157
|
-
this.sandboxClientSecret = sandboxClientSecret;
|
|
158
|
-
this.webhookSecret = webhookSecret;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
accessTokens: API.AccessTokens = new API.AccessTokens(this);
|
|
162
|
-
hris: API.HRIS = new API.HRIS(this);
|
|
163
|
-
providers: API.Providers = new API.Providers(this);
|
|
164
|
-
account: API.Account = new API.Account(this);
|
|
165
|
-
webhooks: API.Webhooks = new API.Webhooks(this);
|
|
166
|
-
requestForwarding: API.RequestForwarding = new API.RequestForwarding(this);
|
|
167
|
-
jobs: API.Jobs = new API.Jobs(this);
|
|
168
|
-
sandbox: API.Sandbox = new API.Sandbox(this);
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* DEPRECATED: use client.accessTokens.create instead.
|
|
172
|
-
*/
|
|
173
|
-
getAccessToken(code: string, options?: { redirectUri: string }): Promise<string> {
|
|
174
|
-
if (!this.clientId) {
|
|
175
|
-
throw new Error('Expected the clientId to be set in order to call getAccessToken');
|
|
176
|
-
}
|
|
177
|
-
if (!this.clientSecret) {
|
|
178
|
-
throw new Error('Expected the clientSecret to be set in order to call getAccessToken');
|
|
179
|
-
}
|
|
180
|
-
return this.post<Record<string, any>, { access_token: string }>('/auth/token', {
|
|
181
|
-
body: {
|
|
182
|
-
client_id: this.clientId,
|
|
183
|
-
client_secret: this.clientSecret,
|
|
184
|
-
code: code,
|
|
185
|
-
redirect_uri: options?.redirectUri,
|
|
186
|
-
},
|
|
187
|
-
headers: {
|
|
188
|
-
authorization: null,
|
|
189
|
-
},
|
|
190
|
-
}).then((response) => response.access_token);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Returns the authorization url which can be visited in order to obtain an
|
|
195
|
-
* authorization code from Finch. The authorization code can then be exchanged for
|
|
196
|
-
* an access token for the Finch api by calling get_access_token().
|
|
197
|
-
*/
|
|
198
|
-
getAuthURL({
|
|
199
|
-
products,
|
|
200
|
-
redirectUri,
|
|
201
|
-
sandbox,
|
|
202
|
-
}: {
|
|
203
|
-
products: string;
|
|
204
|
-
redirectUri: string;
|
|
205
|
-
sandbox: boolean;
|
|
206
|
-
}): string {
|
|
207
|
-
if (!this.clientId) {
|
|
208
|
-
throw new Error('Expected the clientId to be set in order to call getAuthUrl');
|
|
209
|
-
}
|
|
210
|
-
const url = new URL('/authorize', 'https://connect.tryfinch.com/authorize');
|
|
211
|
-
url.search = this.stringifyQuery({
|
|
212
|
-
client_id: this.clientId,
|
|
213
|
-
products: products,
|
|
214
|
-
redirect_uri: redirectUri,
|
|
215
|
-
sandbox: sandbox,
|
|
216
|
-
});
|
|
217
|
-
return url.toString();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Returns a copy of the current Finch client with the given access token for
|
|
222
|
-
* authentication.
|
|
223
|
-
*/
|
|
224
|
-
withAccessToken(accessToken: string): Finch {
|
|
225
|
-
return new Finch({ ...this._options, accessToken });
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
229
|
-
return this._options.defaultQuery;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
233
|
-
return {
|
|
234
|
-
...super.defaultHeaders(opts),
|
|
235
|
-
'Finch-API-Version': '2020-09-17',
|
|
236
|
-
...this._options.defaultHeaders,
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
protected override validateHeaders(headers: Core.Headers, customHeaders: Core.Headers) {
|
|
241
|
-
if (this.accessToken && headers['authorization']) {
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
if (customHeaders['authorization'] === null) {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if (this.sandboxClientId && this.sandboxClientSecret && headers['authorization']) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
if (customHeaders['authorization'] === null) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
throw new Error(
|
|
256
|
-
'Could not resolve authentication method. Expected either accessToken, sandboxClientId or sandboxClientSecret to be set. Or for one of the "Authorization" or "Authorization" headers to be explicitly omitted',
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
261
|
-
const bearerAuth = this.bearerAuth(opts);
|
|
262
|
-
const basicAuth = this.basicAuth(opts);
|
|
263
|
-
|
|
264
|
-
if (bearerAuth != null && !Core.isEmptyObj(bearerAuth)) {
|
|
265
|
-
return bearerAuth;
|
|
266
|
-
}
|
|
267
|
-
return {};
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
protected bearerAuth(opts: Core.FinalRequestOptions): Core.Headers {
|
|
271
|
-
if (this.accessToken == null) {
|
|
272
|
-
return {};
|
|
273
|
-
}
|
|
274
|
-
return { Authorization: `Bearer ${this.accessToken}` };
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
protected basicAuth(opts: Core.FinalRequestOptions): Core.Headers {
|
|
278
|
-
if (!this.sandboxClientId) {
|
|
279
|
-
return {};
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (!this.sandboxClientSecret) {
|
|
283
|
-
return {};
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const credentials = `${this.sandboxClientId}:${this.sandboxClientSecret}`;
|
|
287
|
-
const Authorization = `Basic ${Core.toBase64(credentials)}`;
|
|
288
|
-
return { Authorization };
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
static Finch = this;
|
|
292
|
-
|
|
293
|
-
static FinchError = Errors.FinchError;
|
|
294
|
-
static APIError = Errors.APIError;
|
|
295
|
-
static APIConnectionError = Errors.APIConnectionError;
|
|
296
|
-
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
297
|
-
static APIUserAbortError = Errors.APIUserAbortError;
|
|
298
|
-
static NotFoundError = Errors.NotFoundError;
|
|
299
|
-
static ConflictError = Errors.ConflictError;
|
|
300
|
-
static RateLimitError = Errors.RateLimitError;
|
|
301
|
-
static BadRequestError = Errors.BadRequestError;
|
|
302
|
-
static AuthenticationError = Errors.AuthenticationError;
|
|
303
|
-
static InternalServerError = Errors.InternalServerError;
|
|
304
|
-
static PermissionDeniedError = Errors.PermissionDeniedError;
|
|
305
|
-
static UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
306
|
-
|
|
307
|
-
static toFile = Uploads.toFile;
|
|
308
|
-
static fileFromPath = Uploads.fileFromPath;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
export namespace Finch {
|
|
312
|
-
export import RequestOptions = Core.RequestOptions;
|
|
313
|
-
|
|
314
|
-
export import SinglePage = Pagination.SinglePage;
|
|
315
|
-
export import SinglePageResponse = Pagination.SinglePageResponse;
|
|
316
|
-
|
|
317
|
-
export import ResponsesPage = Pagination.ResponsesPage;
|
|
318
|
-
export import ResponsesPageResponse = Pagination.ResponsesPageResponse;
|
|
319
|
-
|
|
320
|
-
export import IndividualsPage = Pagination.IndividualsPage;
|
|
321
|
-
export import IndividualsPageParams = Pagination.IndividualsPageParams;
|
|
322
|
-
export import IndividualsPageResponse = Pagination.IndividualsPageResponse;
|
|
323
|
-
|
|
324
|
-
export import Page = Pagination.Page;
|
|
325
|
-
export import PageParams = Pagination.PageParams;
|
|
326
|
-
export import PageResponse = Pagination.PageResponse;
|
|
327
|
-
|
|
328
|
-
export import AccessTokens = API.AccessTokens;
|
|
329
|
-
export import CreateAccessTokenResponse = API.CreateAccessTokenResponse;
|
|
330
|
-
export import AccessTokenCreateParams = API.AccessTokenCreateParams;
|
|
331
|
-
|
|
332
|
-
export import HRIS = API.HRIS;
|
|
333
|
-
export import Income = API.Income;
|
|
334
|
-
export import Location = API.Location;
|
|
335
|
-
export import Money = API.Money;
|
|
336
|
-
|
|
337
|
-
export import Providers = API.Providers;
|
|
338
|
-
export import Provider = API.Provider;
|
|
339
|
-
export import ProvidersSinglePage = API.ProvidersSinglePage;
|
|
340
|
-
|
|
341
|
-
export import Account = API.Account;
|
|
342
|
-
export import DisconnectResponse = API.DisconnectResponse;
|
|
343
|
-
export import Introspection = API.Introspection;
|
|
344
|
-
|
|
345
|
-
export import Webhooks = API.Webhooks;
|
|
346
|
-
export import AccountUpdateEvent = API.AccountUpdateEvent;
|
|
347
|
-
export import BaseWebhookEvent = API.BaseWebhookEvent;
|
|
348
|
-
export import CompanyEvent = API.CompanyEvent;
|
|
349
|
-
export import DirectoryEvent = API.DirectoryEvent;
|
|
350
|
-
export import EmploymentEvent = API.EmploymentEvent;
|
|
351
|
-
export import IndividualEvent = API.IndividualEvent;
|
|
352
|
-
export import JobCompletionEvent = API.JobCompletionEvent;
|
|
353
|
-
export import PayStatementEvent = API.PayStatementEvent;
|
|
354
|
-
export import PaymentEvent = API.PaymentEvent;
|
|
355
|
-
export import WebhookEvent = API.WebhookEvent;
|
|
356
|
-
|
|
357
|
-
export import RequestForwarding = API.RequestForwarding;
|
|
358
|
-
export import RequestForwardingForwardResponse = API.RequestForwardingForwardResponse;
|
|
359
|
-
export import RequestForwardingForwardParams = API.RequestForwardingForwardParams;
|
|
360
|
-
|
|
361
|
-
export import Jobs = API.Jobs;
|
|
362
|
-
|
|
363
|
-
export import Sandbox = API.Sandbox;
|
|
364
|
-
|
|
365
|
-
export import ConnectionStatusType = API.ConnectionStatusType;
|
|
366
|
-
export import OperationSupport = API.OperationSupport;
|
|
367
|
-
export import OperationSupportMatrix = API.OperationSupportMatrix;
|
|
368
|
-
export import Paging = API.Paging;
|
|
369
|
-
}
|