@chainlink/external-adapter-framework 0.11.0 → 0.12.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/config/index.d.ts +0 -8
- package/config/index.js +0 -8
- package/config/index.js.map +1 -1
- package/package.json +1 -1
- package/transports/websocket.d.ts +6 -5
- package/transports/websocket.js +21 -10
- package/transports/websocket.js.map +1 -1
- package/examples/bank-frick/accounts.d.ts +0 -45
- package/examples/bank-frick/accounts.js +0 -203
- package/examples/bank-frick/accounts.js.map +0 -1
- package/examples/bank-frick/config/index.d.ts +0 -22
- package/examples/bank-frick/config/index.js +0 -60
- package/examples/bank-frick/config/index.js.map +0 -1
- package/examples/bank-frick/index.d.ts +0 -2
- package/examples/bank-frick/index.js +0 -16
- package/examples/bank-frick/index.js.map +0 -1
- package/examples/bank-frick/util.d.ts +0 -4
- package/examples/bank-frick/util.js +0 -40
- package/examples/bank-frick/util.js.map +0 -1
- package/examples/coingecko/src/config/index.d.ts +0 -9
- package/examples/coingecko/src/config/index.js +0 -13
- package/examples/coingecko/src/config/index.js.map +0 -1
- package/examples/coingecko/src/config/overrides.json +0 -10825
- package/examples/coingecko/src/crypto-utils.d.ts +0 -63
- package/examples/coingecko/src/crypto-utils.js +0 -60
- package/examples/coingecko/src/crypto-utils.js.map +0 -1
- package/examples/coingecko/src/endpoint/coins.d.ts +0 -26
- package/examples/coingecko/src/endpoint/coins.js +0 -37
- package/examples/coingecko/src/endpoint/coins.js.map +0 -1
- package/examples/coingecko/src/endpoint/crypto-marketcap.d.ts +0 -3
- package/examples/coingecko/src/endpoint/crypto-marketcap.js +0 -30
- package/examples/coingecko/src/endpoint/crypto-marketcap.js.map +0 -1
- package/examples/coingecko/src/endpoint/crypto-volume.d.ts +0 -3
- package/examples/coingecko/src/endpoint/crypto-volume.js +0 -30
- package/examples/coingecko/src/endpoint/crypto-volume.js.map +0 -1
- package/examples/coingecko/src/endpoint/crypto.d.ts +0 -3
- package/examples/coingecko/src/endpoint/crypto.js +0 -28
- package/examples/coingecko/src/endpoint/crypto.js.map +0 -1
- package/examples/coingecko/src/endpoint/dominance.d.ts +0 -3
- package/examples/coingecko/src/endpoint/dominance.js +0 -28
- package/examples/coingecko/src/endpoint/dominance.js.map +0 -1
- package/examples/coingecko/src/endpoint/global-marketcap.d.ts +0 -3
- package/examples/coingecko/src/endpoint/global-marketcap.js +0 -28
- package/examples/coingecko/src/endpoint/global-marketcap.js.map +0 -1
- package/examples/coingecko/src/endpoint/index.d.ts +0 -6
- package/examples/coingecko/src/endpoint/index.js +0 -16
- package/examples/coingecko/src/endpoint/index.js.map +0 -1
- package/examples/coingecko/src/global-utils.d.ts +0 -42
- package/examples/coingecko/src/global-utils.js +0 -47
- package/examples/coingecko/src/global-utils.js.map +0 -1
- package/examples/coingecko/src/index.d.ts +0 -4
- package/examples/coingecko/src/index.js +0 -21
- package/examples/coingecko/src/index.js.map +0 -1
- package/examples/cryptocompare/src/config/index.d.ts +0 -9
- package/examples/cryptocompare/src/config/index.js +0 -13
- package/examples/cryptocompare/src/config/index.js.map +0 -1
- package/examples/cryptocompare/src/endpoints/crypto.d.ts +0 -40
- package/examples/cryptocompare/src/endpoints/crypto.js +0 -54
- package/examples/cryptocompare/src/endpoints/crypto.js.map +0 -1
- package/examples/cryptocompare/src/endpoints/index.d.ts +0 -1
- package/examples/cryptocompare/src/endpoints/index.js +0 -6
- package/examples/cryptocompare/src/endpoints/index.js.map +0 -1
- package/examples/cryptocompare/src/index.d.ts +0 -4
- package/examples/cryptocompare/src/index.js +0 -16
- package/examples/cryptocompare/src/index.js.map +0 -1
- package/examples/genesis/config/index.d.ts +0 -12
- package/examples/genesis/config/index.js +0 -16
- package/examples/genesis/config/index.js.map +0 -1
- package/examples/genesis/index.d.ts +0 -2
- package/examples/genesis/index.js +0 -13
- package/examples/genesis/index.js.map +0 -1
- package/examples/genesis/sseStream.d.ts +0 -27
- package/examples/genesis/sseStream.js +0 -149
- package/examples/genesis/sseStream.js.map +0 -1
package/config/index.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export declare const BaseSettings: {
|
|
2
|
-
readonly API_ENDPOINT: {
|
|
3
|
-
readonly description: "The URL that certain transports use to retrieve data";
|
|
4
|
-
readonly type: "string";
|
|
5
|
-
};
|
|
6
2
|
readonly API_TIMEOUT: {
|
|
7
3
|
readonly description: "The number of milliseconds a request can be pending before returning a timeout error for data provider request";
|
|
8
4
|
readonly type: "number";
|
|
@@ -166,10 +162,6 @@ export declare const BaseSettings: {
|
|
|
166
162
|
readonly description: "TTL for batch warmer subscriptions";
|
|
167
163
|
readonly default: 300000;
|
|
168
164
|
};
|
|
169
|
-
readonly WS_API_ENDPOINT: {
|
|
170
|
-
readonly description: "Override the base websocket URL within the EA.";
|
|
171
|
-
readonly type: "string";
|
|
172
|
-
};
|
|
173
165
|
readonly WS_SUBSCRIPTION_TTL: {
|
|
174
166
|
readonly description: "";
|
|
175
167
|
readonly type: "number";
|
package/config/index.js
CHANGED
|
@@ -7,10 +7,6 @@ exports.BaseSettings = {
|
|
|
7
7
|
// description: 'The URL of another adapter from which data needs to be retrieved',
|
|
8
8
|
// type: 'string',
|
|
9
9
|
// },
|
|
10
|
-
API_ENDPOINT: {
|
|
11
|
-
description: 'The URL that certain transports use to retrieve data',
|
|
12
|
-
type: 'string',
|
|
13
|
-
},
|
|
14
10
|
API_TIMEOUT: {
|
|
15
11
|
description: 'The number of milliseconds a request can be pending before returning a timeout error for data provider request',
|
|
16
12
|
type: 'number',
|
|
@@ -219,10 +215,6 @@ exports.BaseSettings = {
|
|
|
219
215
|
// type: 'number',
|
|
220
216
|
// default: 3,
|
|
221
217
|
// },
|
|
222
|
-
WS_API_ENDPOINT: {
|
|
223
|
-
description: 'Override the base websocket URL within the EA.',
|
|
224
|
-
type: 'string',
|
|
225
|
-
},
|
|
226
218
|
WS_SUBSCRIPTION_TTL: {
|
|
227
219
|
description: '',
|
|
228
220
|
type: 'number',
|
package/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;IAC1B,YAAY;IACZ,iBAAiB;IACjB,qFAAqF;IACrF,oBAAoB;IACpB,KAAK;IACL,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;IAC1B,YAAY;IACZ,iBAAiB;IACjB,qFAAqF;IACrF,oBAAoB;IACpB,KAAK;IACL,WAAW,EAAE;QACX,WAAW,EACT,gHAAgH;QAClH,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,KAAK;KACf;IACD,WAAW,EAAE;QACX,WAAW,EACT,sIAAsI;QACxI,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,KAAK;KACf;IACD,QAAQ,EAAE;QACR,WAAW,EAAE,2CAA2C;QACxD,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,GAAG;KACb;IACD,gCAAgC,EAAE;QAChC,WAAW,EAAE,iDAAiD;QAC9D,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,KAAK;KACf;IACD,aAAa,EAAE;QACb,WAAW,EAAE,iEAAiE;QAC9E,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,KAAK;KACf;IACD,qBAAqB;IACrB,oBAAoB;IACpB,mBAAmB;IACnB,KAAK;IACL,mBAAmB;IACnB,oBAAoB;IACpB,oBAAoB;IACpB,KAAK;IACL,8BAA8B,EAAE;QAC9B,WAAW,EAAE,qCAAqC;QAClD,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,KAAK;KACf;IACD,gBAAgB,EAAE;QAChB,WAAW,EAAE,4CAA4C;QACzD,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,WAAW;KACrB;IACD,kCAAkC;IAClC,wEAAwE;IACxE,oBAAoB;IACpB,kBAAkB;IAClB,KAAK;IACL,k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GAAG,CACxG,CAAA;aACF;YACD,OAAO,KAAK,CAAA;KACf;AACH,CAAC,CAAA;AAtBY,QAAA,MAAM,UAsBlB"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import WebSocket, { ClientOptions, RawData } from 'ws';
|
|
2
|
-
import {
|
|
2
|
+
import { AdapterDependencies, EndpointContext } from '../adapter';
|
|
3
3
|
import { Cache } from '../cache';
|
|
4
4
|
import { AdapterConfig } from '../config';
|
|
5
5
|
import { BackgroundExecuteRateLimiter } from '../rate-limiting';
|
|
@@ -18,7 +18,7 @@ export declare class WebSocketClassProvider {
|
|
|
18
18
|
*/
|
|
19
19
|
export interface WebSocketTransportConfig<T extends WebsocketTransportGenerics> {
|
|
20
20
|
/** Endpoint to which to open the WS connection*/
|
|
21
|
-
url: (context: EndpointContext<T
|
|
21
|
+
url: (context: EndpointContext<T>, desiredSubs: T['Request']['Params'][]) => Promise<string> | string;
|
|
22
22
|
/** Optional parameters used when establishing the WebSocket connection */
|
|
23
23
|
options?: (context: EndpointContext<T>) => Promise<ClientOptions> | ClientOptions;
|
|
24
24
|
/** Map of handlers for different WS lifecycle events */
|
|
@@ -41,21 +41,21 @@ export interface WebSocketTransportConfig<T extends WebsocketTransportGenerics>
|
|
|
41
41
|
message: (message: T['Provider']['WsMessage'], context: EndpointContext<T>) => ProviderResult<T>[] | undefined;
|
|
42
42
|
};
|
|
43
43
|
/** Map of "builders", functions that will be used to prepare specific WS messages */
|
|
44
|
-
builders
|
|
44
|
+
builders?: {
|
|
45
45
|
/**
|
|
46
46
|
* Builds a WS message that will be sent to subscribe to a specific feed
|
|
47
47
|
*
|
|
48
48
|
* @param params - the body of the adapter request
|
|
49
49
|
* @returns the WS message (can be any type as long as the [[WebSocket]] doesn't complain)
|
|
50
50
|
*/
|
|
51
|
-
subscribeMessage
|
|
51
|
+
subscribeMessage?: (params: T['Request']['Params']) => unknown;
|
|
52
52
|
/**
|
|
53
53
|
* Builds a WS message that will be sent to unsubscribe to a specific feed
|
|
54
54
|
*
|
|
55
55
|
* @param params - the body of the adapter request
|
|
56
56
|
* @returns the WS message (can be any type as long as the [[WebSocket]] doesn't complain)
|
|
57
57
|
*/
|
|
58
|
-
unsubscribeMessage
|
|
58
|
+
unsubscribeMessage?: (params: T['Request']['Params']) => unknown;
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -86,6 +86,7 @@ export declare class WebSocketTransport<T extends WebsocketTransportGenerics> im
|
|
|
86
86
|
subscriptionSet: SubscriptionSet<T['Request']['Params']>;
|
|
87
87
|
localSubscriptions: T['Request']['Params'][];
|
|
88
88
|
wsConnection: WebSocket;
|
|
89
|
+
currentUrl: string;
|
|
89
90
|
constructor(config: WebSocketTransportConfig<T>);
|
|
90
91
|
initialize(dependencies: AdapterDependencies, config: AdapterConfig<T['CustomSettings']>, endpointName: string): Promise<void>;
|
|
91
92
|
registerRequest(req: AdapterRequest<T['Request']>, config: AdapterConfig<T['CustomSettings']>): Promise<void>;
|
package/transports/websocket.js
CHANGED
|
@@ -55,6 +55,7 @@ class WebSocketTransport {
|
|
|
55
55
|
// The double sets serve to create a simple polling mechanism instead of needing a subscription
|
|
56
56
|
// This one would not; this is always local state
|
|
57
57
|
this.localSubscriptions = [];
|
|
58
|
+
this.currentUrl = '';
|
|
58
59
|
}
|
|
59
60
|
async initialize(dependencies, config, endpointName) {
|
|
60
61
|
this.cache = dependencies.cache;
|
|
@@ -134,10 +135,10 @@ class WebSocketTransport {
|
|
|
134
135
|
const unsubscribes = this.localSubscriptions.filter((s) => !desiredSubs.map((ds) => JSON.stringify(ds)).includes(JSON.stringify(s)));
|
|
135
136
|
logger.debug(`${subscribes.length} new subscriptions; ${unsubscribes.length} to unsubscribe`);
|
|
136
137
|
if (subscribes.length) {
|
|
137
|
-
logger.trace(`Will subscribe to: ${subscribes}`);
|
|
138
|
+
logger.trace(`Will subscribe to: ${JSON.stringify(subscribes)}`);
|
|
138
139
|
}
|
|
139
140
|
if (unsubscribes.length) {
|
|
140
|
-
logger.trace(`Will unsubscribe to: ${unsubscribes}`);
|
|
141
|
+
logger.trace(`Will unsubscribe to: ${JSON.stringify(unsubscribes)}`);
|
|
141
142
|
}
|
|
142
143
|
// New subs && no connection -> connect -> add subs
|
|
143
144
|
// No new subs && no connection -> skip
|
|
@@ -147,17 +148,27 @@ class WebSocketTransport {
|
|
|
147
148
|
logger.debug('No entries in subscription set and no established connection, skipping');
|
|
148
149
|
return this.rateLimiter.msUntilNextExecution(context.endpointName);
|
|
149
150
|
}
|
|
150
|
-
|
|
151
|
+
const urlFromConfig = await this.config.url(context, desiredSubs);
|
|
152
|
+
const urlChanged = this.currentUrl !== urlFromConfig;
|
|
153
|
+
let connectionClosed = this.connectionClosed();
|
|
154
|
+
// Check if we should close the current connection
|
|
155
|
+
if (!connectionClosed && urlChanged) {
|
|
156
|
+
logger.info(`Websocket url has changed from ${this.currentUrl} to ${urlFromConfig}, closing connection...`);
|
|
157
|
+
this.wsConnection.close();
|
|
158
|
+
connectionClosed = true;
|
|
159
|
+
}
|
|
160
|
+
// Check if we need to open a new connection
|
|
161
|
+
if (connectionClosed && desiredSubs.length) {
|
|
151
162
|
logger.debug('No established connection and new subscriptions available, connecting to WS');
|
|
152
|
-
const url = await this.config.url(context);
|
|
153
|
-
if (!url) {
|
|
154
|
-
throw new Error('Got no URL from url builder or WS_API_ENDPOINT');
|
|
155
|
-
}
|
|
156
163
|
const options = this.config.options && (await this.config.options(context));
|
|
157
|
-
|
|
164
|
+
this.currentUrl = urlFromConfig;
|
|
165
|
+
await this.establishWsConnection(context, urlFromConfig, options);
|
|
166
|
+
}
|
|
167
|
+
if (this.config.builders) {
|
|
168
|
+
logger.debug('Sending subs/unsubs if there are any');
|
|
169
|
+
const { subscribeMessage, unsubscribeMessage } = this.config.builders;
|
|
170
|
+
await this.sendMessages(context, subscribeMessage ? subscribes.map(subscribeMessage) : subscribes, unsubscribeMessage ? unsubscribes.map(unsubscribeMessage) : unsubscribes);
|
|
158
171
|
}
|
|
159
|
-
logger.debug('Sending subs/unsubs if there are any');
|
|
160
|
-
await this.sendMessages(context, subscribes.map(this.config.builders.subscribeMessage), unsubscribes.map(this.config.builders.unsubscribeMessage));
|
|
161
172
|
// Record WS message and subscription metrics
|
|
162
173
|
transportMetrics.recordWsMessageMetrics(context, subscribes, unsubscribes);
|
|
163
174
|
logger.debug('Setting local state to cache value');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/transports/websocket.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAsD;AAW7C,oBAXF,YAAS,CAWE;AANlB,kCAAqD;AAErD,yBAA+E;AAC/E,4DAA6C;AAK7C,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,oBAAoB,CAAC,CAAA;AAQ/C,MAAa,sBAAsB;IAGjC,MAAM,CAAC,GAAG,CAAC,IAAoB;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,MAAM,CAAC,GAAG;QACR,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;;AATH,wDAUC;AATQ,2BAAI,GAAmB,YAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/transports/websocket.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAsD;AAW7C,oBAXF,YAAS,CAWE;AANlB,kCAAqD;AAErD,yBAA+E;AAC/E,4DAA6C;AAK7C,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,oBAAoB,CAAC,CAAA;AAQ/C,MAAa,sBAAsB;IAGjC,MAAM,CAAC,GAAG,CAAC,IAAoB;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,MAAM,CAAC,GAAG;QACR,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;;AATH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AO,CAAC,CAAC,CAAA;YAC3E,IAAI,CAAC,UAAU,GAAG,aAAa,CAAA;YAC/B,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;SAClE;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;YACxB,MAAM,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAA;YACpD,MAAM,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAA;YACrE,MAAM,IAAI,CAAC,YAAY,CACrB,OAAO,EACP,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,UAAU,EAChE,kBAAkB,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,YAAY,CACzE,CAAA;SACF;QAED,6CAA6C;QAC7C,gBAAgB,CAAC,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAA;QAE1E,MAAM,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAA;QAClD,IAAI,CAAC,kBAAkB,GAAG,WAAW,CAAA;QAErC,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAA;QAC3C,OAAO,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;IACpE,CAAC;CACF;AAtLD,gDAsLC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
-
import { AdapterDependencies, AdapterEndpoint } from '../../adapter';
|
|
3
|
-
import { Cache } from '../../cache';
|
|
4
|
-
import { AdapterConfig } from '../../config';
|
|
5
|
-
import { Transport } from '../../transports';
|
|
6
|
-
import { AdapterRequest, AdapterResponse, SingleNumberResultResponse } from '../../util';
|
|
7
|
-
import { customSettings } from './config';
|
|
8
|
-
import { AdapterInputParameters, BankFrickAccountsRequestSchema, BankFrickAccountsResponseSchema, SigningAlgorithm } from './types';
|
|
9
|
-
export declare type AccountsEndpointTypes = {
|
|
10
|
-
Request: {
|
|
11
|
-
Params: AdapterInputParameters;
|
|
12
|
-
};
|
|
13
|
-
Response: SingleNumberResultResponse;
|
|
14
|
-
CustomSettings: typeof customSettings;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* RestTransport implementation for Bank Frick, which has unusually complex requirements for an EA
|
|
18
|
-
* The RestTransport is generally built to make a single request and return a single response.
|
|
19
|
-
* This transport instead is used to fetch and process pages of data, and also requires a JWT to run
|
|
20
|
-
*
|
|
21
|
-
* This transport does all the heavy lifting in setup(), which is where the paging happens, and it
|
|
22
|
-
* also has complex retry logic that will attempt to refresh the JWT when certain HTTP errors occur
|
|
23
|
-
*/
|
|
24
|
-
export declare class BankFrickAccountsTransport implements Transport<AccountsEndpointTypes> {
|
|
25
|
-
token: string;
|
|
26
|
-
cache: Cache<AdapterResponse<AccountsEndpointTypes['Response']>>;
|
|
27
|
-
initialize(dependencies: AdapterDependencies): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Creates an AxiosRequestConfig object for fetching a page of accounts from the Bank Frick API
|
|
30
|
-
*/
|
|
31
|
-
prepareRequest(firstPosition: number, inputParams: AdapterInputParameters, config: AdapterConfig<typeof customSettings>): AxiosRequestConfig<BankFrickAccountsRequestSchema>;
|
|
32
|
-
/**
|
|
33
|
-
* Request with retry logic for Bank Frick's API. In addition to standard retry logic, this function
|
|
34
|
-
* compares errors against expected errors from the Bank Frick API, and will throw without retries
|
|
35
|
-
* on a known fatal error, or try to refresh the JWT on a known auth error
|
|
36
|
-
**/
|
|
37
|
-
makeRequest(axiosRequest: AxiosRequestConfig<BankFrickAccountsRequestSchema>, config: AdapterConfig<typeof customSettings>, signingAlgorithm?: SigningAlgorithm): Promise<AxiosResponse<BankFrickAccountsResponseSchema>>;
|
|
38
|
-
validateInputParams(params: AdapterInputParameters): string[];
|
|
39
|
-
/**
|
|
40
|
-
* Fetches pages of data from the Bank Frick API, scans for accounts by IBAN, and returns the balance
|
|
41
|
-
* of all found accounts. Returns a 404 if any IBAN isn't found.
|
|
42
|
-
*/
|
|
43
|
-
foregroundExecute(req: AdapterRequest<AccountsEndpointTypes['Request']>, config: AdapterConfig<typeof customSettings>): Promise<AdapterResponse<AccountsEndpointTypes['Response']>>;
|
|
44
|
-
}
|
|
45
|
-
export declare const accountsRestEndpoint: AdapterEndpoint<AccountsEndpointTypes>;
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.accountsRestEndpoint = exports.BankFrickAccountsTransport = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const adapter_1 = require("../../adapter");
|
|
9
|
-
const util_1 = require("../../util");
|
|
10
|
-
const error_1 = require("../../validation/error");
|
|
11
|
-
const util_2 = require("./util");
|
|
12
|
-
const logger = (0, util_1.makeLogger)('BankFrickTransport');
|
|
13
|
-
// Note: this is a shallow pattern that only checks for a country code since IBANs in the sandbox are invalid
|
|
14
|
-
const ibanPattern = /^[A-Z]{2}[A-Z\d]{14,30}$/;
|
|
15
|
-
const inputParameters = {
|
|
16
|
-
ibanIDs: {
|
|
17
|
-
description: 'The list of account ids included in the sum of balances',
|
|
18
|
-
required: true,
|
|
19
|
-
type: 'array',
|
|
20
|
-
},
|
|
21
|
-
signingAlgorithm: {
|
|
22
|
-
description: 'What signing algorithm is used to sign and verify authorization data, one of rsa-sha256, rsa-sha384, or rsa-sha512',
|
|
23
|
-
required: false,
|
|
24
|
-
type: 'string',
|
|
25
|
-
default: 'rsa-sha512',
|
|
26
|
-
options: ['rsa-sha256', 'rsa-sha384', 'rsa-sha512'],
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
// See here for all expected error returned by the API: https://developers.bankfrick.li/docs#errors
|
|
30
|
-
const AuthErrors = {
|
|
31
|
-
401: 'No JWT token provided or token is invalid',
|
|
32
|
-
403: 'API key is invalid or any other condition is hindering the login', // Unclear if this is fatal or not
|
|
33
|
-
};
|
|
34
|
-
const FatalErrors = {
|
|
35
|
-
400: "Invalid parameters passed to Bank Frick's API",
|
|
36
|
-
423: "Authorization is valid, but the user's account is locked",
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* RestTransport implementation for Bank Frick, which has unusually complex requirements for an EA
|
|
40
|
-
* The RestTransport is generally built to make a single request and return a single response.
|
|
41
|
-
* This transport instead is used to fetch and process pages of data, and also requires a JWT to run
|
|
42
|
-
*
|
|
43
|
-
* This transport does all the heavy lifting in setup(), which is where the paging happens, and it
|
|
44
|
-
* also has complex retry logic that will attempt to refresh the JWT when certain HTTP errors occur
|
|
45
|
-
*/
|
|
46
|
-
class BankFrickAccountsTransport {
|
|
47
|
-
async initialize(dependencies) {
|
|
48
|
-
this.cache = dependencies.cache;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Creates an AxiosRequestConfig object for fetching a page of accounts from the Bank Frick API
|
|
52
|
-
*/
|
|
53
|
-
prepareRequest(firstPosition, inputParams, config) {
|
|
54
|
-
const { API_ENDPOINT, BASE_URL, PAGE_SIZE } = config;
|
|
55
|
-
return {
|
|
56
|
-
baseURL: API_ENDPOINT + BASE_URL,
|
|
57
|
-
url: 'accounts',
|
|
58
|
-
method: 'GET',
|
|
59
|
-
params: {
|
|
60
|
-
firstPosition,
|
|
61
|
-
maxResults: PAGE_SIZE,
|
|
62
|
-
},
|
|
63
|
-
headers: {
|
|
64
|
-
Authorization: `Bearer ${this.token}`,
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Request with retry logic for Bank Frick's API. In addition to standard retry logic, this function
|
|
70
|
-
* compares errors against expected errors from the Bank Frick API, and will throw without retries
|
|
71
|
-
* on a known fatal error, or try to refresh the JWT on a known auth error
|
|
72
|
-
**/
|
|
73
|
-
async makeRequest(axiosRequest, config, signingAlgorithm) {
|
|
74
|
-
let retryNumber = 0;
|
|
75
|
-
let response = await axios_1.default.request(axiosRequest);
|
|
76
|
-
while (response.status !== 200) {
|
|
77
|
-
retryNumber++;
|
|
78
|
-
logger.warn('Encountered error when fetching accounts from Bank Frick:', response.status, response.statusText);
|
|
79
|
-
// Evaluate whether the error was fatal, auth, or transient and whether we've exceeded the max number of retries.
|
|
80
|
-
// Throw on fatal, refresh token on auth error, pass on transient until we've exhausted our retries
|
|
81
|
-
if (FatalErrors[response.status]) {
|
|
82
|
-
throw new error_1.AdapterError({
|
|
83
|
-
statusCode: response.status,
|
|
84
|
-
message: response.statusText,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
else if (AuthErrors[response.status]) {
|
|
88
|
-
// We've encountered a known auth error, so try to refresh the token before making another request
|
|
89
|
-
logger.info('Auth error received from the Bank Frick API, attempting to refresh the token');
|
|
90
|
-
this.token = await (0, util_2.generateJWT)(config, signingAlgorithm);
|
|
91
|
-
}
|
|
92
|
-
else if (retryNumber === config.REST_TRANSPORT_MAX_RATE_LIMIT_RETRIES) {
|
|
93
|
-
throw new error_1.AdapterError({
|
|
94
|
-
statusCode: 504,
|
|
95
|
-
message: `Bank Frick transport hit the max number of retries (${config.REST_TRANSPORT_MAX_RATE_LIMIT_RETRIES} retries) and aborted`,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
logger.debug(`Sleeping for ${config.REST_TRANSPORT_MS_BETWEEN_RATE_LIMIT_RETRIES}ms before retrying`);
|
|
99
|
-
await (0, util_1.sleep)(config.REST_TRANSPORT_MS_BETWEEN_RATE_LIMIT_RETRIES);
|
|
100
|
-
response = await axios_1.default.request(axiosRequest);
|
|
101
|
-
}
|
|
102
|
-
return response;
|
|
103
|
-
}
|
|
104
|
-
validateInputParams(params) {
|
|
105
|
-
const encounteredIds = {};
|
|
106
|
-
const errors = [];
|
|
107
|
-
const { ibanIDs } = params;
|
|
108
|
-
ibanIDs.forEach((v) => {
|
|
109
|
-
if (!v.match(ibanPattern)) {
|
|
110
|
-
errors.push(`Invalid IBAN: ${v}`);
|
|
111
|
-
}
|
|
112
|
-
encounteredIds[v] += 1;
|
|
113
|
-
if (encounteredIds[v] > 1) {
|
|
114
|
-
errors.push(`The following IBAN appears more than once in the input parameters: ${v}`);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
return errors;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Fetches pages of data from the Bank Frick API, scans for accounts by IBAN, and returns the balance
|
|
121
|
-
* of all found accounts. Returns a 404 if any IBAN isn't found.
|
|
122
|
-
*/
|
|
123
|
-
async foregroundExecute(req, config) {
|
|
124
|
-
const { ibanIDs, signingAlgorithm } = req.requestContext.data;
|
|
125
|
-
const { PAGE_SIZE = 500 } = config;
|
|
126
|
-
logger.debug(`Validating input: ${JSON.stringify(req.requestContext.data)}`);
|
|
127
|
-
// Scan ibanIDs for duplicates and invalid IBANs
|
|
128
|
-
const validationErrors = this.validateInputParams(req.requestContext.data);
|
|
129
|
-
if (validationErrors.length > 0) {
|
|
130
|
-
throw new error_1.AdapterError({
|
|
131
|
-
statusCode: 420,
|
|
132
|
-
message: `Received the following errors when validating inputParameters:\n ${validationErrors.join('\n')}`,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
// Refresh the token if it isn't set
|
|
136
|
-
if (!this.token) {
|
|
137
|
-
this.token = await (0, util_2.generateJWT)(config, signingAlgorithm);
|
|
138
|
-
}
|
|
139
|
-
let sum = 0;
|
|
140
|
-
let position = 0;
|
|
141
|
-
const keys = ibanIDs;
|
|
142
|
-
logger.info("Fetching accounts from Bank Frick's API...");
|
|
143
|
-
while (keys.length > 0) {
|
|
144
|
-
// TODO Fetching and processing pages can be run concurrently
|
|
145
|
-
const axiosRequest = this.prepareRequest(position, req.requestContext.data, config);
|
|
146
|
-
const response = await this.makeRequest(axiosRequest, config, signingAlgorithm);
|
|
147
|
-
logger.debug(`Evaluating accounts from page ${position / PAGE_SIZE}`);
|
|
148
|
-
response.data.accounts.forEach((v) => {
|
|
149
|
-
logger.trace(`Evaluating ${v.account} (iban: ${v.iban}, type: ${v.type})`);
|
|
150
|
-
const index = ibanIDs.indexOf(v.iban);
|
|
151
|
-
if (index > -1) {
|
|
152
|
-
keys.splice(index, 1);
|
|
153
|
-
sum += v.balance;
|
|
154
|
-
logger.trace(`Found account: ${v.account} (iban: ${v.iban}) with balance of ${v.balance}`);
|
|
155
|
-
logger.trace(`Running sum: ${sum}, number of ibans left to find: ${keys.length}/${ibanIDs.length}`);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
if (!response.data.moreResults) {
|
|
159
|
-
logger.debug('No more results, breaking out of account query loop');
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
position += PAGE_SIZE || 0;
|
|
163
|
-
}
|
|
164
|
-
// 404 if one or more accounts were not found
|
|
165
|
-
if (keys.length > 0) {
|
|
166
|
-
logger.error(`Could not find all accounts, returning 404: ${keys.join(', ')}`);
|
|
167
|
-
const res = {
|
|
168
|
-
data: {
|
|
169
|
-
result: 0,
|
|
170
|
-
},
|
|
171
|
-
statusCode: 404,
|
|
172
|
-
result: 0,
|
|
173
|
-
};
|
|
174
|
-
await this.cache.set(req.requestContext.cacheKey, res, config.CACHE_MAX_AGE);
|
|
175
|
-
}
|
|
176
|
-
logger.debug('Was able to find all accounts, returning balance across all accounts: ', sum);
|
|
177
|
-
const res = {
|
|
178
|
-
data: {
|
|
179
|
-
result: sum,
|
|
180
|
-
},
|
|
181
|
-
statusCode: 200,
|
|
182
|
-
result: sum,
|
|
183
|
-
};
|
|
184
|
-
await this.cache.set(req.requestContext.cacheKey, res, config.CACHE_MAX_AGE);
|
|
185
|
-
return res;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
exports.BankFrickAccountsTransport = BankFrickAccountsTransport;
|
|
189
|
-
exports.accountsRestEndpoint = new adapter_1.AdapterEndpoint({
|
|
190
|
-
name: 'accounts',
|
|
191
|
-
transport: new BankFrickAccountsTransport(),
|
|
192
|
-
inputParameters,
|
|
193
|
-
cacheKeyGenerator: (data) => {
|
|
194
|
-
const sortedData = Object.keys(data)
|
|
195
|
-
.sort()
|
|
196
|
-
.reduce((a, i) => {
|
|
197
|
-
a[i] = data[i];
|
|
198
|
-
return a;
|
|
199
|
-
}, {});
|
|
200
|
-
return `accounts-${JSON.stringify(sortedData)}`;
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
//# sourceMappingURL=accounts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../../src/examples/bank-frick/accounts.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAgE;AAChE,2CAAoE;AAIpE,qCAMmB;AAEnB,kDAAqD;AASrD,iCAAoC;AAEpC,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,oBAAoB,CAAC,CAAA;AAE/C,6GAA6G;AAC7G,MAAM,WAAW,GAAG,0BAA0B,CAAA;AAC9C,MAAM,eAAe,GAAoB;IACvC,OAAO,EAAE;QACP,WAAW,EAAE,yDAAyD;QACtE,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,OAAO;KACd;IACD,gBAAgB,EAAE;QAChB,WAAW,EACT,oHAAoH;QACtH,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,YAAY;QACrB,OAAO,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC;KACpD;CACF,CAAA;AAED,mGAAmG;AACnG,MAAM,UAAU,GAA8B;IAC5C,GAAG,EAAE,2CAA2C;IAChD,GAAG,EAAE,kEAAkE,EAAE,kCAAkC;CAC5G,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K,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,aAAa,CAAC,CAAA;SAC7E;QAED,MAAM,CAAC,KAAK,CAAC,wEAAwE,EAAE,GAAG,CAAC,CAAA;QAC3F,MAAM,GAAG,GAAG;YACV,IAAI,EAAE;gBACJ,MAAM,EAAE,GAAG;aACZ;YACD,UAAU,EAAE,GAAG;YACf,MAAM,EAAE,GAAG;SAC0C,CAAA;QACvD,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,aAAa,CAAC,CAAA;QAC5E,OAAO,GAAG,CAAA;IACZ,CAAC;CACF;AArLD,gEAqLC;AAEY,QAAA,oBAAoB,GAAG,IAAI,yBAAe,CAAwB;IAC7E,IAAI,EAAE,UAAU;IAChB,SAAS,EAAE,IAAI,0BAA0B,EAAE;IAC3C,eAAe;IACf,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE;QAC1B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;aACjC,IAAI,EAAE;aACN,MAAM,CAAC,CAAC,CAA0B,EAAE,CAAC,EAAE,EAAE;YACxC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;YACd,OAAO,CAAC,CAAA;QACV,CAAC,EAAE,EAAE,CAAC,CAAA;QACR,OAAO,YAAY,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAA;IACjD,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SigningAlgorithm } from '../types';
|
|
2
|
-
export declare const signingAlgorithms: SigningAlgorithm[];
|
|
3
|
-
export declare const customSettings: {
|
|
4
|
-
readonly PAGE_SIZE: {
|
|
5
|
-
readonly description: "The number of accounts to fetch per call to /accounts. Must be >= 1 and <= 500.";
|
|
6
|
-
readonly type: "number";
|
|
7
|
-
readonly required: false;
|
|
8
|
-
readonly default: 500;
|
|
9
|
-
readonly validate: (value?: number) => string | undefined;
|
|
10
|
-
};
|
|
11
|
-
readonly API_KEY: {
|
|
12
|
-
readonly description: "API key";
|
|
13
|
-
readonly type: "string";
|
|
14
|
-
readonly required: true;
|
|
15
|
-
};
|
|
16
|
-
readonly PRIVATE_KEY: {
|
|
17
|
-
readonly description: "";
|
|
18
|
-
readonly type: "string";
|
|
19
|
-
readonly required: true;
|
|
20
|
-
readonly validate: (value: string) => string | undefined;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.customSettings = exports.signingAlgorithms = void 0;
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
const util_1 = require("../../../util");
|
|
9
|
-
const logger = (0, util_1.makeLogger)('BankFrickConfig');
|
|
10
|
-
// Used for enum options and validation
|
|
11
|
-
exports.signingAlgorithms = ['rsa-sha256', 'rsa-sha384', 'rsa-sha512'];
|
|
12
|
-
const MAX_PAGE_SIZE = 500;
|
|
13
|
-
exports.customSettings = {
|
|
14
|
-
PAGE_SIZE: {
|
|
15
|
-
description: 'The number of accounts to fetch per call to /accounts. Must be >= 1 and <= 500.',
|
|
16
|
-
type: 'number',
|
|
17
|
-
required: false,
|
|
18
|
-
default: MAX_PAGE_SIZE,
|
|
19
|
-
validate: (value) => {
|
|
20
|
-
if (!value) {
|
|
21
|
-
return '';
|
|
22
|
-
}
|
|
23
|
-
else if (value < 1) {
|
|
24
|
-
return `PAGE_SIZE must be at least >= 1, was ${value}`;
|
|
25
|
-
}
|
|
26
|
-
else if (value > MAX_PAGE_SIZE) {
|
|
27
|
-
return `PAGE_SIZE must be <= 500, was ${value}`;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
API_KEY: {
|
|
32
|
-
description: 'API key',
|
|
33
|
-
type: 'string',
|
|
34
|
-
required: true,
|
|
35
|
-
},
|
|
36
|
-
PRIVATE_KEY: {
|
|
37
|
-
description: '',
|
|
38
|
-
type: 'string',
|
|
39
|
-
required: true,
|
|
40
|
-
validate: (value) => {
|
|
41
|
-
const failedAlgos = [];
|
|
42
|
-
for (const algorithm of exports.signingAlgorithms) {
|
|
43
|
-
const body = { example: 123 };
|
|
44
|
-
try {
|
|
45
|
-
crypto_1.default.sign(algorithm, Buffer.from(JSON.stringify(body)), value);
|
|
46
|
-
logger.trace("Successfully tested PRIVATE_KEY by signing with algorithm '%s'", algorithm);
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
logger.trace("PRIVATE_KEY failed to sign message with algorithm '%s'", algorithm);
|
|
50
|
-
failedAlgos.push(algorithm);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (failedAlgos.length > 0) {
|
|
54
|
-
return `Failed to sign a dummy body using $PRIVATE_KEY with the following algorithms ${failedAlgos.join(',')}`;
|
|
55
|
-
}
|
|
56
|
-
logger.debug('$PRIVATE_KEY successfully signed a dummy body with all supported algorithms');
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/examples/bank-frick/config/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAE3B,wCAA0C;AAE1C,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,iBAAiB,CAAC,CAAA;AAE5C,uCAAuC;AAC1B,QAAA,iBAAiB,GAAuB,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAA;AAC/F,MAAM,aAAa,GAAG,GA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gF,WAAW,CAAC,IAAI,CACrG,GAAG,CACJ,EAAE,CAAA;aACJ;YACD,MAAM,CAAC,KAAK,CAAC,6EAA6E,CAAC,CAAA;QAC7F,CAAC;KACF;CACO,CAAA"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.adapter = void 0;
|
|
4
|
-
const adapter_1 = require("../../adapter");
|
|
5
|
-
const accounts_1 = require("./accounts");
|
|
6
|
-
const config_1 = require("./config");
|
|
7
|
-
exports.adapter = new adapter_1.Adapter({
|
|
8
|
-
name: 'BANK-FRICK',
|
|
9
|
-
defaultEndpoint: 'accounts',
|
|
10
|
-
endpoints: [accounts_1.accountsRestEndpoint],
|
|
11
|
-
customSettings: config_1.customSettings,
|
|
12
|
-
envDefaultOverrides: {
|
|
13
|
-
API_ENDPOINT: 'https://olbsandbox.bankfrick.li/webapi/v2',
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/examples/bank-frick/index.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AACvC,yCAAiD;AACjD,qCAAyC;AAE5B,QAAA,OAAO,GAAG,IAAI,iBAAO,CAAC;IACjC,IAAI,EAAE,YAAY;IAClB,eAAe,EAAE,UAAU;IAC3B,SAAS,EAAE,CAAC,+BAAoB,CAAC;IACjC,cAAc,EAAd,uBAAc;IACd,mBAAmB,EAAE;QACnB,YAAY,EAAE,2CAA2C;KAC1D;CACF,CAAC,CAAA"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { SigningAlgorithm } from './types';
|
|
2
|
-
import { customSettings } from './config';
|
|
3
|
-
import { AdapterConfig } from '../../config';
|
|
4
|
-
export declare const generateJWT: (config: AdapterConfig<typeof customSettings>, signingAlgorithm?: SigningAlgorithm) => Promise<string>;
|