@quiltt/core 3.3.2 → 3.3.4
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/api/graphql/index.cjs +1 -1
- package/dist/api/graphql/index.cjs.map +1 -1
- package/dist/api/graphql/index.js +1 -1
- package/dist/api/graphql/index.js.map +1 -1
- package/dist/api/graphql/links/actioncable/index.cjs.map +1 -1
- package/dist/api/graphql/links/actioncable/index.js.map +1 -1
- package/dist/api/graphql/links/index.cjs +1 -1
- package/dist/api/graphql/links/index.cjs.map +1 -1
- package/dist/api/graphql/links/index.js +1 -1
- package/dist/api/graphql/links/index.js.map +1 -1
- package/dist/api/index.cjs +1 -1
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/rest/index.cjs.map +1 -1
- package/dist/api/rest/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/JsonWebToken.ts","../src/Observable.ts","../src/Storage/Local.ts","../src/Storage/Memory.ts","../src/Storage/index.ts","../src/Timeoutable.ts","../src/api/browser.ts","../src/api/graphql/links/AuthLink.ts","../src/api/graphql/links/BatchHttpLink.ts","../package.json","../src/configuration.ts","../src/api/graphql/links/ErrorLink.ts","../src/api/graphql/links/ForwardableLink.ts","../src/api/graphql/links/HttpLink.ts","../src/api/graphql/links/RetryLink.ts","../src/api/graphql/links/ActionCableLink.ts","../src/api/graphql/links/actioncable/adapters.ts","../src/api/graphql/links/actioncable/logger.ts","../src/api/graphql/links/actioncable/connection_monitor.ts","../src/api/graphql/links/actioncable/internal.ts","../src/api/graphql/links/actioncable/connection.ts","../src/api/graphql/links/actioncable/subscription.ts","../src/api/graphql/links/actioncable/subscription_guarantor.ts","../src/api/graphql/links/actioncable/subscriptions.ts","../src/api/graphql/links/actioncable/consumer.ts","../src/api/graphql/links/actioncable/index.ts","../src/api/graphql/links/SubscriptionLink.ts","../src/api/graphql/links/TerminatingLink.ts","../src/api/graphql/links/VersionLink.ts","../src/api/graphql/client.ts","../src/api/rest/axios.ts","../src/api/rest/AuthAPI.ts"],"names":["MATCHER","JsonWebTokenParse","token","_header","payload","_signature","error","Observable","initalState","__publicField","nextState","update","observer","LocalStorage","key","state","_a","event","newState","observers","MemoryStorage","Storage","prevValue","GlobalStorage","Timeoutable","callback","delay","ConnectorSDKEventType","ApolloLink","AuthLink","operation","forward","headers","__spreadProps","__spreadValues","ApolloHttpLink","fetch","name","version","QUILTT_API_INSECURE","e","QUILTT_API_DOMAIN","QUILTT_DEBUG","domain","protocolHttp","protocolWebsockets","debugging","endpointAuth","endpointGraphQL","endpointWebsockets","BatchHttpLink","onError","ErrorLink","graphQLErrors","networkError","message","locations","path","ForwardableLink","HttpLink","ApolloRetryLink","RetryLink","_operation","print","adapters_default","Logger","messages","logger","logger_default","now","secondsSince","time","ConnectionMonitor","connection","staleThreshold","reconnectionBackoffRate","backoff","jitter","connection_monitor_default","INTERNAL","internal_default","message_types","protocols","supportedProtocols","indexOf","Connection","consumer","data","socketProtocols","allowReconnect","states","eventName","handler","identifier","reason","reconnect","type","_event","connection_default","extend","object","properties","value","Subscription","params","mixin","action","subscription_default","SubscriptionGuarantor","subscriptions","subscription","s","subscription_guarantor_default","Subscriptions","channelName","channel","callbackName","args","command","subscriptions_default","Consumer","url","createWebSocketURL","subprotocol","a","consumer_default","createConsumer","getConfig","element","ActionCableLink","options","_next","channelId","actionName","connectionParams","_b","ActionCableLink_default","SubscriptionLink","TerminatingLink","VersionLink","ApolloClient","InMemoryCache","gql","useMutation","useQuery","useSubscription","QuilttClient","isSubscriptionOperation","kind","isBatchable","authLink","subscriptionsLink","quilttLink","Axios","RETRY_DELAY","RETRIES","axios","config","response","messageLower","resolve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CAAC,EAEY,KAAK,IAAMD,EAAMC,CAAM,CAAC,CACvC,CAAC,EC1CM,IAAKI,QACVA,EAAA,MAAQ,QACRA,EAAA,MAAQ,QAFEA,QAAA,IAgCCC,GAAN,KAAc,CAGnB,YAAYC,EAA+B,CAF3C1J,EAAA,iBAWAA,EAAA,YAAQP,GACC0J,EAAM,IAAU7G,EAAc,KAAK,OAAO7C,CAAK,CAAC,GASzDO,EAAA,gBAAYL,GACHwJ,EAAM,KAAgB7G,EAAc,KAAK,KAAK3C,CAAO,EAAG,KAAK,OAAO,CAAC,GAS9EK,EAAA,oBAAgBL,GACPwJ,EAAM,IAAkB7G,EAAc,KAAK,KAAK3C,CAAO,EAAG,KAAK,OAAO,CAAC,GAQhFK,EAAA,cAAUP,GACD0J,EAAM,OAAe7G,EAAc,KAAK,OAAO7C,CAAK,CAAC,GAG9DO,EAAA,KAAQ,SAAUP,GAAuC,CACvD,IAAM8B,EAAoC,CACxC,eAAgB,mBAChB,OAAQ,kBACV,EAEA,OAAI9B,IACF8B,EAAQ,cAAgB,UAAU9B,KAG7B,CACL,QAAS8B,EACT,eAAgB,KAAK,eACrB,MAAO,EACT,CACF,GAEAvB,EAAA,KAAQ,iBAAkB2J,GAAmBA,EAAS,KAEtD3J,EAAA,KAAQ,OAAQL,IACT,KAAK,UACR,QAAQ,MAAM,gEAAgE,EAGzE,CACL,QAAS8B,EAAA,CACP,aAAc,KAAK,UAChB9B,EAEP,IAtEA,KAAK,SAAW+J,CAClB,CAuEF","sourcesContent":["import type { Maybe } from './types'\n\nexport type JsonWebToken<T> = {\n token: string // Raw JWT Token\n claims: Claims<T>\n}\n\nexport type Claims<T> = RegisteredClaims & T\n\nexport type RegisteredClaims = {\n iss: string // (issuer): Issuer of the JWT\n sub: string // (subject): Subject of the JWT (Person ID)\n aud: string // (audience): Recipient for which the JWT is intended\n exp: number // (expiration time): Time after which the JWT expires\n nbf: number // (not before time): Time before which the JWT must not be accepted for processing\n iat: number // (issued at time): Time at which the JWT was issued; can be used to determine age of the JWT\n jti: string // (JWT ID): Unique identifier; can be used to prevent the JWT from being replayed (allows a token to be used only once)\n}\n\nexport type PrivateClaims = {\n oid: string // Organization ID\n eid: string // Environment ID\n did: string // Deployment ID\n aid: string // Administrator ID\n ver: number // Session Token Version\n}\n\nexport type QuilttJWT = JsonWebToken<PrivateClaims>\n\nconst MATCHER = /^(?:[\\w-]+\\.){2}[\\w-]+$/\n\nexport const JsonWebTokenParse = <T>(\n token: Maybe<string> | undefined\n): Maybe<JsonWebToken<T>> | undefined => {\n if (typeof token === 'undefined' || token === null) return token\n\n if (!MATCHER.test(token)) {\n console.error(`Invalid Session Token: ${token}`)\n return\n }\n\n const [_header, payload, _signature] = token.split('.')\n\n try {\n return { token: token, claims: JSON.parse(atob(payload)) }\n } catch (error) {\n console.error(`Invalid Session Token: ${error}`)\n }\n}\n","import type { Dispatch, SetStateAction } from 'react'\nimport type { Maybe } from './types'\n\nexport type Observer<T> = Dispatch<SetStateAction<Maybe<T> | undefined>>\n\n/**\n * This is designed to support singletons to share the memory states across all\n * instance of hooks to ensure that updates only process once, by storing a value\n * then notifying all subscribers when it's updated.\n */\nexport class Observable<T> {\n private state?: Maybe<T>\n private observers: Observer<T>[] = []\n\n constructor(initalState?: Maybe<T>) {\n this.state = initalState\n }\n\n get = () => {\n return this.state\n }\n\n set = (nextState: Maybe<T> | undefined) => {\n if (this.state === nextState) return\n\n this.state = nextState\n this.observers.forEach((update) => update(nextState))\n }\n\n subscribe = (observer: Observer<T>) => {\n this.observers.push(observer)\n }\n\n unsubscribe = (observer: Observer<T>) => {\n this.observers = this.observers.filter((update) => update !== observer)\n }\n}\n\nexport default Observable\n","import type { Maybe } from '../types'\nimport type { Observer } from '../Observable'\n\n/**\n * An error and type safe wrapper for localStorage.\n * It allows you to subscribe to changes;\n * but localStorage changes only fire with another\n * window updates the record.\n */\nexport class LocalStorage<T> {\n private observers: { [key: string]: Observer<T>[] } = {}\n\n constructor() {\n if (typeof window !== 'undefined' && !window?.expo) {\n window.addEventListener('storage', this.handleStorageEvent.bind(this))\n }\n }\n\n isEnabled = (): boolean => {\n try {\n localStorage.setItem(`quiltt.ping`, 'pong')\n localStorage.removeItem(`quiltt.ping`)\n return true\n } catch (error) {\n return false\n }\n }\n\n isDisabled = (): boolean => !this.isEnabled()\n\n get = (key: string): Maybe<T> | undefined => {\n if (typeof window === 'undefined' || !!window.expo) return undefined\n\n try {\n const state = window.localStorage.getItem(`quiltt.${key}`)\n return state ? JSON.parse(state) : state\n } catch (error) {\n console.warn(`localStorage Error: \"quiltt.${key}\"`, error)\n return undefined\n }\n }\n\n set = (key: string, state: Maybe<T> | undefined): void => {\n if (typeof window === 'undefined' || !!window.expo) return\n\n try {\n if (state) {\n window.localStorage.setItem(`quiltt.${key}`, JSON.stringify(state))\n } else {\n window.localStorage.removeItem(`quiltt.${key}`)\n }\n } catch (error) {\n console.warn(`localStorage Error: \"quiltt.${key}\"`, error)\n }\n }\n\n remove = (key: string) => {\n try {\n window.localStorage.removeItem(`quiltt.${key}`)\n } catch (error) {\n console.warn(`localStorage Error: \"quiltt.${key}\">`, error)\n }\n }\n\n subscribe = (key: string, observer: Observer<T>) => {\n if (!this.observers[key]) this.observers[key] = []\n\n this.observers[key].push(observer)\n }\n\n unsubscribe = (key: string, observer: Observer<T>) => {\n this.observers[key] = this.observers[key]?.filter((update) => update !== observer)\n }\n\n // if there is a key, then trigger the related updates. If there is not key\n // it means that a record has been removed and everything needs to be rechecked.\n private handleStorageEvent = (event: StorageEvent) => {\n if (event.key && event.key.includes('quiltt.')) {\n const newState = event.newValue ? JSON.parse(event.newValue) : null\n\n if (this.observers[event.key]) {\n this.observers[event.key].forEach((update) => update(newState))\n }\n } else {\n Object.entries(this.observers).forEach(([key, observers]) => {\n observers.forEach((update) => update(this.get(key)))\n })\n }\n }\n}\n\nexport default LocalStorage\n","import type { Maybe } from '../types'\n\nimport { Observable } from '../Observable'\nimport type { Observer } from '../Observable'\n\n/**\n * This is designed to support effectively an in memory key value store singleton,\n * similar to localstorage, but allows you to subscribe to changes within the current\n * window.\n */\nexport class MemoryStorage<T> {\n private observables: { [key: string]: Observable<T> } = {}\n\n get = (key: string) => {\n if (this.observables[key]) {\n return this.observables[key].get()\n } else {\n return undefined\n }\n }\n\n set = (key: string, state: Maybe<T> | undefined): void => {\n if (!this.observables[key]) {\n this.observables[key] = new Observable<T>(state)\n } else {\n this.observables[key].set(state)\n }\n }\n\n subscribe = (key: string, observer: Observer<T>): void => {\n if (!this.observables[key]) this.observables[key] = new Observable<T>()\n\n this.observables[key].subscribe(observer)\n }\n\n unsubscribe = (key: string, observer: Observer<T>): void => {\n if (this.observables[key]) {\n this.observables[key].unsubscribe(observer)\n }\n }\n}\n\nexport default MemoryStorage\n","import type { Maybe } from '../types'\n\nimport type { Observer } from '../Observable'\nimport { LocalStorage } from './Local'\nimport { MemoryStorage } from './Memory'\n\n/**\n * This is wraps both local and memory storage to create a unified interface, that\n * allows you to subscribe to all either changes made within this window, or changes\n * made by other windows.\n */\nexport class Storage<T> {\n private memoryStore = new MemoryStorage<T>()\n private localStore = new LocalStorage<T>()\n private observers: { [key: string]: Observer<T>[] } = {}\n private monitors: Set<string> = new Set()\n\n /**\n * Checks memoryStorage before falling back to localStorage.\n */\n get = (key: string): Maybe<T> | undefined => {\n this.monitorLocalStorageChanges(key)\n\n let state = this.memoryStore.get(key)\n\n if (state === undefined) {\n state = this.localStore.get(key)\n }\n\n return state\n }\n\n /**\n * We don't trust localStorage to always be present, so we can't rely on it to\n * update memoryStorage based on emitted changes. So we manage our own\n * emitting while using the underlying events to keep memoryStore in sync with\n * localStore.\n */\n set = (key: string, newState: Maybe<T> | undefined) => {\n this.monitorLocalStorageChanges(key)\n\n this.localStore.set(key, newState)\n this.memoryStore.set(key, newState)\n\n this.observers[key]?.forEach((update) => update(newState))\n }\n\n /**\n * Allows you to subscribe to all changes in memory or local storage as a\n * single event.\n */\n subscribe = (key: string, observer: Observer<T>) => {\n if (!this.observers[key]) this.observers[key] = []\n\n this.observers[key].push(observer)\n }\n\n unsubscribe = (key: string, observer: Observer<T>) => {\n this.observers[key] = this.observers[key]?.filter((update) => update !== observer)\n }\n\n /**\n * Sets bubble the changes down the stack starting with memoryStore and then\n * localStore. memoryStore will emit changes to everything within the current\n * window context, while localStore will emit changes to every other window\n * context.\n *\n * To ensure that the other windows are updated correctly, changes to localStore\n * need to be subscribed and updated to in memory store, which then may be subscribed\n * to outside of storage.\n */\n private monitorLocalStorageChanges = (key: string) => {\n if (this.monitors.has(key)) return\n this.monitors.add(key)\n\n this.localStore.subscribe(key, (nextState) => {\n const prevValue = this.memoryStore.get(key)\n const newState = nextState instanceof Function ? nextState(prevValue) : nextState\n\n this.memoryStore.set(key, newState)\n this.observers[key]?.forEach((update) => update(newState))\n })\n }\n}\n\nexport * from './Local'\nexport * from './Memory'\n\n/**\n * This is an singleton to share the memory states across all instances; This\n * basically acts like shared memory when there is no localStorage.\n */\nexport const GlobalStorage = new Storage<any>()\n","import type { Observer } from './Observable'\n\n/**\n * This is designed to support singletons to timeouts that can broadcast\n * to any observers, preventing race conditions with multiple timeouts.\n */\nexport class Timeoutable {\n private timeout?: ReturnType<typeof setTimeout>\n private observers: Observer<void>[] = []\n\n set = (callback: () => void, delay: number | undefined) => {\n if (this.timeout) {\n clearTimeout(this.timeout)\n }\n\n this.observers.push(callback)\n this.timeout = setTimeout(this.broadcast.bind(this), delay)\n }\n\n clear = (observer: Observer<void>) => {\n this.observers = this.observers.filter((callback) => callback !== observer)\n }\n\n // Only sends to the 1st listener, but ensures that someone is notified\n private broadcast = () => {\n if (this.observers.length === 0) return\n\n this.observers[0](undefined)\n }\n}\n\nexport default Timeoutable\n","interface CallbackManager {\n onEvent(callback: ConnectorSDKOnEventCallback): void\n onLoad(callback: ConnectorSDKOnLoadCallback): void\n onExit(callback: ConnectorSDKOnEventExitCallback): void\n onExitSuccess(callback: ConnectorSDKOnExitSuccessCallback): void\n onExitAbort(callback: ConnectorSDKOnExitAbortCallback): void\n onExitError(callback: ConnectorSDKOnExitErrorCallback): void\n\n // Because it's well within React behavior to try to register a billion functions\n offEvent(callback: ConnectorSDKOnEventCallback): void\n offLoad(callback: ConnectorSDKOnLoadCallback): void\n offExit(callback: ConnectorSDKOnEventExitCallback): void\n offExitSuccess(callback: ConnectorSDKOnExitSuccessCallback): void\n offExitAbort(callback: ConnectorSDKOnExitAbortCallback): void\n offExitError(callback: ConnectorSDKOnExitErrorCallback): void\n}\n\nexport interface ConnectorSDK extends CallbackManager {\n authenticate(token: string | null | undefined): void\n connect(connectorId: string, options?: ConnectorSDKConnectOptions): ConnectorSDKConnector\n reconnect(connectorId: string, options: ConnectorSDKReconnectOptions): ConnectorSDKConnector\n\n reset(): void\n}\n\nexport interface ConnectorSDKConnector extends CallbackManager {\n open(): void\n}\n\n/**\n * Types for optional callbacks in the ConnectorSDK.\n *\n * Leaf event nodes return only metadata.\n * Internal nodes return both event type and metadata.\n */\nexport type ConnectorSDKCallbacks = {\n onEvent?: ConnectorSDKOnEventCallback\n onLoad?: ConnectorSDKOnLoadCallback\n onExit?: ConnectorSDKOnEventExitCallback\n onExitSuccess?: ConnectorSDKOnExitSuccessCallback\n onExitAbort?: ConnectorSDKOnExitAbortCallback\n onExitError?: ConnectorSDKOnExitErrorCallback\n}\n\nexport type ConnectorSDKOnEventCallback = (\n type: ConnectorSDKEventType,\n metadata: ConnectorSDKCallbackMetadata\n) => void\n\nexport type ConnectorSDKOnLoadCallback = (metadata: ConnectorSDKCallbackMetadata) => void\n\nexport type ConnectorSDKOnEventExitCallback = (\n type: ConnectorSDKEventType,\n metadata: ConnectorSDKCallbackMetadata\n) => void\n\nexport type ConnectorSDKOnExitSuccessCallback = (metadata: ConnectorSDKCallbackMetadata) => void\nexport type ConnectorSDKOnExitAbortCallback = (metadata: ConnectorSDKCallbackMetadata) => void\nexport type ConnectorSDKOnExitErrorCallback = (metadata: ConnectorSDKCallbackMetadata) => void\n\nexport enum ConnectorSDKEventType {\n Load = 'loaded',\n ExitSuccess = 'exited.successful',\n ExitAbort = 'exited.aborted',\n ExitError = 'exited.errored',\n}\n\nexport type ConnectorSDKCallbackMetadata = {\n connectorId: string\n profileId?: string\n connectionId?: string\n}\n\nexport type ConnectorSDKConnectOptions = ConnectorSDKCallbacks\nexport type ConnectorSDKReconnectOptions = ConnectorSDKCallbacks & {\n connectionId: string\n}\n\nexport type ConnectorSDKConnectorOptions = ConnectorSDKConnectOptions & {\n connectionId?: string\n}\n","import type { FetchResult, NextLink, Observable, Operation } from '@apollo/client/index.js'\nimport { ApolloLink } from '@apollo/client/index.js'\n\nimport { GlobalStorage } from '@/Storage'\n\n/**\n * unauthorizedCallback only triggers in the event the token is present, and\n * returns the token; This allows sessions to be forgotten without race conditions\n * causing null sessions to kill valid sessions, or invalid sessions for killing\n * valid sessions during rotation and networking weirdness.\n */\nexport class AuthLink extends ApolloLink {\n request(operation: Operation, forward: NextLink): Observable<FetchResult> | null {\n const token = GlobalStorage.get('session')\n\n if (!token) {\n console.warn(`QuilttLink attempted to send an unauthenticated Query`)\n return null\n }\n\n operation.setContext(({ headers = {} }) => ({\n headers: {\n ...headers,\n authorization: `Bearer ${token}`,\n },\n }))\n\n return forward(operation)\n }\n}\n\nexport default AuthLink\n","import { BatchHttpLink as ApolloHttpLink } from '@apollo/client/link/batch-http/index.js'\n\nimport fetch from 'cross-fetch'\n\nimport { endpointGraphQL } from '../../../configuration'\n\nexport const BatchHttpLink = new ApolloHttpLink({\n uri: endpointGraphQL,\n fetch,\n})\n\nexport default BatchHttpLink\n","{\n \"name\": \"@quiltt/core\",\n \"version\": \"3.3.2\",\n \"description\": \"Javascript API client and utilities for Quiltt\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/quiltt/quiltt-public.git\",\n \"directory\": \"ECMAScript/core\"\n },\n \"homepage\": \"https://github.com/quiltt/quiltt-public/tree/main/ECMAScript/core#readme\",\n \"keywords\": [\n \"quiltt\",\n \"typescript\"\n ],\n \"license\": \"MIT\",\n \"sideEffects\": [\n \"./src/Storage/Local.ts\",\n \"./src/api/graphql/links/SubscriptionLink.ts\"\n ],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"dist/**\",\n \"src/**\",\n \"CHANGELOG.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rimraf .turbo dist\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"TIMING=1 eslint --ext .js,.jsx,.ts,.tsx src/ --fix\",\n \"typecheck\": \"tsc --project tsconfig.json --noEmit\"\n },\n \"dependencies\": {\n \"@apollo/client\": \"^3.7.16\",\n \"axios\": \"^1.4.0\",\n \"cross-fetch\": \"^3.1.8\",\n \"graphql\": \"^16.8.1\",\n \"graphql-ruby-client\": \"^1.11.8\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"4.1.1\",\n \"@types/node\": \"18.16.18\",\n \"@types/react\": \"18.2.7\",\n \"@typescript-eslint/eslint-plugin\": \"5.60.1\",\n \"@typescript-eslint/parser\": \"5.60.1\",\n \"eslint\": \"8.43.0\",\n \"eslint-config-prettier\": \"8.8.0\",\n \"eslint-plugin-prettier\": \"4.2.1\",\n \"prettier\": \"2.8.8\",\n \"tsup\": \"6.7.0\",\n \"typescript\": \"5.1.3\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import { name as packageName, version as packageVersion } from '../package.json'\n\nconst QUILTT_API_INSECURE = (() => {\n try {\n return process.env.QUILTT_API_INSECURE\n } catch {\n return undefined\n }\n})()\n\nconst QUILTT_API_DOMAIN = (() => {\n try {\n return process.env.QUILTT_API_DOMAIN\n } catch {\n return undefined\n }\n})()\n\nconst QUILTT_DEBUG = (() => {\n try {\n return !!process.env.QUILTT_DEBUG || process.env.NODE_ENV !== 'production'\n } catch {\n return false\n }\n})()\n\nconst domain = QUILTT_API_DOMAIN || 'quiltt.io'\nconst protocolHttp = `http${QUILTT_API_INSECURE ? '' : 's'}`\nconst protocolWebsockets = `ws${QUILTT_API_DOMAIN ? '' : 's'}`\n\nexport const debugging = QUILTT_DEBUG\nexport const endpointAuth = `${protocolHttp}://auth.${domain}/v1/users/session`\nexport const endpointGraphQL = `${protocolHttp}://api.${domain}/v1/graphql`\nexport const endpointWebsockets = `${protocolWebsockets}://api.${domain}/websockets`\nexport const version = `${packageName}: v${packageVersion}`\n\nconst Config = {\n debugging,\n endpointAuth,\n endpointGraphQL,\n endpointWebsockets,\n version,\n}\n\nexport default Config\n","import { GlobalStorage } from '@/Storage'\n\nimport type { ServerError } from '@apollo/client/index.js'\nimport { onError } from '@apollo/client/link/error/index.js'\n\nexport const ErrorLink = onError(({ graphQLErrors, networkError }) => {\n if (graphQLErrors) {\n graphQLErrors.forEach(({ message, locations, path }) => {\n console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`)\n })\n }\n\n if (networkError) {\n if ((networkError as ServerError).statusCode === 401) {\n console.warn('[Authentication error]:', networkError)\n GlobalStorage.set('session', null)\n } else {\n console.warn('[Network error]:', networkError)\n }\n }\n})\n\nexport default ErrorLink\n","import { ApolloLink } from '@apollo/client/index.js'\n\nexport const ForwardableLink = new ApolloLink((operation, forward) => forward(operation))\n\nexport default ForwardableLink\n","import { HttpLink as ApolloHttpLink } from '@apollo/client/link/http/index.js'\n\nimport fetch from 'cross-fetch'\n\nimport { endpointGraphQL } from '../../../configuration'\n\nexport const HttpLink = new ApolloHttpLink({\n uri: endpointGraphQL,\n fetch,\n})\n\nexport default HttpLink\n","import type { ServerError } from '@apollo/client/index.js'\nimport { RetryLink as ApolloRetryLink } from '@apollo/client/link/retry/index.js'\n\nexport const RetryLink = new ApolloRetryLink({\n attempts: {\n retryIf: (error: ServerError, _operation) => error.statusCode >= 500,\n },\n})\n\nexport default RetryLink\n","import { GlobalStorage } from '@/Storage'\nimport type { FetchResult, NextLink, Operation } from '@apollo/client/core/index.js'\nimport { ApolloLink, Observable } from '@apollo/client/core/index.js'\nimport { print } from 'graphql'\nimport { endpointWebsockets } from '../../../configuration'\nimport type { Consumer } from './actioncable'\nimport { createConsumer } from './actioncable'\n\ntype RequestResult = FetchResult<\n { [key: string]: unknown },\n Record<string, unknown>,\n Record<string, unknown>\n>\ntype ConnectionParams = object | ((operation: Operation) => object)\n\nclass ActionCableLink extends ApolloLink {\n cables: { [id: string]: Consumer }\n channelName: string\n actionName: string\n connectionParams: ConnectionParams\n\n constructor(options: {\n channelName?: string\n actionName?: string\n connectionParams?: ConnectionParams\n }) {\n super()\n this.cables = {}\n this.channelName = options.channelName || 'GraphqlChannel'\n this.actionName = options.actionName || 'execute'\n this.connectionParams = options.connectionParams || {}\n }\n\n // Interestingly, this link does _not_ call through to `next` because\n // instead, it sends the request to ActionCable.\n request(operation: Operation, _next: NextLink): Observable<RequestResult> | null {\n const token = GlobalStorage.get('session')\n\n if (!token) {\n console.warn(`QuilttLink attempted to send an unauthenticated Subscription`)\n return null\n }\n\n if (!this.cables[token]) {\n this.cables[token] = createConsumer(endpointWebsockets + (token ? `?token=${token}` : ''))\n }\n\n return new Observable((observer) => {\n const channelId = Math.round(Date.now() + Math.random() * 100000).toString(16)\n const actionName = this.actionName\n const connectionParams =\n typeof this.connectionParams === 'function'\n ? this.connectionParams(operation)\n : this.connectionParams\n\n const channel = this.cables[token].subscriptions.create(\n Object.assign(\n {},\n {\n channel: this.channelName,\n channelId: channelId,\n },\n connectionParams\n ),\n {\n connected: () => {\n channel.perform(actionName, {\n query: operation.query ? print(operation.query) : null,\n variables: operation.variables,\n // This is added for persisted operation support:\n operationId: (operation as { operationId?: string }).operationId,\n operationName: operation.operationName,\n })\n },\n\n received: (payload: { result: RequestResult; more: any }) => {\n if (payload?.result?.data || payload?.result?.errors) {\n observer.next(payload.result)\n }\n\n if (!payload.more) {\n observer.complete()\n }\n },\n }\n )\n // Make the ActionCable subscription behave like an Apollo subscription\n return Object.assign(channel, { closed: false })\n })\n }\n}\n\nexport default ActionCableLink\n","export default {\n logger: typeof globalThis !== 'undefined' ? globalThis.console : undefined,\n WebSocket: typeof globalThis !== 'undefined' ? globalThis.WebSocket : undefined,\n}\n","import { debugging } from '../../../../configuration'\nimport adapters from './adapters'\n\nclass Logger {\n enabled = debugging\n\n log(...messages: Array<string>) {\n if (adapters.logger && this.enabled) {\n messages.push(Date.now().toString())\n adapters.logger.log('[ActionCable]', ...messages)\n }\n }\n}\n\nexport const logger = new Logger()\nexport default logger\n","// @ts-nocheck\nimport logger from './logger'\n\n// Responsible for ensuring the cable connection is in good health by validating the heartbeat pings sent from the server, and attempting\n// revival reconnections if things go astray. Internal class, not intended for direct user manipulation.\n\nconst now = () => new Date().getTime()\n\nconst secondsSince = (time) => (now() - time) / 1000\n\nclass ConnectionMonitor {\n constructor(connection) {\n this.visibilityDidChange = this.visibilityDidChange.bind(this)\n this.connection = connection\n this.reconnectAttempts = 0\n }\n\n start() {\n if (!this.isRunning()) {\n this.startedAt = now()\n delete this.stoppedAt\n this.startPolling()\n addEventListener('visibilitychange', this.visibilityDidChange)\n logger.log(\n `ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`\n )\n }\n }\n\n stop() {\n if (this.isRunning()) {\n this.stoppedAt = now()\n this.stopPolling()\n removeEventListener('visibilitychange', this.visibilityDidChange)\n logger.log('ConnectionMonitor stopped')\n }\n }\n\n isRunning() {\n return this.startedAt && !this.stoppedAt\n }\n\n recordPing() {\n this.pingedAt = now()\n }\n\n recordConnect() {\n this.reconnectAttempts = 0\n this.recordPing()\n delete this.disconnectedAt\n logger.log('ConnectionMonitor recorded connect')\n }\n\n recordDisconnect() {\n this.disconnectedAt = now()\n logger.log('ConnectionMonitor recorded disconnect')\n }\n\n // Private\n\n startPolling() {\n this.stopPolling()\n this.poll()\n }\n\n stopPolling() {\n clearTimeout(this.pollTimeout)\n }\n\n poll() {\n this.pollTimeout = setTimeout(() => {\n this.reconnectIfStale()\n this.poll()\n }, this.getPollInterval())\n }\n\n getPollInterval() {\n const { staleThreshold, reconnectionBackoffRate } = this.constructor\n const backoff = Math.pow(1 + reconnectionBackoffRate, Math.min(this.reconnectAttempts, 10))\n const jitterMax = this.reconnectAttempts === 0 ? 1.0 : reconnectionBackoffRate\n const jitter = jitterMax * Math.random()\n return staleThreshold * 1000 * backoff * (1 + jitter)\n }\n\n reconnectIfStale() {\n if (this.connectionIsStale()) {\n logger.log(\n `ConnectionMonitor detected stale connection. reconnectAttempts = ${\n this.reconnectAttempts\n }, time stale = ${secondsSince(this.refreshedAt)} s, stale threshold = ${\n this.constructor.staleThreshold\n } s`\n )\n this.reconnectAttempts++\n if (this.disconnectedRecently()) {\n logger.log(\n `ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${secondsSince(\n this.disconnectedAt\n )} s`\n )\n } else {\n logger.log('ConnectionMonitor reopening')\n this.connection.reopen()\n }\n }\n }\n\n get refreshedAt() {\n return this.pingedAt ? this.pingedAt : this.startedAt\n }\n\n connectionIsStale() {\n return secondsSince(this.refreshedAt) > this.constructor.staleThreshold\n }\n\n disconnectedRecently() {\n return (\n this.disconnectedAt && secondsSince(this.disconnectedAt) < this.constructor.staleThreshold\n )\n }\n\n visibilityDidChange() {\n if (document.visibilityState === 'visible') {\n setTimeout(() => {\n if (this.connectionIsStale() || !this.connection.isOpen()) {\n logger.log(\n `ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`\n )\n this.connection.reopen()\n }\n }, 200)\n }\n }\n}\n\nConnectionMonitor.staleThreshold = 6 // Server::Connections::BEAT_INTERVAL * 2 (missed two pings)\nConnectionMonitor.reconnectionBackoffRate = 0.15\n\nexport default ConnectionMonitor\n","const INTERNAL = {\n message_types: {\n welcome: 'welcome',\n disconnect: 'disconnect',\n ping: 'ping',\n confirmation: 'confirm_subscription',\n rejection: 'reject_subscription',\n },\n disconnect_reasons: {\n unauthorized: 'unauthorized',\n invalid_request: 'invalid_request',\n server_restart: 'server_restart',\n remote: 'remote',\n },\n default_mount_path: '/cable',\n protocols: ['actioncable-v1-json', 'actioncable-unsupported'],\n}\n\nexport default INTERNAL\n","// @ts-nocheck\nimport adapters from './adapters'\nimport ConnectionMonitor from './connection_monitor'\nimport INTERNAL from './internal'\nimport logger from './logger'\n\n// Encapsulate the cable connection held by the consumer. This is an internal class not intended for direct user manipulation.\n\nconst { message_types, protocols } = INTERNAL\nconst supportedProtocols = protocols.slice(0, protocols.length - 1)\n\nconst indexOf = [].indexOf\n\nclass Connection {\n constructor(consumer) {\n this.open = this.open.bind(this)\n this.consumer = consumer\n this.subscriptions = this.consumer.subscriptions\n this.monitor = new ConnectionMonitor(this)\n this.disconnected = true\n }\n\n send(data) {\n if (this.isOpen()) {\n this.webSocket.send(JSON.stringify(data))\n return true\n } else {\n return false\n }\n }\n\n open() {\n if (this.isActive()) {\n logger.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`)\n return false\n } else {\n const socketProtocols = [...protocols, ...(this.consumer.subprotocols || [])]\n logger.log(\n `Opening WebSocket, current state is ${this.getState()}, subprotocols: ${socketProtocols}`\n )\n if (this.webSocket) {\n this.uninstallEventHandlers()\n }\n this.webSocket = new adapters.WebSocket(this.consumer.url, socketProtocols)\n this.installEventHandlers()\n this.monitor.start()\n return true\n }\n }\n\n close({ allowReconnect } = { allowReconnect: true }) {\n if (!allowReconnect) {\n this.monitor.stop()\n }\n // Avoid closing websockets in a \"connecting\" state due to Safari 15.1+ bug. See: https://github.com/rails/rails/issues/43835#issuecomment-1002288478\n if (this.isOpen()) {\n return this.webSocket.close()\n }\n }\n\n reopen() {\n logger.log(`Reopening WebSocket, current state is ${this.getState()}`)\n if (this.isActive()) {\n try {\n return this.close()\n } catch (error) {\n logger.log('Failed to reopen WebSocket', error)\n } finally {\n logger.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`)\n setTimeout(this.open, this.constructor.reopenDelay)\n }\n } else {\n return this.open()\n }\n }\n\n getProtocol() {\n if (this.webSocket) {\n return this.webSocket.protocol\n }\n }\n\n isOpen() {\n return this.isState('open')\n }\n\n isActive() {\n return this.isState('open', 'connecting')\n }\n\n triedToReconnect() {\n return this.monitor.reconnectAttempts > 0\n }\n\n // Private\n\n isProtocolSupported() {\n return indexOf.call(supportedProtocols, this.getProtocol()) >= 0\n }\n\n isState(...states) {\n return indexOf.call(states, this.getState()) >= 0\n }\n\n getState() {\n if (this.webSocket) {\n for (const state in adapters.WebSocket) {\n if (adapters.WebSocket[state] === this.webSocket.readyState) {\n return state.toLowerCase()\n }\n }\n }\n return null\n }\n\n installEventHandlers() {\n for (const eventName in this.events) {\n const handler = this.events[eventName].bind(this)\n this.webSocket[`on${eventName}`] = handler\n }\n }\n\n uninstallEventHandlers() {\n for (const eventName in this.events) {\n this.webSocket[`on${eventName}`] = function () {}\n }\n }\n}\n\nConnection.reopenDelay = 500\n\nConnection.prototype.events = {\n message(event) {\n if (!this.isProtocolSupported()) {\n return\n }\n const { identifier, message, reason, reconnect, type } = JSON.parse(event.data)\n switch (type) {\n case message_types.welcome:\n if (this.triedToReconnect()) {\n this.reconnectAttempted = true\n }\n this.monitor.recordConnect()\n return this.subscriptions.reload()\n case message_types.disconnect:\n logger.log(`Disconnecting. Reason: ${reason}`)\n return this.close({ allowReconnect: reconnect })\n case message_types.ping:\n return this.monitor.recordPing()\n case message_types.confirmation:\n this.subscriptions.confirmSubscription(identifier)\n if (this.reconnectAttempted) {\n this.reconnectAttempted = false\n return this.subscriptions.notify(identifier, 'connected', { reconnected: true })\n } else {\n return this.subscriptions.notify(identifier, 'connected', { reconnected: false })\n }\n case message_types.rejection:\n return this.subscriptions.reject(identifier)\n default:\n return this.subscriptions.notify(identifier, 'received', message)\n }\n },\n\n open() {\n logger.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`)\n this.disconnected = false\n if (!this.isProtocolSupported()) {\n logger.log('Protocol is unsupported. Stopping monitor and disconnecting.')\n return this.close({ allowReconnect: false })\n }\n },\n\n close(_event) {\n logger.log('WebSocket onclose event')\n if (this.disconnected) {\n return\n }\n this.disconnected = true\n this.monitor.recordDisconnect()\n return this.subscriptions.notifyAll('disconnected', {\n willAttemptReconnect: this.monitor.isRunning(),\n })\n },\n\n error() {\n logger.log('WebSocket onerror event')\n },\n}\n\nexport default Connection\n","import type { Consumer } from './consumer'\n\nexport type Data = { [id: string]: string | object | null | undefined }\n\nconst extend = function (object: Data, properties: Data) {\n if (properties !== null) {\n for (const key in properties) {\n const value = properties[key]\n object[key] = value\n }\n }\n return object\n}\n\nexport class Subscription {\n consumer: Consumer\n identifier: string\n\n constructor(consumer: Consumer, params: Data = {}, mixin: Data) {\n this.consumer = consumer\n this.identifier = JSON.stringify(params)\n extend(this as unknown as Data, mixin)\n }\n\n // Perform a channel action with the optional data passed as an attribute\n perform(action: string, data: Data = {}) {\n data.action = action\n return this.send(data)\n }\n\n send(data: object) {\n return this.consumer.send({\n command: 'message',\n identifier: this.identifier,\n data: JSON.stringify(data),\n })\n }\n\n unsubscribe() {\n return this.consumer.subscriptions.remove(this)\n }\n}\n\nexport default Subscription\n","import logger from './logger'\nimport type { Subscription } from './subscription'\nimport type { Subscriptions } from './subscriptions'\n\n// Responsible for ensuring channel subscribe command is confirmed, retrying until confirmation is received.\n// Internal class, not intended for direct user manipulation.\n\nclass SubscriptionGuarantor {\n subscriptions: Subscriptions\n pendingSubscriptions: Array<Subscription>\n retryTimeout: ReturnType<typeof setTimeout> | undefined\n\n constructor(subscriptions: Subscriptions) {\n this.subscriptions = subscriptions\n this.pendingSubscriptions = []\n }\n\n guarantee(subscription: Subscription) {\n if (this.pendingSubscriptions.indexOf(subscription) == -1) {\n logger.log(`SubscriptionGuarantor guaranteeing ${subscription.identifier}`)\n this.pendingSubscriptions.push(subscription)\n } else {\n logger.log(`SubscriptionGuarantor already guaranteeing ${subscription.identifier}`)\n }\n this.startGuaranteeing()\n }\n\n forget(subscription: Subscription) {\n logger.log(`SubscriptionGuarantor forgetting ${subscription.identifier}`)\n this.pendingSubscriptions = this.pendingSubscriptions.filter((s) => s !== subscription)\n }\n\n startGuaranteeing() {\n this.stopGuaranteeing()\n this.retrySubscribing()\n }\n\n stopGuaranteeing() {\n clearTimeout(this.retryTimeout)\n }\n\n retrySubscribing() {\n this.retryTimeout = setTimeout(() => {\n if (this.subscriptions && typeof this.subscriptions.subscribe === 'function') {\n this.pendingSubscriptions.map((subscription) => {\n logger.log(`SubscriptionGuarantor resubscribing ${subscription.identifier}`)\n this.subscriptions.subscribe(subscription)\n })\n }\n }, 500)\n }\n}\n\nexport default SubscriptionGuarantor\n","import type { Consumer } from './consumer'\nimport logger from './logger'\nimport type { Data } from './subscription'\nimport Subscription from './subscription'\nimport SubscriptionGuarantor from './subscription_guarantor'\n\n// Collection class for creating (and internally managing) channel subscriptions.\n// The only method intended to be triggered by the user is ActionCable.Subscriptions#create,\n// and it should be called through the consumer like so:\n//\n// App = {}\n// App.cable = ActionCable.createConsumer(\"ws://example.com/accounts/1\")\n// App.appearance = App.cable.subscriptions.create(\"AppearanceChannel\")\n//\n// For more details on how you'd configure an actual channel subscription, see ActionCable.Subscription.\n\nexport class Subscriptions {\n consumer: Consumer\n guarantor: SubscriptionGuarantor\n subscriptions: Array<Subscription>\n\n constructor(consumer: Consumer) {\n this.consumer = consumer\n this.guarantor = new SubscriptionGuarantor(this)\n this.subscriptions = []\n }\n\n create(channelName: string, mixin: Data) {\n const channel = channelName\n const params = typeof channel === 'object' ? channel : { channel }\n const subscription = new Subscription(this.consumer, params, mixin)\n return this.add(subscription)\n }\n\n // Private\n\n add(subscription: Subscription) {\n this.subscriptions.push(subscription)\n this.consumer.ensureActiveConnection()\n this.notify(subscription, 'initialized')\n this.subscribe(subscription)\n return subscription\n }\n\n remove(subscription: Subscription) {\n this.forget(subscription)\n if (!this.findAll(subscription.identifier).length) {\n this.sendCommand(subscription, 'unsubscribe')\n }\n return subscription\n }\n\n reject(identifier: string) {\n return this.findAll(identifier).map((subscription) => {\n this.forget(subscription)\n this.notify(subscription, 'rejected')\n return subscription\n })\n }\n\n forget(subscription: Subscription) {\n this.guarantor.forget(subscription)\n this.subscriptions = this.subscriptions.filter((s) => s !== subscription)\n return subscription\n }\n\n findAll(identifier: string) {\n return this.subscriptions.filter((s) => s.identifier === identifier)\n }\n\n reload() {\n return this.subscriptions.map((subscription) => this.subscribe(subscription))\n }\n\n notifyAll(callbackName: string, ...args: any[]) {\n return this.subscriptions.map((subscription) =>\n this.notify(subscription, callbackName, ...args)\n )\n }\n\n notify(subscription: Subscription, callbackName: string, ...args: any[]) {\n let subscriptions\n if (typeof subscription === 'string') {\n subscriptions = this.findAll(subscription)\n } else {\n subscriptions = [subscription]\n }\n\n return subscriptions.map((subscription: any) =>\n typeof subscription[callbackName] === 'function'\n ? subscription[callbackName](...args)\n : undefined\n )\n }\n\n subscribe(subscription: Subscription) {\n if (this.sendCommand(subscription, 'subscribe')) {\n this.guarantor.guarantee(subscription)\n }\n }\n\n confirmSubscription(identifier: string) {\n logger.log(`Subscription confirmed ${identifier}`)\n this.findAll(identifier).map((subscription) => this.guarantor.forget(subscription))\n }\n\n sendCommand(subscription: Subscription, command: string) {\n const { identifier } = subscription\n return this.consumer.send({ command, identifier })\n }\n}\n\nexport default Subscriptions\n","import Connection from './connection'\nimport Subscriptions from './subscriptions'\n\n// The ActionCable.Consumer establishes the connection to a server-side Ruby Connection object. Once established,\n// the ActionCable.ConnectionMonitor will ensure that its properly maintained through heartbeats and checking for stale updates.\n// The Consumer instance is also the gateway to establishing subscriptions to desired channels through the #createSubscription\n// method.\n//\n// The following example shows how this can be set up:\n//\n// App = {}\n// App.cable = ActionCable.createConsumer(\"ws://example.com/accounts/1\")\n// App.appearance = App.cable.subscriptions.create(\"AppearanceChannel\")\n//\n// For more details on how you'd configure an actual channel subscription, see ActionCable.Subscription.\n//\n// When a consumer is created, it automatically connects with the server.\n//\n// To disconnect from the server, call\n//\n// App.cable.disconnect()\n//\n// and to restart the connection:\n//\n// App.cable.connect()\n//\n// Any channel subscriptions which existed prior to disconnecting will\n// automatically resubscribe.\n\nexport class Consumer {\n _url: string\n subscriptions: Subscriptions\n connection: Connection\n subprotocols: Array<string>\n\n constructor(url: string) {\n this._url = url\n this.subscriptions = new Subscriptions(this)\n this.connection = new Connection(this)\n this.subprotocols = []\n }\n\n get url() {\n return createWebSocketURL(this._url)\n }\n\n send(data: object) {\n return this.connection.send(data)\n }\n\n connect() {\n return this.connection.open()\n }\n\n disconnect() {\n return this.connection.close({ allowReconnect: false })\n }\n\n ensureActiveConnection() {\n if (!this.connection.isActive()) {\n return this.connection.open()\n }\n }\n\n addSubProtocol(subprotocol: string) {\n this.subprotocols = [...this.subprotocols, subprotocol]\n }\n}\n\nexport function createWebSocketURL(url: string | (() => string)): string {\n if (typeof url === 'function') {\n url = url()\n }\n\n if (url && !/^wss?:/i.test(url)) {\n const a = document.createElement('a')\n a.href = url\n // eslint-disable-next-line no-self-assign\n a.href = a.href\n a.protocol = a.protocol.replace('http', 'ws')\n return a.href\n } else {\n return url\n }\n}\n\nexport default Consumer\n","'use client'\n\nimport adapters from './adapters'\nimport Connection from './connection'\nimport ConnectionMonitor from './connection_monitor'\nimport Consumer, { createWebSocketURL } from './consumer'\nimport INTERNAL from './internal'\nimport logger from './logger'\nimport Subscription from './subscription'\nimport SubscriptionGuarantor from './subscription_guarantor'\nimport Subscriptions from './subscriptions'\n\nexport {\n Connection,\n ConnectionMonitor,\n Consumer,\n INTERNAL,\n Subscription,\n Subscriptions,\n SubscriptionGuarantor,\n adapters,\n createWebSocketURL,\n logger,\n}\n\nexport function createConsumer(url = getConfig('url') || INTERNAL.default_mount_path) {\n return new Consumer(url)\n}\n\nexport function getConfig(name: string) {\n const element = document.head.querySelector(`meta[name='action-cable-${name}']`)\n if (element) {\n return element.getAttribute('content')\n }\n}\n","'use client'\n\nimport ActionCableLink from './ActionCableLink'\n\nexport class SubscriptionLink extends ActionCableLink {\n constructor() {\n super({ channelName: 'GraphQLChannel' })\n }\n}\n\nexport default SubscriptionLink\n","import { ApolloLink } from '@apollo/client/index.js'\n\nexport const TerminatingLink = new ApolloLink(() => null)\n\nexport default TerminatingLink\n","import { ApolloLink } from '@apollo/client/index.js'\n\nimport { version } from '../../../configuration'\n\nexport const VersionLink = new ApolloLink((operation, forward) => {\n operation.setContext(({ headers = {} }) => ({\n headers: {\n ...headers,\n 'Quiltt-Client-Version': version,\n },\n }))\n return forward(operation)\n})\n\nexport default VersionLink\n","import type { ApolloClientOptions, Operation } from '@apollo/client/index.js'\nimport { ApolloClient, ApolloLink } from '@apollo/client/index.js'\n\nimport { debugging } from '../../configuration'\nimport {\n AuthLink,\n BatchHttpLink,\n ErrorLink,\n ForwardableLink,\n HttpLink,\n RetryLink,\n SubscriptionLink,\n VersionLink,\n} from './links'\n\nexport type QuilttClientOptions<T> = Omit<ApolloClientOptions<T>, 'link'>\n\nexport class QuilttClient<T> extends ApolloClient<T> {\n constructor(options: QuilttClientOptions<T>) {\n if (!options.connectToDevTools) options.connectToDevTools = debugging\n\n const isSubscriptionOperation = (operation: Operation) => {\n return operation.query.definitions.some(\n // @ts-ignore\n ({ kind, operation }) => kind === 'OperationDefinition' && operation === 'subscription'\n )\n }\n\n const isBatchable = (operation: Operation) => {\n return operation.getContext().batchable ?? true\n }\n\n const authLink = new AuthLink()\n const subscriptionsLink = new SubscriptionLink()\n\n const quilttLink = ApolloLink.from([VersionLink, authLink, ErrorLink, RetryLink])\n .split(isSubscriptionOperation, subscriptionsLink, ForwardableLink)\n .split(isBatchable, BatchHttpLink, HttpLink)\n\n super({\n link: quilttLink,\n ...options,\n })\n }\n}\n\nexport { InMemoryCache, gql, useMutation, useQuery, useSubscription } from '@apollo/client/index.js'\nexport type {\n NormalizedCacheObject,\n OperationVariables,\n ApolloError,\n} from '@apollo/client/index.js'\n","import type { AxiosRequestConfig as RequestConfig } from 'axios'\nimport Axios from 'axios'\n\nexport type { AxiosResponse } from 'axios'\nexport type AxiosRequestConfig<D = any> = RequestConfig<D> & {\n retry: boolean\n}\n\nconst RETRY_DELAY = 150 // ms\nconst RETRIES = 10 // 150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500 = 8.250s\n\n// Create an axios singleton for Quiltt, to prevent mutating other instances\nconst axios = Axios.create()\n\n// Example: axios.get(url, { retry: true })\naxios.interceptors.response.use(undefined, (error) => {\n const { config, message, response } = error\n const messageLower = message.toLowerCase()\n\n if (!config || !config.retry) {\n return Promise.reject(error)\n }\n\n // Retry Network timeout, Network errors, and Too Many Requests\n if (\n !(\n messageLower.includes('timeout') ||\n messageLower.includes('network error') ||\n response?.status === 429\n )\n ) {\n return Promise.reject(error)\n }\n\n if (config.retriesRemaining === undefined) {\n config.retriesRemaining = RETRIES - 1\n } else if (config.retriesRemaining === 1) {\n return Promise.reject(error)\n } else {\n config.retriesRemaining -= 1\n }\n\n const delay = new Promise<void>((resolve) => {\n setTimeout(() => resolve(), RETRY_DELAY * (RETRIES - config.retriesRemaining))\n })\n\n return delay.then(() => axios(config))\n})\n\nexport { axios }\n\nexport default axios\n","import type { AxiosRequestConfig, AxiosResponse } from './axios'\nimport { axios } from './axios'\n\nimport { endpointAuth } from '../../configuration'\n\nexport enum AuthStrategies {\n Email = 'email',\n Phone = 'phone',\n}\n\ninterface EmailInput {\n email: string\n phone?: never\n}\n\ninterface PhoneInput {\n phone: string\n email?: never\n}\n\nexport type UsernamePayload = EmailInput | PhoneInput\nexport type PasscodePayload = UsernamePayload & { passcode: string }\n\ntype SessionData = { token: string }\ntype NoContentData = void\ntype UnauthorizedData = { message: string; instruction: string }\nexport type UnprocessableData = { [attribute: string]: Array<string> }\n\ntype Ping = SessionData | UnauthorizedData\ntype Indentify = SessionData | NoContentData | UnprocessableData\ntype Authenticate = SessionData | UnauthorizedData | UnprocessableData\ntype Revoke = NoContentData | UnauthorizedData\n\nexport type SessionResponse = AxiosResponse<SessionData>\nexport type UnprocessableResponse = AxiosResponse<UnprocessableData>\n\n// https://www.quiltt.dev/api-reference/rest/auth#\nexport class AuthAPI {\n clientId: string | undefined\n\n constructor(clientId?: string | undefined) {\n this.clientId = clientId\n }\n\n /**\n * Response Statuses:\n * - 200: OK -> Session is Valid\n * - 401: Unauthorized -> Session is Invalid\n */\n ping = (token: string) => {\n return axios.get<Ping>(endpointAuth, this.config(token))\n }\n\n /**\n * Response Statuses:\n * - 201: Created -> Profile Created, New Session Returned\n * - 202: Accepted -> Profile Found, MFA Code Sent for `authenticate`\n * - 422: Unprocessable Entity -> Invalid Payload\n */\n identify = (payload: UsernamePayload) => {\n return axios.post<Indentify>(endpointAuth, this.body(payload), this.config())\n }\n\n /**\n * Response Statuses:\n * - 201: Created -> MFA Validated, New Session Returned\n * - 401: Unauthorized -> MFA Invalid\n * - 422: Unprocessable Entity -> Invalid Payload\n */\n authenticate = (payload: PasscodePayload) => {\n return axios.put<Authenticate>(endpointAuth, this.body(payload), this.config())\n }\n\n /**\n * Response Statuses:\n * - 204: No Content -> Session Revoked\n * - 401: Unauthorized -> Session Not Found\n */\n revoke = (token: string) => {\n return axios.delete<Revoke>(endpointAuth, this.config(token))\n }\n\n private config = (token?: string): AxiosRequestConfig => {\n const headers: { [id: string]: string } = {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n }\n\n if (token) {\n headers.Authorization = `Bearer ${token}`\n }\n\n return {\n headers: headers,\n validateStatus: this.validateStatus,\n retry: true,\n }\n }\n\n private validateStatus = (status: number) => status < 500\n\n private body = (payload: any) => {\n if (!this.clientId) {\n console.error('Quiltt Client ID is not set. Unable to identify & authenticate')\n }\n\n return {\n session: {\n deploymentId: this.clientId, // Rename API?\n ...payload,\n },\n }\n }\n}\n\nexport default AuthAPI\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/JsonWebToken.ts","../src/Observable.ts","../src/Storage/Local.ts","../src/Storage/Memory.ts","../src/Storage/index.ts","../src/Timeoutable.ts","../src/api/browser.ts","../src/api/graphql/links/AuthLink.ts","../src/api/graphql/links/BatchHttpLink.ts","../package.json","../src/configuration.ts","../src/api/graphql/links/ErrorLink.ts","../src/api/graphql/links/ForwardableLink.ts","../src/api/graphql/links/HttpLink.ts","../src/api/graphql/links/RetryLink.ts","../src/api/graphql/links/ActionCableLink.ts","../src/api/graphql/links/actioncable/adapters.ts","../src/api/graphql/links/actioncable/logger.ts","../src/api/graphql/links/actioncable/connection_monitor.ts","../src/api/graphql/links/actioncable/internal.ts","../src/api/graphql/links/actioncable/connection.ts","../src/api/graphql/links/actioncable/subscription.ts","../src/api/graphql/links/actioncable/subscription_guarantor.ts","../src/api/graphql/links/actioncable/subscriptions.ts","../src/api/graphql/links/actioncable/consumer.ts","../src/api/graphql/links/actioncable/index.ts","../src/api/graphql/links/SubscriptionLink.ts","../src/api/graphql/links/TerminatingLink.ts","../src/api/graphql/links/VersionLink.ts","../src/api/graphql/client.ts","../src/api/rest/axios.ts","../src/api/rest/AuthAPI.ts"],"names":["MATCHER","JsonWebTokenParse","token","_header","payload","_signature","error","Observable","initalState","__publicField","nextState","update","observer","LocalStorage","key","state","_a","event","newState","observers","MemoryStorage","Storage","prevValue","GlobalStorage","Timeoutable","callback","delay","ConnectorSDKEventType","ApolloLink","AuthLink","operation","forward","headers","__spreadProps","__spreadValues","ApolloHttpLink","fetch","name","version","QUILTT_API_INSECURE","e","QUILTT_API_DOMAIN","QUILTT_DEBUG","domain","protocolHttp","protocolWebsockets","debugging","endpointAuth","endpointGraphQL","endpointWebsockets","BatchHttpLink","onError","ErrorLink","graphQLErrors","networkError","message","locations","path","ForwardableLink","HttpLink","ApolloRetryLink","RetryLink","_operation","print","adapters_default","Logger","messages","logger","logger_default","now","secondsSince","time","ConnectionMonitor","connection","staleThreshold","reconnectionBackoffRate","backoff","jitter","connection_monitor_default","INTERNAL","internal_default","message_types","protocols","supportedProtocols","indexOf","Connection","consumer","data","socketProtocols","allowReconnect","states","eventName","handler","identifier","reason","reconnect","type","_event","connection_default","extend","object","properties","value","Subscription","params","mixin","action","subscription_default","SubscriptionGuarantor","subscriptions","subscription","s","subscription_guarantor_default","Subscriptions","channelName","channel","callbackName","args","command","subscriptions_default","Consumer","url","createWebSocketURL","subprotocol","a","consumer_default","createConsumer","getConfig","element","ActionCableLink","options","_next","channelId","actionName","connectionParams","_b","ActionCableLink_default","SubscriptionLink","TerminatingLink","VersionLink","ApolloClient","InMemoryCache","gql","useMutation","useQuery","useSubscription","QuilttClient","isSubscriptionOperation","kind","isBatchable","authLink","subscriptionsLink","quilttLink","Axios","RETRY_DELAY","RETRIES","axios","config","response","messageLower","resolve","AuthStrategies","AuthAPI","clientId","status"],"mappings":"2eA6BA,IAAMA,GAAU,0BAEHC,GACXC,GACuC,CACvC,GAAI,OAAOA,GAAU,aAAeA,IAAU,KAAM,OAAOA,EAE3D,GAAI,CAACF,GAAQ,KAAKE,CAAK,EAAG,CACxB,QAAQ,MAAM,0BAA0BA,GAAO,EAC/C,OAGF,GAAM,CAACC,EAASC,EAASC,CAAU,EAAIH,EAAM,MAAM,GAAG,EAEtD,GAAI,CACF,MAAO,CAAE,MAAOA,EAAO,OAAQ,KAAK,MAAM,KAAKE,CAAO,CAAC,CAAE,CAC3D,OAASE,EAAP,CACA,QAAQ,MAAM,0BAA0BA,GAAO,CACjD,CACF,ECtCO,IAAMC,EAAN,KAAoB,CAIzB,YAAYC,EAAwB,CAHpCC,EAAA,KAAQ,SACRA,EAAA,KAAQ,YAA2B,CAAC,GAMpCA,EAAA,WAAM,IACG,KAAK,OAGdA,EAAA,WAAOC,GAAoC,CACrC,KAAK,QAAUA,IAEnB,KAAK,MAAQA,EACb,KAAK,UAAU,QAASC,GAAWA,EAAOD,CAAS,CAAC,EACtD,GAEAD,EAAA,iBAAaG,GAA0B,CACrC,KAAK,UAAU,KAAKA,CAAQ,CAC9B,GAEAH,EAAA,mBAAeG,GAA0B,CACvC,KAAK,UAAY,KAAK,UAAU,OAAQD,GAAWA,IAAWC,CAAQ,CACxE,GApBE,KAAK,MAAQJ,CACf,CAoB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,UAChB9B,EAEP,IAtEA,KAAK,SAAW+J,CAClB,CAuEF","sourcesContent":["import type { Maybe } from './types'\n\nexport type JsonWebToken<T> = {\n token: string // Raw JWT Token\n claims: Claims<T>\n}\n\nexport type Claims<T> = RegisteredClaims & T\n\nexport type RegisteredClaims = {\n iss: string // (issuer): Issuer of the JWT\n sub: string // (subject): Subject of the JWT (Person ID)\n aud: string // (audience): Recipient for which the JWT is intended\n exp: number // (expiration time): Time after which the JWT expires\n nbf: number // (not before time): Time before which the JWT must not be accepted for processing\n iat: number // (issued at time): Time at which the JWT was issued; can be used to determine age of the JWT\n jti: string // (JWT ID): Unique identifier; can be used to prevent the JWT from being replayed (allows a token to be used only once)\n}\n\nexport type PrivateClaims = {\n oid: string // Organization ID\n eid: string // Environment ID\n did: string // Deployment ID\n aid: string // Administrator ID\n ver: number // Session Token Version\n}\n\nexport type QuilttJWT = JsonWebToken<PrivateClaims>\n\nconst MATCHER = /^(?:[\\w-]+\\.){2}[\\w-]+$/\n\nexport const JsonWebTokenParse = <T>(\n token: Maybe<string> | undefined\n): Maybe<JsonWebToken<T>> | undefined => {\n if (typeof token === 'undefined' || token === null) return token\n\n if (!MATCHER.test(token)) {\n console.error(`Invalid Session Token: ${token}`)\n return\n }\n\n const [_header, payload, _signature] = token.split('.')\n\n try {\n return { token: token, claims: JSON.parse(atob(payload)) }\n } catch (error) {\n console.error(`Invalid Session Token: ${error}`)\n }\n}\n","import type { Dispatch, SetStateAction } from 'react'\nimport type { Maybe } from './types'\n\nexport type Observer<T> = Dispatch<SetStateAction<Maybe<T> | undefined>>\n\n/**\n * This is designed to support singletons to share the memory states across all\n * instance of hooks to ensure that updates only process once, by storing a value\n * then notifying all subscribers when it's updated.\n */\nexport class Observable<T> {\n private state?: Maybe<T>\n private observers: Observer<T>[] = []\n\n constructor(initalState?: Maybe<T>) {\n this.state = initalState\n }\n\n get = () => {\n return this.state\n }\n\n set = (nextState: Maybe<T> | undefined) => {\n if (this.state === nextState) return\n\n this.state = nextState\n this.observers.forEach((update) => update(nextState))\n }\n\n subscribe = (observer: Observer<T>) => {\n this.observers.push(observer)\n }\n\n unsubscribe = (observer: Observer<T>) => {\n this.observers = this.observers.filter((update) => update !== observer)\n }\n}\n\nexport default Observable\n","import type { Maybe } from '../types'\nimport type { Observer } from '../Observable'\n\n/**\n * An error and type safe wrapper for localStorage.\n * It allows you to subscribe to changes;\n * but localStorage changes only fire with another\n * window updates the record.\n */\nexport class LocalStorage<T> {\n private observers: { [key: string]: Observer<T>[] } = {}\n\n constructor() {\n if (typeof window !== 'undefined' && !window?.expo) {\n window.addEventListener('storage', this.handleStorageEvent.bind(this))\n }\n }\n\n isEnabled = (): boolean => {\n try {\n localStorage.setItem(`quiltt.ping`, 'pong')\n localStorage.removeItem(`quiltt.ping`)\n return true\n } catch (error) {\n return false\n }\n }\n\n isDisabled = (): boolean => !this.isEnabled()\n\n get = (key: string): Maybe<T> | undefined => {\n if (typeof window === 'undefined' || !!window.expo) return undefined\n\n try {\n const state = window.localStorage.getItem(`quiltt.${key}`)\n return state ? JSON.parse(state) : state\n } catch (error) {\n console.warn(`localStorage Error: \"quiltt.${key}\"`, error)\n return undefined\n }\n }\n\n set = (key: string, state: Maybe<T> | undefined): void => {\n if (typeof window === 'undefined' || !!window.expo) return\n\n try {\n if (state) {\n window.localStorage.setItem(`quiltt.${key}`, JSON.stringify(state))\n } else {\n window.localStorage.removeItem(`quiltt.${key}`)\n }\n } catch (error) {\n console.warn(`localStorage Error: \"quiltt.${key}\"`, error)\n }\n }\n\n remove = (key: string) => {\n try {\n window.localStorage.removeItem(`quiltt.${key}`)\n } catch (error) {\n console.warn(`localStorage Error: \"quiltt.${key}\">`, error)\n }\n }\n\n subscribe = (key: string, observer: Observer<T>) => {\n if (!this.observers[key]) this.observers[key] = []\n\n this.observers[key].push(observer)\n }\n\n unsubscribe = (key: string, observer: Observer<T>) => {\n this.observers[key] = this.observers[key]?.filter((update) => update !== observer)\n }\n\n // if there is a key, then trigger the related updates. If there is not key\n // it means that a record has been removed and everything needs to be rechecked.\n private handleStorageEvent = (event: StorageEvent) => {\n if (event.key && event.key.includes('quiltt.')) {\n const newState = event.newValue ? JSON.parse(event.newValue) : null\n\n if (this.observers[event.key]) {\n this.observers[event.key].forEach((update) => update(newState))\n }\n } else {\n Object.entries(this.observers).forEach(([key, observers]) => {\n observers.forEach((update) => update(this.get(key)))\n })\n }\n }\n}\n\nexport default LocalStorage\n","import type { Maybe } from '../types'\n\nimport { Observable } from '../Observable'\nimport type { Observer } from '../Observable'\n\n/**\n * This is designed to support effectively an in memory key value store singleton,\n * similar to localstorage, but allows you to subscribe to changes within the current\n * window.\n */\nexport class MemoryStorage<T> {\n private observables: { [key: string]: Observable<T> } = {}\n\n get = (key: string) => {\n if (this.observables[key]) {\n return this.observables[key].get()\n } else {\n return undefined\n }\n }\n\n set = (key: string, state: Maybe<T> | undefined): void => {\n if (!this.observables[key]) {\n this.observables[key] = new Observable<T>(state)\n } else {\n this.observables[key].set(state)\n }\n }\n\n subscribe = (key: string, observer: Observer<T>): void => {\n if (!this.observables[key]) this.observables[key] = new Observable<T>()\n\n this.observables[key].subscribe(observer)\n }\n\n unsubscribe = (key: string, observer: Observer<T>): void => {\n if (this.observables[key]) {\n this.observables[key].unsubscribe(observer)\n }\n }\n}\n\nexport default MemoryStorage\n","import type { Maybe } from '../types'\n\nimport type { Observer } from '../Observable'\nimport { LocalStorage } from './Local'\nimport { MemoryStorage } from './Memory'\n\n/**\n * This is wraps both local and memory storage to create a unified interface, that\n * allows you to subscribe to all either changes made within this window, or changes\n * made by other windows.\n */\nexport class Storage<T> {\n private memoryStore = new MemoryStorage<T>()\n private localStore = new LocalStorage<T>()\n private observers: { [key: string]: Observer<T>[] } = {}\n private monitors: Set<string> = new Set()\n\n /**\n * Checks memoryStorage before falling back to localStorage.\n */\n get = (key: string): Maybe<T> | undefined => {\n this.monitorLocalStorageChanges(key)\n\n let state = this.memoryStore.get(key)\n\n if (state === undefined) {\n state = this.localStore.get(key)\n }\n\n return state\n }\n\n /**\n * We don't trust localStorage to always be present, so we can't rely on it to\n * update memoryStorage based on emitted changes. So we manage our own\n * emitting while using the underlying events to keep memoryStore in sync with\n * localStore.\n */\n set = (key: string, newState: Maybe<T> | undefined) => {\n this.monitorLocalStorageChanges(key)\n\n this.localStore.set(key, newState)\n this.memoryStore.set(key, newState)\n\n this.observers[key]?.forEach((update) => update(newState))\n }\n\n /**\n * Allows you to subscribe to all changes in memory or local storage as a\n * single event.\n */\n subscribe = (key: string, observer: Observer<T>) => {\n if (!this.observers[key]) this.observers[key] = []\n\n this.observers[key].push(observer)\n }\n\n unsubscribe = (key: string, observer: Observer<T>) => {\n this.observers[key] = this.observers[key]?.filter((update) => update !== observer)\n }\n\n /**\n * Sets bubble the changes down the stack starting with memoryStore and then\n * localStore. memoryStore will emit changes to everything within the current\n * window context, while localStore will emit changes to every other window\n * context.\n *\n * To ensure that the other windows are updated correctly, changes to localStore\n * need to be subscribed and updated to in memory store, which then may be subscribed\n * to outside of storage.\n */\n private monitorLocalStorageChanges = (key: string) => {\n if (this.monitors.has(key)) return\n this.monitors.add(key)\n\n this.localStore.subscribe(key, (nextState) => {\n const prevValue = this.memoryStore.get(key)\n const newState = nextState instanceof Function ? nextState(prevValue) : nextState\n\n this.memoryStore.set(key, newState)\n this.observers[key]?.forEach((update) => update(newState))\n })\n }\n}\n\nexport * from './Local'\nexport * from './Memory'\n\n/**\n * This is an singleton to share the memory states across all instances; This\n * basically acts like shared memory when there is no localStorage.\n */\nexport const GlobalStorage = new Storage<any>()\n","import type { Observer } from './Observable'\n\n/**\n * This is designed to support singletons to timeouts that can broadcast\n * to any observers, preventing race conditions with multiple timeouts.\n */\nexport class Timeoutable {\n private timeout?: ReturnType<typeof setTimeout>\n private observers: Observer<void>[] = []\n\n set = (callback: () => void, delay: number | undefined) => {\n if (this.timeout) {\n clearTimeout(this.timeout)\n }\n\n this.observers.push(callback)\n this.timeout = setTimeout(this.broadcast.bind(this), delay)\n }\n\n clear = (observer: Observer<void>) => {\n this.observers = this.observers.filter((callback) => callback !== observer)\n }\n\n // Only sends to the 1st listener, but ensures that someone is notified\n private broadcast = () => {\n if (this.observers.length === 0) return\n\n this.observers[0](undefined)\n }\n}\n\nexport default Timeoutable\n","interface CallbackManager {\n onEvent(callback: ConnectorSDKOnEventCallback): void\n onLoad(callback: ConnectorSDKOnLoadCallback): void\n onExit(callback: ConnectorSDKOnEventExitCallback): void\n onExitSuccess(callback: ConnectorSDKOnExitSuccessCallback): void\n onExitAbort(callback: ConnectorSDKOnExitAbortCallback): void\n onExitError(callback: ConnectorSDKOnExitErrorCallback): void\n\n // Because it's well within React behavior to try to register a billion functions\n offEvent(callback: ConnectorSDKOnEventCallback): void\n offLoad(callback: ConnectorSDKOnLoadCallback): void\n offExit(callback: ConnectorSDKOnEventExitCallback): void\n offExitSuccess(callback: ConnectorSDKOnExitSuccessCallback): void\n offExitAbort(callback: ConnectorSDKOnExitAbortCallback): void\n offExitError(callback: ConnectorSDKOnExitErrorCallback): void\n}\n\nexport interface ConnectorSDK extends CallbackManager {\n authenticate(token: string | null | undefined): void\n connect(connectorId: string, options?: ConnectorSDKConnectOptions): ConnectorSDKConnector\n reconnect(connectorId: string, options: ConnectorSDKReconnectOptions): ConnectorSDKConnector\n\n reset(): void\n}\n\nexport interface ConnectorSDKConnector extends CallbackManager {\n open(): void\n}\n\n/**\n * Types for optional callbacks in the ConnectorSDK.\n *\n * Leaf event nodes return only metadata.\n * Internal nodes return both event type and metadata.\n */\nexport type ConnectorSDKCallbacks = {\n onEvent?: ConnectorSDKOnEventCallback\n onLoad?: ConnectorSDKOnLoadCallback\n onExit?: ConnectorSDKOnEventExitCallback\n onExitSuccess?: ConnectorSDKOnExitSuccessCallback\n onExitAbort?: ConnectorSDKOnExitAbortCallback\n onExitError?: ConnectorSDKOnExitErrorCallback\n}\n\nexport type ConnectorSDKOnEventCallback = (\n type: ConnectorSDKEventType,\n metadata: ConnectorSDKCallbackMetadata\n) => void\n\nexport type ConnectorSDKOnLoadCallback = (metadata: ConnectorSDKCallbackMetadata) => void\n\nexport type ConnectorSDKOnEventExitCallback = (\n type: ConnectorSDKEventType,\n metadata: ConnectorSDKCallbackMetadata\n) => void\n\nexport type ConnectorSDKOnExitSuccessCallback = (metadata: ConnectorSDKCallbackMetadata) => void\nexport type ConnectorSDKOnExitAbortCallback = (metadata: ConnectorSDKCallbackMetadata) => void\nexport type ConnectorSDKOnExitErrorCallback = (metadata: ConnectorSDKCallbackMetadata) => void\n\nexport enum ConnectorSDKEventType {\n Load = 'loaded',\n ExitSuccess = 'exited.successful',\n ExitAbort = 'exited.aborted',\n ExitError = 'exited.errored',\n}\n\nexport type ConnectorSDKCallbackMetadata = {\n connectorId: string\n profileId?: string\n connectionId?: string\n}\n\nexport type ConnectorSDKConnectOptions = ConnectorSDKCallbacks\nexport type ConnectorSDKReconnectOptions = ConnectorSDKCallbacks & {\n connectionId: string\n}\n\nexport type ConnectorSDKConnectorOptions = ConnectorSDKConnectOptions & {\n connectionId?: string\n}\n","import type { FetchResult, NextLink, Observable, Operation } from '@apollo/client/index.js'\nimport { ApolloLink } from '@apollo/client/index.js'\n\nimport { GlobalStorage } from '@/Storage'\n\n/**\n * unauthorizedCallback only triggers in the event the token is present, and\n * returns the token; This allows sessions to be forgotten without race conditions\n * causing null sessions to kill valid sessions, or invalid sessions for killing\n * valid sessions during rotation and networking weirdness.\n */\nexport class AuthLink extends ApolloLink {\n request(operation: Operation, forward: NextLink): Observable<FetchResult> | null {\n const token = GlobalStorage.get('session')\n\n if (!token) {\n console.warn(`QuilttLink attempted to send an unauthenticated Query`)\n return null\n }\n\n operation.setContext(({ headers = {} }) => ({\n headers: {\n ...headers,\n authorization: `Bearer ${token}`,\n },\n }))\n\n return forward(operation)\n }\n}\n\nexport default AuthLink\n","import { BatchHttpLink as ApolloHttpLink } from '@apollo/client/link/batch-http/index.js'\n\nimport fetch from 'cross-fetch'\n\nimport { endpointGraphQL } from '../../../configuration'\n\nexport const BatchHttpLink = new ApolloHttpLink({\n uri: endpointGraphQL,\n fetch,\n})\n\nexport default BatchHttpLink\n","{\n \"name\": \"@quiltt/core\",\n \"version\": \"3.3.4\",\n \"description\": \"Javascript API client and utilities for Quiltt\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/quiltt/quiltt-public.git\",\n \"directory\": \"ECMAScript/core\"\n },\n \"homepage\": \"https://github.com/quiltt/quiltt-public/tree/main/ECMAScript/core#readme\",\n \"keywords\": [\n \"quiltt\",\n \"typescript\"\n ],\n \"license\": \"MIT\",\n \"sideEffects\": [\n \"./src/Storage/Local.ts\",\n \"./src/api/graphql/links/SubscriptionLink.ts\"\n ],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"dist/**\",\n \"src/**\",\n \"CHANGELOG.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rimraf .turbo dist\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"TIMING=1 eslint --ext .js,.jsx,.ts,.tsx src/ --fix\",\n \"typecheck\": \"tsc --project tsconfig.json --noEmit\"\n },\n \"dependencies\": {\n \"@apollo/client\": \"^3.7.16\",\n \"axios\": \"^1.4.0\",\n \"cross-fetch\": \"^3.1.8\",\n \"graphql\": \"^16.8.1\",\n \"graphql-ruby-client\": \"^1.11.8\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"4.1.1\",\n \"@types/node\": \"18.16.18\",\n \"@types/react\": \"18.2.7\",\n \"@typescript-eslint/eslint-plugin\": \"5.60.1\",\n \"@typescript-eslint/parser\": \"5.60.1\",\n \"eslint\": \"8.43.0\",\n \"eslint-config-prettier\": \"8.8.0\",\n \"eslint-plugin-prettier\": \"4.2.1\",\n \"prettier\": \"2.8.8\",\n \"tsup\": \"6.7.0\",\n \"typescript\": \"5.1.3\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import { name as packageName, version as packageVersion } from '../package.json'\n\nconst QUILTT_API_INSECURE = (() => {\n try {\n return process.env.QUILTT_API_INSECURE\n } catch {\n return undefined\n }\n})()\n\nconst QUILTT_API_DOMAIN = (() => {\n try {\n return process.env.QUILTT_API_DOMAIN\n } catch {\n return undefined\n }\n})()\n\nconst QUILTT_DEBUG = (() => {\n try {\n return !!process.env.QUILTT_DEBUG || process.env.NODE_ENV !== 'production'\n } catch {\n return false\n }\n})()\n\nconst domain = QUILTT_API_DOMAIN || 'quiltt.io'\nconst protocolHttp = `http${QUILTT_API_INSECURE ? '' : 's'}`\nconst protocolWebsockets = `ws${QUILTT_API_DOMAIN ? '' : 's'}`\n\nexport const debugging = QUILTT_DEBUG\nexport const endpointAuth = `${protocolHttp}://auth.${domain}/v1/users/session`\nexport const endpointGraphQL = `${protocolHttp}://api.${domain}/v1/graphql`\nexport const endpointWebsockets = `${protocolWebsockets}://api.${domain}/websockets`\nexport const version = `${packageName}: v${packageVersion}`\n\nconst Config = {\n debugging,\n endpointAuth,\n endpointGraphQL,\n endpointWebsockets,\n version,\n}\n\nexport default Config\n","import { GlobalStorage } from '@/Storage'\n\nimport type { ServerError } from '@apollo/client/index.js'\nimport { onError } from '@apollo/client/link/error/index.js'\n\nexport const ErrorLink = onError(({ graphQLErrors, networkError }) => {\n if (graphQLErrors) {\n graphQLErrors.forEach(({ message, locations, path }) => {\n console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`)\n })\n }\n\n if (networkError) {\n if ((networkError as ServerError).statusCode === 401) {\n console.warn('[Authentication error]:', networkError)\n GlobalStorage.set('session', null)\n } else {\n console.warn('[Network error]:', networkError)\n }\n }\n})\n\nexport default ErrorLink\n","import { ApolloLink } from '@apollo/client/index.js'\n\nexport const ForwardableLink = new ApolloLink((operation, forward) => forward(operation))\n\nexport default ForwardableLink\n","import { HttpLink as ApolloHttpLink } from '@apollo/client/link/http/index.js'\n\nimport fetch from 'cross-fetch'\n\nimport { endpointGraphQL } from '../../../configuration'\n\nexport const HttpLink = new ApolloHttpLink({\n uri: endpointGraphQL,\n fetch,\n})\n\nexport default HttpLink\n","import type { ServerError } from '@apollo/client/index.js'\nimport { RetryLink as ApolloRetryLink } from '@apollo/client/link/retry/index.js'\n\nexport const RetryLink = new ApolloRetryLink({\n attempts: {\n retryIf: (error: ServerError, _operation) => error.statusCode >= 500,\n },\n})\n\nexport default RetryLink\n","import { GlobalStorage } from '@/Storage'\nimport type { FetchResult, NextLink, Operation } from '@apollo/client/core/index.js'\nimport { ApolloLink, Observable } from '@apollo/client/core/index.js'\nimport { print } from 'graphql'\nimport { endpointWebsockets } from '../../../configuration'\nimport type { Consumer } from './actioncable'\nimport { createConsumer } from './actioncable'\n\ntype RequestResult = FetchResult<\n { [key: string]: unknown },\n Record<string, unknown>,\n Record<string, unknown>\n>\ntype ConnectionParams = object | ((operation: Operation) => object)\n\nclass ActionCableLink extends ApolloLink {\n cables: { [id: string]: Consumer }\n channelName: string\n actionName: string\n connectionParams: ConnectionParams\n\n constructor(options: {\n channelName?: string\n actionName?: string\n connectionParams?: ConnectionParams\n }) {\n super()\n this.cables = {}\n this.channelName = options.channelName || 'GraphqlChannel'\n this.actionName = options.actionName || 'execute'\n this.connectionParams = options.connectionParams || {}\n }\n\n // Interestingly, this link does _not_ call through to `next` because\n // instead, it sends the request to ActionCable.\n request(operation: Operation, _next: NextLink): Observable<RequestResult> | null {\n const token = GlobalStorage.get('session')\n\n if (!token) {\n console.warn(`QuilttLink attempted to send an unauthenticated Subscription`)\n return null\n }\n\n if (!this.cables[token]) {\n this.cables[token] = createConsumer(endpointWebsockets + (token ? `?token=${token}` : ''))\n }\n\n return new Observable((observer) => {\n const channelId = Math.round(Date.now() + Math.random() * 100000).toString(16)\n const actionName = this.actionName\n const connectionParams =\n typeof this.connectionParams === 'function'\n ? this.connectionParams(operation)\n : this.connectionParams\n\n const channel = this.cables[token].subscriptions.create(\n Object.assign(\n {},\n {\n channel: this.channelName,\n channelId: channelId,\n },\n connectionParams\n ),\n {\n connected: () => {\n channel.perform(actionName, {\n query: operation.query ? print(operation.query) : null,\n variables: operation.variables,\n // This is added for persisted operation support:\n operationId: (operation as { operationId?: string }).operationId,\n operationName: operation.operationName,\n })\n },\n\n received: (payload: { result: RequestResult; more: any }) => {\n if (payload?.result?.data || payload?.result?.errors) {\n observer.next(payload.result)\n }\n\n if (!payload.more) {\n observer.complete()\n }\n },\n }\n )\n // Make the ActionCable subscription behave like an Apollo subscription\n return Object.assign(channel, { closed: false })\n })\n }\n}\n\nexport default ActionCableLink\n","export default {\n logger: typeof globalThis !== 'undefined' ? globalThis.console : undefined,\n WebSocket: typeof globalThis !== 'undefined' ? globalThis.WebSocket : undefined,\n}\n","import { debugging } from '../../../../configuration'\nimport adapters from './adapters'\n\nclass Logger {\n enabled = debugging\n\n log(...messages: Array<string>) {\n if (adapters.logger && this.enabled) {\n messages.push(Date.now().toString())\n adapters.logger.log('[ActionCable]', ...messages)\n }\n }\n}\n\nexport const logger = new Logger()\nexport default logger\n","// @ts-nocheck\nimport logger from './logger'\n\n// Responsible for ensuring the cable connection is in good health by validating the heartbeat pings sent from the server, and attempting\n// revival reconnections if things go astray. Internal class, not intended for direct user manipulation.\n\nconst now = () => new Date().getTime()\n\nconst secondsSince = (time) => (now() - time) / 1000\n\nclass ConnectionMonitor {\n constructor(connection) {\n this.visibilityDidChange = this.visibilityDidChange.bind(this)\n this.connection = connection\n this.reconnectAttempts = 0\n }\n\n start() {\n if (!this.isRunning()) {\n this.startedAt = now()\n delete this.stoppedAt\n this.startPolling()\n addEventListener('visibilitychange', this.visibilityDidChange)\n logger.log(\n `ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`\n )\n }\n }\n\n stop() {\n if (this.isRunning()) {\n this.stoppedAt = now()\n this.stopPolling()\n removeEventListener('visibilitychange', this.visibilityDidChange)\n logger.log('ConnectionMonitor stopped')\n }\n }\n\n isRunning() {\n return this.startedAt && !this.stoppedAt\n }\n\n recordPing() {\n this.pingedAt = now()\n }\n\n recordConnect() {\n this.reconnectAttempts = 0\n this.recordPing()\n delete this.disconnectedAt\n logger.log('ConnectionMonitor recorded connect')\n }\n\n recordDisconnect() {\n this.disconnectedAt = now()\n logger.log('ConnectionMonitor recorded disconnect')\n }\n\n // Private\n\n startPolling() {\n this.stopPolling()\n this.poll()\n }\n\n stopPolling() {\n clearTimeout(this.pollTimeout)\n }\n\n poll() {\n this.pollTimeout = setTimeout(() => {\n this.reconnectIfStale()\n this.poll()\n }, this.getPollInterval())\n }\n\n getPollInterval() {\n const { staleThreshold, reconnectionBackoffRate } = this.constructor\n const backoff = Math.pow(1 + reconnectionBackoffRate, Math.min(this.reconnectAttempts, 10))\n const jitterMax = this.reconnectAttempts === 0 ? 1.0 : reconnectionBackoffRate\n const jitter = jitterMax * Math.random()\n return staleThreshold * 1000 * backoff * (1 + jitter)\n }\n\n reconnectIfStale() {\n if (this.connectionIsStale()) {\n logger.log(\n `ConnectionMonitor detected stale connection. reconnectAttempts = ${\n this.reconnectAttempts\n }, time stale = ${secondsSince(this.refreshedAt)} s, stale threshold = ${\n this.constructor.staleThreshold\n } s`\n )\n this.reconnectAttempts++\n if (this.disconnectedRecently()) {\n logger.log(\n `ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${secondsSince(\n this.disconnectedAt\n )} s`\n )\n } else {\n logger.log('ConnectionMonitor reopening')\n this.connection.reopen()\n }\n }\n }\n\n get refreshedAt() {\n return this.pingedAt ? this.pingedAt : this.startedAt\n }\n\n connectionIsStale() {\n return secondsSince(this.refreshedAt) > this.constructor.staleThreshold\n }\n\n disconnectedRecently() {\n return (\n this.disconnectedAt && secondsSince(this.disconnectedAt) < this.constructor.staleThreshold\n )\n }\n\n visibilityDidChange() {\n if (document.visibilityState === 'visible') {\n setTimeout(() => {\n if (this.connectionIsStale() || !this.connection.isOpen()) {\n logger.log(\n `ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`\n )\n this.connection.reopen()\n }\n }, 200)\n }\n }\n}\n\nConnectionMonitor.staleThreshold = 6 // Server::Connections::BEAT_INTERVAL * 2 (missed two pings)\nConnectionMonitor.reconnectionBackoffRate = 0.15\n\nexport default ConnectionMonitor\n","const INTERNAL = {\n message_types: {\n welcome: 'welcome',\n disconnect: 'disconnect',\n ping: 'ping',\n confirmation: 'confirm_subscription',\n rejection: 'reject_subscription',\n },\n disconnect_reasons: {\n unauthorized: 'unauthorized',\n invalid_request: 'invalid_request',\n server_restart: 'server_restart',\n remote: 'remote',\n },\n default_mount_path: '/cable',\n protocols: ['actioncable-v1-json', 'actioncable-unsupported'],\n}\n\nexport default INTERNAL\n","// @ts-nocheck\nimport adapters from './adapters'\nimport ConnectionMonitor from './connection_monitor'\nimport INTERNAL from './internal'\nimport logger from './logger'\n\n// Encapsulate the cable connection held by the consumer. This is an internal class not intended for direct user manipulation.\n\nconst { message_types, protocols } = INTERNAL\nconst supportedProtocols = protocols.slice(0, protocols.length - 1)\n\nconst indexOf = [].indexOf\n\nclass Connection {\n constructor(consumer) {\n this.open = this.open.bind(this)\n this.consumer = consumer\n this.subscriptions = this.consumer.subscriptions\n this.monitor = new ConnectionMonitor(this)\n this.disconnected = true\n }\n\n send(data) {\n if (this.isOpen()) {\n this.webSocket.send(JSON.stringify(data))\n return true\n } else {\n return false\n }\n }\n\n open() {\n if (this.isActive()) {\n logger.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`)\n return false\n } else {\n const socketProtocols = [...protocols, ...(this.consumer.subprotocols || [])]\n logger.log(\n `Opening WebSocket, current state is ${this.getState()}, subprotocols: ${socketProtocols}`\n )\n if (this.webSocket) {\n this.uninstallEventHandlers()\n }\n this.webSocket = new adapters.WebSocket(this.consumer.url, socketProtocols)\n this.installEventHandlers()\n this.monitor.start()\n return true\n }\n }\n\n close({ allowReconnect } = { allowReconnect: true }) {\n if (!allowReconnect) {\n this.monitor.stop()\n }\n // Avoid closing websockets in a \"connecting\" state due to Safari 15.1+ bug. See: https://github.com/rails/rails/issues/43835#issuecomment-1002288478\n if (this.isOpen()) {\n return this.webSocket.close()\n }\n }\n\n reopen() {\n logger.log(`Reopening WebSocket, current state is ${this.getState()}`)\n if (this.isActive()) {\n try {\n return this.close()\n } catch (error) {\n logger.log('Failed to reopen WebSocket', error)\n } finally {\n logger.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`)\n setTimeout(this.open, this.constructor.reopenDelay)\n }\n } else {\n return this.open()\n }\n }\n\n getProtocol() {\n if (this.webSocket) {\n return this.webSocket.protocol\n }\n }\n\n isOpen() {\n return this.isState('open')\n }\n\n isActive() {\n return this.isState('open', 'connecting')\n }\n\n triedToReconnect() {\n return this.monitor.reconnectAttempts > 0\n }\n\n // Private\n\n isProtocolSupported() {\n return indexOf.call(supportedProtocols, this.getProtocol()) >= 0\n }\n\n isState(...states) {\n return indexOf.call(states, this.getState()) >= 0\n }\n\n getState() {\n if (this.webSocket) {\n for (const state in adapters.WebSocket) {\n if (adapters.WebSocket[state] === this.webSocket.readyState) {\n return state.toLowerCase()\n }\n }\n }\n return null\n }\n\n installEventHandlers() {\n for (const eventName in this.events) {\n const handler = this.events[eventName].bind(this)\n this.webSocket[`on${eventName}`] = handler\n }\n }\n\n uninstallEventHandlers() {\n for (const eventName in this.events) {\n this.webSocket[`on${eventName}`] = function () {}\n }\n }\n}\n\nConnection.reopenDelay = 500\n\nConnection.prototype.events = {\n message(event) {\n if (!this.isProtocolSupported()) {\n return\n }\n const { identifier, message, reason, reconnect, type } = JSON.parse(event.data)\n switch (type) {\n case message_types.welcome:\n if (this.triedToReconnect()) {\n this.reconnectAttempted = true\n }\n this.monitor.recordConnect()\n return this.subscriptions.reload()\n case message_types.disconnect:\n logger.log(`Disconnecting. Reason: ${reason}`)\n return this.close({ allowReconnect: reconnect })\n case message_types.ping:\n return this.monitor.recordPing()\n case message_types.confirmation:\n this.subscriptions.confirmSubscription(identifier)\n if (this.reconnectAttempted) {\n this.reconnectAttempted = false\n return this.subscriptions.notify(identifier, 'connected', { reconnected: true })\n } else {\n return this.subscriptions.notify(identifier, 'connected', { reconnected: false })\n }\n case message_types.rejection:\n return this.subscriptions.reject(identifier)\n default:\n return this.subscriptions.notify(identifier, 'received', message)\n }\n },\n\n open() {\n logger.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`)\n this.disconnected = false\n if (!this.isProtocolSupported()) {\n logger.log('Protocol is unsupported. Stopping monitor and disconnecting.')\n return this.close({ allowReconnect: false })\n }\n },\n\n close(_event) {\n logger.log('WebSocket onclose event')\n if (this.disconnected) {\n return\n }\n this.disconnected = true\n this.monitor.recordDisconnect()\n return this.subscriptions.notifyAll('disconnected', {\n willAttemptReconnect: this.monitor.isRunning(),\n })\n },\n\n error() {\n logger.log('WebSocket onerror event')\n },\n}\n\nexport default Connection\n","import type { Consumer } from './consumer'\n\nexport type Data = { [id: string]: string | object | null | undefined }\n\nconst extend = function (object: Data, properties: Data) {\n if (properties !== null) {\n for (const key in properties) {\n const value = properties[key]\n object[key] = value\n }\n }\n return object\n}\n\nexport class Subscription {\n consumer: Consumer\n identifier: string\n\n constructor(consumer: Consumer, params: Data = {}, mixin: Data) {\n this.consumer = consumer\n this.identifier = JSON.stringify(params)\n extend(this as unknown as Data, mixin)\n }\n\n // Perform a channel action with the optional data passed as an attribute\n perform(action: string, data: Data = {}) {\n data.action = action\n return this.send(data)\n }\n\n send(data: object) {\n return this.consumer.send({\n command: 'message',\n identifier: this.identifier,\n data: JSON.stringify(data),\n })\n }\n\n unsubscribe() {\n return this.consumer.subscriptions.remove(this)\n }\n}\n\nexport default Subscription\n","import logger from './logger'\nimport type { Subscription } from './subscription'\nimport type { Subscriptions } from './subscriptions'\n\n// Responsible for ensuring channel subscribe command is confirmed, retrying until confirmation is received.\n// Internal class, not intended for direct user manipulation.\n\nclass SubscriptionGuarantor {\n subscriptions: Subscriptions\n pendingSubscriptions: Array<Subscription>\n retryTimeout: ReturnType<typeof setTimeout> | undefined\n\n constructor(subscriptions: Subscriptions) {\n this.subscriptions = subscriptions\n this.pendingSubscriptions = []\n }\n\n guarantee(subscription: Subscription) {\n if (this.pendingSubscriptions.indexOf(subscription) == -1) {\n logger.log(`SubscriptionGuarantor guaranteeing ${subscription.identifier}`)\n this.pendingSubscriptions.push(subscription)\n } else {\n logger.log(`SubscriptionGuarantor already guaranteeing ${subscription.identifier}`)\n }\n this.startGuaranteeing()\n }\n\n forget(subscription: Subscription) {\n logger.log(`SubscriptionGuarantor forgetting ${subscription.identifier}`)\n this.pendingSubscriptions = this.pendingSubscriptions.filter((s) => s !== subscription)\n }\n\n startGuaranteeing() {\n this.stopGuaranteeing()\n this.retrySubscribing()\n }\n\n stopGuaranteeing() {\n clearTimeout(this.retryTimeout)\n }\n\n retrySubscribing() {\n this.retryTimeout = setTimeout(() => {\n if (this.subscriptions && typeof this.subscriptions.subscribe === 'function') {\n this.pendingSubscriptions.map((subscription) => {\n logger.log(`SubscriptionGuarantor resubscribing ${subscription.identifier}`)\n this.subscriptions.subscribe(subscription)\n })\n }\n }, 500)\n }\n}\n\nexport default SubscriptionGuarantor\n","import type { Consumer } from './consumer'\nimport logger from './logger'\nimport type { Data } from './subscription'\nimport Subscription from './subscription'\nimport SubscriptionGuarantor from './subscription_guarantor'\n\n// Collection class for creating (and internally managing) channel subscriptions.\n// The only method intended to be triggered by the user is ActionCable.Subscriptions#create,\n// and it should be called through the consumer like so:\n//\n// App = {}\n// App.cable = ActionCable.createConsumer(\"ws://example.com/accounts/1\")\n// App.appearance = App.cable.subscriptions.create(\"AppearanceChannel\")\n//\n// For more details on how you'd configure an actual channel subscription, see ActionCable.Subscription.\n\nexport class Subscriptions {\n consumer: Consumer\n guarantor: SubscriptionGuarantor\n subscriptions: Array<Subscription>\n\n constructor(consumer: Consumer) {\n this.consumer = consumer\n this.guarantor = new SubscriptionGuarantor(this)\n this.subscriptions = []\n }\n\n create(channelName: string, mixin: Data) {\n const channel = channelName\n const params = typeof channel === 'object' ? channel : { channel }\n const subscription = new Subscription(this.consumer, params, mixin)\n return this.add(subscription)\n }\n\n // Private\n\n add(subscription: Subscription) {\n this.subscriptions.push(subscription)\n this.consumer.ensureActiveConnection()\n this.notify(subscription, 'initialized')\n this.subscribe(subscription)\n return subscription\n }\n\n remove(subscription: Subscription) {\n this.forget(subscription)\n if (!this.findAll(subscription.identifier).length) {\n this.sendCommand(subscription, 'unsubscribe')\n }\n return subscription\n }\n\n reject(identifier: string) {\n return this.findAll(identifier).map((subscription) => {\n this.forget(subscription)\n this.notify(subscription, 'rejected')\n return subscription\n })\n }\n\n forget(subscription: Subscription) {\n this.guarantor.forget(subscription)\n this.subscriptions = this.subscriptions.filter((s) => s !== subscription)\n return subscription\n }\n\n findAll(identifier: string) {\n return this.subscriptions.filter((s) => s.identifier === identifier)\n }\n\n reload() {\n return this.subscriptions.map((subscription) => this.subscribe(subscription))\n }\n\n notifyAll(callbackName: string, ...args: any[]) {\n return this.subscriptions.map((subscription) =>\n this.notify(subscription, callbackName, ...args)\n )\n }\n\n notify(subscription: Subscription, callbackName: string, ...args: any[]) {\n let subscriptions\n if (typeof subscription === 'string') {\n subscriptions = this.findAll(subscription)\n } else {\n subscriptions = [subscription]\n }\n\n return subscriptions.map((subscription: any) =>\n typeof subscription[callbackName] === 'function'\n ? subscription[callbackName](...args)\n : undefined\n )\n }\n\n subscribe(subscription: Subscription) {\n if (this.sendCommand(subscription, 'subscribe')) {\n this.guarantor.guarantee(subscription)\n }\n }\n\n confirmSubscription(identifier: string) {\n logger.log(`Subscription confirmed ${identifier}`)\n this.findAll(identifier).map((subscription) => this.guarantor.forget(subscription))\n }\n\n sendCommand(subscription: Subscription, command: string) {\n const { identifier } = subscription\n return this.consumer.send({ command, identifier })\n }\n}\n\nexport default Subscriptions\n","import Connection from './connection'\nimport Subscriptions from './subscriptions'\n\n// The ActionCable.Consumer establishes the connection to a server-side Ruby Connection object. Once established,\n// the ActionCable.ConnectionMonitor will ensure that its properly maintained through heartbeats and checking for stale updates.\n// The Consumer instance is also the gateway to establishing subscriptions to desired channels through the #createSubscription\n// method.\n//\n// The following example shows how this can be set up:\n//\n// App = {}\n// App.cable = ActionCable.createConsumer(\"ws://example.com/accounts/1\")\n// App.appearance = App.cable.subscriptions.create(\"AppearanceChannel\")\n//\n// For more details on how you'd configure an actual channel subscription, see ActionCable.Subscription.\n//\n// When a consumer is created, it automatically connects with the server.\n//\n// To disconnect from the server, call\n//\n// App.cable.disconnect()\n//\n// and to restart the connection:\n//\n// App.cable.connect()\n//\n// Any channel subscriptions which existed prior to disconnecting will\n// automatically resubscribe.\n\nexport class Consumer {\n _url: string\n subscriptions: Subscriptions\n connection: Connection\n subprotocols: Array<string>\n\n constructor(url: string) {\n this._url = url\n this.subscriptions = new Subscriptions(this)\n this.connection = new Connection(this)\n this.subprotocols = []\n }\n\n get url() {\n return createWebSocketURL(this._url)\n }\n\n send(data: object) {\n return this.connection.send(data)\n }\n\n connect() {\n return this.connection.open()\n }\n\n disconnect() {\n return this.connection.close({ allowReconnect: false })\n }\n\n ensureActiveConnection() {\n if (!this.connection.isActive()) {\n return this.connection.open()\n }\n }\n\n addSubProtocol(subprotocol: string) {\n this.subprotocols = [...this.subprotocols, subprotocol]\n }\n}\n\nexport function createWebSocketURL(url: string | (() => string)): string {\n if (typeof url === 'function') {\n url = url()\n }\n\n if (url && !/^wss?:/i.test(url)) {\n const a = document.createElement('a')\n a.href = url\n // eslint-disable-next-line no-self-assign\n a.href = a.href\n a.protocol = a.protocol.replace('http', 'ws')\n return a.href\n } else {\n return url\n }\n}\n\nexport default Consumer\n","'use client'\n\nimport adapters from './adapters'\nimport Connection from './connection'\nimport ConnectionMonitor from './connection_monitor'\nimport Consumer, { createWebSocketURL } from './consumer'\nimport INTERNAL from './internal'\nimport logger from './logger'\nimport Subscription from './subscription'\nimport SubscriptionGuarantor from './subscription_guarantor'\nimport Subscriptions from './subscriptions'\n\nexport {\n Connection,\n ConnectionMonitor,\n Consumer,\n INTERNAL,\n Subscription,\n Subscriptions,\n SubscriptionGuarantor,\n adapters,\n createWebSocketURL,\n logger,\n}\n\nexport function createConsumer(url = getConfig('url') || INTERNAL.default_mount_path) {\n return new Consumer(url)\n}\n\nexport function getConfig(name: string) {\n const element = document.head.querySelector(`meta[name='action-cable-${name}']`)\n if (element) {\n return element.getAttribute('content')\n }\n}\n","'use client'\n\nimport ActionCableLink from './ActionCableLink'\n\nexport class SubscriptionLink extends ActionCableLink {\n constructor() {\n super({ channelName: 'GraphQLChannel' })\n }\n}\n\nexport default SubscriptionLink\n","import { ApolloLink } from '@apollo/client/index.js'\n\nexport const TerminatingLink = new ApolloLink(() => null)\n\nexport default TerminatingLink\n","import { ApolloLink } from '@apollo/client/index.js'\n\nimport { version } from '../../../configuration'\n\nexport const VersionLink = new ApolloLink((operation, forward) => {\n operation.setContext(({ headers = {} }) => ({\n headers: {\n ...headers,\n 'Quiltt-Client-Version': version,\n },\n }))\n return forward(operation)\n})\n\nexport default VersionLink\n","import type { ApolloClientOptions, Operation } from '@apollo/client/index.js'\nimport { ApolloClient, ApolloLink } from '@apollo/client/index.js'\n\nimport { debugging } from '../../configuration'\nimport {\n AuthLink,\n BatchHttpLink,\n ErrorLink,\n ForwardableLink,\n HttpLink,\n RetryLink,\n SubscriptionLink,\n VersionLink,\n} from './links'\n\nexport type QuilttClientOptions<T> = Omit<ApolloClientOptions<T>, 'link'>\n\nexport class QuilttClient<T> extends ApolloClient<T> {\n constructor(options: QuilttClientOptions<T>) {\n if (!options.connectToDevTools) options.connectToDevTools = debugging\n\n const isSubscriptionOperation = (operation: Operation) => {\n return operation.query.definitions.some(\n // @ts-ignore\n ({ kind, operation }) => kind === 'OperationDefinition' && operation === 'subscription'\n )\n }\n\n const isBatchable = (operation: Operation) => {\n return operation.getContext().batchable ?? true\n }\n\n const authLink = new AuthLink()\n const subscriptionsLink = new SubscriptionLink()\n\n const quilttLink = ApolloLink.from([VersionLink, authLink, ErrorLink, RetryLink])\n .split(isSubscriptionOperation, subscriptionsLink, ForwardableLink)\n .split(isBatchable, BatchHttpLink, HttpLink)\n\n super({\n link: quilttLink,\n ...options,\n })\n }\n}\n\nexport { InMemoryCache, gql, useMutation, useQuery, useSubscription } from '@apollo/client/index.js'\nexport type {\n NormalizedCacheObject,\n OperationVariables,\n ApolloError,\n} from '@apollo/client/index.js'\n","import type { AxiosRequestConfig as RequestConfig } from 'axios'\nimport Axios from 'axios'\n\nexport type { AxiosResponse } from 'axios'\nexport type AxiosRequestConfig<D = any> = RequestConfig<D> & {\n retry: boolean\n}\n\nconst RETRY_DELAY = 150 // ms\nconst RETRIES = 10 // 150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500 = 8.250s\n\n// Create an axios singleton for Quiltt, to prevent mutating other instances\nconst axios = Axios.create()\n\n// Example: axios.get(url, { retry: true })\naxios.interceptors.response.use(undefined, (error) => {\n const { config, message, response } = error\n const messageLower = message.toLowerCase()\n\n if (!config || !config.retry) {\n return Promise.reject(error)\n }\n\n // Retry Network timeout, Network errors, and Too Many Requests\n if (\n !(\n messageLower.includes('timeout') ||\n messageLower.includes('network error') ||\n response?.status === 429\n )\n ) {\n return Promise.reject(error)\n }\n\n if (config.retriesRemaining === undefined) {\n config.retriesRemaining = RETRIES - 1\n } else if (config.retriesRemaining === 1) {\n return Promise.reject(error)\n } else {\n config.retriesRemaining -= 1\n }\n\n const delay = new Promise<void>((resolve) => {\n setTimeout(() => resolve(), RETRY_DELAY * (RETRIES - config.retriesRemaining))\n })\n\n return delay.then(() => axios(config))\n})\n\nexport { axios }\n\nexport default axios\n","import type { AxiosRequestConfig, AxiosResponse } from './axios'\nimport { axios } from './axios'\n\nimport { endpointAuth } from '../../configuration'\n\nexport enum AuthStrategies {\n Email = 'email',\n Phone = 'phone',\n}\n\ninterface EmailInput {\n email: string\n phone?: never\n}\n\ninterface PhoneInput {\n phone: string\n email?: never\n}\n\nexport type UsernamePayload = EmailInput | PhoneInput\nexport type PasscodePayload = UsernamePayload & { passcode: string }\n\ntype SessionData = { token: string }\ntype NoContentData = void\ntype UnauthorizedData = { message: string; instruction: string }\nexport type UnprocessableData = { [attribute: string]: Array<string> }\n\ntype Ping = SessionData | UnauthorizedData\ntype Indentify = SessionData | NoContentData | UnprocessableData\ntype Authenticate = SessionData | UnauthorizedData | UnprocessableData\ntype Revoke = NoContentData | UnauthorizedData\n\nexport type SessionResponse = AxiosResponse<SessionData>\nexport type UnprocessableResponse = AxiosResponse<UnprocessableData>\n\n// https://www.quiltt.dev/api-reference/rest/auth#\nexport class AuthAPI {\n clientId: string | undefined\n\n constructor(clientId?: string | undefined) {\n this.clientId = clientId\n }\n\n /**\n * Response Statuses:\n * - 200: OK -> Session is Valid\n * - 401: Unauthorized -> Session is Invalid\n */\n ping = (token: string) => {\n return axios.get<Ping>(endpointAuth, this.config(token))\n }\n\n /**\n * Response Statuses:\n * - 201: Created -> Profile Created, New Session Returned\n * - 202: Accepted -> Profile Found, MFA Code Sent for `authenticate`\n * - 422: Unprocessable Entity -> Invalid Payload\n */\n identify = (payload: UsernamePayload) => {\n return axios.post<Indentify>(endpointAuth, this.body(payload), this.config())\n }\n\n /**\n * Response Statuses:\n * - 201: Created -> MFA Validated, New Session Returned\n * - 401: Unauthorized -> MFA Invalid\n * - 422: Unprocessable Entity -> Invalid Payload\n */\n authenticate = (payload: PasscodePayload) => {\n return axios.put<Authenticate>(endpointAuth, this.body(payload), this.config())\n }\n\n /**\n * Response Statuses:\n * - 204: No Content -> Session Revoked\n * - 401: Unauthorized -> Session Not Found\n */\n revoke = (token: string) => {\n return axios.delete<Revoke>(endpointAuth, this.config(token))\n }\n\n private config = (token?: string): AxiosRequestConfig => {\n const headers: { [id: string]: string } = {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n }\n\n if (token) {\n headers.Authorization = `Bearer ${token}`\n }\n\n return {\n headers: headers,\n validateStatus: this.validateStatus,\n retry: true,\n }\n }\n\n private validateStatus = (status: number) => status < 500\n\n private body = (payload: any) => {\n if (!this.clientId) {\n console.error('Quiltt Client ID is not set. Unable to identify & authenticate')\n }\n\n return {\n session: {\n deploymentId: this.clientId, // Rename API?\n ...payload,\n },\n }\n }\n}\n\nexport default AuthAPI\n"]}
|