flinks-api 1.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Jeremy Cox
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`axios`);c=s(c);let l=function(e){return e.cad=`CAD`,e.usd=`USD`,e}({}),u=function(e){return e.Alberta=`AB`,e[`British Columbia`]=`BC`,e.Manitoba=`MB`,e[`New Brunswick`]=`NB`,e[`Newfoundland and Labrador`]=`NL`,e[`Northwest Territories`]=`NT`,e[`Nova Scotia`]=`NS`,e.Ontario=`ON`,e[`Prince Edward Island`]=`PE`,e.Quebec=`QC`,e.Saskatchewan=`SK`,e.Yukon=`YT`,e.Nunavut=`NU`,e}({}),d=function(e){return e.Alabama=`AL`,e.Alaska=`AK`,e.Arizona=`AZ`,e.Arkansas=`AR`,e.California=`CA`,e.Colorado=`CO`,e.Connecticut=`CT`,e.Delaware=`DE`,e.Florida=`FL`,e.Georgia=`GA`,e.Hawaii=`HI`,e.Idaho=`ID`,e.Illinois=`IL`,e.Indiana=`IN`,e.Iowa=`IA`,e.Kansas=`KS`,e.Kentucky=`KY`,e.Louisiana=`LA`,e.Maine=`ME`,e.Maryland=`MD`,e.Massachusetts=`MA`,e.Michigan=`MI`,e.Minnesota=`MN`,e.Mississippi=`MS`,e.Missouri=`MO`,e.Montana=`MT`,e.Nebraska=`NE`,e.Nevada=`NV`,e.NewHampshire=`NH`,e.NewJersey=`NJ`,e.NewMexico=`NM`,e.NewYork=`NY`,e.NorthCarolina=`NC`,e.NorthDakota=`ND`,e.Ohio=`OH`,e.Oklahoma=`OK`,e.Oregon=`OR`,e.Pennsylvania=`PA`,e.RhodeIsland=`RI`,e.SouthCarolina=`SC`,e.SouthDakota=`SD`,e.Tennessee=`TN`,e.Texas=`TX`,e.Utah=`UT`,e.Vermont=`VT`,e.Virginia=`VA`,e.Washington=`WA`,e.WestVirginia=`WV`,e.Wisconsin=`WI`,e.Wyoming=`WY`,e}({}),f=function(e){return e.Canada=`CA`,e[`United States`]=`US`,e}({}),p=function(e){return e.Days90=`Days90`,e.Days365=`Days365`,e}({}),m=function(e){return e[`Most Recent`]=`MostRecent`,e[`Months 3`]=`Months3`,e[`Months 12`]=`Months12`,e}({}),h=function(e){return e.AuthKey=`AuthKey`,e.ApiKey=`ApiKey`,e.BearerToken=`BearerToken`,e}({}),g=function(e){return e.QuestionAndAnswer=`QuestionAndAnswer`,e.ImageSelection=`ImageSelection`,e.MultipleChoice=`MultipleChoice`,e.TextOrCall=`TextOrCall`,e.WaitUntilEUAccept=`WaitUntilEUAccept`,e.MultipleChoiceMultipleAnswers=`MultipleChoiceMultipleAnswers`,e}({}),_=function(e){return e.INVALID_LOGIN=`INVALID_LOGIN`,e.METHOD_NOT_AVAILABLE=`METHOD_NOT_AVAILABLE`,e.INVALID_SECURITY_RESPONSE=`INVALID_SECURITY_RESPONSE`,e.UNKNOWN_CHALLENGE_KEY=`UNKNOWN_CHALLENGE_KEY`,e}({}),v=function(e){return e.Cached=`Cached`,e.ActionRequired=`ActionRequired`,e}({}),y=function(e){return e.GetAccountsDetail=`GetAccountsDetail`,e.KYC=`KYC`,e}({});const b=20;var x=class{static{this.interceptorInstalled=!1}constructor(e){this.REQUEST_TIMEOUT=3e4,this.country=e.country,this.customerId=e.customerId,this.url=e.url,this.apiKey=e.apiKey,this.authKey=e.authKey,this.bearerToken=e.bearerToken,this.axios=e.axiosInstance??c.default.create({baseURL:`${this.url}/${this.customerId}`,headers:{accept:`application/json`,"content-type":`application/json`,...this.authKey?{"flinks-auth-key":this.authKey}:{}}}),this.logger={log:e.logger?.log??console.log,error:e.logger?.error??console.error,info:e.logger?.info??console.info,warn:e.logger?.warn??console.warn,debug:e.logger?.debug??console.debug}}getFlinksUrl(){return`${this.url}/${this.customerId}`}flinksApiUrlBuilder(e,t){let n=``;t?.pathParams?.map(e=>{n=`${n}/${e}`});let r=new URLSearchParams;return Object.entries(t?.queryParams||[]).map(e=>{r.append(e[0],e[1])}),`${this.url}/${this.customerId}/${e}${n}${r.size>0?`?${r.toString()}`:``}`}async getAuthorizeToken(){let e=await this.post(`BankingServices/GenerateAuthorizeToken`,{includeHeaders:[h.AuthKey]});if(e.HttpStatusCode!==200){let t=`Status ${e.HttpStatusCode}: ${e.FlinksCode} | ${e.Message}`;throw Error(`Failed to generate authorize token! \n ${t}`)}return{token:e.Token,timestamp:Date.now()}}async getRequestId(e,t){if(!this.country)throw Error(`No locale provided for flinks!!`);let n=t?.mfaResponse,r={LoginId:e,MostRecentCached:t?.mostRecentCached===void 0?!0:t?.mostRecentCached,Save:t?.save,Tag:t?.tag,SecurityResponses:n,requestId:t?.requestId},i=await this.getAuthorizeToken(),a=await this.post(`BankingServices/Authorize`,{headers:{"flinks-auth-key":i.token},body:r,customTimeout:t?.customTimeout||18e4});if(a?.Message===`Request source is unsupported. (Parameter 'requestSource')
2
+ Actual value was Unknown.`)return this.logger.log(`Flinks Account with login ID ${e} no longer exists! This account should be disabled!`),a;if(!a?.RequestId)throw Error(`Response does not contain RequestId!`);return a}async receivePendingData(e){let t=e=>new Promise(t=>setTimeout(t,e));await t(2e3);for(let n=1;n<=20;n++){let r;try{r=await this.axios.get(`${this.url}/${this.customerId}/${e.PathParam}Async/${e.requestId}`,{headers:e.headers,timeout:this.REQUEST_TIMEOUT})}catch(e){throw Error(`Absolute failure when attempting async fetch.`)}switch(r.status){case 200:return r.data;case 202:await t(1e4),this.logger.log(`still waiting 202: `,n);break;default:this.logger.error(`Flinks async request failed with status ${r.status}, Status text: ${r.statusText}`),r.data&&this.logger.error(`Additional information from Flinks: Flinks Code: ${r.data.FlinksCode}, Message: ${r.data.Message}`),await t(1e4)}}throw Error(`Failed to retrieve pending data`)}async post(e,t){if(!this.country)throw Error(`No locale set for Flinks API!`);let n={...t.headers,...t.includeHeaders?.includes(h.ApiKey)&&{"x-api-key":this.apiKey},...t.includeHeaders?.includes(h.AuthKey)&&{"flinks-auth-key":this.authKey},...t.includeHeaders?.includes(h.BearerToken)&&{Authorization:this.bearerToken}},r=await this.axios.post(this.flinksApiUrlBuilder(e,t),t.body||{},{headers:n,timeout:t?.customTimeout||this.REQUEST_TIMEOUT,validateStatus:()=>!0});if(!(r.status>=200&&r.status<300))if(r.data&&r.data.Message)this.logger.error(`Flinks Post had status: ${r.status} and returned message ${r.data.Message}`);else throw Error(`Flinks Post failed with status ${r.status}: ${r.statusText}`);if(r.data.HttpStatusCode===202){let t={PathParam:e,requestId:r.data.RequestId,HttpStatusCode:202,headers:n};return await this.receivePendingData(t)}return r.data}async patch(e,t){if(!this.country)throw Error(`No locale set for Flinks API!`);let n={...t.headers,...t.includeHeaders?.includes(h.ApiKey)&&{"x-api-key":this.apiKey},...t.includeHeaders?.includes(h.AuthKey)&&{"flinks-auth-key":this.authKey},...t.includeHeaders?.includes(h.BearerToken)&&{Authorization:this.bearerToken}},r=``;t.pathParams?.map(e=>{r=`${r}/${e}`});let i=await this.axios.patch(`${this.url}/${this.customerId}/${e}${r}`,t.body||{},{headers:n,timeout:t?.customTimeout||this.REQUEST_TIMEOUT});if(!(i.status>=200&&i.status<300))if(i.data)this.logger.error(`Flinks Patch had status: ${i.status} and returned message ${i.data.Message}`);else throw Error(`Flinks Patch failed with status ${i.status}: ${i.statusText}`);if(i.data.HttpStatusCode===202){let r={PathParam:e,requestId:t.requestId,HttpStatusCode:202,headers:n};return await this.receivePendingData(r)}return i.data}async get(e,t){if(!this.country)throw Error(`No locale set for Flinks API!`);let n={...t.headers,...t.includeHeaders?.includes(h.ApiKey)&&{"x-api-key":this.apiKey},...t.includeHeaders?.includes(h.AuthKey)&&{"flinks-auth-key":this.authKey},...t.includeHeaders?.includes(h.BearerToken)&&{Authorization:this.bearerToken}},r=await this.axios.get(this.flinksApiUrlBuilder(e,t),{headers:n,timeout:t?.customTimeout||this.REQUEST_TIMEOUT});if(!(r.status>=200&&r.status<300))if(r.data)this.logger.error(`Flinks Get had status: ${r.status} and returned message ${r.data.Message}`);else throw Error(`Flinks Get failed with status ${r.status}: ${r.statusText}`);if(r.data.HttpStatusCode===202){let r={PathParam:e,requestId:t.requestId,HttpStatusCode:202,headers:n};return await this.receivePendingData(r)}return r.data}async delete(e,t){if(!this.country)throw Error(`No locale set for Flinks API!`);let n={...t.headers,...t.includeHeaders?.includes(h.ApiKey)&&{"x-api-key":this.apiKey},...t.includeHeaders?.includes(h.AuthKey)&&{"flinks-auth-key":this.authKey},...t.includeHeaders?.includes(h.BearerToken)&&{Authorization:this.bearerToken}},r=await this.axios.delete(this.flinksApiUrlBuilder(e,t),{headers:n,timeout:t?.customTimeout||this.REQUEST_TIMEOUT});if(!(r.status>=200&&r.status<300))if(r.data)this.logger.error(`Flinks Delete had status: ${r.status} and returned message ${r.data.Message}`);else throw Error(`Flinks Delete failed with status ${r.status}: ${r.statusText}`);if(r.data.HttpStatusCode===202){let r={PathParam:e,requestId:t.requestId,HttpStatusCode:202,headers:n};return await this.receivePendingData(r)}return r.data}};exports.AllowedCurrencyTypes=l,exports.CountryShortcode=f,exports.DaysOfTransactionsOptions=p,exports.EFlinksCodes=_,exports.FlinksApi=x,exports.FlinksHeaderOptions=h,exports.FlinksSecurityType=g,exports.MFAType=v,exports.NumberOfStatements=m,exports.ProvincesShortcode=u,exports.ResponseType=y,exports.StatesShortcode=d;
@@ -0,0 +1,563 @@
1
+ import { AxiosInstance, AxiosRequestConfig } from "axios";
2
+
3
+ //#region src/types.d.ts
4
+ interface Logger {
5
+ log(message: string, ...optionalParams: any[]): void;
6
+ error(message: string, ...optionalParams: any[]): void;
7
+ info?(message: string, ...optionalParams: any[]): void;
8
+ warn?(message: string, ...optionalParams: any[]): void;
9
+ debug?(message: string, ...optionalParams: any[]): void;
10
+ }
11
+ interface FlinksApiConfiguration {
12
+ country: CountryShortcode;
13
+ customerId: string;
14
+ url: string;
15
+ apiKey: string;
16
+ authKey: string;
17
+ bearerToken: string;
18
+ axiosInstance?: AxiosInstance;
19
+ logger?: Logger;
20
+ }
21
+ declare enum AllowedCurrencyTypes {
22
+ "cad" = "CAD",
23
+ "usd" = "USD",
24
+ }
25
+ declare enum ProvincesShortcode {
26
+ "Alberta" = "AB",
27
+ "British Columbia" = "BC",
28
+ "Manitoba" = "MB",
29
+ "New Brunswick" = "NB",
30
+ "Newfoundland and Labrador" = "NL",
31
+ "Northwest Territories" = "NT",
32
+ "Nova Scotia" = "NS",
33
+ "Ontario" = "ON",
34
+ "Prince Edward Island" = "PE",
35
+ "Quebec" = "QC",
36
+ "Saskatchewan" = "SK",
37
+ "Yukon" = "YT",
38
+ "Nunavut" = "NU",
39
+ }
40
+ declare enum StatesShortcode {
41
+ Alabama = "AL",
42
+ Alaska = "AK",
43
+ Arizona = "AZ",
44
+ Arkansas = "AR",
45
+ California = "CA",
46
+ Colorado = "CO",
47
+ Connecticut = "CT",
48
+ Delaware = "DE",
49
+ Florida = "FL",
50
+ Georgia = "GA",
51
+ Hawaii = "HI",
52
+ Idaho = "ID",
53
+ Illinois = "IL",
54
+ Indiana = "IN",
55
+ Iowa = "IA",
56
+ Kansas = "KS",
57
+ Kentucky = "KY",
58
+ Louisiana = "LA",
59
+ Maine = "ME",
60
+ Maryland = "MD",
61
+ Massachusetts = "MA",
62
+ Michigan = "MI",
63
+ Minnesota = "MN",
64
+ Mississippi = "MS",
65
+ Missouri = "MO",
66
+ Montana = "MT",
67
+ Nebraska = "NE",
68
+ Nevada = "NV",
69
+ NewHampshire = "NH",
70
+ NewJersey = "NJ",
71
+ NewMexico = "NM",
72
+ NewYork = "NY",
73
+ NorthCarolina = "NC",
74
+ NorthDakota = "ND",
75
+ Ohio = "OH",
76
+ Oklahoma = "OK",
77
+ Oregon = "OR",
78
+ Pennsylvania = "PA",
79
+ RhodeIsland = "RI",
80
+ SouthCarolina = "SC",
81
+ SouthDakota = "SD",
82
+ Tennessee = "TN",
83
+ Texas = "TX",
84
+ Utah = "UT",
85
+ Vermont = "VT",
86
+ Virginia = "VA",
87
+ Washington = "WA",
88
+ WestVirginia = "WV",
89
+ Wisconsin = "WI",
90
+ Wyoming = "WY",
91
+ }
92
+ declare enum CountryShortcode {
93
+ "Canada" = "CA",
94
+ "United States" = "US",
95
+ }
96
+ type CaAddress = {
97
+ CivicAddress: string;
98
+ City: string;
99
+ Province: ProvincesShortcode;
100
+ PostalCode: string;
101
+ POBox?: string;
102
+ Country: CountryShortcode;
103
+ };
104
+ interface WordLists {
105
+ adjectives: string[];
106
+ verbs: string[];
107
+ nouns: string[];
108
+ }
109
+ interface PendingPackage {
110
+ requestId?: string;
111
+ headers: Record<string, string>;
112
+ PathParam: string;
113
+ FlinksCode?: string;
114
+ Body?: string;
115
+ Config?: AxiosRequestConfig;
116
+ Links?: [{
117
+ rel: string;
118
+ href: string;
119
+ example: string;
120
+ }];
121
+ HttpStatusCode: number;
122
+ Message?: string;
123
+ RequestId?: string;
124
+ }
125
+ interface SecurityChallenge {
126
+ Type: FlinksSecurityType;
127
+ Prompt: string;
128
+ Iterables: string[];
129
+ }
130
+ interface SecurityResponses {
131
+ [key: string]: string[];
132
+ }
133
+ declare enum DaysOfTransactionsOptions {
134
+ "Days90" = "Days90",
135
+ "Days365" = "Days365",
136
+ }
137
+ interface BankInfoOptions {
138
+ /**
139
+ * Contains a valid Authorize Token and represents a successful call to the /Authorize endpoint.
140
+ */
141
+ requestId?: string;
142
+ /**
143
+ * Enable Instant Bank Verification (IBV).
144
+ * Defaults to false.
145
+ */
146
+ WithAccountIdentity?: boolean;
147
+ /**
148
+ * Include customer (KYC) information in account details.
149
+ * Defaults to false.
150
+ */
151
+ WithKYC?: boolean;
152
+ /**
153
+ * Include transactions in account details.
154
+ * Defaults to false.
155
+ */
156
+ WithTransactions?: boolean;
157
+ /**
158
+ * Include balances in account details.
159
+ * Defaults to false.
160
+ */
161
+ WithBalance?: boolean;
162
+ /**
163
+ * Limit the session to specific account IDs.
164
+ */
165
+ AccountsFilter?: string[];
166
+ /**
167
+ * Number of days of transaction history.
168
+ * Defaults to "Days90".
169
+ * - "Days90"
170
+ * - "Days365"
171
+ */
172
+ DaysOfTransactions?: DaysOfTransactionsOptions;
173
+ /**
174
+ * Enable PDF banking statements (Base64).
175
+ * Defaults to false.
176
+ * Must be enabled by Flinks support.
177
+ */
178
+ WithDetailsAndBankingStatements?: boolean;
179
+ /**
180
+ * Number of PDF banking statements to return.
181
+ */
182
+ NumberOfBankingStatements?: number;
183
+ }
184
+ interface FlinksTransactionDetails {
185
+ transactionId: string;
186
+ AccountID: string;
187
+ Key: string;
188
+ Signature: string;
189
+ FlinksAccountID: string;
190
+ FlinksLoginID: string;
191
+ Amount: number;
192
+ }
193
+ interface MFAQuestions {
194
+ Question: string;
195
+ Answer?: string;
196
+ }
197
+ interface Transaction {
198
+ Date: string;
199
+ Code: string | null;
200
+ Description: string;
201
+ Debit: number;
202
+ Credit: number;
203
+ Balance: number;
204
+ Id: string;
205
+ }
206
+ interface TransactionHistory {
207
+ Accounts: {
208
+ Transactions: Transaction[];
209
+ }[];
210
+ }
211
+ declare enum NumberOfStatements {
212
+ "Most Recent" = "MostRecent",
213
+ "Months 3" = "Months3",
214
+ "Months 12" = "Months12",
215
+ }
216
+ type StatementsByAccount = {
217
+ AccountNumber: string;
218
+ Statements: [{
219
+ UniqueId: string;
220
+ FileType: string;
221
+ Base64Bytes: string;
222
+ }];
223
+ };
224
+ type AccountFromSummary = {
225
+ EftEligibleRatio: number;
226
+ ETransferEligibleRatio: number;
227
+ Title: string;
228
+ AccountNumber: string;
229
+ LastFourDigits?: string;
230
+ Balance: Balance;
231
+ Category: string;
232
+ Type: string;
233
+ Currency: AllowedCurrencyTypes;
234
+ Holder: {
235
+ Name: string;
236
+ Address: CaAddress;
237
+ Email: string;
238
+ Id: string;
239
+ };
240
+ };
241
+ interface BankAccountDetails {
242
+ FinancialInstitutionNumber: string;
243
+ BranchTransitNumber: string;
244
+ AccountNumber: string;
245
+ }
246
+ interface FlinksDataOptions {
247
+ includeHeaders?: FlinksHeaderOptions[];
248
+ headers?: Record<string, string>;
249
+ requestId?: string;
250
+ pathParams?: string[];
251
+ queryParams?: Record<string, string>;
252
+ customTimeout?: number;
253
+ }
254
+ interface FlinksPostOptions extends FlinksDataOptions {
255
+ body?: unknown;
256
+ }
257
+ interface FlinksPatchOptions extends FlinksDataOptions {
258
+ body?: unknown;
259
+ }
260
+ interface FlinksGetOptions extends FlinksDataOptions {}
261
+ interface FlinksDeleteOptions extends FlinksDataOptions {}
262
+ declare enum FlinksHeaderOptions {
263
+ AuthKey = "AuthKey",
264
+ ApiKey = "ApiKey",
265
+ BearerToken = "BearerToken",
266
+ }
267
+ /**
268
+ * This could probably be extensible, for the different Security Types
269
+ */
270
+ interface FlinksAuthorizeOptions extends BankInfoOptions {
271
+ mostRecentCached?: boolean;
272
+ save?: boolean;
273
+ mfaResponse?: SecurityResponses[];
274
+ tag?: string;
275
+ customTimeout?: number;
276
+ requestId?: string;
277
+ }
278
+ declare enum FlinksSecurityType {
279
+ "QuestionAndAnswer" = "QuestionAndAnswer",
280
+ "ImageSelection" = "ImageSelection",
281
+ "MultipleChoice" = "MultipleChoice",
282
+ "TextOrCall" = "TextOrCall",
283
+ "WaitUntilEUAccept" = "WaitUntilEUAccept",
284
+ "MultipleChoiceMultipleAnswers" = "MultipleChoiceMultipleAnswers",
285
+ }
286
+ type Balance = {
287
+ Available?: number;
288
+ Current?: number;
289
+ Limit?: number;
290
+ };
291
+ interface IFlinksBankAccountDetails {
292
+ Transactions: IFlinksTransaction[];
293
+ TransitNumber: string;
294
+ InstitutionNumber: string;
295
+ OverdraftLimit: number;
296
+ Title: string;
297
+ AccountNumber: string;
298
+ LastFourDigits: string;
299
+ Balance: IFlinksBalance;
300
+ Category: string;
301
+ Type: string;
302
+ Currency: AllowedCurrencyTypes;
303
+ Holder: IFlinksHolder;
304
+ AccountType: string;
305
+ Id: string;
306
+ }
307
+ interface IFlinksHolder {
308
+ Name: string;
309
+ Address: IFlinksAddress;
310
+ Email: string;
311
+ PhoneNumber: string;
312
+ }
313
+ interface IFlinksBalance {
314
+ Available?: number;
315
+ Current?: number;
316
+ Limit?: number;
317
+ }
318
+ interface IFlinksAddress {
319
+ CivicAddress: string;
320
+ City: string;
321
+ Province: ProvincesShortcode | StatesShortcode;
322
+ PostalCode: string;
323
+ POBox?: string;
324
+ Country: CountryShortcode;
325
+ }
326
+ interface IFlinksLogin {
327
+ Username: string;
328
+ IsScheduledRefresh: boolean;
329
+ LastRefresh: string;
330
+ Type: string;
331
+ Id: string;
332
+ }
333
+ interface IFlinksTransaction {
334
+ Date: string;
335
+ Code?: string | null;
336
+ Description: string;
337
+ Debit?: number | null;
338
+ Credit?: number | null;
339
+ Balance: number;
340
+ Id: string;
341
+ }
342
+ interface IFlinksAccountCredential {
343
+ loginId: string;
344
+ accountId: string;
345
+ institution: string;
346
+ country: CountryShortcode;
347
+ securityType?: FlinksSecurityType;
348
+ }
349
+ interface IFlinksLink {
350
+ rel: string;
351
+ href: string;
352
+ example: string;
353
+ }
354
+ interface FlinksResponse {
355
+ HttpStatusCode: number;
356
+ StatusCode?: number;
357
+ Message?: string;
358
+ FlinksCode?: string;
359
+ RequestId?: string;
360
+ [key: string]: any;
361
+ PathParam?: string;
362
+ ApiKeyNeeded?: boolean;
363
+ }
364
+ interface OnboardEditOrganizationDto {
365
+ organizationId: string;
366
+ organizationName: string;
367
+ organizationCountry: CountryShortcode;
368
+ organizationPlan: string;
369
+ }
370
+ interface OnboardEditUserDto {
371
+ userId: string;
372
+ firstName: string;
373
+ lastName?: string;
374
+ email: string;
375
+ country: CountryShortcode;
376
+ }
377
+ interface IFlinksResponse {
378
+ HttpStatusCode: number;
379
+ Links?: IFlinksLink[];
380
+ Login?: {
381
+ Username: string;
382
+ IsScheduledRefresh: boolean;
383
+ LastRefresh: string;
384
+ Type: string;
385
+ Id: string;
386
+ };
387
+ StatementsByAccount?: IFlinksStatementsByAccount[];
388
+ SecurityChallenges?: SecurityChallenge[];
389
+ InstitutionName?: string;
390
+ InstitutionId?: number;
391
+ Institution?: string;
392
+ RequestId?: string;
393
+ Accounts?: IFlinksBankAccountDetails[];
394
+ Message?: string;
395
+ Tag?: string;
396
+ FlinksCode?: EFlinksCodes;
397
+ }
398
+ interface IFlinksStatementsByAccount {
399
+ AccountNumber: string;
400
+ Statements: IFlinksStatement[];
401
+ }
402
+ interface IFlinksStatement {
403
+ UniqueId: string;
404
+ FileType: string;
405
+ Base64Bytes: string;
406
+ }
407
+ interface IFlinksToken extends IFlinksResponse {
408
+ Token: string;
409
+ }
410
+ interface IFlinksAuthorize extends IFlinksResponse {
411
+ RequestId: string;
412
+ Institution: string;
413
+ Links: IFlinksLink[];
414
+ }
415
+ interface IFlinksDetails extends IFlinksResponse {
416
+ HttpStatusCode: number;
417
+ Accounts: IFlinksBankAccountDetails[];
418
+ Links: IFlinksLink[];
419
+ Tag: string;
420
+ InstitutionName: string;
421
+ Login: IFlinksLogin;
422
+ InstitutionId: number;
423
+ Institution: string;
424
+ RequestId: string;
425
+ }
426
+ interface IFlinksSummary extends IFlinksResponse {
427
+ Login: IFlinksLogin;
428
+ Tag: string;
429
+ InstitutionName: string;
430
+ InstitutionId: number;
431
+ Institution: string;
432
+ RequestId: string;
433
+ Accounts: IFlinksBankAccountDetails[];
434
+ Links: IFlinksLink[];
435
+ }
436
+ interface FlinksAuthorizeToken {
437
+ token: string;
438
+ timestamp: number;
439
+ }
440
+ declare enum EFlinksCodes {
441
+ "INVALID_LOGIN" = "INVALID_LOGIN",
442
+ "METHOD_NOT_AVAILABLE" = "METHOD_NOT_AVAILABLE",
443
+ "INVALID_SECURITY_RESPONSE" = "INVALID_SECURITY_RESPONSE",
444
+ "UNKNOWN_CHALLENGE_KEY" = "UNKNOWN_CHALLENGE_KEY",
445
+ }
446
+ declare enum MFAType {
447
+ "Cached" = "Cached",
448
+ "ActionRequired" = "ActionRequired",
449
+ }
450
+ declare enum ResponseType {
451
+ GetAccountsDetail = "GetAccountsDetail",
452
+ KYC = "KYC",
453
+ }
454
+ interface ICachedFlinksWebhook {
455
+ ResponseType: ResponseType;
456
+ HttpStatusCode: number;
457
+ Accounts?: IFlinksBankAccountDetails[];
458
+ Login: IFlinksLogin;
459
+ Institution: string;
460
+ RequestId: string;
461
+ Tag?: string;
462
+ }
463
+ interface IFlinksWebhookTag {
464
+ origin: string;
465
+ [key: string]: string;
466
+ }
467
+ interface IUniqueLogin {
468
+ institution: string;
469
+ flinksId: string;
470
+ title?: string;
471
+ lastRefresh: Date;
472
+ authorizedAccountIds: string[];
473
+ }
474
+ //#endregion
475
+ //#region src/FlinksApi.d.ts
476
+ /**
477
+ * This is our Flinks API class, which aims to standardize the way we:
478
+ * - Post
479
+ * - Patch
480
+ * - Get
481
+ * - Delete
482
+ * Data when integrating with the Flinks Backend.
483
+ *
484
+ * Calling the API class itself will not work, instead you must call the "useCountry" factory method
485
+ * to get an Instance of the FlinksApi specific to the provided CountryCode.
486
+ *
487
+ */
488
+ declare class FlinksApi {
489
+ private static interceptorInstalled;
490
+ constructor(config: FlinksApiConfiguration);
491
+ protected country: CountryShortcode;
492
+ protected customerId: string;
493
+ protected url: string;
494
+ protected apiKey: string;
495
+ protected authKey: string;
496
+ protected bearerToken: string;
497
+ protected axios: AxiosInstance;
498
+ protected logger: Required<Logger>;
499
+ private REQUEST_TIMEOUT;
500
+ /**
501
+ * Returns a Flinks URL for being registered under a VoPay account,
502
+ * based on the Country this class is registered to return
503
+ */
504
+ getFlinksUrl(): string;
505
+ private flinksApiUrlBuilder;
506
+ getAuthorizeToken(): Promise<FlinksAuthorizeToken>;
507
+ /**
508
+ * Generates an Authorize token & turns it into a Request ID
509
+ * associated with the provided Login ID
510
+ *
511
+ * Only returns the RequestID
512
+ *
513
+ * @param loginId
514
+ */
515
+ getRequestId(loginId: string, options?: FlinksAuthorizeOptions): Promise<IFlinksAuthorize>;
516
+ receivePendingData<T extends IFlinksResponse>(pendingPackage: PendingPackage): Promise<T>;
517
+ /**
518
+ * This function will create a POST request to flinks, and manage any 202 status responses received.
519
+ *
520
+ * Additional allowed options:
521
+ * Body - JSON body object
522
+ *
523
+ * !! Path should omit the first "/" !!
524
+ *
525
+ *
526
+ * @param path
527
+ * @param body
528
+ */
529
+ post<T extends IFlinksResponse>(path: string, options: FlinksPostOptions): Promise<T>;
530
+ /**
531
+ * Patch method of the Flinks API.
532
+ *
533
+ * Additional allowed options:
534
+ * Body - JSON body object
535
+ *
536
+ * !! Path should omit the first "/" !!
537
+ *
538
+ * @param path
539
+ * @param options
540
+ */
541
+ patch<T extends IFlinksResponse>(path: string, options: FlinksPatchOptions): Promise<T>;
542
+ /**
543
+ * Get method for the Flinks API
544
+ *
545
+ *
546
+ * !! Path should omit the first "/" !!
547
+ *
548
+ * @param path
549
+ * @param options
550
+ */
551
+ get(path: string, options: FlinksGetOptions): Promise<IFlinksResponse | FlinksResponse>;
552
+ /**
553
+ * Delete method for our Flinks API
554
+ *
555
+ * !! Path should omit the first "/" !!
556
+ *
557
+ * @param path
558
+ * @param options
559
+ */
560
+ delete(path: string, options: FlinksDeleteOptions): Promise<FlinksResponse>;
561
+ }
562
+ //#endregion
563
+ export { AccountFromSummary, AllowedCurrencyTypes, Balance, BankAccountDetails, BankInfoOptions, CaAddress, CountryShortcode, DaysOfTransactionsOptions, EFlinksCodes, FlinksApi, FlinksApiConfiguration, FlinksAuthorizeOptions, FlinksAuthorizeToken, FlinksDataOptions, FlinksDeleteOptions, FlinksGetOptions, FlinksHeaderOptions, FlinksPatchOptions, FlinksPostOptions, FlinksResponse, FlinksSecurityType, FlinksTransactionDetails, ICachedFlinksWebhook, IFlinksAccountCredential, IFlinksAddress, IFlinksAuthorize, IFlinksBalance, IFlinksBankAccountDetails, IFlinksDetails, IFlinksHolder, IFlinksLink, IFlinksLogin, IFlinksResponse, IFlinksStatement, IFlinksStatementsByAccount, IFlinksSummary, IFlinksToken, IFlinksTransaction, IFlinksWebhookTag, IUniqueLogin, Logger, MFAQuestions, MFAType, NumberOfStatements, OnboardEditOrganizationDto, OnboardEditUserDto, PendingPackage, ProvincesShortcode, ResponseType, SecurityChallenge, SecurityResponses, StatementsByAccount, StatesShortcode, Transaction, TransactionHistory, WordLists };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "flinks-api",
3
+ "version": "1.0.2",
4
+ "description": "TypeScript wrapper for Flinks API, designed primarily for Nest.js Integration. Developed to work for Clove-Financial, but expanded personally by Jeremy Cox.",
5
+ "keywords": ["flinks", "api", "typescript", "nestjs", "banking"],
6
+ "homepage": "https://github.com/JeremyCCox/Flinks-api",
7
+ "engines": {
8
+ "node": ">=22.12.0"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/JeremyCCox/Flinks-api.git"
13
+ },
14
+ "author": {
15
+ "url": "https://github.com/JeremyCCox",
16
+ "name": "Jeremy Cox",
17
+ "email": "jchristophercox@gmail.com"
18
+ },
19
+ "license": "MIT",
20
+ "main": "dist/index.cjs",
21
+ "types": "dist/index.d.cts",
22
+ "type": "module",
23
+ "scripts": {
24
+ "build": "tsdown",
25
+ "prepublishOnly": "npm run build"
26
+ },
27
+ "dependencies": {
28
+ "axios": "1.12.0"
29
+ },
30
+ "devDependencies": {
31
+ "tsdown": "0.15.0",
32
+ "typescript": "5.5.3"
33
+ },
34
+ "private": false
35
+ }