@quiltt/core 4.0.1 → 4.2.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @quiltt/core
2
2
 
3
+ ## 4.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#348](https://github.com/quiltt/quiltt-js/pull/348) [`7e27845`](https://github.com/quiltt/quiltt-js/commit/7e2784523124c87fc6654d8336f924286daade1b) Thanks [@zubairaziz](https://github.com/zubairaziz)! - resolve connectionId persistence issue in QuilttContainer
8
+
9
+ ## 4.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#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
14
+
3
15
  ## 4.0.1
4
16
 
5
17
  ### Patch 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.0.1";
207
+ var version$1 = "4.2.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, Storage as b, cdnBase as c, debugging as d, endpointGraphQL as e, endpointWebsockets as f, version as v };
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
@@ -35,6 +35,7 @@ interface ConnectorSDK extends CallbackManager {
35
35
  connect(connectorId: string, options?: ConnectorSDKConnectOptions): ConnectorSDKConnector;
36
36
  reconnect(connectorId: string, options: ConnectorSDKReconnectOptions): ConnectorSDKConnector;
37
37
  reset(): void;
38
+ resetConnector: (connectorId: string) => void;
38
39
  }
39
40
  interface ConnectorSDKConnector extends CallbackManager {
40
41
  open(): void;
@@ -191,6 +192,23 @@ type FetchResponse<T> = {
191
192
  ok: boolean;
192
193
  };
193
194
 
195
+ type NoContentData = null;
196
+ type ErrorData = {
197
+ message: string;
198
+ instruction: string;
199
+ error_id: string;
200
+ };
201
+ type UnauthorizedData = {
202
+ message: string;
203
+ instruction: string;
204
+ };
205
+ type UnprocessableData = {
206
+ [attribute: string]: Array<string>;
207
+ };
208
+ type BadRequestResponse = FetchResponse<ErrorData>;
209
+ type UnauthorizedResponse = FetchResponse<UnauthorizedData>;
210
+ type UnprocessableResponse = FetchResponse<UnprocessableData>;
211
+
194
212
  declare enum AuthStrategies {
195
213
  Email = "email",
196
214
  Phone = "phone"
@@ -210,20 +228,11 @@ type PasscodePayload = UsernamePayload & {
210
228
  type SessionData = {
211
229
  token: string;
212
230
  };
213
- type NoContentData = null;
214
- type UnauthorizedData = {
215
- message: string;
216
- instruction: string;
217
- };
218
- type UnprocessableData = {
219
- [attribute: string]: Array<string>;
220
- };
221
231
  type Ping = SessionData | UnauthorizedData;
222
232
  type Identify = SessionData | NoContentData | UnprocessableData;
223
233
  type Authenticate = SessionData | UnauthorizedData | UnprocessableData;
224
234
  type Revoke = NoContentData | UnauthorizedData;
225
235
  type SessionResponse = FetchResponse<SessionData>;
226
- type UnprocessableResponse = FetchResponse<UnprocessableData>;
227
236
  declare class AuthAPI {
228
237
  clientId: string | undefined;
229
238
  constructor(clientId?: string | undefined);
@@ -258,6 +267,29 @@ declare class AuthAPI {
258
267
  private body;
259
268
  }
260
269
 
270
+ type InstitutionData = {
271
+ name: string;
272
+ logoUrl: string;
273
+ };
274
+ type InstitutionsData = Array<InstitutionData>;
275
+ type Search = InstitutionsData | ErrorData | UnauthorizedData;
276
+ type SearchResponse = FetchResponse<InstitutionsData>;
277
+ declare class InstitutionsAPI {
278
+ clientId: string;
279
+ agent: string;
280
+ constructor(clientId: string, agent?: string);
281
+ /**
282
+ * Response Statuses:
283
+ * - 200: OK -> Institutions Found
284
+ * - 401: Unauthorized -> Invalid Token
285
+ * - 400: Bad Request -> Invalid Request
286
+ */
287
+ search: (token: string, connectorId: string, term: string, signal?: AbortSignal) => Promise<FetchResponse<Search>>;
288
+ private config;
289
+ private validateStatus;
290
+ private body;
291
+ }
292
+
261
293
  /** Utility types to extend default TS utilities */
262
294
  type Maybe<T> = T | null;
263
295
  type InputMaybe<T> = Maybe<T>;
@@ -383,6 +415,7 @@ declare const version: string;
383
415
  declare const cdnBase: string;
384
416
  declare const endpointAuth: string;
385
417
  declare const endpointGraphQL: string;
418
+ declare const endpointRest: string;
386
419
  declare const endpointWebsockets: string;
387
420
 
388
421
  type RegisteredClaims = {
@@ -422,5 +455,5 @@ declare class Timeoutable {
422
455
  private broadcast;
423
456
  }
424
457
 
425
- export { AuthAPI, AuthLink, AuthStrategies, BatchHttpLink, ConnectorSDKEventType, ErrorLink, ForwardableLink, GlobalStorage, HttpLink, JsonWebTokenParse, LocalStorage, MemoryStorage, Observable, QuilttClient, RetryLink, Storage, SubscriptionLink, TerminatingLink, Timeoutable, VersionLink, cdnBase, debugging, endpointAuth, endpointGraphQL, endpointWebsockets, version };
426
- export type { Claims, ConnectorSDK, ConnectorSDKCallbackMetadata, ConnectorSDKCallbacks, ConnectorSDKConnectOptions, ConnectorSDKConnector, ConnectorSDKConnectorOptions, ConnectorSDKOnEventCallback, ConnectorSDKOnEventExitCallback, ConnectorSDKOnExitAbortCallback, ConnectorSDKOnExitErrorCallback, ConnectorSDKOnExitSuccessCallback, ConnectorSDKOnLoadCallback, ConnectorSDKOnOpenCallback, ConnectorSDKReconnectOptions, DeepPartial, DeepReadonly, Exact, InputMaybe, JsonWebToken, MakeMaybe, MakeOptional, Maybe, Mutable, Nullable, Observer, PasscodePayload, PrivateClaims, QuilttClientOptions, QuilttJWT, RegisteredClaims, SessionResponse, UnprocessableData, UnprocessableResponse, UsernamePayload };
458
+ 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 };
459
+ 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-CVjwwmoB.js';
4
- export { L as LocalStorage, M as MemoryStorage, O as Observable, b as Storage, c as cdnBase, f as endpointWebsockets } from './SubscriptionLink-client-CVjwwmoB.js';
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-BD6UeWjS.js';
4
+ export { L as LocalStorage, M as MemoryStorage, O as Observable, c as Storage, f as cdnBase, g as endpointWebsockets } from './SubscriptionLink-client-BD6UeWjS.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.0.1",
3
+ "version": "4.2.0",
4
4
  "description": "Javascript API client and utilities for Quiltt",
5
5
  "keywords": [
6
6
  "quiltt",
@@ -23,6 +23,7 @@ export interface ConnectorSDK extends CallbackManager {
23
23
  reconnect(connectorId: string, options: ConnectorSDKReconnectOptions): ConnectorSDKConnector
24
24
 
25
25
  reset(): void // For Test and Development Use
26
+ resetConnector: (connectorId: string) => void // For forcing a reset of a specific connector
26
27
  }
27
28
 
28
29
  export interface ConnectorSDKConnector extends CallbackManager {
@@ -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 {
@@ -1 +1,3 @@
1
1
  export * from './auth'
2
+ export * from './institutions'
3
+ export * from './types'
@@ -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>
@@ -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`