@quiltt/core 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/{SubscriptionLink-client-C1V1Dc3C.js → SubscriptionLink-client-BS9H6eZn.js} +3 -2
- package/dist/index.d.ts +45 -10
- package/dist/index.js +50 -3
- package/package.json +4 -4
- package/src/api/browser.ts +3 -0
- package/src/api/rest/auth.ts +2 -4
- package/src/api/rest/index.ts +2 -0
- package/src/api/rest/institutions.ts +70 -0
- package/src/api/rest/types.ts +10 -0
- package/src/configuration.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @quiltt/core
|
|
2
2
|
|
|
3
|
+
## 4.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#342](https://github.com/quiltt/quiltt-js/pull/342) [`6a387ba`](https://github.com/quiltt/quiltt-js/commit/6a387ba0db77912df85c6cd1924f63edf50f9cdd) Thanks [@sirwolfgang](https://github.com/sirwolfgang)! - Create useQuilttInstitutions hook
|
|
8
|
+
|
|
9
|
+
## 4.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#343](https://github.com/quiltt/quiltt-js/pull/343) [`da152b7`](https://github.com/quiltt/quiltt-js/commit/da152b7f42606defde5f55488632bcdc095be592) Thanks [@sirwolfgang](https://github.com/sirwolfgang)! - Add the ability to set nonce for the Quiltt SDK Script
|
|
14
|
+
|
|
3
15
|
## 4.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
|
@@ -204,7 +204,7 @@ import { print } from 'graphql';
|
|
|
204
204
|
*/ const GlobalStorage = new Storage();
|
|
205
205
|
|
|
206
206
|
var name = "@quiltt/core";
|
|
207
|
-
var version$1 = "4.
|
|
207
|
+
var version$1 = "4.1.0";
|
|
208
208
|
|
|
209
209
|
const QUILTT_API_INSECURE = (()=>{
|
|
210
210
|
try {
|
|
@@ -235,6 +235,7 @@ const version = `${name}: v${version$1}`;
|
|
|
235
235
|
const cdnBase = `${protocolHttp}://cdn.${domain}`;
|
|
236
236
|
const endpointAuth = `${protocolHttp}://auth.${domain}/v1/users/session`;
|
|
237
237
|
const endpointGraphQL = `${protocolHttp}://api.${domain}/v1/graphql`;
|
|
238
|
+
const endpointRest = `${protocolHttp}://api.${domain}/v1`;
|
|
238
239
|
const endpointWebsockets = `${protocolWebsockets}://api.${domain}/websockets`;
|
|
239
240
|
|
|
240
241
|
class ActionCableLink extends ApolloLink {
|
|
@@ -298,4 +299,4 @@ class SubscriptionLink extends ActionCableLink {
|
|
|
298
299
|
}
|
|
299
300
|
}
|
|
300
301
|
|
|
301
|
-
export { GlobalStorage as G, LocalStorage as L, MemoryStorage as M, Observable as O, SubscriptionLink as S, endpointAuth as a,
|
|
302
|
+
export { GlobalStorage as G, LocalStorage as L, MemoryStorage as M, Observable as O, SubscriptionLink as S, endpointAuth as a, endpointRest as b, Storage as c, debugging as d, endpointGraphQL as e, cdnBase as f, endpointWebsockets as g, version as v };
|
package/dist/index.d.ts
CHANGED
|
@@ -127,6 +127,8 @@ type ConnectorSDKConnectorOptions = ConnectorSDKCallbacks & {
|
|
|
127
127
|
institution?: string;
|
|
128
128
|
/** The ID of the Connection to reconnect */
|
|
129
129
|
connectionId?: string;
|
|
130
|
+
/** The nonce to use for the script tag */
|
|
131
|
+
nonce?: string;
|
|
130
132
|
};
|
|
131
133
|
|
|
132
134
|
/**
|
|
@@ -189,6 +191,23 @@ type FetchResponse<T> = {
|
|
|
189
191
|
ok: boolean;
|
|
190
192
|
};
|
|
191
193
|
|
|
194
|
+
type NoContentData = null;
|
|
195
|
+
type ErrorData = {
|
|
196
|
+
message: string;
|
|
197
|
+
instruction: string;
|
|
198
|
+
error_id: string;
|
|
199
|
+
};
|
|
200
|
+
type UnauthorizedData = {
|
|
201
|
+
message: string;
|
|
202
|
+
instruction: string;
|
|
203
|
+
};
|
|
204
|
+
type UnprocessableData = {
|
|
205
|
+
[attribute: string]: Array<string>;
|
|
206
|
+
};
|
|
207
|
+
type BadRequestResponse = FetchResponse<ErrorData>;
|
|
208
|
+
type UnauthorizedResponse = FetchResponse<UnauthorizedData>;
|
|
209
|
+
type UnprocessableResponse = FetchResponse<UnprocessableData>;
|
|
210
|
+
|
|
192
211
|
declare enum AuthStrategies {
|
|
193
212
|
Email = "email",
|
|
194
213
|
Phone = "phone"
|
|
@@ -208,20 +227,11 @@ type PasscodePayload = UsernamePayload & {
|
|
|
208
227
|
type SessionData = {
|
|
209
228
|
token: string;
|
|
210
229
|
};
|
|
211
|
-
type NoContentData = null;
|
|
212
|
-
type UnauthorizedData = {
|
|
213
|
-
message: string;
|
|
214
|
-
instruction: string;
|
|
215
|
-
};
|
|
216
|
-
type UnprocessableData = {
|
|
217
|
-
[attribute: string]: Array<string>;
|
|
218
|
-
};
|
|
219
230
|
type Ping = SessionData | UnauthorizedData;
|
|
220
231
|
type Identify = SessionData | NoContentData | UnprocessableData;
|
|
221
232
|
type Authenticate = SessionData | UnauthorizedData | UnprocessableData;
|
|
222
233
|
type Revoke = NoContentData | UnauthorizedData;
|
|
223
234
|
type SessionResponse = FetchResponse<SessionData>;
|
|
224
|
-
type UnprocessableResponse = FetchResponse<UnprocessableData>;
|
|
225
235
|
declare class AuthAPI {
|
|
226
236
|
clientId: string | undefined;
|
|
227
237
|
constructor(clientId?: string | undefined);
|
|
@@ -256,6 +266,29 @@ declare class AuthAPI {
|
|
|
256
266
|
private body;
|
|
257
267
|
}
|
|
258
268
|
|
|
269
|
+
type InstitutionData = {
|
|
270
|
+
name: string;
|
|
271
|
+
logoUrl: string;
|
|
272
|
+
};
|
|
273
|
+
type InstitutionsData = Array<InstitutionData>;
|
|
274
|
+
type Search = InstitutionsData | ErrorData | UnauthorizedData;
|
|
275
|
+
type SearchResponse = FetchResponse<InstitutionsData>;
|
|
276
|
+
declare class InstitutionsAPI {
|
|
277
|
+
clientId: string;
|
|
278
|
+
agent: string;
|
|
279
|
+
constructor(clientId: string, agent?: string);
|
|
280
|
+
/**
|
|
281
|
+
* Response Statuses:
|
|
282
|
+
* - 200: OK -> Institutions Found
|
|
283
|
+
* - 401: Unauthorized -> Invalid Token
|
|
284
|
+
* - 400: Bad Request -> Invalid Request
|
|
285
|
+
*/
|
|
286
|
+
search: (token: string, connectorId: string, term: string, signal?: AbortSignal) => Promise<FetchResponse<Search>>;
|
|
287
|
+
private config;
|
|
288
|
+
private validateStatus;
|
|
289
|
+
private body;
|
|
290
|
+
}
|
|
291
|
+
|
|
259
292
|
/** Utility types to extend default TS utilities */
|
|
260
293
|
type Maybe<T> = T | null;
|
|
261
294
|
type InputMaybe<T> = Maybe<T>;
|
|
@@ -381,6 +414,7 @@ declare const version: string;
|
|
|
381
414
|
declare const cdnBase: string;
|
|
382
415
|
declare const endpointAuth: string;
|
|
383
416
|
declare const endpointGraphQL: string;
|
|
417
|
+
declare const endpointRest: string;
|
|
384
418
|
declare const endpointWebsockets: string;
|
|
385
419
|
|
|
386
420
|
type RegisteredClaims = {
|
|
@@ -420,4 +454,5 @@ declare class Timeoutable {
|
|
|
420
454
|
private broadcast;
|
|
421
455
|
}
|
|
422
456
|
|
|
423
|
-
export { AuthAPI, AuthLink, AuthStrategies, BatchHttpLink,
|
|
457
|
+
export { AuthAPI, AuthLink, AuthStrategies, BatchHttpLink, ConnectorSDKEventType, ErrorLink, ForwardableLink, GlobalStorage, HttpLink, InstitutionsAPI, JsonWebTokenParse, LocalStorage, MemoryStorage, Observable, QuilttClient, RetryLink, Storage, SubscriptionLink, TerminatingLink, Timeoutable, VersionLink, cdnBase, debugging, endpointAuth, endpointGraphQL, endpointRest, endpointWebsockets, version };
|
|
458
|
+
export type { BadRequestResponse, Claims, ConnectorSDK, ConnectorSDKCallbackMetadata, ConnectorSDKCallbacks, ConnectorSDKConnectOptions, ConnectorSDKConnector, ConnectorSDKConnectorOptions, ConnectorSDKOnEventCallback, ConnectorSDKOnEventExitCallback, ConnectorSDKOnExitAbortCallback, ConnectorSDKOnExitErrorCallback, ConnectorSDKOnExitSuccessCallback, ConnectorSDKOnLoadCallback, ConnectorSDKOnOpenCallback, ConnectorSDKReconnectOptions, DeepPartial, DeepReadonly, ErrorData, Exact, InputMaybe, InstitutionData, InstitutionsData, JsonWebToken, MakeMaybe, MakeOptional, Maybe, Mutable, NoContentData, Nullable, Observer, PasscodePayload, PrivateClaims, QuilttClientOptions, QuilttJWT, RegisteredClaims, SearchResponse, SessionResponse, UnauthorizedData, UnauthorizedResponse, UnprocessableData, UnprocessableResponse, UsernamePayload };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApolloLink, ApolloClient } from '@apollo/client/core/index.js';
|
|
2
2
|
export { gql } from '@apollo/client/core/index.js';
|
|
3
|
-
import { G as GlobalStorage, e as endpointGraphQL, v as version, d as debugging, S as SubscriptionLink, a as endpointAuth } from './SubscriptionLink-client-
|
|
4
|
-
export { L as LocalStorage, M as MemoryStorage, O as Observable,
|
|
3
|
+
import { G as GlobalStorage, e as endpointGraphQL, v as version, d as debugging, S as SubscriptionLink, a as endpointAuth, b as endpointRest } from './SubscriptionLink-client-BS9H6eZn.js';
|
|
4
|
+
export { L as LocalStorage, M as MemoryStorage, O as Observable, c as Storage, f as cdnBase, g as endpointWebsockets } from './SubscriptionLink-client-BS9H6eZn.js';
|
|
5
5
|
import { BatchHttpLink as BatchHttpLink$1 } from '@apollo/client/link/batch-http/index.js';
|
|
6
6
|
import crossfetch from 'cross-fetch';
|
|
7
7
|
import { onError } from '@apollo/client/link/error/index.js';
|
|
@@ -254,6 +254,53 @@ class AuthAPI {
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
+
class InstitutionsAPI {
|
|
258
|
+
constructor(clientId, agent = 'web'){
|
|
259
|
+
/**
|
|
260
|
+
* Response Statuses:
|
|
261
|
+
* - 200: OK -> Institutions Found
|
|
262
|
+
* - 401: Unauthorized -> Invalid Token
|
|
263
|
+
* - 400: Bad Request -> Invalid Request
|
|
264
|
+
*/ this.search = async (token, connectorId, term, signal)=>{
|
|
265
|
+
const params = new URLSearchParams();
|
|
266
|
+
params.append('connectorId', connectorId);
|
|
267
|
+
params.append('term', term);
|
|
268
|
+
const response = await fetchWithRetry(`${endpointRest}/sdk/institutions?${params}`, {
|
|
269
|
+
method: 'GET',
|
|
270
|
+
signal,
|
|
271
|
+
...this.config(token)
|
|
272
|
+
});
|
|
273
|
+
return response;
|
|
274
|
+
};
|
|
275
|
+
this.config = (token)=>{
|
|
276
|
+
const headers = new Headers();
|
|
277
|
+
headers.set('Content-Type', 'application/json');
|
|
278
|
+
headers.set('Accept', 'application/json');
|
|
279
|
+
headers.set('X-Quiltt-SDK-Agent', this.agent);
|
|
280
|
+
headers.set('Authorization', `Bearer ${token}`);
|
|
281
|
+
return {
|
|
282
|
+
headers,
|
|
283
|
+
validateStatus: this.validateStatus,
|
|
284
|
+
retry: true
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
this.validateStatus = (status)=>status < 500 && status !== 429;
|
|
288
|
+
this.body = (payload)=>{
|
|
289
|
+
if (!this.clientId) {
|
|
290
|
+
console.error('Quiltt Client ID is not set. Unable to identify & authenticate');
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
session: {
|
|
294
|
+
clientId: this.clientId,
|
|
295
|
+
...payload
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
this.clientId = clientId;
|
|
300
|
+
this.agent = agent;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
257
304
|
const MATCHER = /^(?:[\w-]+\.){2}[\w-]+$/;
|
|
258
305
|
const JsonWebTokenParse = (token)=>{
|
|
259
306
|
if (typeof token === 'undefined' || token === null) return token;
|
|
@@ -296,4 +343,4 @@ const JsonWebTokenParse = (token)=>{
|
|
|
296
343
|
}
|
|
297
344
|
}
|
|
298
345
|
|
|
299
|
-
export { AuthAPI, AuthLink, AuthStrategies, BatchHttpLink, ConnectorSDKEventType, ErrorLink, ForwardableLink, GlobalStorage, HttpLink, JsonWebTokenParse, QuilttClient, RetryLink, SubscriptionLink, TerminatingLink, Timeoutable, VersionLink, debugging, endpointAuth, endpointGraphQL, version };
|
|
346
|
+
export { AuthAPI, AuthLink, AuthStrategies, BatchHttpLink, ConnectorSDKEventType, ErrorLink, ForwardableLink, GlobalStorage, HttpLink, InstitutionsAPI, JsonWebTokenParse, QuilttClient, RetryLink, SubscriptionLink, TerminatingLink, Timeoutable, VersionLink, debugging, endpointAuth, endpointGraphQL, endpointRest, version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quiltt/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Javascript API client and utilities for Quiltt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"quiltt",
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@biomejs/biome": "1.9.4",
|
|
44
|
-
"@types/node": "22.
|
|
44
|
+
"@types/node": "22.14.1",
|
|
45
45
|
"@types/rails__actioncable": "6.1.11",
|
|
46
|
-
"@types/react": "18.3.
|
|
46
|
+
"@types/react": "18.3.20",
|
|
47
47
|
"bunchee": "6.3.4",
|
|
48
48
|
"rimraf": "6.0.1",
|
|
49
|
-
"typescript": "5.
|
|
49
|
+
"typescript": "5.8.2"
|
|
50
50
|
},
|
|
51
51
|
"tags": [
|
|
52
52
|
"quiltt"
|
package/src/api/browser.ts
CHANGED
package/src/api/rest/auth.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { endpointAuth } from '@/configuration'
|
|
2
|
+
|
|
2
3
|
import type { FetchResponse } from './fetchWithRetry'
|
|
3
4
|
import { fetchWithRetry } from './fetchWithRetry'
|
|
5
|
+
import type { NoContentData, UnauthorizedData, UnprocessableData } from './types'
|
|
4
6
|
|
|
5
7
|
export enum AuthStrategies {
|
|
6
8
|
Email = 'email',
|
|
@@ -21,9 +23,6 @@ export type UsernamePayload = EmailInput | PhoneInput
|
|
|
21
23
|
export type PasscodePayload = UsernamePayload & { passcode: string }
|
|
22
24
|
|
|
23
25
|
type SessionData = { token: string }
|
|
24
|
-
type NoContentData = null
|
|
25
|
-
type UnauthorizedData = { message: string; instruction: string }
|
|
26
|
-
export type UnprocessableData = { [attribute: string]: Array<string> }
|
|
27
26
|
|
|
28
27
|
type Ping = SessionData | UnauthorizedData
|
|
29
28
|
type Identify = SessionData | NoContentData | UnprocessableData
|
|
@@ -31,7 +30,6 @@ type Authenticate = SessionData | UnauthorizedData | UnprocessableData
|
|
|
31
30
|
type Revoke = NoContentData | UnauthorizedData
|
|
32
31
|
|
|
33
32
|
export type SessionResponse = FetchResponse<SessionData>
|
|
34
|
-
export type UnprocessableResponse = FetchResponse<UnprocessableData>
|
|
35
33
|
|
|
36
34
|
// https://www.quiltt.dev/api-reference/auth
|
|
37
35
|
export class AuthAPI {
|
package/src/api/rest/index.ts
CHANGED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { endpointRest } from '@/configuration'
|
|
2
|
+
|
|
3
|
+
import type { FetchResponse } from './fetchWithRetry'
|
|
4
|
+
import { fetchWithRetry } from './fetchWithRetry'
|
|
5
|
+
import type { ErrorData, UnauthorizedData } from './types'
|
|
6
|
+
|
|
7
|
+
export type InstitutionData = { name: string; logoUrl: string }
|
|
8
|
+
export type InstitutionsData = Array<InstitutionData>
|
|
9
|
+
|
|
10
|
+
type Search = InstitutionsData | ErrorData | UnauthorizedData
|
|
11
|
+
|
|
12
|
+
export type SearchResponse = FetchResponse<InstitutionsData>
|
|
13
|
+
|
|
14
|
+
export class InstitutionsAPI {
|
|
15
|
+
clientId: string
|
|
16
|
+
agent: string
|
|
17
|
+
|
|
18
|
+
constructor(clientId: string, agent = 'web') {
|
|
19
|
+
this.clientId = clientId
|
|
20
|
+
this.agent = agent
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Response Statuses:
|
|
25
|
+
* - 200: OK -> Institutions Found
|
|
26
|
+
* - 401: Unauthorized -> Invalid Token
|
|
27
|
+
* - 400: Bad Request -> Invalid Request
|
|
28
|
+
*/
|
|
29
|
+
search = async (token: string, connectorId: string, term: string, signal?: AbortSignal) => {
|
|
30
|
+
const params = new URLSearchParams()
|
|
31
|
+
params.append('connectorId', connectorId)
|
|
32
|
+
params.append('term', term)
|
|
33
|
+
|
|
34
|
+
const response = await fetchWithRetry<Search>(`${endpointRest}/sdk/institutions?${params}`, {
|
|
35
|
+
method: 'GET',
|
|
36
|
+
signal,
|
|
37
|
+
...this.config(token),
|
|
38
|
+
})
|
|
39
|
+
return response
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private config = (token?: string) => {
|
|
43
|
+
const headers = new Headers()
|
|
44
|
+
headers.set('Content-Type', 'application/json')
|
|
45
|
+
headers.set('Accept', 'application/json')
|
|
46
|
+
headers.set('X-Quiltt-SDK-Agent', this.agent)
|
|
47
|
+
headers.set('Authorization', `Bearer ${token}`)
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
headers,
|
|
51
|
+
validateStatus: this.validateStatus,
|
|
52
|
+
retry: true,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private validateStatus = (status: number) => status < 500 && status !== 429
|
|
57
|
+
|
|
58
|
+
private body = (payload: any) => {
|
|
59
|
+
if (!this.clientId) {
|
|
60
|
+
console.error('Quiltt Client ID is not set. Unable to identify & authenticate')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
session: {
|
|
65
|
+
clientId: this.clientId,
|
|
66
|
+
...payload,
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FetchResponse } from './fetchWithRetry'
|
|
2
|
+
|
|
3
|
+
export type NoContentData = null
|
|
4
|
+
export type ErrorData = { message: string; instruction: string; error_id: string }
|
|
5
|
+
export type UnauthorizedData = { message: string; instruction: string }
|
|
6
|
+
export type UnprocessableData = { [attribute: string]: Array<string> }
|
|
7
|
+
|
|
8
|
+
export type BadRequestResponse = FetchResponse<ErrorData>
|
|
9
|
+
export type UnauthorizedResponse = FetchResponse<UnauthorizedData>
|
|
10
|
+
export type UnprocessableResponse = FetchResponse<UnprocessableData>
|
package/src/configuration.ts
CHANGED
|
@@ -34,4 +34,5 @@ export const version = `${packageName}: v${packageVersion}`
|
|
|
34
34
|
export const cdnBase = `${protocolHttp}://cdn.${domain}`
|
|
35
35
|
export const endpointAuth = `${protocolHttp}://auth.${domain}/v1/users/session`
|
|
36
36
|
export const endpointGraphQL = `${protocolHttp}://api.${domain}/v1/graphql`
|
|
37
|
+
export const endpointRest = `${protocolHttp}://api.${domain}/v1`
|
|
37
38
|
export const endpointWebsockets = `${protocolWebsockets}://api.${domain}/websockets`
|