@quiltt/core 3.5.5 → 3.6.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/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { Dispatch, SetStateAction } from 'react';
2
1
  import { ApolloLink, Operation, NextLink, Observable as Observable$1, FetchResult, ApolloClientOptions, ApolloClient } from '@apollo/client/index.js';
3
2
  export { ApolloError, InMemoryCache, NormalizedCacheObject, OperationVariables, gql, useMutation, useQuery, useSubscription } from '@apollo/client/index.js';
4
3
  import { BatchHttpLink as BatchHttpLink$1 } from '@apollo/client/link/batch-http/index.js';
@@ -6,176 +5,7 @@ import * as _apollo_client from '@apollo/client';
6
5
  import { HttpLink as HttpLink$1 } from '@apollo/client/link/http/index.js';
7
6
  import { RetryLink as RetryLink$1 } from '@apollo/client/link/retry/index.js';
8
7
  import { ApolloLink as ApolloLink$1, Operation as Operation$1, NextLink as NextLink$1, Observable as Observable$2, FetchResult as FetchResult$1 } from '@apollo/client/core/index.js';
9
- import { AxiosResponse } from 'axios';
10
-
11
- declare const debugging: boolean;
12
- declare const version: string;
13
- declare const cdnBase: string;
14
- declare const endpointAuth: string;
15
- declare const endpointGraphQL: string;
16
- declare const endpointWebsockets: string;
17
-
18
- /** Utility types to extend default TS utilities */
19
- type Maybe<T> = T | null;
20
- type InputMaybe<T> = Maybe<T>;
21
- type Exact<T extends {
22
- [key: string]: unknown;
23
- }> = {
24
- [K in keyof T]: T[K];
25
- };
26
- type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
27
- [SubKey in K]?: Maybe<T[SubKey]>;
28
- };
29
- type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
30
- [SubKey in K]: Maybe<T[SubKey]>;
31
- };
32
- type Nullable<T> = {
33
- [K in keyof T]: T[K] | null;
34
- };
35
- type Mutable<Type> = {
36
- -readonly [Key in keyof Type]: Type[Key];
37
- };
38
- type DeepPartial<T> = T extends object ? {
39
- [P in keyof T]?: DeepPartial<T[P]>;
40
- } : T;
41
- type DeepReadonly<T> = T extends object ? {
42
- [P in keyof T]: DeepReadonly<T[P]>;
43
- } : T;
44
- declare global {
45
- interface Window {
46
- expo: any;
47
- }
48
- }
49
-
50
- type JsonWebToken<T> = {
51
- token: string;
52
- claims: Claims<T>;
53
- };
54
- type Claims<T> = RegisteredClaims & T;
55
- type RegisteredClaims = {
56
- iss: string;
57
- sub: string;
58
- aud: string;
59
- exp: number;
60
- nbf: number;
61
- iat: number;
62
- jti: string;
63
- };
64
- type PrivateClaims = {
65
- oid: string;
66
- eid: string;
67
- cid: string;
68
- aid: string;
69
- ver: number;
70
- };
71
- type QuilttJWT = JsonWebToken<PrivateClaims>;
72
- declare const JsonWebTokenParse: <T>(token: Maybe<string> | undefined) => Maybe<JsonWebToken<T>> | undefined;
73
-
74
- type Observer<T> = Dispatch<SetStateAction<Maybe<T> | undefined>>;
75
- /**
76
- * This is designed to support singletons to share the memory states across all
77
- * instance of hooks to ensure that updates only process once, by storing a value
78
- * then notifying all subscribers when it's updated.
79
- */
80
- declare class Observable<T> {
81
- private state?;
82
- private observers;
83
- constructor(initalState?: Maybe<T>);
84
- get: () => Maybe<T> | undefined;
85
- set: (nextState: Maybe<T> | undefined) => void;
86
- subscribe: (observer: Observer<T>) => void;
87
- unsubscribe: (observer: Observer<T>) => void;
88
- }
89
-
90
- /**
91
- * An error and type safe wrapper for localStorage.
92
- * It allows you to subscribe to changes;
93
- * but localStorage changes only fire with another
94
- * window updates the record.
95
- */
96
- declare class LocalStorage<T> {
97
- private observers;
98
- constructor();
99
- isEnabled: () => boolean;
100
- isDisabled: () => boolean;
101
- get: (key: string) => Maybe<T> | undefined;
102
- set: (key: string, state: Maybe<T> | undefined) => void;
103
- remove: (key: string) => void;
104
- subscribe: (key: string, observer: Observer<T>) => void;
105
- unsubscribe: (key: string, observer: Observer<T>) => void;
106
- private handleStorageEvent;
107
- }
108
-
109
- /**
110
- * This is designed to support effectively an in memory key value store singleton,
111
- * similar to localstorage, but allows you to subscribe to changes within the current
112
- * window.
113
- */
114
- declare class MemoryStorage<T> {
115
- private observables;
116
- get: (key: string) => Maybe<T> | undefined;
117
- set: (key: string, state: Maybe<T> | undefined) => void;
118
- subscribe: (key: string, observer: Observer<T>) => void;
119
- unsubscribe: (key: string, observer: Observer<T>) => void;
120
- }
121
-
122
- /**
123
- * This is wraps both local and memory storage to create a unified interface, that
124
- * allows you to subscribe to all either changes made within this window, or changes
125
- * made by other windows.
126
- */
127
- declare class Storage<T> {
128
- private memoryStore;
129
- private localStore;
130
- private observers;
131
- private monitors;
132
- /**
133
- * Checks memoryStorage before falling back to localStorage.
134
- */
135
- get: (key: string) => Maybe<T> | undefined;
136
- /**
137
- * We don't trust localStorage to always be present, so we can't rely on it to
138
- * update memoryStorage based on emitted changes. So we manage our own
139
- * emitting while using the underlying events to keep memoryStore in sync with
140
- * localStore.
141
- */
142
- set: (key: string, newState: Maybe<T> | undefined) => void;
143
- /**
144
- * Allows you to subscribe to all changes in memory or local storage as a
145
- * single event.
146
- */
147
- subscribe: (key: string, observer: Observer<T>) => void;
148
- unsubscribe: (key: string, observer: Observer<T>) => void;
149
- /**
150
- * Sets bubble the changes down the stack starting with memoryStore and then
151
- * localStore. memoryStore will emit changes to everything within the current
152
- * window context, while localStore will emit changes to every other window
153
- * context.
154
- *
155
- * To ensure that the other windows are updated correctly, changes to localStore
156
- * need to be subscribed and updated to in memory store, which then may be subscribed
157
- * to outside of storage.
158
- */
159
- private monitorLocalStorageChanges;
160
- }
161
-
162
- /**
163
- * This is an singleton to share the memory states across all instances; This
164
- * basically acts like shared memory when there is no localStorage.
165
- */
166
- declare const GlobalStorage: Storage<any>;
167
-
168
- /**
169
- * This is designed to support singletons to timeouts that can broadcast
170
- * to any observers, preventing race conditions with multiple timeouts.
171
- */
172
- declare class Timeoutable {
173
- private timeout?;
174
- private observers;
175
- set: (callback: () => void, delay: number | undefined) => void;
176
- clear: (observer: Observer<void>) => void;
177
- private broadcast;
178
- }
8
+ import { Dispatch, SetStateAction } from 'react';
179
9
 
180
10
  interface CallbackManager {
181
11
  onEvent(callback: ConnectorSDKOnEventCallback): void;
@@ -370,6 +200,14 @@ declare class QuilttClient<T> extends ApolloClient<T> {
370
200
  constructor(options: QuilttClientOptions<T>);
371
201
  }
372
202
 
203
+ type FetchResponse<T> = {
204
+ data: T;
205
+ status: number;
206
+ statusText: string;
207
+ headers: Headers;
208
+ ok: boolean;
209
+ };
210
+
373
211
  declare enum AuthStrategies {
374
212
  Email = "email",
375
213
  Phone = "phone"
@@ -389,7 +227,7 @@ type PasscodePayload = UsernamePayload & {
389
227
  type SessionData = {
390
228
  token: string;
391
229
  };
392
- type NoContentData = void;
230
+ type NoContentData = null;
393
231
  type UnauthorizedData = {
394
232
  message: string;
395
233
  instruction: string;
@@ -401,8 +239,8 @@ type Ping = SessionData | UnauthorizedData;
401
239
  type Identify = SessionData | NoContentData | UnprocessableData;
402
240
  type Authenticate = SessionData | UnauthorizedData | UnprocessableData;
403
241
  type Revoke = NoContentData | UnauthorizedData;
404
- type SessionResponse = AxiosResponse<SessionData>;
405
- type UnprocessableResponse = AxiosResponse<UnprocessableData>;
242
+ type SessionResponse = FetchResponse<SessionData>;
243
+ type UnprocessableResponse = FetchResponse<UnprocessableData>;
406
244
  declare class AuthAPI {
407
245
  clientId: string | undefined;
408
246
  constructor(clientId?: string | undefined);
@@ -411,30 +249,203 @@ declare class AuthAPI {
411
249
  * - 200: OK -> Session is Valid
412
250
  * - 401: Unauthorized -> Session is Invalid
413
251
  */
414
- ping: (token: string) => Promise<AxiosResponse<Ping, any>>;
252
+ ping: (token: string) => Promise<FetchResponse<Ping>>;
415
253
  /**
416
254
  * Response Statuses:
417
255
  * - 201: Created -> Profile Created, New Session Returned
418
256
  * - 202: Accepted -> Profile Found, MFA Code Sent for `authenticate`
419
257
  * - 422: Unprocessable Entity -> Invalid Payload
420
258
  */
421
- identify: (payload: UsernamePayload) => Promise<AxiosResponse<Identify, any>>;
259
+ identify: (payload: UsernamePayload) => Promise<FetchResponse<Identify>>;
422
260
  /**
423
261
  * Response Statuses:
424
262
  * - 201: Created -> MFA Validated, New Session Returned
425
263
  * - 401: Unauthorized -> MFA Invalid
426
264
  * - 422: Unprocessable Entity -> Invalid Payload
427
265
  */
428
- authenticate: (payload: PasscodePayload) => Promise<AxiosResponse<Authenticate, any>>;
266
+ authenticate: (payload: PasscodePayload) => Promise<FetchResponse<Authenticate>>;
429
267
  /**
430
268
  * Response Statuses:
431
269
  * - 204: No Content -> Session Revoked
432
270
  * - 401: Unauthorized -> Session Not Found
433
271
  */
434
- revoke: (token: string) => Promise<AxiosResponse<Revoke, any>>;
272
+ revoke: (token: string) => Promise<FetchResponse<Revoke>>;
435
273
  private config;
436
274
  private validateStatus;
437
275
  private body;
438
276
  }
439
277
 
440
- export { AuthAPI, AuthLink, AuthStrategies, BatchHttpLink, type Claims, type ConnectorSDK, type ConnectorSDKCallbackMetadata, type ConnectorSDKCallbacks, type ConnectorSDKConnectOptions, type ConnectorSDKConnector, type ConnectorSDKConnectorOptions, ConnectorSDKEventType, type ConnectorSDKOnEventCallback, type ConnectorSDKOnEventExitCallback, type ConnectorSDKOnExitAbortCallback, type ConnectorSDKOnExitErrorCallback, type ConnectorSDKOnExitSuccessCallback, type ConnectorSDKOnLoadCallback, type ConnectorSDKReconnectOptions, type DeepPartial, type DeepReadonly, ErrorLink, type Exact, ForwardableLink, GlobalStorage, HttpLink, type InputMaybe, type JsonWebToken, JsonWebTokenParse, LocalStorage, type MakeMaybe, type MakeOptional, type Maybe, MemoryStorage, type Mutable, type Nullable, Observable, type Observer, type PasscodePayload, type PrivateClaims, QuilttClient, type QuilttClientOptions, type QuilttJWT, type RegisteredClaims, RetryLink, type SessionResponse, Storage, SubscriptionLink, TerminatingLink, Timeoutable, type UnprocessableData, type UnprocessableResponse, type UsernamePayload, VersionLink, cdnBase, debugging, endpointAuth, endpointGraphQL, endpointWebsockets, version };
278
+ /** Utility types to extend default TS utilities */
279
+ type Maybe<T> = T | null;
280
+ type InputMaybe<T> = Maybe<T>;
281
+ type Exact<T extends {
282
+ [key: string]: unknown;
283
+ }> = {
284
+ [K in keyof T]: T[K];
285
+ };
286
+ type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
287
+ [SubKey in K]?: Maybe<T[SubKey]>;
288
+ };
289
+ type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
290
+ [SubKey in K]: Maybe<T[SubKey]>;
291
+ };
292
+ type Nullable<T> = {
293
+ [K in keyof T]: T[K] | null;
294
+ };
295
+ type Mutable<Type> = {
296
+ -readonly [Key in keyof Type]: Type[Key];
297
+ };
298
+ type DeepPartial<T> = T extends object ? {
299
+ [P in keyof T]?: DeepPartial<T[P]>;
300
+ } : T;
301
+ type DeepReadonly<T> = T extends object ? {
302
+ [P in keyof T]: DeepReadonly<T[P]>;
303
+ } : T;
304
+ declare global {
305
+ interface Window {
306
+ expo: any;
307
+ }
308
+ }
309
+
310
+ type Observer<T> = Dispatch<SetStateAction<Maybe<T> | undefined>>;
311
+ /**
312
+ * This is designed to support singletons to share the memory states across all
313
+ * instance of hooks to ensure that updates only process once, by storing a value
314
+ * then notifying all subscribers when it's updated.
315
+ */
316
+ declare class Observable<T> {
317
+ private state?;
318
+ private observers;
319
+ constructor(initalState?: Maybe<T>);
320
+ get: () => Maybe<T> | undefined;
321
+ set: (nextState: Maybe<T> | undefined) => void;
322
+ subscribe: (observer: Observer<T>) => void;
323
+ unsubscribe: (observer: Observer<T>) => void;
324
+ }
325
+
326
+ /**
327
+ * An error and type safe wrapper for localStorage.
328
+ * It allows you to subscribe to changes;
329
+ * but localStorage changes only fire with another
330
+ * window updates the record.
331
+ */
332
+ declare class LocalStorage<T> {
333
+ private observers;
334
+ constructor();
335
+ isEnabled: () => boolean;
336
+ isDisabled: () => boolean;
337
+ get: (key: string) => Maybe<T> | undefined;
338
+ set: (key: string, state: Maybe<T> | undefined) => void;
339
+ remove: (key: string) => void;
340
+ subscribe: (key: string, observer: Observer<T>) => void;
341
+ unsubscribe: (key: string, observer: Observer<T>) => void;
342
+ private handleStorageEvent;
343
+ }
344
+
345
+ /**
346
+ * This is designed to support effectively an in memory key value store singleton,
347
+ * similar to localstorage, but allows you to subscribe to changes within the current
348
+ * window.
349
+ */
350
+ declare class MemoryStorage<T> {
351
+ private observables;
352
+ get: (key: string) => Maybe<T> | undefined;
353
+ set: (key: string, state: Maybe<T> | undefined) => void;
354
+ subscribe: (key: string, observer: Observer<T>) => void;
355
+ unsubscribe: (key: string, observer: Observer<T>) => void;
356
+ }
357
+
358
+ /**
359
+ * This is wraps both local and memory storage to create a unified interface, that
360
+ * allows you to subscribe to all either changes made within this window, or changes
361
+ * made by other windows.
362
+ */
363
+ declare class Storage<T> {
364
+ private memoryStore;
365
+ private localStore;
366
+ private observers;
367
+ private monitors;
368
+ /**
369
+ * Checks memoryStorage before falling back to localStorage.
370
+ */
371
+ get: (key: string) => Maybe<T> | undefined;
372
+ /**
373
+ * We don't trust localStorage to always be present, so we can't rely on it to
374
+ * update memoryStorage based on emitted changes. So we manage our own
375
+ * emitting while using the underlying events to keep memoryStore in sync with
376
+ * localStore.
377
+ */
378
+ set: (key: string, newState: Maybe<T> | undefined) => void;
379
+ /**
380
+ * Allows you to subscribe to all changes in memory or local storage as a
381
+ * single event.
382
+ */
383
+ subscribe: (key: string, observer: Observer<T>) => void;
384
+ unsubscribe: (key: string, observer: Observer<T>) => void;
385
+ /**
386
+ * Sets bubble the changes down the stack starting with memoryStore and then
387
+ * localStore. memoryStore will emit changes to everything within the current
388
+ * window context, while localStore will emit changes to every other window
389
+ * context.
390
+ *
391
+ * To ensure that the other windows are updated correctly, changes to localStore
392
+ * need to be subscribed and updated to in memory store, which then may be subscribed
393
+ * to outside of storage.
394
+ */
395
+ private monitorLocalStorageChanges;
396
+ }
397
+ /**
398
+ * This is an singleton to share the memory states across all instances; This
399
+ * basically acts like shared memory when there is no localStorage.
400
+ */
401
+ declare const GlobalStorage: Storage<any>;
402
+
403
+ /**
404
+ * Retrieves the environment variable by key, with fallback and type conversion,
405
+ * supporting Node.js, Vite, and potentially other runtime environments.
406
+ */
407
+ declare const getEnv: (key: string, fallback?: any) => any;
408
+ declare const debugging: any;
409
+ declare const version: string;
410
+ declare const cdnBase: string;
411
+ declare const endpointAuth: string;
412
+ declare const endpointGraphQL: string;
413
+ declare const endpointWebsockets: string;
414
+
415
+ type JsonWebToken<T> = {
416
+ token: string;
417
+ claims: Claims<T>;
418
+ };
419
+ type Claims<T> = RegisteredClaims & T;
420
+ type RegisteredClaims = {
421
+ iss: string;
422
+ sub: string;
423
+ aud: string;
424
+ exp: number;
425
+ nbf: number;
426
+ iat: number;
427
+ jti: string;
428
+ };
429
+ type PrivateClaims = {
430
+ oid: string;
431
+ eid: string;
432
+ cid: string;
433
+ aid: string;
434
+ ver: number;
435
+ };
436
+ type QuilttJWT = JsonWebToken<PrivateClaims>;
437
+ declare const JsonWebTokenParse: <T>(token: Maybe<string> | undefined) => Maybe<JsonWebToken<T>> | undefined;
438
+
439
+ /**
440
+ * This is designed to support singletons to timeouts that can broadcast
441
+ * to any observers, preventing race conditions with multiple timeouts.
442
+ */
443
+ declare class Timeoutable {
444
+ private timeout?;
445
+ private observers;
446
+ set: (callback: () => void, delay: number | undefined) => void;
447
+ clear: (observer: Observer<void>) => void;
448
+ private broadcast;
449
+ }
450
+
451
+ export { AuthAPI, AuthLink, AuthStrategies, BatchHttpLink, type Claims, type ConnectorSDK, type ConnectorSDKCallbackMetadata, type ConnectorSDKCallbacks, type ConnectorSDKConnectOptions, type ConnectorSDKConnector, type ConnectorSDKConnectorOptions, ConnectorSDKEventType, type ConnectorSDKOnEventCallback, type ConnectorSDKOnEventExitCallback, type ConnectorSDKOnExitAbortCallback, type ConnectorSDKOnExitErrorCallback, type ConnectorSDKOnExitSuccessCallback, type ConnectorSDKOnLoadCallback, type ConnectorSDKReconnectOptions, type DeepPartial, type DeepReadonly, ErrorLink, type Exact, ForwardableLink, GlobalStorage, HttpLink, type InputMaybe, type JsonWebToken, JsonWebTokenParse, LocalStorage, type MakeMaybe, type MakeOptional, type Maybe, MemoryStorage, type Mutable, type Nullable, Observable, type Observer, type PasscodePayload, type PrivateClaims, QuilttClient, type QuilttClientOptions, type QuilttJWT, type RegisteredClaims, RetryLink, type SessionResponse, Storage, SubscriptionLink, TerminatingLink, Timeoutable, type UnprocessableData, type UnprocessableResponse, type UsernamePayload, VersionLink, cdnBase, debugging, endpointAuth, endpointGraphQL, endpointWebsockets, getEnv, version };