diff --git a/CHANGELOG.md b/CHANGELOG.md index 34182bc..af5b3e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.17.3-WIP +## 0.17.3 - Loosen the type check when calling `pb.files.getUrl(user, filename)` to allow passing the `pb.authStore.model` without type assertion. diff --git a/dist/pocketbase.cjs.d.ts b/dist/pocketbase.cjs.d.ts index 87240a4..ac07ca2 100644 --- a/dist/pocketbase.cjs.d.ts +++ b/dist/pocketbase.cjs.d.ts @@ -1021,9 +1021,9 @@ declare class Client { /** * Legacy alias of `pb.files.getUrl()`. */ - getFileUrl(record: Pick<{ + getFileUrl(record: { [key: string]: any; - }, 'id' | 'collectionId' | 'collectionName'>, filename: string, queryParams?: FileOptions): string; + }, filename: string, queryParams?: FileOptions): string; /** * Builds a full client url by safely concatenating the provided path. */ diff --git a/dist/pocketbase.cjs.js.map b/dist/pocketbase.cjs.js.map index 8584ff4..ec9ba47 100644 --- a/dist/pocketbase.cjs.js.map +++ b/dist/pocketbase.cjs.js.map @@ -1 +1 @@ -{"version":3,"file":"pocketbase.cjs.js","sources":["../src/ClientResponseError.ts","../src/stores/utils/cookie.ts","../src/stores/utils/jwt.ts","../src/stores/BaseAuthStore.ts","../src/stores/LocalAuthStore.ts","../src/services/utils/BaseService.ts","../src/services/SettingsService.ts","../src/services/utils/CrudService.ts","../src/services/utils/legacy.ts","../src/services/AdminService.ts","../src/services/RealtimeService.ts","../src/services/RecordService.ts","../src/services/CollectionService.ts","../src/services/LogService.ts","../src/services/HealthService.ts","../src/services/FileService.ts","../src/services/BackupService.ts","../src/Client.ts"],"sourcesContent":["/**\n * ClientResponseError is a custom Error class that is intended to wrap\n * and normalize any error thrown by `Client.send()`.\n */\nexport class ClientResponseError extends Error {\n url: string = '';\n status: number = 0;\n response: {[key: string]: any} = {};\n isAbort: boolean = false;\n originalError: any = null;\n\n constructor(errData?: any) {\n super(\"ClientResponseError\");\n\n // Set the prototype explicitly.\n // https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\n Object.setPrototypeOf(this, ClientResponseError.prototype);\n\n if (errData !== null && typeof errData === 'object') {\n this.url = typeof errData.url === 'string' ? errData.url : '';\n this.status = typeof errData.status === 'number' ? errData.status : 0;\n this.isAbort = !!errData.isAbort;\n this.originalError = errData.originalError;\n\n if (errData.response !== null && typeof errData.response === 'object') {\n this.response = errData.response;\n } else if (errData.data !== null && typeof errData.data === 'object') {\n this.response = errData.data;\n } else {\n this.response = {};\n }\n }\n\n if (!this.originalError && !(errData instanceof ClientResponseError)) {\n this.originalError = errData;\n }\n\n if (typeof DOMException !== 'undefined' && errData instanceof DOMException) {\n this.isAbort = true;\n }\n\n this.name = \"ClientResponseError \" + this.status;\n this.message = this.response?.message;\n if (!this.message) {\n if (this.isAbort) {\n this.message = 'The request was autocancelled. You can find more info in https://github.com/pocketbase/js-sdk#auto-cancellation.';\n } else if (this.originalError?.cause?.message?.includes(\"ECONNREFUSED ::1\")) {\n this.message = 'Failed to connect to the PocketBase server. Try changing the SDK URL from localhost to 127.0.0.1 (https://github.com/pocketbase/js-sdk/issues/21).';\n } else {\n this.message = 'Something went wrong while processing your request.';\n }\n }\n }\n\n /**\n * Alias for `this.response` to preserve the backward compatibility.\n */\n get data() {\n return this.response;\n }\n\n /**\n * Make a POJO's copy of the current error class instance.\n * @see https://github.com/vuex-orm/vuex-orm/issues/255\n */\n toJSON() {\n return { ...this };\n }\n}\n","/**\n * -------------------------------------------------------------------\n * Simple cookie parse and serialize utilities mostly based on the\n * node module https://github.com/jshttp/cookie.\n * -------------------------------------------------------------------\n */\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\nconst fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;\n\nexport interface ParseOptions{\n decode?: (val: string) => string,\n}\n\n/**\n* Parses the given cookie header string into an object\n* The object has the various cookies as keys(names) => values\n*/\nexport function cookieParse(str: string, options?: ParseOptions): { [key: string]: any } {\n const result: { [key: string]: any } = {};\n\n if (typeof str !== 'string') {\n return result;\n }\n\n const opt = Object.assign({}, options || {});\n const decode = opt.decode || defaultDecode;\n\n let index = 0;\n while (index < str.length) {\n const eqIdx = str.indexOf('=', index);\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break;\n }\n\n let endIdx = str.indexOf(';', index);\n\n if (endIdx === -1) {\n endIdx = str.length;\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(';', eqIdx - 1) + 1;\n continue;\n }\n\n const key = str.slice(index, eqIdx).trim();\n\n // only assign once\n if (undefined === result[key]) {\n let val = str.slice(eqIdx + 1, endIdx).trim();\n\n // quoted values\n if (val.charCodeAt(0) === 0x22) {\n val = val.slice(1, -1);\n }\n\n try {\n result[key] = decode(val);\n } catch (_) {\n result[key] = val; // no decoding\n }\n }\n\n index = endIdx + 1;\n }\n\n return result;\n};\n\nexport interface SerializeOptions {\n encode?: (val: string | number | boolean) => string,\n maxAge?: number,\n domain?: string,\n path?: string,\n expires?: Date,\n httpOnly?: boolean,\n secure?: boolean,\n priority?: string,\n sameSite?: boolean|string,\n}\n\n/**\n * Serialize data into a cookie header.\n *\n * Serialize the a name value pair into a cookie string suitable for\n * http headers. An optional options object specified cookie parameters.\n *\n * ```js\n * cookieSerialize('foo', 'bar', { httpOnly: true }) // \"foo=bar; httpOnly\"\n * ```\n */\nexport function cookieSerialize(name: string, val: string, options?: SerializeOptions): string {\n const opt = Object.assign({}, options || {});\n const encode = opt.encode || defaultEncode;\n\n if (!fieldContentRegExp.test(name)) {\n throw new TypeError('argument name is invalid');\n }\n\n const value = encode(val);\n\n if (value && !fieldContentRegExp.test(value)) {\n throw new TypeError('argument val is invalid');\n }\n\n let result = name + '=' + value;\n\n if (opt.maxAge != null) {\n const maxAge = opt.maxAge - 0;\n\n if (isNaN(maxAge) || !isFinite(maxAge)) {\n throw new TypeError('option maxAge is invalid');\n }\n\n result += '; Max-Age=' + Math.floor(maxAge);\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new TypeError('option domain is invalid');\n }\n\n result += '; Domain=' + opt.domain;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new TypeError('option path is invalid');\n }\n\n result += '; Path=' + opt.path;\n }\n\n if (opt.expires) {\n if (!isDate(opt.expires) || isNaN(opt.expires.valueOf())) {\n throw new TypeError('option expires is invalid');\n }\n\n result += '; Expires=' + opt.expires.toUTCString();\n }\n\n if (opt.httpOnly) {\n result += '; HttpOnly';\n }\n\n if (opt.secure) {\n result += '; Secure';\n }\n\n if (opt.priority) {\n const priority = typeof opt.priority === 'string' ? opt.priority.toLowerCase() : opt.priority;\n\n switch (priority) {\n case 'low':\n result += '; Priority=Low';\n break;\n case 'medium':\n result += '; Priority=Medium';\n break;\n case 'high':\n result += '; Priority=High';\n break;\n default:\n throw new TypeError('option priority is invalid');\n }\n }\n\n if (opt.sameSite) {\n const sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;\n\n switch (sameSite) {\n case true:\n result += '; SameSite=Strict';\n break;\n case 'lax':\n result += '; SameSite=Lax';\n break;\n case 'strict':\n result += '; SameSite=Strict';\n break;\n case 'none':\n result += '; SameSite=None';\n break;\n default:\n throw new TypeError('option sameSite is invalid');\n }\n }\n\n return result;\n};\n\n/**\n * Default URL-decode string value function.\n * Optimized to skip native call when no `%`.\n */\nfunction defaultDecode(val: string): string {\n return val.indexOf('%') !== -1\n ? decodeURIComponent(val)\n : val;\n}\n\n/**\n * Default URL-encode value function.\n */\nfunction defaultEncode(val: string | number | boolean): string {\n return encodeURIComponent(val);\n}\n\n/**\n * Determines if value is a Date.\n */\nfunction isDate(val: any): boolean {\n return (\n Object.prototype.toString.call(val) === '[object Date]' ||\n val instanceof Date\n );\n}\n","let atobPolyfill: Function;\nif (typeof atob === 'function') {\n atobPolyfill = atob\n} else {\n /**\n * The code was extracted from:\n * https://github.com/davidchambers/Base64.js\n */\n atobPolyfill = (input: any) => {\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\n let str = String(input).replace(/=+$/, \"\");\n if (str.length % 4 == 1) {\n throw new Error(\"'atob' failed: The string to be decoded is not correctly encoded.\");\n }\n\n for (\n // initialize result and counters\n var bc = 0, bs, buffer, idx = 0, output = \"\";\n // get next character\n (buffer = str.charAt(idx++));\n // character found in table? initialize bit storage and add its ascii value;\n ~buffer &&\n ((bs = bc % 4 ? (bs as any) * 64 + buffer : buffer),\n // and if not first of each 4 characters,\n // convert the first 8 bits to one ascii character\n bc++ % 4) ?\n (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)))) :\n 0\n ) {\n // try to find character in table (0-63, not found => -1)\n buffer = chars.indexOf(buffer);\n }\n\n return output;\n };\n}\n\n/**\n * Returns JWT token's payload data.\n */\nexport function getTokenPayload(token: string): { [key: string]: any } {\n if (token) {\n try {\n const encodedPayload = decodeURIComponent(atobPolyfill(token.split('.')[1]).split('').map(function (c: string) {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n }).join(''));\n\n return JSON.parse(encodedPayload) || {};\n } catch (e) {\n }\n }\n\n return {};\n}\n\n/**\n * Checks whether a JWT token is expired or not.\n * Tokens without `exp` payload key are considered valid.\n * Tokens with empty payload (eg. invalid token strings) are considered expired.\n *\n * @param token The token to check.\n * @param [expirationThreshold] Time in seconds that will be subtracted from the token `exp` property.\n */\nexport function isTokenExpired(token: string, expirationThreshold = 0): boolean {\n let payload = getTokenPayload(token);\n\n if (\n Object.keys(payload).length > 0 &&\n (!payload.exp || (payload.exp - expirationThreshold) > (Date.now() / 1000))\n ) {\n return false;\n }\n\n return true;\n}\n","import { cookieParse, cookieSerialize, SerializeOptions } from '@/stores/utils/cookie';\nimport { isTokenExpired, getTokenPayload } from '@/stores/utils/jwt';\nimport { RecordModel, AdminModel } from '@/services/utils/dtos';\n\nexport type AuthModel = RecordModel|AdminModel|null;\n\nexport type OnStoreChangeFunc = (token: string, model: AuthModel) => void;\n\nconst defaultCookieKey = 'pb_auth';\n\n/**\n * Base AuthStore class that is intended to be extended by all other\n * PocketBase AuthStore implementations.\n */\nexport abstract class BaseAuthStore {\n protected baseToken: string = '';\n protected baseModel: AuthModel = null;\n\n private _onChangeCallbacks: Array = [];\n\n /**\n * Retrieves the stored token (if any).\n */\n get token(): string {\n return this.baseToken;\n }\n\n /**\n * Retrieves the stored model data (if any).\n */\n get model(): AuthModel {\n return this.baseModel;\n }\n\n /**\n * Loosely checks if the store has valid token (aka. existing and unexpired exp claim).\n */\n get isValid(): boolean {\n return !isTokenExpired(this.token);\n }\n\n /**\n * Checks whether the current store state is for admin authentication.\n */\n get isAdmin(): boolean {\n return getTokenPayload(this.token).type === \"admin\";\n }\n\n /**\n * Checks whether the current store state is for auth record authentication.\n */\n get isAuthRecord(): boolean {\n return getTokenPayload(this.token).type === \"authRecord\";\n }\n\n /**\n * Saves the provided new token and model data in the auth store.\n */\n save(token: string, model?: AuthModel): void {\n this.baseToken = token || '';\n this.baseModel = model || null;\n\n this.triggerChange();\n }\n\n /**\n * Removes the stored token and model data form the auth store.\n */\n clear(): void {\n this.baseToken = '';\n this.baseModel = null;\n this.triggerChange();\n }\n\n /**\n * Parses the provided cookie string and updates the store state\n * with the cookie's token and model data.\n *\n * NB! This function doesn't validate the token or its data.\n * Usually this isn't a concern if you are interacting only with the\n * PocketBase API because it has the proper server-side security checks in place,\n * but if you are using the store `isValid` state for permission controls\n * in a node server (eg. SSR), then it is recommended to call `authRefresh()`\n * after loading the cookie to ensure an up-to-date token and model state.\n * For example:\n *\n * ```js\n * pb.authStore.loadFromCookie(\"cookie string...\");\n *\n * try {\n * // get an up-to-date auth store state by veryfing and refreshing the loaded auth model (if any)\n * pb.authStore.isValid && await pb.collection('users').authRefresh();\n * } catch (_) {\n * // clear the auth store on failed refresh\n * pb.authStore.clear();\n * }\n * ```\n */\n loadFromCookie(cookie: string, key = defaultCookieKey): void {\n const rawData = cookieParse(cookie || '')[key] || '';\n\n let data: { [key: string]: any } = {};\n try {\n data = JSON.parse(rawData);\n // normalize\n if (typeof data === null || typeof data !== 'object' || Array.isArray(data)) {\n data = {};\n }\n } catch (_) {}\n\n this.save(data.token || '', data.model || null);\n }\n\n /**\n * Exports the current store state as cookie string.\n *\n * By default the following optional attributes are added:\n * - Secure\n * - HttpOnly\n * - SameSite=Strict\n * - Path=/\n * - Expires={the token expiration date}\n *\n * NB! If the generated cookie exceeds 4096 bytes, this method will\n * strip the model data to the bare minimum to try to fit within the\n * recommended size in https://www.rfc-editor.org/rfc/rfc6265#section-6.1.\n */\n exportToCookie(options?: SerializeOptions, key = defaultCookieKey): string {\n const defaultOptions: SerializeOptions = {\n secure: true,\n sameSite: true,\n httpOnly: true,\n path: \"/\",\n };\n\n // extract the token expiration date\n const payload = getTokenPayload(this.token);\n if (payload?.exp) {\n defaultOptions.expires = new Date(payload.exp * 1000);\n } else {\n defaultOptions.expires = new Date('1970-01-01');\n }\n\n // merge with the user defined options\n options = Object.assign({}, defaultOptions, options);\n\n const rawData = {\n token: this.token,\n model: this.model ? JSON.parse(JSON.stringify(this.model)) : null,\n };\n\n let result = cookieSerialize(key, JSON.stringify(rawData), options);\n\n const resultLength = typeof Blob !== 'undefined' ?\n (new Blob([result])).size : result.length;\n\n // strip down the model data to the bare minimum\n if (rawData.model && resultLength > 4096) {\n rawData.model = {id: rawData?.model?.id, email: rawData?.model?.email};\n const extraProps = [\"collectionId\", \"username\", \"verified\"];\n for (const prop in this.model) {\n if (extraProps.includes(prop)) {\n rawData.model[prop] = this.model[prop];\n }\n }\n result = cookieSerialize(key, JSON.stringify(rawData), options);\n }\n\n return result;\n }\n\n /**\n * Register a callback function that will be called on store change.\n *\n * You can set the `fireImmediately` argument to true in order to invoke\n * the provided callback right after registration.\n *\n * Returns a removal function that you could call to \"unsubscribe\" from the changes.\n */\n onChange(callback: OnStoreChangeFunc, fireImmediately = false): () => void {\n this._onChangeCallbacks.push(callback);\n\n if (fireImmediately) {\n callback(this.token, this.model);\n }\n\n return () => {\n for (let i = this._onChangeCallbacks.length - 1; i >= 0; i--) {\n if (this._onChangeCallbacks[i] == callback) {\n delete this._onChangeCallbacks[i]; // removes the function reference\n this._onChangeCallbacks.splice(i, 1); // reindex the array\n return;\n }\n }\n }\n }\n\n protected triggerChange(): void {\n for (const callback of this._onChangeCallbacks) {\n callback && callback(this.token, this.model);\n }\n }\n}\n","import { BaseAuthStore, AuthModel } from '@/stores/BaseAuthStore';\n\n/**\n * The default token store for browsers with auto fallback\n * to runtime/memory if local storage is undefined (eg. in node env).\n */\nexport class LocalAuthStore extends BaseAuthStore {\n private storageFallback: { [key: string]: any } = {};\n private storageKey: string\n\n constructor(storageKey = \"pocketbase_auth\") {\n super();\n\n this.storageKey = storageKey;\n\n this._bindStorageEvent();\n }\n\n /**\n * @inheritdoc\n */\n get token(): string {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.token || '';\n }\n\n /**\n * @inheritdoc\n */\n get model(): AuthModel {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.model || null;\n }\n\n /**\n * @inheritdoc\n */\n save(token: string, model?: AuthModel) {\n this._storageSet(this.storageKey, {\n 'token': token,\n 'model': model,\n });\n\n super.save(token, model);\n }\n\n /**\n * @inheritdoc\n */\n clear() {\n this._storageRemove(this.storageKey);\n\n super.clear();\n }\n\n // ---------------------------------------------------------------\n // Internal helpers:\n // ---------------------------------------------------------------\n\n /**\n * Retrieves `key` from the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageGet(key: string): any {\n if (typeof window !== 'undefined' && window?.localStorage) {\n const rawValue = window.localStorage.getItem(key) || '';\n try {\n return JSON.parse(rawValue);\n } catch (e) { // not a json\n return rawValue;\n }\n }\n\n // fallback\n return this.storageFallback[key];\n }\n\n /**\n * Stores a new data in the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageSet(key: string, value: any) {\n if (typeof window !== 'undefined' && window?.localStorage) {\n // store in local storage\n let normalizedVal = value;\n if (typeof value !== 'string') {\n normalizedVal = JSON.stringify(value);\n }\n window.localStorage.setItem(key, normalizedVal);\n } else {\n // store in fallback\n this.storageFallback[key] = value;\n }\n }\n\n /**\n * Removes `key` from the browser's local storage and the runtime/memory.\n */\n private _storageRemove(key: string) {\n // delete from local storage\n if (typeof window !== 'undefined' && window?.localStorage) {\n window.localStorage?.removeItem(key);\n }\n\n // delete from fallback\n delete this.storageFallback[key];\n }\n\n /**\n * Updates the current store state on localStorage change.\n */\n private _bindStorageEvent() {\n if (typeof window === 'undefined' || !window?.localStorage || !window.addEventListener) {\n return;\n }\n\n window.addEventListener('storage', (e) => {\n if (e.key != this.storageKey) {\n return;\n }\n\n const data = this._storageGet(this.storageKey) || {};\n\n super.save(data.token || '', data.model || null);\n });\n }\n}\n","import Client from '@/Client';\n\n/**\n * BaseService class that should be inherited from all API services.\n */\nexport abstract class BaseService {\n readonly client: Client\n\n constructor(client: Client) {\n this.client = client;\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\ninterface appleClientSecret {\n secret: string;\n}\n\nexport class SettingsService extends BaseService {\n /**\n * Fetch all available app settings.\n */\n getAll(options?: CommonOptions): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Bulk updates app settings.\n */\n update(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Performs a S3 filesystem connection test.\n *\n * The currently supported `filesystem` are \"storage\" and \"backups\".\n */\n testS3(filesystem: string = \"storage\", options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'filesystem': filesystem,\n },\n }, options);\n\n return this.client.send('/api/settings/test/s3', options)\n .then(() => true);\n }\n\n /**\n * Sends a test email.\n *\n * The possible `emailTemplate` values are:\n * - verification\n * - password-reset\n * - email-change\n */\n testEmail(toEmail: string, emailTemplate: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'email': toEmail,\n 'template': emailTemplate,\n },\n }, options);\n\n return this.client.send('/api/settings/test/email', options)\n .then(() => true);\n }\n\n /**\n * Generates a new Apple OAuth2 client secret.\n */\n generateAppleClientSecret(\n clientId: string,\n teamId: string,\n keyId: string,\n privateKey: string,\n duration: number,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n clientId,\n teamId,\n keyId,\n privateKey,\n duration,\n },\n }, options);\n\n return this.client.send('/api/settings/apple/generate-client-secret', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n FullListOptions\n} from '@/services/utils/options';\n\nexport abstract class CrudService extends BaseService {\n /**\n * Base path for the crud actions (without trailing slash, eg. '/admins').\n */\n abstract get baseCrudPath(): string\n\n /**\n * Response data decoder.\n */\n decode(data: { [key: string]: any }): T {\n return data as T;\n }\n\n /**\n * Returns a promise with all list items batch fetched at once\n * (by default 500 items per request; to change it set the `batch` query param).\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getFullList(options?: FullListOptions): Promise>\n\n /**\n * Legacy version of getFullList with explicitly specified batch size.\n */\n getFullList(batch?: number, options?: ListOptions): Promise>\n\n getFullList(batchOrqueryParams?: number|FullListOptions, options?: ListOptions): Promise> {\n if (typeof batchOrqueryParams == \"number\") {\n return this._getFullList(batchOrqueryParams, options);\n }\n\n options = Object.assign({}, batchOrqueryParams, options);\n\n let batch = 500;\n if (options.batch) {\n batch = options.batch;\n delete options.batch;\n }\n\n return this._getFullList(batch, options);\n }\n\n /**\n * Returns paginated items list.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({\n method: 'GET'\n }, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => {\n responseData.items = responseData.items?.map((item: any) => {\n return this.decode(item);\n }) || [];\n\n return responseData;\n });\n }\n\n /**\n * Returns the first found item by the specified filter.\n *\n * Internally it calls `getList(1, 1, { filter, skipTotal })` and\n * returns the first found item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n *\n * For consistency with `getOne`, this method will throw a 404\n * ClientResponseError if no item was found.\n */\n getFirstListItem(filter: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'requestKey': 'one_by_filter_' + this.baseCrudPath + \"_\" + filter,\n }, options);\n\n options.query = Object.assign({\n 'filter': filter,\n 'skipTotal': 1,\n }, options.query);\n\n return this.getList(1, 1, options)\n .then((result) => {\n if (!result?.items?.length) {\n throw new ClientResponseError({\n status: 404,\n data: {\n code: 404,\n message: \"The requested resource wasn't found.\",\n data: {},\n },\n });\n }\n\n return result.items[0];\n });\n }\n\n /**\n * Returns single item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getOne(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Creates a new item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n create(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Updates an existing item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Deletes an existing item by its id.\n */\n delete(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then(() => true);\n }\n\n /**\n * Returns a promise with all list items batch fetched at once.\n */\n protected _getFullList(batchSize = 500, options?: ListOptions): Promise> {\n options = options || {};\n options.query = Object.assign({\n 'skipTotal': 1,\n }, options.query);\n\n let result: Array = [];\n\n let request = async (page: number): Promise> => {\n return this.getList(page, batchSize || 500, options).then((list) => {\n const castedList = (list as any as ListResult);\n const items = castedList.items;\n\n result = result.concat(items);\n\n if (items.length == list.perPage) {\n return request(page + 1);\n }\n\n return result;\n });\n }\n\n return request(1);\n }\n}\n","import { SendOptions } from '@/services/utils/options';\n\nexport function normalizeLegacyOptionsArgs(legacyWarn: string, baseOptions: SendOptions, bodyOrOptions?: any, query?: any): SendOptions {\n const hasBodyOrOptions = typeof bodyOrOptions !== 'undefined';\n const hasQuery = typeof query !== 'undefined';\n\n if (!hasQuery && !hasBodyOrOptions) {\n return baseOptions;\n }\n\n if (hasQuery) {\n console.warn(legacyWarn);\n baseOptions.body = Object.assign({}, baseOptions.body, bodyOrOptions);\n baseOptions.query = Object.assign({}, baseOptions.query, query);\n\n return baseOptions;\n }\n\n baseOptions = Object.assign(baseOptions, bodyOrOptions);\n return baseOptions;\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { AdminModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface AdminAuthResponse {\n [key: string]: any;\n\n token: string;\n admin: AdminModel;\n}\n\nexport class AdminService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/admins';\n }\n\n // ---------------------------------------------------------------\n // Post update/delete AuthStore sync\n // ---------------------------------------------------------------\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n // update the store state if the updated item id matches with the stored model\n if (\n this.client.authStore.model?.id === item.id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n // clear the store state if the deleted item id matches with the stored model\n if (\n success &&\n this.client.authStore.model?.id === id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful authorize response.\n */\n protected authResponse(responseData: any): AdminAuthResponse {\n const admin = this.decode(responseData?.admin || {});\n\n if (responseData?.token && responseData?.admin) {\n this.client.authStore.save(responseData.token, admin);\n }\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'admin': admin,\n });\n }\n\n /**\n * Authenticate an admin account with its email and password\n * and returns a new admin token and data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authWithPassword(email: string, password: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authWithPassword(email, password, options?).\n */\n authWithPassword(email: string, password: string, body?: any, query?: any): Promise\n\n authWithPassword(\n email: string,\n password: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': email,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(email, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(email, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-with-password', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Refreshes the current admin authenticated instance and\n * returns a new token and admin data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authRefresh(options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-refresh', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Sends admin password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/request-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Confirms admin password reset request.\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(resetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, body?: any, query?: any): Promise\n\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, bodyOrOptions?: any, query?: any): Promise{\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': resetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(resetToken, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(resetToken, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\n\ninterface promiseCallbacks {\n resolve: Function\n reject: Function\n}\n\nexport type UnsubscribeFunc = () => Promise;\n\nexport class RealtimeService extends BaseService {\n clientId: string = \"\";\n\n private eventSource: EventSource | null = null;\n private subscriptions: { [key: string]: Array } = {};\n private lastSentTopics: Array = [];\n private connectTimeoutId: any;\n private maxConnectTimeout: number = 15000;\n private reconnectTimeoutId: any;\n private reconnectAttempts: number = 0;\n private maxReconnectAttempts: number = Infinity;\n private predefinedReconnectIntervals: Array = [\n 200, 300, 500, 1000, 1200, 1500, 2000,\n ];\n private pendingConnects: Array = [];\n\n /**\n * Returns whether the realtime connection has been established.\n */\n get isConnected(): boolean {\n return !!this.eventSource && !!this.clientId && !this.pendingConnects.length;\n }\n\n /**\n * Register the subscription listener.\n *\n * You can subscribe multiple times to the same topic.\n *\n * If the SSE connection is not started yet,\n * this method will also initialize it.\n */\n async subscribe(topic: string, callback: (data: any) => void): Promise {\n if (!topic) {\n throw new Error('topic must be set.')\n }\n\n const listener = function (e: Event) {\n const msgEvent = (e as MessageEvent);\n\n let data;\n try {\n data = JSON.parse(msgEvent?.data);\n } catch {}\n\n callback(data || {});\n };\n\n // store the listener\n if (!this.subscriptions[topic]) {\n this.subscriptions[topic] = [];\n }\n this.subscriptions[topic].push(listener);\n\n if (!this.isConnected) {\n // initialize sse connection\n await this.connect();\n } else if (this.subscriptions[topic].length === 1) {\n // send the updated subscriptions (if it is the first for the topic)\n await this.submitSubscriptions();\n } else {\n // only register the listener\n this.eventSource?.addEventListener(topic, listener);\n }\n\n return async (): Promise => {\n return this.unsubscribeByTopicAndListener(topic, listener);\n };\n }\n\n /**\n * Unsubscribe from all subscription listeners with the specified topic.\n *\n * If `topic` is not provided, then this method will unsubscribe\n * from all active subscriptions.\n *\n * This method is no-op if there are no active subscriptions.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribe(topic?: string): Promise {\n if (!this.hasSubscriptionListeners(topic)) {\n return; // already unsubscribed\n }\n\n if (!topic) {\n // remove all subscriptions\n this.subscriptions = {};\n } else {\n // remove all topic listeners\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n /**\n * Unsubscribe from all subscription listeners starting with the specified topic prefix.\n *\n * This method is no-op if there are no active subscriptions with the specified topic prefix.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByPrefix(topicPrefix: string): Promise {\n let hasAtleastOneTopic = false;\n for (let topic in this.subscriptions) {\n if (!topic.startsWith(topicPrefix)) {\n continue;\n }\n\n hasAtleastOneTopic = true;\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!hasAtleastOneTopic) {\n return; // nothing to unsubscribe from\n }\n\n if (this.hasSubscriptionListeners()) {\n // submit the deleted subscriptions\n await this.submitSubscriptions();\n } else {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n }\n }\n\n /**\n * Unsubscribe from all subscriptions matching the specified topic and listener function.\n *\n * This method is no-op if there are no active subscription with\n * the specified topic and listener.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByTopicAndListener(topic: string, listener: EventListener): Promise {\n if (!Array.isArray(this.subscriptions[topic]) || !this.subscriptions[topic].length) {\n return; // already unsubscribed\n }\n\n let exist = false;\n for (let i = this.subscriptions[topic].length - 1; i >= 0; i--) {\n if (this.subscriptions[topic][i] !== listener) {\n continue;\n }\n\n exist = true; // has at least one matching listener\n delete this.subscriptions[topic][i]; // removes the function reference\n this.subscriptions[topic].splice(i, 1); // reindex the array\n this.eventSource?.removeEventListener(topic, listener);\n }\n if (!exist) {\n return;\n }\n\n // remove the topic from the subscriptions list if there are no other listeners\n if (!this.subscriptions[topic].length) {\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n private hasSubscriptionListeners(topicToCheck?: string): boolean {\n this.subscriptions = this.subscriptions || {};\n\n // check the specified topic\n if (topicToCheck) {\n return !!this.subscriptions[topicToCheck]?.length;\n }\n\n // check for at least one non-empty topic\n for (let topic in this.subscriptions) {\n if (!!this.subscriptions[topic]?.length) {\n return true\n }\n }\n\n return false;\n }\n\n private async submitSubscriptions(): Promise {\n if (!this.clientId) {\n return; // no client/subscriber\n }\n\n // optimistic update\n this.addAllSubscriptionListeners();\n\n this.lastSentTopics = this.getNonEmptySubscriptionTopics();\n\n return this.client.send('/api/realtime', {\n 'method': 'POST',\n 'body': {\n 'clientId': this.clientId,\n 'subscriptions': this.lastSentTopics,\n },\n 'query': {\n 'requestKey': this.getSubscriptionsCancelKey(),\n },\n }).catch((err) => {\n if (err?.isAbort) {\n return; // silently ignore aborted pending requests\n }\n throw err;\n });\n }\n\n private getSubscriptionsCancelKey(): string {\n return \"realtime_\" + this.clientId;\n }\n\n private getNonEmptySubscriptionTopics(): Array {\n const result : Array = [];\n\n for (let topic in this.subscriptions) {\n if (this.subscriptions[topic].length) {\n result.push(topic);\n }\n }\n\n return result;\n }\n\n private addAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n this.removeAllSubscriptionListeners();\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.addEventListener(topic, listener);\n }\n }\n }\n\n private removeAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.removeEventListener(topic, listener);\n }\n }\n }\n\n private async connect(): Promise {\n if (this.reconnectAttempts > 0) {\n // immediately resolve the promise to avoid indefinitely\n // blocking the client during reconnection\n return;\n }\n\n return new Promise((resolve, reject) => {\n this.pendingConnects.push({ resolve, reject });\n\n if (this.pendingConnects.length > 1) {\n // all promises will be resolved once the connection is established\n return;\n }\n\n this.initConnect();\n })\n }\n\n private initConnect() {\n this.disconnect(true);\n\n // wait up to 15s for connect\n clearTimeout(this.connectTimeoutId);\n this.connectTimeoutId = setTimeout(() => {\n this.connectErrorHandler(new Error(\"EventSource connect took too long.\"));\n }, this.maxConnectTimeout);\n\n this.eventSource = new EventSource(this.client.buildUrl('/api/realtime'))\n\n this.eventSource.onerror = (_) => {\n this.connectErrorHandler(new Error(\"Failed to establish realtime connection.\"));\n };\n\n this.eventSource.addEventListener('PB_CONNECT', (e) => {\n const msgEvent = (e as MessageEvent);\n this.clientId = msgEvent?.lastEventId;\n\n this.submitSubscriptions()\n .then(async () => {\n let retries = 3;\n while (this.hasUnsentSubscriptions() && retries > 0) {\n retries--;\n // resubscribe to ensure that the latest topics are submitted\n //\n // This is needed because missed topics could happen on reconnect\n // if after the pending sent `submitSubscriptions()` call another `subscribe()`\n // was made before the submit was able to complete.\n await this.submitSubscriptions();\n }\n }).then(() => {\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n\n // reset connect meta\n this.pendingConnects = [];\n this.reconnectAttempts = 0;\n clearTimeout(this.reconnectTimeoutId);\n clearTimeout(this.connectTimeoutId);\n }).catch((err) => {\n this.clientId = \"\";\n this.connectErrorHandler(err);\n });\n });\n }\n\n private hasUnsentSubscriptions(): boolean {\n const latestTopics = this.getNonEmptySubscriptionTopics();\n if (latestTopics.length != this.lastSentTopics.length) {\n return true;\n }\n\n for (const t of latestTopics) {\n if (!this.lastSentTopics.includes(t)) {\n return true;\n }\n }\n\n return false;\n }\n\n private connectErrorHandler(err: any) {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n\n if (\n // wasn't previously connected -> direct reject\n (!this.clientId && !this.reconnectAttempts) ||\n // was previously connected but the max reconnection limit has been reached\n this.reconnectAttempts > this.maxReconnectAttempts\n ) {\n for (let p of this.pendingConnects) {\n p.reject(new ClientResponseError(err));\n }\n this.pendingConnects = [];\n this.disconnect();\n return;\n }\n\n // otherwise -> reconnect in the background\n this.disconnect(true);\n const timeout = this.predefinedReconnectIntervals[this.reconnectAttempts] || this.predefinedReconnectIntervals[this.predefinedReconnectIntervals.length - 1];\n this.reconnectAttempts++;\n this.reconnectTimeoutId = setTimeout(() => {\n this.initConnect();\n }, timeout);\n }\n\n private disconnect(fromReconnect = false): void {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n this.removeAllSubscriptionListeners();\n this.client.cancelRequest(this.getSubscriptionsCancelKey());\n this.eventSource?.close();\n this.eventSource = null;\n this.clientId = \"\";\n\n if (!fromReconnect) {\n this.reconnectAttempts = 0;\n\n // resolve any remaining connect promises\n //\n // this is done to avoid unnecessary throwing errors in case\n // unsubscribe is called before the pending connect promises complete\n // (see https://github.com/pocketbase/pocketbase/discussions/2897#discussioncomment-6423818)\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n this.pendingConnects = [];\n }\n }\n}\n","import Client from '@/Client';\nimport { CrudService } from '@/services/utils/CrudService';\nimport { RealtimeService, UnsubscribeFunc } from '@/services/RealtimeService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult, RecordModel, ExternalAuthModel } from '@/services/utils/dtos';\nimport {\n SendOptions,\n CommonOptions,\n RecordOptions,\n RecordListOptions,\n RecordFullListOptions,\n} from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface RecordAuthResponse {\n // The signed PocketBase auth record.\n record: T;\n\n // The PocketBase record auth token.\n //\n // If you are looking for the OAuth2 access and refresh tokens\n // they are available under the `meta.accessToken` and `meta.refreshToken` props.\n token: string;\n\n // Auth meta data usually filled when OAuth2 is used.\n meta?: {[key: string]: any};\n}\n\nexport interface AuthProviderInfo {\n name: string;\n state: string;\n codeVerifier: string;\n codeChallenge: string;\n codeChallengeMethod: string;\n authUrl: string;\n}\n\nexport interface AuthMethodsList {\n usernamePassword: boolean;\n emailPassword: boolean;\n authProviders: Array;\n}\n\nexport interface RecordSubscription {\n action: string; // eg. create, update, delete\n record: T;\n}\n\nexport type OAuth2UrlCallback = (url: string) => void|Promise;\n\nexport interface OAuth2AuthConfig extends SendOptions {\n // the name of the OAuth2 provider (eg. \"google\")\n provider: string;\n\n // custom scopes to overwrite the default ones\n scopes?: Array;\n\n // optional record create data\n createData?: {[key: string]: any};\n\n // optional callback that is triggered after the OAuth2 sign-in/sign-up url generation\n urlCallback?: OAuth2UrlCallback;\n\n // optional query params to send with the PocketBase auth request (eg. fields, expand, etc.)\n query?: RecordOptions;\n}\n\nexport class RecordService extends CrudService {\n readonly collectionIdOrName: string;\n\n constructor(client: Client, collectionIdOrName: string) {\n super(client);\n\n this.collectionIdOrName = collectionIdOrName;\n }\n\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return this.baseCollectionPath + '/records';\n }\n\n /**\n * Returns the current collection service base path.\n */\n get baseCollectionPath(): string {\n return '/api/collections/' + encodeURIComponent(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Realtime handlers\n // ---------------------------------------------------------------\n\n /**\n * @deprecated Use subscribe(recordId, callback) instead.\n *\n * Subscribe to the realtime changes of a single record in the collection.\n */\n async subscribeOne(recordId: string, callback: (data: RecordSubscription) => void): Promise {\n console.warn(\"PocketBase: subscribeOne(recordId, callback) is deprecated. Please replace it with subscribe(recordId, callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName + \"/\" + recordId, callback);\n }\n\n /**\n * @deprecated This form of subscribe is deprecated. Please use `subscribe(\"*\", callback)`.\n */\n async subscribe(callback: (data: RecordSubscription) => void): Promise\n\n /**\n * Subscribe to realtime changes to the specified topic (\"*\" or record id).\n *\n * If `topic` is the wildcard \"*\", then this method will subscribe to\n * any record changes in the collection.\n *\n * If `topic` is a record id, then this method will subscribe only\n * to changes of the specified record id.\n *\n * It's OK to subscribe multiple times to the same topic.\n * You can use the returned `UnsubscribeFunc` to remove only a single subscription.\n * Or use `unsubscribe(topic)` if you want to remove all subscriptions attached to the topic.\n */\n async subscribe(topic: string, callback: (data: RecordSubscription) => void): Promise\n\n async subscribe(\n topicOrCallback: string|((data: RecordSubscription) => void),\n callback?: (data: RecordSubscription) => void\n ): Promise {\n if (typeof topicOrCallback === 'function') {\n console.warn(\"PocketBase: subscribe(callback) is deprecated. Please replace it with subscribe('*', callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName, topicOrCallback);\n }\n\n if (!callback) {\n throw new Error(\"Missing subscription callback.\");\n }\n\n if (topicOrCallback === \"\") {\n throw new Error(\"Missing topic.\");\n }\n\n let topic = this.collectionIdOrName;\n if (topicOrCallback !== \"*\") {\n topic += ('/' + topicOrCallback);\n }\n\n return this.client.realtime.subscribe(topic, callback)\n }\n\n /**\n * Unsubscribe from all subscriptions of the specified topic\n * (\"*\" or record id).\n *\n * If `topic` is not set, then this method will unsubscribe from\n * all subscriptions associated to the current collection.\n */\n async unsubscribe(topic?: string): Promise {\n // unsubscribe wildcard topic\n if (topic === \"*\") {\n return this.client.realtime.unsubscribe(this.collectionIdOrName);\n }\n\n // unsubscribe recordId topic\n if (topic) {\n return this.client.realtime.unsubscribe(this.collectionIdOrName + \"/\" + topic);\n }\n\n // unsubscribe from everything related to the collection\n return this.client.realtime.unsubscribeByPrefix(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Crud handers\n // ---------------------------------------------------------------\n /**\n * @inheritdoc\n */\n getFullList(options?: RecordFullListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batch?: number, options?: RecordListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batchOrOptions?: number|RecordFullListOptions, options?: RecordListOptions): Promise> {\n if (typeof batchOrOptions == \"number\") {\n return super.getFullList(batchOrOptions, options);\n }\n\n const params = Object.assign({}, batchOrOptions, options);\n\n return super.getFullList(params);\n }\n\n /**\n * @inheritdoc\n */\n getList(page = 1, perPage = 30, options?: RecordListOptions): Promise> {\n return super.getList(page, perPage, options);\n }\n\n /**\n * @inheritdoc\n */\n getFirstListItem(filter: string, options?: RecordListOptions): Promise {\n return super.getFirstListItem(filter, options);\n }\n\n /**\n * @inheritdoc\n */\n getOne(id: string, options?: RecordOptions): Promise {\n return super.getOne(id, options);\n }\n\n /**\n * @inheritdoc\n */\n create(bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.create(bodyParams, options);\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(id: string, bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n if (\n // is record auth\n this.client.authStore.model?.id === item?.id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n if (\n success &&\n // is record auth\n this.client.authStore.model?.id === id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful collection authorization response.\n */\n protected authResponse(responseData: any): RecordAuthResponse {\n const record = this.decode(responseData?.record || {});\n\n this.client.authStore.save(responseData?.token, record);\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'record': record as any as T,\n });\n }\n\n /**\n * Returns all available collection auth methods.\n */\n listAuthMethods(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCollectionPath + '/auth-methods', options)\n .then((responseData: any) => {\n return Object.assign({}, responseData, {\n // normalize common fields\n 'usernamePassword': !!responseData?.usernamePassword,\n 'emailPassword': !!responseData?.emailPassword,\n 'authProviders': Array.isArray(responseData?.authProviders) ? responseData?.authProviders : [],\n });\n });\n }\n\n /**\n * Authenticate a single auth collection record via its username/email and password.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n */\n authWithPassword(usernameOrEmail: string, password: string, options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authWithPassword(usernameOrEmail, password, options?).\n */\n authWithPassword(usernameOrEmail: string, password: string, body?: any, query?: any): Promise>\n\n authWithPassword(usernameOrEmail: string, password: string, bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': usernameOrEmail,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(usernameOrEmail, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(usernameOrEmail, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-password', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Authenticate a single auth collection record with OAuth2 code.\n *\n * If you don't have an OAuth2 code you may also want to check `authWithOAuth2` method.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n options?: RecordOptions,\n ): Promise>\n\n /**\n * @deprecated\n * Consider using authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createdData, options?).\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n body?: any,\n query?: any\n ): Promise>\n\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n bodyOrOptions?: any,\n query?: any\n ): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'provider': provider,\n 'code': code,\n 'codeVerifier': codeVerifier,\n 'redirectUrl': redirectUrl,\n 'createData': createData,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, body?, query?) is deprecated. Consider replacing it with authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-oauth2', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * @deprecated This form of authWithOAuth2 is deprecated.\n *\n * Please use `authWithOAuth2Code()` OR its simplified realtime version\n * as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\n */\n async authWithOAuth2(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key: string]: any},\n bodyParams?: {[key: string]: any},\n queryParams?: RecordOptions,\n ): Promise>\n\n /**\n * Authenticate a single auth collection record with OAuth2\n * **without custom redirects, deeplinks or even page reload**.\n *\n * This method initializes a one-off realtime subscription and will\n * open a popup window with the OAuth2 vendor page to authenticate.\n * Once the external OAuth2 sign-in/sign-up flow is completed, the popup\n * window will be automatically closed and the OAuth2 data sent back\n * to the user through the previously established realtime connection.\n *\n * You can specify an optional `urlCallback` prop to customize\n * the default url `window.open` behavior.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n *\n * Example:\n *\n * ```js\n * const authData = await pb.collection(\"users\").authWithOAuth2({\n * provider: \"google\",\n * })\n * ```\n *\n * _Site-note_: when creating the OAuth2 app in the provider dashboard\n * you have to configure `https://yourdomain.com/api/oauth2-redirect`\n * as redirect URL.\n */\n async authWithOAuth2(options: OAuth2AuthConfig): Promise>\n\n async authWithOAuth2(...args: any): Promise> {\n // fallback to legacy format\n if (args.length > 1 || typeof args?.[0] === 'string') {\n console.warn(\"PocketBase: This form of authWithOAuth2() is deprecated and may get removed in the future. Please replace with authWithOAuth2Code() OR use the authWithOAuth2() realtime form as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\");\n return this.authWithOAuth2Code(\n args?.[0] || '',\n args?.[1] || '',\n args?.[2] || '',\n args?.[3] || '',\n args?.[4] || {},\n args?.[5] || {},\n args?.[6] || {},\n );\n }\n\n const config = args?.[0] || {};\n\n const authMethods = await this.listAuthMethods();\n\n const provider = authMethods.authProviders.find((p) => p.name === config.provider);\n if (!provider) {\n throw new ClientResponseError(new Error(`Missing or invalid provider \"${config.provider}\".`));\n }\n\n const redirectUrl = this.client.buildUrl('/api/oauth2-redirect');\n\n // initialize a one-off realtime service\n const realtime = new RealtimeService(this.client);\n\n // open a new popup window in case config.urlCallback is not set\n //\n // note: it is opened before the async call due to Safari restrictions\n // (see https://github.com/pocketbase/pocketbase/discussions/2429#discussioncomment-5943061)\n let eagerDefaultPopup: Window|null = null;\n if (!config.urlCallback) {\n eagerDefaultPopup = openBrowserPopup(undefined);\n }\n\n function cleanup() {\n eagerDefaultPopup?.close();\n realtime.unsubscribe();\n }\n\n return new Promise(async (resolve, reject) => {\n try {\n await realtime.subscribe('@oauth2', async (e) => {\n const oldState = realtime.clientId;\n\n try {\n if (!e.state || oldState !== e.state) {\n throw new Error(\"State parameters don't match.\");\n }\n\n // clear the non SendOptions props\n const options = Object.assign({}, config);\n delete options.provider;\n delete options.scopes;\n delete options.createData;\n delete options.urlCallback;\n\n const authData = await this.authWithOAuth2Code(\n provider.name,\n e.code,\n provider.codeVerifier,\n redirectUrl,\n config.createData,\n options,\n );\n\n resolve(authData);\n } catch (err) {\n reject(new ClientResponseError(err));\n }\n\n cleanup();\n });\n\n const replacements: {[key: string]: any} = {\n \"state\": realtime.clientId,\n }\n if (config.scopes?.length) {\n replacements[\"scope\"] = config.scopes.join(\" \");\n }\n\n const url = this._replaceQueryParams(provider.authUrl + redirectUrl, replacements);\n\n let urlCallback = config.urlCallback || function (url: string) {\n if (eagerDefaultPopup) {\n eagerDefaultPopup.location.href = url;\n } else {\n // it could have been blocked due to its empty initial url,\n // try again...\n eagerDefaultPopup = openBrowserPopup(url);\n }\n }\n\n await urlCallback(url);\n } catch (err) {\n cleanup();\n reject(new ClientResponseError(err));\n }\n });\n }\n\n /**\n * Refreshes the current authenticated record instance and\n * returns a new token and record data.\n *\n * On success this method also automatically updates the client's AuthStore.\n */\n authRefresh(options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise>\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-refresh', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Sends auth record password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-password-reset', options).then(() => true);\n }\n\n /**\n * Confirms auth record password reset request.\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n options?: CommonOptions,\n ): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(passwordResetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n body?: any,\n query?: any,\n ): Promise\n\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': passwordResetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(token, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(token, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Sends auth record verification email request.\n */\n requestVerification(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestVerification(email, options?).\n */\n requestVerification(email: string, body?: any, query?: any): Promise\n\n requestVerification(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestVerification(email, body?, query?) is deprecated. Consider replacing it with requestVerification(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-verification', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record email verification request.\n */\n confirmVerification(verificationToken: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmVerification(verificationToken, options?).\n */\n confirmVerification(verificationToken: string, body?: any, query?: any): Promise\n\n confirmVerification(verificationToken: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': verificationToken,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmVerification(token, body?, query?) is deprecated. Consider replacing it with confirmVerification(token, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-verification', options)\n .then(() => true);\n }\n\n /**\n * Sends an email change request to the authenticated record model.\n */\n requestEmailChange(newEmail: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestEmailChange(newEmail, options?).\n */\n requestEmailChange(newEmail: string, body?: any, query?: any): Promise\n\n requestEmailChange(newEmail: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'newEmail': newEmail,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestEmailChange(newEmail, body?, query?) is deprecated. Consider replacing it with requestEmailChange(newEmail, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-email-change', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record's new email address.\n */\n confirmEmailChange(emailChangeToken: string, password: string, options?: CommonOptions): Promise\n\n\n /**\n * @deprecated\n * Consider using confirmEmailChange(emailChangeToken, password, options?).\n */\n confirmEmailChange(emailChangeToken: string, password: string, body?: any, query?: any): Promise\n\n confirmEmailChange(emailChangeToken: string, password: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': emailChangeToken,\n 'password': password,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmEmailChange(token, password, body?, query?) is deprecated. Consider replacing it with confirmEmailChange(token, password, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-email-change', options)\n .then(() => true);\n }\n\n /**\n * Lists all linked external auth providers for the specified auth record.\n */\n listExternalAuths(recordId: string, options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths', options);\n }\n\n /**\n * Unlink a single external auth provider from the specified auth record.\n */\n unlinkExternalAuth(recordId: string, provider: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths/' + encodeURIComponent(provider), options)\n .then(() => true);\n }\n\n // ---------------------------------------------------------------\n\n // very rudimentary url query params replacement because at the moment\n // URL (and URLSearchParams) doesn't seem to be fully supported in React Native\n //\n // note: for details behind some of the decode/encode parsing check https://unixpapa.com/js/querystring.html\n private _replaceQueryParams(url: string, replacements: {[key: string]: any} = {}): string {\n let urlPath = url\n let query = \"\";\n\n const queryIndex = url.indexOf(\"?\");\n if (queryIndex >= 0) {\n urlPath = url.substring(0, url.indexOf(\"?\"));\n query = url.substring(url.indexOf(\"?\") + 1);\n }\n\n const parsedParams: {[key: string]: string} = {};\n\n // parse the query parameters\n const rawParams = query.split(\"&\");\n for (const param of rawParams) {\n if (param == \"\") {\n continue\n }\n\n const pair = param.split(\"=\");\n parsedParams[decodeURIComponent(pair[0].replace(/\\+/g,' '))] = decodeURIComponent((pair[1] || \"\").replace(/\\+/g,' '));\n }\n\n // apply the replacements\n for (let key in replacements) {\n if (!replacements.hasOwnProperty(key)) {\n continue;\n }\n\n if (replacements[key] == null) {\n delete parsedParams[key];\n } else {\n parsedParams[key] = replacements[key];\n }\n }\n\n // construct back the full query string\n query = \"\";\n for (let key in parsedParams) {\n if (!parsedParams.hasOwnProperty(key)) {\n continue;\n }\n\n if (query != \"\") {\n query += \"&\";\n }\n\n query += encodeURIComponent(key.replace(/%20/g,'+')) + \"=\" + encodeURIComponent(parsedParams[key].replace(/%20/g,'+'));\n }\n\n return query != \"\" ? (urlPath + \"?\" + query) : urlPath;\n }\n}\n\nfunction openBrowserPopup(url?: string): Window|null {\n if (typeof window === \"undefined\" || !window?.open) {\n throw new ClientResponseError(new Error(`Not in a browser context - please pass a custom urlCallback function.`));\n }\n\n let width = 1024;\n let height = 768;\n\n let windowWidth = window.innerWidth;\n let windowHeight = window.innerHeight;\n\n // normalize window size\n width = width > windowWidth ? windowWidth : width;\n height = height > windowHeight ? windowHeight : height;\n\n let left = (windowWidth / 2) - (width / 2);\n let top = (windowHeight / 2) - (height / 2);\n\n // note: we don't use the noopener and noreferrer attributes since\n // for some reason browser blocks such windows then url is undefined/blank\n return window.open(\n url,\n 'popup_window',\n 'width='+width+',height='+height+',top='+top+',left='+left+',resizable,menubar=no'\n );\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { CollectionModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport class CollectionService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/collections';\n }\n\n /**\n * Imports the provided collections.\n *\n * If `deleteMissing` is `true`, all local collections and schema fields,\n * that are not present in the imported configuration, WILL BE DELETED\n * (including their related records data)!\n */\n async import(\n collections: Array,\n deleteMissing: boolean = false,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PUT',\n 'body': {\n 'collections': collections,\n 'deleteMissing': deleteMissing,\n }\n }, options);\n\n return this.client.send(this.baseCrudPath + '/import', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ListResult, LogRequestModel } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n LogStatsOptions,\n} from '@/services/utils/options';\n\nexport interface HourlyStats {\n total: number;\n date: string;\n}\n\nexport class LogService extends BaseService {\n /**\n * Returns paginated logged requests list.\n */\n getRequestsList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({'method': 'GET'}, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send('/api/logs/requests', options);\n }\n\n /**\n * Returns a single logged request by its id.\n */\n getRequest(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/' + encodeURIComponent(id), options);\n }\n\n /**\n * Returns request logs statistics.\n */\n getRequestsStats(options?: LogStatsOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/stats', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface HealthCheckResponse {\n code: number;\n message: string;\n data: {[key: string]: any};\n}\n\nexport class HealthService extends BaseService {\n /**\n * Checks the health status of the api.\n */\n check(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/health', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions, FileOptions } from '@/services/utils/options';\n\nexport class FileService extends BaseService {\n /**\n * Builds and returns an absolute record file url for the provided filename.\n */\n getUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n if (\n !filename ||\n !record?.id ||\n !(record?.collectionId || record?.collectionName)\n ) {\n return '';\n }\n\n const parts = [];\n parts.push('api')\n parts.push('files')\n parts.push(encodeURIComponent(record.collectionId || record.collectionName))\n parts.push(encodeURIComponent(record.id))\n parts.push(encodeURIComponent(filename))\n\n let result = this.client.buildUrl(parts.join('/'));\n\n if (Object.keys(queryParams).length) {\n // normalize the download query param for consistency with the Dart sdk\n if (queryParams.download === false) {\n delete(queryParams.download);\n }\n\n const params = new URLSearchParams(queryParams);\n\n result += (result.includes('?') ? '&' : '?') + params;\n }\n\n return result\n }\n\n /**\n * Requests a new private file access token for the current auth model (admin or record).\n */\n getToken(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send('/api/files/token', options)\n .then((data) => data?.token || '');\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface BackupFileInfo {\n key: string;\n size: number;\n modified: string;\n}\n\nexport class BackupService extends BaseService {\n /**\n * Returns list with all available backup files.\n */\n getFullList(options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/backups', options);\n }\n\n /**\n * Initializes a new backup.\n */\n create(basename: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'name': basename,\n },\n }, options);\n\n return this.client.send('/api/backups', options)\n .then(() => true);\n }\n\n /**\n * Deletes a single backup file.\n */\n delete(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}`, options)\n .then(() => true);\n }\n\n /**\n * Initializes an app data restore from an existing backup.\n */\n restore(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}/restore`, options)\n .then(() => true);\n }\n\n /**\n * Builds a download url for a single existing backup using an\n * admin file token and the backup file key.\n *\n * The file token can be generated via `pb.files.getToken()`.\n */\n getDownloadUrl(token: string, key: string): string {\n return this.client.buildUrl(`/api/backups/${encodeURIComponent(key)}?token=${encodeURIComponent(token)}`);\n }\n}\n","import { ClientResponseError } from '@/ClientResponseError';\nimport { BaseAuthStore } from '@/stores/BaseAuthStore';\nimport { LocalAuthStore } from '@/stores/LocalAuthStore';\nimport { SettingsService } from '@/services/SettingsService';\nimport { AdminService } from '@/services/AdminService';\nimport { RecordService } from '@/services/RecordService';\nimport { CollectionService } from '@/services/CollectionService';\nimport { LogService } from '@/services/LogService';\nimport { RealtimeService } from '@/services/RealtimeService';\nimport { HealthService } from '@/services/HealthService';\nimport { FileService } from '@/services/FileService';\nimport { BackupService } from '@/services/BackupService';\nimport { SendOptions, FileOptions } from '@/services/utils/options';\n\n// list of known SendOptions keys (everything else is treated as query param)\nconst knownSendOptionsKeys = [\n 'requestKey',\n '$cancelKey',\n '$autoCancel',\n 'fetch',\n 'headers',\n 'body',\n 'query',\n 'params',\n // ---,\n 'cache',\n 'credentials',\n 'headers',\n 'integrity',\n 'keepalive',\n 'method',\n 'mode',\n 'redirect',\n 'referrer',\n 'referrerPolicy',\n 'signal',\n 'window',\n];\n\nexport interface BeforeSendResult {\n [key: string]: any, // for backward compatibility\n url?: string,\n options?: {[key: string]: any}\n}\n\n/**\n * PocketBase JS Client.\n */\nexport default class Client {\n /**\n * The base PocketBase backend url address (eg. 'http://127.0.0.1.8090').\n */\n baseUrl: string;\n\n /**\n * Hook that get triggered right before sending the fetch request,\n * allowing you to inspect and modify the url and request options.\n *\n * For list of the possible options check https://developer.mozilla.org/en-US/docs/Web/API/fetch#options\n *\n * You can return a non-empty result object `{ url, options }` to replace the url and request options entirely.\n *\n * Example:\n * ```js\n * client.beforeSend = function (url, options) {\n * options.headers = Object.assign({}, options.headers, {\n * 'X-Custom-Header': 'example',\n * });\n *\n * return { url, options }\n * };\n * ```\n */\n beforeSend?: (url: string, options: SendOptions) => BeforeSendResult|Promise;\n\n /**\n * Hook that get triggered after successfully sending the fetch request,\n * allowing you to inspect/modify the response object and its parsed data.\n *\n * Returns the new Promise resolved `data` that will be returned to the client.\n *\n * Example:\n * ```js\n * client.afterSend = function (response, data) {\n * if (response.status != 200) {\n * throw new ClientResponseError({\n * url: response.url,\n * status: response.status,\n * data: data,\n * });\n * }\n *\n * return data;\n * };\n * ```\n */\n afterSend?: (response: Response, data: any) => any;\n\n /**\n * Optional language code (default to `en-US`) that will be sent\n * with the requests to the server as `Accept-Language` header.\n */\n lang: string;\n\n /**\n * A replaceable instance of the local auth store service.\n */\n authStore: BaseAuthStore;\n\n /**\n * An instance of the service that handles the **Settings APIs**.\n */\n readonly settings: SettingsService;\n\n /**\n * An instance of the service that handles the **Admin APIs**.\n */\n readonly admins: AdminService;\n\n /**\n * An instance of the service that handles the **Collection APIs**.\n */\n readonly collections: CollectionService;\n\n /**\n * An instance of the service that handles the **File APIs**.\n */\n readonly files: FileService;\n\n /**\n * An instance of the service that handles the **Log APIs**.\n */\n readonly logs: LogService;\n\n /**\n * An instance of the service that handles the **Realtime APIs**.\n */\n readonly realtime: RealtimeService;\n\n /**\n * An instance of the service that handles the **Health APIs**.\n */\n readonly health: HealthService;\n\n /**\n * An instance of the service that handles the **Backup APIs**.\n */\n readonly backups: BackupService;\n\n private cancelControllers: { [key: string]: AbortController } = {};\n private recordServices: { [key: string]: RecordService } = {};\n private enableAutoCancellation: boolean = true;\n\n constructor(\n baseUrl = '/',\n authStore?: BaseAuthStore | null,\n lang = 'en-US',\n ) {\n this.baseUrl = baseUrl;\n this.lang = lang;\n this.authStore = authStore || new LocalAuthStore();\n\n // services\n this.admins = new AdminService(this);\n this.collections = new CollectionService(this);\n this.files = new FileService(this);\n this.logs = new LogService(this);\n this.settings = new SettingsService(this);\n this.realtime = new RealtimeService(this);\n this.health = new HealthService(this);\n this.backups = new BackupService(this);\n }\n\n /**\n * Returns the RecordService associated to the specified collection.\n *\n * @param {string} idOrName\n * @return {RecordService}\n */\n collection(idOrName: string): RecordService {\n if (!this.recordServices[idOrName]) {\n this.recordServices[idOrName] = new RecordService(this, idOrName);\n }\n\n return this.recordServices[idOrName];\n }\n\n /**\n * Globally enable or disable auto cancellation for pending duplicated requests.\n */\n autoCancellation(enable: boolean): Client {\n this.enableAutoCancellation = !!enable;\n\n return this;\n }\n\n /**\n * Cancels single request by its cancellation key.\n */\n cancelRequest(requestKey: string): Client {\n if (this.cancelControllers[requestKey]) {\n this.cancelControllers[requestKey].abort();\n delete this.cancelControllers[requestKey];\n }\n\n return this;\n }\n\n /**\n * Cancels all pending requests.\n */\n cancelAllRequests(): Client {\n for (let k in this.cancelControllers) {\n this.cancelControllers[k].abort();\n }\n\n this.cancelControllers = {};\n\n return this;\n }\n\n /**\n * Legacy alias of `pb.files.getUrl()`.\n */\n getFileUrl(\n record: Pick<{[key:string]:any}, 'id' | 'collectionId' | 'collectionName'>,\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n return this.files.getUrl(record, filename, queryParams);\n }\n\n /**\n * Builds a full client url by safely concatenating the provided path.\n */\n buildUrl(path: string): string {\n let url = this.baseUrl;\n\n // construct an absolute base url if in a browser environment\n if (\n typeof window !== 'undefined' &&\n !!window.location &&\n !url.startsWith('https://') &&\n !url.startsWith('http://')\n ) {\n url = window.location.origin?.endsWith('/') ?\n window.location.origin.substring(0, window.location.origin.length - 1) :\n (window.location.origin || '');\n\n if (!this.baseUrl.startsWith('/')) {\n url += window.location.pathname || '/';\n url += url.endsWith('/') ? '' : '/';\n }\n\n url += this.baseUrl;\n }\n\n // concatenate the path\n if (path) {\n url += url.endsWith('/') ? '' : '/'; // append trailing slash if missing\n url += path.startsWith('/') ? path.substring(1) : path;\n }\n\n return url;\n }\n\n /**\n * Sends an api http request.\n */\n async send(path: string, options: SendOptions): Promise {\n options = this.initSendOptions(path, options);\n\n // build url + path\n let url = this.buildUrl(path);\n\n // serialize the query parameters\n if (typeof options.query !== 'undefined') {\n const query = this.serializeQueryParams(options.query)\n if (query) {\n url += (url.includes('?') ? '&' : '?') + query;\n }\n delete options.query;\n }\n\n if (this.beforeSend) {\n const result = Object.assign({}, await this.beforeSend(url, options));\n if (typeof result.url !== 'undefined' || typeof result.options !== 'undefined') {\n url = result.url || url;\n options = result.options || options;\n } else if (Object.keys(result).length) {\n // legacy behavior\n options = result as SendOptions;\n console?.warn && console.warn('Deprecated format of beforeSend return: please use `return { url, options }`, instead of `return options`.');\n }\n }\n\n // ensures that the json body is serialized\n if (\n this.getHeader(options.headers, 'Content-Type') == 'application/json' &&\n options.body && typeof options.body !== 'string'\n ) {\n options.body = JSON.stringify(options.body);\n }\n\n const fetchFunc = options.fetch || fetch;\n\n // send the request\n return fetchFunc(url, options)\n .then(async (response) => {\n let data : any = {};\n\n try {\n data = await response.json();\n } catch (_) {\n // all api responses are expected to return json\n // with the exception of the realtime event and 204\n }\n\n if (this.afterSend) {\n data = await this.afterSend(response, data);\n }\n\n if (response.status >= 400) {\n throw new ClientResponseError({\n url: response.url,\n status: response.status,\n data: data,\n });\n }\n\n return data as T;\n }).catch((err) => {\n // wrap to normalize all errors\n throw new ClientResponseError(err);\n });\n }\n\n /**\n * Shallow copy the provided object and takes care to initialize\n * any options required to preserve the backward compatability.\n *\n * @param {SendOptions} options\n * @return {SendOptions}\n */\n private initSendOptions(path: string, options: SendOptions): SendOptions {\n options = Object.assign({ method: 'GET' } as SendOptions, options)\n options.query = options.query || {};\n\n // auto convert the body to FormData, if needed\n options.body = this.convertToFormDataIfNeeded(options.body);\n\n // move unknown send options as query parameters\n for (let key in options) {\n if (knownSendOptionsKeys.includes(key)) {\n continue\n }\n\n options.query[key] = options[key];\n delete (options[key]);\n }\n\n // requestKey normalizations for backward-compatibility\n // ---\n options.query = Object.assign({}, options.params, options.query);\n if (typeof options.requestKey === 'undefined') {\n if (options.$autoCancel === false || options.query.$autoCancel === false) {\n options.requestKey = null;\n } else if (options.$cancelKey || options.query.$cancelKey) {\n options.requestKey = options.$cancelKey || options.query.$cancelKey;\n }\n }\n // remove the deprecated special cancellation params from the other query params\n delete options.$autoCancel;\n delete options.query.$autoCancel;\n delete options.$cancelKey;\n delete options.query.$cancelKey;\n // ---\n\n // add the json header, if not explicitly set\n // (for FormData body the Content-Type header should be skipped since the boundary is autogenerated)\n if (\n this.getHeader(options.headers, 'Content-Type') === null &&\n !this.isFormData(options.body)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Content-Type': 'application/json',\n });\n }\n\n // add Accept-Language header, if not explicitly set\n if (this.getHeader(options.headers, 'Accept-Language') === null) {\n options.headers = Object.assign({}, options.headers, {\n 'Accept-Language': this.lang,\n });\n }\n\n // check if Authorization header can be added\n if (\n // has valid token\n this.authStore.token &&\n // auth header is not explicitly set\n (this.getHeader(options.headers, 'Authorization') === null)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Authorization': this.authStore.token,\n });\n }\n\n // handle auto cancelation for duplicated pending request\n if (this.enableAutoCancellation && options.requestKey !== null) {\n const requestKey = options.requestKey || ((options.method || 'GET') + path);\n\n delete options.requestKey;\n\n // cancel previous pending requests\n this.cancelRequest(requestKey);\n\n const controller = new AbortController();\n this.cancelControllers[requestKey] = controller;\n options.signal = controller.signal;\n }\n\n return options\n }\n\n /**\n * Converts analyzes the provided body and converts it to FormData\n * in case a plain object with File/Blob values is used.\n */\n private convertToFormDataIfNeeded(body: any): any {\n if (\n typeof FormData === 'undefined' ||\n typeof body === \"undefined\" ||\n typeof body !== \"object\" ||\n body === null ||\n this.isFormData(body) ||\n !this.hasBlobField(body)\n ) {\n return body;\n }\n\n const form = new FormData();\n\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let val of values) {\n form.append(key, val);\n }\n }\n\n return form;\n }\n\n /**\n * Checks if the submitted body object has at least one Blob/File field.\n */\n private hasBlobField(body: {[key:string]: any}): boolean {\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let v of values) {\n if (\n (typeof Blob !== 'undefined' && v instanceof Blob) ||\n (typeof File !== 'undefined' && v instanceof File)\n ) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /**\n * Extracts the header with the provided name in case-insensitive manner.\n * Returns `null` if no header matching the name is found.\n */\n private getHeader(headers: {[key:string]:string}|undefined, name: string): string|null {\n headers = headers || {};\n name = name.toLowerCase();\n\n for (let key in headers) {\n if (key.toLowerCase() == name) {\n return headers[key];\n }\n }\n\n return null;\n }\n\n /**\n * Loosely checks if the specified body is a FormData instance.\n */\n private isFormData(body: any): boolean {\n return body && (\n // we are checking the constructor name because FormData\n // is not available natively in some environments and the\n // polyfill(s) may not be globally accessible\n body.constructor.name === 'FormData' ||\n // fallback to global FormData instance check\n // note: this is needed because the constructor.name could be different in case of\n // custom global FormData implementation, eg. React Native on Android/iOS\n (typeof FormData !== 'undefined' && body instanceof FormData)\n )\n }\n\n /**\n * Serializes the provided query parameters into a query string.\n */\n private serializeQueryParams(params: {[key: string]: any}): string {\n const result: Array = [];\n for (const key in params) {\n if (params[key] === null) {\n // skip null query params\n continue;\n }\n\n const value = params[key];\n const encodedKey = encodeURIComponent(key);\n\n if (Array.isArray(value)) {\n // repeat array params\n for (const v of value) {\n result.push(encodedKey + '=' + encodeURIComponent(v));\n }\n } else if (value instanceof Date) {\n result.push(encodedKey + '=' + encodeURIComponent(value.toISOString()));\n } else if (typeof value !== null && typeof value === 'object') {\n result.push(encodedKey + '=' + encodeURIComponent(JSON.stringify(value)));\n } else {\n result.push(encodedKey + '=' + encodeURIComponent(value));\n }\n }\n\n return result.join('&');\n }\n}\n"],"names":["ClientResponseError","Error","constructor","errData","super","this","url","status","response","isAbort","originalError","Object","setPrototypeOf","prototype","data","DOMException","name","message","_a","_d","_c","_b","cause","includes","toJSON","assign","fieldContentRegExp","cookieSerialize","val","options","opt","encode","defaultEncode","test","TypeError","value","result","maxAge","isNaN","isFinite","Math","floor","domain","path","expires","isDate","toString","call","Date","valueOf","toUTCString","httpOnly","secure","priority","toLowerCase","sameSite","defaultDecode","indexOf","decodeURIComponent","encodeURIComponent","atobPolyfill","getTokenPayload","token","encodedPayload","split","map","c","charCodeAt","slice","join","JSON","parse","e","atob","input","str","String","replace","length","bs","buffer","bc","idx","output","charAt","fromCharCode","defaultCookieKey","BaseAuthStore","baseToken","baseModel","_onChangeCallbacks","model","isValid","isTokenExpired","expirationThreshold","payload","keys","exp","now","isAdmin","type","isAuthRecord","save","triggerChange","clear","loadFromCookie","cookie","key","rawData","cookieParse","decode","index","eqIdx","endIdx","lastIndexOf","trim","undefined","_","Array","isArray","exportToCookie","defaultOptions","stringify","resultLength","Blob","size","id","email","extraProps","prop","onChange","callback","fireImmediately","push","i","splice","LocalAuthStore","storageKey","storageFallback","_bindStorageEvent","_storageGet","_storageSet","_storageRemove","window","localStorage","rawValue","getItem","normalizedVal","setItem","removeItem","addEventListener","BaseService","client","SettingsService","getAll","method","send","update","bodyParams","body","testS3","filesystem","then","testEmail","toEmail","emailTemplate","template","generateAppleClientSecret","clientId","teamId","keyId","privateKey","duration","CrudService","getFullList","batchOrqueryParams","_getFullList","batch","getList","page","perPage","query","baseCrudPath","responseData","items","item","getFirstListItem","filter","requestKey","skipTotal","code","getOne","create","batchSize","request","__awaiter","list","concat","normalizeLegacyOptionsArgs","legacyWarn","baseOptions","bodyOrOptions","hasQuery","console","warn","AdminService","authStore","collectionId","delete","success","authResponse","admin","authWithPassword","password","identity","bind","authRefresh","requestPasswordReset","confirmPasswordReset","resetToken","passwordConfirm","RealtimeService","eventSource","subscriptions","lastSentTopics","maxConnectTimeout","reconnectAttempts","maxReconnectAttempts","Infinity","predefinedReconnectIntervals","pendingConnects","isConnected","subscribe","topic","listener","msgEvent","submitSubscriptions","connect","unsubscribeByTopicAndListener","unsubscribe","hasSubscriptionListeners","removeEventListener","disconnect","unsubscribeByPrefix","topicPrefix","hasAtleastOneTopic","startsWith","exist","topicToCheck","addAllSubscriptionListeners","getNonEmptySubscriptionTopics","getSubscriptionsCancelKey","catch","err","removeAllSubscriptionListeners","Promise","resolve","reject","initConnect","clearTimeout","connectTimeoutId","setTimeout","connectErrorHandler","EventSource","buildUrl","onerror","lastEventId","retries","hasUnsentSubscriptions","p","reconnectTimeoutId","latestTopics","t","timeout","fromReconnect","cancelRequest","close","RecordService","collectionIdOrName","baseCollectionPath","subscribeOne","recordId","realtime","topicOrCallback","batchOrOptions","params","collectionName","record","listAuthMethods","usernamePassword","emailPassword","authProviders","usernameOrEmail","authWithOAuth2Code","provider","codeVerifier","redirectUrl","createData","authWithOAuth2","args","config","find","eagerDefaultPopup","cleanup","urlCallback","openBrowserPopup","oldState","state","scopes","authData","replacements","_replaceQueryParams","authUrl","location","href","passwordResetToken","requestVerification","confirmVerification","verificationToken","requestEmailChange","newEmail","confirmEmailChange","emailChangeToken","listExternalAuths","unlinkExternalAuth","urlPath","substring","parsedParams","rawParams","param","pair","hasOwnProperty","open","width","height","windowWidth","innerWidth","windowHeight","innerHeight","left","top","CollectionService","import","collections","deleteMissing","LogService","getRequestsList","getRequest","getRequestsStats","HealthService","check","FileService","getUrl","filename","queryParams","parts","download","URLSearchParams","getToken","BackupService","basename","restore","getDownloadUrl","knownSendOptionsKeys","Client","baseUrl","lang","cancelControllers","recordServices","enableAutoCancellation","admins","files","logs","settings","health","backups","collection","idOrName","autoCancellation","enable","abort","cancelAllRequests","k","getFileUrl","origin","endsWith","pathname","initSendOptions","serializeQueryParams","beforeSend","getHeader","headers","fetch","json","afterSend","convertToFormDataIfNeeded","$autoCancel","$cancelKey","isFormData","Authorization","controller","AbortController","signal","FormData","hasBlobField","form","values","append","v","File","encodedKey","toISOString"],"mappings":"yaAIM,MAAOA,4BAA4BC,MAOrC,WAAAC,CAAYC,eACRC,MAAM,uBAPVC,KAAGC,IAA8B,GACjCD,KAAME,OAA2B,EACjCF,KAAQG,SAAyB,GACjCH,KAAOI,SAA0B,EACjCJ,KAAaK,cAAoB,KAO7BC,OAAOC,eAAeP,KAAML,oBAAoBa,WAEhC,OAAZV,GAAuC,iBAAZA,IAC3BE,KAAKC,IAAuC,iBAAhBH,EAAQG,IAAmBH,EAAQG,IAAM,GACrED,KAAKE,OAA0C,iBAAnBJ,EAAQI,OAAsBJ,EAAQI,OAAS,EAC3EF,K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,EAAQ5R,GAIvB,OAAO,IACV,CAKO,UAAAmS,CAAW/O,GACf,OAAOA,IAIuB,aAA1BA,EAAK7J,YAAYc,MAII,oBAAbmY,UAA4BpP,aAAgBoP,SAE3D,CAKO,oBAAAf,CAAqBvG,GACzB,MAAMzP,EAAwB,GAC9B,IAAK,MAAMuE,KAAOkL,EAAQ,CACtB,GAAoB,OAAhBA,EAAOlL,GAEP,SAGJ,MAAMxE,EAAQ0P,EAAOlL,GACf+S,EAAa/V,mBAAmBgD,GAEtC,GAAIW,MAAMC,QAAQpF,GAEd,IAAK,MAAMqX,KAAKrX,EACZC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmB6V,SAE/CrX,aAAiBa,KACxBZ,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBxB,EAAMwX,gBAChC,cAAVxX,GAAmC,iBAAVA,EACvCC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBW,KAAKoD,UAAUvF,KAEjEC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBxB,GAEzD,CAED,OAAOC,EAAOiC,KAAK,IACtB"} \ No newline at end of file +{"version":3,"file":"pocketbase.cjs.js","sources":["../src/ClientResponseError.ts","../src/stores/utils/cookie.ts","../src/stores/utils/jwt.ts","../src/stores/BaseAuthStore.ts","../src/stores/LocalAuthStore.ts","../src/services/utils/BaseService.ts","../src/services/SettingsService.ts","../src/services/utils/CrudService.ts","../src/services/utils/legacy.ts","../src/services/AdminService.ts","../src/services/RealtimeService.ts","../src/services/RecordService.ts","../src/services/CollectionService.ts","../src/services/LogService.ts","../src/services/HealthService.ts","../src/services/FileService.ts","../src/services/BackupService.ts","../src/Client.ts"],"sourcesContent":["/**\n * ClientResponseError is a custom Error class that is intended to wrap\n * and normalize any error thrown by `Client.send()`.\n */\nexport class ClientResponseError extends Error {\n url: string = '';\n status: number = 0;\n response: {[key: string]: any} = {};\n isAbort: boolean = false;\n originalError: any = null;\n\n constructor(errData?: any) {\n super(\"ClientResponseError\");\n\n // Set the prototype explicitly.\n // https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\n Object.setPrototypeOf(this, ClientResponseError.prototype);\n\n if (errData !== null && typeof errData === 'object') {\n this.url = typeof errData.url === 'string' ? errData.url : '';\n this.status = typeof errData.status === 'number' ? errData.status : 0;\n this.isAbort = !!errData.isAbort;\n this.originalError = errData.originalError;\n\n if (errData.response !== null && typeof errData.response === 'object') {\n this.response = errData.response;\n } else if (errData.data !== null && typeof errData.data === 'object') {\n this.response = errData.data;\n } else {\n this.response = {};\n }\n }\n\n if (!this.originalError && !(errData instanceof ClientResponseError)) {\n this.originalError = errData;\n }\n\n if (typeof DOMException !== 'undefined' && errData instanceof DOMException) {\n this.isAbort = true;\n }\n\n this.name = \"ClientResponseError \" + this.status;\n this.message = this.response?.message;\n if (!this.message) {\n if (this.isAbort) {\n this.message = 'The request was autocancelled. You can find more info in https://github.com/pocketbase/js-sdk#auto-cancellation.';\n } else if (this.originalError?.cause?.message?.includes(\"ECONNREFUSED ::1\")) {\n this.message = 'Failed to connect to the PocketBase server. Try changing the SDK URL from localhost to 127.0.0.1 (https://github.com/pocketbase/js-sdk/issues/21).';\n } else {\n this.message = 'Something went wrong while processing your request.';\n }\n }\n }\n\n /**\n * Alias for `this.response` to preserve the backward compatibility.\n */\n get data() {\n return this.response;\n }\n\n /**\n * Make a POJO's copy of the current error class instance.\n * @see https://github.com/vuex-orm/vuex-orm/issues/255\n */\n toJSON() {\n return { ...this };\n }\n}\n","/**\n * -------------------------------------------------------------------\n * Simple cookie parse and serialize utilities mostly based on the\n * node module https://github.com/jshttp/cookie.\n * -------------------------------------------------------------------\n */\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\nconst fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;\n\nexport interface ParseOptions{\n decode?: (val: string) => string,\n}\n\n/**\n* Parses the given cookie header string into an object\n* The object has the various cookies as keys(names) => values\n*/\nexport function cookieParse(str: string, options?: ParseOptions): { [key: string]: any } {\n const result: { [key: string]: any } = {};\n\n if (typeof str !== 'string') {\n return result;\n }\n\n const opt = Object.assign({}, options || {});\n const decode = opt.decode || defaultDecode;\n\n let index = 0;\n while (index < str.length) {\n const eqIdx = str.indexOf('=', index);\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break;\n }\n\n let endIdx = str.indexOf(';', index);\n\n if (endIdx === -1) {\n endIdx = str.length;\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(';', eqIdx - 1) + 1;\n continue;\n }\n\n const key = str.slice(index, eqIdx).trim();\n\n // only assign once\n if (undefined === result[key]) {\n let val = str.slice(eqIdx + 1, endIdx).trim();\n\n // quoted values\n if (val.charCodeAt(0) === 0x22) {\n val = val.slice(1, -1);\n }\n\n try {\n result[key] = decode(val);\n } catch (_) {\n result[key] = val; // no decoding\n }\n }\n\n index = endIdx + 1;\n }\n\n return result;\n};\n\nexport interface SerializeOptions {\n encode?: (val: string | number | boolean) => string,\n maxAge?: number,\n domain?: string,\n path?: string,\n expires?: Date,\n httpOnly?: boolean,\n secure?: boolean,\n priority?: string,\n sameSite?: boolean|string,\n}\n\n/**\n * Serialize data into a cookie header.\n *\n * Serialize the a name value pair into a cookie string suitable for\n * http headers. An optional options object specified cookie parameters.\n *\n * ```js\n * cookieSerialize('foo', 'bar', { httpOnly: true }) // \"foo=bar; httpOnly\"\n * ```\n */\nexport function cookieSerialize(name: string, val: string, options?: SerializeOptions): string {\n const opt = Object.assign({}, options || {});\n const encode = opt.encode || defaultEncode;\n\n if (!fieldContentRegExp.test(name)) {\n throw new TypeError('argument name is invalid');\n }\n\n const value = encode(val);\n\n if (value && !fieldContentRegExp.test(value)) {\n throw new TypeError('argument val is invalid');\n }\n\n let result = name + '=' + value;\n\n if (opt.maxAge != null) {\n const maxAge = opt.maxAge - 0;\n\n if (isNaN(maxAge) || !isFinite(maxAge)) {\n throw new TypeError('option maxAge is invalid');\n }\n\n result += '; Max-Age=' + Math.floor(maxAge);\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new TypeError('option domain is invalid');\n }\n\n result += '; Domain=' + opt.domain;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new TypeError('option path is invalid');\n }\n\n result += '; Path=' + opt.path;\n }\n\n if (opt.expires) {\n if (!isDate(opt.expires) || isNaN(opt.expires.valueOf())) {\n throw new TypeError('option expires is invalid');\n }\n\n result += '; Expires=' + opt.expires.toUTCString();\n }\n\n if (opt.httpOnly) {\n result += '; HttpOnly';\n }\n\n if (opt.secure) {\n result += '; Secure';\n }\n\n if (opt.priority) {\n const priority = typeof opt.priority === 'string' ? opt.priority.toLowerCase() : opt.priority;\n\n switch (priority) {\n case 'low':\n result += '; Priority=Low';\n break;\n case 'medium':\n result += '; Priority=Medium';\n break;\n case 'high':\n result += '; Priority=High';\n break;\n default:\n throw new TypeError('option priority is invalid');\n }\n }\n\n if (opt.sameSite) {\n const sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;\n\n switch (sameSite) {\n case true:\n result += '; SameSite=Strict';\n break;\n case 'lax':\n result += '; SameSite=Lax';\n break;\n case 'strict':\n result += '; SameSite=Strict';\n break;\n case 'none':\n result += '; SameSite=None';\n break;\n default:\n throw new TypeError('option sameSite is invalid');\n }\n }\n\n return result;\n};\n\n/**\n * Default URL-decode string value function.\n * Optimized to skip native call when no `%`.\n */\nfunction defaultDecode(val: string): string {\n return val.indexOf('%') !== -1\n ? decodeURIComponent(val)\n : val;\n}\n\n/**\n * Default URL-encode value function.\n */\nfunction defaultEncode(val: string | number | boolean): string {\n return encodeURIComponent(val);\n}\n\n/**\n * Determines if value is a Date.\n */\nfunction isDate(val: any): boolean {\n return (\n Object.prototype.toString.call(val) === '[object Date]' ||\n val instanceof Date\n );\n}\n","let atobPolyfill: Function;\nif (typeof atob === 'function') {\n atobPolyfill = atob\n} else {\n /**\n * The code was extracted from:\n * https://github.com/davidchambers/Base64.js\n */\n atobPolyfill = (input: any) => {\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\n let str = String(input).replace(/=+$/, \"\");\n if (str.length % 4 == 1) {\n throw new Error(\"'atob' failed: The string to be decoded is not correctly encoded.\");\n }\n\n for (\n // initialize result and counters\n var bc = 0, bs, buffer, idx = 0, output = \"\";\n // get next character\n (buffer = str.charAt(idx++));\n // character found in table? initialize bit storage and add its ascii value;\n ~buffer &&\n ((bs = bc % 4 ? (bs as any) * 64 + buffer : buffer),\n // and if not first of each 4 characters,\n // convert the first 8 bits to one ascii character\n bc++ % 4) ?\n (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)))) :\n 0\n ) {\n // try to find character in table (0-63, not found => -1)\n buffer = chars.indexOf(buffer);\n }\n\n return output;\n };\n}\n\n/**\n * Returns JWT token's payload data.\n */\nexport function getTokenPayload(token: string): { [key: string]: any } {\n if (token) {\n try {\n const encodedPayload = decodeURIComponent(atobPolyfill(token.split('.')[1]).split('').map(function (c: string) {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n }).join(''));\n\n return JSON.parse(encodedPayload) || {};\n } catch (e) {\n }\n }\n\n return {};\n}\n\n/**\n * Checks whether a JWT token is expired or not.\n * Tokens without `exp` payload key are considered valid.\n * Tokens with empty payload (eg. invalid token strings) are considered expired.\n *\n * @param token The token to check.\n * @param [expirationThreshold] Time in seconds that will be subtracted from the token `exp` property.\n */\nexport function isTokenExpired(token: string, expirationThreshold = 0): boolean {\n let payload = getTokenPayload(token);\n\n if (\n Object.keys(payload).length > 0 &&\n (!payload.exp || (payload.exp - expirationThreshold) > (Date.now() / 1000))\n ) {\n return false;\n }\n\n return true;\n}\n","import { cookieParse, cookieSerialize, SerializeOptions } from '@/stores/utils/cookie';\nimport { isTokenExpired, getTokenPayload } from '@/stores/utils/jwt';\nimport { RecordModel, AdminModel } from '@/services/utils/dtos';\n\nexport type AuthModel = RecordModel|AdminModel|null;\n\nexport type OnStoreChangeFunc = (token: string, model: AuthModel) => void;\n\nconst defaultCookieKey = 'pb_auth';\n\n/**\n * Base AuthStore class that is intended to be extended by all other\n * PocketBase AuthStore implementations.\n */\nexport abstract class BaseAuthStore {\n protected baseToken: string = '';\n protected baseModel: AuthModel = null;\n\n private _onChangeCallbacks: Array = [];\n\n /**\n * Retrieves the stored token (if any).\n */\n get token(): string {\n return this.baseToken;\n }\n\n /**\n * Retrieves the stored model data (if any).\n */\n get model(): AuthModel {\n return this.baseModel;\n }\n\n /**\n * Loosely checks if the store has valid token (aka. existing and unexpired exp claim).\n */\n get isValid(): boolean {\n return !isTokenExpired(this.token);\n }\n\n /**\n * Checks whether the current store state is for admin authentication.\n */\n get isAdmin(): boolean {\n return getTokenPayload(this.token).type === \"admin\";\n }\n\n /**\n * Checks whether the current store state is for auth record authentication.\n */\n get isAuthRecord(): boolean {\n return getTokenPayload(this.token).type === \"authRecord\";\n }\n\n /**\n * Saves the provided new token and model data in the auth store.\n */\n save(token: string, model?: AuthModel): void {\n this.baseToken = token || '';\n this.baseModel = model || null;\n\n this.triggerChange();\n }\n\n /**\n * Removes the stored token and model data form the auth store.\n */\n clear(): void {\n this.baseToken = '';\n this.baseModel = null;\n this.triggerChange();\n }\n\n /**\n * Parses the provided cookie string and updates the store state\n * with the cookie's token and model data.\n *\n * NB! This function doesn't validate the token or its data.\n * Usually this isn't a concern if you are interacting only with the\n * PocketBase API because it has the proper server-side security checks in place,\n * but if you are using the store `isValid` state for permission controls\n * in a node server (eg. SSR), then it is recommended to call `authRefresh()`\n * after loading the cookie to ensure an up-to-date token and model state.\n * For example:\n *\n * ```js\n * pb.authStore.loadFromCookie(\"cookie string...\");\n *\n * try {\n * // get an up-to-date auth store state by veryfing and refreshing the loaded auth model (if any)\n * pb.authStore.isValid && await pb.collection('users').authRefresh();\n * } catch (_) {\n * // clear the auth store on failed refresh\n * pb.authStore.clear();\n * }\n * ```\n */\n loadFromCookie(cookie: string, key = defaultCookieKey): void {\n const rawData = cookieParse(cookie || '')[key] || '';\n\n let data: { [key: string]: any } = {};\n try {\n data = JSON.parse(rawData);\n // normalize\n if (typeof data === null || typeof data !== 'object' || Array.isArray(data)) {\n data = {};\n }\n } catch (_) {}\n\n this.save(data.token || '', data.model || null);\n }\n\n /**\n * Exports the current store state as cookie string.\n *\n * By default the following optional attributes are added:\n * - Secure\n * - HttpOnly\n * - SameSite=Strict\n * - Path=/\n * - Expires={the token expiration date}\n *\n * NB! If the generated cookie exceeds 4096 bytes, this method will\n * strip the model data to the bare minimum to try to fit within the\n * recommended size in https://www.rfc-editor.org/rfc/rfc6265#section-6.1.\n */\n exportToCookie(options?: SerializeOptions, key = defaultCookieKey): string {\n const defaultOptions: SerializeOptions = {\n secure: true,\n sameSite: true,\n httpOnly: true,\n path: \"/\",\n };\n\n // extract the token expiration date\n const payload = getTokenPayload(this.token);\n if (payload?.exp) {\n defaultOptions.expires = new Date(payload.exp * 1000);\n } else {\n defaultOptions.expires = new Date('1970-01-01');\n }\n\n // merge with the user defined options\n options = Object.assign({}, defaultOptions, options);\n\n const rawData = {\n token: this.token,\n model: this.model ? JSON.parse(JSON.stringify(this.model)) : null,\n };\n\n let result = cookieSerialize(key, JSON.stringify(rawData), options);\n\n const resultLength = typeof Blob !== 'undefined' ?\n (new Blob([result])).size : result.length;\n\n // strip down the model data to the bare minimum\n if (rawData.model && resultLength > 4096) {\n rawData.model = {id: rawData?.model?.id, email: rawData?.model?.email};\n const extraProps = [\"collectionId\", \"username\", \"verified\"];\n for (const prop in this.model) {\n if (extraProps.includes(prop)) {\n rawData.model[prop] = this.model[prop];\n }\n }\n result = cookieSerialize(key, JSON.stringify(rawData), options);\n }\n\n return result;\n }\n\n /**\n * Register a callback function that will be called on store change.\n *\n * You can set the `fireImmediately` argument to true in order to invoke\n * the provided callback right after registration.\n *\n * Returns a removal function that you could call to \"unsubscribe\" from the changes.\n */\n onChange(callback: OnStoreChangeFunc, fireImmediately = false): () => void {\n this._onChangeCallbacks.push(callback);\n\n if (fireImmediately) {\n callback(this.token, this.model);\n }\n\n return () => {\n for (let i = this._onChangeCallbacks.length - 1; i >= 0; i--) {\n if (this._onChangeCallbacks[i] == callback) {\n delete this._onChangeCallbacks[i]; // removes the function reference\n this._onChangeCallbacks.splice(i, 1); // reindex the array\n return;\n }\n }\n }\n }\n\n protected triggerChange(): void {\n for (const callback of this._onChangeCallbacks) {\n callback && callback(this.token, this.model);\n }\n }\n}\n","import { BaseAuthStore, AuthModel } from '@/stores/BaseAuthStore';\n\n/**\n * The default token store for browsers with auto fallback\n * to runtime/memory if local storage is undefined (eg. in node env).\n */\nexport class LocalAuthStore extends BaseAuthStore {\n private storageFallback: { [key: string]: any } = {};\n private storageKey: string\n\n constructor(storageKey = \"pocketbase_auth\") {\n super();\n\n this.storageKey = storageKey;\n\n this._bindStorageEvent();\n }\n\n /**\n * @inheritdoc\n */\n get token(): string {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.token || '';\n }\n\n /**\n * @inheritdoc\n */\n get model(): AuthModel {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.model || null;\n }\n\n /**\n * @inheritdoc\n */\n save(token: string, model?: AuthModel) {\n this._storageSet(this.storageKey, {\n 'token': token,\n 'model': model,\n });\n\n super.save(token, model);\n }\n\n /**\n * @inheritdoc\n */\n clear() {\n this._storageRemove(this.storageKey);\n\n super.clear();\n }\n\n // ---------------------------------------------------------------\n // Internal helpers:\n // ---------------------------------------------------------------\n\n /**\n * Retrieves `key` from the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageGet(key: string): any {\n if (typeof window !== 'undefined' && window?.localStorage) {\n const rawValue = window.localStorage.getItem(key) || '';\n try {\n return JSON.parse(rawValue);\n } catch (e) { // not a json\n return rawValue;\n }\n }\n\n // fallback\n return this.storageFallback[key];\n }\n\n /**\n * Stores a new data in the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageSet(key: string, value: any) {\n if (typeof window !== 'undefined' && window?.localStorage) {\n // store in local storage\n let normalizedVal = value;\n if (typeof value !== 'string') {\n normalizedVal = JSON.stringify(value);\n }\n window.localStorage.setItem(key, normalizedVal);\n } else {\n // store in fallback\n this.storageFallback[key] = value;\n }\n }\n\n /**\n * Removes `key` from the browser's local storage and the runtime/memory.\n */\n private _storageRemove(key: string) {\n // delete from local storage\n if (typeof window !== 'undefined' && window?.localStorage) {\n window.localStorage?.removeItem(key);\n }\n\n // delete from fallback\n delete this.storageFallback[key];\n }\n\n /**\n * Updates the current store state on localStorage change.\n */\n private _bindStorageEvent() {\n if (typeof window === 'undefined' || !window?.localStorage || !window.addEventListener) {\n return;\n }\n\n window.addEventListener('storage', (e) => {\n if (e.key != this.storageKey) {\n return;\n }\n\n const data = this._storageGet(this.storageKey) || {};\n\n super.save(data.token || '', data.model || null);\n });\n }\n}\n","import Client from '@/Client';\n\n/**\n * BaseService class that should be inherited from all API services.\n */\nexport abstract class BaseService {\n readonly client: Client\n\n constructor(client: Client) {\n this.client = client;\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\ninterface appleClientSecret {\n secret: string;\n}\n\nexport class SettingsService extends BaseService {\n /**\n * Fetch all available app settings.\n */\n getAll(options?: CommonOptions): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Bulk updates app settings.\n */\n update(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Performs a S3 filesystem connection test.\n *\n * The currently supported `filesystem` are \"storage\" and \"backups\".\n */\n testS3(filesystem: string = \"storage\", options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'filesystem': filesystem,\n },\n }, options);\n\n return this.client.send('/api/settings/test/s3', options)\n .then(() => true);\n }\n\n /**\n * Sends a test email.\n *\n * The possible `emailTemplate` values are:\n * - verification\n * - password-reset\n * - email-change\n */\n testEmail(toEmail: string, emailTemplate: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'email': toEmail,\n 'template': emailTemplate,\n },\n }, options);\n\n return this.client.send('/api/settings/test/email', options)\n .then(() => true);\n }\n\n /**\n * Generates a new Apple OAuth2 client secret.\n */\n generateAppleClientSecret(\n clientId: string,\n teamId: string,\n keyId: string,\n privateKey: string,\n duration: number,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n clientId,\n teamId,\n keyId,\n privateKey,\n duration,\n },\n }, options);\n\n return this.client.send('/api/settings/apple/generate-client-secret', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n FullListOptions\n} from '@/services/utils/options';\n\nexport abstract class CrudService extends BaseService {\n /**\n * Base path for the crud actions (without trailing slash, eg. '/admins').\n */\n abstract get baseCrudPath(): string\n\n /**\n * Response data decoder.\n */\n decode(data: { [key: string]: any }): T {\n return data as T;\n }\n\n /**\n * Returns a promise with all list items batch fetched at once\n * (by default 500 items per request; to change it set the `batch` query param).\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getFullList(options?: FullListOptions): Promise>\n\n /**\n * Legacy version of getFullList with explicitly specified batch size.\n */\n getFullList(batch?: number, options?: ListOptions): Promise>\n\n getFullList(batchOrqueryParams?: number|FullListOptions, options?: ListOptions): Promise> {\n if (typeof batchOrqueryParams == \"number\") {\n return this._getFullList(batchOrqueryParams, options);\n }\n\n options = Object.assign({}, batchOrqueryParams, options);\n\n let batch = 500;\n if (options.batch) {\n batch = options.batch;\n delete options.batch;\n }\n\n return this._getFullList(batch, options);\n }\n\n /**\n * Returns paginated items list.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({\n method: 'GET'\n }, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => {\n responseData.items = responseData.items?.map((item: any) => {\n return this.decode(item);\n }) || [];\n\n return responseData;\n });\n }\n\n /**\n * Returns the first found item by the specified filter.\n *\n * Internally it calls `getList(1, 1, { filter, skipTotal })` and\n * returns the first found item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n *\n * For consistency with `getOne`, this method will throw a 404\n * ClientResponseError if no item was found.\n */\n getFirstListItem(filter: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'requestKey': 'one_by_filter_' + this.baseCrudPath + \"_\" + filter,\n }, options);\n\n options.query = Object.assign({\n 'filter': filter,\n 'skipTotal': 1,\n }, options.query);\n\n return this.getList(1, 1, options)\n .then((result) => {\n if (!result?.items?.length) {\n throw new ClientResponseError({\n status: 404,\n data: {\n code: 404,\n message: \"The requested resource wasn't found.\",\n data: {},\n },\n });\n }\n\n return result.items[0];\n });\n }\n\n /**\n * Returns single item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getOne(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Creates a new item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n create(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Updates an existing item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Deletes an existing item by its id.\n */\n delete(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then(() => true);\n }\n\n /**\n * Returns a promise with all list items batch fetched at once.\n */\n protected _getFullList(batchSize = 500, options?: ListOptions): Promise> {\n options = options || {};\n options.query = Object.assign({\n 'skipTotal': 1,\n }, options.query);\n\n let result: Array = [];\n\n let request = async (page: number): Promise> => {\n return this.getList(page, batchSize || 500, options).then((list) => {\n const castedList = (list as any as ListResult);\n const items = castedList.items;\n\n result = result.concat(items);\n\n if (items.length == list.perPage) {\n return request(page + 1);\n }\n\n return result;\n });\n }\n\n return request(1);\n }\n}\n","import { SendOptions } from '@/services/utils/options';\n\nexport function normalizeLegacyOptionsArgs(legacyWarn: string, baseOptions: SendOptions, bodyOrOptions?: any, query?: any): SendOptions {\n const hasBodyOrOptions = typeof bodyOrOptions !== 'undefined';\n const hasQuery = typeof query !== 'undefined';\n\n if (!hasQuery && !hasBodyOrOptions) {\n return baseOptions;\n }\n\n if (hasQuery) {\n console.warn(legacyWarn);\n baseOptions.body = Object.assign({}, baseOptions.body, bodyOrOptions);\n baseOptions.query = Object.assign({}, baseOptions.query, query);\n\n return baseOptions;\n }\n\n baseOptions = Object.assign(baseOptions, bodyOrOptions);\n return baseOptions;\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { AdminModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface AdminAuthResponse {\n [key: string]: any;\n\n token: string;\n admin: AdminModel;\n}\n\nexport class AdminService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/admins';\n }\n\n // ---------------------------------------------------------------\n // Post update/delete AuthStore sync\n // ---------------------------------------------------------------\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n // update the store state if the updated item id matches with the stored model\n if (\n this.client.authStore.model?.id === item.id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n // clear the store state if the deleted item id matches with the stored model\n if (\n success &&\n this.client.authStore.model?.id === id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful authorize response.\n */\n protected authResponse(responseData: any): AdminAuthResponse {\n const admin = this.decode(responseData?.admin || {});\n\n if (responseData?.token && responseData?.admin) {\n this.client.authStore.save(responseData.token, admin);\n }\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'admin': admin,\n });\n }\n\n /**\n * Authenticate an admin account with its email and password\n * and returns a new admin token and data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authWithPassword(email: string, password: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authWithPassword(email, password, options?).\n */\n authWithPassword(email: string, password: string, body?: any, query?: any): Promise\n\n authWithPassword(\n email: string,\n password: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': email,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(email, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(email, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-with-password', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Refreshes the current admin authenticated instance and\n * returns a new token and admin data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authRefresh(options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-refresh', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Sends admin password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/request-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Confirms admin password reset request.\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(resetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, body?: any, query?: any): Promise\n\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, bodyOrOptions?: any, query?: any): Promise{\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': resetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(resetToken, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(resetToken, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\n\ninterface promiseCallbacks {\n resolve: Function\n reject: Function\n}\n\nexport type UnsubscribeFunc = () => Promise;\n\nexport class RealtimeService extends BaseService {\n clientId: string = \"\";\n\n private eventSource: EventSource | null = null;\n private subscriptions: { [key: string]: Array } = {};\n private lastSentTopics: Array = [];\n private connectTimeoutId: any;\n private maxConnectTimeout: number = 15000;\n private reconnectTimeoutId: any;\n private reconnectAttempts: number = 0;\n private maxReconnectAttempts: number = Infinity;\n private predefinedReconnectIntervals: Array = [\n 200, 300, 500, 1000, 1200, 1500, 2000,\n ];\n private pendingConnects: Array = [];\n\n /**\n * Returns whether the realtime connection has been established.\n */\n get isConnected(): boolean {\n return !!this.eventSource && !!this.clientId && !this.pendingConnects.length;\n }\n\n /**\n * Register the subscription listener.\n *\n * You can subscribe multiple times to the same topic.\n *\n * If the SSE connection is not started yet,\n * this method will also initialize it.\n */\n async subscribe(topic: string, callback: (data: any) => void): Promise {\n if (!topic) {\n throw new Error('topic must be set.')\n }\n\n const listener = function (e: Event) {\n const msgEvent = (e as MessageEvent);\n\n let data;\n try {\n data = JSON.parse(msgEvent?.data);\n } catch {}\n\n callback(data || {});\n };\n\n // store the listener\n if (!this.subscriptions[topic]) {\n this.subscriptions[topic] = [];\n }\n this.subscriptions[topic].push(listener);\n\n if (!this.isConnected) {\n // initialize sse connection\n await this.connect();\n } else if (this.subscriptions[topic].length === 1) {\n // send the updated subscriptions (if it is the first for the topic)\n await this.submitSubscriptions();\n } else {\n // only register the listener\n this.eventSource?.addEventListener(topic, listener);\n }\n\n return async (): Promise => {\n return this.unsubscribeByTopicAndListener(topic, listener);\n };\n }\n\n /**\n * Unsubscribe from all subscription listeners with the specified topic.\n *\n * If `topic` is not provided, then this method will unsubscribe\n * from all active subscriptions.\n *\n * This method is no-op if there are no active subscriptions.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribe(topic?: string): Promise {\n if (!this.hasSubscriptionListeners(topic)) {\n return; // already unsubscribed\n }\n\n if (!topic) {\n // remove all subscriptions\n this.subscriptions = {};\n } else {\n // remove all topic listeners\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n /**\n * Unsubscribe from all subscription listeners starting with the specified topic prefix.\n *\n * This method is no-op if there are no active subscriptions with the specified topic prefix.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByPrefix(topicPrefix: string): Promise {\n let hasAtleastOneTopic = false;\n for (let topic in this.subscriptions) {\n if (!topic.startsWith(topicPrefix)) {\n continue;\n }\n\n hasAtleastOneTopic = true;\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!hasAtleastOneTopic) {\n return; // nothing to unsubscribe from\n }\n\n if (this.hasSubscriptionListeners()) {\n // submit the deleted subscriptions\n await this.submitSubscriptions();\n } else {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n }\n }\n\n /**\n * Unsubscribe from all subscriptions matching the specified topic and listener function.\n *\n * This method is no-op if there are no active subscription with\n * the specified topic and listener.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByTopicAndListener(topic: string, listener: EventListener): Promise {\n if (!Array.isArray(this.subscriptions[topic]) || !this.subscriptions[topic].length) {\n return; // already unsubscribed\n }\n\n let exist = false;\n for (let i = this.subscriptions[topic].length - 1; i >= 0; i--) {\n if (this.subscriptions[topic][i] !== listener) {\n continue;\n }\n\n exist = true; // has at least one matching listener\n delete this.subscriptions[topic][i]; // removes the function reference\n this.subscriptions[topic].splice(i, 1); // reindex the array\n this.eventSource?.removeEventListener(topic, listener);\n }\n if (!exist) {\n return;\n }\n\n // remove the topic from the subscriptions list if there are no other listeners\n if (!this.subscriptions[topic].length) {\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n private hasSubscriptionListeners(topicToCheck?: string): boolean {\n this.subscriptions = this.subscriptions || {};\n\n // check the specified topic\n if (topicToCheck) {\n return !!this.subscriptions[topicToCheck]?.length;\n }\n\n // check for at least one non-empty topic\n for (let topic in this.subscriptions) {\n if (!!this.subscriptions[topic]?.length) {\n return true\n }\n }\n\n return false;\n }\n\n private async submitSubscriptions(): Promise {\n if (!this.clientId) {\n return; // no client/subscriber\n }\n\n // optimistic update\n this.addAllSubscriptionListeners();\n\n this.lastSentTopics = this.getNonEmptySubscriptionTopics();\n\n return this.client.send('/api/realtime', {\n 'method': 'POST',\n 'body': {\n 'clientId': this.clientId,\n 'subscriptions': this.lastSentTopics,\n },\n 'query': {\n 'requestKey': this.getSubscriptionsCancelKey(),\n },\n }).catch((err) => {\n if (err?.isAbort) {\n return; // silently ignore aborted pending requests\n }\n throw err;\n });\n }\n\n private getSubscriptionsCancelKey(): string {\n return \"realtime_\" + this.clientId;\n }\n\n private getNonEmptySubscriptionTopics(): Array {\n const result : Array = [];\n\n for (let topic in this.subscriptions) {\n if (this.subscriptions[topic].length) {\n result.push(topic);\n }\n }\n\n return result;\n }\n\n private addAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n this.removeAllSubscriptionListeners();\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.addEventListener(topic, listener);\n }\n }\n }\n\n private removeAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.removeEventListener(topic, listener);\n }\n }\n }\n\n private async connect(): Promise {\n if (this.reconnectAttempts > 0) {\n // immediately resolve the promise to avoid indefinitely\n // blocking the client during reconnection\n return;\n }\n\n return new Promise((resolve, reject) => {\n this.pendingConnects.push({ resolve, reject });\n\n if (this.pendingConnects.length > 1) {\n // all promises will be resolved once the connection is established\n return;\n }\n\n this.initConnect();\n })\n }\n\n private initConnect() {\n this.disconnect(true);\n\n // wait up to 15s for connect\n clearTimeout(this.connectTimeoutId);\n this.connectTimeoutId = setTimeout(() => {\n this.connectErrorHandler(new Error(\"EventSource connect took too long.\"));\n }, this.maxConnectTimeout);\n\n this.eventSource = new EventSource(this.client.buildUrl('/api/realtime'))\n\n this.eventSource.onerror = (_) => {\n this.connectErrorHandler(new Error(\"Failed to establish realtime connection.\"));\n };\n\n this.eventSource.addEventListener('PB_CONNECT', (e) => {\n const msgEvent = (e as MessageEvent);\n this.clientId = msgEvent?.lastEventId;\n\n this.submitSubscriptions()\n .then(async () => {\n let retries = 3;\n while (this.hasUnsentSubscriptions() && retries > 0) {\n retries--;\n // resubscribe to ensure that the latest topics are submitted\n //\n // This is needed because missed topics could happen on reconnect\n // if after the pending sent `submitSubscriptions()` call another `subscribe()`\n // was made before the submit was able to complete.\n await this.submitSubscriptions();\n }\n }).then(() => {\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n\n // reset connect meta\n this.pendingConnects = [];\n this.reconnectAttempts = 0;\n clearTimeout(this.reconnectTimeoutId);\n clearTimeout(this.connectTimeoutId);\n }).catch((err) => {\n this.clientId = \"\";\n this.connectErrorHandler(err);\n });\n });\n }\n\n private hasUnsentSubscriptions(): boolean {\n const latestTopics = this.getNonEmptySubscriptionTopics();\n if (latestTopics.length != this.lastSentTopics.length) {\n return true;\n }\n\n for (const t of latestTopics) {\n if (!this.lastSentTopics.includes(t)) {\n return true;\n }\n }\n\n return false;\n }\n\n private connectErrorHandler(err: any) {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n\n if (\n // wasn't previously connected -> direct reject\n (!this.clientId && !this.reconnectAttempts) ||\n // was previously connected but the max reconnection limit has been reached\n this.reconnectAttempts > this.maxReconnectAttempts\n ) {\n for (let p of this.pendingConnects) {\n p.reject(new ClientResponseError(err));\n }\n this.pendingConnects = [];\n this.disconnect();\n return;\n }\n\n // otherwise -> reconnect in the background\n this.disconnect(true);\n const timeout = this.predefinedReconnectIntervals[this.reconnectAttempts] || this.predefinedReconnectIntervals[this.predefinedReconnectIntervals.length - 1];\n this.reconnectAttempts++;\n this.reconnectTimeoutId = setTimeout(() => {\n this.initConnect();\n }, timeout);\n }\n\n private disconnect(fromReconnect = false): void {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n this.removeAllSubscriptionListeners();\n this.client.cancelRequest(this.getSubscriptionsCancelKey());\n this.eventSource?.close();\n this.eventSource = null;\n this.clientId = \"\";\n\n if (!fromReconnect) {\n this.reconnectAttempts = 0;\n\n // resolve any remaining connect promises\n //\n // this is done to avoid unnecessary throwing errors in case\n // unsubscribe is called before the pending connect promises complete\n // (see https://github.com/pocketbase/pocketbase/discussions/2897#discussioncomment-6423818)\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n this.pendingConnects = [];\n }\n }\n}\n","import Client from '@/Client';\nimport { CrudService } from '@/services/utils/CrudService';\nimport { RealtimeService, UnsubscribeFunc } from '@/services/RealtimeService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult, RecordModel, ExternalAuthModel } from '@/services/utils/dtos';\nimport {\n SendOptions,\n CommonOptions,\n RecordOptions,\n RecordListOptions,\n RecordFullListOptions,\n} from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface RecordAuthResponse {\n // The signed PocketBase auth record.\n record: T;\n\n // The PocketBase record auth token.\n //\n // If you are looking for the OAuth2 access and refresh tokens\n // they are available under the `meta.accessToken` and `meta.refreshToken` props.\n token: string;\n\n // Auth meta data usually filled when OAuth2 is used.\n meta?: {[key: string]: any};\n}\n\nexport interface AuthProviderInfo {\n name: string;\n state: string;\n codeVerifier: string;\n codeChallenge: string;\n codeChallengeMethod: string;\n authUrl: string;\n}\n\nexport interface AuthMethodsList {\n usernamePassword: boolean;\n emailPassword: boolean;\n authProviders: Array;\n}\n\nexport interface RecordSubscription {\n action: string; // eg. create, update, delete\n record: T;\n}\n\nexport type OAuth2UrlCallback = (url: string) => void|Promise;\n\nexport interface OAuth2AuthConfig extends SendOptions {\n // the name of the OAuth2 provider (eg. \"google\")\n provider: string;\n\n // custom scopes to overwrite the default ones\n scopes?: Array;\n\n // optional record create data\n createData?: {[key: string]: any};\n\n // optional callback that is triggered after the OAuth2 sign-in/sign-up url generation\n urlCallback?: OAuth2UrlCallback;\n\n // optional query params to send with the PocketBase auth request (eg. fields, expand, etc.)\n query?: RecordOptions;\n}\n\nexport class RecordService extends CrudService {\n readonly collectionIdOrName: string;\n\n constructor(client: Client, collectionIdOrName: string) {\n super(client);\n\n this.collectionIdOrName = collectionIdOrName;\n }\n\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return this.baseCollectionPath + '/records';\n }\n\n /**\n * Returns the current collection service base path.\n */\n get baseCollectionPath(): string {\n return '/api/collections/' + encodeURIComponent(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Realtime handlers\n // ---------------------------------------------------------------\n\n /**\n * @deprecated Use subscribe(recordId, callback) instead.\n *\n * Subscribe to the realtime changes of a single record in the collection.\n */\n async subscribeOne(recordId: string, callback: (data: RecordSubscription) => void): Promise {\n console.warn(\"PocketBase: subscribeOne(recordId, callback) is deprecated. Please replace it with subscribe(recordId, callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName + \"/\" + recordId, callback);\n }\n\n /**\n * @deprecated This form of subscribe is deprecated. Please use `subscribe(\"*\", callback)`.\n */\n async subscribe(callback: (data: RecordSubscription) => void): Promise\n\n /**\n * Subscribe to realtime changes to the specified topic (\"*\" or record id).\n *\n * If `topic` is the wildcard \"*\", then this method will subscribe to\n * any record changes in the collection.\n *\n * If `topic` is a record id, then this method will subscribe only\n * to changes of the specified record id.\n *\n * It's OK to subscribe multiple times to the same topic.\n * You can use the returned `UnsubscribeFunc` to remove only a single subscription.\n * Or use `unsubscribe(topic)` if you want to remove all subscriptions attached to the topic.\n */\n async subscribe(topic: string, callback: (data: RecordSubscription) => void): Promise\n\n async subscribe(\n topicOrCallback: string|((data: RecordSubscription) => void),\n callback?: (data: RecordSubscription) => void\n ): Promise {\n if (typeof topicOrCallback === 'function') {\n console.warn(\"PocketBase: subscribe(callback) is deprecated. Please replace it with subscribe('*', callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName, topicOrCallback);\n }\n\n if (!callback) {\n throw new Error(\"Missing subscription callback.\");\n }\n\n if (topicOrCallback === \"\") {\n throw new Error(\"Missing topic.\");\n }\n\n let topic = this.collectionIdOrName;\n if (topicOrCallback !== \"*\") {\n topic += ('/' + topicOrCallback);\n }\n\n return this.client.realtime.subscribe(topic, callback)\n }\n\n /**\n * Unsubscribe from all subscriptions of the specified topic\n * (\"*\" or record id).\n *\n * If `topic` is not set, then this method will unsubscribe from\n * all subscriptions associated to the current collection.\n */\n async unsubscribe(topic?: string): Promise {\n // unsubscribe wildcard topic\n if (topic === \"*\") {\n return this.client.realtime.unsubscribe(this.collectionIdOrName);\n }\n\n // unsubscribe recordId topic\n if (topic) {\n return this.client.realtime.unsubscribe(this.collectionIdOrName + \"/\" + topic);\n }\n\n // unsubscribe from everything related to the collection\n return this.client.realtime.unsubscribeByPrefix(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Crud handers\n // ---------------------------------------------------------------\n /**\n * @inheritdoc\n */\n getFullList(options?: RecordFullListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batch?: number, options?: RecordListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batchOrOptions?: number|RecordFullListOptions, options?: RecordListOptions): Promise> {\n if (typeof batchOrOptions == \"number\") {\n return super.getFullList(batchOrOptions, options);\n }\n\n const params = Object.assign({}, batchOrOptions, options);\n\n return super.getFullList(params);\n }\n\n /**\n * @inheritdoc\n */\n getList(page = 1, perPage = 30, options?: RecordListOptions): Promise> {\n return super.getList(page, perPage, options);\n }\n\n /**\n * @inheritdoc\n */\n getFirstListItem(filter: string, options?: RecordListOptions): Promise {\n return super.getFirstListItem(filter, options);\n }\n\n /**\n * @inheritdoc\n */\n getOne(id: string, options?: RecordOptions): Promise {\n return super.getOne(id, options);\n }\n\n /**\n * @inheritdoc\n */\n create(bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.create(bodyParams, options);\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(id: string, bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n if (\n // is record auth\n this.client.authStore.model?.id === item?.id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n if (\n success &&\n // is record auth\n this.client.authStore.model?.id === id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful collection authorization response.\n */\n protected authResponse(responseData: any): RecordAuthResponse {\n const record = this.decode(responseData?.record || {});\n\n this.client.authStore.save(responseData?.token, record);\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'record': record as any as T,\n });\n }\n\n /**\n * Returns all available collection auth methods.\n */\n listAuthMethods(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCollectionPath + '/auth-methods', options)\n .then((responseData: any) => {\n return Object.assign({}, responseData, {\n // normalize common fields\n 'usernamePassword': !!responseData?.usernamePassword,\n 'emailPassword': !!responseData?.emailPassword,\n 'authProviders': Array.isArray(responseData?.authProviders) ? responseData?.authProviders : [],\n });\n });\n }\n\n /**\n * Authenticate a single auth collection record via its username/email and password.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n */\n authWithPassword(usernameOrEmail: string, password: string, options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authWithPassword(usernameOrEmail, password, options?).\n */\n authWithPassword(usernameOrEmail: string, password: string, body?: any, query?: any): Promise>\n\n authWithPassword(usernameOrEmail: string, password: string, bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': usernameOrEmail,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(usernameOrEmail, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(usernameOrEmail, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-password', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Authenticate a single auth collection record with OAuth2 code.\n *\n * If you don't have an OAuth2 code you may also want to check `authWithOAuth2` method.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n options?: RecordOptions,\n ): Promise>\n\n /**\n * @deprecated\n * Consider using authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createdData, options?).\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n body?: any,\n query?: any\n ): Promise>\n\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n bodyOrOptions?: any,\n query?: any\n ): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'provider': provider,\n 'code': code,\n 'codeVerifier': codeVerifier,\n 'redirectUrl': redirectUrl,\n 'createData': createData,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, body?, query?) is deprecated. Consider replacing it with authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-oauth2', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * @deprecated This form of authWithOAuth2 is deprecated.\n *\n * Please use `authWithOAuth2Code()` OR its simplified realtime version\n * as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\n */\n async authWithOAuth2(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key: string]: any},\n bodyParams?: {[key: string]: any},\n queryParams?: RecordOptions,\n ): Promise>\n\n /**\n * Authenticate a single auth collection record with OAuth2\n * **without custom redirects, deeplinks or even page reload**.\n *\n * This method initializes a one-off realtime subscription and will\n * open a popup window with the OAuth2 vendor page to authenticate.\n * Once the external OAuth2 sign-in/sign-up flow is completed, the popup\n * window will be automatically closed and the OAuth2 data sent back\n * to the user through the previously established realtime connection.\n *\n * You can specify an optional `urlCallback` prop to customize\n * the default url `window.open` behavior.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n *\n * Example:\n *\n * ```js\n * const authData = await pb.collection(\"users\").authWithOAuth2({\n * provider: \"google\",\n * })\n * ```\n *\n * _Site-note_: when creating the OAuth2 app in the provider dashboard\n * you have to configure `https://yourdomain.com/api/oauth2-redirect`\n * as redirect URL.\n */\n async authWithOAuth2(options: OAuth2AuthConfig): Promise>\n\n async authWithOAuth2(...args: any): Promise> {\n // fallback to legacy format\n if (args.length > 1 || typeof args?.[0] === 'string') {\n console.warn(\"PocketBase: This form of authWithOAuth2() is deprecated and may get removed in the future. Please replace with authWithOAuth2Code() OR use the authWithOAuth2() realtime form as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\");\n return this.authWithOAuth2Code(\n args?.[0] || '',\n args?.[1] || '',\n args?.[2] || '',\n args?.[3] || '',\n args?.[4] || {},\n args?.[5] || {},\n args?.[6] || {},\n );\n }\n\n const config = args?.[0] || {};\n\n const authMethods = await this.listAuthMethods();\n\n const provider = authMethods.authProviders.find((p) => p.name === config.provider);\n if (!provider) {\n throw new ClientResponseError(new Error(`Missing or invalid provider \"${config.provider}\".`));\n }\n\n const redirectUrl = this.client.buildUrl('/api/oauth2-redirect');\n\n // initialize a one-off realtime service\n const realtime = new RealtimeService(this.client);\n\n // open a new popup window in case config.urlCallback is not set\n //\n // note: it is opened before the async call due to Safari restrictions\n // (see https://github.com/pocketbase/pocketbase/discussions/2429#discussioncomment-5943061)\n let eagerDefaultPopup: Window|null = null;\n if (!config.urlCallback) {\n eagerDefaultPopup = openBrowserPopup(undefined);\n }\n\n function cleanup() {\n eagerDefaultPopup?.close();\n realtime.unsubscribe();\n }\n\n return new Promise(async (resolve, reject) => {\n try {\n await realtime.subscribe('@oauth2', async (e) => {\n const oldState = realtime.clientId;\n\n try {\n if (!e.state || oldState !== e.state) {\n throw new Error(\"State parameters don't match.\");\n }\n\n // clear the non SendOptions props\n const options = Object.assign({}, config);\n delete options.provider;\n delete options.scopes;\n delete options.createData;\n delete options.urlCallback;\n\n const authData = await this.authWithOAuth2Code(\n provider.name,\n e.code,\n provider.codeVerifier,\n redirectUrl,\n config.createData,\n options,\n );\n\n resolve(authData);\n } catch (err) {\n reject(new ClientResponseError(err));\n }\n\n cleanup();\n });\n\n const replacements: {[key: string]: any} = {\n \"state\": realtime.clientId,\n }\n if (config.scopes?.length) {\n replacements[\"scope\"] = config.scopes.join(\" \");\n }\n\n const url = this._replaceQueryParams(provider.authUrl + redirectUrl, replacements);\n\n let urlCallback = config.urlCallback || function (url: string) {\n if (eagerDefaultPopup) {\n eagerDefaultPopup.location.href = url;\n } else {\n // it could have been blocked due to its empty initial url,\n // try again...\n eagerDefaultPopup = openBrowserPopup(url);\n }\n }\n\n await urlCallback(url);\n } catch (err) {\n cleanup();\n reject(new ClientResponseError(err));\n }\n });\n }\n\n /**\n * Refreshes the current authenticated record instance and\n * returns a new token and record data.\n *\n * On success this method also automatically updates the client's AuthStore.\n */\n authRefresh(options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise>\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-refresh', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Sends auth record password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-password-reset', options).then(() => true);\n }\n\n /**\n * Confirms auth record password reset request.\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n options?: CommonOptions,\n ): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(passwordResetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n body?: any,\n query?: any,\n ): Promise\n\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': passwordResetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(token, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(token, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Sends auth record verification email request.\n */\n requestVerification(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestVerification(email, options?).\n */\n requestVerification(email: string, body?: any, query?: any): Promise\n\n requestVerification(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestVerification(email, body?, query?) is deprecated. Consider replacing it with requestVerification(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-verification', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record email verification request.\n */\n confirmVerification(verificationToken: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmVerification(verificationToken, options?).\n */\n confirmVerification(verificationToken: string, body?: any, query?: any): Promise\n\n confirmVerification(verificationToken: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': verificationToken,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmVerification(token, body?, query?) is deprecated. Consider replacing it with confirmVerification(token, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-verification', options)\n .then(() => true);\n }\n\n /**\n * Sends an email change request to the authenticated record model.\n */\n requestEmailChange(newEmail: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestEmailChange(newEmail, options?).\n */\n requestEmailChange(newEmail: string, body?: any, query?: any): Promise\n\n requestEmailChange(newEmail: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'newEmail': newEmail,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestEmailChange(newEmail, body?, query?) is deprecated. Consider replacing it with requestEmailChange(newEmail, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-email-change', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record's new email address.\n */\n confirmEmailChange(emailChangeToken: string, password: string, options?: CommonOptions): Promise\n\n\n /**\n * @deprecated\n * Consider using confirmEmailChange(emailChangeToken, password, options?).\n */\n confirmEmailChange(emailChangeToken: string, password: string, body?: any, query?: any): Promise\n\n confirmEmailChange(emailChangeToken: string, password: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': emailChangeToken,\n 'password': password,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmEmailChange(token, password, body?, query?) is deprecated. Consider replacing it with confirmEmailChange(token, password, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-email-change', options)\n .then(() => true);\n }\n\n /**\n * Lists all linked external auth providers for the specified auth record.\n */\n listExternalAuths(recordId: string, options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths', options);\n }\n\n /**\n * Unlink a single external auth provider from the specified auth record.\n */\n unlinkExternalAuth(recordId: string, provider: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths/' + encodeURIComponent(provider), options)\n .then(() => true);\n }\n\n // ---------------------------------------------------------------\n\n // very rudimentary url query params replacement because at the moment\n // URL (and URLSearchParams) doesn't seem to be fully supported in React Native\n //\n // note: for details behind some of the decode/encode parsing check https://unixpapa.com/js/querystring.html\n private _replaceQueryParams(url: string, replacements: {[key: string]: any} = {}): string {\n let urlPath = url\n let query = \"\";\n\n const queryIndex = url.indexOf(\"?\");\n if (queryIndex >= 0) {\n urlPath = url.substring(0, url.indexOf(\"?\"));\n query = url.substring(url.indexOf(\"?\") + 1);\n }\n\n const parsedParams: {[key: string]: string} = {};\n\n // parse the query parameters\n const rawParams = query.split(\"&\");\n for (const param of rawParams) {\n if (param == \"\") {\n continue\n }\n\n const pair = param.split(\"=\");\n parsedParams[decodeURIComponent(pair[0].replace(/\\+/g,' '))] = decodeURIComponent((pair[1] || \"\").replace(/\\+/g,' '));\n }\n\n // apply the replacements\n for (let key in replacements) {\n if (!replacements.hasOwnProperty(key)) {\n continue;\n }\n\n if (replacements[key] == null) {\n delete parsedParams[key];\n } else {\n parsedParams[key] = replacements[key];\n }\n }\n\n // construct back the full query string\n query = \"\";\n for (let key in parsedParams) {\n if (!parsedParams.hasOwnProperty(key)) {\n continue;\n }\n\n if (query != \"\") {\n query += \"&\";\n }\n\n query += encodeURIComponent(key.replace(/%20/g,'+')) + \"=\" + encodeURIComponent(parsedParams[key].replace(/%20/g,'+'));\n }\n\n return query != \"\" ? (urlPath + \"?\" + query) : urlPath;\n }\n}\n\nfunction openBrowserPopup(url?: string): Window|null {\n if (typeof window === \"undefined\" || !window?.open) {\n throw new ClientResponseError(new Error(`Not in a browser context - please pass a custom urlCallback function.`));\n }\n\n let width = 1024;\n let height = 768;\n\n let windowWidth = window.innerWidth;\n let windowHeight = window.innerHeight;\n\n // normalize window size\n width = width > windowWidth ? windowWidth : width;\n height = height > windowHeight ? windowHeight : height;\n\n let left = (windowWidth / 2) - (width / 2);\n let top = (windowHeight / 2) - (height / 2);\n\n // note: we don't use the noopener and noreferrer attributes since\n // for some reason browser blocks such windows then url is undefined/blank\n return window.open(\n url,\n 'popup_window',\n 'width='+width+',height='+height+',top='+top+',left='+left+',resizable,menubar=no'\n );\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { CollectionModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport class CollectionService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/collections';\n }\n\n /**\n * Imports the provided collections.\n *\n * If `deleteMissing` is `true`, all local collections and schema fields,\n * that are not present in the imported configuration, WILL BE DELETED\n * (including their related records data)!\n */\n async import(\n collections: Array,\n deleteMissing: boolean = false,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PUT',\n 'body': {\n 'collections': collections,\n 'deleteMissing': deleteMissing,\n }\n }, options);\n\n return this.client.send(this.baseCrudPath + '/import', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ListResult, LogRequestModel } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n LogStatsOptions,\n} from '@/services/utils/options';\n\nexport interface HourlyStats {\n total: number;\n date: string;\n}\n\nexport class LogService extends BaseService {\n /**\n * Returns paginated logged requests list.\n */\n getRequestsList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({'method': 'GET'}, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send('/api/logs/requests', options);\n }\n\n /**\n * Returns a single logged request by its id.\n */\n getRequest(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/' + encodeURIComponent(id), options);\n }\n\n /**\n * Returns request logs statistics.\n */\n getRequestsStats(options?: LogStatsOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/stats', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface HealthCheckResponse {\n code: number;\n message: string;\n data: {[key: string]: any};\n}\n\nexport class HealthService extends BaseService {\n /**\n * Checks the health status of the api.\n */\n check(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/health', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions, FileOptions } from '@/services/utils/options';\n\nexport class FileService extends BaseService {\n /**\n * Builds and returns an absolute record file url for the provided filename.\n */\n getUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n if (\n !filename ||\n !record?.id ||\n !(record?.collectionId || record?.collectionName)\n ) {\n return '';\n }\n\n const parts = [];\n parts.push('api')\n parts.push('files')\n parts.push(encodeURIComponent(record.collectionId || record.collectionName))\n parts.push(encodeURIComponent(record.id))\n parts.push(encodeURIComponent(filename))\n\n let result = this.client.buildUrl(parts.join('/'));\n\n if (Object.keys(queryParams).length) {\n // normalize the download query param for consistency with the Dart sdk\n if (queryParams.download === false) {\n delete(queryParams.download);\n }\n\n const params = new URLSearchParams(queryParams);\n\n result += (result.includes('?') ? '&' : '?') + params;\n }\n\n return result\n }\n\n /**\n * Requests a new private file access token for the current auth model (admin or record).\n */\n getToken(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send('/api/files/token', options)\n .then((data) => data?.token || '');\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface BackupFileInfo {\n key: string;\n size: number;\n modified: string;\n}\n\nexport class BackupService extends BaseService {\n /**\n * Returns list with all available backup files.\n */\n getFullList(options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/backups', options);\n }\n\n /**\n * Initializes a new backup.\n */\n create(basename: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'name': basename,\n },\n }, options);\n\n return this.client.send('/api/backups', options)\n .then(() => true);\n }\n\n /**\n * Deletes a single backup file.\n */\n delete(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}`, options)\n .then(() => true);\n }\n\n /**\n * Initializes an app data restore from an existing backup.\n */\n restore(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}/restore`, options)\n .then(() => true);\n }\n\n /**\n * Builds a download url for a single existing backup using an\n * admin file token and the backup file key.\n *\n * The file token can be generated via `pb.files.getToken()`.\n */\n getDownloadUrl(token: string, key: string): string {\n return this.client.buildUrl(`/api/backups/${encodeURIComponent(key)}?token=${encodeURIComponent(token)}`);\n }\n}\n","import { ClientResponseError } from '@/ClientResponseError';\nimport { BaseAuthStore } from '@/stores/BaseAuthStore';\nimport { LocalAuthStore } from '@/stores/LocalAuthStore';\nimport { SettingsService } from '@/services/SettingsService';\nimport { AdminService } from '@/services/AdminService';\nimport { RecordService } from '@/services/RecordService';\nimport { CollectionService } from '@/services/CollectionService';\nimport { LogService } from '@/services/LogService';\nimport { RealtimeService } from '@/services/RealtimeService';\nimport { HealthService } from '@/services/HealthService';\nimport { FileService } from '@/services/FileService';\nimport { BackupService } from '@/services/BackupService';\nimport { SendOptions, FileOptions } from '@/services/utils/options';\n\n// list of known SendOptions keys (everything else is treated as query param)\nconst knownSendOptionsKeys = [\n 'requestKey',\n '$cancelKey',\n '$autoCancel',\n 'fetch',\n 'headers',\n 'body',\n 'query',\n 'params',\n // ---,\n 'cache',\n 'credentials',\n 'headers',\n 'integrity',\n 'keepalive',\n 'method',\n 'mode',\n 'redirect',\n 'referrer',\n 'referrerPolicy',\n 'signal',\n 'window',\n];\n\nexport interface BeforeSendResult {\n [key: string]: any, // for backward compatibility\n url?: string,\n options?: {[key: string]: any}\n}\n\n/**\n * PocketBase JS Client.\n */\nexport default class Client {\n /**\n * The base PocketBase backend url address (eg. 'http://127.0.0.1.8090').\n */\n baseUrl: string;\n\n /**\n * Hook that get triggered right before sending the fetch request,\n * allowing you to inspect and modify the url and request options.\n *\n * For list of the possible options check https://developer.mozilla.org/en-US/docs/Web/API/fetch#options\n *\n * You can return a non-empty result object `{ url, options }` to replace the url and request options entirely.\n *\n * Example:\n * ```js\n * client.beforeSend = function (url, options) {\n * options.headers = Object.assign({}, options.headers, {\n * 'X-Custom-Header': 'example',\n * });\n *\n * return { url, options }\n * };\n * ```\n */\n beforeSend?: (url: string, options: SendOptions) => BeforeSendResult|Promise;\n\n /**\n * Hook that get triggered after successfully sending the fetch request,\n * allowing you to inspect/modify the response object and its parsed data.\n *\n * Returns the new Promise resolved `data` that will be returned to the client.\n *\n * Example:\n * ```js\n * client.afterSend = function (response, data) {\n * if (response.status != 200) {\n * throw new ClientResponseError({\n * url: response.url,\n * status: response.status,\n * data: data,\n * });\n * }\n *\n * return data;\n * };\n * ```\n */\n afterSend?: (response: Response, data: any) => any;\n\n /**\n * Optional language code (default to `en-US`) that will be sent\n * with the requests to the server as `Accept-Language` header.\n */\n lang: string;\n\n /**\n * A replaceable instance of the local auth store service.\n */\n authStore: BaseAuthStore;\n\n /**\n * An instance of the service that handles the **Settings APIs**.\n */\n readonly settings: SettingsService;\n\n /**\n * An instance of the service that handles the **Admin APIs**.\n */\n readonly admins: AdminService;\n\n /**\n * An instance of the service that handles the **Collection APIs**.\n */\n readonly collections: CollectionService;\n\n /**\n * An instance of the service that handles the **File APIs**.\n */\n readonly files: FileService;\n\n /**\n * An instance of the service that handles the **Log APIs**.\n */\n readonly logs: LogService;\n\n /**\n * An instance of the service that handles the **Realtime APIs**.\n */\n readonly realtime: RealtimeService;\n\n /**\n * An instance of the service that handles the **Health APIs**.\n */\n readonly health: HealthService;\n\n /**\n * An instance of the service that handles the **Backup APIs**.\n */\n readonly backups: BackupService;\n\n private cancelControllers: { [key: string]: AbortController } = {};\n private recordServices: { [key: string]: RecordService } = {};\n private enableAutoCancellation: boolean = true;\n\n constructor(\n baseUrl = '/',\n authStore?: BaseAuthStore | null,\n lang = 'en-US',\n ) {\n this.baseUrl = baseUrl;\n this.lang = lang;\n this.authStore = authStore || new LocalAuthStore();\n\n // services\n this.admins = new AdminService(this);\n this.collections = new CollectionService(this);\n this.files = new FileService(this);\n this.logs = new LogService(this);\n this.settings = new SettingsService(this);\n this.realtime = new RealtimeService(this);\n this.health = new HealthService(this);\n this.backups = new BackupService(this);\n }\n\n /**\n * Returns the RecordService associated to the specified collection.\n *\n * @param {string} idOrName\n * @return {RecordService}\n */\n collection(idOrName: string): RecordService {\n if (!this.recordServices[idOrName]) {\n this.recordServices[idOrName] = new RecordService(this, idOrName);\n }\n\n return this.recordServices[idOrName];\n }\n\n /**\n * Globally enable or disable auto cancellation for pending duplicated requests.\n */\n autoCancellation(enable: boolean): Client {\n this.enableAutoCancellation = !!enable;\n\n return this;\n }\n\n /**\n * Cancels single request by its cancellation key.\n */\n cancelRequest(requestKey: string): Client {\n if (this.cancelControllers[requestKey]) {\n this.cancelControllers[requestKey].abort();\n delete this.cancelControllers[requestKey];\n }\n\n return this;\n }\n\n /**\n * Cancels all pending requests.\n */\n cancelAllRequests(): Client {\n for (let k in this.cancelControllers) {\n this.cancelControllers[k].abort();\n }\n\n this.cancelControllers = {};\n\n return this;\n }\n\n /**\n * Legacy alias of `pb.files.getUrl()`.\n */\n getFileUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n return this.files.getUrl(record, filename, queryParams);\n }\n\n /**\n * Builds a full client url by safely concatenating the provided path.\n */\n buildUrl(path: string): string {\n let url = this.baseUrl;\n\n // construct an absolute base url if in a browser environment\n if (\n typeof window !== 'undefined' &&\n !!window.location &&\n !url.startsWith('https://') &&\n !url.startsWith('http://')\n ) {\n url = window.location.origin?.endsWith('/') ?\n window.location.origin.substring(0, window.location.origin.length - 1) :\n (window.location.origin || '');\n\n if (!this.baseUrl.startsWith('/')) {\n url += window.location.pathname || '/';\n url += url.endsWith('/') ? '' : '/';\n }\n\n url += this.baseUrl;\n }\n\n // concatenate the path\n if (path) {\n url += url.endsWith('/') ? '' : '/'; // append trailing slash if missing\n url += path.startsWith('/') ? path.substring(1) : path;\n }\n\n return url;\n }\n\n /**\n * Sends an api http request.\n */\n async send(path: string, options: SendOptions): Promise {\n options = this.initSendOptions(path, options);\n\n // build url + path\n let url = this.buildUrl(path);\n\n // serialize the query parameters\n if (typeof options.query !== 'undefined') {\n const query = this.serializeQueryParams(options.query)\n if (query) {\n url += (url.includes('?') ? '&' : '?') + query;\n }\n delete options.query;\n }\n\n if (this.beforeSend) {\n const result = Object.assign({}, await this.beforeSend(url, options));\n if (typeof result.url !== 'undefined' || typeof result.options !== 'undefined') {\n url = result.url || url;\n options = result.options || options;\n } else if (Object.keys(result).length) {\n // legacy behavior\n options = result as SendOptions;\n console?.warn && console.warn('Deprecated format of beforeSend return: please use `return { url, options }`, instead of `return options`.');\n }\n }\n\n // ensures that the json body is serialized\n if (\n this.getHeader(options.headers, 'Content-Type') == 'application/json' &&\n options.body && typeof options.body !== 'string'\n ) {\n options.body = JSON.stringify(options.body);\n }\n\n const fetchFunc = options.fetch || fetch;\n\n // send the request\n return fetchFunc(url, options)\n .then(async (response) => {\n let data : any = {};\n\n try {\n data = await response.json();\n } catch (_) {\n // all api responses are expected to return json\n // with the exception of the realtime event and 204\n }\n\n if (this.afterSend) {\n data = await this.afterSend(response, data);\n }\n\n if (response.status >= 400) {\n throw new ClientResponseError({\n url: response.url,\n status: response.status,\n data: data,\n });\n }\n\n return data as T;\n }).catch((err) => {\n // wrap to normalize all errors\n throw new ClientResponseError(err);\n });\n }\n\n /**\n * Shallow copy the provided object and takes care to initialize\n * any options required to preserve the backward compatability.\n *\n * @param {SendOptions} options\n * @return {SendOptions}\n */\n private initSendOptions(path: string, options: SendOptions): SendOptions {\n options = Object.assign({ method: 'GET' } as SendOptions, options)\n options.query = options.query || {};\n\n // auto convert the body to FormData, if needed\n options.body = this.convertToFormDataIfNeeded(options.body);\n\n // move unknown send options as query parameters\n for (let key in options) {\n if (knownSendOptionsKeys.includes(key)) {\n continue\n }\n\n options.query[key] = options[key];\n delete (options[key]);\n }\n\n // requestKey normalizations for backward-compatibility\n // ---\n options.query = Object.assign({}, options.params, options.query);\n if (typeof options.requestKey === 'undefined') {\n if (options.$autoCancel === false || options.query.$autoCancel === false) {\n options.requestKey = null;\n } else if (options.$cancelKey || options.query.$cancelKey) {\n options.requestKey = options.$cancelKey || options.query.$cancelKey;\n }\n }\n // remove the deprecated special cancellation params from the other query params\n delete options.$autoCancel;\n delete options.query.$autoCancel;\n delete options.$cancelKey;\n delete options.query.$cancelKey;\n // ---\n\n // add the json header, if not explicitly set\n // (for FormData body the Content-Type header should be skipped since the boundary is autogenerated)\n if (\n this.getHeader(options.headers, 'Content-Type') === null &&\n !this.isFormData(options.body)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Content-Type': 'application/json',\n });\n }\n\n // add Accept-Language header, if not explicitly set\n if (this.getHeader(options.headers, 'Accept-Language') === null) {\n options.headers = Object.assign({}, options.headers, {\n 'Accept-Language': this.lang,\n });\n }\n\n // check if Authorization header can be added\n if (\n // has valid token\n this.authStore.token &&\n // auth header is not explicitly set\n (this.getHeader(options.headers, 'Authorization') === null)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Authorization': this.authStore.token,\n });\n }\n\n // handle auto cancelation for duplicated pending request\n if (this.enableAutoCancellation && options.requestKey !== null) {\n const requestKey = options.requestKey || ((options.method || 'GET') + path);\n\n delete options.requestKey;\n\n // cancel previous pending requests\n this.cancelRequest(requestKey);\n\n const controller = new AbortController();\n this.cancelControllers[requestKey] = controller;\n options.signal = controller.signal;\n }\n\n return options\n }\n\n /**\n * Converts analyzes the provided body and converts it to FormData\n * in case a plain object with File/Blob values is used.\n */\n private convertToFormDataIfNeeded(body: any): any {\n if (\n typeof FormData === 'undefined' ||\n typeof body === \"undefined\" ||\n typeof body !== \"object\" ||\n body === null ||\n this.isFormData(body) ||\n !this.hasBlobField(body)\n ) {\n return body;\n }\n\n const form = new FormData();\n\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let val of values) {\n form.append(key, val);\n }\n }\n\n return form;\n }\n\n /**\n * Checks if the submitted body object has at least one Blob/File field.\n */\n private hasBlobField(body: {[key:string]: any}): boolean {\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let v of values) {\n if (\n (typeof Blob !== 'undefined' && v instanceof Blob) ||\n (typeof File !== 'undefined' && v instanceof File)\n ) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /**\n * Extracts the header with the provided name in case-insensitive manner.\n * Returns `null` if no header matching the name is found.\n */\n private getHeader(headers: {[key:string]:string}|undefined, name: string): string|null {\n headers = headers || {};\n name = name.toLowerCase();\n\n for (let key in headers) {\n if (key.toLowerCase() == name) {\n return headers[key];\n }\n }\n\n return null;\n }\n\n /**\n * Loosely checks if the specified body is a FormData instance.\n */\n private isFormData(body: any): boolean {\n return body && (\n // we are checking the constructor name because FormData\n // is not available natively in some environments and the\n // polyfill(s) may not be globally accessible\n body.constructor.name === 'FormData' ||\n // fallback to global FormData instance check\n // note: this is needed because the constructor.name could be different in case of\n // custom global FormData implementation, eg. React Native on Android/iOS\n (typeof FormData !== 'undefined' && body instanceof FormData)\n )\n }\n\n /**\n * Serializes the provided query parameters into a query string.\n */\n private serializeQueryParams(params: {[key: string]: any}): string {\n const result: Array = [];\n for (const key in params) {\n if (params[key] === null) {\n // skip null query params\n continue;\n }\n\n const value = params[key];\n const encodedKey = encodeURIComponent(key);\n\n if (Array.isArray(value)) {\n // repeat array params\n for (const v of value) {\n result.push(encodedKey + '=' + encodeURIComponent(v));\n }\n } else if (value instanceof Date) {\n result.push(encodedKey + '=' + encodeURIComponent(value.toISOString()));\n } else if (typeof value !== null && typeof value === 'object') {\n result.push(encodedKey + '=' + encodeURIComponent(JSON.stringify(value)));\n } else {\n result.push(encodedKey + '=' + encodeURIComponent(value));\n }\n }\n\n return result.join('&');\n }\n}\n"],"names":["ClientResponseError","Error","constructor","errData","super","this","url","status","response","isAbort","originalError","Object","setPrototypeOf","prototype","data","DOMException","name","message","_a","_d","_c","_b","cause","includes","toJSON","assign","fieldContentRegExp","cookieSerialize","val","options","opt","encode","defaultEncode","test","TypeError","value","result","maxAge","isNaN","isFinite","Math","floor","domain","path","expires","isDate","toString","call","Date","valueOf","toUTCString","httpOnly","secure","priority","toLowerCase","sameSite","defaultDecode","indexOf","decodeURIComponent","encodeURIComponent","atobPolyfill","getTokenPayload","token","encodedPayload","split","map","c","charCodeAt","slice","join","JSON","parse","e","atob","input","str","String","replace","length","bs","buffer","bc","idx","output","charAt","fromCharCode","defaultCookieKey","BaseAuthStore","baseToken","baseModel","_onChangeCallbacks","model","isValid","isTokenExpired","expirationThreshold","payload","keys","exp","now","isAdmin","type","isAuthRecord","save","triggerChange","clear","loadFromCookie","cookie","key","rawData","cookieParse","decode","index","eqIdx","endIdx","lastIndexOf","trim","undefined","_","Array","isArray","exportToCookie","defaultOptions","stringify","resultLength","Blob","size","id","email","extraProps","prop","onChange","callback","fireImmediately","push","i","splice","LocalAuthStore","storageKey","storageFallback","_bindStorageEvent","_storageGet","_storageSet","_storageRemove","window","localStorage","rawValue","getItem","normalizedVal","setItem","removeItem","addEventListener","BaseService","client","SettingsService","getAll","method","send","update","bodyParams","body","testS3","filesystem","then","testEmail","toEmail","emailTemplate","template","generateAppleClientSecret","clientId","teamId","keyId","privateKey","duration","CrudService","getFullList","batchOrqueryParams","_getFullList","batch","getList","page","perPage","query","baseCrudPath","responseData","items","item","getFirstListItem","filter","requestKey","skipTotal","code","getOne","create","batchSize","request","__awaiter","list","concat","normalizeLegacyOptionsArgs","legacyWarn","baseOptions","bodyOrOptions","hasQuery","console","warn","AdminService","authStore","collectionId","delete","success","authResponse","admin","authWithPassword","password","identity","bind","authRefresh","requestPasswordReset","confirmPasswordReset","resetToken","passwordConfirm","RealtimeService","eventSource","subscriptions","lastSentTopics","maxConnectTimeout","reconnectAttempts","maxReconnectAttempts","Infinity","predefinedReconnectIntervals","pendingConnects","isConnected","subscribe","topic","listener","msgEvent","submitSubscriptions","connect","unsubscribeByTopicAndListener","unsubscribe","hasSubscriptionListeners","removeEventListener","disconnect","unsubscribeByPrefix","topicPrefix","hasAtleastOneTopic","startsWith","exist","topicToCheck","addAllSubscriptionListeners","getNonEmptySubscriptionTopics","getSubscriptionsCancelKey","catch","err","removeAllSubscriptionListeners","Promise","resolve","reject","initConnect","clearTimeout","connectTimeoutId","setTimeout","connectErrorHandler","EventSource","buildUrl","onerror","lastEventId","retries","hasUnsentSubscriptions","p","reconnectTimeoutId","latestTopics","t","timeout","fromReconnect","cancelRequest","close","RecordService","collectionIdOrName","baseCollectionPath","subscribeOne","recordId","realtime","topicOrCallback","batchOrOptions","params","collectionName","record","listAuthMethods","usernamePassword","emailPassword","authProviders","usernameOrEmail","authWithOAuth2Code","provider","codeVerifier","redirectUrl","createData","authWithOAuth2","args","config","find","eagerDefaultPopup","cleanup","urlCallback","openBrowserPopup","oldState","state","scopes","authData","replacements","_replaceQueryParams","authUrl","location","href","passwordResetToken","requestVerification","confirmVerification","verificationToken","requestEmailChange","newEmail","confirmEmailChange","emailChangeToken","listExternalAuths","unlinkExternalAuth","urlPath","substring","parsedParams","rawParams","param","pair","hasOwnProperty","open","width","height","windowWidth","innerWidth","windowHeight","innerHeight","left","top","CollectionService","import","collections","deleteMissing","LogService","getRequestsList","getRequest","getRequestsStats","HealthService","check","FileService","getUrl","filename","queryParams","parts","download","URLSearchParams","getToken","BackupService","basename","restore","getDownloadUrl","knownSendOptionsKeys","Client","baseUrl","lang","cancelControllers","recordServices","enableAutoCancellation","admins","files","logs","settings","health","backups","collection","idOrName","autoCancellation","enable","abort","cancelAllRequests","k","getFileUrl","origin","endsWith","pathname","initSendOptions","serializeQueryParams","beforeSend","getHeader","headers","fetch","json","afterSend","convertToFormDataIfNeeded","$autoCancel","$cancelKey","isFormData","Authorization","controller","AbortController","signal","FormData","hasBlobField","form","values","append","v","File","encodedKey","toISOString"],"mappings":"yaAIM,MAAOA,4BAA4BC,MAOrC,WAAAC,CAAYC,eACRC,MAAM,uBAPVC,KAAGC,IAA8B,GACjCD,KAAME,OAA2B,EACjCF,KAAQG,SAAyB,GACjCH,KAAOI,SAA0B,EACjCJ,KAAaK,cAAoB,KAO7BC,OAAOC,eAAeP,KAAML,oBAAoBa,WAEhC,OAAZV,GAAuC,iBAAZA,IAC3BE,KAAKC,IAAuC,iBAAhBH,EAAQG,IAAmBH,EAAQG,IAAM,GACrED,KAAKE,OAA0C,iBAAnBJ,EAAQI,OAAsBJ,EAAQI,OAAS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rB,OAAOuX,EAAQ5R,GAIvB,OAAO,IACV,CAKO,UAAAmS,CAAW/O,GACf,OAAOA,IAIuB,aAA1BA,EAAK7J,YAAYc,MAII,oBAAbmY,UAA4BpP,aAAgBoP,SAE3D,CAKO,oBAAAf,CAAqBvG,GACzB,MAAMzP,EAAwB,GAC9B,IAAK,MAAMuE,KAAOkL,EAAQ,CACtB,GAAoB,OAAhBA,EAAOlL,GAEP,SAGJ,MAAMxE,EAAQ0P,EAAOlL,GACf+S,EAAa/V,mBAAmBgD,GAEtC,GAAIW,MAAMC,QAAQpF,GAEd,IAAK,MAAMqX,KAAKrX,EACZC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmB6V,SAE/CrX,aAAiBa,KACxBZ,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBxB,EAAMwX,gBAChC,cAAVxX,GAAmC,iBAAVA,EACvCC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBW,KAAKoD,UAAUvF,KAEjEC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBxB,GAEzD,CAED,OAAOC,EAAOiC,KAAK,IACtB"} \ No newline at end of file diff --git a/dist/pocketbase.es.d.mts b/dist/pocketbase.es.d.mts index b4ddb05..055a34d 100644 --- a/dist/pocketbase.es.d.mts +++ b/dist/pocketbase.es.d.mts @@ -1024,9 +1024,9 @@ declare class Client { /** * Legacy alias of `pb.files.getUrl()`. */ - getFileUrl(record: Pick<{ + getFileUrl(record: { [key: string]: any; - }, "id" | "collectionId" | "collectionName">, filename: string, queryParams?: FileOptions): string; + }, filename: string, queryParams?: FileOptions): string; /** * Builds a full client url by safely concatenating the provided path. */ diff --git a/dist/pocketbase.es.d.ts b/dist/pocketbase.es.d.ts index b4ddb05..055a34d 100644 --- a/dist/pocketbase.es.d.ts +++ b/dist/pocketbase.es.d.ts @@ -1024,9 +1024,9 @@ declare class Client { /** * Legacy alias of `pb.files.getUrl()`. */ - getFileUrl(record: Pick<{ + getFileUrl(record: { [key: string]: any; - }, "id" | "collectionId" | "collectionName">, filename: string, queryParams?: FileOptions): string; + }, filename: string, queryParams?: FileOptions): string; /** * Builds a full client url by safely concatenating the provided path. */ diff --git a/dist/pocketbase.es.js.map b/dist/pocketbase.es.js.map index 021d590..c6303ae 100644 --- a/dist/pocketbase.es.js.map +++ b/dist/pocketbase.es.js.map @@ -1 +1 @@ -{"version":3,"file":"pocketbase.es.js","sources":["../src/ClientResponseError.ts","../src/stores/utils/cookie.ts","../src/stores/utils/jwt.ts","../src/stores/BaseAuthStore.ts","../src/stores/LocalAuthStore.ts","../src/services/utils/BaseService.ts","../src/services/SettingsService.ts","../src/services/utils/CrudService.ts","../src/services/utils/legacy.ts","../src/services/AdminService.ts","../src/services/RealtimeService.ts","../src/services/RecordService.ts","../src/services/CollectionService.ts","../src/services/LogService.ts","../src/services/HealthService.ts","../src/services/FileService.ts","../src/services/BackupService.ts","../src/Client.ts","../src/stores/AsyncAuthStore.ts"],"sourcesContent":["/**\n * ClientResponseError is a custom Error class that is intended to wrap\n * and normalize any error thrown by `Client.send()`.\n */\nexport class ClientResponseError extends Error {\n url: string = '';\n status: number = 0;\n response: {[key: string]: any} = {};\n isAbort: boolean = false;\n originalError: any = null;\n\n constructor(errData?: any) {\n super(\"ClientResponseError\");\n\n // Set the prototype explicitly.\n // https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\n Object.setPrototypeOf(this, ClientResponseError.prototype);\n\n if (errData !== null && typeof errData === 'object') {\n this.url = typeof errData.url === 'string' ? errData.url : '';\n this.status = typeof errData.status === 'number' ? errData.status : 0;\n this.isAbort = !!errData.isAbort;\n this.originalError = errData.originalError;\n\n if (errData.response !== null && typeof errData.response === 'object') {\n this.response = errData.response;\n } else if (errData.data !== null && typeof errData.data === 'object') {\n this.response = errData.data;\n } else {\n this.response = {};\n }\n }\n\n if (!this.originalError && !(errData instanceof ClientResponseError)) {\n this.originalError = errData;\n }\n\n if (typeof DOMException !== 'undefined' && errData instanceof DOMException) {\n this.isAbort = true;\n }\n\n this.name = \"ClientResponseError \" + this.status;\n this.message = this.response?.message;\n if (!this.message) {\n if (this.isAbort) {\n this.message = 'The request was autocancelled. You can find more info in https://github.com/pocketbase/js-sdk#auto-cancellation.';\n } else if (this.originalError?.cause?.message?.includes(\"ECONNREFUSED ::1\")) {\n this.message = 'Failed to connect to the PocketBase server. Try changing the SDK URL from localhost to 127.0.0.1 (https://github.com/pocketbase/js-sdk/issues/21).';\n } else {\n this.message = 'Something went wrong while processing your request.';\n }\n }\n }\n\n /**\n * Alias for `this.response` to preserve the backward compatibility.\n */\n get data() {\n return this.response;\n }\n\n /**\n * Make a POJO's copy of the current error class instance.\n * @see https://github.com/vuex-orm/vuex-orm/issues/255\n */\n toJSON() {\n return { ...this };\n }\n}\n","/**\n * -------------------------------------------------------------------\n * Simple cookie parse and serialize utilities mostly based on the\n * node module https://github.com/jshttp/cookie.\n * -------------------------------------------------------------------\n */\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\nconst fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;\n\nexport interface ParseOptions{\n decode?: (val: string) => string,\n}\n\n/**\n* Parses the given cookie header string into an object\n* The object has the various cookies as keys(names) => values\n*/\nexport function cookieParse(str: string, options?: ParseOptions): { [key: string]: any } {\n const result: { [key: string]: any } = {};\n\n if (typeof str !== 'string') {\n return result;\n }\n\n const opt = Object.assign({}, options || {});\n const decode = opt.decode || defaultDecode;\n\n let index = 0;\n while (index < str.length) {\n const eqIdx = str.indexOf('=', index);\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break;\n }\n\n let endIdx = str.indexOf(';', index);\n\n if (endIdx === -1) {\n endIdx = str.length;\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(';', eqIdx - 1) + 1;\n continue;\n }\n\n const key = str.slice(index, eqIdx).trim();\n\n // only assign once\n if (undefined === result[key]) {\n let val = str.slice(eqIdx + 1, endIdx).trim();\n\n // quoted values\n if (val.charCodeAt(0) === 0x22) {\n val = val.slice(1, -1);\n }\n\n try {\n result[key] = decode(val);\n } catch (_) {\n result[key] = val; // no decoding\n }\n }\n\n index = endIdx + 1;\n }\n\n return result;\n};\n\nexport interface SerializeOptions {\n encode?: (val: string | number | boolean) => string,\n maxAge?: number,\n domain?: string,\n path?: string,\n expires?: Date,\n httpOnly?: boolean,\n secure?: boolean,\n priority?: string,\n sameSite?: boolean|string,\n}\n\n/**\n * Serialize data into a cookie header.\n *\n * Serialize the a name value pair into a cookie string suitable for\n * http headers. An optional options object specified cookie parameters.\n *\n * ```js\n * cookieSerialize('foo', 'bar', { httpOnly: true }) // \"foo=bar; httpOnly\"\n * ```\n */\nexport function cookieSerialize(name: string, val: string, options?: SerializeOptions): string {\n const opt = Object.assign({}, options || {});\n const encode = opt.encode || defaultEncode;\n\n if (!fieldContentRegExp.test(name)) {\n throw new TypeError('argument name is invalid');\n }\n\n const value = encode(val);\n\n if (value && !fieldContentRegExp.test(value)) {\n throw new TypeError('argument val is invalid');\n }\n\n let result = name + '=' + value;\n\n if (opt.maxAge != null) {\n const maxAge = opt.maxAge - 0;\n\n if (isNaN(maxAge) || !isFinite(maxAge)) {\n throw new TypeError('option maxAge is invalid');\n }\n\n result += '; Max-Age=' + Math.floor(maxAge);\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new TypeError('option domain is invalid');\n }\n\n result += '; Domain=' + opt.domain;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new TypeError('option path is invalid');\n }\n\n result += '; Path=' + opt.path;\n }\n\n if (opt.expires) {\n if (!isDate(opt.expires) || isNaN(opt.expires.valueOf())) {\n throw new TypeError('option expires is invalid');\n }\n\n result += '; Expires=' + opt.expires.toUTCString();\n }\n\n if (opt.httpOnly) {\n result += '; HttpOnly';\n }\n\n if (opt.secure) {\n result += '; Secure';\n }\n\n if (opt.priority) {\n const priority = typeof opt.priority === 'string' ? opt.priority.toLowerCase() : opt.priority;\n\n switch (priority) {\n case 'low':\n result += '; Priority=Low';\n break;\n case 'medium':\n result += '; Priority=Medium';\n break;\n case 'high':\n result += '; Priority=High';\n break;\n default:\n throw new TypeError('option priority is invalid');\n }\n }\n\n if (opt.sameSite) {\n const sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;\n\n switch (sameSite) {\n case true:\n result += '; SameSite=Strict';\n break;\n case 'lax':\n result += '; SameSite=Lax';\n break;\n case 'strict':\n result += '; SameSite=Strict';\n break;\n case 'none':\n result += '; SameSite=None';\n break;\n default:\n throw new TypeError('option sameSite is invalid');\n }\n }\n\n return result;\n};\n\n/**\n * Default URL-decode string value function.\n * Optimized to skip native call when no `%`.\n */\nfunction defaultDecode(val: string): string {\n return val.indexOf('%') !== -1\n ? decodeURIComponent(val)\n : val;\n}\n\n/**\n * Default URL-encode value function.\n */\nfunction defaultEncode(val: string | number | boolean): string {\n return encodeURIComponent(val);\n}\n\n/**\n * Determines if value is a Date.\n */\nfunction isDate(val: any): boolean {\n return (\n Object.prototype.toString.call(val) === '[object Date]' ||\n val instanceof Date\n );\n}\n","let atobPolyfill: Function;\nif (typeof atob === 'function') {\n atobPolyfill = atob\n} else {\n /**\n * The code was extracted from:\n * https://github.com/davidchambers/Base64.js\n */\n atobPolyfill = (input: any) => {\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\n let str = String(input).replace(/=+$/, \"\");\n if (str.length % 4 == 1) {\n throw new Error(\"'atob' failed: The string to be decoded is not correctly encoded.\");\n }\n\n for (\n // initialize result and counters\n var bc = 0, bs, buffer, idx = 0, output = \"\";\n // get next character\n (buffer = str.charAt(idx++));\n // character found in table? initialize bit storage and add its ascii value;\n ~buffer &&\n ((bs = bc % 4 ? (bs as any) * 64 + buffer : buffer),\n // and if not first of each 4 characters,\n // convert the first 8 bits to one ascii character\n bc++ % 4) ?\n (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)))) :\n 0\n ) {\n // try to find character in table (0-63, not found => -1)\n buffer = chars.indexOf(buffer);\n }\n\n return output;\n };\n}\n\n/**\n * Returns JWT token's payload data.\n */\nexport function getTokenPayload(token: string): { [key: string]: any } {\n if (token) {\n try {\n const encodedPayload = decodeURIComponent(atobPolyfill(token.split('.')[1]).split('').map(function (c: string) {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n }).join(''));\n\n return JSON.parse(encodedPayload) || {};\n } catch (e) {\n }\n }\n\n return {};\n}\n\n/**\n * Checks whether a JWT token is expired or not.\n * Tokens without `exp` payload key are considered valid.\n * Tokens with empty payload (eg. invalid token strings) are considered expired.\n *\n * @param token The token to check.\n * @param [expirationThreshold] Time in seconds that will be subtracted from the token `exp` property.\n */\nexport function isTokenExpired(token: string, expirationThreshold = 0): boolean {\n let payload = getTokenPayload(token);\n\n if (\n Object.keys(payload).length > 0 &&\n (!payload.exp || (payload.exp - expirationThreshold) > (Date.now() / 1000))\n ) {\n return false;\n }\n\n return true;\n}\n","import { cookieParse, cookieSerialize, SerializeOptions } from '@/stores/utils/cookie';\nimport { isTokenExpired, getTokenPayload } from '@/stores/utils/jwt';\nimport { RecordModel, AdminModel } from '@/services/utils/dtos';\n\nexport type AuthModel = RecordModel|AdminModel|null;\n\nexport type OnStoreChangeFunc = (token: string, model: AuthModel) => void;\n\nconst defaultCookieKey = 'pb_auth';\n\n/**\n * Base AuthStore class that is intended to be extended by all other\n * PocketBase AuthStore implementations.\n */\nexport abstract class BaseAuthStore {\n protected baseToken: string = '';\n protected baseModel: AuthModel = null;\n\n private _onChangeCallbacks: Array = [];\n\n /**\n * Retrieves the stored token (if any).\n */\n get token(): string {\n return this.baseToken;\n }\n\n /**\n * Retrieves the stored model data (if any).\n */\n get model(): AuthModel {\n return this.baseModel;\n }\n\n /**\n * Loosely checks if the store has valid token (aka. existing and unexpired exp claim).\n */\n get isValid(): boolean {\n return !isTokenExpired(this.token);\n }\n\n /**\n * Checks whether the current store state is for admin authentication.\n */\n get isAdmin(): boolean {\n return getTokenPayload(this.token).type === \"admin\";\n }\n\n /**\n * Checks whether the current store state is for auth record authentication.\n */\n get isAuthRecord(): boolean {\n return getTokenPayload(this.token).type === \"authRecord\";\n }\n\n /**\n * Saves the provided new token and model data in the auth store.\n */\n save(token: string, model?: AuthModel): void {\n this.baseToken = token || '';\n this.baseModel = model || null;\n\n this.triggerChange();\n }\n\n /**\n * Removes the stored token and model data form the auth store.\n */\n clear(): void {\n this.baseToken = '';\n this.baseModel = null;\n this.triggerChange();\n }\n\n /**\n * Parses the provided cookie string and updates the store state\n * with the cookie's token and model data.\n *\n * NB! This function doesn't validate the token or its data.\n * Usually this isn't a concern if you are interacting only with the\n * PocketBase API because it has the proper server-side security checks in place,\n * but if you are using the store `isValid` state for permission controls\n * in a node server (eg. SSR), then it is recommended to call `authRefresh()`\n * after loading the cookie to ensure an up-to-date token and model state.\n * For example:\n *\n * ```js\n * pb.authStore.loadFromCookie(\"cookie string...\");\n *\n * try {\n * // get an up-to-date auth store state by veryfing and refreshing the loaded auth model (if any)\n * pb.authStore.isValid && await pb.collection('users').authRefresh();\n * } catch (_) {\n * // clear the auth store on failed refresh\n * pb.authStore.clear();\n * }\n * ```\n */\n loadFromCookie(cookie: string, key = defaultCookieKey): void {\n const rawData = cookieParse(cookie || '')[key] || '';\n\n let data: { [key: string]: any } = {};\n try {\n data = JSON.parse(rawData);\n // normalize\n if (typeof data === null || typeof data !== 'object' || Array.isArray(data)) {\n data = {};\n }\n } catch (_) {}\n\n this.save(data.token || '', data.model || null);\n }\n\n /**\n * Exports the current store state as cookie string.\n *\n * By default the following optional attributes are added:\n * - Secure\n * - HttpOnly\n * - SameSite=Strict\n * - Path=/\n * - Expires={the token expiration date}\n *\n * NB! If the generated cookie exceeds 4096 bytes, this method will\n * strip the model data to the bare minimum to try to fit within the\n * recommended size in https://www.rfc-editor.org/rfc/rfc6265#section-6.1.\n */\n exportToCookie(options?: SerializeOptions, key = defaultCookieKey): string {\n const defaultOptions: SerializeOptions = {\n secure: true,\n sameSite: true,\n httpOnly: true,\n path: \"/\",\n };\n\n // extract the token expiration date\n const payload = getTokenPayload(this.token);\n if (payload?.exp) {\n defaultOptions.expires = new Date(payload.exp * 1000);\n } else {\n defaultOptions.expires = new Date('1970-01-01');\n }\n\n // merge with the user defined options\n options = Object.assign({}, defaultOptions, options);\n\n const rawData = {\n token: this.token,\n model: this.model ? JSON.parse(JSON.stringify(this.model)) : null,\n };\n\n let result = cookieSerialize(key, JSON.stringify(rawData), options);\n\n const resultLength = typeof Blob !== 'undefined' ?\n (new Blob([result])).size : result.length;\n\n // strip down the model data to the bare minimum\n if (rawData.model && resultLength > 4096) {\n rawData.model = {id: rawData?.model?.id, email: rawData?.model?.email};\n const extraProps = [\"collectionId\", \"username\", \"verified\"];\n for (const prop in this.model) {\n if (extraProps.includes(prop)) {\n rawData.model[prop] = this.model[prop];\n }\n }\n result = cookieSerialize(key, JSON.stringify(rawData), options);\n }\n\n return result;\n }\n\n /**\n * Register a callback function that will be called on store change.\n *\n * You can set the `fireImmediately` argument to true in order to invoke\n * the provided callback right after registration.\n *\n * Returns a removal function that you could call to \"unsubscribe\" from the changes.\n */\n onChange(callback: OnStoreChangeFunc, fireImmediately = false): () => void {\n this._onChangeCallbacks.push(callback);\n\n if (fireImmediately) {\n callback(this.token, this.model);\n }\n\n return () => {\n for (let i = this._onChangeCallbacks.length - 1; i >= 0; i--) {\n if (this._onChangeCallbacks[i] == callback) {\n delete this._onChangeCallbacks[i]; // removes the function reference\n this._onChangeCallbacks.splice(i, 1); // reindex the array\n return;\n }\n }\n }\n }\n\n protected triggerChange(): void {\n for (const callback of this._onChangeCallbacks) {\n callback && callback(this.token, this.model);\n }\n }\n}\n","import { BaseAuthStore, AuthModel } from '@/stores/BaseAuthStore';\n\n/**\n * The default token store for browsers with auto fallback\n * to runtime/memory if local storage is undefined (eg. in node env).\n */\nexport class LocalAuthStore extends BaseAuthStore {\n private storageFallback: { [key: string]: any } = {};\n private storageKey: string\n\n constructor(storageKey = \"pocketbase_auth\") {\n super();\n\n this.storageKey = storageKey;\n\n this._bindStorageEvent();\n }\n\n /**\n * @inheritdoc\n */\n get token(): string {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.token || '';\n }\n\n /**\n * @inheritdoc\n */\n get model(): AuthModel {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.model || null;\n }\n\n /**\n * @inheritdoc\n */\n save(token: string, model?: AuthModel) {\n this._storageSet(this.storageKey, {\n 'token': token,\n 'model': model,\n });\n\n super.save(token, model);\n }\n\n /**\n * @inheritdoc\n */\n clear() {\n this._storageRemove(this.storageKey);\n\n super.clear();\n }\n\n // ---------------------------------------------------------------\n // Internal helpers:\n // ---------------------------------------------------------------\n\n /**\n * Retrieves `key` from the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageGet(key: string): any {\n if (typeof window !== 'undefined' && window?.localStorage) {\n const rawValue = window.localStorage.getItem(key) || '';\n try {\n return JSON.parse(rawValue);\n } catch (e) { // not a json\n return rawValue;\n }\n }\n\n // fallback\n return this.storageFallback[key];\n }\n\n /**\n * Stores a new data in the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageSet(key: string, value: any) {\n if (typeof window !== 'undefined' && window?.localStorage) {\n // store in local storage\n let normalizedVal = value;\n if (typeof value !== 'string') {\n normalizedVal = JSON.stringify(value);\n }\n window.localStorage.setItem(key, normalizedVal);\n } else {\n // store in fallback\n this.storageFallback[key] = value;\n }\n }\n\n /**\n * Removes `key` from the browser's local storage and the runtime/memory.\n */\n private _storageRemove(key: string) {\n // delete from local storage\n if (typeof window !== 'undefined' && window?.localStorage) {\n window.localStorage?.removeItem(key);\n }\n\n // delete from fallback\n delete this.storageFallback[key];\n }\n\n /**\n * Updates the current store state on localStorage change.\n */\n private _bindStorageEvent() {\n if (typeof window === 'undefined' || !window?.localStorage || !window.addEventListener) {\n return;\n }\n\n window.addEventListener('storage', (e) => {\n if (e.key != this.storageKey) {\n return;\n }\n\n const data = this._storageGet(this.storageKey) || {};\n\n super.save(data.token || '', data.model || null);\n });\n }\n}\n","import Client from '@/Client';\n\n/**\n * BaseService class that should be inherited from all API services.\n */\nexport abstract class BaseService {\n readonly client: Client\n\n constructor(client: Client) {\n this.client = client;\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\ninterface appleClientSecret {\n secret: string;\n}\n\nexport class SettingsService extends BaseService {\n /**\n * Fetch all available app settings.\n */\n getAll(options?: CommonOptions): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Bulk updates app settings.\n */\n update(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Performs a S3 filesystem connection test.\n *\n * The currently supported `filesystem` are \"storage\" and \"backups\".\n */\n testS3(filesystem: string = \"storage\", options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'filesystem': filesystem,\n },\n }, options);\n\n return this.client.send('/api/settings/test/s3', options)\n .then(() => true);\n }\n\n /**\n * Sends a test email.\n *\n * The possible `emailTemplate` values are:\n * - verification\n * - password-reset\n * - email-change\n */\n testEmail(toEmail: string, emailTemplate: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'email': toEmail,\n 'template': emailTemplate,\n },\n }, options);\n\n return this.client.send('/api/settings/test/email', options)\n .then(() => true);\n }\n\n /**\n * Generates a new Apple OAuth2 client secret.\n */\n generateAppleClientSecret(\n clientId: string,\n teamId: string,\n keyId: string,\n privateKey: string,\n duration: number,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n clientId,\n teamId,\n keyId,\n privateKey,\n duration,\n },\n }, options);\n\n return this.client.send('/api/settings/apple/generate-client-secret', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n FullListOptions\n} from '@/services/utils/options';\n\nexport abstract class CrudService extends BaseService {\n /**\n * Base path for the crud actions (without trailing slash, eg. '/admins').\n */\n abstract get baseCrudPath(): string\n\n /**\n * Response data decoder.\n */\n decode(data: { [key: string]: any }): T {\n return data as T;\n }\n\n /**\n * Returns a promise with all list items batch fetched at once\n * (by default 500 items per request; to change it set the `batch` query param).\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getFullList(options?: FullListOptions): Promise>\n\n /**\n * Legacy version of getFullList with explicitly specified batch size.\n */\n getFullList(batch?: number, options?: ListOptions): Promise>\n\n getFullList(batchOrqueryParams?: number|FullListOptions, options?: ListOptions): Promise> {\n if (typeof batchOrqueryParams == \"number\") {\n return this._getFullList(batchOrqueryParams, options);\n }\n\n options = Object.assign({}, batchOrqueryParams, options);\n\n let batch = 500;\n if (options.batch) {\n batch = options.batch;\n delete options.batch;\n }\n\n return this._getFullList(batch, options);\n }\n\n /**\n * Returns paginated items list.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({\n method: 'GET'\n }, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => {\n responseData.items = responseData.items?.map((item: any) => {\n return this.decode(item);\n }) || [];\n\n return responseData;\n });\n }\n\n /**\n * Returns the first found item by the specified filter.\n *\n * Internally it calls `getList(1, 1, { filter, skipTotal })` and\n * returns the first found item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n *\n * For consistency with `getOne`, this method will throw a 404\n * ClientResponseError if no item was found.\n */\n getFirstListItem(filter: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'requestKey': 'one_by_filter_' + this.baseCrudPath + \"_\" + filter,\n }, options);\n\n options.query = Object.assign({\n 'filter': filter,\n 'skipTotal': 1,\n }, options.query);\n\n return this.getList(1, 1, options)\n .then((result) => {\n if (!result?.items?.length) {\n throw new ClientResponseError({\n status: 404,\n data: {\n code: 404,\n message: \"The requested resource wasn't found.\",\n data: {},\n },\n });\n }\n\n return result.items[0];\n });\n }\n\n /**\n * Returns single item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getOne(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Creates a new item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n create(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Updates an existing item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Deletes an existing item by its id.\n */\n delete(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then(() => true);\n }\n\n /**\n * Returns a promise with all list items batch fetched at once.\n */\n protected _getFullList(batchSize = 500, options?: ListOptions): Promise> {\n options = options || {};\n options.query = Object.assign({\n 'skipTotal': 1,\n }, options.query);\n\n let result: Array = [];\n\n let request = async (page: number): Promise> => {\n return this.getList(page, batchSize || 500, options).then((list) => {\n const castedList = (list as any as ListResult);\n const items = castedList.items;\n\n result = result.concat(items);\n\n if (items.length == list.perPage) {\n return request(page + 1);\n }\n\n return result;\n });\n }\n\n return request(1);\n }\n}\n","import { SendOptions } from '@/services/utils/options';\n\nexport function normalizeLegacyOptionsArgs(legacyWarn: string, baseOptions: SendOptions, bodyOrOptions?: any, query?: any): SendOptions {\n const hasBodyOrOptions = typeof bodyOrOptions !== 'undefined';\n const hasQuery = typeof query !== 'undefined';\n\n if (!hasQuery && !hasBodyOrOptions) {\n return baseOptions;\n }\n\n if (hasQuery) {\n console.warn(legacyWarn);\n baseOptions.body = Object.assign({}, baseOptions.body, bodyOrOptions);\n baseOptions.query = Object.assign({}, baseOptions.query, query);\n\n return baseOptions;\n }\n\n baseOptions = Object.assign(baseOptions, bodyOrOptions);\n return baseOptions;\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { AdminModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface AdminAuthResponse {\n [key: string]: any;\n\n token: string;\n admin: AdminModel;\n}\n\nexport class AdminService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/admins';\n }\n\n // ---------------------------------------------------------------\n // Post update/delete AuthStore sync\n // ---------------------------------------------------------------\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n // update the store state if the updated item id matches with the stored model\n if (\n this.client.authStore.model?.id === item.id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n // clear the store state if the deleted item id matches with the stored model\n if (\n success &&\n this.client.authStore.model?.id === id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful authorize response.\n */\n protected authResponse(responseData: any): AdminAuthResponse {\n const admin = this.decode(responseData?.admin || {});\n\n if (responseData?.token && responseData?.admin) {\n this.client.authStore.save(responseData.token, admin);\n }\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'admin': admin,\n });\n }\n\n /**\n * Authenticate an admin account with its email and password\n * and returns a new admin token and data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authWithPassword(email: string, password: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authWithPassword(email, password, options?).\n */\n authWithPassword(email: string, password: string, body?: any, query?: any): Promise\n\n authWithPassword(\n email: string,\n password: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': email,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(email, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(email, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-with-password', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Refreshes the current admin authenticated instance and\n * returns a new token and admin data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authRefresh(options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-refresh', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Sends admin password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/request-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Confirms admin password reset request.\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(resetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, body?: any, query?: any): Promise\n\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, bodyOrOptions?: any, query?: any): Promise{\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': resetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(resetToken, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(resetToken, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\n\ninterface promiseCallbacks {\n resolve: Function\n reject: Function\n}\n\nexport type UnsubscribeFunc = () => Promise;\n\nexport class RealtimeService extends BaseService {\n clientId: string = \"\";\n\n private eventSource: EventSource | null = null;\n private subscriptions: { [key: string]: Array } = {};\n private lastSentTopics: Array = [];\n private connectTimeoutId: any;\n private maxConnectTimeout: number = 15000;\n private reconnectTimeoutId: any;\n private reconnectAttempts: number = 0;\n private maxReconnectAttempts: number = Infinity;\n private predefinedReconnectIntervals: Array = [\n 200, 300, 500, 1000, 1200, 1500, 2000,\n ];\n private pendingConnects: Array = [];\n\n /**\n * Returns whether the realtime connection has been established.\n */\n get isConnected(): boolean {\n return !!this.eventSource && !!this.clientId && !this.pendingConnects.length;\n }\n\n /**\n * Register the subscription listener.\n *\n * You can subscribe multiple times to the same topic.\n *\n * If the SSE connection is not started yet,\n * this method will also initialize it.\n */\n async subscribe(topic: string, callback: (data: any) => void): Promise {\n if (!topic) {\n throw new Error('topic must be set.')\n }\n\n const listener = function (e: Event) {\n const msgEvent = (e as MessageEvent);\n\n let data;\n try {\n data = JSON.parse(msgEvent?.data);\n } catch {}\n\n callback(data || {});\n };\n\n // store the listener\n if (!this.subscriptions[topic]) {\n this.subscriptions[topic] = [];\n }\n this.subscriptions[topic].push(listener);\n\n if (!this.isConnected) {\n // initialize sse connection\n await this.connect();\n } else if (this.subscriptions[topic].length === 1) {\n // send the updated subscriptions (if it is the first for the topic)\n await this.submitSubscriptions();\n } else {\n // only register the listener\n this.eventSource?.addEventListener(topic, listener);\n }\n\n return async (): Promise => {\n return this.unsubscribeByTopicAndListener(topic, listener);\n };\n }\n\n /**\n * Unsubscribe from all subscription listeners with the specified topic.\n *\n * If `topic` is not provided, then this method will unsubscribe\n * from all active subscriptions.\n *\n * This method is no-op if there are no active subscriptions.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribe(topic?: string): Promise {\n if (!this.hasSubscriptionListeners(topic)) {\n return; // already unsubscribed\n }\n\n if (!topic) {\n // remove all subscriptions\n this.subscriptions = {};\n } else {\n // remove all topic listeners\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n /**\n * Unsubscribe from all subscription listeners starting with the specified topic prefix.\n *\n * This method is no-op if there are no active subscriptions with the specified topic prefix.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByPrefix(topicPrefix: string): Promise {\n let hasAtleastOneTopic = false;\n for (let topic in this.subscriptions) {\n if (!topic.startsWith(topicPrefix)) {\n continue;\n }\n\n hasAtleastOneTopic = true;\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!hasAtleastOneTopic) {\n return; // nothing to unsubscribe from\n }\n\n if (this.hasSubscriptionListeners()) {\n // submit the deleted subscriptions\n await this.submitSubscriptions();\n } else {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n }\n }\n\n /**\n * Unsubscribe from all subscriptions matching the specified topic and listener function.\n *\n * This method is no-op if there are no active subscription with\n * the specified topic and listener.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByTopicAndListener(topic: string, listener: EventListener): Promise {\n if (!Array.isArray(this.subscriptions[topic]) || !this.subscriptions[topic].length) {\n return; // already unsubscribed\n }\n\n let exist = false;\n for (let i = this.subscriptions[topic].length - 1; i >= 0; i--) {\n if (this.subscriptions[topic][i] !== listener) {\n continue;\n }\n\n exist = true; // has at least one matching listener\n delete this.subscriptions[topic][i]; // removes the function reference\n this.subscriptions[topic].splice(i, 1); // reindex the array\n this.eventSource?.removeEventListener(topic, listener);\n }\n if (!exist) {\n return;\n }\n\n // remove the topic from the subscriptions list if there are no other listeners\n if (!this.subscriptions[topic].length) {\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n private hasSubscriptionListeners(topicToCheck?: string): boolean {\n this.subscriptions = this.subscriptions || {};\n\n // check the specified topic\n if (topicToCheck) {\n return !!this.subscriptions[topicToCheck]?.length;\n }\n\n // check for at least one non-empty topic\n for (let topic in this.subscriptions) {\n if (!!this.subscriptions[topic]?.length) {\n return true\n }\n }\n\n return false;\n }\n\n private async submitSubscriptions(): Promise {\n if (!this.clientId) {\n return; // no client/subscriber\n }\n\n // optimistic update\n this.addAllSubscriptionListeners();\n\n this.lastSentTopics = this.getNonEmptySubscriptionTopics();\n\n return this.client.send('/api/realtime', {\n 'method': 'POST',\n 'body': {\n 'clientId': this.clientId,\n 'subscriptions': this.lastSentTopics,\n },\n 'query': {\n 'requestKey': this.getSubscriptionsCancelKey(),\n },\n }).catch((err) => {\n if (err?.isAbort) {\n return; // silently ignore aborted pending requests\n }\n throw err;\n });\n }\n\n private getSubscriptionsCancelKey(): string {\n return \"realtime_\" + this.clientId;\n }\n\n private getNonEmptySubscriptionTopics(): Array {\n const result : Array = [];\n\n for (let topic in this.subscriptions) {\n if (this.subscriptions[topic].length) {\n result.push(topic);\n }\n }\n\n return result;\n }\n\n private addAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n this.removeAllSubscriptionListeners();\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.addEventListener(topic, listener);\n }\n }\n }\n\n private removeAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.removeEventListener(topic, listener);\n }\n }\n }\n\n private async connect(): Promise {\n if (this.reconnectAttempts > 0) {\n // immediately resolve the promise to avoid indefinitely\n // blocking the client during reconnection\n return;\n }\n\n return new Promise((resolve, reject) => {\n this.pendingConnects.push({ resolve, reject });\n\n if (this.pendingConnects.length > 1) {\n // all promises will be resolved once the connection is established\n return;\n }\n\n this.initConnect();\n })\n }\n\n private initConnect() {\n this.disconnect(true);\n\n // wait up to 15s for connect\n clearTimeout(this.connectTimeoutId);\n this.connectTimeoutId = setTimeout(() => {\n this.connectErrorHandler(new Error(\"EventSource connect took too long.\"));\n }, this.maxConnectTimeout);\n\n this.eventSource = new EventSource(this.client.buildUrl('/api/realtime'))\n\n this.eventSource.onerror = (_) => {\n this.connectErrorHandler(new Error(\"Failed to establish realtime connection.\"));\n };\n\n this.eventSource.addEventListener('PB_CONNECT', (e) => {\n const msgEvent = (e as MessageEvent);\n this.clientId = msgEvent?.lastEventId;\n\n this.submitSubscriptions()\n .then(async () => {\n let retries = 3;\n while (this.hasUnsentSubscriptions() && retries > 0) {\n retries--;\n // resubscribe to ensure that the latest topics are submitted\n //\n // This is needed because missed topics could happen on reconnect\n // if after the pending sent `submitSubscriptions()` call another `subscribe()`\n // was made before the submit was able to complete.\n await this.submitSubscriptions();\n }\n }).then(() => {\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n\n // reset connect meta\n this.pendingConnects = [];\n this.reconnectAttempts = 0;\n clearTimeout(this.reconnectTimeoutId);\n clearTimeout(this.connectTimeoutId);\n }).catch((err) => {\n this.clientId = \"\";\n this.connectErrorHandler(err);\n });\n });\n }\n\n private hasUnsentSubscriptions(): boolean {\n const latestTopics = this.getNonEmptySubscriptionTopics();\n if (latestTopics.length != this.lastSentTopics.length) {\n return true;\n }\n\n for (const t of latestTopics) {\n if (!this.lastSentTopics.includes(t)) {\n return true;\n }\n }\n\n return false;\n }\n\n private connectErrorHandler(err: any) {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n\n if (\n // wasn't previously connected -> direct reject\n (!this.clientId && !this.reconnectAttempts) ||\n // was previously connected but the max reconnection limit has been reached\n this.reconnectAttempts > this.maxReconnectAttempts\n ) {\n for (let p of this.pendingConnects) {\n p.reject(new ClientResponseError(err));\n }\n this.pendingConnects = [];\n this.disconnect();\n return;\n }\n\n // otherwise -> reconnect in the background\n this.disconnect(true);\n const timeout = this.predefinedReconnectIntervals[this.reconnectAttempts] || this.predefinedReconnectIntervals[this.predefinedReconnectIntervals.length - 1];\n this.reconnectAttempts++;\n this.reconnectTimeoutId = setTimeout(() => {\n this.initConnect();\n }, timeout);\n }\n\n private disconnect(fromReconnect = false): void {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n this.removeAllSubscriptionListeners();\n this.client.cancelRequest(this.getSubscriptionsCancelKey());\n this.eventSource?.close();\n this.eventSource = null;\n this.clientId = \"\";\n\n if (!fromReconnect) {\n this.reconnectAttempts = 0;\n\n // resolve any remaining connect promises\n //\n // this is done to avoid unnecessary throwing errors in case\n // unsubscribe is called before the pending connect promises complete\n // (see https://github.com/pocketbase/pocketbase/discussions/2897#discussioncomment-6423818)\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n this.pendingConnects = [];\n }\n }\n}\n","import Client from '@/Client';\nimport { CrudService } from '@/services/utils/CrudService';\nimport { RealtimeService, UnsubscribeFunc } from '@/services/RealtimeService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult, RecordModel, ExternalAuthModel } from '@/services/utils/dtos';\nimport {\n SendOptions,\n CommonOptions,\n RecordOptions,\n RecordListOptions,\n RecordFullListOptions,\n} from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface RecordAuthResponse {\n // The signed PocketBase auth record.\n record: T;\n\n // The PocketBase record auth token.\n //\n // If you are looking for the OAuth2 access and refresh tokens\n // they are available under the `meta.accessToken` and `meta.refreshToken` props.\n token: string;\n\n // Auth meta data usually filled when OAuth2 is used.\n meta?: {[key: string]: any};\n}\n\nexport interface AuthProviderInfo {\n name: string;\n state: string;\n codeVerifier: string;\n codeChallenge: string;\n codeChallengeMethod: string;\n authUrl: string;\n}\n\nexport interface AuthMethodsList {\n usernamePassword: boolean;\n emailPassword: boolean;\n authProviders: Array;\n}\n\nexport interface RecordSubscription {\n action: string; // eg. create, update, delete\n record: T;\n}\n\nexport type OAuth2UrlCallback = (url: string) => void|Promise;\n\nexport interface OAuth2AuthConfig extends SendOptions {\n // the name of the OAuth2 provider (eg. \"google\")\n provider: string;\n\n // custom scopes to overwrite the default ones\n scopes?: Array;\n\n // optional record create data\n createData?: {[key: string]: any};\n\n // optional callback that is triggered after the OAuth2 sign-in/sign-up url generation\n urlCallback?: OAuth2UrlCallback;\n\n // optional query params to send with the PocketBase auth request (eg. fields, expand, etc.)\n query?: RecordOptions;\n}\n\nexport class RecordService extends CrudService {\n readonly collectionIdOrName: string;\n\n constructor(client: Client, collectionIdOrName: string) {\n super(client);\n\n this.collectionIdOrName = collectionIdOrName;\n }\n\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return this.baseCollectionPath + '/records';\n }\n\n /**\n * Returns the current collection service base path.\n */\n get baseCollectionPath(): string {\n return '/api/collections/' + encodeURIComponent(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Realtime handlers\n // ---------------------------------------------------------------\n\n /**\n * @deprecated Use subscribe(recordId, callback) instead.\n *\n * Subscribe to the realtime changes of a single record in the collection.\n */\n async subscribeOne(recordId: string, callback: (data: RecordSubscription) => void): Promise {\n console.warn(\"PocketBase: subscribeOne(recordId, callback) is deprecated. Please replace it with subscribe(recordId, callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName + \"/\" + recordId, callback);\n }\n\n /**\n * @deprecated This form of subscribe is deprecated. Please use `subscribe(\"*\", callback)`.\n */\n async subscribe(callback: (data: RecordSubscription) => void): Promise\n\n /**\n * Subscribe to realtime changes to the specified topic (\"*\" or record id).\n *\n * If `topic` is the wildcard \"*\", then this method will subscribe to\n * any record changes in the collection.\n *\n * If `topic` is a record id, then this method will subscribe only\n * to changes of the specified record id.\n *\n * It's OK to subscribe multiple times to the same topic.\n * You can use the returned `UnsubscribeFunc` to remove only a single subscription.\n * Or use `unsubscribe(topic)` if you want to remove all subscriptions attached to the topic.\n */\n async subscribe(topic: string, callback: (data: RecordSubscription) => void): Promise\n\n async subscribe(\n topicOrCallback: string|((data: RecordSubscription) => void),\n callback?: (data: RecordSubscription) => void\n ): Promise {\n if (typeof topicOrCallback === 'function') {\n console.warn(\"PocketBase: subscribe(callback) is deprecated. Please replace it with subscribe('*', callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName, topicOrCallback);\n }\n\n if (!callback) {\n throw new Error(\"Missing subscription callback.\");\n }\n\n if (topicOrCallback === \"\") {\n throw new Error(\"Missing topic.\");\n }\n\n let topic = this.collectionIdOrName;\n if (topicOrCallback !== \"*\") {\n topic += ('/' + topicOrCallback);\n }\n\n return this.client.realtime.subscribe(topic, callback)\n }\n\n /**\n * Unsubscribe from all subscriptions of the specified topic\n * (\"*\" or record id).\n *\n * If `topic` is not set, then this method will unsubscribe from\n * all subscriptions associated to the current collection.\n */\n async unsubscribe(topic?: string): Promise {\n // unsubscribe wildcard topic\n if (topic === \"*\") {\n return this.client.realtime.unsubscribe(this.collectionIdOrName);\n }\n\n // unsubscribe recordId topic\n if (topic) {\n return this.client.realtime.unsubscribe(this.collectionIdOrName + \"/\" + topic);\n }\n\n // unsubscribe from everything related to the collection\n return this.client.realtime.unsubscribeByPrefix(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Crud handers\n // ---------------------------------------------------------------\n /**\n * @inheritdoc\n */\n getFullList(options?: RecordFullListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batch?: number, options?: RecordListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batchOrOptions?: number|RecordFullListOptions, options?: RecordListOptions): Promise> {\n if (typeof batchOrOptions == \"number\") {\n return super.getFullList(batchOrOptions, options);\n }\n\n const params = Object.assign({}, batchOrOptions, options);\n\n return super.getFullList(params);\n }\n\n /**\n * @inheritdoc\n */\n getList(page = 1, perPage = 30, options?: RecordListOptions): Promise> {\n return super.getList(page, perPage, options);\n }\n\n /**\n * @inheritdoc\n */\n getFirstListItem(filter: string, options?: RecordListOptions): Promise {\n return super.getFirstListItem(filter, options);\n }\n\n /**\n * @inheritdoc\n */\n getOne(id: string, options?: RecordOptions): Promise {\n return super.getOne(id, options);\n }\n\n /**\n * @inheritdoc\n */\n create(bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.create(bodyParams, options);\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(id: string, bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n if (\n // is record auth\n this.client.authStore.model?.id === item?.id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n if (\n success &&\n // is record auth\n this.client.authStore.model?.id === id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful collection authorization response.\n */\n protected authResponse(responseData: any): RecordAuthResponse {\n const record = this.decode(responseData?.record || {});\n\n this.client.authStore.save(responseData?.token, record);\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'record': record as any as T,\n });\n }\n\n /**\n * Returns all available collection auth methods.\n */\n listAuthMethods(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCollectionPath + '/auth-methods', options)\n .then((responseData: any) => {\n return Object.assign({}, responseData, {\n // normalize common fields\n 'usernamePassword': !!responseData?.usernamePassword,\n 'emailPassword': !!responseData?.emailPassword,\n 'authProviders': Array.isArray(responseData?.authProviders) ? responseData?.authProviders : [],\n });\n });\n }\n\n /**\n * Authenticate a single auth collection record via its username/email and password.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n */\n authWithPassword(usernameOrEmail: string, password: string, options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authWithPassword(usernameOrEmail, password, options?).\n */\n authWithPassword(usernameOrEmail: string, password: string, body?: any, query?: any): Promise>\n\n authWithPassword(usernameOrEmail: string, password: string, bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': usernameOrEmail,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(usernameOrEmail, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(usernameOrEmail, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-password', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Authenticate a single auth collection record with OAuth2 code.\n *\n * If you don't have an OAuth2 code you may also want to check `authWithOAuth2` method.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n options?: RecordOptions,\n ): Promise>\n\n /**\n * @deprecated\n * Consider using authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createdData, options?).\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n body?: any,\n query?: any\n ): Promise>\n\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n bodyOrOptions?: any,\n query?: any\n ): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'provider': provider,\n 'code': code,\n 'codeVerifier': codeVerifier,\n 'redirectUrl': redirectUrl,\n 'createData': createData,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, body?, query?) is deprecated. Consider replacing it with authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-oauth2', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * @deprecated This form of authWithOAuth2 is deprecated.\n *\n * Please use `authWithOAuth2Code()` OR its simplified realtime version\n * as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\n */\n async authWithOAuth2(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key: string]: any},\n bodyParams?: {[key: string]: any},\n queryParams?: RecordOptions,\n ): Promise>\n\n /**\n * Authenticate a single auth collection record with OAuth2\n * **without custom redirects, deeplinks or even page reload**.\n *\n * This method initializes a one-off realtime subscription and will\n * open a popup window with the OAuth2 vendor page to authenticate.\n * Once the external OAuth2 sign-in/sign-up flow is completed, the popup\n * window will be automatically closed and the OAuth2 data sent back\n * to the user through the previously established realtime connection.\n *\n * You can specify an optional `urlCallback` prop to customize\n * the default url `window.open` behavior.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n *\n * Example:\n *\n * ```js\n * const authData = await pb.collection(\"users\").authWithOAuth2({\n * provider: \"google\",\n * })\n * ```\n *\n * _Site-note_: when creating the OAuth2 app in the provider dashboard\n * you have to configure `https://yourdomain.com/api/oauth2-redirect`\n * as redirect URL.\n */\n async authWithOAuth2(options: OAuth2AuthConfig): Promise>\n\n async authWithOAuth2(...args: any): Promise> {\n // fallback to legacy format\n if (args.length > 1 || typeof args?.[0] === 'string') {\n console.warn(\"PocketBase: This form of authWithOAuth2() is deprecated and may get removed in the future. Please replace with authWithOAuth2Code() OR use the authWithOAuth2() realtime form as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\");\n return this.authWithOAuth2Code(\n args?.[0] || '',\n args?.[1] || '',\n args?.[2] || '',\n args?.[3] || '',\n args?.[4] || {},\n args?.[5] || {},\n args?.[6] || {},\n );\n }\n\n const config = args?.[0] || {};\n\n const authMethods = await this.listAuthMethods();\n\n const provider = authMethods.authProviders.find((p) => p.name === config.provider);\n if (!provider) {\n throw new ClientResponseError(new Error(`Missing or invalid provider \"${config.provider}\".`));\n }\n\n const redirectUrl = this.client.buildUrl('/api/oauth2-redirect');\n\n // initialize a one-off realtime service\n const realtime = new RealtimeService(this.client);\n\n // open a new popup window in case config.urlCallback is not set\n //\n // note: it is opened before the async call due to Safari restrictions\n // (see https://github.com/pocketbase/pocketbase/discussions/2429#discussioncomment-5943061)\n let eagerDefaultPopup: Window|null = null;\n if (!config.urlCallback) {\n eagerDefaultPopup = openBrowserPopup(undefined);\n }\n\n function cleanup() {\n eagerDefaultPopup?.close();\n realtime.unsubscribe();\n }\n\n return new Promise(async (resolve, reject) => {\n try {\n await realtime.subscribe('@oauth2', async (e) => {\n const oldState = realtime.clientId;\n\n try {\n if (!e.state || oldState !== e.state) {\n throw new Error(\"State parameters don't match.\");\n }\n\n // clear the non SendOptions props\n const options = Object.assign({}, config);\n delete options.provider;\n delete options.scopes;\n delete options.createData;\n delete options.urlCallback;\n\n const authData = await this.authWithOAuth2Code(\n provider.name,\n e.code,\n provider.codeVerifier,\n redirectUrl,\n config.createData,\n options,\n );\n\n resolve(authData);\n } catch (err) {\n reject(new ClientResponseError(err));\n }\n\n cleanup();\n });\n\n const replacements: {[key: string]: any} = {\n \"state\": realtime.clientId,\n }\n if (config.scopes?.length) {\n replacements[\"scope\"] = config.scopes.join(\" \");\n }\n\n const url = this._replaceQueryParams(provider.authUrl + redirectUrl, replacements);\n\n let urlCallback = config.urlCallback || function (url: string) {\n if (eagerDefaultPopup) {\n eagerDefaultPopup.location.href = url;\n } else {\n // it could have been blocked due to its empty initial url,\n // try again...\n eagerDefaultPopup = openBrowserPopup(url);\n }\n }\n\n await urlCallback(url);\n } catch (err) {\n cleanup();\n reject(new ClientResponseError(err));\n }\n });\n }\n\n /**\n * Refreshes the current authenticated record instance and\n * returns a new token and record data.\n *\n * On success this method also automatically updates the client's AuthStore.\n */\n authRefresh(options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise>\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-refresh', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Sends auth record password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-password-reset', options).then(() => true);\n }\n\n /**\n * Confirms auth record password reset request.\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n options?: CommonOptions,\n ): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(passwordResetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n body?: any,\n query?: any,\n ): Promise\n\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': passwordResetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(token, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(token, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Sends auth record verification email request.\n */\n requestVerification(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestVerification(email, options?).\n */\n requestVerification(email: string, body?: any, query?: any): Promise\n\n requestVerification(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestVerification(email, body?, query?) is deprecated. Consider replacing it with requestVerification(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-verification', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record email verification request.\n */\n confirmVerification(verificationToken: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmVerification(verificationToken, options?).\n */\n confirmVerification(verificationToken: string, body?: any, query?: any): Promise\n\n confirmVerification(verificationToken: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': verificationToken,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmVerification(token, body?, query?) is deprecated. Consider replacing it with confirmVerification(token, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-verification', options)\n .then(() => true);\n }\n\n /**\n * Sends an email change request to the authenticated record model.\n */\n requestEmailChange(newEmail: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestEmailChange(newEmail, options?).\n */\n requestEmailChange(newEmail: string, body?: any, query?: any): Promise\n\n requestEmailChange(newEmail: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'newEmail': newEmail,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestEmailChange(newEmail, body?, query?) is deprecated. Consider replacing it with requestEmailChange(newEmail, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-email-change', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record's new email address.\n */\n confirmEmailChange(emailChangeToken: string, password: string, options?: CommonOptions): Promise\n\n\n /**\n * @deprecated\n * Consider using confirmEmailChange(emailChangeToken, password, options?).\n */\n confirmEmailChange(emailChangeToken: string, password: string, body?: any, query?: any): Promise\n\n confirmEmailChange(emailChangeToken: string, password: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': emailChangeToken,\n 'password': password,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmEmailChange(token, password, body?, query?) is deprecated. Consider replacing it with confirmEmailChange(token, password, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-email-change', options)\n .then(() => true);\n }\n\n /**\n * Lists all linked external auth providers for the specified auth record.\n */\n listExternalAuths(recordId: string, options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths', options);\n }\n\n /**\n * Unlink a single external auth provider from the specified auth record.\n */\n unlinkExternalAuth(recordId: string, provider: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths/' + encodeURIComponent(provider), options)\n .then(() => true);\n }\n\n // ---------------------------------------------------------------\n\n // very rudimentary url query params replacement because at the moment\n // URL (and URLSearchParams) doesn't seem to be fully supported in React Native\n //\n // note: for details behind some of the decode/encode parsing check https://unixpapa.com/js/querystring.html\n private _replaceQueryParams(url: string, replacements: {[key: string]: any} = {}): string {\n let urlPath = url\n let query = \"\";\n\n const queryIndex = url.indexOf(\"?\");\n if (queryIndex >= 0) {\n urlPath = url.substring(0, url.indexOf(\"?\"));\n query = url.substring(url.indexOf(\"?\") + 1);\n }\n\n const parsedParams: {[key: string]: string} = {};\n\n // parse the query parameters\n const rawParams = query.split(\"&\");\n for (const param of rawParams) {\n if (param == \"\") {\n continue\n }\n\n const pair = param.split(\"=\");\n parsedParams[decodeURIComponent(pair[0].replace(/\\+/g,' '))] = decodeURIComponent((pair[1] || \"\").replace(/\\+/g,' '));\n }\n\n // apply the replacements\n for (let key in replacements) {\n if (!replacements.hasOwnProperty(key)) {\n continue;\n }\n\n if (replacements[key] == null) {\n delete parsedParams[key];\n } else {\n parsedParams[key] = replacements[key];\n }\n }\n\n // construct back the full query string\n query = \"\";\n for (let key in parsedParams) {\n if (!parsedParams.hasOwnProperty(key)) {\n continue;\n }\n\n if (query != \"\") {\n query += \"&\";\n }\n\n query += encodeURIComponent(key.replace(/%20/g,'+')) + \"=\" + encodeURIComponent(parsedParams[key].replace(/%20/g,'+'));\n }\n\n return query != \"\" ? (urlPath + \"?\" + query) : urlPath;\n }\n}\n\nfunction openBrowserPopup(url?: string): Window|null {\n if (typeof window === \"undefined\" || !window?.open) {\n throw new ClientResponseError(new Error(`Not in a browser context - please pass a custom urlCallback function.`));\n }\n\n let width = 1024;\n let height = 768;\n\n let windowWidth = window.innerWidth;\n let windowHeight = window.innerHeight;\n\n // normalize window size\n width = width > windowWidth ? windowWidth : width;\n height = height > windowHeight ? windowHeight : height;\n\n let left = (windowWidth / 2) - (width / 2);\n let top = (windowHeight / 2) - (height / 2);\n\n // note: we don't use the noopener and noreferrer attributes since\n // for some reason browser blocks such windows then url is undefined/blank\n return window.open(\n url,\n 'popup_window',\n 'width='+width+',height='+height+',top='+top+',left='+left+',resizable,menubar=no'\n );\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { CollectionModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport class CollectionService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/collections';\n }\n\n /**\n * Imports the provided collections.\n *\n * If `deleteMissing` is `true`, all local collections and schema fields,\n * that are not present in the imported configuration, WILL BE DELETED\n * (including their related records data)!\n */\n async import(\n collections: Array,\n deleteMissing: boolean = false,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PUT',\n 'body': {\n 'collections': collections,\n 'deleteMissing': deleteMissing,\n }\n }, options);\n\n return this.client.send(this.baseCrudPath + '/import', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ListResult, LogRequestModel } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n LogStatsOptions,\n} from '@/services/utils/options';\n\nexport interface HourlyStats {\n total: number;\n date: string;\n}\n\nexport class LogService extends BaseService {\n /**\n * Returns paginated logged requests list.\n */\n getRequestsList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({'method': 'GET'}, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send('/api/logs/requests', options);\n }\n\n /**\n * Returns a single logged request by its id.\n */\n getRequest(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/' + encodeURIComponent(id), options);\n }\n\n /**\n * Returns request logs statistics.\n */\n getRequestsStats(options?: LogStatsOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/stats', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface HealthCheckResponse {\n code: number;\n message: string;\n data: {[key: string]: any};\n}\n\nexport class HealthService extends BaseService {\n /**\n * Checks the health status of the api.\n */\n check(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/health', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions, FileOptions } from '@/services/utils/options';\n\nexport class FileService extends BaseService {\n /**\n * Builds and returns an absolute record file url for the provided filename.\n */\n getUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n if (\n !filename ||\n !record?.id ||\n !(record?.collectionId || record?.collectionName)\n ) {\n return '';\n }\n\n const parts = [];\n parts.push('api')\n parts.push('files')\n parts.push(encodeURIComponent(record.collectionId || record.collectionName))\n parts.push(encodeURIComponent(record.id))\n parts.push(encodeURIComponent(filename))\n\n let result = this.client.buildUrl(parts.join('/'));\n\n if (Object.keys(queryParams).length) {\n // normalize the download query param for consistency with the Dart sdk\n if (queryParams.download === false) {\n delete(queryParams.download);\n }\n\n const params = new URLSearchParams(queryParams);\n\n result += (result.includes('?') ? '&' : '?') + params;\n }\n\n return result\n }\n\n /**\n * Requests a new private file access token for the current auth model (admin or record).\n */\n getToken(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send('/api/files/token', options)\n .then((data) => data?.token || '');\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface BackupFileInfo {\n key: string;\n size: number;\n modified: string;\n}\n\nexport class BackupService extends BaseService {\n /**\n * Returns list with all available backup files.\n */\n getFullList(options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/backups', options);\n }\n\n /**\n * Initializes a new backup.\n */\n create(basename: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'name': basename,\n },\n }, options);\n\n return this.client.send('/api/backups', options)\n .then(() => true);\n }\n\n /**\n * Deletes a single backup file.\n */\n delete(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}`, options)\n .then(() => true);\n }\n\n /**\n * Initializes an app data restore from an existing backup.\n */\n restore(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}/restore`, options)\n .then(() => true);\n }\n\n /**\n * Builds a download url for a single existing backup using an\n * admin file token and the backup file key.\n *\n * The file token can be generated via `pb.files.getToken()`.\n */\n getDownloadUrl(token: string, key: string): string {\n return this.client.buildUrl(`/api/backups/${encodeURIComponent(key)}?token=${encodeURIComponent(token)}`);\n }\n}\n","import { ClientResponseError } from '@/ClientResponseError';\nimport { BaseAuthStore } from '@/stores/BaseAuthStore';\nimport { LocalAuthStore } from '@/stores/LocalAuthStore';\nimport { SettingsService } from '@/services/SettingsService';\nimport { AdminService } from '@/services/AdminService';\nimport { RecordService } from '@/services/RecordService';\nimport { CollectionService } from '@/services/CollectionService';\nimport { LogService } from '@/services/LogService';\nimport { RealtimeService } from '@/services/RealtimeService';\nimport { HealthService } from '@/services/HealthService';\nimport { FileService } from '@/services/FileService';\nimport { BackupService } from '@/services/BackupService';\nimport { SendOptions, FileOptions } from '@/services/utils/options';\n\n// list of known SendOptions keys (everything else is treated as query param)\nconst knownSendOptionsKeys = [\n 'requestKey',\n '$cancelKey',\n '$autoCancel',\n 'fetch',\n 'headers',\n 'body',\n 'query',\n 'params',\n // ---,\n 'cache',\n 'credentials',\n 'headers',\n 'integrity',\n 'keepalive',\n 'method',\n 'mode',\n 'redirect',\n 'referrer',\n 'referrerPolicy',\n 'signal',\n 'window',\n];\n\nexport interface BeforeSendResult {\n [key: string]: any, // for backward compatibility\n url?: string,\n options?: {[key: string]: any}\n}\n\n/**\n * PocketBase JS Client.\n */\nexport default class Client {\n /**\n * The base PocketBase backend url address (eg. 'http://127.0.0.1.8090').\n */\n baseUrl: string;\n\n /**\n * Hook that get triggered right before sending the fetch request,\n * allowing you to inspect and modify the url and request options.\n *\n * For list of the possible options check https://developer.mozilla.org/en-US/docs/Web/API/fetch#options\n *\n * You can return a non-empty result object `{ url, options }` to replace the url and request options entirely.\n *\n * Example:\n * ```js\n * client.beforeSend = function (url, options) {\n * options.headers = Object.assign({}, options.headers, {\n * 'X-Custom-Header': 'example',\n * });\n *\n * return { url, options }\n * };\n * ```\n */\n beforeSend?: (url: string, options: SendOptions) => BeforeSendResult|Promise;\n\n /**\n * Hook that get triggered after successfully sending the fetch request,\n * allowing you to inspect/modify the response object and its parsed data.\n *\n * Returns the new Promise resolved `data` that will be returned to the client.\n *\n * Example:\n * ```js\n * client.afterSend = function (response, data) {\n * if (response.status != 200) {\n * throw new ClientResponseError({\n * url: response.url,\n * status: response.status,\n * data: data,\n * });\n * }\n *\n * return data;\n * };\n * ```\n */\n afterSend?: (response: Response, data: any) => any;\n\n /**\n * Optional language code (default to `en-US`) that will be sent\n * with the requests to the server as `Accept-Language` header.\n */\n lang: string;\n\n /**\n * A replaceable instance of the local auth store service.\n */\n authStore: BaseAuthStore;\n\n /**\n * An instance of the service that handles the **Settings APIs**.\n */\n readonly settings: SettingsService;\n\n /**\n * An instance of the service that handles the **Admin APIs**.\n */\n readonly admins: AdminService;\n\n /**\n * An instance of the service that handles the **Collection APIs**.\n */\n readonly collections: CollectionService;\n\n /**\n * An instance of the service that handles the **File APIs**.\n */\n readonly files: FileService;\n\n /**\n * An instance of the service that handles the **Log APIs**.\n */\n readonly logs: LogService;\n\n /**\n * An instance of the service that handles the **Realtime APIs**.\n */\n readonly realtime: RealtimeService;\n\n /**\n * An instance of the service that handles the **Health APIs**.\n */\n readonly health: HealthService;\n\n /**\n * An instance of the service that handles the **Backup APIs**.\n */\n readonly backups: BackupService;\n\n private cancelControllers: { [key: string]: AbortController } = {};\n private recordServices: { [key: string]: RecordService } = {};\n private enableAutoCancellation: boolean = true;\n\n constructor(\n baseUrl = '/',\n authStore?: BaseAuthStore | null,\n lang = 'en-US',\n ) {\n this.baseUrl = baseUrl;\n this.lang = lang;\n this.authStore = authStore || new LocalAuthStore();\n\n // services\n this.admins = new AdminService(this);\n this.collections = new CollectionService(this);\n this.files = new FileService(this);\n this.logs = new LogService(this);\n this.settings = new SettingsService(this);\n this.realtime = new RealtimeService(this);\n this.health = new HealthService(this);\n this.backups = new BackupService(this);\n }\n\n /**\n * Returns the RecordService associated to the specified collection.\n *\n * @param {string} idOrName\n * @return {RecordService}\n */\n collection(idOrName: string): RecordService {\n if (!this.recordServices[idOrName]) {\n this.recordServices[idOrName] = new RecordService(this, idOrName);\n }\n\n return this.recordServices[idOrName];\n }\n\n /**\n * Globally enable or disable auto cancellation for pending duplicated requests.\n */\n autoCancellation(enable: boolean): Client {\n this.enableAutoCancellation = !!enable;\n\n return this;\n }\n\n /**\n * Cancels single request by its cancellation key.\n */\n cancelRequest(requestKey: string): Client {\n if (this.cancelControllers[requestKey]) {\n this.cancelControllers[requestKey].abort();\n delete this.cancelControllers[requestKey];\n }\n\n return this;\n }\n\n /**\n * Cancels all pending requests.\n */\n cancelAllRequests(): Client {\n for (let k in this.cancelControllers) {\n this.cancelControllers[k].abort();\n }\n\n this.cancelControllers = {};\n\n return this;\n }\n\n /**\n * Legacy alias of `pb.files.getUrl()`.\n */\n getFileUrl(\n record: Pick<{[key:string]:any}, 'id' | 'collectionId' | 'collectionName'>,\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n return this.files.getUrl(record, filename, queryParams);\n }\n\n /**\n * Builds a full client url by safely concatenating the provided path.\n */\n buildUrl(path: string): string {\n let url = this.baseUrl;\n\n // construct an absolute base url if in a browser environment\n if (\n typeof window !== 'undefined' &&\n !!window.location &&\n !url.startsWith('https://') &&\n !url.startsWith('http://')\n ) {\n url = window.location.origin?.endsWith('/') ?\n window.location.origin.substring(0, window.location.origin.length - 1) :\n (window.location.origin || '');\n\n if (!this.baseUrl.startsWith('/')) {\n url += window.location.pathname || '/';\n url += url.endsWith('/') ? '' : '/';\n }\n\n url += this.baseUrl;\n }\n\n // concatenate the path\n if (path) {\n url += url.endsWith('/') ? '' : '/'; // append trailing slash if missing\n url += path.startsWith('/') ? path.substring(1) : path;\n }\n\n return url;\n }\n\n /**\n * Sends an api http request.\n */\n async send(path: string, options: SendOptions): Promise {\n options = this.initSendOptions(path, options);\n\n // build url + path\n let url = this.buildUrl(path);\n\n // serialize the query parameters\n if (typeof options.query !== 'undefined') {\n const query = this.serializeQueryParams(options.query)\n if (query) {\n url += (url.includes('?') ? '&' : '?') + query;\n }\n delete options.query;\n }\n\n if (this.beforeSend) {\n const result = Object.assign({}, await this.beforeSend(url, options));\n if (typeof result.url !== 'undefined' || typeof result.options !== 'undefined') {\n url = result.url || url;\n options = result.options || options;\n } else if (Object.keys(result).length) {\n // legacy behavior\n options = result as SendOptions;\n console?.warn && console.warn('Deprecated format of beforeSend return: please use `return { url, options }`, instead of `return options`.');\n }\n }\n\n // ensures that the json body is serialized\n if (\n this.getHeader(options.headers, 'Content-Type') == 'application/json' &&\n options.body && typeof options.body !== 'string'\n ) {\n options.body = JSON.stringify(options.body);\n }\n\n const fetchFunc = options.fetch || fetch;\n\n // send the request\n return fetchFunc(url, options)\n .then(async (response) => {\n let data : any = {};\n\n try {\n data = await response.json();\n } catch (_) {\n // all api responses are expected to return json\n // with the exception of the realtime event and 204\n }\n\n if (this.afterSend) {\n data = await this.afterSend(response, data);\n }\n\n if (response.status >= 400) {\n throw new ClientResponseError({\n url: response.url,\n status: response.status,\n data: data,\n });\n }\n\n return data as T;\n }).catch((err) => {\n // wrap to normalize all errors\n throw new ClientResponseError(err);\n });\n }\n\n /**\n * Shallow copy the provided object and takes care to initialize\n * any options required to preserve the backward compatability.\n *\n * @param {SendOptions} options\n * @return {SendOptions}\n */\n private initSendOptions(path: string, options: SendOptions): SendOptions {\n options = Object.assign({ method: 'GET' } as SendOptions, options)\n options.query = options.query || {};\n\n // auto convert the body to FormData, if needed\n options.body = this.convertToFormDataIfNeeded(options.body);\n\n // move unknown send options as query parameters\n for (let key in options) {\n if (knownSendOptionsKeys.includes(key)) {\n continue\n }\n\n options.query[key] = options[key];\n delete (options[key]);\n }\n\n // requestKey normalizations for backward-compatibility\n // ---\n options.query = Object.assign({}, options.params, options.query);\n if (typeof options.requestKey === 'undefined') {\n if (options.$autoCancel === false || options.query.$autoCancel === false) {\n options.requestKey = null;\n } else if (options.$cancelKey || options.query.$cancelKey) {\n options.requestKey = options.$cancelKey || options.query.$cancelKey;\n }\n }\n // remove the deprecated special cancellation params from the other query params\n delete options.$autoCancel;\n delete options.query.$autoCancel;\n delete options.$cancelKey;\n delete options.query.$cancelKey;\n // ---\n\n // add the json header, if not explicitly set\n // (for FormData body the Content-Type header should be skipped since the boundary is autogenerated)\n if (\n this.getHeader(options.headers, 'Content-Type') === null &&\n !this.isFormData(options.body)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Content-Type': 'application/json',\n });\n }\n\n // add Accept-Language header, if not explicitly set\n if (this.getHeader(options.headers, 'Accept-Language') === null) {\n options.headers = Object.assign({}, options.headers, {\n 'Accept-Language': this.lang,\n });\n }\n\n // check if Authorization header can be added\n if (\n // has valid token\n this.authStore.token &&\n // auth header is not explicitly set\n (this.getHeader(options.headers, 'Authorization') === null)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Authorization': this.authStore.token,\n });\n }\n\n // handle auto cancelation for duplicated pending request\n if (this.enableAutoCancellation && options.requestKey !== null) {\n const requestKey = options.requestKey || ((options.method || 'GET') + path);\n\n delete options.requestKey;\n\n // cancel previous pending requests\n this.cancelRequest(requestKey);\n\n const controller = new AbortController();\n this.cancelControllers[requestKey] = controller;\n options.signal = controller.signal;\n }\n\n return options\n }\n\n /**\n * Converts analyzes the provided body and converts it to FormData\n * in case a plain object with File/Blob values is used.\n */\n private convertToFormDataIfNeeded(body: any): any {\n if (\n typeof FormData === 'undefined' ||\n typeof body === \"undefined\" ||\n typeof body !== \"object\" ||\n body === null ||\n this.isFormData(body) ||\n !this.hasBlobField(body)\n ) {\n return body;\n }\n\n const form = new FormData();\n\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let val of values) {\n form.append(key, val);\n }\n }\n\n return form;\n }\n\n /**\n * Checks if the submitted body object has at least one Blob/File field.\n */\n private hasBlobField(body: {[key:string]: any}): boolean {\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let v of values) {\n if (\n (typeof Blob !== 'undefined' && v instanceof Blob) ||\n (typeof File !== 'undefined' && v instanceof File)\n ) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /**\n * Extracts the header with the provided name in case-insensitive manner.\n * Returns `null` if no header matching the name is found.\n */\n private getHeader(headers: {[key:string]:string}|undefined, name: string): string|null {\n headers = headers || {};\n name = name.toLowerCase();\n\n for (let key in headers) {\n if (key.toLowerCase() == name) {\n return headers[key];\n }\n }\n\n return null;\n }\n\n /**\n * Loosely checks if the specified body is a FormData instance.\n */\n private isFormData(body: any): boolean {\n return body && (\n // we are checking the constructor name because FormData\n // is not available natively in some environments and the\n // polyfill(s) may not be globally accessible\n body.constructor.name === 'FormData' ||\n // fallback to global FormData instance check\n // note: this is needed because the constructor.name could be different in case of\n // custom global FormData implementation, eg. React Native on Android/iOS\n (typeof FormData !== 'undefined' && body instanceof FormData)\n )\n }\n\n /**\n * Serializes the provided query parameters into a query string.\n */\n private serializeQueryParams(params: {[key: string]: any}): string {\n const result: Array = [];\n for (const key in params) {\n if (params[key] === null) {\n // skip null query params\n continue;\n }\n\n const value = params[key];\n const encodedKey = encodeURIComponent(key);\n\n if (Array.isArray(value)) {\n // repeat array params\n for (const v of value) {\n result.push(encodedKey + '=' + encodeURIComponent(v));\n }\n } else if (value instanceof Date) {\n result.push(encodedKey + '=' + encodeURIComponent(value.toISOString()));\n } else if (typeof value !== null && typeof value === 'object') {\n result.push(encodedKey + '=' + encodeURIComponent(JSON.stringify(value)));\n } else {\n result.push(encodedKey + '=' + encodeURIComponent(value));\n }\n }\n\n return result.join('&');\n }\n}\n","import { BaseAuthStore, AuthModel } from '@/stores/BaseAuthStore';\n\nexport type AsyncSaveFunc = (serializedPayload: string) => Promise;\n\nexport type AsyncClearFunc = () => Promise;\n\ntype queueFunc = () => Promise;\n\n/**\n * AsyncAuthStore is a helper auth store implementation\n * that could be used with any external async persistent layer\n * (key-value db, local file, etc.).\n *\n * Here is an example with the React Native AsyncStorage package:\n *\n * ```\n * import AsyncStorage from \"@react-native-async-storage/async-storage\";\n * import PocketBase, { AsyncAuthStore } from \"pocketbase\";\n *\n * const store = new AsyncAuthStore({\n * save: async (serialized) => AsyncStorage.setItem(\"pb_auth\", serialized),\n * initial: await AsyncStorage.getItem(\"pb_auth\"),\n * });\n *\n * const pb = new PocketBase(\"https://example.com\", store)\n * ```\n */\nexport class AsyncAuthStore extends BaseAuthStore {\n private saveFunc: AsyncSaveFunc;\n private clearFunc?: AsyncClearFunc;\n private queue: Array = [];\n\n constructor(config: {\n // The async function that is called every time\n // when the auth store state needs to be persisted.\n save: AsyncSaveFunc,\n\n /// An *optional* async function that is called every time\n /// when the auth store needs to be cleared.\n ///\n /// If not explicitly set, `saveFunc` with empty data will be used.\n clear?: AsyncClearFunc,\n\n // initial data to load into the store\n initial?: string,\n }) {\n super();\n\n this.saveFunc = config.save;\n this.clearFunc = config.clear;\n\n this._loadInitial(config.initial);\n }\n\n /**\n * @inheritdoc\n */\n save(token: string, model?: AuthModel): void {\n super.save(token, model);\n\n let value = '';\n try {\n value = JSON.stringify({token, model})\n } catch (err) {\n console.warn('AsyncAuthStore: failed to stringify the new state');\n }\n\n this._enqueue(() => this.saveFunc(value));\n }\n\n /**\n * @inheritdoc\n */\n clear(): void {\n super.clear();\n\n if (this.clearFunc) {\n this._enqueue(() => this.clearFunc!());\n } else {\n this._enqueue(() => this.saveFunc(\"\"));\n }\n }\n\n\n /**\n * Initializes the auth store state.\n */\n private _loadInitial(payload?: string) {\n if (!payload) {\n return; // nothing to load\n }\n\n try {\n const parsed = JSON.parse(payload) || {};\n\n this.save(parsed.token || \"\", parsed.model || null);\n } catch (_) {}\n }\n\n /**\n * Appends an async function to the queue.\n */\n private _enqueue(asyncCallback: () => Promise) {\n this.queue.push(asyncCallback);\n\n if (this.queue.length == 1) {\n this._dequeue();\n }\n }\n\n /**\n * Starts the queue processing.\n */\n private _dequeue() {\n if (!this.queue.length) {\n return;\n }\n\n this.queue[0]().finally(() => {\n this.queue.shift();\n\n if (!this.queue.length) {\n return;\n }\n\n this._dequeue();\n });\n }\n}\n"],"names":["ClientResponseError","Error","constructor","errData","super","this","url","status","response","isAbort","originalError","Object","setPrototypeOf","prototype","data","DOMException","name","message","_a","_d","_c","_b","cause","includes","toJSON","assign","fieldContentRegExp","cookieParse","str","options","result","decode","defaultDecode","index","length","eqIdx","indexOf","endIdx","lastIndexOf","key","slice","trim","undefined","val","charCodeAt","_","cookieSerialize","opt","encode","defaultEncode","test","TypeError","value","maxAge","isNaN","isFinite","Math","floor","domain","path","expires","isDate","toString","call","Date","valueOf","toUTCString","httpOnly","secure","priority","toLowerCase","sameSite","decodeURIComponent","encodeURIComponent","atobPolyfill","getTokenPayload","token","encodedPayload","split","map","c","join","JSON","parse","e","isTokenExpired","expirationThreshold","payload","keys","exp","now","atob","input","String","replace","bs","buffer","bc","idx","output","charAt","fromCharCode","defaultCookieKey","BaseAuthStore","baseToken","baseModel","_onChangeCallbacks","model","isValid","isAdmin","type","isAuthRecord","save","triggerChange","clear","loadFromCookie","cookie","rawData","Array","isArray","exportToCookie","defaultOptions","stringify","resultLength","Blob","size","id","email","extraProps","prop","onChange","callback","fireImmediately","push","i","splice","LocalAuthStore","storageKey","storageFallback","_bindStorageEvent","_storageGet","_storageSet","_storageRemove","window","localStorage","rawValue","getItem","normalizedVal","setItem","removeItem","addEventListener","BaseService","client","SettingsService","getAll","method","send","update","bodyParams","body","testS3","filesystem","then","testEmail","toEmail","emailTemplate","template","generateAppleClientSecret","clientId","teamId","keyId","privateKey","duration","CrudService","getFullList","batchOrqueryParams","_getFullList","batch","getList","page","perPage","query","baseCrudPath","responseData","items","item","getFirstListItem","filter","requestKey","skipTotal","code","getOne","create","batchSize","request","__awaiter","list","concat","normalizeLegacyOptionsArgs","legacyWarn","baseOptions","bodyOrOptions","hasQuery","console","warn","AdminService","authStore","collectionId","delete","success","authResponse","admin","authWithPassword","password","identity","bind","authRefresh","requestPasswordReset","confirmPasswordReset","resetToken","passwordConfirm","RealtimeService","eventSource","subscriptions","lastSentTopics","maxConnectTimeout","reconnectAttempts","maxReconnectAttempts","Infinity","predefinedReconnectIntervals","pendingConnects","isConnected","subscribe","topic","listener","msgEvent","submitSubscriptions","connect","unsubscribeByTopicAndListener","unsubscribe","hasSubscriptionListeners","removeEventListener","disconnect","unsubscribeByPrefix","topicPrefix","hasAtleastOneTopic","startsWith","exist","topicToCheck","addAllSubscriptionListeners","getNonEmptySubscriptionTopics","getSubscriptionsCancelKey","catch","err","removeAllSubscriptionListeners","Promise","resolve","reject","initConnect","clearTimeout","connectTimeoutId","setTimeout","connectErrorHandler","EventSource","buildUrl","onerror","lastEventId","retries","hasUnsentSubscriptions","p","reconnectTimeoutId","latestTopics","t","timeout","fromReconnect","cancelRequest","close","RecordService","collectionIdOrName","baseCollectionPath","subscribeOne","recordId","realtime","topicOrCallback","batchOrOptions","params","collectionName","record","listAuthMethods","usernamePassword","emailPassword","authProviders","usernameOrEmail","authWithOAuth2Code","provider","codeVerifier","redirectUrl","createData","authWithOAuth2","args","config","find","eagerDefaultPopup","cleanup","urlCallback","openBrowserPopup","oldState","state","scopes","authData","replacements","_replaceQueryParams","authUrl","location","href","passwordResetToken","requestVerification","confirmVerification","verificationToken","requestEmailChange","newEmail","confirmEmailChange","emailChangeToken","listExternalAuths","unlinkExternalAuth","urlPath","substring","parsedParams","rawParams","param","pair","hasOwnProperty","open","width","height","windowWidth","innerWidth","windowHeight","innerHeight","left","top","CollectionService","import","collections","deleteMissing","LogService","getRequestsList","getRequest","getRequestsStats","HealthService","check","FileService","getUrl","filename","queryParams","parts","download","URLSearchParams","getToken","BackupService","basename","restore","getDownloadUrl","knownSendOptionsKeys","Client","baseUrl","lang","cancelControllers","recordServices","enableAutoCancellation","admins","files","logs","settings","health","backups","collection","idOrName","autoCancellation","enable","abort","cancelAllRequests","k","getFileUrl","origin","endsWith","pathname","initSendOptions","serializeQueryParams","beforeSend","getHeader","headers","fetch","json","afterSend","convertToFormDataIfNeeded","$autoCancel","$cancelKey","isFormData","Authorization","controller","AbortController","signal","FormData","hasBlobField","form","values","append","v","File","encodedKey","toISOString","AsyncAuthStore","queue","saveFunc","clearFunc","_loadInitial","initial","_enqueue","parsed","asyncCallback","_dequeue","finally","shift"],"mappings":"4ZAIM,MAAOA,4BAA4BC,MAOrC,WAAAC,CAAYC,eACRC,MAAM,uBAPVC,KAAGC,IAA8B,GACjCD,KAAME,OAA2B,EACjCF,KAAQG,SAAyB,GACjCH,KAAOI,SAA0B,EACjCJ,KAAaK,cAAoB,KAO7BC,OAAOC,eAAeP,KAAML,oBAAoBa,WAEhC,OAAZV,GAAuC,iBAAZA,IAC3BE,KAAKC,IAAuC,iBAAhBH,EAAQG,IAAmBH,EAAQG,IAAM,GACrED,KAAKE,OAA0C,iBAAnBJ,EAAQI,OAAsBJ,EAAQI,OAAS,EAC3EF,KAAKI,UAAkBN,EAAQM,QAC/B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GACjB,GAAKA,EAIL,IACI,MAAM4U,EAASjV,KAAKC,MAAMI,IAAY,CAAA,EAEtClF,KAAK2G,KAAKmT,EAAOvV,OAAS,GAAIuV,EAAOxT,OAAS,KACjD,CAAC,MAAO9D,GAAK,CACjB,CAKO,QAAAqX,CAASE,GACb/Z,KAAKwZ,MAAMxR,KAAK+R,GAES,GAArB/Z,KAAKwZ,MAAM3X,QACX7B,KAAKga,UAEZ,CAKO,QAAAA,GACCha,KAAKwZ,MAAM3X,QAIhB7B,KAAKwZ,MAAM,KAAKS,SAAQ,KACpBja,KAAKwZ,MAAMU,QAENla,KAAKwZ,MAAM3X,QAIhB7B,KAAKga,UAAU,GAEtB"} \ No newline at end of file +{"version":3,"file":"pocketbase.es.js","sources":["../src/ClientResponseError.ts","../src/stores/utils/cookie.ts","../src/stores/utils/jwt.ts","../src/stores/BaseAuthStore.ts","../src/stores/LocalAuthStore.ts","../src/services/utils/BaseService.ts","../src/services/SettingsService.ts","../src/services/utils/CrudService.ts","../src/services/utils/legacy.ts","../src/services/AdminService.ts","../src/services/RealtimeService.ts","../src/services/RecordService.ts","../src/services/CollectionService.ts","../src/services/LogService.ts","../src/services/HealthService.ts","../src/services/FileService.ts","../src/services/BackupService.ts","../src/Client.ts","../src/stores/AsyncAuthStore.ts"],"sourcesContent":["/**\n * ClientResponseError is a custom Error class that is intended to wrap\n * and normalize any error thrown by `Client.send()`.\n */\nexport class ClientResponseError extends Error {\n url: string = '';\n status: number = 0;\n response: {[key: string]: any} = {};\n isAbort: boolean = false;\n originalError: any = null;\n\n constructor(errData?: any) {\n super(\"ClientResponseError\");\n\n // Set the prototype explicitly.\n // https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\n Object.setPrototypeOf(this, ClientResponseError.prototype);\n\n if (errData !== null && typeof errData === 'object') {\n this.url = typeof errData.url === 'string' ? errData.url : '';\n this.status = typeof errData.status === 'number' ? errData.status : 0;\n this.isAbort = !!errData.isAbort;\n this.originalError = errData.originalError;\n\n if (errData.response !== null && typeof errData.response === 'object') {\n this.response = errData.response;\n } else if (errData.data !== null && typeof errData.data === 'object') {\n this.response = errData.data;\n } else {\n this.response = {};\n }\n }\n\n if (!this.originalError && !(errData instanceof ClientResponseError)) {\n this.originalError = errData;\n }\n\n if (typeof DOMException !== 'undefined' && errData instanceof DOMException) {\n this.isAbort = true;\n }\n\n this.name = \"ClientResponseError \" + this.status;\n this.message = this.response?.message;\n if (!this.message) {\n if (this.isAbort) {\n this.message = 'The request was autocancelled. You can find more info in https://github.com/pocketbase/js-sdk#auto-cancellation.';\n } else if (this.originalError?.cause?.message?.includes(\"ECONNREFUSED ::1\")) {\n this.message = 'Failed to connect to the PocketBase server. Try changing the SDK URL from localhost to 127.0.0.1 (https://github.com/pocketbase/js-sdk/issues/21).';\n } else {\n this.message = 'Something went wrong while processing your request.';\n }\n }\n }\n\n /**\n * Alias for `this.response` to preserve the backward compatibility.\n */\n get data() {\n return this.response;\n }\n\n /**\n * Make a POJO's copy of the current error class instance.\n * @see https://github.com/vuex-orm/vuex-orm/issues/255\n */\n toJSON() {\n return { ...this };\n }\n}\n","/**\n * -------------------------------------------------------------------\n * Simple cookie parse and serialize utilities mostly based on the\n * node module https://github.com/jshttp/cookie.\n * -------------------------------------------------------------------\n */\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\nconst fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;\n\nexport interface ParseOptions{\n decode?: (val: string) => string,\n}\n\n/**\n* Parses the given cookie header string into an object\n* The object has the various cookies as keys(names) => values\n*/\nexport function cookieParse(str: string, options?: ParseOptions): { [key: string]: any } {\n const result: { [key: string]: any } = {};\n\n if (typeof str !== 'string') {\n return result;\n }\n\n const opt = Object.assign({}, options || {});\n const decode = opt.decode || defaultDecode;\n\n let index = 0;\n while (index < str.length) {\n const eqIdx = str.indexOf('=', index);\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break;\n }\n\n let endIdx = str.indexOf(';', index);\n\n if (endIdx === -1) {\n endIdx = str.length;\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(';', eqIdx - 1) + 1;\n continue;\n }\n\n const key = str.slice(index, eqIdx).trim();\n\n // only assign once\n if (undefined === result[key]) {\n let val = str.slice(eqIdx + 1, endIdx).trim();\n\n // quoted values\n if (val.charCodeAt(0) === 0x22) {\n val = val.slice(1, -1);\n }\n\n try {\n result[key] = decode(val);\n } catch (_) {\n result[key] = val; // no decoding\n }\n }\n\n index = endIdx + 1;\n }\n\n return result;\n};\n\nexport interface SerializeOptions {\n encode?: (val: string | number | boolean) => string,\n maxAge?: number,\n domain?: string,\n path?: string,\n expires?: Date,\n httpOnly?: boolean,\n secure?: boolean,\n priority?: string,\n sameSite?: boolean|string,\n}\n\n/**\n * Serialize data into a cookie header.\n *\n * Serialize the a name value pair into a cookie string suitable for\n * http headers. An optional options object specified cookie parameters.\n *\n * ```js\n * cookieSerialize('foo', 'bar', { httpOnly: true }) // \"foo=bar; httpOnly\"\n * ```\n */\nexport function cookieSerialize(name: string, val: string, options?: SerializeOptions): string {\n const opt = Object.assign({}, options || {});\n const encode = opt.encode || defaultEncode;\n\n if (!fieldContentRegExp.test(name)) {\n throw new TypeError('argument name is invalid');\n }\n\n const value = encode(val);\n\n if (value && !fieldContentRegExp.test(value)) {\n throw new TypeError('argument val is invalid');\n }\n\n let result = name + '=' + value;\n\n if (opt.maxAge != null) {\n const maxAge = opt.maxAge - 0;\n\n if (isNaN(maxAge) || !isFinite(maxAge)) {\n throw new TypeError('option maxAge is invalid');\n }\n\n result += '; Max-Age=' + Math.floor(maxAge);\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new TypeError('option domain is invalid');\n }\n\n result += '; Domain=' + opt.domain;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new TypeError('option path is invalid');\n }\n\n result += '; Path=' + opt.path;\n }\n\n if (opt.expires) {\n if (!isDate(opt.expires) || isNaN(opt.expires.valueOf())) {\n throw new TypeError('option expires is invalid');\n }\n\n result += '; Expires=' + opt.expires.toUTCString();\n }\n\n if (opt.httpOnly) {\n result += '; HttpOnly';\n }\n\n if (opt.secure) {\n result += '; Secure';\n }\n\n if (opt.priority) {\n const priority = typeof opt.priority === 'string' ? opt.priority.toLowerCase() : opt.priority;\n\n switch (priority) {\n case 'low':\n result += '; Priority=Low';\n break;\n case 'medium':\n result += '; Priority=Medium';\n break;\n case 'high':\n result += '; Priority=High';\n break;\n default:\n throw new TypeError('option priority is invalid');\n }\n }\n\n if (opt.sameSite) {\n const sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;\n\n switch (sameSite) {\n case true:\n result += '; SameSite=Strict';\n break;\n case 'lax':\n result += '; SameSite=Lax';\n break;\n case 'strict':\n result += '; SameSite=Strict';\n break;\n case 'none':\n result += '; SameSite=None';\n break;\n default:\n throw new TypeError('option sameSite is invalid');\n }\n }\n\n return result;\n};\n\n/**\n * Default URL-decode string value function.\n * Optimized to skip native call when no `%`.\n */\nfunction defaultDecode(val: string): string {\n return val.indexOf('%') !== -1\n ? decodeURIComponent(val)\n : val;\n}\n\n/**\n * Default URL-encode value function.\n */\nfunction defaultEncode(val: string | number | boolean): string {\n return encodeURIComponent(val);\n}\n\n/**\n * Determines if value is a Date.\n */\nfunction isDate(val: any): boolean {\n return (\n Object.prototype.toString.call(val) === '[object Date]' ||\n val instanceof Date\n );\n}\n","let atobPolyfill: Function;\nif (typeof atob === 'function') {\n atobPolyfill = atob\n} else {\n /**\n * The code was extracted from:\n * https://github.com/davidchambers/Base64.js\n */\n atobPolyfill = (input: any) => {\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\n let str = String(input).replace(/=+$/, \"\");\n if (str.length % 4 == 1) {\n throw new Error(\"'atob' failed: The string to be decoded is not correctly encoded.\");\n }\n\n for (\n // initialize result and counters\n var bc = 0, bs, buffer, idx = 0, output = \"\";\n // get next character\n (buffer = str.charAt(idx++));\n // character found in table? initialize bit storage and add its ascii value;\n ~buffer &&\n ((bs = bc % 4 ? (bs as any) * 64 + buffer : buffer),\n // and if not first of each 4 characters,\n // convert the first 8 bits to one ascii character\n bc++ % 4) ?\n (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)))) :\n 0\n ) {\n // try to find character in table (0-63, not found => -1)\n buffer = chars.indexOf(buffer);\n }\n\n return output;\n };\n}\n\n/**\n * Returns JWT token's payload data.\n */\nexport function getTokenPayload(token: string): { [key: string]: any } {\n if (token) {\n try {\n const encodedPayload = decodeURIComponent(atobPolyfill(token.split('.')[1]).split('').map(function (c: string) {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n }).join(''));\n\n return JSON.parse(encodedPayload) || {};\n } catch (e) {\n }\n }\n\n return {};\n}\n\n/**\n * Checks whether a JWT token is expired or not.\n * Tokens without `exp` payload key are considered valid.\n * Tokens with empty payload (eg. invalid token strings) are considered expired.\n *\n * @param token The token to check.\n * @param [expirationThreshold] Time in seconds that will be subtracted from the token `exp` property.\n */\nexport function isTokenExpired(token: string, expirationThreshold = 0): boolean {\n let payload = getTokenPayload(token);\n\n if (\n Object.keys(payload).length > 0 &&\n (!payload.exp || (payload.exp - expirationThreshold) > (Date.now() / 1000))\n ) {\n return false;\n }\n\n return true;\n}\n","import { cookieParse, cookieSerialize, SerializeOptions } from '@/stores/utils/cookie';\nimport { isTokenExpired, getTokenPayload } from '@/stores/utils/jwt';\nimport { RecordModel, AdminModel } from '@/services/utils/dtos';\n\nexport type AuthModel = RecordModel|AdminModel|null;\n\nexport type OnStoreChangeFunc = (token: string, model: AuthModel) => void;\n\nconst defaultCookieKey = 'pb_auth';\n\n/**\n * Base AuthStore class that is intended to be extended by all other\n * PocketBase AuthStore implementations.\n */\nexport abstract class BaseAuthStore {\n protected baseToken: string = '';\n protected baseModel: AuthModel = null;\n\n private _onChangeCallbacks: Array = [];\n\n /**\n * Retrieves the stored token (if any).\n */\n get token(): string {\n return this.baseToken;\n }\n\n /**\n * Retrieves the stored model data (if any).\n */\n get model(): AuthModel {\n return this.baseModel;\n }\n\n /**\n * Loosely checks if the store has valid token (aka. existing and unexpired exp claim).\n */\n get isValid(): boolean {\n return !isTokenExpired(this.token);\n }\n\n /**\n * Checks whether the current store state is for admin authentication.\n */\n get isAdmin(): boolean {\n return getTokenPayload(this.token).type === \"admin\";\n }\n\n /**\n * Checks whether the current store state is for auth record authentication.\n */\n get isAuthRecord(): boolean {\n return getTokenPayload(this.token).type === \"authRecord\";\n }\n\n /**\n * Saves the provided new token and model data in the auth store.\n */\n save(token: string, model?: AuthModel): void {\n this.baseToken = token || '';\n this.baseModel = model || null;\n\n this.triggerChange();\n }\n\n /**\n * Removes the stored token and model data form the auth store.\n */\n clear(): void {\n this.baseToken = '';\n this.baseModel = null;\n this.triggerChange();\n }\n\n /**\n * Parses the provided cookie string and updates the store state\n * with the cookie's token and model data.\n *\n * NB! This function doesn't validate the token or its data.\n * Usually this isn't a concern if you are interacting only with the\n * PocketBase API because it has the proper server-side security checks in place,\n * but if you are using the store `isValid` state for permission controls\n * in a node server (eg. SSR), then it is recommended to call `authRefresh()`\n * after loading the cookie to ensure an up-to-date token and model state.\n * For example:\n *\n * ```js\n * pb.authStore.loadFromCookie(\"cookie string...\");\n *\n * try {\n * // get an up-to-date auth store state by veryfing and refreshing the loaded auth model (if any)\n * pb.authStore.isValid && await pb.collection('users').authRefresh();\n * } catch (_) {\n * // clear the auth store on failed refresh\n * pb.authStore.clear();\n * }\n * ```\n */\n loadFromCookie(cookie: string, key = defaultCookieKey): void {\n const rawData = cookieParse(cookie || '')[key] || '';\n\n let data: { [key: string]: any } = {};\n try {\n data = JSON.parse(rawData);\n // normalize\n if (typeof data === null || typeof data !== 'object' || Array.isArray(data)) {\n data = {};\n }\n } catch (_) {}\n\n this.save(data.token || '', data.model || null);\n }\n\n /**\n * Exports the current store state as cookie string.\n *\n * By default the following optional attributes are added:\n * - Secure\n * - HttpOnly\n * - SameSite=Strict\n * - Path=/\n * - Expires={the token expiration date}\n *\n * NB! If the generated cookie exceeds 4096 bytes, this method will\n * strip the model data to the bare minimum to try to fit within the\n * recommended size in https://www.rfc-editor.org/rfc/rfc6265#section-6.1.\n */\n exportToCookie(options?: SerializeOptions, key = defaultCookieKey): string {\n const defaultOptions: SerializeOptions = {\n secure: true,\n sameSite: true,\n httpOnly: true,\n path: \"/\",\n };\n\n // extract the token expiration date\n const payload = getTokenPayload(this.token);\n if (payload?.exp) {\n defaultOptions.expires = new Date(payload.exp * 1000);\n } else {\n defaultOptions.expires = new Date('1970-01-01');\n }\n\n // merge with the user defined options\n options = Object.assign({}, defaultOptions, options);\n\n const rawData = {\n token: this.token,\n model: this.model ? JSON.parse(JSON.stringify(this.model)) : null,\n };\n\n let result = cookieSerialize(key, JSON.stringify(rawData), options);\n\n const resultLength = typeof Blob !== 'undefined' ?\n (new Blob([result])).size : result.length;\n\n // strip down the model data to the bare minimum\n if (rawData.model && resultLength > 4096) {\n rawData.model = {id: rawData?.model?.id, email: rawData?.model?.email};\n const extraProps = [\"collectionId\", \"username\", \"verified\"];\n for (const prop in this.model) {\n if (extraProps.includes(prop)) {\n rawData.model[prop] = this.model[prop];\n }\n }\n result = cookieSerialize(key, JSON.stringify(rawData), options);\n }\n\n return result;\n }\n\n /**\n * Register a callback function that will be called on store change.\n *\n * You can set the `fireImmediately` argument to true in order to invoke\n * the provided callback right after registration.\n *\n * Returns a removal function that you could call to \"unsubscribe\" from the changes.\n */\n onChange(callback: OnStoreChangeFunc, fireImmediately = false): () => void {\n this._onChangeCallbacks.push(callback);\n\n if (fireImmediately) {\n callback(this.token, this.model);\n }\n\n return () => {\n for (let i = this._onChangeCallbacks.length - 1; i >= 0; i--) {\n if (this._onChangeCallbacks[i] == callback) {\n delete this._onChangeCallbacks[i]; // removes the function reference\n this._onChangeCallbacks.splice(i, 1); // reindex the array\n return;\n }\n }\n }\n }\n\n protected triggerChange(): void {\n for (const callback of this._onChangeCallbacks) {\n callback && callback(this.token, this.model);\n }\n }\n}\n","import { BaseAuthStore, AuthModel } from '@/stores/BaseAuthStore';\n\n/**\n * The default token store for browsers with auto fallback\n * to runtime/memory if local storage is undefined (eg. in node env).\n */\nexport class LocalAuthStore extends BaseAuthStore {\n private storageFallback: { [key: string]: any } = {};\n private storageKey: string\n\n constructor(storageKey = \"pocketbase_auth\") {\n super();\n\n this.storageKey = storageKey;\n\n this._bindStorageEvent();\n }\n\n /**\n * @inheritdoc\n */\n get token(): string {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.token || '';\n }\n\n /**\n * @inheritdoc\n */\n get model(): AuthModel {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.model || null;\n }\n\n /**\n * @inheritdoc\n */\n save(token: string, model?: AuthModel) {\n this._storageSet(this.storageKey, {\n 'token': token,\n 'model': model,\n });\n\n super.save(token, model);\n }\n\n /**\n * @inheritdoc\n */\n clear() {\n this._storageRemove(this.storageKey);\n\n super.clear();\n }\n\n // ---------------------------------------------------------------\n // Internal helpers:\n // ---------------------------------------------------------------\n\n /**\n * Retrieves `key` from the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageGet(key: string): any {\n if (typeof window !== 'undefined' && window?.localStorage) {\n const rawValue = window.localStorage.getItem(key) || '';\n try {\n return JSON.parse(rawValue);\n } catch (e) { // not a json\n return rawValue;\n }\n }\n\n // fallback\n return this.storageFallback[key];\n }\n\n /**\n * Stores a new data in the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageSet(key: string, value: any) {\n if (typeof window !== 'undefined' && window?.localStorage) {\n // store in local storage\n let normalizedVal = value;\n if (typeof value !== 'string') {\n normalizedVal = JSON.stringify(value);\n }\n window.localStorage.setItem(key, normalizedVal);\n } else {\n // store in fallback\n this.storageFallback[key] = value;\n }\n }\n\n /**\n * Removes `key` from the browser's local storage and the runtime/memory.\n */\n private _storageRemove(key: string) {\n // delete from local storage\n if (typeof window !== 'undefined' && window?.localStorage) {\n window.localStorage?.removeItem(key);\n }\n\n // delete from fallback\n delete this.storageFallback[key];\n }\n\n /**\n * Updates the current store state on localStorage change.\n */\n private _bindStorageEvent() {\n if (typeof window === 'undefined' || !window?.localStorage || !window.addEventListener) {\n return;\n }\n\n window.addEventListener('storage', (e) => {\n if (e.key != this.storageKey) {\n return;\n }\n\n const data = this._storageGet(this.storageKey) || {};\n\n super.save(data.token || '', data.model || null);\n });\n }\n}\n","import Client from '@/Client';\n\n/**\n * BaseService class that should be inherited from all API services.\n */\nexport abstract class BaseService {\n readonly client: Client\n\n constructor(client: Client) {\n this.client = client;\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\ninterface appleClientSecret {\n secret: string;\n}\n\nexport class SettingsService extends BaseService {\n /**\n * Fetch all available app settings.\n */\n getAll(options?: CommonOptions): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Bulk updates app settings.\n */\n update(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Performs a S3 filesystem connection test.\n *\n * The currently supported `filesystem` are \"storage\" and \"backups\".\n */\n testS3(filesystem: string = \"storage\", options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'filesystem': filesystem,\n },\n }, options);\n\n return this.client.send('/api/settings/test/s3', options)\n .then(() => true);\n }\n\n /**\n * Sends a test email.\n *\n * The possible `emailTemplate` values are:\n * - verification\n * - password-reset\n * - email-change\n */\n testEmail(toEmail: string, emailTemplate: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'email': toEmail,\n 'template': emailTemplate,\n },\n }, options);\n\n return this.client.send('/api/settings/test/email', options)\n .then(() => true);\n }\n\n /**\n * Generates a new Apple OAuth2 client secret.\n */\n generateAppleClientSecret(\n clientId: string,\n teamId: string,\n keyId: string,\n privateKey: string,\n duration: number,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n clientId,\n teamId,\n keyId,\n privateKey,\n duration,\n },\n }, options);\n\n return this.client.send('/api/settings/apple/generate-client-secret', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n FullListOptions\n} from '@/services/utils/options';\n\nexport abstract class CrudService extends BaseService {\n /**\n * Base path for the crud actions (without trailing slash, eg. '/admins').\n */\n abstract get baseCrudPath(): string\n\n /**\n * Response data decoder.\n */\n decode(data: { [key: string]: any }): T {\n return data as T;\n }\n\n /**\n * Returns a promise with all list items batch fetched at once\n * (by default 500 items per request; to change it set the `batch` query param).\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getFullList(options?: FullListOptions): Promise>\n\n /**\n * Legacy version of getFullList with explicitly specified batch size.\n */\n getFullList(batch?: number, options?: ListOptions): Promise>\n\n getFullList(batchOrqueryParams?: number|FullListOptions, options?: ListOptions): Promise> {\n if (typeof batchOrqueryParams == \"number\") {\n return this._getFullList(batchOrqueryParams, options);\n }\n\n options = Object.assign({}, batchOrqueryParams, options);\n\n let batch = 500;\n if (options.batch) {\n batch = options.batch;\n delete options.batch;\n }\n\n return this._getFullList(batch, options);\n }\n\n /**\n * Returns paginated items list.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({\n method: 'GET'\n }, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => {\n responseData.items = responseData.items?.map((item: any) => {\n return this.decode(item);\n }) || [];\n\n return responseData;\n });\n }\n\n /**\n * Returns the first found item by the specified filter.\n *\n * Internally it calls `getList(1, 1, { filter, skipTotal })` and\n * returns the first found item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n *\n * For consistency with `getOne`, this method will throw a 404\n * ClientResponseError if no item was found.\n */\n getFirstListItem(filter: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'requestKey': 'one_by_filter_' + this.baseCrudPath + \"_\" + filter,\n }, options);\n\n options.query = Object.assign({\n 'filter': filter,\n 'skipTotal': 1,\n }, options.query);\n\n return this.getList(1, 1, options)\n .then((result) => {\n if (!result?.items?.length) {\n throw new ClientResponseError({\n status: 404,\n data: {\n code: 404,\n message: \"The requested resource wasn't found.\",\n data: {},\n },\n });\n }\n\n return result.items[0];\n });\n }\n\n /**\n * Returns single item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getOne(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Creates a new item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n create(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Updates an existing item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Deletes an existing item by its id.\n */\n delete(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then(() => true);\n }\n\n /**\n * Returns a promise with all list items batch fetched at once.\n */\n protected _getFullList(batchSize = 500, options?: ListOptions): Promise> {\n options = options || {};\n options.query = Object.assign({\n 'skipTotal': 1,\n }, options.query);\n\n let result: Array = [];\n\n let request = async (page: number): Promise> => {\n return this.getList(page, batchSize || 500, options).then((list) => {\n const castedList = (list as any as ListResult);\n const items = castedList.items;\n\n result = result.concat(items);\n\n if (items.length == list.perPage) {\n return request(page + 1);\n }\n\n return result;\n });\n }\n\n return request(1);\n }\n}\n","import { SendOptions } from '@/services/utils/options';\n\nexport function normalizeLegacyOptionsArgs(legacyWarn: string, baseOptions: SendOptions, bodyOrOptions?: any, query?: any): SendOptions {\n const hasBodyOrOptions = typeof bodyOrOptions !== 'undefined';\n const hasQuery = typeof query !== 'undefined';\n\n if (!hasQuery && !hasBodyOrOptions) {\n return baseOptions;\n }\n\n if (hasQuery) {\n console.warn(legacyWarn);\n baseOptions.body = Object.assign({}, baseOptions.body, bodyOrOptions);\n baseOptions.query = Object.assign({}, baseOptions.query, query);\n\n return baseOptions;\n }\n\n baseOptions = Object.assign(baseOptions, bodyOrOptions);\n return baseOptions;\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { AdminModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface AdminAuthResponse {\n [key: string]: any;\n\n token: string;\n admin: AdminModel;\n}\n\nexport class AdminService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/admins';\n }\n\n // ---------------------------------------------------------------\n // Post update/delete AuthStore sync\n // ---------------------------------------------------------------\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n // update the store state if the updated item id matches with the stored model\n if (\n this.client.authStore.model?.id === item.id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n // clear the store state if the deleted item id matches with the stored model\n if (\n success &&\n this.client.authStore.model?.id === id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful authorize response.\n */\n protected authResponse(responseData: any): AdminAuthResponse {\n const admin = this.decode(responseData?.admin || {});\n\n if (responseData?.token && responseData?.admin) {\n this.client.authStore.save(responseData.token, admin);\n }\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'admin': admin,\n });\n }\n\n /**\n * Authenticate an admin account with its email and password\n * and returns a new admin token and data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authWithPassword(email: string, password: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authWithPassword(email, password, options?).\n */\n authWithPassword(email: string, password: string, body?: any, query?: any): Promise\n\n authWithPassword(\n email: string,\n password: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': email,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(email, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(email, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-with-password', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Refreshes the current admin authenticated instance and\n * returns a new token and admin data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authRefresh(options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-refresh', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Sends admin password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/request-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Confirms admin password reset request.\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(resetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, body?: any, query?: any): Promise\n\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, bodyOrOptions?: any, query?: any): Promise{\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': resetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(resetToken, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(resetToken, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\n\ninterface promiseCallbacks {\n resolve: Function\n reject: Function\n}\n\nexport type UnsubscribeFunc = () => Promise;\n\nexport class RealtimeService extends BaseService {\n clientId: string = \"\";\n\n private eventSource: EventSource | null = null;\n private subscriptions: { [key: string]: Array } = {};\n private lastSentTopics: Array = [];\n private connectTimeoutId: any;\n private maxConnectTimeout: number = 15000;\n private reconnectTimeoutId: any;\n private reconnectAttempts: number = 0;\n private maxReconnectAttempts: number = Infinity;\n private predefinedReconnectIntervals: Array = [\n 200, 300, 500, 1000, 1200, 1500, 2000,\n ];\n private pendingConnects: Array = [];\n\n /**\n * Returns whether the realtime connection has been established.\n */\n get isConnected(): boolean {\n return !!this.eventSource && !!this.clientId && !this.pendingConnects.length;\n }\n\n /**\n * Register the subscription listener.\n *\n * You can subscribe multiple times to the same topic.\n *\n * If the SSE connection is not started yet,\n * this method will also initialize it.\n */\n async subscribe(topic: string, callback: (data: any) => void): Promise {\n if (!topic) {\n throw new Error('topic must be set.')\n }\n\n const listener = function (e: Event) {\n const msgEvent = (e as MessageEvent);\n\n let data;\n try {\n data = JSON.parse(msgEvent?.data);\n } catch {}\n\n callback(data || {});\n };\n\n // store the listener\n if (!this.subscriptions[topic]) {\n this.subscriptions[topic] = [];\n }\n this.subscriptions[topic].push(listener);\n\n if (!this.isConnected) {\n // initialize sse connection\n await this.connect();\n } else if (this.subscriptions[topic].length === 1) {\n // send the updated subscriptions (if it is the first for the topic)\n await this.submitSubscriptions();\n } else {\n // only register the listener\n this.eventSource?.addEventListener(topic, listener);\n }\n\n return async (): Promise => {\n return this.unsubscribeByTopicAndListener(topic, listener);\n };\n }\n\n /**\n * Unsubscribe from all subscription listeners with the specified topic.\n *\n * If `topic` is not provided, then this method will unsubscribe\n * from all active subscriptions.\n *\n * This method is no-op if there are no active subscriptions.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribe(topic?: string): Promise {\n if (!this.hasSubscriptionListeners(topic)) {\n return; // already unsubscribed\n }\n\n if (!topic) {\n // remove all subscriptions\n this.subscriptions = {};\n } else {\n // remove all topic listeners\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n /**\n * Unsubscribe from all subscription listeners starting with the specified topic prefix.\n *\n * This method is no-op if there are no active subscriptions with the specified topic prefix.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByPrefix(topicPrefix: string): Promise {\n let hasAtleastOneTopic = false;\n for (let topic in this.subscriptions) {\n if (!topic.startsWith(topicPrefix)) {\n continue;\n }\n\n hasAtleastOneTopic = true;\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!hasAtleastOneTopic) {\n return; // nothing to unsubscribe from\n }\n\n if (this.hasSubscriptionListeners()) {\n // submit the deleted subscriptions\n await this.submitSubscriptions();\n } else {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n }\n }\n\n /**\n * Unsubscribe from all subscriptions matching the specified topic and listener function.\n *\n * This method is no-op if there are no active subscription with\n * the specified topic and listener.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByTopicAndListener(topic: string, listener: EventListener): Promise {\n if (!Array.isArray(this.subscriptions[topic]) || !this.subscriptions[topic].length) {\n return; // already unsubscribed\n }\n\n let exist = false;\n for (let i = this.subscriptions[topic].length - 1; i >= 0; i--) {\n if (this.subscriptions[topic][i] !== listener) {\n continue;\n }\n\n exist = true; // has at least one matching listener\n delete this.subscriptions[topic][i]; // removes the function reference\n this.subscriptions[topic].splice(i, 1); // reindex the array\n this.eventSource?.removeEventListener(topic, listener);\n }\n if (!exist) {\n return;\n }\n\n // remove the topic from the subscriptions list if there are no other listeners\n if (!this.subscriptions[topic].length) {\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n private hasSubscriptionListeners(topicToCheck?: string): boolean {\n this.subscriptions = this.subscriptions || {};\n\n // check the specified topic\n if (topicToCheck) {\n return !!this.subscriptions[topicToCheck]?.length;\n }\n\n // check for at least one non-empty topic\n for (let topic in this.subscriptions) {\n if (!!this.subscriptions[topic]?.length) {\n return true\n }\n }\n\n return false;\n }\n\n private async submitSubscriptions(): Promise {\n if (!this.clientId) {\n return; // no client/subscriber\n }\n\n // optimistic update\n this.addAllSubscriptionListeners();\n\n this.lastSentTopics = this.getNonEmptySubscriptionTopics();\n\n return this.client.send('/api/realtime', {\n 'method': 'POST',\n 'body': {\n 'clientId': this.clientId,\n 'subscriptions': this.lastSentTopics,\n },\n 'query': {\n 'requestKey': this.getSubscriptionsCancelKey(),\n },\n }).catch((err) => {\n if (err?.isAbort) {\n return; // silently ignore aborted pending requests\n }\n throw err;\n });\n }\n\n private getSubscriptionsCancelKey(): string {\n return \"realtime_\" + this.clientId;\n }\n\n private getNonEmptySubscriptionTopics(): Array {\n const result : Array = [];\n\n for (let topic in this.subscriptions) {\n if (this.subscriptions[topic].length) {\n result.push(topic);\n }\n }\n\n return result;\n }\n\n private addAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n this.removeAllSubscriptionListeners();\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.addEventListener(topic, listener);\n }\n }\n }\n\n private removeAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.removeEventListener(topic, listener);\n }\n }\n }\n\n private async connect(): Promise {\n if (this.reconnectAttempts > 0) {\n // immediately resolve the promise to avoid indefinitely\n // blocking the client during reconnection\n return;\n }\n\n return new Promise((resolve, reject) => {\n this.pendingConnects.push({ resolve, reject });\n\n if (this.pendingConnects.length > 1) {\n // all promises will be resolved once the connection is established\n return;\n }\n\n this.initConnect();\n })\n }\n\n private initConnect() {\n this.disconnect(true);\n\n // wait up to 15s for connect\n clearTimeout(this.connectTimeoutId);\n this.connectTimeoutId = setTimeout(() => {\n this.connectErrorHandler(new Error(\"EventSource connect took too long.\"));\n }, this.maxConnectTimeout);\n\n this.eventSource = new EventSource(this.client.buildUrl('/api/realtime'))\n\n this.eventSource.onerror = (_) => {\n this.connectErrorHandler(new Error(\"Failed to establish realtime connection.\"));\n };\n\n this.eventSource.addEventListener('PB_CONNECT', (e) => {\n const msgEvent = (e as MessageEvent);\n this.clientId = msgEvent?.lastEventId;\n\n this.submitSubscriptions()\n .then(async () => {\n let retries = 3;\n while (this.hasUnsentSubscriptions() && retries > 0) {\n retries--;\n // resubscribe to ensure that the latest topics are submitted\n //\n // This is needed because missed topics could happen on reconnect\n // if after the pending sent `submitSubscriptions()` call another `subscribe()`\n // was made before the submit was able to complete.\n await this.submitSubscriptions();\n }\n }).then(() => {\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n\n // reset connect meta\n this.pendingConnects = [];\n this.reconnectAttempts = 0;\n clearTimeout(this.reconnectTimeoutId);\n clearTimeout(this.connectTimeoutId);\n }).catch((err) => {\n this.clientId = \"\";\n this.connectErrorHandler(err);\n });\n });\n }\n\n private hasUnsentSubscriptions(): boolean {\n const latestTopics = this.getNonEmptySubscriptionTopics();\n if (latestTopics.length != this.lastSentTopics.length) {\n return true;\n }\n\n for (const t of latestTopics) {\n if (!this.lastSentTopics.includes(t)) {\n return true;\n }\n }\n\n return false;\n }\n\n private connectErrorHandler(err: any) {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n\n if (\n // wasn't previously connected -> direct reject\n (!this.clientId && !this.reconnectAttempts) ||\n // was previously connected but the max reconnection limit has been reached\n this.reconnectAttempts > this.maxReconnectAttempts\n ) {\n for (let p of this.pendingConnects) {\n p.reject(new ClientResponseError(err));\n }\n this.pendingConnects = [];\n this.disconnect();\n return;\n }\n\n // otherwise -> reconnect in the background\n this.disconnect(true);\n const timeout = this.predefinedReconnectIntervals[this.reconnectAttempts] || this.predefinedReconnectIntervals[this.predefinedReconnectIntervals.length - 1];\n this.reconnectAttempts++;\n this.reconnectTimeoutId = setTimeout(() => {\n this.initConnect();\n }, timeout);\n }\n\n private disconnect(fromReconnect = false): void {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n this.removeAllSubscriptionListeners();\n this.client.cancelRequest(this.getSubscriptionsCancelKey());\n this.eventSource?.close();\n this.eventSource = null;\n this.clientId = \"\";\n\n if (!fromReconnect) {\n this.reconnectAttempts = 0;\n\n // resolve any remaining connect promises\n //\n // this is done to avoid unnecessary throwing errors in case\n // unsubscribe is called before the pending connect promises complete\n // (see https://github.com/pocketbase/pocketbase/discussions/2897#discussioncomment-6423818)\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n this.pendingConnects = [];\n }\n }\n}\n","import Client from '@/Client';\nimport { CrudService } from '@/services/utils/CrudService';\nimport { RealtimeService, UnsubscribeFunc } from '@/services/RealtimeService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult, RecordModel, ExternalAuthModel } from '@/services/utils/dtos';\nimport {\n SendOptions,\n CommonOptions,\n RecordOptions,\n RecordListOptions,\n RecordFullListOptions,\n} from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface RecordAuthResponse {\n // The signed PocketBase auth record.\n record: T;\n\n // The PocketBase record auth token.\n //\n // If you are looking for the OAuth2 access and refresh tokens\n // they are available under the `meta.accessToken` and `meta.refreshToken` props.\n token: string;\n\n // Auth meta data usually filled when OAuth2 is used.\n meta?: {[key: string]: any};\n}\n\nexport interface AuthProviderInfo {\n name: string;\n state: string;\n codeVerifier: string;\n codeChallenge: string;\n codeChallengeMethod: string;\n authUrl: string;\n}\n\nexport interface AuthMethodsList {\n usernamePassword: boolean;\n emailPassword: boolean;\n authProviders: Array;\n}\n\nexport interface RecordSubscription {\n action: string; // eg. create, update, delete\n record: T;\n}\n\nexport type OAuth2UrlCallback = (url: string) => void|Promise;\n\nexport interface OAuth2AuthConfig extends SendOptions {\n // the name of the OAuth2 provider (eg. \"google\")\n provider: string;\n\n // custom scopes to overwrite the default ones\n scopes?: Array;\n\n // optional record create data\n createData?: {[key: string]: any};\n\n // optional callback that is triggered after the OAuth2 sign-in/sign-up url generation\n urlCallback?: OAuth2UrlCallback;\n\n // optional query params to send with the PocketBase auth request (eg. fields, expand, etc.)\n query?: RecordOptions;\n}\n\nexport class RecordService extends CrudService {\n readonly collectionIdOrName: string;\n\n constructor(client: Client, collectionIdOrName: string) {\n super(client);\n\n this.collectionIdOrName = collectionIdOrName;\n }\n\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return this.baseCollectionPath + '/records';\n }\n\n /**\n * Returns the current collection service base path.\n */\n get baseCollectionPath(): string {\n return '/api/collections/' + encodeURIComponent(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Realtime handlers\n // ---------------------------------------------------------------\n\n /**\n * @deprecated Use subscribe(recordId, callback) instead.\n *\n * Subscribe to the realtime changes of a single record in the collection.\n */\n async subscribeOne(recordId: string, callback: (data: RecordSubscription) => void): Promise {\n console.warn(\"PocketBase: subscribeOne(recordId, callback) is deprecated. Please replace it with subscribe(recordId, callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName + \"/\" + recordId, callback);\n }\n\n /**\n * @deprecated This form of subscribe is deprecated. Please use `subscribe(\"*\", callback)`.\n */\n async subscribe(callback: (data: RecordSubscription) => void): Promise\n\n /**\n * Subscribe to realtime changes to the specified topic (\"*\" or record id).\n *\n * If `topic` is the wildcard \"*\", then this method will subscribe to\n * any record changes in the collection.\n *\n * If `topic` is a record id, then this method will subscribe only\n * to changes of the specified record id.\n *\n * It's OK to subscribe multiple times to the same topic.\n * You can use the returned `UnsubscribeFunc` to remove only a single subscription.\n * Or use `unsubscribe(topic)` if you want to remove all subscriptions attached to the topic.\n */\n async subscribe(topic: string, callback: (data: RecordSubscription) => void): Promise\n\n async subscribe(\n topicOrCallback: string|((data: RecordSubscription) => void),\n callback?: (data: RecordSubscription) => void\n ): Promise {\n if (typeof topicOrCallback === 'function') {\n console.warn(\"PocketBase: subscribe(callback) is deprecated. Please replace it with subscribe('*', callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName, topicOrCallback);\n }\n\n if (!callback) {\n throw new Error(\"Missing subscription callback.\");\n }\n\n if (topicOrCallback === \"\") {\n throw new Error(\"Missing topic.\");\n }\n\n let topic = this.collectionIdOrName;\n if (topicOrCallback !== \"*\") {\n topic += ('/' + topicOrCallback);\n }\n\n return this.client.realtime.subscribe(topic, callback)\n }\n\n /**\n * Unsubscribe from all subscriptions of the specified topic\n * (\"*\" or record id).\n *\n * If `topic` is not set, then this method will unsubscribe from\n * all subscriptions associated to the current collection.\n */\n async unsubscribe(topic?: string): Promise {\n // unsubscribe wildcard topic\n if (topic === \"*\") {\n return this.client.realtime.unsubscribe(this.collectionIdOrName);\n }\n\n // unsubscribe recordId topic\n if (topic) {\n return this.client.realtime.unsubscribe(this.collectionIdOrName + \"/\" + topic);\n }\n\n // unsubscribe from everything related to the collection\n return this.client.realtime.unsubscribeByPrefix(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Crud handers\n // ---------------------------------------------------------------\n /**\n * @inheritdoc\n */\n getFullList(options?: RecordFullListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batch?: number, options?: RecordListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batchOrOptions?: number|RecordFullListOptions, options?: RecordListOptions): Promise> {\n if (typeof batchOrOptions == \"number\") {\n return super.getFullList(batchOrOptions, options);\n }\n\n const params = Object.assign({}, batchOrOptions, options);\n\n return super.getFullList(params);\n }\n\n /**\n * @inheritdoc\n */\n getList(page = 1, perPage = 30, options?: RecordListOptions): Promise> {\n return super.getList(page, perPage, options);\n }\n\n /**\n * @inheritdoc\n */\n getFirstListItem(filter: string, options?: RecordListOptions): Promise {\n return super.getFirstListItem(filter, options);\n }\n\n /**\n * @inheritdoc\n */\n getOne(id: string, options?: RecordOptions): Promise {\n return super.getOne(id, options);\n }\n\n /**\n * @inheritdoc\n */\n create(bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.create(bodyParams, options);\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(id: string, bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n if (\n // is record auth\n this.client.authStore.model?.id === item?.id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n if (\n success &&\n // is record auth\n this.client.authStore.model?.id === id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful collection authorization response.\n */\n protected authResponse(responseData: any): RecordAuthResponse {\n const record = this.decode(responseData?.record || {});\n\n this.client.authStore.save(responseData?.token, record);\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'record': record as any as T,\n });\n }\n\n /**\n * Returns all available collection auth methods.\n */\n listAuthMethods(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCollectionPath + '/auth-methods', options)\n .then((responseData: any) => {\n return Object.assign({}, responseData, {\n // normalize common fields\n 'usernamePassword': !!responseData?.usernamePassword,\n 'emailPassword': !!responseData?.emailPassword,\n 'authProviders': Array.isArray(responseData?.authProviders) ? responseData?.authProviders : [],\n });\n });\n }\n\n /**\n * Authenticate a single auth collection record via its username/email and password.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n */\n authWithPassword(usernameOrEmail: string, password: string, options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authWithPassword(usernameOrEmail, password, options?).\n */\n authWithPassword(usernameOrEmail: string, password: string, body?: any, query?: any): Promise>\n\n authWithPassword(usernameOrEmail: string, password: string, bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': usernameOrEmail,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(usernameOrEmail, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(usernameOrEmail, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-password', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Authenticate a single auth collection record with OAuth2 code.\n *\n * If you don't have an OAuth2 code you may also want to check `authWithOAuth2` method.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n options?: RecordOptions,\n ): Promise>\n\n /**\n * @deprecated\n * Consider using authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createdData, options?).\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n body?: any,\n query?: any\n ): Promise>\n\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n bodyOrOptions?: any,\n query?: any\n ): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'provider': provider,\n 'code': code,\n 'codeVerifier': codeVerifier,\n 'redirectUrl': redirectUrl,\n 'createData': createData,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, body?, query?) is deprecated. Consider replacing it with authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-oauth2', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * @deprecated This form of authWithOAuth2 is deprecated.\n *\n * Please use `authWithOAuth2Code()` OR its simplified realtime version\n * as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\n */\n async authWithOAuth2(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key: string]: any},\n bodyParams?: {[key: string]: any},\n queryParams?: RecordOptions,\n ): Promise>\n\n /**\n * Authenticate a single auth collection record with OAuth2\n * **without custom redirects, deeplinks or even page reload**.\n *\n * This method initializes a one-off realtime subscription and will\n * open a popup window with the OAuth2 vendor page to authenticate.\n * Once the external OAuth2 sign-in/sign-up flow is completed, the popup\n * window will be automatically closed and the OAuth2 data sent back\n * to the user through the previously established realtime connection.\n *\n * You can specify an optional `urlCallback` prop to customize\n * the default url `window.open` behavior.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n *\n * Example:\n *\n * ```js\n * const authData = await pb.collection(\"users\").authWithOAuth2({\n * provider: \"google\",\n * })\n * ```\n *\n * _Site-note_: when creating the OAuth2 app in the provider dashboard\n * you have to configure `https://yourdomain.com/api/oauth2-redirect`\n * as redirect URL.\n */\n async authWithOAuth2(options: OAuth2AuthConfig): Promise>\n\n async authWithOAuth2(...args: any): Promise> {\n // fallback to legacy format\n if (args.length > 1 || typeof args?.[0] === 'string') {\n console.warn(\"PocketBase: This form of authWithOAuth2() is deprecated and may get removed in the future. Please replace with authWithOAuth2Code() OR use the authWithOAuth2() realtime form as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\");\n return this.authWithOAuth2Code(\n args?.[0] || '',\n args?.[1] || '',\n args?.[2] || '',\n args?.[3] || '',\n args?.[4] || {},\n args?.[5] || {},\n args?.[6] || {},\n );\n }\n\n const config = args?.[0] || {};\n\n const authMethods = await this.listAuthMethods();\n\n const provider = authMethods.authProviders.find((p) => p.name === config.provider);\n if (!provider) {\n throw new ClientResponseError(new Error(`Missing or invalid provider \"${config.provider}\".`));\n }\n\n const redirectUrl = this.client.buildUrl('/api/oauth2-redirect');\n\n // initialize a one-off realtime service\n const realtime = new RealtimeService(this.client);\n\n // open a new popup window in case config.urlCallback is not set\n //\n // note: it is opened before the async call due to Safari restrictions\n // (see https://github.com/pocketbase/pocketbase/discussions/2429#discussioncomment-5943061)\n let eagerDefaultPopup: Window|null = null;\n if (!config.urlCallback) {\n eagerDefaultPopup = openBrowserPopup(undefined);\n }\n\n function cleanup() {\n eagerDefaultPopup?.close();\n realtime.unsubscribe();\n }\n\n return new Promise(async (resolve, reject) => {\n try {\n await realtime.subscribe('@oauth2', async (e) => {\n const oldState = realtime.clientId;\n\n try {\n if (!e.state || oldState !== e.state) {\n throw new Error(\"State parameters don't match.\");\n }\n\n // clear the non SendOptions props\n const options = Object.assign({}, config);\n delete options.provider;\n delete options.scopes;\n delete options.createData;\n delete options.urlCallback;\n\n const authData = await this.authWithOAuth2Code(\n provider.name,\n e.code,\n provider.codeVerifier,\n redirectUrl,\n config.createData,\n options,\n );\n\n resolve(authData);\n } catch (err) {\n reject(new ClientResponseError(err));\n }\n\n cleanup();\n });\n\n const replacements: {[key: string]: any} = {\n \"state\": realtime.clientId,\n }\n if (config.scopes?.length) {\n replacements[\"scope\"] = config.scopes.join(\" \");\n }\n\n const url = this._replaceQueryParams(provider.authUrl + redirectUrl, replacements);\n\n let urlCallback = config.urlCallback || function (url: string) {\n if (eagerDefaultPopup) {\n eagerDefaultPopup.location.href = url;\n } else {\n // it could have been blocked due to its empty initial url,\n // try again...\n eagerDefaultPopup = openBrowserPopup(url);\n }\n }\n\n await urlCallback(url);\n } catch (err) {\n cleanup();\n reject(new ClientResponseError(err));\n }\n });\n }\n\n /**\n * Refreshes the current authenticated record instance and\n * returns a new token and record data.\n *\n * On success this method also automatically updates the client's AuthStore.\n */\n authRefresh(options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise>\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-refresh', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Sends auth record password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-password-reset', options).then(() => true);\n }\n\n /**\n * Confirms auth record password reset request.\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n options?: CommonOptions,\n ): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(passwordResetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n body?: any,\n query?: any,\n ): Promise\n\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': passwordResetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(token, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(token, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Sends auth record verification email request.\n */\n requestVerification(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestVerification(email, options?).\n */\n requestVerification(email: string, body?: any, query?: any): Promise\n\n requestVerification(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestVerification(email, body?, query?) is deprecated. Consider replacing it with requestVerification(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-verification', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record email verification request.\n */\n confirmVerification(verificationToken: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmVerification(verificationToken, options?).\n */\n confirmVerification(verificationToken: string, body?: any, query?: any): Promise\n\n confirmVerification(verificationToken: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': verificationToken,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmVerification(token, body?, query?) is deprecated. Consider replacing it with confirmVerification(token, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-verification', options)\n .then(() => true);\n }\n\n /**\n * Sends an email change request to the authenticated record model.\n */\n requestEmailChange(newEmail: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestEmailChange(newEmail, options?).\n */\n requestEmailChange(newEmail: string, body?: any, query?: any): Promise\n\n requestEmailChange(newEmail: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'newEmail': newEmail,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestEmailChange(newEmail, body?, query?) is deprecated. Consider replacing it with requestEmailChange(newEmail, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-email-change', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record's new email address.\n */\n confirmEmailChange(emailChangeToken: string, password: string, options?: CommonOptions): Promise\n\n\n /**\n * @deprecated\n * Consider using confirmEmailChange(emailChangeToken, password, options?).\n */\n confirmEmailChange(emailChangeToken: string, password: string, body?: any, query?: any): Promise\n\n confirmEmailChange(emailChangeToken: string, password: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': emailChangeToken,\n 'password': password,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmEmailChange(token, password, body?, query?) is deprecated. Consider replacing it with confirmEmailChange(token, password, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-email-change', options)\n .then(() => true);\n }\n\n /**\n * Lists all linked external auth providers for the specified auth record.\n */\n listExternalAuths(recordId: string, options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths', options);\n }\n\n /**\n * Unlink a single external auth provider from the specified auth record.\n */\n unlinkExternalAuth(recordId: string, provider: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths/' + encodeURIComponent(provider), options)\n .then(() => true);\n }\n\n // ---------------------------------------------------------------\n\n // very rudimentary url query params replacement because at the moment\n // URL (and URLSearchParams) doesn't seem to be fully supported in React Native\n //\n // note: for details behind some of the decode/encode parsing check https://unixpapa.com/js/querystring.html\n private _replaceQueryParams(url: string, replacements: {[key: string]: any} = {}): string {\n let urlPath = url\n let query = \"\";\n\n const queryIndex = url.indexOf(\"?\");\n if (queryIndex >= 0) {\n urlPath = url.substring(0, url.indexOf(\"?\"));\n query = url.substring(url.indexOf(\"?\") + 1);\n }\n\n const parsedParams: {[key: string]: string} = {};\n\n // parse the query parameters\n const rawParams = query.split(\"&\");\n for (const param of rawParams) {\n if (param == \"\") {\n continue\n }\n\n const pair = param.split(\"=\");\n parsedParams[decodeURIComponent(pair[0].replace(/\\+/g,' '))] = decodeURIComponent((pair[1] || \"\").replace(/\\+/g,' '));\n }\n\n // apply the replacements\n for (let key in replacements) {\n if (!replacements.hasOwnProperty(key)) {\n continue;\n }\n\n if (replacements[key] == null) {\n delete parsedParams[key];\n } else {\n parsedParams[key] = replacements[key];\n }\n }\n\n // construct back the full query string\n query = \"\";\n for (let key in parsedParams) {\n if (!parsedParams.hasOwnProperty(key)) {\n continue;\n }\n\n if (query != \"\") {\n query += \"&\";\n }\n\n query += encodeURIComponent(key.replace(/%20/g,'+')) + \"=\" + encodeURIComponent(parsedParams[key].replace(/%20/g,'+'));\n }\n\n return query != \"\" ? (urlPath + \"?\" + query) : urlPath;\n }\n}\n\nfunction openBrowserPopup(url?: string): Window|null {\n if (typeof window === \"undefined\" || !window?.open) {\n throw new ClientResponseError(new Error(`Not in a browser context - please pass a custom urlCallback function.`));\n }\n\n let width = 1024;\n let height = 768;\n\n let windowWidth = window.innerWidth;\n let windowHeight = window.innerHeight;\n\n // normalize window size\n width = width > windowWidth ? windowWidth : width;\n height = height > windowHeight ? windowHeight : height;\n\n let left = (windowWidth / 2) - (width / 2);\n let top = (windowHeight / 2) - (height / 2);\n\n // note: we don't use the noopener and noreferrer attributes since\n // for some reason browser blocks such windows then url is undefined/blank\n return window.open(\n url,\n 'popup_window',\n 'width='+width+',height='+height+',top='+top+',left='+left+',resizable,menubar=no'\n );\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { CollectionModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport class CollectionService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/collections';\n }\n\n /**\n * Imports the provided collections.\n *\n * If `deleteMissing` is `true`, all local collections and schema fields,\n * that are not present in the imported configuration, WILL BE DELETED\n * (including their related records data)!\n */\n async import(\n collections: Array,\n deleteMissing: boolean = false,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PUT',\n 'body': {\n 'collections': collections,\n 'deleteMissing': deleteMissing,\n }\n }, options);\n\n return this.client.send(this.baseCrudPath + '/import', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ListResult, LogRequestModel } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n LogStatsOptions,\n} from '@/services/utils/options';\n\nexport interface HourlyStats {\n total: number;\n date: string;\n}\n\nexport class LogService extends BaseService {\n /**\n * Returns paginated logged requests list.\n */\n getRequestsList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({'method': 'GET'}, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send('/api/logs/requests', options);\n }\n\n /**\n * Returns a single logged request by its id.\n */\n getRequest(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/' + encodeURIComponent(id), options);\n }\n\n /**\n * Returns request logs statistics.\n */\n getRequestsStats(options?: LogStatsOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/stats', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface HealthCheckResponse {\n code: number;\n message: string;\n data: {[key: string]: any};\n}\n\nexport class HealthService extends BaseService {\n /**\n * Checks the health status of the api.\n */\n check(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/health', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions, FileOptions } from '@/services/utils/options';\n\nexport class FileService extends BaseService {\n /**\n * Builds and returns an absolute record file url for the provided filename.\n */\n getUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n if (\n !filename ||\n !record?.id ||\n !(record?.collectionId || record?.collectionName)\n ) {\n return '';\n }\n\n const parts = [];\n parts.push('api')\n parts.push('files')\n parts.push(encodeURIComponent(record.collectionId || record.collectionName))\n parts.push(encodeURIComponent(record.id))\n parts.push(encodeURIComponent(filename))\n\n let result = this.client.buildUrl(parts.join('/'));\n\n if (Object.keys(queryParams).length) {\n // normalize the download query param for consistency with the Dart sdk\n if (queryParams.download === false) {\n delete(queryParams.download);\n }\n\n const params = new URLSearchParams(queryParams);\n\n result += (result.includes('?') ? '&' : '?') + params;\n }\n\n return result\n }\n\n /**\n * Requests a new private file access token for the current auth model (admin or record).\n */\n getToken(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send('/api/files/token', options)\n .then((data) => data?.token || '');\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface BackupFileInfo {\n key: string;\n size: number;\n modified: string;\n}\n\nexport class BackupService extends BaseService {\n /**\n * Returns list with all available backup files.\n */\n getFullList(options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/backups', options);\n }\n\n /**\n * Initializes a new backup.\n */\n create(basename: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'name': basename,\n },\n }, options);\n\n return this.client.send('/api/backups', options)\n .then(() => true);\n }\n\n /**\n * Deletes a single backup file.\n */\n delete(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}`, options)\n .then(() => true);\n }\n\n /**\n * Initializes an app data restore from an existing backup.\n */\n restore(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}/restore`, options)\n .then(() => true);\n }\n\n /**\n * Builds a download url for a single existing backup using an\n * admin file token and the backup file key.\n *\n * The file token can be generated via `pb.files.getToken()`.\n */\n getDownloadUrl(token: string, key: string): string {\n return this.client.buildUrl(`/api/backups/${encodeURIComponent(key)}?token=${encodeURIComponent(token)}`);\n }\n}\n","import { ClientResponseError } from '@/ClientResponseError';\nimport { BaseAuthStore } from '@/stores/BaseAuthStore';\nimport { LocalAuthStore } from '@/stores/LocalAuthStore';\nimport { SettingsService } from '@/services/SettingsService';\nimport { AdminService } from '@/services/AdminService';\nimport { RecordService } from '@/services/RecordService';\nimport { CollectionService } from '@/services/CollectionService';\nimport { LogService } from '@/services/LogService';\nimport { RealtimeService } from '@/services/RealtimeService';\nimport { HealthService } from '@/services/HealthService';\nimport { FileService } from '@/services/FileService';\nimport { BackupService } from '@/services/BackupService';\nimport { SendOptions, FileOptions } from '@/services/utils/options';\n\n// list of known SendOptions keys (everything else is treated as query param)\nconst knownSendOptionsKeys = [\n 'requestKey',\n '$cancelKey',\n '$autoCancel',\n 'fetch',\n 'headers',\n 'body',\n 'query',\n 'params',\n // ---,\n 'cache',\n 'credentials',\n 'headers',\n 'integrity',\n 'keepalive',\n 'method',\n 'mode',\n 'redirect',\n 'referrer',\n 'referrerPolicy',\n 'signal',\n 'window',\n];\n\nexport interface BeforeSendResult {\n [key: string]: any, // for backward compatibility\n url?: string,\n options?: {[key: string]: any}\n}\n\n/**\n * PocketBase JS Client.\n */\nexport default class Client {\n /**\n * The base PocketBase backend url address (eg. 'http://127.0.0.1.8090').\n */\n baseUrl: string;\n\n /**\n * Hook that get triggered right before sending the fetch request,\n * allowing you to inspect and modify the url and request options.\n *\n * For list of the possible options check https://developer.mozilla.org/en-US/docs/Web/API/fetch#options\n *\n * You can return a non-empty result object `{ url, options }` to replace the url and request options entirely.\n *\n * Example:\n * ```js\n * client.beforeSend = function (url, options) {\n * options.headers = Object.assign({}, options.headers, {\n * 'X-Custom-Header': 'example',\n * });\n *\n * return { url, options }\n * };\n * ```\n */\n beforeSend?: (url: string, options: SendOptions) => BeforeSendResult|Promise;\n\n /**\n * Hook that get triggered after successfully sending the fetch request,\n * allowing you to inspect/modify the response object and its parsed data.\n *\n * Returns the new Promise resolved `data` that will be returned to the client.\n *\n * Example:\n * ```js\n * client.afterSend = function (response, data) {\n * if (response.status != 200) {\n * throw new ClientResponseError({\n * url: response.url,\n * status: response.status,\n * data: data,\n * });\n * }\n *\n * return data;\n * };\n * ```\n */\n afterSend?: (response: Response, data: any) => any;\n\n /**\n * Optional language code (default to `en-US`) that will be sent\n * with the requests to the server as `Accept-Language` header.\n */\n lang: string;\n\n /**\n * A replaceable instance of the local auth store service.\n */\n authStore: BaseAuthStore;\n\n /**\n * An instance of the service that handles the **Settings APIs**.\n */\n readonly settings: SettingsService;\n\n /**\n * An instance of the service that handles the **Admin APIs**.\n */\n readonly admins: AdminService;\n\n /**\n * An instance of the service that handles the **Collection APIs**.\n */\n readonly collections: CollectionService;\n\n /**\n * An instance of the service that handles the **File APIs**.\n */\n readonly files: FileService;\n\n /**\n * An instance of the service that handles the **Log APIs**.\n */\n readonly logs: LogService;\n\n /**\n * An instance of the service that handles the **Realtime APIs**.\n */\n readonly realtime: RealtimeService;\n\n /**\n * An instance of the service that handles the **Health APIs**.\n */\n readonly health: HealthService;\n\n /**\n * An instance of the service that handles the **Backup APIs**.\n */\n readonly backups: BackupService;\n\n private cancelControllers: { [key: string]: AbortController } = {};\n private recordServices: { [key: string]: RecordService } = {};\n private enableAutoCancellation: boolean = true;\n\n constructor(\n baseUrl = '/',\n authStore?: BaseAuthStore | null,\n lang = 'en-US',\n ) {\n this.baseUrl = baseUrl;\n this.lang = lang;\n this.authStore = authStore || new LocalAuthStore();\n\n // services\n this.admins = new AdminService(this);\n this.collections = new CollectionService(this);\n this.files = new FileService(this);\n this.logs = new LogService(this);\n this.settings = new SettingsService(this);\n this.realtime = new RealtimeService(this);\n this.health = new HealthService(this);\n this.backups = new BackupService(this);\n }\n\n /**\n * Returns the RecordService associated to the specified collection.\n *\n * @param {string} idOrName\n * @return {RecordService}\n */\n collection(idOrName: string): RecordService {\n if (!this.recordServices[idOrName]) {\n this.recordServices[idOrName] = new RecordService(this, idOrName);\n }\n\n return this.recordServices[idOrName];\n }\n\n /**\n * Globally enable or disable auto cancellation for pending duplicated requests.\n */\n autoCancellation(enable: boolean): Client {\n this.enableAutoCancellation = !!enable;\n\n return this;\n }\n\n /**\n * Cancels single request by its cancellation key.\n */\n cancelRequest(requestKey: string): Client {\n if (this.cancelControllers[requestKey]) {\n this.cancelControllers[requestKey].abort();\n delete this.cancelControllers[requestKey];\n }\n\n return this;\n }\n\n /**\n * Cancels all pending requests.\n */\n cancelAllRequests(): Client {\n for (let k in this.cancelControllers) {\n this.cancelControllers[k].abort();\n }\n\n this.cancelControllers = {};\n\n return this;\n }\n\n /**\n * Legacy alias of `pb.files.getUrl()`.\n */\n getFileUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n return this.files.getUrl(record, filename, queryParams);\n }\n\n /**\n * Builds a full client url by safely concatenating the provided path.\n */\n buildUrl(path: string): string {\n let url = this.baseUrl;\n\n // construct an absolute base url if in a browser environment\n if (\n typeof window !== 'undefined' &&\n !!window.location &&\n !url.startsWith('https://') &&\n !url.startsWith('http://')\n ) {\n url = window.location.origin?.endsWith('/') ?\n window.location.origin.substring(0, window.location.origin.length - 1) :\n (window.location.origin || '');\n\n if (!this.baseUrl.startsWith('/')) {\n url += window.location.pathname || '/';\n url += url.endsWith('/') ? '' : '/';\n }\n\n url += this.baseUrl;\n }\n\n // concatenate the path\n if (path) {\n url += url.endsWith('/') ? '' : '/'; // append trailing slash if missing\n url += path.startsWith('/') ? path.substring(1) : path;\n }\n\n return url;\n }\n\n /**\n * Sends an api http request.\n */\n async send(path: string, options: SendOptions): Promise {\n options = this.initSendOptions(path, options);\n\n // build url + path\n let url = this.buildUrl(path);\n\n // serialize the query parameters\n if (typeof options.query !== 'undefined') {\n const query = this.serializeQueryParams(options.query)\n if (query) {\n url += (url.includes('?') ? '&' : '?') + query;\n }\n delete options.query;\n }\n\n if (this.beforeSend) {\n const result = Object.assign({}, await this.beforeSend(url, options));\n if (typeof result.url !== 'undefined' || typeof result.options !== 'undefined') {\n url = result.url || url;\n options = result.options || options;\n } else if (Object.keys(result).length) {\n // legacy behavior\n options = result as SendOptions;\n console?.warn && console.warn('Deprecated format of beforeSend return: please use `return { url, options }`, instead of `return options`.');\n }\n }\n\n // ensures that the json body is serialized\n if (\n this.getHeader(options.headers, 'Content-Type') == 'application/json' &&\n options.body && typeof options.body !== 'string'\n ) {\n options.body = JSON.stringify(options.body);\n }\n\n const fetchFunc = options.fetch || fetch;\n\n // send the request\n return fetchFunc(url, options)\n .then(async (response) => {\n let data : any = {};\n\n try {\n data = await response.json();\n } catch (_) {\n // all api responses are expected to return json\n // with the exception of the realtime event and 204\n }\n\n if (this.afterSend) {\n data = await this.afterSend(response, data);\n }\n\n if (response.status >= 400) {\n throw new ClientResponseError({\n url: response.url,\n status: response.status,\n data: data,\n });\n }\n\n return data as T;\n }).catch((err) => {\n // wrap to normalize all errors\n throw new ClientResponseError(err);\n });\n }\n\n /**\n * Shallow copy the provided object and takes care to initialize\n * any options required to preserve the backward compatability.\n *\n * @param {SendOptions} options\n * @return {SendOptions}\n */\n private initSendOptions(path: string, options: SendOptions): SendOptions {\n options = Object.assign({ method: 'GET' } as SendOptions, options)\n options.query = options.query || {};\n\n // auto convert the body to FormData, if needed\n options.body = this.convertToFormDataIfNeeded(options.body);\n\n // move unknown send options as query parameters\n for (let key in options) {\n if (knownSendOptionsKeys.includes(key)) {\n continue\n }\n\n options.query[key] = options[key];\n delete (options[key]);\n }\n\n // requestKey normalizations for backward-compatibility\n // ---\n options.query = Object.assign({}, options.params, options.query);\n if (typeof options.requestKey === 'undefined') {\n if (options.$autoCancel === false || options.query.$autoCancel === false) {\n options.requestKey = null;\n } else if (options.$cancelKey || options.query.$cancelKey) {\n options.requestKey = options.$cancelKey || options.query.$cancelKey;\n }\n }\n // remove the deprecated special cancellation params from the other query params\n delete options.$autoCancel;\n delete options.query.$autoCancel;\n delete options.$cancelKey;\n delete options.query.$cancelKey;\n // ---\n\n // add the json header, if not explicitly set\n // (for FormData body the Content-Type header should be skipped since the boundary is autogenerated)\n if (\n this.getHeader(options.headers, 'Content-Type') === null &&\n !this.isFormData(options.body)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Content-Type': 'application/json',\n });\n }\n\n // add Accept-Language header, if not explicitly set\n if (this.getHeader(options.headers, 'Accept-Language') === null) {\n options.headers = Object.assign({}, options.headers, {\n 'Accept-Language': this.lang,\n });\n }\n\n // check if Authorization header can be added\n if (\n // has valid token\n this.authStore.token &&\n // auth header is not explicitly set\n (this.getHeader(options.headers, 'Authorization') === null)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Authorization': this.authStore.token,\n });\n }\n\n // handle auto cancelation for duplicated pending request\n if (this.enableAutoCancellation && options.requestKey !== null) {\n const requestKey = options.requestKey || ((options.method || 'GET') + path);\n\n delete options.requestKey;\n\n // cancel previous pending requests\n this.cancelRequest(requestKey);\n\n const controller = new AbortController();\n this.cancelControllers[requestKey] = controller;\n options.signal = controller.signal;\n }\n\n return options\n }\n\n /**\n * Converts analyzes the provided body and converts it to FormData\n * in case a plain object with File/Blob values is used.\n */\n private convertToFormDataIfNeeded(body: any): any {\n if (\n typeof FormData === 'undefined' ||\n typeof body === \"undefined\" ||\n typeof body !== \"object\" ||\n body === null ||\n this.isFormData(body) ||\n !this.hasBlobField(body)\n ) {\n return body;\n }\n\n const form = new FormData();\n\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let val of values) {\n form.append(key, val);\n }\n }\n\n return form;\n }\n\n /**\n * Checks if the submitted body object has at least one Blob/File field.\n */\n private hasBlobField(body: {[key:string]: any}): boolean {\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let v of values) {\n if (\n (typeof Blob !== 'undefined' && v instanceof Blob) ||\n (typeof File !== 'undefined' && v instanceof File)\n ) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /**\n * Extracts the header with the provided name in case-insensitive manner.\n * Returns `null` if no header matching the name is found.\n */\n private getHeader(headers: {[key:string]:string}|undefined, name: string): string|null {\n headers = headers || {};\n name = name.toLowerCase();\n\n for (let key in headers) {\n if (key.toLowerCase() == name) {\n return headers[key];\n }\n }\n\n return null;\n }\n\n /**\n * Loosely checks if the specified body is a FormData instance.\n */\n private isFormData(body: any): boolean {\n return body && (\n // we are checking the constructor name because FormData\n // is not available natively in some environments and the\n // polyfill(s) may not be globally accessible\n body.constructor.name === 'FormData' ||\n // fallback to global FormData instance check\n // note: this is needed because the constructor.name could be different in case of\n // custom global FormData implementation, eg. React Native on Android/iOS\n (typeof FormData !== 'undefined' && body instanceof FormData)\n )\n }\n\n /**\n * Serializes the provided query parameters into a query string.\n */\n private serializeQueryParams(params: {[key: string]: any}): string {\n const result: Array = [];\n for (const key in params) {\n if (params[key] === null) {\n // skip null query params\n continue;\n }\n\n const value = params[key];\n const encodedKey = encodeURIComponent(key);\n\n if (Array.isArray(value)) {\n // repeat array params\n for (const v of value) {\n result.push(encodedKey + '=' + encodeURIComponent(v));\n }\n } else if (value instanceof Date) {\n result.push(encodedKey + '=' + encodeURIComponent(value.toISOString()));\n } else if (typeof value !== null && typeof value === 'object') {\n result.push(encodedKey + '=' + encodeURIComponent(JSON.stringify(value)));\n } else {\n result.push(encodedKey + '=' + encodeURIComponent(value));\n }\n }\n\n return result.join('&');\n }\n}\n","import { BaseAuthStore, AuthModel } from '@/stores/BaseAuthStore';\n\nexport type AsyncSaveFunc = (serializedPayload: string) => Promise;\n\nexport type AsyncClearFunc = () => Promise;\n\ntype queueFunc = () => Promise;\n\n/**\n * AsyncAuthStore is a helper auth store implementation\n * that could be used with any external async persistent layer\n * (key-value db, local file, etc.).\n *\n * Here is an example with the React Native AsyncStorage package:\n *\n * ```\n * import AsyncStorage from \"@react-native-async-storage/async-storage\";\n * import PocketBase, { AsyncAuthStore } from \"pocketbase\";\n *\n * const store = new AsyncAuthStore({\n * save: async (serialized) => AsyncStorage.setItem(\"pb_auth\", serialized),\n * initial: await AsyncStorage.getItem(\"pb_auth\"),\n * });\n *\n * const pb = new PocketBase(\"https://example.com\", store)\n * ```\n */\nexport class AsyncAuthStore extends BaseAuthStore {\n private saveFunc: AsyncSaveFunc;\n private clearFunc?: AsyncClearFunc;\n private queue: Array = [];\n\n constructor(config: {\n // The async function that is called every time\n // when the auth store state needs to be persisted.\n save: AsyncSaveFunc,\n\n /// An *optional* async function that is called every time\n /// when the auth store needs to be cleared.\n ///\n /// If not explicitly set, `saveFunc` with empty data will be used.\n clear?: AsyncClearFunc,\n\n // initial data to load into the store\n initial?: string,\n }) {\n super();\n\n this.saveFunc = config.save;\n this.clearFunc = config.clear;\n\n this._loadInitial(config.initial);\n }\n\n /**\n * @inheritdoc\n */\n save(token: string, model?: AuthModel): void {\n super.save(token, model);\n\n let value = '';\n try {\n value = JSON.stringify({token, model})\n } catch (err) {\n console.warn('AsyncAuthStore: failed to stringify the new state');\n }\n\n this._enqueue(() => this.saveFunc(value));\n }\n\n /**\n * @inheritdoc\n */\n clear(): void {\n super.clear();\n\n if (this.clearFunc) {\n this._enqueue(() => this.clearFunc!());\n } else {\n this._enqueue(() => this.saveFunc(\"\"));\n }\n }\n\n\n /**\n * Initializes the auth store state.\n */\n private _loadInitial(payload?: string) {\n if (!payload) {\n return; // nothing to load\n }\n\n try {\n const parsed = JSON.parse(payload) || {};\n\n this.save(parsed.token || \"\", parsed.model || null);\n } catch (_) {}\n }\n\n /**\n * Appends an async function to the queue.\n */\n private _enqueue(asyncCallback: () => Promise) {\n this.queue.push(asyncCallback);\n\n if (this.queue.length == 1) {\n this._dequeue();\n }\n }\n\n /**\n * Starts the queue processing.\n */\n private _dequeue() {\n if (!this.queue.length) {\n return;\n }\n\n this.queue[0]().finally(() => {\n this.queue.shift();\n\n if (!this.queue.length) {\n return;\n }\n\n this._dequeue();\n });\n }\n}\n"],"names":["ClientResponseError","Error","constructor","errData","super","this","url","status","response","isAbort","originalError","Object","setPrototypeOf","prototype","data","DOMException","name","message","_a","_d","_c","_b","cause","includes","toJSON","assign","fieldContentRegExp","cookieParse","str","options","result","decode","defaultDecode","index","length","eqIdx","indexOf","endIdx","lastIndexOf","key","slice","trim","undefined","val","charCodeAt","_","cookieSerialize","opt","encode","defaultEncode","test","TypeError","value","maxAge","isNaN","isFinite","Math","floor","domain","path","expires","isDate","toString","call","Date","valueOf","toUTCString","httpOnly","secure","priority","toLowerCase","sameSite","decodeURIComponent","encodeURIComponent","atobPolyfill","getTokenPayload","token","encodedPayload","split","map","c","join","JSON","parse","e","isTokenExpired","expirationThreshold","payload","keys","exp","now","atob","input","String","replace","bs","buffer","bc","idx","output","charAt","fromCharCode","defaultCookieKey","BaseAuthStore","baseToken","baseModel","_onChangeCallbacks","model","isValid","isAdmin","type","isAuthRecord","save","triggerChange","clear","loadFromCookie","cookie","rawData","Array","isArray","exportToCookie","defaultOptions","stringify","resultLength","Blob","size","id","email","extraProps","prop","onChange","callback","fireImmediately","push","i","splice","LocalAuthStore","storageKey","storageFallback","_bindStorageEvent","_storageGet","_storageSet","_storageRemove","window","localStorage","rawValue","getItem","normalizedVal","setItem","removeItem","addEventListener","BaseService","client","SettingsService","getAll","method","send","update","bodyParams","body","testS3","filesystem","then","testEmail","toEmail","emailTemplate","template","generateAppleClientSecret","clientId","teamId","keyId","privateKey","duration","CrudService","getFullList","batchOrqueryParams","_getFullList","batch","getList","page","perPage","query","baseCrudPath","responseData","items","item","getFirstListItem","filter","requestKey","skipTotal","code","getOne","create","batchSize","request","__awaiter","list","concat","normalizeLegacyOptionsArgs","legacyWarn","baseOptions","bodyOrOptions","hasQuery","console","warn","AdminService","authStore","collectionId","delete","success","authResponse","admin","authWithPassword","password","identity","bind","authRefresh","requestPasswordReset","confirmPasswordReset","resetToken","passwordConfirm","RealtimeService","eventSource","subscriptions","lastSentTopics","maxConnectTimeout","reconnectAttempts","maxReconnectAttempts","Infinity","predefinedReconnectIntervals","pendingConnects","isConnected","subscribe","topic","listener","msgEvent","submitSubscriptions","connect","unsubscribeByTopicAndListener","unsubscribe","hasSubscriptionListeners","removeEventListener","disconnect","unsubscribeByPrefix","topicPrefix","hasAtleastOneTopic","startsWith","exist","topicToCheck","addAllSubscriptionListeners","getNonEmptySubscriptionTopics","getSubscriptionsCancelKey","catch","err","removeAllSubscriptionListeners","Promise","resolve","reject","initConnect","clearTimeout","connectTimeoutId","setTimeout","connectErrorHandler","EventSource","buildUrl","onerror","lastEventId","retries","hasUnsentSubscriptions","p","reconnectTimeoutId","latestTopics","t","timeout","fromReconnect","cancelRequest","close","RecordService","collectionIdOrName","baseCollectionPath","subscribeOne","recordId","realtime","topicOrCallback","batchOrOptions","params","collectionName","record","listAuthMethods","usernamePassword","emailPassword","authProviders","usernameOrEmail","authWithOAuth2Code","provider","codeVerifier","redirectUrl","createData","authWithOAuth2","args","config","find","eagerDefaultPopup","cleanup","urlCallback","openBrowserPopup","oldState","state","scopes","authData","replacements","_replaceQueryParams","authUrl","location","href","passwordResetToken","requestVerification","confirmVerification","verificationToken","requestEmailChange","newEmail","confirmEmailChange","emailChangeToken","listExternalAuths","unlinkExternalAuth","urlPath","substring","parsedParams","rawParams","param","pair","hasOwnProperty","open","width","height","windowWidth","innerWidth","windowHeight","innerHeight","left","top","CollectionService","import","collections","deleteMissing","LogService","getRequestsList","getRequest","getRequestsStats","HealthService","check","FileService","getUrl","filename","queryParams","parts","download","URLSearchParams","getToken","BackupService","basename","restore","getDownloadUrl","knownSendOptionsKeys","Client","baseUrl","lang","cancelControllers","recordServices","enableAutoCancellation","admins","files","logs","settings","health","backups","collection","idOrName","autoCancellation","enable","abort","cancelAllRequests","k","getFileUrl","origin","endsWith","pathname","initSendOptions","serializeQueryParams","beforeSend","getHeader","headers","fetch","json","afterSend","convertToFormDataIfNeeded","$autoCancel","$cancelKey","isFormData","Authorization","controller","AbortController","signal","FormData","hasBlobField","form","values","append","v","File","encodedKey","toISOString","AsyncAuthStore","queue","saveFunc","clearFunc","_loadInitial","initial","_enqueue","parsed","asyncCallback","_dequeue","finally","shift"],"mappings":"4ZAIM,MAAOA,4BAA4BC,MAOrC,WAAAC,CAAYC,eACRC,MAAM,uBAPVC,KAAGC,IAA8B,GACjCD,KAAME,OAA2B,EACjCF,KAAQG,SAAyB,GACjCH,KAAOI,SAA0B,EACjCJ,KAAaK,cAAoB,KAO7BC,OAAOC,eAAeP,KAAML,oBAAoBa,WAEhC,OAAZV,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ACrC,CAKD,KAAA8D,GACI9G,MAAM8G,QAEF7G,KAAK0Z,UACL1Z,KAAK6Z,UAAS,IAAM7Z,KAAK0Z,cAEzB1Z,KAAK6Z,UAAS,IAAM7Z,KAAKyZ,SAAS,KAEzC,CAMO,YAAAE,CAAazU,GACjB,GAAKA,EAIL,IACI,MAAM4U,EAASjV,KAAKC,MAAMI,IAAY,CAAA,EAEtClF,KAAK2G,KAAKmT,EAAOvV,OAAS,GAAIuV,EAAOxT,OAAS,KACjD,CAAC,MAAO9D,GAAK,CACjB,CAKO,QAAAqX,CAASE,GACb/Z,KAAKwZ,MAAMxR,KAAK+R,GAES,GAArB/Z,KAAKwZ,MAAM3X,QACX7B,KAAKga,UAEZ,CAKO,QAAAA,GACCha,KAAKwZ,MAAM3X,QAIhB7B,KAAKwZ,MAAM,KAAKS,SAAQ,KACpBja,KAAKwZ,MAAMU,QAENla,KAAKwZ,MAAM3X,QAIhB7B,KAAKga,UAAU,GAEtB"} \ No newline at end of file diff --git a/dist/pocketbase.es.mjs.map b/dist/pocketbase.es.mjs.map index 488104a..c32c895 100644 --- a/dist/pocketbase.es.mjs.map +++ b/dist/pocketbase.es.mjs.map @@ -1 +1 @@ -{"version":3,"file":"pocketbase.es.mjs","sources":["../src/ClientResponseError.ts","../src/stores/utils/cookie.ts","../src/stores/utils/jwt.ts","../src/stores/BaseAuthStore.ts","../src/stores/LocalAuthStore.ts","../src/services/utils/BaseService.ts","../src/services/SettingsService.ts","../src/services/utils/CrudService.ts","../src/services/utils/legacy.ts","../src/services/AdminService.ts","../src/services/RealtimeService.ts","../src/services/RecordService.ts","../src/services/CollectionService.ts","../src/services/LogService.ts","../src/services/HealthService.ts","../src/services/FileService.ts","../src/services/BackupService.ts","../src/Client.ts","../src/stores/AsyncAuthStore.ts"],"sourcesContent":["/**\n * ClientResponseError is a custom Error class that is intended to wrap\n * and normalize any error thrown by `Client.send()`.\n */\nexport class ClientResponseError extends Error {\n url: string = '';\n status: number = 0;\n response: {[key: string]: any} = {};\n isAbort: boolean = false;\n originalError: any = null;\n\n constructor(errData?: any) {\n super(\"ClientResponseError\");\n\n // Set the prototype explicitly.\n // https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\n Object.setPrototypeOf(this, ClientResponseError.prototype);\n\n if (errData !== null && typeof errData === 'object') {\n this.url = typeof errData.url === 'string' ? errData.url : '';\n this.status = typeof errData.status === 'number' ? errData.status : 0;\n this.isAbort = !!errData.isAbort;\n this.originalError = errData.originalError;\n\n if (errData.response !== null && typeof errData.response === 'object') {\n this.response = errData.response;\n } else if (errData.data !== null && typeof errData.data === 'object') {\n this.response = errData.data;\n } else {\n this.response = {};\n }\n }\n\n if (!this.originalError && !(errData instanceof ClientResponseError)) {\n this.originalError = errData;\n }\n\n if (typeof DOMException !== 'undefined' && errData instanceof DOMException) {\n this.isAbort = true;\n }\n\n this.name = \"ClientResponseError \" + this.status;\n this.message = this.response?.message;\n if (!this.message) {\n if (this.isAbort) {\n this.message = 'The request was autocancelled. You can find more info in https://github.com/pocketbase/js-sdk#auto-cancellation.';\n } else if (this.originalError?.cause?.message?.includes(\"ECONNREFUSED ::1\")) {\n this.message = 'Failed to connect to the PocketBase server. Try changing the SDK URL from localhost to 127.0.0.1 (https://github.com/pocketbase/js-sdk/issues/21).';\n } else {\n this.message = 'Something went wrong while processing your request.';\n }\n }\n }\n\n /**\n * Alias for `this.response` to preserve the backward compatibility.\n */\n get data() {\n return this.response;\n }\n\n /**\n * Make a POJO's copy of the current error class instance.\n * @see https://github.com/vuex-orm/vuex-orm/issues/255\n */\n toJSON() {\n return { ...this };\n }\n}\n","/**\n * -------------------------------------------------------------------\n * Simple cookie parse and serialize utilities mostly based on the\n * node module https://github.com/jshttp/cookie.\n * -------------------------------------------------------------------\n */\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\nconst fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;\n\nexport interface ParseOptions{\n decode?: (val: string) => string,\n}\n\n/**\n* Parses the given cookie header string into an object\n* The object has the various cookies as keys(names) => values\n*/\nexport function cookieParse(str: string, options?: ParseOptions): { [key: string]: any } {\n const result: { [key: string]: any } = {};\n\n if (typeof str !== 'string') {\n return result;\n }\n\n const opt = Object.assign({}, options || {});\n const decode = opt.decode || defaultDecode;\n\n let index = 0;\n while (index < str.length) {\n const eqIdx = str.indexOf('=', index);\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break;\n }\n\n let endIdx = str.indexOf(';', index);\n\n if (endIdx === -1) {\n endIdx = str.length;\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(';', eqIdx - 1) + 1;\n continue;\n }\n\n const key = str.slice(index, eqIdx).trim();\n\n // only assign once\n if (undefined === result[key]) {\n let val = str.slice(eqIdx + 1, endIdx).trim();\n\n // quoted values\n if (val.charCodeAt(0) === 0x22) {\n val = val.slice(1, -1);\n }\n\n try {\n result[key] = decode(val);\n } catch (_) {\n result[key] = val; // no decoding\n }\n }\n\n index = endIdx + 1;\n }\n\n return result;\n};\n\nexport interface SerializeOptions {\n encode?: (val: string | number | boolean) => string,\n maxAge?: number,\n domain?: string,\n path?: string,\n expires?: Date,\n httpOnly?: boolean,\n secure?: boolean,\n priority?: string,\n sameSite?: boolean|string,\n}\n\n/**\n * Serialize data into a cookie header.\n *\n * Serialize the a name value pair into a cookie string suitable for\n * http headers. An optional options object specified cookie parameters.\n *\n * ```js\n * cookieSerialize('foo', 'bar', { httpOnly: true }) // \"foo=bar; httpOnly\"\n * ```\n */\nexport function cookieSerialize(name: string, val: string, options?: SerializeOptions): string {\n const opt = Object.assign({}, options || {});\n const encode = opt.encode || defaultEncode;\n\n if (!fieldContentRegExp.test(name)) {\n throw new TypeError('argument name is invalid');\n }\n\n const value = encode(val);\n\n if (value && !fieldContentRegExp.test(value)) {\n throw new TypeError('argument val is invalid');\n }\n\n let result = name + '=' + value;\n\n if (opt.maxAge != null) {\n const maxAge = opt.maxAge - 0;\n\n if (isNaN(maxAge) || !isFinite(maxAge)) {\n throw new TypeError('option maxAge is invalid');\n }\n\n result += '; Max-Age=' + Math.floor(maxAge);\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new TypeError('option domain is invalid');\n }\n\n result += '; Domain=' + opt.domain;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new TypeError('option path is invalid');\n }\n\n result += '; Path=' + opt.path;\n }\n\n if (opt.expires) {\n if (!isDate(opt.expires) || isNaN(opt.expires.valueOf())) {\n throw new TypeError('option expires is invalid');\n }\n\n result += '; Expires=' + opt.expires.toUTCString();\n }\n\n if (opt.httpOnly) {\n result += '; HttpOnly';\n }\n\n if (opt.secure) {\n result += '; Secure';\n }\n\n if (opt.priority) {\n const priority = typeof opt.priority === 'string' ? opt.priority.toLowerCase() : opt.priority;\n\n switch (priority) {\n case 'low':\n result += '; Priority=Low';\n break;\n case 'medium':\n result += '; Priority=Medium';\n break;\n case 'high':\n result += '; Priority=High';\n break;\n default:\n throw new TypeError('option priority is invalid');\n }\n }\n\n if (opt.sameSite) {\n const sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;\n\n switch (sameSite) {\n case true:\n result += '; SameSite=Strict';\n break;\n case 'lax':\n result += '; SameSite=Lax';\n break;\n case 'strict':\n result += '; SameSite=Strict';\n break;\n case 'none':\n result += '; SameSite=None';\n break;\n default:\n throw new TypeError('option sameSite is invalid');\n }\n }\n\n return result;\n};\n\n/**\n * Default URL-decode string value function.\n * Optimized to skip native call when no `%`.\n */\nfunction defaultDecode(val: string): string {\n return val.indexOf('%') !== -1\n ? decodeURIComponent(val)\n : val;\n}\n\n/**\n * Default URL-encode value function.\n */\nfunction defaultEncode(val: string | number | boolean): string {\n return encodeURIComponent(val);\n}\n\n/**\n * Determines if value is a Date.\n */\nfunction isDate(val: any): boolean {\n return (\n Object.prototype.toString.call(val) === '[object Date]' ||\n val instanceof Date\n );\n}\n","let atobPolyfill: Function;\nif (typeof atob === 'function') {\n atobPolyfill = atob\n} else {\n /**\n * The code was extracted from:\n * https://github.com/davidchambers/Base64.js\n */\n atobPolyfill = (input: any) => {\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\n let str = String(input).replace(/=+$/, \"\");\n if (str.length % 4 == 1) {\n throw new Error(\"'atob' failed: The string to be decoded is not correctly encoded.\");\n }\n\n for (\n // initialize result and counters\n var bc = 0, bs, buffer, idx = 0, output = \"\";\n // get next character\n (buffer = str.charAt(idx++));\n // character found in table? initialize bit storage and add its ascii value;\n ~buffer &&\n ((bs = bc % 4 ? (bs as any) * 64 + buffer : buffer),\n // and if not first of each 4 characters,\n // convert the first 8 bits to one ascii character\n bc++ % 4) ?\n (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)))) :\n 0\n ) {\n // try to find character in table (0-63, not found => -1)\n buffer = chars.indexOf(buffer);\n }\n\n return output;\n };\n}\n\n/**\n * Returns JWT token's payload data.\n */\nexport function getTokenPayload(token: string): { [key: string]: any } {\n if (token) {\n try {\n const encodedPayload = decodeURIComponent(atobPolyfill(token.split('.')[1]).split('').map(function (c: string) {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n }).join(''));\n\n return JSON.parse(encodedPayload) || {};\n } catch (e) {\n }\n }\n\n return {};\n}\n\n/**\n * Checks whether a JWT token is expired or not.\n * Tokens without `exp` payload key are considered valid.\n * Tokens with empty payload (eg. invalid token strings) are considered expired.\n *\n * @param token The token to check.\n * @param [expirationThreshold] Time in seconds that will be subtracted from the token `exp` property.\n */\nexport function isTokenExpired(token: string, expirationThreshold = 0): boolean {\n let payload = getTokenPayload(token);\n\n if (\n Object.keys(payload).length > 0 &&\n (!payload.exp || (payload.exp - expirationThreshold) > (Date.now() / 1000))\n ) {\n return false;\n }\n\n return true;\n}\n","import { cookieParse, cookieSerialize, SerializeOptions } from '@/stores/utils/cookie';\nimport { isTokenExpired, getTokenPayload } from '@/stores/utils/jwt';\nimport { RecordModel, AdminModel } from '@/services/utils/dtos';\n\nexport type AuthModel = RecordModel|AdminModel|null;\n\nexport type OnStoreChangeFunc = (token: string, model: AuthModel) => void;\n\nconst defaultCookieKey = 'pb_auth';\n\n/**\n * Base AuthStore class that is intended to be extended by all other\n * PocketBase AuthStore implementations.\n */\nexport abstract class BaseAuthStore {\n protected baseToken: string = '';\n protected baseModel: AuthModel = null;\n\n private _onChangeCallbacks: Array = [];\n\n /**\n * Retrieves the stored token (if any).\n */\n get token(): string {\n return this.baseToken;\n }\n\n /**\n * Retrieves the stored model data (if any).\n */\n get model(): AuthModel {\n return this.baseModel;\n }\n\n /**\n * Loosely checks if the store has valid token (aka. existing and unexpired exp claim).\n */\n get isValid(): boolean {\n return !isTokenExpired(this.token);\n }\n\n /**\n * Checks whether the current store state is for admin authentication.\n */\n get isAdmin(): boolean {\n return getTokenPayload(this.token).type === \"admin\";\n }\n\n /**\n * Checks whether the current store state is for auth record authentication.\n */\n get isAuthRecord(): boolean {\n return getTokenPayload(this.token).type === \"authRecord\";\n }\n\n /**\n * Saves the provided new token and model data in the auth store.\n */\n save(token: string, model?: AuthModel): void {\n this.baseToken = token || '';\n this.baseModel = model || null;\n\n this.triggerChange();\n }\n\n /**\n * Removes the stored token and model data form the auth store.\n */\n clear(): void {\n this.baseToken = '';\n this.baseModel = null;\n this.triggerChange();\n }\n\n /**\n * Parses the provided cookie string and updates the store state\n * with the cookie's token and model data.\n *\n * NB! This function doesn't validate the token or its data.\n * Usually this isn't a concern if you are interacting only with the\n * PocketBase API because it has the proper server-side security checks in place,\n * but if you are using the store `isValid` state for permission controls\n * in a node server (eg. SSR), then it is recommended to call `authRefresh()`\n * after loading the cookie to ensure an up-to-date token and model state.\n * For example:\n *\n * ```js\n * pb.authStore.loadFromCookie(\"cookie string...\");\n *\n * try {\n * // get an up-to-date auth store state by veryfing and refreshing the loaded auth model (if any)\n * pb.authStore.isValid && await pb.collection('users').authRefresh();\n * } catch (_) {\n * // clear the auth store on failed refresh\n * pb.authStore.clear();\n * }\n * ```\n */\n loadFromCookie(cookie: string, key = defaultCookieKey): void {\n const rawData = cookieParse(cookie || '')[key] || '';\n\n let data: { [key: string]: any } = {};\n try {\n data = JSON.parse(rawData);\n // normalize\n if (typeof data === null || typeof data !== 'object' || Array.isArray(data)) {\n data = {};\n }\n } catch (_) {}\n\n this.save(data.token || '', data.model || null);\n }\n\n /**\n * Exports the current store state as cookie string.\n *\n * By default the following optional attributes are added:\n * - Secure\n * - HttpOnly\n * - SameSite=Strict\n * - Path=/\n * - Expires={the token expiration date}\n *\n * NB! If the generated cookie exceeds 4096 bytes, this method will\n * strip the model data to the bare minimum to try to fit within the\n * recommended size in https://www.rfc-editor.org/rfc/rfc6265#section-6.1.\n */\n exportToCookie(options?: SerializeOptions, key = defaultCookieKey): string {\n const defaultOptions: SerializeOptions = {\n secure: true,\n sameSite: true,\n httpOnly: true,\n path: \"/\",\n };\n\n // extract the token expiration date\n const payload = getTokenPayload(this.token);\n if (payload?.exp) {\n defaultOptions.expires = new Date(payload.exp * 1000);\n } else {\n defaultOptions.expires = new Date('1970-01-01');\n }\n\n // merge with the user defined options\n options = Object.assign({}, defaultOptions, options);\n\n const rawData = {\n token: this.token,\n model: this.model ? JSON.parse(JSON.stringify(this.model)) : null,\n };\n\n let result = cookieSerialize(key, JSON.stringify(rawData), options);\n\n const resultLength = typeof Blob !== 'undefined' ?\n (new Blob([result])).size : result.length;\n\n // strip down the model data to the bare minimum\n if (rawData.model && resultLength > 4096) {\n rawData.model = {id: rawData?.model?.id, email: rawData?.model?.email};\n const extraProps = [\"collectionId\", \"username\", \"verified\"];\n for (const prop in this.model) {\n if (extraProps.includes(prop)) {\n rawData.model[prop] = this.model[prop];\n }\n }\n result = cookieSerialize(key, JSON.stringify(rawData), options);\n }\n\n return result;\n }\n\n /**\n * Register a callback function that will be called on store change.\n *\n * You can set the `fireImmediately` argument to true in order to invoke\n * the provided callback right after registration.\n *\n * Returns a removal function that you could call to \"unsubscribe\" from the changes.\n */\n onChange(callback: OnStoreChangeFunc, fireImmediately = false): () => void {\n this._onChangeCallbacks.push(callback);\n\n if (fireImmediately) {\n callback(this.token, this.model);\n }\n\n return () => {\n for (let i = this._onChangeCallbacks.length - 1; i >= 0; i--) {\n if (this._onChangeCallbacks[i] == callback) {\n delete this._onChangeCallbacks[i]; // removes the function reference\n this._onChangeCallbacks.splice(i, 1); // reindex the array\n return;\n }\n }\n }\n }\n\n protected triggerChange(): void {\n for (const callback of this._onChangeCallbacks) {\n callback && callback(this.token, this.model);\n }\n }\n}\n","import { BaseAuthStore, AuthModel } from '@/stores/BaseAuthStore';\n\n/**\n * The default token store for browsers with auto fallback\n * to runtime/memory if local storage is undefined (eg. in node env).\n */\nexport class LocalAuthStore extends BaseAuthStore {\n private storageFallback: { [key: string]: any } = {};\n private storageKey: string\n\n constructor(storageKey = \"pocketbase_auth\") {\n super();\n\n this.storageKey = storageKey;\n\n this._bindStorageEvent();\n }\n\n /**\n * @inheritdoc\n */\n get token(): string {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.token || '';\n }\n\n /**\n * @inheritdoc\n */\n get model(): AuthModel {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.model || null;\n }\n\n /**\n * @inheritdoc\n */\n save(token: string, model?: AuthModel) {\n this._storageSet(this.storageKey, {\n 'token': token,\n 'model': model,\n });\n\n super.save(token, model);\n }\n\n /**\n * @inheritdoc\n */\n clear() {\n this._storageRemove(this.storageKey);\n\n super.clear();\n }\n\n // ---------------------------------------------------------------\n // Internal helpers:\n // ---------------------------------------------------------------\n\n /**\n * Retrieves `key` from the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageGet(key: string): any {\n if (typeof window !== 'undefined' && window?.localStorage) {\n const rawValue = window.localStorage.getItem(key) || '';\n try {\n return JSON.parse(rawValue);\n } catch (e) { // not a json\n return rawValue;\n }\n }\n\n // fallback\n return this.storageFallback[key];\n }\n\n /**\n * Stores a new data in the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageSet(key: string, value: any) {\n if (typeof window !== 'undefined' && window?.localStorage) {\n // store in local storage\n let normalizedVal = value;\n if (typeof value !== 'string') {\n normalizedVal = JSON.stringify(value);\n }\n window.localStorage.setItem(key, normalizedVal);\n } else {\n // store in fallback\n this.storageFallback[key] = value;\n }\n }\n\n /**\n * Removes `key` from the browser's local storage and the runtime/memory.\n */\n private _storageRemove(key: string) {\n // delete from local storage\n if (typeof window !== 'undefined' && window?.localStorage) {\n window.localStorage?.removeItem(key);\n }\n\n // delete from fallback\n delete this.storageFallback[key];\n }\n\n /**\n * Updates the current store state on localStorage change.\n */\n private _bindStorageEvent() {\n if (typeof window === 'undefined' || !window?.localStorage || !window.addEventListener) {\n return;\n }\n\n window.addEventListener('storage', (e) => {\n if (e.key != this.storageKey) {\n return;\n }\n\n const data = this._storageGet(this.storageKey) || {};\n\n super.save(data.token || '', data.model || null);\n });\n }\n}\n","import Client from '@/Client';\n\n/**\n * BaseService class that should be inherited from all API services.\n */\nexport abstract class BaseService {\n readonly client: Client\n\n constructor(client: Client) {\n this.client = client;\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\ninterface appleClientSecret {\n secret: string;\n}\n\nexport class SettingsService extends BaseService {\n /**\n * Fetch all available app settings.\n */\n getAll(options?: CommonOptions): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Bulk updates app settings.\n */\n update(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Performs a S3 filesystem connection test.\n *\n * The currently supported `filesystem` are \"storage\" and \"backups\".\n */\n testS3(filesystem: string = \"storage\", options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'filesystem': filesystem,\n },\n }, options);\n\n return this.client.send('/api/settings/test/s3', options)\n .then(() => true);\n }\n\n /**\n * Sends a test email.\n *\n * The possible `emailTemplate` values are:\n * - verification\n * - password-reset\n * - email-change\n */\n testEmail(toEmail: string, emailTemplate: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'email': toEmail,\n 'template': emailTemplate,\n },\n }, options);\n\n return this.client.send('/api/settings/test/email', options)\n .then(() => true);\n }\n\n /**\n * Generates a new Apple OAuth2 client secret.\n */\n generateAppleClientSecret(\n clientId: string,\n teamId: string,\n keyId: string,\n privateKey: string,\n duration: number,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n clientId,\n teamId,\n keyId,\n privateKey,\n duration,\n },\n }, options);\n\n return this.client.send('/api/settings/apple/generate-client-secret', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n FullListOptions\n} from '@/services/utils/options';\n\nexport abstract class CrudService extends BaseService {\n /**\n * Base path for the crud actions (without trailing slash, eg. '/admins').\n */\n abstract get baseCrudPath(): string\n\n /**\n * Response data decoder.\n */\n decode(data: { [key: string]: any }): T {\n return data as T;\n }\n\n /**\n * Returns a promise with all list items batch fetched at once\n * (by default 500 items per request; to change it set the `batch` query param).\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getFullList(options?: FullListOptions): Promise>\n\n /**\n * Legacy version of getFullList with explicitly specified batch size.\n */\n getFullList(batch?: number, options?: ListOptions): Promise>\n\n getFullList(batchOrqueryParams?: number|FullListOptions, options?: ListOptions): Promise> {\n if (typeof batchOrqueryParams == \"number\") {\n return this._getFullList(batchOrqueryParams, options);\n }\n\n options = Object.assign({}, batchOrqueryParams, options);\n\n let batch = 500;\n if (options.batch) {\n batch = options.batch;\n delete options.batch;\n }\n\n return this._getFullList(batch, options);\n }\n\n /**\n * Returns paginated items list.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({\n method: 'GET'\n }, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => {\n responseData.items = responseData.items?.map((item: any) => {\n return this.decode(item);\n }) || [];\n\n return responseData;\n });\n }\n\n /**\n * Returns the first found item by the specified filter.\n *\n * Internally it calls `getList(1, 1, { filter, skipTotal })` and\n * returns the first found item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n *\n * For consistency with `getOne`, this method will throw a 404\n * ClientResponseError if no item was found.\n */\n getFirstListItem(filter: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'requestKey': 'one_by_filter_' + this.baseCrudPath + \"_\" + filter,\n }, options);\n\n options.query = Object.assign({\n 'filter': filter,\n 'skipTotal': 1,\n }, options.query);\n\n return this.getList(1, 1, options)\n .then((result) => {\n if (!result?.items?.length) {\n throw new ClientResponseError({\n status: 404,\n data: {\n code: 404,\n message: \"The requested resource wasn't found.\",\n data: {},\n },\n });\n }\n\n return result.items[0];\n });\n }\n\n /**\n * Returns single item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getOne(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Creates a new item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n create(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Updates an existing item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Deletes an existing item by its id.\n */\n delete(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then(() => true);\n }\n\n /**\n * Returns a promise with all list items batch fetched at once.\n */\n protected _getFullList(batchSize = 500, options?: ListOptions): Promise> {\n options = options || {};\n options.query = Object.assign({\n 'skipTotal': 1,\n }, options.query);\n\n let result: Array = [];\n\n let request = async (page: number): Promise> => {\n return this.getList(page, batchSize || 500, options).then((list) => {\n const castedList = (list as any as ListResult);\n const items = castedList.items;\n\n result = result.concat(items);\n\n if (items.length == list.perPage) {\n return request(page + 1);\n }\n\n return result;\n });\n }\n\n return request(1);\n }\n}\n","import { SendOptions } from '@/services/utils/options';\n\nexport function normalizeLegacyOptionsArgs(legacyWarn: string, baseOptions: SendOptions, bodyOrOptions?: any, query?: any): SendOptions {\n const hasBodyOrOptions = typeof bodyOrOptions !== 'undefined';\n const hasQuery = typeof query !== 'undefined';\n\n if (!hasQuery && !hasBodyOrOptions) {\n return baseOptions;\n }\n\n if (hasQuery) {\n console.warn(legacyWarn);\n baseOptions.body = Object.assign({}, baseOptions.body, bodyOrOptions);\n baseOptions.query = Object.assign({}, baseOptions.query, query);\n\n return baseOptions;\n }\n\n baseOptions = Object.assign(baseOptions, bodyOrOptions);\n return baseOptions;\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { AdminModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface AdminAuthResponse {\n [key: string]: any;\n\n token: string;\n admin: AdminModel;\n}\n\nexport class AdminService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/admins';\n }\n\n // ---------------------------------------------------------------\n // Post update/delete AuthStore sync\n // ---------------------------------------------------------------\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n // update the store state if the updated item id matches with the stored model\n if (\n this.client.authStore.model?.id === item.id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n // clear the store state if the deleted item id matches with the stored model\n if (\n success &&\n this.client.authStore.model?.id === id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful authorize response.\n */\n protected authResponse(responseData: any): AdminAuthResponse {\n const admin = this.decode(responseData?.admin || {});\n\n if (responseData?.token && responseData?.admin) {\n this.client.authStore.save(responseData.token, admin);\n }\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'admin': admin,\n });\n }\n\n /**\n * Authenticate an admin account with its email and password\n * and returns a new admin token and data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authWithPassword(email: string, password: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authWithPassword(email, password, options?).\n */\n authWithPassword(email: string, password: string, body?: any, query?: any): Promise\n\n authWithPassword(\n email: string,\n password: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': email,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(email, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(email, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-with-password', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Refreshes the current admin authenticated instance and\n * returns a new token and admin data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authRefresh(options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-refresh', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Sends admin password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/request-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Confirms admin password reset request.\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(resetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, body?: any, query?: any): Promise\n\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, bodyOrOptions?: any, query?: any): Promise{\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': resetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(resetToken, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(resetToken, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\n\ninterface promiseCallbacks {\n resolve: Function\n reject: Function\n}\n\nexport type UnsubscribeFunc = () => Promise;\n\nexport class RealtimeService extends BaseService {\n clientId: string = \"\";\n\n private eventSource: EventSource | null = null;\n private subscriptions: { [key: string]: Array } = {};\n private lastSentTopics: Array = [];\n private connectTimeoutId: any;\n private maxConnectTimeout: number = 15000;\n private reconnectTimeoutId: any;\n private reconnectAttempts: number = 0;\n private maxReconnectAttempts: number = Infinity;\n private predefinedReconnectIntervals: Array = [\n 200, 300, 500, 1000, 1200, 1500, 2000,\n ];\n private pendingConnects: Array = [];\n\n /**\n * Returns whether the realtime connection has been established.\n */\n get isConnected(): boolean {\n return !!this.eventSource && !!this.clientId && !this.pendingConnects.length;\n }\n\n /**\n * Register the subscription listener.\n *\n * You can subscribe multiple times to the same topic.\n *\n * If the SSE connection is not started yet,\n * this method will also initialize it.\n */\n async subscribe(topic: string, callback: (data: any) => void): Promise {\n if (!topic) {\n throw new Error('topic must be set.')\n }\n\n const listener = function (e: Event) {\n const msgEvent = (e as MessageEvent);\n\n let data;\n try {\n data = JSON.parse(msgEvent?.data);\n } catch {}\n\n callback(data || {});\n };\n\n // store the listener\n if (!this.subscriptions[topic]) {\n this.subscriptions[topic] = [];\n }\n this.subscriptions[topic].push(listener);\n\n if (!this.isConnected) {\n // initialize sse connection\n await this.connect();\n } else if (this.subscriptions[topic].length === 1) {\n // send the updated subscriptions (if it is the first for the topic)\n await this.submitSubscriptions();\n } else {\n // only register the listener\n this.eventSource?.addEventListener(topic, listener);\n }\n\n return async (): Promise => {\n return this.unsubscribeByTopicAndListener(topic, listener);\n };\n }\n\n /**\n * Unsubscribe from all subscription listeners with the specified topic.\n *\n * If `topic` is not provided, then this method will unsubscribe\n * from all active subscriptions.\n *\n * This method is no-op if there are no active subscriptions.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribe(topic?: string): Promise {\n if (!this.hasSubscriptionListeners(topic)) {\n return; // already unsubscribed\n }\n\n if (!topic) {\n // remove all subscriptions\n this.subscriptions = {};\n } else {\n // remove all topic listeners\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n /**\n * Unsubscribe from all subscription listeners starting with the specified topic prefix.\n *\n * This method is no-op if there are no active subscriptions with the specified topic prefix.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByPrefix(topicPrefix: string): Promise {\n let hasAtleastOneTopic = false;\n for (let topic in this.subscriptions) {\n if (!topic.startsWith(topicPrefix)) {\n continue;\n }\n\n hasAtleastOneTopic = true;\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!hasAtleastOneTopic) {\n return; // nothing to unsubscribe from\n }\n\n if (this.hasSubscriptionListeners()) {\n // submit the deleted subscriptions\n await this.submitSubscriptions();\n } else {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n }\n }\n\n /**\n * Unsubscribe from all subscriptions matching the specified topic and listener function.\n *\n * This method is no-op if there are no active subscription with\n * the specified topic and listener.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByTopicAndListener(topic: string, listener: EventListener): Promise {\n if (!Array.isArray(this.subscriptions[topic]) || !this.subscriptions[topic].length) {\n return; // already unsubscribed\n }\n\n let exist = false;\n for (let i = this.subscriptions[topic].length - 1; i >= 0; i--) {\n if (this.subscriptions[topic][i] !== listener) {\n continue;\n }\n\n exist = true; // has at least one matching listener\n delete this.subscriptions[topic][i]; // removes the function reference\n this.subscriptions[topic].splice(i, 1); // reindex the array\n this.eventSource?.removeEventListener(topic, listener);\n }\n if (!exist) {\n return;\n }\n\n // remove the topic from the subscriptions list if there are no other listeners\n if (!this.subscriptions[topic].length) {\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n private hasSubscriptionListeners(topicToCheck?: string): boolean {\n this.subscriptions = this.subscriptions || {};\n\n // check the specified topic\n if (topicToCheck) {\n return !!this.subscriptions[topicToCheck]?.length;\n }\n\n // check for at least one non-empty topic\n for (let topic in this.subscriptions) {\n if (!!this.subscriptions[topic]?.length) {\n return true\n }\n }\n\n return false;\n }\n\n private async submitSubscriptions(): Promise {\n if (!this.clientId) {\n return; // no client/subscriber\n }\n\n // optimistic update\n this.addAllSubscriptionListeners();\n\n this.lastSentTopics = this.getNonEmptySubscriptionTopics();\n\n return this.client.send('/api/realtime', {\n 'method': 'POST',\n 'body': {\n 'clientId': this.clientId,\n 'subscriptions': this.lastSentTopics,\n },\n 'query': {\n 'requestKey': this.getSubscriptionsCancelKey(),\n },\n }).catch((err) => {\n if (err?.isAbort) {\n return; // silently ignore aborted pending requests\n }\n throw err;\n });\n }\n\n private getSubscriptionsCancelKey(): string {\n return \"realtime_\" + this.clientId;\n }\n\n private getNonEmptySubscriptionTopics(): Array {\n const result : Array = [];\n\n for (let topic in this.subscriptions) {\n if (this.subscriptions[topic].length) {\n result.push(topic);\n }\n }\n\n return result;\n }\n\n private addAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n this.removeAllSubscriptionListeners();\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.addEventListener(topic, listener);\n }\n }\n }\n\n private removeAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.removeEventListener(topic, listener);\n }\n }\n }\n\n private async connect(): Promise {\n if (this.reconnectAttempts > 0) {\n // immediately resolve the promise to avoid indefinitely\n // blocking the client during reconnection\n return;\n }\n\n return new Promise((resolve, reject) => {\n this.pendingConnects.push({ resolve, reject });\n\n if (this.pendingConnects.length > 1) {\n // all promises will be resolved once the connection is established\n return;\n }\n\n this.initConnect();\n })\n }\n\n private initConnect() {\n this.disconnect(true);\n\n // wait up to 15s for connect\n clearTimeout(this.connectTimeoutId);\n this.connectTimeoutId = setTimeout(() => {\n this.connectErrorHandler(new Error(\"EventSource connect took too long.\"));\n }, this.maxConnectTimeout);\n\n this.eventSource = new EventSource(this.client.buildUrl('/api/realtime'))\n\n this.eventSource.onerror = (_) => {\n this.connectErrorHandler(new Error(\"Failed to establish realtime connection.\"));\n };\n\n this.eventSource.addEventListener('PB_CONNECT', (e) => {\n const msgEvent = (e as MessageEvent);\n this.clientId = msgEvent?.lastEventId;\n\n this.submitSubscriptions()\n .then(async () => {\n let retries = 3;\n while (this.hasUnsentSubscriptions() && retries > 0) {\n retries--;\n // resubscribe to ensure that the latest topics are submitted\n //\n // This is needed because missed topics could happen on reconnect\n // if after the pending sent `submitSubscriptions()` call another `subscribe()`\n // was made before the submit was able to complete.\n await this.submitSubscriptions();\n }\n }).then(() => {\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n\n // reset connect meta\n this.pendingConnects = [];\n this.reconnectAttempts = 0;\n clearTimeout(this.reconnectTimeoutId);\n clearTimeout(this.connectTimeoutId);\n }).catch((err) => {\n this.clientId = \"\";\n this.connectErrorHandler(err);\n });\n });\n }\n\n private hasUnsentSubscriptions(): boolean {\n const latestTopics = this.getNonEmptySubscriptionTopics();\n if (latestTopics.length != this.lastSentTopics.length) {\n return true;\n }\n\n for (const t of latestTopics) {\n if (!this.lastSentTopics.includes(t)) {\n return true;\n }\n }\n\n return false;\n }\n\n private connectErrorHandler(err: any) {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n\n if (\n // wasn't previously connected -> direct reject\n (!this.clientId && !this.reconnectAttempts) ||\n // was previously connected but the max reconnection limit has been reached\n this.reconnectAttempts > this.maxReconnectAttempts\n ) {\n for (let p of this.pendingConnects) {\n p.reject(new ClientResponseError(err));\n }\n this.pendingConnects = [];\n this.disconnect();\n return;\n }\n\n // otherwise -> reconnect in the background\n this.disconnect(true);\n const timeout = this.predefinedReconnectIntervals[this.reconnectAttempts] || this.predefinedReconnectIntervals[this.predefinedReconnectIntervals.length - 1];\n this.reconnectAttempts++;\n this.reconnectTimeoutId = setTimeout(() => {\n this.initConnect();\n }, timeout);\n }\n\n private disconnect(fromReconnect = false): void {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n this.removeAllSubscriptionListeners();\n this.client.cancelRequest(this.getSubscriptionsCancelKey());\n this.eventSource?.close();\n this.eventSource = null;\n this.clientId = \"\";\n\n if (!fromReconnect) {\n this.reconnectAttempts = 0;\n\n // resolve any remaining connect promises\n //\n // this is done to avoid unnecessary throwing errors in case\n // unsubscribe is called before the pending connect promises complete\n // (see https://github.com/pocketbase/pocketbase/discussions/2897#discussioncomment-6423818)\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n this.pendingConnects = [];\n }\n }\n}\n","import Client from '@/Client';\nimport { CrudService } from '@/services/utils/CrudService';\nimport { RealtimeService, UnsubscribeFunc } from '@/services/RealtimeService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult, RecordModel, ExternalAuthModel } from '@/services/utils/dtos';\nimport {\n SendOptions,\n CommonOptions,\n RecordOptions,\n RecordListOptions,\n RecordFullListOptions,\n} from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface RecordAuthResponse {\n // The signed PocketBase auth record.\n record: T;\n\n // The PocketBase record auth token.\n //\n // If you are looking for the OAuth2 access and refresh tokens\n // they are available under the `meta.accessToken` and `meta.refreshToken` props.\n token: string;\n\n // Auth meta data usually filled when OAuth2 is used.\n meta?: {[key: string]: any};\n}\n\nexport interface AuthProviderInfo {\n name: string;\n state: string;\n codeVerifier: string;\n codeChallenge: string;\n codeChallengeMethod: string;\n authUrl: string;\n}\n\nexport interface AuthMethodsList {\n usernamePassword: boolean;\n emailPassword: boolean;\n authProviders: Array;\n}\n\nexport interface RecordSubscription {\n action: string; // eg. create, update, delete\n record: T;\n}\n\nexport type OAuth2UrlCallback = (url: string) => void|Promise;\n\nexport interface OAuth2AuthConfig extends SendOptions {\n // the name of the OAuth2 provider (eg. \"google\")\n provider: string;\n\n // custom scopes to overwrite the default ones\n scopes?: Array;\n\n // optional record create data\n createData?: {[key: string]: any};\n\n // optional callback that is triggered after the OAuth2 sign-in/sign-up url generation\n urlCallback?: OAuth2UrlCallback;\n\n // optional query params to send with the PocketBase auth request (eg. fields, expand, etc.)\n query?: RecordOptions;\n}\n\nexport class RecordService extends CrudService {\n readonly collectionIdOrName: string;\n\n constructor(client: Client, collectionIdOrName: string) {\n super(client);\n\n this.collectionIdOrName = collectionIdOrName;\n }\n\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return this.baseCollectionPath + '/records';\n }\n\n /**\n * Returns the current collection service base path.\n */\n get baseCollectionPath(): string {\n return '/api/collections/' + encodeURIComponent(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Realtime handlers\n // ---------------------------------------------------------------\n\n /**\n * @deprecated Use subscribe(recordId, callback) instead.\n *\n * Subscribe to the realtime changes of a single record in the collection.\n */\n async subscribeOne(recordId: string, callback: (data: RecordSubscription) => void): Promise {\n console.warn(\"PocketBase: subscribeOne(recordId, callback) is deprecated. Please replace it with subscribe(recordId, callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName + \"/\" + recordId, callback);\n }\n\n /**\n * @deprecated This form of subscribe is deprecated. Please use `subscribe(\"*\", callback)`.\n */\n async subscribe(callback: (data: RecordSubscription) => void): Promise\n\n /**\n * Subscribe to realtime changes to the specified topic (\"*\" or record id).\n *\n * If `topic` is the wildcard \"*\", then this method will subscribe to\n * any record changes in the collection.\n *\n * If `topic` is a record id, then this method will subscribe only\n * to changes of the specified record id.\n *\n * It's OK to subscribe multiple times to the same topic.\n * You can use the returned `UnsubscribeFunc` to remove only a single subscription.\n * Or use `unsubscribe(topic)` if you want to remove all subscriptions attached to the topic.\n */\n async subscribe(topic: string, callback: (data: RecordSubscription) => void): Promise\n\n async subscribe(\n topicOrCallback: string|((data: RecordSubscription) => void),\n callback?: (data: RecordSubscription) => void\n ): Promise {\n if (typeof topicOrCallback === 'function') {\n console.warn(\"PocketBase: subscribe(callback) is deprecated. Please replace it with subscribe('*', callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName, topicOrCallback);\n }\n\n if (!callback) {\n throw new Error(\"Missing subscription callback.\");\n }\n\n if (topicOrCallback === \"\") {\n throw new Error(\"Missing topic.\");\n }\n\n let topic = this.collectionIdOrName;\n if (topicOrCallback !== \"*\") {\n topic += ('/' + topicOrCallback);\n }\n\n return this.client.realtime.subscribe(topic, callback)\n }\n\n /**\n * Unsubscribe from all subscriptions of the specified topic\n * (\"*\" or record id).\n *\n * If `topic` is not set, then this method will unsubscribe from\n * all subscriptions associated to the current collection.\n */\n async unsubscribe(topic?: string): Promise {\n // unsubscribe wildcard topic\n if (topic === \"*\") {\n return this.client.realtime.unsubscribe(this.collectionIdOrName);\n }\n\n // unsubscribe recordId topic\n if (topic) {\n return this.client.realtime.unsubscribe(this.collectionIdOrName + \"/\" + topic);\n }\n\n // unsubscribe from everything related to the collection\n return this.client.realtime.unsubscribeByPrefix(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Crud handers\n // ---------------------------------------------------------------\n /**\n * @inheritdoc\n */\n getFullList(options?: RecordFullListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batch?: number, options?: RecordListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batchOrOptions?: number|RecordFullListOptions, options?: RecordListOptions): Promise> {\n if (typeof batchOrOptions == \"number\") {\n return super.getFullList(batchOrOptions, options);\n }\n\n const params = Object.assign({}, batchOrOptions, options);\n\n return super.getFullList(params);\n }\n\n /**\n * @inheritdoc\n */\n getList(page = 1, perPage = 30, options?: RecordListOptions): Promise> {\n return super.getList(page, perPage, options);\n }\n\n /**\n * @inheritdoc\n */\n getFirstListItem(filter: string, options?: RecordListOptions): Promise {\n return super.getFirstListItem(filter, options);\n }\n\n /**\n * @inheritdoc\n */\n getOne(id: string, options?: RecordOptions): Promise {\n return super.getOne(id, options);\n }\n\n /**\n * @inheritdoc\n */\n create(bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.create(bodyParams, options);\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(id: string, bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n if (\n // is record auth\n this.client.authStore.model?.id === item?.id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n if (\n success &&\n // is record auth\n this.client.authStore.model?.id === id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful collection authorization response.\n */\n protected authResponse(responseData: any): RecordAuthResponse {\n const record = this.decode(responseData?.record || {});\n\n this.client.authStore.save(responseData?.token, record);\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'record': record as any as T,\n });\n }\n\n /**\n * Returns all available collection auth methods.\n */\n listAuthMethods(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCollectionPath + '/auth-methods', options)\n .then((responseData: any) => {\n return Object.assign({}, responseData, {\n // normalize common fields\n 'usernamePassword': !!responseData?.usernamePassword,\n 'emailPassword': !!responseData?.emailPassword,\n 'authProviders': Array.isArray(responseData?.authProviders) ? responseData?.authProviders : [],\n });\n });\n }\n\n /**\n * Authenticate a single auth collection record via its username/email and password.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n */\n authWithPassword(usernameOrEmail: string, password: string, options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authWithPassword(usernameOrEmail, password, options?).\n */\n authWithPassword(usernameOrEmail: string, password: string, body?: any, query?: any): Promise>\n\n authWithPassword(usernameOrEmail: string, password: string, bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': usernameOrEmail,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(usernameOrEmail, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(usernameOrEmail, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-password', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Authenticate a single auth collection record with OAuth2 code.\n *\n * If you don't have an OAuth2 code you may also want to check `authWithOAuth2` method.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n options?: RecordOptions,\n ): Promise>\n\n /**\n * @deprecated\n * Consider using authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createdData, options?).\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n body?: any,\n query?: any\n ): Promise>\n\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n bodyOrOptions?: any,\n query?: any\n ): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'provider': provider,\n 'code': code,\n 'codeVerifier': codeVerifier,\n 'redirectUrl': redirectUrl,\n 'createData': createData,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, body?, query?) is deprecated. Consider replacing it with authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-oauth2', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * @deprecated This form of authWithOAuth2 is deprecated.\n *\n * Please use `authWithOAuth2Code()` OR its simplified realtime version\n * as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\n */\n async authWithOAuth2(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key: string]: any},\n bodyParams?: {[key: string]: any},\n queryParams?: RecordOptions,\n ): Promise>\n\n /**\n * Authenticate a single auth collection record with OAuth2\n * **without custom redirects, deeplinks or even page reload**.\n *\n * This method initializes a one-off realtime subscription and will\n * open a popup window with the OAuth2 vendor page to authenticate.\n * Once the external OAuth2 sign-in/sign-up flow is completed, the popup\n * window will be automatically closed and the OAuth2 data sent back\n * to the user through the previously established realtime connection.\n *\n * You can specify an optional `urlCallback` prop to customize\n * the default url `window.open` behavior.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n *\n * Example:\n *\n * ```js\n * const authData = await pb.collection(\"users\").authWithOAuth2({\n * provider: \"google\",\n * })\n * ```\n *\n * _Site-note_: when creating the OAuth2 app in the provider dashboard\n * you have to configure `https://yourdomain.com/api/oauth2-redirect`\n * as redirect URL.\n */\n async authWithOAuth2(options: OAuth2AuthConfig): Promise>\n\n async authWithOAuth2(...args: any): Promise> {\n // fallback to legacy format\n if (args.length > 1 || typeof args?.[0] === 'string') {\n console.warn(\"PocketBase: This form of authWithOAuth2() is deprecated and may get removed in the future. Please replace with authWithOAuth2Code() OR use the authWithOAuth2() realtime form as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\");\n return this.authWithOAuth2Code(\n args?.[0] || '',\n args?.[1] || '',\n args?.[2] || '',\n args?.[3] || '',\n args?.[4] || {},\n args?.[5] || {},\n args?.[6] || {},\n );\n }\n\n const config = args?.[0] || {};\n\n const authMethods = await this.listAuthMethods();\n\n const provider = authMethods.authProviders.find((p) => p.name === config.provider);\n if (!provider) {\n throw new ClientResponseError(new Error(`Missing or invalid provider \"${config.provider}\".`));\n }\n\n const redirectUrl = this.client.buildUrl('/api/oauth2-redirect');\n\n // initialize a one-off realtime service\n const realtime = new RealtimeService(this.client);\n\n // open a new popup window in case config.urlCallback is not set\n //\n // note: it is opened before the async call due to Safari restrictions\n // (see https://github.com/pocketbase/pocketbase/discussions/2429#discussioncomment-5943061)\n let eagerDefaultPopup: Window|null = null;\n if (!config.urlCallback) {\n eagerDefaultPopup = openBrowserPopup(undefined);\n }\n\n function cleanup() {\n eagerDefaultPopup?.close();\n realtime.unsubscribe();\n }\n\n return new Promise(async (resolve, reject) => {\n try {\n await realtime.subscribe('@oauth2', async (e) => {\n const oldState = realtime.clientId;\n\n try {\n if (!e.state || oldState !== e.state) {\n throw new Error(\"State parameters don't match.\");\n }\n\n // clear the non SendOptions props\n const options = Object.assign({}, config);\n delete options.provider;\n delete options.scopes;\n delete options.createData;\n delete options.urlCallback;\n\n const authData = await this.authWithOAuth2Code(\n provider.name,\n e.code,\n provider.codeVerifier,\n redirectUrl,\n config.createData,\n options,\n );\n\n resolve(authData);\n } catch (err) {\n reject(new ClientResponseError(err));\n }\n\n cleanup();\n });\n\n const replacements: {[key: string]: any} = {\n \"state\": realtime.clientId,\n }\n if (config.scopes?.length) {\n replacements[\"scope\"] = config.scopes.join(\" \");\n }\n\n const url = this._replaceQueryParams(provider.authUrl + redirectUrl, replacements);\n\n let urlCallback = config.urlCallback || function (url: string) {\n if (eagerDefaultPopup) {\n eagerDefaultPopup.location.href = url;\n } else {\n // it could have been blocked due to its empty initial url,\n // try again...\n eagerDefaultPopup = openBrowserPopup(url);\n }\n }\n\n await urlCallback(url);\n } catch (err) {\n cleanup();\n reject(new ClientResponseError(err));\n }\n });\n }\n\n /**\n * Refreshes the current authenticated record instance and\n * returns a new token and record data.\n *\n * On success this method also automatically updates the client's AuthStore.\n */\n authRefresh(options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise>\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-refresh', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Sends auth record password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-password-reset', options).then(() => true);\n }\n\n /**\n * Confirms auth record password reset request.\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n options?: CommonOptions,\n ): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(passwordResetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n body?: any,\n query?: any,\n ): Promise\n\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': passwordResetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(token, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(token, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Sends auth record verification email request.\n */\n requestVerification(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestVerification(email, options?).\n */\n requestVerification(email: string, body?: any, query?: any): Promise\n\n requestVerification(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestVerification(email, body?, query?) is deprecated. Consider replacing it with requestVerification(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-verification', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record email verification request.\n */\n confirmVerification(verificationToken: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmVerification(verificationToken, options?).\n */\n confirmVerification(verificationToken: string, body?: any, query?: any): Promise\n\n confirmVerification(verificationToken: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': verificationToken,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmVerification(token, body?, query?) is deprecated. Consider replacing it with confirmVerification(token, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-verification', options)\n .then(() => true);\n }\n\n /**\n * Sends an email change request to the authenticated record model.\n */\n requestEmailChange(newEmail: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestEmailChange(newEmail, options?).\n */\n requestEmailChange(newEmail: string, body?: any, query?: any): Promise\n\n requestEmailChange(newEmail: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'newEmail': newEmail,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestEmailChange(newEmail, body?, query?) is deprecated. Consider replacing it with requestEmailChange(newEmail, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-email-change', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record's new email address.\n */\n confirmEmailChange(emailChangeToken: string, password: string, options?: CommonOptions): Promise\n\n\n /**\n * @deprecated\n * Consider using confirmEmailChange(emailChangeToken, password, options?).\n */\n confirmEmailChange(emailChangeToken: string, password: string, body?: any, query?: any): Promise\n\n confirmEmailChange(emailChangeToken: string, password: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': emailChangeToken,\n 'password': password,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmEmailChange(token, password, body?, query?) is deprecated. Consider replacing it with confirmEmailChange(token, password, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-email-change', options)\n .then(() => true);\n }\n\n /**\n * Lists all linked external auth providers for the specified auth record.\n */\n listExternalAuths(recordId: string, options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths', options);\n }\n\n /**\n * Unlink a single external auth provider from the specified auth record.\n */\n unlinkExternalAuth(recordId: string, provider: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths/' + encodeURIComponent(provider), options)\n .then(() => true);\n }\n\n // ---------------------------------------------------------------\n\n // very rudimentary url query params replacement because at the moment\n // URL (and URLSearchParams) doesn't seem to be fully supported in React Native\n //\n // note: for details behind some of the decode/encode parsing check https://unixpapa.com/js/querystring.html\n private _replaceQueryParams(url: string, replacements: {[key: string]: any} = {}): string {\n let urlPath = url\n let query = \"\";\n\n const queryIndex = url.indexOf(\"?\");\n if (queryIndex >= 0) {\n urlPath = url.substring(0, url.indexOf(\"?\"));\n query = url.substring(url.indexOf(\"?\") + 1);\n }\n\n const parsedParams: {[key: string]: string} = {};\n\n // parse the query parameters\n const rawParams = query.split(\"&\");\n for (const param of rawParams) {\n if (param == \"\") {\n continue\n }\n\n const pair = param.split(\"=\");\n parsedParams[decodeURIComponent(pair[0].replace(/\\+/g,' '))] = decodeURIComponent((pair[1] || \"\").replace(/\\+/g,' '));\n }\n\n // apply the replacements\n for (let key in replacements) {\n if (!replacements.hasOwnProperty(key)) {\n continue;\n }\n\n if (replacements[key] == null) {\n delete parsedParams[key];\n } else {\n parsedParams[key] = replacements[key];\n }\n }\n\n // construct back the full query string\n query = \"\";\n for (let key in parsedParams) {\n if (!parsedParams.hasOwnProperty(key)) {\n continue;\n }\n\n if (query != \"\") {\n query += \"&\";\n }\n\n query += encodeURIComponent(key.replace(/%20/g,'+')) + \"=\" + encodeURIComponent(parsedParams[key].replace(/%20/g,'+'));\n }\n\n return query != \"\" ? (urlPath + \"?\" + query) : urlPath;\n }\n}\n\nfunction openBrowserPopup(url?: string): Window|null {\n if (typeof window === \"undefined\" || !window?.open) {\n throw new ClientResponseError(new Error(`Not in a browser context - please pass a custom urlCallback function.`));\n }\n\n let width = 1024;\n let height = 768;\n\n let windowWidth = window.innerWidth;\n let windowHeight = window.innerHeight;\n\n // normalize window size\n width = width > windowWidth ? windowWidth : width;\n height = height > windowHeight ? windowHeight : height;\n\n let left = (windowWidth / 2) - (width / 2);\n let top = (windowHeight / 2) - (height / 2);\n\n // note: we don't use the noopener and noreferrer attributes since\n // for some reason browser blocks such windows then url is undefined/blank\n return window.open(\n url,\n 'popup_window',\n 'width='+width+',height='+height+',top='+top+',left='+left+',resizable,menubar=no'\n );\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { CollectionModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport class CollectionService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/collections';\n }\n\n /**\n * Imports the provided collections.\n *\n * If `deleteMissing` is `true`, all local collections and schema fields,\n * that are not present in the imported configuration, WILL BE DELETED\n * (including their related records data)!\n */\n async import(\n collections: Array,\n deleteMissing: boolean = false,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PUT',\n 'body': {\n 'collections': collections,\n 'deleteMissing': deleteMissing,\n }\n }, options);\n\n return this.client.send(this.baseCrudPath + '/import', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ListResult, LogRequestModel } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n LogStatsOptions,\n} from '@/services/utils/options';\n\nexport interface HourlyStats {\n total: number;\n date: string;\n}\n\nexport class LogService extends BaseService {\n /**\n * Returns paginated logged requests list.\n */\n getRequestsList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({'method': 'GET'}, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send('/api/logs/requests', options);\n }\n\n /**\n * Returns a single logged request by its id.\n */\n getRequest(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/' + encodeURIComponent(id), options);\n }\n\n /**\n * Returns request logs statistics.\n */\n getRequestsStats(options?: LogStatsOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/stats', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface HealthCheckResponse {\n code: number;\n message: string;\n data: {[key: string]: any};\n}\n\nexport class HealthService extends BaseService {\n /**\n * Checks the health status of the api.\n */\n check(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/health', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions, FileOptions } from '@/services/utils/options';\n\nexport class FileService extends BaseService {\n /**\n * Builds and returns an absolute record file url for the provided filename.\n */\n getUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n if (\n !filename ||\n !record?.id ||\n !(record?.collectionId || record?.collectionName)\n ) {\n return '';\n }\n\n const parts = [];\n parts.push('api')\n parts.push('files')\n parts.push(encodeURIComponent(record.collectionId || record.collectionName))\n parts.push(encodeURIComponent(record.id))\n parts.push(encodeURIComponent(filename))\n\n let result = this.client.buildUrl(parts.join('/'));\n\n if (Object.keys(queryParams).length) {\n // normalize the download query param for consistency with the Dart sdk\n if (queryParams.download === false) {\n delete(queryParams.download);\n }\n\n const params = new URLSearchParams(queryParams);\n\n result += (result.includes('?') ? '&' : '?') + params;\n }\n\n return result\n }\n\n /**\n * Requests a new private file access token for the current auth model (admin or record).\n */\n getToken(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send('/api/files/token', options)\n .then((data) => data?.token || '');\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface BackupFileInfo {\n key: string;\n size: number;\n modified: string;\n}\n\nexport class BackupService extends BaseService {\n /**\n * Returns list with all available backup files.\n */\n getFullList(options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/backups', options);\n }\n\n /**\n * Initializes a new backup.\n */\n create(basename: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'name': basename,\n },\n }, options);\n\n return this.client.send('/api/backups', options)\n .then(() => true);\n }\n\n /**\n * Deletes a single backup file.\n */\n delete(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}`, options)\n .then(() => true);\n }\n\n /**\n * Initializes an app data restore from an existing backup.\n */\n restore(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}/restore`, options)\n .then(() => true);\n }\n\n /**\n * Builds a download url for a single existing backup using an\n * admin file token and the backup file key.\n *\n * The file token can be generated via `pb.files.getToken()`.\n */\n getDownloadUrl(token: string, key: string): string {\n return this.client.buildUrl(`/api/backups/${encodeURIComponent(key)}?token=${encodeURIComponent(token)}`);\n }\n}\n","import { ClientResponseError } from '@/ClientResponseError';\nimport { BaseAuthStore } from '@/stores/BaseAuthStore';\nimport { LocalAuthStore } from '@/stores/LocalAuthStore';\nimport { SettingsService } from '@/services/SettingsService';\nimport { AdminService } from '@/services/AdminService';\nimport { RecordService } from '@/services/RecordService';\nimport { CollectionService } from '@/services/CollectionService';\nimport { LogService } from '@/services/LogService';\nimport { RealtimeService } from '@/services/RealtimeService';\nimport { HealthService } from '@/services/HealthService';\nimport { FileService } from '@/services/FileService';\nimport { BackupService } from '@/services/BackupService';\nimport { SendOptions, FileOptions } from '@/services/utils/options';\n\n// list of known SendOptions keys (everything else is treated as query param)\nconst knownSendOptionsKeys = [\n 'requestKey',\n '$cancelKey',\n '$autoCancel',\n 'fetch',\n 'headers',\n 'body',\n 'query',\n 'params',\n // ---,\n 'cache',\n 'credentials',\n 'headers',\n 'integrity',\n 'keepalive',\n 'method',\n 'mode',\n 'redirect',\n 'referrer',\n 'referrerPolicy',\n 'signal',\n 'window',\n];\n\nexport interface BeforeSendResult {\n [key: string]: any, // for backward compatibility\n url?: string,\n options?: {[key: string]: any}\n}\n\n/**\n * PocketBase JS Client.\n */\nexport default class Client {\n /**\n * The base PocketBase backend url address (eg. 'http://127.0.0.1.8090').\n */\n baseUrl: string;\n\n /**\n * Hook that get triggered right before sending the fetch request,\n * allowing you to inspect and modify the url and request options.\n *\n * For list of the possible options check https://developer.mozilla.org/en-US/docs/Web/API/fetch#options\n *\n * You can return a non-empty result object `{ url, options }` to replace the url and request options entirely.\n *\n * Example:\n * ```js\n * client.beforeSend = function (url, options) {\n * options.headers = Object.assign({}, options.headers, {\n * 'X-Custom-Header': 'example',\n * });\n *\n * return { url, options }\n * };\n * ```\n */\n beforeSend?: (url: string, options: SendOptions) => BeforeSendResult|Promise;\n\n /**\n * Hook that get triggered after successfully sending the fetch request,\n * allowing you to inspect/modify the response object and its parsed data.\n *\n * Returns the new Promise resolved `data` that will be returned to the client.\n *\n * Example:\n * ```js\n * client.afterSend = function (response, data) {\n * if (response.status != 200) {\n * throw new ClientResponseError({\n * url: response.url,\n * status: response.status,\n * data: data,\n * });\n * }\n *\n * return data;\n * };\n * ```\n */\n afterSend?: (response: Response, data: any) => any;\n\n /**\n * Optional language code (default to `en-US`) that will be sent\n * with the requests to the server as `Accept-Language` header.\n */\n lang: string;\n\n /**\n * A replaceable instance of the local auth store service.\n */\n authStore: BaseAuthStore;\n\n /**\n * An instance of the service that handles the **Settings APIs**.\n */\n readonly settings: SettingsService;\n\n /**\n * An instance of the service that handles the **Admin APIs**.\n */\n readonly admins: AdminService;\n\n /**\n * An instance of the service that handles the **Collection APIs**.\n */\n readonly collections: CollectionService;\n\n /**\n * An instance of the service that handles the **File APIs**.\n */\n readonly files: FileService;\n\n /**\n * An instance of the service that handles the **Log APIs**.\n */\n readonly logs: LogService;\n\n /**\n * An instance of the service that handles the **Realtime APIs**.\n */\n readonly realtime: RealtimeService;\n\n /**\n * An instance of the service that handles the **Health APIs**.\n */\n readonly health: HealthService;\n\n /**\n * An instance of the service that handles the **Backup APIs**.\n */\n readonly backups: BackupService;\n\n private cancelControllers: { [key: string]: AbortController } = {};\n private recordServices: { [key: string]: RecordService } = {};\n private enableAutoCancellation: boolean = true;\n\n constructor(\n baseUrl = '/',\n authStore?: BaseAuthStore | null,\n lang = 'en-US',\n ) {\n this.baseUrl = baseUrl;\n this.lang = lang;\n this.authStore = authStore || new LocalAuthStore();\n\n // services\n this.admins = new AdminService(this);\n this.collections = new CollectionService(this);\n this.files = new FileService(this);\n this.logs = new LogService(this);\n this.settings = new SettingsService(this);\n this.realtime = new RealtimeService(this);\n this.health = new HealthService(this);\n this.backups = new BackupService(this);\n }\n\n /**\n * Returns the RecordService associated to the specified collection.\n *\n * @param {string} idOrName\n * @return {RecordService}\n */\n collection(idOrName: string): RecordService {\n if (!this.recordServices[idOrName]) {\n this.recordServices[idOrName] = new RecordService(this, idOrName);\n }\n\n return this.recordServices[idOrName];\n }\n\n /**\n * Globally enable or disable auto cancellation for pending duplicated requests.\n */\n autoCancellation(enable: boolean): Client {\n this.enableAutoCancellation = !!enable;\n\n return this;\n }\n\n /**\n * Cancels single request by its cancellation key.\n */\n cancelRequest(requestKey: string): Client {\n if (this.cancelControllers[requestKey]) {\n this.cancelControllers[requestKey].abort();\n delete this.cancelControllers[requestKey];\n }\n\n return this;\n }\n\n /**\n * Cancels all pending requests.\n */\n cancelAllRequests(): Client {\n for (let k in this.cancelControllers) {\n this.cancelControllers[k].abort();\n }\n\n this.cancelControllers = {};\n\n return this;\n }\n\n /**\n * Legacy alias of `pb.files.getUrl()`.\n */\n getFileUrl(\n record: Pick<{[key:string]:any}, 'id' | 'collectionId' | 'collectionName'>,\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n return this.files.getUrl(record, filename, queryParams);\n }\n\n /**\n * Builds a full client url by safely concatenating the provided path.\n */\n buildUrl(path: string): string {\n let url = this.baseUrl;\n\n // construct an absolute base url if in a browser environment\n if (\n typeof window !== 'undefined' &&\n !!window.location &&\n !url.startsWith('https://') &&\n !url.startsWith('http://')\n ) {\n url = window.location.origin?.endsWith('/') ?\n window.location.origin.substring(0, window.location.origin.length - 1) :\n (window.location.origin || '');\n\n if (!this.baseUrl.startsWith('/')) {\n url += window.location.pathname || '/';\n url += url.endsWith('/') ? '' : '/';\n }\n\n url += this.baseUrl;\n }\n\n // concatenate the path\n if (path) {\n url += url.endsWith('/') ? '' : '/'; // append trailing slash if missing\n url += path.startsWith('/') ? path.substring(1) : path;\n }\n\n return url;\n }\n\n /**\n * Sends an api http request.\n */\n async send(path: string, options: SendOptions): Promise {\n options = this.initSendOptions(path, options);\n\n // build url + path\n let url = this.buildUrl(path);\n\n // serialize the query parameters\n if (typeof options.query !== 'undefined') {\n const query = this.serializeQueryParams(options.query)\n if (query) {\n url += (url.includes('?') ? '&' : '?') + query;\n }\n delete options.query;\n }\n\n if (this.beforeSend) {\n const result = Object.assign({}, await this.beforeSend(url, options));\n if (typeof result.url !== 'undefined' || typeof result.options !== 'undefined') {\n url = result.url || url;\n options = result.options || options;\n } else if (Object.keys(result).length) {\n // legacy behavior\n options = result as SendOptions;\n console?.warn && console.warn('Deprecated format of beforeSend return: please use `return { url, options }`, instead of `return options`.');\n }\n }\n\n // ensures that the json body is serialized\n if (\n this.getHeader(options.headers, 'Content-Type') == 'application/json' &&\n options.body && typeof options.body !== 'string'\n ) {\n options.body = JSON.stringify(options.body);\n }\n\n const fetchFunc = options.fetch || fetch;\n\n // send the request\n return fetchFunc(url, options)\n .then(async (response) => {\n let data : any = {};\n\n try {\n data = await response.json();\n } catch (_) {\n // all api responses are expected to return json\n // with the exception of the realtime event and 204\n }\n\n if (this.afterSend) {\n data = await this.afterSend(response, data);\n }\n\n if (response.status >= 400) {\n throw new ClientResponseError({\n url: response.url,\n status: response.status,\n data: data,\n });\n }\n\n return data as T;\n }).catch((err) => {\n // wrap to normalize all errors\n throw new ClientResponseError(err);\n });\n }\n\n /**\n * Shallow copy the provided object and takes care to initialize\n * any options required to preserve the backward compatability.\n *\n * @param {SendOptions} options\n * @return {SendOptions}\n */\n private initSendOptions(path: string, options: SendOptions): SendOptions {\n options = Object.assign({ method: 'GET' } as SendOptions, options)\n options.query = options.query || {};\n\n // auto convert the body to FormData, if needed\n options.body = this.convertToFormDataIfNeeded(options.body);\n\n // move unknown send options as query parameters\n for (let key in options) {\n if (knownSendOptionsKeys.includes(key)) {\n continue\n }\n\n options.query[key] = options[key];\n delete (options[key]);\n }\n\n // requestKey normalizations for backward-compatibility\n // ---\n options.query = Object.assign({}, options.params, options.query);\n if (typeof options.requestKey === 'undefined') {\n if (options.$autoCancel === false || options.query.$autoCancel === false) {\n options.requestKey = null;\n } else if (options.$cancelKey || options.query.$cancelKey) {\n options.requestKey = options.$cancelKey || options.query.$cancelKey;\n }\n }\n // remove the deprecated special cancellation params from the other query params\n delete options.$autoCancel;\n delete options.query.$autoCancel;\n delete options.$cancelKey;\n delete options.query.$cancelKey;\n // ---\n\n // add the json header, if not explicitly set\n // (for FormData body the Content-Type header should be skipped since the boundary is autogenerated)\n if (\n this.getHeader(options.headers, 'Content-Type') === null &&\n !this.isFormData(options.body)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Content-Type': 'application/json',\n });\n }\n\n // add Accept-Language header, if not explicitly set\n if (this.getHeader(options.headers, 'Accept-Language') === null) {\n options.headers = Object.assign({}, options.headers, {\n 'Accept-Language': this.lang,\n });\n }\n\n // check if Authorization header can be added\n if (\n // has valid token\n this.authStore.token &&\n // auth header is not explicitly set\n (this.getHeader(options.headers, 'Authorization') === null)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Authorization': this.authStore.token,\n });\n }\n\n // handle auto cancelation for duplicated pending request\n if (this.enableAutoCancellation && options.requestKey !== null) {\n const requestKey = options.requestKey || ((options.method || 'GET') + path);\n\n delete options.requestKey;\n\n // cancel previous pending requests\n this.cancelRequest(requestKey);\n\n const controller = new AbortController();\n this.cancelControllers[requestKey] = controller;\n options.signal = controller.signal;\n }\n\n return options\n }\n\n /**\n * Converts analyzes the provided body and converts it to FormData\n * in case a plain object with File/Blob values is used.\n */\n private convertToFormDataIfNeeded(body: any): any {\n if (\n typeof FormData === 'undefined' ||\n typeof body === \"undefined\" ||\n typeof body !== \"object\" ||\n body === null ||\n this.isFormData(body) ||\n !this.hasBlobField(body)\n ) {\n return body;\n }\n\n const form = new FormData();\n\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let val of values) {\n form.append(key, val);\n }\n }\n\n return form;\n }\n\n /**\n * Checks if the submitted body object has at least one Blob/File field.\n */\n private hasBlobField(body: {[key:string]: any}): boolean {\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let v of values) {\n if (\n (typeof Blob !== 'undefined' && v instanceof Blob) ||\n (typeof File !== 'undefined' && v instanceof File)\n ) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /**\n * Extracts the header with the provided name in case-insensitive manner.\n * Returns `null` if no header matching the name is found.\n */\n private getHeader(headers: {[key:string]:string}|undefined, name: string): string|null {\n headers = headers || {};\n name = name.toLowerCase();\n\n for (let key in headers) {\n if (key.toLowerCase() == name) {\n return headers[key];\n }\n }\n\n return null;\n }\n\n /**\n * Loosely checks if the specified body is a FormData instance.\n */\n private isFormData(body: any): boolean {\n return body && (\n // we are checking the constructor name because FormData\n // is not available natively in some environments and the\n // polyfill(s) may not be globally accessible\n body.constructor.name === 'FormData' ||\n // fallback to global FormData instance check\n // note: this is needed because the constructor.name could be different in case of\n // custom global FormData implementation, eg. React Native on Android/iOS\n (typeof FormData !== 'undefined' && body instanceof FormData)\n )\n }\n\n /**\n * Serializes the provided query parameters into a query string.\n */\n private serializeQueryParams(params: {[key: string]: any}): string {\n const result: Array = [];\n for (const key in params) {\n if (params[key] === null) {\n // skip null query params\n continue;\n }\n\n const value = params[key];\n const encodedKey = encodeURIComponent(key);\n\n if (Array.isArray(value)) {\n // repeat array params\n for (const v of value) {\n result.push(encodedKey + '=' + encodeURIComponent(v));\n }\n } else if (value instanceof Date) {\n result.push(encodedKey + '=' + encodeURIComponent(value.toISOString()));\n } else if (typeof value !== null && typeof value === 'object') {\n result.push(encodedKey + '=' + encodeURIComponent(JSON.stringify(value)));\n } else {\n result.push(encodedKey + '=' + encodeURIComponent(value));\n }\n }\n\n return result.join('&');\n }\n}\n","import { BaseAuthStore, AuthModel } from '@/stores/BaseAuthStore';\n\nexport type AsyncSaveFunc = (serializedPayload: string) => Promise;\n\nexport type AsyncClearFunc = () => Promise;\n\ntype queueFunc = () => Promise;\n\n/**\n * AsyncAuthStore is a helper auth store implementation\n * that could be used with any external async persistent layer\n * (key-value db, local file, etc.).\n *\n * Here is an example with the React Native AsyncStorage package:\n *\n * ```\n * import AsyncStorage from \"@react-native-async-storage/async-storage\";\n * import PocketBase, { AsyncAuthStore } from \"pocketbase\";\n *\n * const store = new AsyncAuthStore({\n * save: async (serialized) => AsyncStorage.setItem(\"pb_auth\", serialized),\n * initial: await AsyncStorage.getItem(\"pb_auth\"),\n * });\n *\n * const pb = new PocketBase(\"https://example.com\", store)\n * ```\n */\nexport class AsyncAuthStore extends BaseAuthStore {\n private saveFunc: AsyncSaveFunc;\n private clearFunc?: AsyncClearFunc;\n private queue: Array = [];\n\n constructor(config: {\n // The async function that is called every time\n // when the auth store state needs to be persisted.\n save: AsyncSaveFunc,\n\n /// An *optional* async function that is called every time\n /// when the auth store needs to be cleared.\n ///\n /// If not explicitly set, `saveFunc` with empty data will be used.\n clear?: AsyncClearFunc,\n\n // initial data to load into the store\n initial?: string,\n }) {\n super();\n\n this.saveFunc = config.save;\n this.clearFunc = config.clear;\n\n this._loadInitial(config.initial);\n }\n\n /**\n * @inheritdoc\n */\n save(token: string, model?: AuthModel): void {\n super.save(token, model);\n\n let value = '';\n try {\n value = JSON.stringify({token, model})\n } catch (err) {\n console.warn('AsyncAuthStore: failed to stringify the new state');\n }\n\n this._enqueue(() => this.saveFunc(value));\n }\n\n /**\n * @inheritdoc\n */\n clear(): void {\n super.clear();\n\n if (this.clearFunc) {\n this._enqueue(() => this.clearFunc!());\n } else {\n this._enqueue(() => this.saveFunc(\"\"));\n }\n }\n\n\n /**\n * Initializes the auth store state.\n */\n private _loadInitial(payload?: string) {\n if (!payload) {\n return; // nothing to load\n }\n\n try {\n const parsed = JSON.parse(payload) || {};\n\n this.save(parsed.token || \"\", parsed.model || null);\n } catch (_) {}\n }\n\n /**\n * Appends an async function to the queue.\n */\n private _enqueue(asyncCallback: () => Promise) {\n this.queue.push(asyncCallback);\n\n if (this.queue.length == 1) {\n this._dequeue();\n }\n }\n\n /**\n * Starts the queue processing.\n */\n private _dequeue() {\n if (!this.queue.length) {\n return;\n }\n\n this.queue[0]().finally(() => {\n this.queue.shift();\n\n if (!this.queue.length) {\n return;\n }\n\n this._dequeue();\n });\n }\n}\n"],"names":["ClientResponseError","Error","constructor","errData","super","this","url","status","response","isAbort","originalError","Object","setPrototypeOf","prototype","data","DOMException","name","message","_a","_d","_c","_b","cause","includes","toJSON","assign","fieldContentRegExp","cookieParse","str","options","result","decode","defaultDecode","index","length","eqIdx","indexOf","endIdx","lastIndexOf","key","slice","trim","undefined","val","charCodeAt","_","cookieSerialize","opt","encode","defaultEncode","test","TypeError","value","maxAge","isNaN","isFinite","Math","floor","domain","path","expires","isDate","toString","call","Date","valueOf","toUTCString","httpOnly","secure","priority","toLowerCase","sameSite","decodeURIComponent","encodeURIComponent","atobPolyfill","getTokenPayload","token","encodedPayload","split","map","c","join","JSON","parse","e","isTokenExpired","expirationThreshold","payload","keys","exp","now","atob","input","String","replace","bs","buffer","bc","idx","output","charAt","fromCharCode","defaultCookieKey","BaseAuthStore","baseToken","baseModel","_onChangeCallbacks","model","isValid","isAdmin","type","isAuthRecord","save","triggerChange","clear","loadFromCookie","cookie","rawData","Array","isArray","exportToCookie","defaultOptions","stringify","resultLength","Blob","size","id","email","extraProps","prop","onChange","callback","fireImmediately","push","i","splice","LocalAuthStore","storageKey","storageFallback","_bindStorageEvent","_storageGet","_storageSet","_storageRemove","window","localStorage","rawValue","getItem","normalizedVal","setItem","removeItem","addEventListener","BaseService","client","SettingsService","getAll","method","send","update","bodyParams","body","testS3","filesystem","then","testEmail","toEmail","emailTemplate","template","generateAppleClientSecret","clientId","teamId","keyId","privateKey","duration","CrudService","getFullList","batchOrqueryParams","_getFullList","batch","getList","page","perPage","query","baseCrudPath","responseData","items","item","getFirstListItem","filter","requestKey","skipTotal","code","getOne","create","batchSize","request","__awaiter","list","concat","normalizeLegacyOptionsArgs","legacyWarn","baseOptions","bodyOrOptions","hasQuery","console","warn","AdminService","authStore","collectionId","delete","success","authResponse","admin","authWithPassword","password","identity","bind","authRefresh","requestPasswordReset","confirmPasswordReset","resetToken","passwordConfirm","RealtimeService","eventSource","subscriptions","lastSentTopics","maxConnectTimeout","reconnectAttempts","maxReconnectAttempts","Infinity","predefinedReconnectIntervals","pendingConnects","isConnected","subscribe","topic","listener","msgEvent","submitSubscriptions","connect","unsubscribeByTopicAndListener","unsubscribe","hasSubscriptionListeners","removeEventListener","disconnect","unsubscribeByPrefix","topicPrefix","hasAtleastOneTopic","startsWith","exist","topicToCheck","addAllSubscriptionListeners","getNonEmptySubscriptionTopics","getSubscriptionsCancelKey","catch","err","removeAllSubscriptionListeners","Promise","resolve","reject","initConnect","clearTimeout","connectTimeoutId","setTimeout","connectErrorHandler","EventSource","buildUrl","onerror","lastEventId","retries","hasUnsentSubscriptions","p","reconnectTimeoutId","latestTopics","t","timeout","fromReconnect","cancelRequest","close","RecordService","collectionIdOrName","baseCollectionPath","subscribeOne","recordId","realtime","topicOrCallback","batchOrOptions","params","collectionName","record","listAuthMethods","usernamePassword","emailPassword","authProviders","usernameOrEmail","authWithOAuth2Code","provider","codeVerifier","redirectUrl","createData","authWithOAuth2","args","config","find","eagerDefaultPopup","cleanup","urlCallback","openBrowserPopup","oldState","state","scopes","authData","replacements","_replaceQueryParams","authUrl","location","href","passwordResetToken","requestVerification","confirmVerification","verificationToken","requestEmailChange","newEmail","confirmEmailChange","emailChangeToken","listExternalAuths","unlinkExternalAuth","urlPath","substring","parsedParams","rawParams","param","pair","hasOwnProperty","open","width","height","windowWidth","innerWidth","windowHeight","innerHeight","left","top","CollectionService","import","collections","deleteMissing","LogService","getRequestsList","getRequest","getRequestsStats","HealthService","check","FileService","getUrl","filename","queryParams","parts","download","URLSearchParams","getToken","BackupService","basename","restore","getDownloadUrl","knownSendOptionsKeys","Client","baseUrl","lang","cancelControllers","recordServices","enableAutoCancellation","admins","files","logs","settings","health","backups","collection","idOrName","autoCancellation","enable","abort","cancelAllRequests","k","getFileUrl","origin","endsWith","pathname","initSendOptions","serializeQueryParams","beforeSend","getHeader","headers","fetch","json","afterSend","convertToFormDataIfNeeded","$autoCancel","$cancelKey","isFormData","Authorization","controller","AbortController","signal","FormData","hasBlobField","form","values","append","v","File","encodedKey","toISOString","AsyncAuthStore","queue","saveFunc","clearFunc","_loadInitial","initial","_enqueue","parsed","asyncCallback","_dequeue","finally","shift"],"mappings":"4ZAIM,MAAOA,4BAA4BC,MAOrC,WAAAC,CAAYC,eACRC,MAAM,uBAPVC,KAAGC,IAA8B,GACjCD,KAAME,OAA2B,EACjCF,KAAQG,SAAyB,GACjCH,KAAOI,SAA0B,EACjCJ,KAAaK,cAAoB,KAO7BC,OAAOC,eAAeP,KAAML,oBAAoBa,WAEhC,OAAZV,GAAuC,iBAAZA,IAC3BE,KAAKC,IAAuC,iBAAhBH,EAAQG,IAAmBH,EAAQG,IAAM,GACrED,KAAKE,OAA0C,iBAAnBJ,EAAQI,OAAsBJ,EAAQI,OAAS,EAC3EF,KAAKI,UAAkBN,EAAQM,QAC/BJ,KAAKK,cAAgBP,EAAQO,cAEJ,OAArBP,EAAQK,UAAiD,iBAArBL,EAAQK,SAC5CH,KAAKG,SAAYL,EAAQK,SACD,OAAjBL,EAAQW,MAAyC,iBAAjBX,EAAQW,KAC/CT,KAAKG,SAAYL,EAAQW,KAEzBT,KAAKG,SAAY,IAIpBH,KAAKK,eAAmBP,aAAmBH,sBAC5CK,KAAKK,cAAgBP,GAGG,oBAAjBY,cAAgCZ,aAAmBY,eAC1DV,KAAKI,SAAU,GAGnBJ,KAAKW,KAAO,uBAAyBX,KAAKE,OAC1CF,KAAKY,QAAyB,QAAfC,EAAAb,KAAKG,gBAAU,IAAAU,OAAA,EAAAA,EAAAD,QACzBZ,KAAKY,UACFZ,KAAKI,QACLJ,KAAKY,QAAU,oHAC4B,QAApCE,EAAyB,QAAzBC,EAAkB,QAAlBC,EAAAhB,KAAKK,qBAAa,IAAAW,OAAA,EAAAA,EAAEC,aAAK,IAAAF,OAAA,EAAAA,EAAEH,eAAS,IAAAE,OAAA,EAAAA,EAAAI,SAAS,qBACpDlB,KAAKY,QAAU,qJAEfZ,KAAKY,QAAU,sDAG1B,CAKD,QAAIH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yZ,SAAWlH,EAAO5L,KACvB3G,KAAK0Z,UAAYnH,EAAO1L,MAExB7G,KAAK2Z,aAAapH,EAAOqH,QAC5B,CAKD,IAAAjT,CAAKpC,EAAe+B,GAChBvG,MAAM4G,KAAKpC,EAAO+B,GAElB,IAAIvD,EAAQ,GACZ,IACIA,EAAQ8B,KAAKwC,UAAU,CAAC9C,QAAO+B,SAClC,CAAC,MAAOkJ,GACLlD,QAAQC,KAAK,oDAChB,CAEDvM,KAAK6Z,UAAS,IAAM7Z,KAAKyZ,SAAS1W,IACrC,CAKD,KAAA8D,GACI9G,MAAM8G,QAEF7G,KAAK0Z,UACL1Z,KAAK6Z,UAAS,IAAM7Z,KAAK0Z,cAEzB1Z,KAAK6Z,UAAS,IAAM7Z,KAAKyZ,SAAS,KAEzC,CAMO,YAAAE,CAAazU,GACjB,GAAKA,EAIL,IACI,MAAM4U,EAASjV,KAAKC,MAAMI,IAAY,CAAA,EAEtClF,KAAK2G,KAAKmT,EAAOvV,OAAS,GAAIuV,EAAOxT,OAAS,KACjD,CAAC,MAAO9D,GAAK,CACjB,CAKO,QAAAqX,CAASE,GACb/Z,KAAKwZ,MAAMxR,KAAK+R,GAES,GAArB/Z,KAAKwZ,MAAM3X,QACX7B,KAAKga,UAEZ,CAKO,QAAAA,GACCha,KAAKwZ,MAAM3X,QAIhB7B,KAAKwZ,MAAM,KAAKS,SAAQ,KACpBja,KAAKwZ,MAAMU,QAENla,KAAKwZ,MAAM3X,QAIhB7B,KAAKga,UAAU,GAEtB"} \ No newline at end of file +{"version":3,"file":"pocketbase.es.mjs","sources":["../src/ClientResponseError.ts","../src/stores/utils/cookie.ts","../src/stores/utils/jwt.ts","../src/stores/BaseAuthStore.ts","../src/stores/LocalAuthStore.ts","../src/services/utils/BaseService.ts","../src/services/SettingsService.ts","../src/services/utils/CrudService.ts","../src/services/utils/legacy.ts","../src/services/AdminService.ts","../src/services/RealtimeService.ts","../src/services/RecordService.ts","../src/services/CollectionService.ts","../src/services/LogService.ts","../src/services/HealthService.ts","../src/services/FileService.ts","../src/services/BackupService.ts","../src/Client.ts","../src/stores/AsyncAuthStore.ts"],"sourcesContent":["/**\n * ClientResponseError is a custom Error class that is intended to wrap\n * and normalize any error thrown by `Client.send()`.\n */\nexport class ClientResponseError extends Error {\n url: string = '';\n status: number = 0;\n response: {[key: string]: any} = {};\n isAbort: boolean = false;\n originalError: any = null;\n\n constructor(errData?: any) {\n super(\"ClientResponseError\");\n\n // Set the prototype explicitly.\n // https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\n Object.setPrototypeOf(this, ClientResponseError.prototype);\n\n if (errData !== null && typeof errData === 'object') {\n this.url = typeof errData.url === 'string' ? errData.url : '';\n this.status = typeof errData.status === 'number' ? errData.status : 0;\n this.isAbort = !!errData.isAbort;\n this.originalError = errData.originalError;\n\n if (errData.response !== null && typeof errData.response === 'object') {\n this.response = errData.response;\n } else if (errData.data !== null && typeof errData.data === 'object') {\n this.response = errData.data;\n } else {\n this.response = {};\n }\n }\n\n if (!this.originalError && !(errData instanceof ClientResponseError)) {\n this.originalError = errData;\n }\n\n if (typeof DOMException !== 'undefined' && errData instanceof DOMException) {\n this.isAbort = true;\n }\n\n this.name = \"ClientResponseError \" + this.status;\n this.message = this.response?.message;\n if (!this.message) {\n if (this.isAbort) {\n this.message = 'The request was autocancelled. You can find more info in https://github.com/pocketbase/js-sdk#auto-cancellation.';\n } else if (this.originalError?.cause?.message?.includes(\"ECONNREFUSED ::1\")) {\n this.message = 'Failed to connect to the PocketBase server. Try changing the SDK URL from localhost to 127.0.0.1 (https://github.com/pocketbase/js-sdk/issues/21).';\n } else {\n this.message = 'Something went wrong while processing your request.';\n }\n }\n }\n\n /**\n * Alias for `this.response` to preserve the backward compatibility.\n */\n get data() {\n return this.response;\n }\n\n /**\n * Make a POJO's copy of the current error class instance.\n * @see https://github.com/vuex-orm/vuex-orm/issues/255\n */\n toJSON() {\n return { ...this };\n }\n}\n","/**\n * -------------------------------------------------------------------\n * Simple cookie parse and serialize utilities mostly based on the\n * node module https://github.com/jshttp/cookie.\n * -------------------------------------------------------------------\n */\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\nconst fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;\n\nexport interface ParseOptions{\n decode?: (val: string) => string,\n}\n\n/**\n* Parses the given cookie header string into an object\n* The object has the various cookies as keys(names) => values\n*/\nexport function cookieParse(str: string, options?: ParseOptions): { [key: string]: any } {\n const result: { [key: string]: any } = {};\n\n if (typeof str !== 'string') {\n return result;\n }\n\n const opt = Object.assign({}, options || {});\n const decode = opt.decode || defaultDecode;\n\n let index = 0;\n while (index < str.length) {\n const eqIdx = str.indexOf('=', index);\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break;\n }\n\n let endIdx = str.indexOf(';', index);\n\n if (endIdx === -1) {\n endIdx = str.length;\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(';', eqIdx - 1) + 1;\n continue;\n }\n\n const key = str.slice(index, eqIdx).trim();\n\n // only assign once\n if (undefined === result[key]) {\n let val = str.slice(eqIdx + 1, endIdx).trim();\n\n // quoted values\n if (val.charCodeAt(0) === 0x22) {\n val = val.slice(1, -1);\n }\n\n try {\n result[key] = decode(val);\n } catch (_) {\n result[key] = val; // no decoding\n }\n }\n\n index = endIdx + 1;\n }\n\n return result;\n};\n\nexport interface SerializeOptions {\n encode?: (val: string | number | boolean) => string,\n maxAge?: number,\n domain?: string,\n path?: string,\n expires?: Date,\n httpOnly?: boolean,\n secure?: boolean,\n priority?: string,\n sameSite?: boolean|string,\n}\n\n/**\n * Serialize data into a cookie header.\n *\n * Serialize the a name value pair into a cookie string suitable for\n * http headers. An optional options object specified cookie parameters.\n *\n * ```js\n * cookieSerialize('foo', 'bar', { httpOnly: true }) // \"foo=bar; httpOnly\"\n * ```\n */\nexport function cookieSerialize(name: string, val: string, options?: SerializeOptions): string {\n const opt = Object.assign({}, options || {});\n const encode = opt.encode || defaultEncode;\n\n if (!fieldContentRegExp.test(name)) {\n throw new TypeError('argument name is invalid');\n }\n\n const value = encode(val);\n\n if (value && !fieldContentRegExp.test(value)) {\n throw new TypeError('argument val is invalid');\n }\n\n let result = name + '=' + value;\n\n if (opt.maxAge != null) {\n const maxAge = opt.maxAge - 0;\n\n if (isNaN(maxAge) || !isFinite(maxAge)) {\n throw new TypeError('option maxAge is invalid');\n }\n\n result += '; Max-Age=' + Math.floor(maxAge);\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new TypeError('option domain is invalid');\n }\n\n result += '; Domain=' + opt.domain;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new TypeError('option path is invalid');\n }\n\n result += '; Path=' + opt.path;\n }\n\n if (opt.expires) {\n if (!isDate(opt.expires) || isNaN(opt.expires.valueOf())) {\n throw new TypeError('option expires is invalid');\n }\n\n result += '; Expires=' + opt.expires.toUTCString();\n }\n\n if (opt.httpOnly) {\n result += '; HttpOnly';\n }\n\n if (opt.secure) {\n result += '; Secure';\n }\n\n if (opt.priority) {\n const priority = typeof opt.priority === 'string' ? opt.priority.toLowerCase() : opt.priority;\n\n switch (priority) {\n case 'low':\n result += '; Priority=Low';\n break;\n case 'medium':\n result += '; Priority=Medium';\n break;\n case 'high':\n result += '; Priority=High';\n break;\n default:\n throw new TypeError('option priority is invalid');\n }\n }\n\n if (opt.sameSite) {\n const sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;\n\n switch (sameSite) {\n case true:\n result += '; SameSite=Strict';\n break;\n case 'lax':\n result += '; SameSite=Lax';\n break;\n case 'strict':\n result += '; SameSite=Strict';\n break;\n case 'none':\n result += '; SameSite=None';\n break;\n default:\n throw new TypeError('option sameSite is invalid');\n }\n }\n\n return result;\n};\n\n/**\n * Default URL-decode string value function.\n * Optimized to skip native call when no `%`.\n */\nfunction defaultDecode(val: string): string {\n return val.indexOf('%') !== -1\n ? decodeURIComponent(val)\n : val;\n}\n\n/**\n * Default URL-encode value function.\n */\nfunction defaultEncode(val: string | number | boolean): string {\n return encodeURIComponent(val);\n}\n\n/**\n * Determines if value is a Date.\n */\nfunction isDate(val: any): boolean {\n return (\n Object.prototype.toString.call(val) === '[object Date]' ||\n val instanceof Date\n );\n}\n","let atobPolyfill: Function;\nif (typeof atob === 'function') {\n atobPolyfill = atob\n} else {\n /**\n * The code was extracted from:\n * https://github.com/davidchambers/Base64.js\n */\n atobPolyfill = (input: any) => {\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\n let str = String(input).replace(/=+$/, \"\");\n if (str.length % 4 == 1) {\n throw new Error(\"'atob' failed: The string to be decoded is not correctly encoded.\");\n }\n\n for (\n // initialize result and counters\n var bc = 0, bs, buffer, idx = 0, output = \"\";\n // get next character\n (buffer = str.charAt(idx++));\n // character found in table? initialize bit storage and add its ascii value;\n ~buffer &&\n ((bs = bc % 4 ? (bs as any) * 64 + buffer : buffer),\n // and if not first of each 4 characters,\n // convert the first 8 bits to one ascii character\n bc++ % 4) ?\n (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)))) :\n 0\n ) {\n // try to find character in table (0-63, not found => -1)\n buffer = chars.indexOf(buffer);\n }\n\n return output;\n };\n}\n\n/**\n * Returns JWT token's payload data.\n */\nexport function getTokenPayload(token: string): { [key: string]: any } {\n if (token) {\n try {\n const encodedPayload = decodeURIComponent(atobPolyfill(token.split('.')[1]).split('').map(function (c: string) {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n }).join(''));\n\n return JSON.parse(encodedPayload) || {};\n } catch (e) {\n }\n }\n\n return {};\n}\n\n/**\n * Checks whether a JWT token is expired or not.\n * Tokens without `exp` payload key are considered valid.\n * Tokens with empty payload (eg. invalid token strings) are considered expired.\n *\n * @param token The token to check.\n * @param [expirationThreshold] Time in seconds that will be subtracted from the token `exp` property.\n */\nexport function isTokenExpired(token: string, expirationThreshold = 0): boolean {\n let payload = getTokenPayload(token);\n\n if (\n Object.keys(payload).length > 0 &&\n (!payload.exp || (payload.exp - expirationThreshold) > (Date.now() / 1000))\n ) {\n return false;\n }\n\n return true;\n}\n","import { cookieParse, cookieSerialize, SerializeOptions } from '@/stores/utils/cookie';\nimport { isTokenExpired, getTokenPayload } from '@/stores/utils/jwt';\nimport { RecordModel, AdminModel } from '@/services/utils/dtos';\n\nexport type AuthModel = RecordModel|AdminModel|null;\n\nexport type OnStoreChangeFunc = (token: string, model: AuthModel) => void;\n\nconst defaultCookieKey = 'pb_auth';\n\n/**\n * Base AuthStore class that is intended to be extended by all other\n * PocketBase AuthStore implementations.\n */\nexport abstract class BaseAuthStore {\n protected baseToken: string = '';\n protected baseModel: AuthModel = null;\n\n private _onChangeCallbacks: Array = [];\n\n /**\n * Retrieves the stored token (if any).\n */\n get token(): string {\n return this.baseToken;\n }\n\n /**\n * Retrieves the stored model data (if any).\n */\n get model(): AuthModel {\n return this.baseModel;\n }\n\n /**\n * Loosely checks if the store has valid token (aka. existing and unexpired exp claim).\n */\n get isValid(): boolean {\n return !isTokenExpired(this.token);\n }\n\n /**\n * Checks whether the current store state is for admin authentication.\n */\n get isAdmin(): boolean {\n return getTokenPayload(this.token).type === \"admin\";\n }\n\n /**\n * Checks whether the current store state is for auth record authentication.\n */\n get isAuthRecord(): boolean {\n return getTokenPayload(this.token).type === \"authRecord\";\n }\n\n /**\n * Saves the provided new token and model data in the auth store.\n */\n save(token: string, model?: AuthModel): void {\n this.baseToken = token || '';\n this.baseModel = model || null;\n\n this.triggerChange();\n }\n\n /**\n * Removes the stored token and model data form the auth store.\n */\n clear(): void {\n this.baseToken = '';\n this.baseModel = null;\n this.triggerChange();\n }\n\n /**\n * Parses the provided cookie string and updates the store state\n * with the cookie's token and model data.\n *\n * NB! This function doesn't validate the token or its data.\n * Usually this isn't a concern if you are interacting only with the\n * PocketBase API because it has the proper server-side security checks in place,\n * but if you are using the store `isValid` state for permission controls\n * in a node server (eg. SSR), then it is recommended to call `authRefresh()`\n * after loading the cookie to ensure an up-to-date token and model state.\n * For example:\n *\n * ```js\n * pb.authStore.loadFromCookie(\"cookie string...\");\n *\n * try {\n * // get an up-to-date auth store state by veryfing and refreshing the loaded auth model (if any)\n * pb.authStore.isValid && await pb.collection('users').authRefresh();\n * } catch (_) {\n * // clear the auth store on failed refresh\n * pb.authStore.clear();\n * }\n * ```\n */\n loadFromCookie(cookie: string, key = defaultCookieKey): void {\n const rawData = cookieParse(cookie || '')[key] || '';\n\n let data: { [key: string]: any } = {};\n try {\n data = JSON.parse(rawData);\n // normalize\n if (typeof data === null || typeof data !== 'object' || Array.isArray(data)) {\n data = {};\n }\n } catch (_) {}\n\n this.save(data.token || '', data.model || null);\n }\n\n /**\n * Exports the current store state as cookie string.\n *\n * By default the following optional attributes are added:\n * - Secure\n * - HttpOnly\n * - SameSite=Strict\n * - Path=/\n * - Expires={the token expiration date}\n *\n * NB! If the generated cookie exceeds 4096 bytes, this method will\n * strip the model data to the bare minimum to try to fit within the\n * recommended size in https://www.rfc-editor.org/rfc/rfc6265#section-6.1.\n */\n exportToCookie(options?: SerializeOptions, key = defaultCookieKey): string {\n const defaultOptions: SerializeOptions = {\n secure: true,\n sameSite: true,\n httpOnly: true,\n path: \"/\",\n };\n\n // extract the token expiration date\n const payload = getTokenPayload(this.token);\n if (payload?.exp) {\n defaultOptions.expires = new Date(payload.exp * 1000);\n } else {\n defaultOptions.expires = new Date('1970-01-01');\n }\n\n // merge with the user defined options\n options = Object.assign({}, defaultOptions, options);\n\n const rawData = {\n token: this.token,\n model: this.model ? JSON.parse(JSON.stringify(this.model)) : null,\n };\n\n let result = cookieSerialize(key, JSON.stringify(rawData), options);\n\n const resultLength = typeof Blob !== 'undefined' ?\n (new Blob([result])).size : result.length;\n\n // strip down the model data to the bare minimum\n if (rawData.model && resultLength > 4096) {\n rawData.model = {id: rawData?.model?.id, email: rawData?.model?.email};\n const extraProps = [\"collectionId\", \"username\", \"verified\"];\n for (const prop in this.model) {\n if (extraProps.includes(prop)) {\n rawData.model[prop] = this.model[prop];\n }\n }\n result = cookieSerialize(key, JSON.stringify(rawData), options);\n }\n\n return result;\n }\n\n /**\n * Register a callback function that will be called on store change.\n *\n * You can set the `fireImmediately` argument to true in order to invoke\n * the provided callback right after registration.\n *\n * Returns a removal function that you could call to \"unsubscribe\" from the changes.\n */\n onChange(callback: OnStoreChangeFunc, fireImmediately = false): () => void {\n this._onChangeCallbacks.push(callback);\n\n if (fireImmediately) {\n callback(this.token, this.model);\n }\n\n return () => {\n for (let i = this._onChangeCallbacks.length - 1; i >= 0; i--) {\n if (this._onChangeCallbacks[i] == callback) {\n delete this._onChangeCallbacks[i]; // removes the function reference\n this._onChangeCallbacks.splice(i, 1); // reindex the array\n return;\n }\n }\n }\n }\n\n protected triggerChange(): void {\n for (const callback of this._onChangeCallbacks) {\n callback && callback(this.token, this.model);\n }\n }\n}\n","import { BaseAuthStore, AuthModel } from '@/stores/BaseAuthStore';\n\n/**\n * The default token store for browsers with auto fallback\n * to runtime/memory if local storage is undefined (eg. in node env).\n */\nexport class LocalAuthStore extends BaseAuthStore {\n private storageFallback: { [key: string]: any } = {};\n private storageKey: string\n\n constructor(storageKey = \"pocketbase_auth\") {\n super();\n\n this.storageKey = storageKey;\n\n this._bindStorageEvent();\n }\n\n /**\n * @inheritdoc\n */\n get token(): string {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.token || '';\n }\n\n /**\n * @inheritdoc\n */\n get model(): AuthModel {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.model || null;\n }\n\n /**\n * @inheritdoc\n */\n save(token: string, model?: AuthModel) {\n this._storageSet(this.storageKey, {\n 'token': token,\n 'model': model,\n });\n\n super.save(token, model);\n }\n\n /**\n * @inheritdoc\n */\n clear() {\n this._storageRemove(this.storageKey);\n\n super.clear();\n }\n\n // ---------------------------------------------------------------\n // Internal helpers:\n // ---------------------------------------------------------------\n\n /**\n * Retrieves `key` from the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageGet(key: string): any {\n if (typeof window !== 'undefined' && window?.localStorage) {\n const rawValue = window.localStorage.getItem(key) || '';\n try {\n return JSON.parse(rawValue);\n } catch (e) { // not a json\n return rawValue;\n }\n }\n\n // fallback\n return this.storageFallback[key];\n }\n\n /**\n * Stores a new data in the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageSet(key: string, value: any) {\n if (typeof window !== 'undefined' && window?.localStorage) {\n // store in local storage\n let normalizedVal = value;\n if (typeof value !== 'string') {\n normalizedVal = JSON.stringify(value);\n }\n window.localStorage.setItem(key, normalizedVal);\n } else {\n // store in fallback\n this.storageFallback[key] = value;\n }\n }\n\n /**\n * Removes `key` from the browser's local storage and the runtime/memory.\n */\n private _storageRemove(key: string) {\n // delete from local storage\n if (typeof window !== 'undefined' && window?.localStorage) {\n window.localStorage?.removeItem(key);\n }\n\n // delete from fallback\n delete this.storageFallback[key];\n }\n\n /**\n * Updates the current store state on localStorage change.\n */\n private _bindStorageEvent() {\n if (typeof window === 'undefined' || !window?.localStorage || !window.addEventListener) {\n return;\n }\n\n window.addEventListener('storage', (e) => {\n if (e.key != this.storageKey) {\n return;\n }\n\n const data = this._storageGet(this.storageKey) || {};\n\n super.save(data.token || '', data.model || null);\n });\n }\n}\n","import Client from '@/Client';\n\n/**\n * BaseService class that should be inherited from all API services.\n */\nexport abstract class BaseService {\n readonly client: Client\n\n constructor(client: Client) {\n this.client = client;\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\ninterface appleClientSecret {\n secret: string;\n}\n\nexport class SettingsService extends BaseService {\n /**\n * Fetch all available app settings.\n */\n getAll(options?: CommonOptions): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Bulk updates app settings.\n */\n update(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Performs a S3 filesystem connection test.\n *\n * The currently supported `filesystem` are \"storage\" and \"backups\".\n */\n testS3(filesystem: string = \"storage\", options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'filesystem': filesystem,\n },\n }, options);\n\n return this.client.send('/api/settings/test/s3', options)\n .then(() => true);\n }\n\n /**\n * Sends a test email.\n *\n * The possible `emailTemplate` values are:\n * - verification\n * - password-reset\n * - email-change\n */\n testEmail(toEmail: string, emailTemplate: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'email': toEmail,\n 'template': emailTemplate,\n },\n }, options);\n\n return this.client.send('/api/settings/test/email', options)\n .then(() => true);\n }\n\n /**\n * Generates a new Apple OAuth2 client secret.\n */\n generateAppleClientSecret(\n clientId: string,\n teamId: string,\n keyId: string,\n privateKey: string,\n duration: number,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n clientId,\n teamId,\n keyId,\n privateKey,\n duration,\n },\n }, options);\n\n return this.client.send('/api/settings/apple/generate-client-secret', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n FullListOptions\n} from '@/services/utils/options';\n\nexport abstract class CrudService extends BaseService {\n /**\n * Base path for the crud actions (without trailing slash, eg. '/admins').\n */\n abstract get baseCrudPath(): string\n\n /**\n * Response data decoder.\n */\n decode(data: { [key: string]: any }): T {\n return data as T;\n }\n\n /**\n * Returns a promise with all list items batch fetched at once\n * (by default 500 items per request; to change it set the `batch` query param).\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getFullList(options?: FullListOptions): Promise>\n\n /**\n * Legacy version of getFullList with explicitly specified batch size.\n */\n getFullList(batch?: number, options?: ListOptions): Promise>\n\n getFullList(batchOrqueryParams?: number|FullListOptions, options?: ListOptions): Promise> {\n if (typeof batchOrqueryParams == \"number\") {\n return this._getFullList(batchOrqueryParams, options);\n }\n\n options = Object.assign({}, batchOrqueryParams, options);\n\n let batch = 500;\n if (options.batch) {\n batch = options.batch;\n delete options.batch;\n }\n\n return this._getFullList(batch, options);\n }\n\n /**\n * Returns paginated items list.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({\n method: 'GET'\n }, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => {\n responseData.items = responseData.items?.map((item: any) => {\n return this.decode(item);\n }) || [];\n\n return responseData;\n });\n }\n\n /**\n * Returns the first found item by the specified filter.\n *\n * Internally it calls `getList(1, 1, { filter, skipTotal })` and\n * returns the first found item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n *\n * For consistency with `getOne`, this method will throw a 404\n * ClientResponseError if no item was found.\n */\n getFirstListItem(filter: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'requestKey': 'one_by_filter_' + this.baseCrudPath + \"_\" + filter,\n }, options);\n\n options.query = Object.assign({\n 'filter': filter,\n 'skipTotal': 1,\n }, options.query);\n\n return this.getList(1, 1, options)\n .then((result) => {\n if (!result?.items?.length) {\n throw new ClientResponseError({\n status: 404,\n data: {\n code: 404,\n message: \"The requested resource wasn't found.\",\n data: {},\n },\n });\n }\n\n return result.items[0];\n });\n }\n\n /**\n * Returns single item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getOne(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Creates a new item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n create(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Updates an existing item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Deletes an existing item by its id.\n */\n delete(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then(() => true);\n }\n\n /**\n * Returns a promise with all list items batch fetched at once.\n */\n protected _getFullList(batchSize = 500, options?: ListOptions): Promise> {\n options = options || {};\n options.query = Object.assign({\n 'skipTotal': 1,\n }, options.query);\n\n let result: Array = [];\n\n let request = async (page: number): Promise> => {\n return this.getList(page, batchSize || 500, options).then((list) => {\n const castedList = (list as any as ListResult);\n const items = castedList.items;\n\n result = result.concat(items);\n\n if (items.length == list.perPage) {\n return request(page + 1);\n }\n\n return result;\n });\n }\n\n return request(1);\n }\n}\n","import { SendOptions } from '@/services/utils/options';\n\nexport function normalizeLegacyOptionsArgs(legacyWarn: string, baseOptions: SendOptions, bodyOrOptions?: any, query?: any): SendOptions {\n const hasBodyOrOptions = typeof bodyOrOptions !== 'undefined';\n const hasQuery = typeof query !== 'undefined';\n\n if (!hasQuery && !hasBodyOrOptions) {\n return baseOptions;\n }\n\n if (hasQuery) {\n console.warn(legacyWarn);\n baseOptions.body = Object.assign({}, baseOptions.body, bodyOrOptions);\n baseOptions.query = Object.assign({}, baseOptions.query, query);\n\n return baseOptions;\n }\n\n baseOptions = Object.assign(baseOptions, bodyOrOptions);\n return baseOptions;\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { AdminModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface AdminAuthResponse {\n [key: string]: any;\n\n token: string;\n admin: AdminModel;\n}\n\nexport class AdminService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/admins';\n }\n\n // ---------------------------------------------------------------\n // Post update/delete AuthStore sync\n // ---------------------------------------------------------------\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n // update the store state if the updated item id matches with the stored model\n if (\n this.client.authStore.model?.id === item.id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n // clear the store state if the deleted item id matches with the stored model\n if (\n success &&\n this.client.authStore.model?.id === id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful authorize response.\n */\n protected authResponse(responseData: any): AdminAuthResponse {\n const admin = this.decode(responseData?.admin || {});\n\n if (responseData?.token && responseData?.admin) {\n this.client.authStore.save(responseData.token, admin);\n }\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'admin': admin,\n });\n }\n\n /**\n * Authenticate an admin account with its email and password\n * and returns a new admin token and data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authWithPassword(email: string, password: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authWithPassword(email, password, options?).\n */\n authWithPassword(email: string, password: string, body?: any, query?: any): Promise\n\n authWithPassword(\n email: string,\n password: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': email,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(email, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(email, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-with-password', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Refreshes the current admin authenticated instance and\n * returns a new token and admin data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authRefresh(options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-refresh', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Sends admin password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/request-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Confirms admin password reset request.\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(resetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, body?: any, query?: any): Promise\n\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, bodyOrOptions?: any, query?: any): Promise{\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': resetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(resetToken, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(resetToken, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\n\ninterface promiseCallbacks {\n resolve: Function\n reject: Function\n}\n\nexport type UnsubscribeFunc = () => Promise;\n\nexport class RealtimeService extends BaseService {\n clientId: string = \"\";\n\n private eventSource: EventSource | null = null;\n private subscriptions: { [key: string]: Array } = {};\n private lastSentTopics: Array = [];\n private connectTimeoutId: any;\n private maxConnectTimeout: number = 15000;\n private reconnectTimeoutId: any;\n private reconnectAttempts: number = 0;\n private maxReconnectAttempts: number = Infinity;\n private predefinedReconnectIntervals: Array = [\n 200, 300, 500, 1000, 1200, 1500, 2000,\n ];\n private pendingConnects: Array = [];\n\n /**\n * Returns whether the realtime connection has been established.\n */\n get isConnected(): boolean {\n return !!this.eventSource && !!this.clientId && !this.pendingConnects.length;\n }\n\n /**\n * Register the subscription listener.\n *\n * You can subscribe multiple times to the same topic.\n *\n * If the SSE connection is not started yet,\n * this method will also initialize it.\n */\n async subscribe(topic: string, callback: (data: any) => void): Promise {\n if (!topic) {\n throw new Error('topic must be set.')\n }\n\n const listener = function (e: Event) {\n const msgEvent = (e as MessageEvent);\n\n let data;\n try {\n data = JSON.parse(msgEvent?.data);\n } catch {}\n\n callback(data || {});\n };\n\n // store the listener\n if (!this.subscriptions[topic]) {\n this.subscriptions[topic] = [];\n }\n this.subscriptions[topic].push(listener);\n\n if (!this.isConnected) {\n // initialize sse connection\n await this.connect();\n } else if (this.subscriptions[topic].length === 1) {\n // send the updated subscriptions (if it is the first for the topic)\n await this.submitSubscriptions();\n } else {\n // only register the listener\n this.eventSource?.addEventListener(topic, listener);\n }\n\n return async (): Promise => {\n return this.unsubscribeByTopicAndListener(topic, listener);\n };\n }\n\n /**\n * Unsubscribe from all subscription listeners with the specified topic.\n *\n * If `topic` is not provided, then this method will unsubscribe\n * from all active subscriptions.\n *\n * This method is no-op if there are no active subscriptions.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribe(topic?: string): Promise {\n if (!this.hasSubscriptionListeners(topic)) {\n return; // already unsubscribed\n }\n\n if (!topic) {\n // remove all subscriptions\n this.subscriptions = {};\n } else {\n // remove all topic listeners\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n /**\n * Unsubscribe from all subscription listeners starting with the specified topic prefix.\n *\n * This method is no-op if there are no active subscriptions with the specified topic prefix.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByPrefix(topicPrefix: string): Promise {\n let hasAtleastOneTopic = false;\n for (let topic in this.subscriptions) {\n if (!topic.startsWith(topicPrefix)) {\n continue;\n }\n\n hasAtleastOneTopic = true;\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!hasAtleastOneTopic) {\n return; // nothing to unsubscribe from\n }\n\n if (this.hasSubscriptionListeners()) {\n // submit the deleted subscriptions\n await this.submitSubscriptions();\n } else {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n }\n }\n\n /**\n * Unsubscribe from all subscriptions matching the specified topic and listener function.\n *\n * This method is no-op if there are no active subscription with\n * the specified topic and listener.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByTopicAndListener(topic: string, listener: EventListener): Promise {\n if (!Array.isArray(this.subscriptions[topic]) || !this.subscriptions[topic].length) {\n return; // already unsubscribed\n }\n\n let exist = false;\n for (let i = this.subscriptions[topic].length - 1; i >= 0; i--) {\n if (this.subscriptions[topic][i] !== listener) {\n continue;\n }\n\n exist = true; // has at least one matching listener\n delete this.subscriptions[topic][i]; // removes the function reference\n this.subscriptions[topic].splice(i, 1); // reindex the array\n this.eventSource?.removeEventListener(topic, listener);\n }\n if (!exist) {\n return;\n }\n\n // remove the topic from the subscriptions list if there are no other listeners\n if (!this.subscriptions[topic].length) {\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n private hasSubscriptionListeners(topicToCheck?: string): boolean {\n this.subscriptions = this.subscriptions || {};\n\n // check the specified topic\n if (topicToCheck) {\n return !!this.subscriptions[topicToCheck]?.length;\n }\n\n // check for at least one non-empty topic\n for (let topic in this.subscriptions) {\n if (!!this.subscriptions[topic]?.length) {\n return true\n }\n }\n\n return false;\n }\n\n private async submitSubscriptions(): Promise {\n if (!this.clientId) {\n return; // no client/subscriber\n }\n\n // optimistic update\n this.addAllSubscriptionListeners();\n\n this.lastSentTopics = this.getNonEmptySubscriptionTopics();\n\n return this.client.send('/api/realtime', {\n 'method': 'POST',\n 'body': {\n 'clientId': this.clientId,\n 'subscriptions': this.lastSentTopics,\n },\n 'query': {\n 'requestKey': this.getSubscriptionsCancelKey(),\n },\n }).catch((err) => {\n if (err?.isAbort) {\n return; // silently ignore aborted pending requests\n }\n throw err;\n });\n }\n\n private getSubscriptionsCancelKey(): string {\n return \"realtime_\" + this.clientId;\n }\n\n private getNonEmptySubscriptionTopics(): Array {\n const result : Array = [];\n\n for (let topic in this.subscriptions) {\n if (this.subscriptions[topic].length) {\n result.push(topic);\n }\n }\n\n return result;\n }\n\n private addAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n this.removeAllSubscriptionListeners();\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.addEventListener(topic, listener);\n }\n }\n }\n\n private removeAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.removeEventListener(topic, listener);\n }\n }\n }\n\n private async connect(): Promise {\n if (this.reconnectAttempts > 0) {\n // immediately resolve the promise to avoid indefinitely\n // blocking the client during reconnection\n return;\n }\n\n return new Promise((resolve, reject) => {\n this.pendingConnects.push({ resolve, reject });\n\n if (this.pendingConnects.length > 1) {\n // all promises will be resolved once the connection is established\n return;\n }\n\n this.initConnect();\n })\n }\n\n private initConnect() {\n this.disconnect(true);\n\n // wait up to 15s for connect\n clearTimeout(this.connectTimeoutId);\n this.connectTimeoutId = setTimeout(() => {\n this.connectErrorHandler(new Error(\"EventSource connect took too long.\"));\n }, this.maxConnectTimeout);\n\n this.eventSource = new EventSource(this.client.buildUrl('/api/realtime'))\n\n this.eventSource.onerror = (_) => {\n this.connectErrorHandler(new Error(\"Failed to establish realtime connection.\"));\n };\n\n this.eventSource.addEventListener('PB_CONNECT', (e) => {\n const msgEvent = (e as MessageEvent);\n this.clientId = msgEvent?.lastEventId;\n\n this.submitSubscriptions()\n .then(async () => {\n let retries = 3;\n while (this.hasUnsentSubscriptions() && retries > 0) {\n retries--;\n // resubscribe to ensure that the latest topics are submitted\n //\n // This is needed because missed topics could happen on reconnect\n // if after the pending sent `submitSubscriptions()` call another `subscribe()`\n // was made before the submit was able to complete.\n await this.submitSubscriptions();\n }\n }).then(() => {\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n\n // reset connect meta\n this.pendingConnects = [];\n this.reconnectAttempts = 0;\n clearTimeout(this.reconnectTimeoutId);\n clearTimeout(this.connectTimeoutId);\n }).catch((err) => {\n this.clientId = \"\";\n this.connectErrorHandler(err);\n });\n });\n }\n\n private hasUnsentSubscriptions(): boolean {\n const latestTopics = this.getNonEmptySubscriptionTopics();\n if (latestTopics.length != this.lastSentTopics.length) {\n return true;\n }\n\n for (const t of latestTopics) {\n if (!this.lastSentTopics.includes(t)) {\n return true;\n }\n }\n\n return false;\n }\n\n private connectErrorHandler(err: any) {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n\n if (\n // wasn't previously connected -> direct reject\n (!this.clientId && !this.reconnectAttempts) ||\n // was previously connected but the max reconnection limit has been reached\n this.reconnectAttempts > this.maxReconnectAttempts\n ) {\n for (let p of this.pendingConnects) {\n p.reject(new ClientResponseError(err));\n }\n this.pendingConnects = [];\n this.disconnect();\n return;\n }\n\n // otherwise -> reconnect in the background\n this.disconnect(true);\n const timeout = this.predefinedReconnectIntervals[this.reconnectAttempts] || this.predefinedReconnectIntervals[this.predefinedReconnectIntervals.length - 1];\n this.reconnectAttempts++;\n this.reconnectTimeoutId = setTimeout(() => {\n this.initConnect();\n }, timeout);\n }\n\n private disconnect(fromReconnect = false): void {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n this.removeAllSubscriptionListeners();\n this.client.cancelRequest(this.getSubscriptionsCancelKey());\n this.eventSource?.close();\n this.eventSource = null;\n this.clientId = \"\";\n\n if (!fromReconnect) {\n this.reconnectAttempts = 0;\n\n // resolve any remaining connect promises\n //\n // this is done to avoid unnecessary throwing errors in case\n // unsubscribe is called before the pending connect promises complete\n // (see https://github.com/pocketbase/pocketbase/discussions/2897#discussioncomment-6423818)\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n this.pendingConnects = [];\n }\n }\n}\n","import Client from '@/Client';\nimport { CrudService } from '@/services/utils/CrudService';\nimport { RealtimeService, UnsubscribeFunc } from '@/services/RealtimeService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult, RecordModel, ExternalAuthModel } from '@/services/utils/dtos';\nimport {\n SendOptions,\n CommonOptions,\n RecordOptions,\n RecordListOptions,\n RecordFullListOptions,\n} from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface RecordAuthResponse {\n // The signed PocketBase auth record.\n record: T;\n\n // The PocketBase record auth token.\n //\n // If you are looking for the OAuth2 access and refresh tokens\n // they are available under the `meta.accessToken` and `meta.refreshToken` props.\n token: string;\n\n // Auth meta data usually filled when OAuth2 is used.\n meta?: {[key: string]: any};\n}\n\nexport interface AuthProviderInfo {\n name: string;\n state: string;\n codeVerifier: string;\n codeChallenge: string;\n codeChallengeMethod: string;\n authUrl: string;\n}\n\nexport interface AuthMethodsList {\n usernamePassword: boolean;\n emailPassword: boolean;\n authProviders: Array;\n}\n\nexport interface RecordSubscription {\n action: string; // eg. create, update, delete\n record: T;\n}\n\nexport type OAuth2UrlCallback = (url: string) => void|Promise;\n\nexport interface OAuth2AuthConfig extends SendOptions {\n // the name of the OAuth2 provider (eg. \"google\")\n provider: string;\n\n // custom scopes to overwrite the default ones\n scopes?: Array;\n\n // optional record create data\n createData?: {[key: string]: any};\n\n // optional callback that is triggered after the OAuth2 sign-in/sign-up url generation\n urlCallback?: OAuth2UrlCallback;\n\n // optional query params to send with the PocketBase auth request (eg. fields, expand, etc.)\n query?: RecordOptions;\n}\n\nexport class RecordService extends CrudService {\n readonly collectionIdOrName: string;\n\n constructor(client: Client, collectionIdOrName: string) {\n super(client);\n\n this.collectionIdOrName = collectionIdOrName;\n }\n\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return this.baseCollectionPath + '/records';\n }\n\n /**\n * Returns the current collection service base path.\n */\n get baseCollectionPath(): string {\n return '/api/collections/' + encodeURIComponent(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Realtime handlers\n // ---------------------------------------------------------------\n\n /**\n * @deprecated Use subscribe(recordId, callback) instead.\n *\n * Subscribe to the realtime changes of a single record in the collection.\n */\n async subscribeOne(recordId: string, callback: (data: RecordSubscription) => void): Promise {\n console.warn(\"PocketBase: subscribeOne(recordId, callback) is deprecated. Please replace it with subscribe(recordId, callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName + \"/\" + recordId, callback);\n }\n\n /**\n * @deprecated This form of subscribe is deprecated. Please use `subscribe(\"*\", callback)`.\n */\n async subscribe(callback: (data: RecordSubscription) => void): Promise\n\n /**\n * Subscribe to realtime changes to the specified topic (\"*\" or record id).\n *\n * If `topic` is the wildcard \"*\", then this method will subscribe to\n * any record changes in the collection.\n *\n * If `topic` is a record id, then this method will subscribe only\n * to changes of the specified record id.\n *\n * It's OK to subscribe multiple times to the same topic.\n * You can use the returned `UnsubscribeFunc` to remove only a single subscription.\n * Or use `unsubscribe(topic)` if you want to remove all subscriptions attached to the topic.\n */\n async subscribe(topic: string, callback: (data: RecordSubscription) => void): Promise\n\n async subscribe(\n topicOrCallback: string|((data: RecordSubscription) => void),\n callback?: (data: RecordSubscription) => void\n ): Promise {\n if (typeof topicOrCallback === 'function') {\n console.warn(\"PocketBase: subscribe(callback) is deprecated. Please replace it with subscribe('*', callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName, topicOrCallback);\n }\n\n if (!callback) {\n throw new Error(\"Missing subscription callback.\");\n }\n\n if (topicOrCallback === \"\") {\n throw new Error(\"Missing topic.\");\n }\n\n let topic = this.collectionIdOrName;\n if (topicOrCallback !== \"*\") {\n topic += ('/' + topicOrCallback);\n }\n\n return this.client.realtime.subscribe(topic, callback)\n }\n\n /**\n * Unsubscribe from all subscriptions of the specified topic\n * (\"*\" or record id).\n *\n * If `topic` is not set, then this method will unsubscribe from\n * all subscriptions associated to the current collection.\n */\n async unsubscribe(topic?: string): Promise {\n // unsubscribe wildcard topic\n if (topic === \"*\") {\n return this.client.realtime.unsubscribe(this.collectionIdOrName);\n }\n\n // unsubscribe recordId topic\n if (topic) {\n return this.client.realtime.unsubscribe(this.collectionIdOrName + \"/\" + topic);\n }\n\n // unsubscribe from everything related to the collection\n return this.client.realtime.unsubscribeByPrefix(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Crud handers\n // ---------------------------------------------------------------\n /**\n * @inheritdoc\n */\n getFullList(options?: RecordFullListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batch?: number, options?: RecordListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batchOrOptions?: number|RecordFullListOptions, options?: RecordListOptions): Promise> {\n if (typeof batchOrOptions == \"number\") {\n return super.getFullList(batchOrOptions, options);\n }\n\n const params = Object.assign({}, batchOrOptions, options);\n\n return super.getFullList(params);\n }\n\n /**\n * @inheritdoc\n */\n getList(page = 1, perPage = 30, options?: RecordListOptions): Promise> {\n return super.getList(page, perPage, options);\n }\n\n /**\n * @inheritdoc\n */\n getFirstListItem(filter: string, options?: RecordListOptions): Promise {\n return super.getFirstListItem(filter, options);\n }\n\n /**\n * @inheritdoc\n */\n getOne(id: string, options?: RecordOptions): Promise {\n return super.getOne(id, options);\n }\n\n /**\n * @inheritdoc\n */\n create(bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.create(bodyParams, options);\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(id: string, bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n if (\n // is record auth\n this.client.authStore.model?.id === item?.id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n if (\n success &&\n // is record auth\n this.client.authStore.model?.id === id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful collection authorization response.\n */\n protected authResponse(responseData: any): RecordAuthResponse {\n const record = this.decode(responseData?.record || {});\n\n this.client.authStore.save(responseData?.token, record);\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'record': record as any as T,\n });\n }\n\n /**\n * Returns all available collection auth methods.\n */\n listAuthMethods(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCollectionPath + '/auth-methods', options)\n .then((responseData: any) => {\n return Object.assign({}, responseData, {\n // normalize common fields\n 'usernamePassword': !!responseData?.usernamePassword,\n 'emailPassword': !!responseData?.emailPassword,\n 'authProviders': Array.isArray(responseData?.authProviders) ? responseData?.authProviders : [],\n });\n });\n }\n\n /**\n * Authenticate a single auth collection record via its username/email and password.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n */\n authWithPassword(usernameOrEmail: string, password: string, options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authWithPassword(usernameOrEmail, password, options?).\n */\n authWithPassword(usernameOrEmail: string, password: string, body?: any, query?: any): Promise>\n\n authWithPassword(usernameOrEmail: string, password: string, bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': usernameOrEmail,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(usernameOrEmail, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(usernameOrEmail, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-password', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Authenticate a single auth collection record with OAuth2 code.\n *\n * If you don't have an OAuth2 code you may also want to check `authWithOAuth2` method.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n options?: RecordOptions,\n ): Promise>\n\n /**\n * @deprecated\n * Consider using authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createdData, options?).\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n body?: any,\n query?: any\n ): Promise>\n\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n bodyOrOptions?: any,\n query?: any\n ): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'provider': provider,\n 'code': code,\n 'codeVerifier': codeVerifier,\n 'redirectUrl': redirectUrl,\n 'createData': createData,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, body?, query?) is deprecated. Consider replacing it with authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-oauth2', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * @deprecated This form of authWithOAuth2 is deprecated.\n *\n * Please use `authWithOAuth2Code()` OR its simplified realtime version\n * as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\n */\n async authWithOAuth2(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key: string]: any},\n bodyParams?: {[key: string]: any},\n queryParams?: RecordOptions,\n ): Promise>\n\n /**\n * Authenticate a single auth collection record with OAuth2\n * **without custom redirects, deeplinks or even page reload**.\n *\n * This method initializes a one-off realtime subscription and will\n * open a popup window with the OAuth2 vendor page to authenticate.\n * Once the external OAuth2 sign-in/sign-up flow is completed, the popup\n * window will be automatically closed and the OAuth2 data sent back\n * to the user through the previously established realtime connection.\n *\n * You can specify an optional `urlCallback` prop to customize\n * the default url `window.open` behavior.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n *\n * Example:\n *\n * ```js\n * const authData = await pb.collection(\"users\").authWithOAuth2({\n * provider: \"google\",\n * })\n * ```\n *\n * _Site-note_: when creating the OAuth2 app in the provider dashboard\n * you have to configure `https://yourdomain.com/api/oauth2-redirect`\n * as redirect URL.\n */\n async authWithOAuth2(options: OAuth2AuthConfig): Promise>\n\n async authWithOAuth2(...args: any): Promise> {\n // fallback to legacy format\n if (args.length > 1 || typeof args?.[0] === 'string') {\n console.warn(\"PocketBase: This form of authWithOAuth2() is deprecated and may get removed in the future. Please replace with authWithOAuth2Code() OR use the authWithOAuth2() realtime form as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\");\n return this.authWithOAuth2Code(\n args?.[0] || '',\n args?.[1] || '',\n args?.[2] || '',\n args?.[3] || '',\n args?.[4] || {},\n args?.[5] || {},\n args?.[6] || {},\n );\n }\n\n const config = args?.[0] || {};\n\n const authMethods = await this.listAuthMethods();\n\n const provider = authMethods.authProviders.find((p) => p.name === config.provider);\n if (!provider) {\n throw new ClientResponseError(new Error(`Missing or invalid provider \"${config.provider}\".`));\n }\n\n const redirectUrl = this.client.buildUrl('/api/oauth2-redirect');\n\n // initialize a one-off realtime service\n const realtime = new RealtimeService(this.client);\n\n // open a new popup window in case config.urlCallback is not set\n //\n // note: it is opened before the async call due to Safari restrictions\n // (see https://github.com/pocketbase/pocketbase/discussions/2429#discussioncomment-5943061)\n let eagerDefaultPopup: Window|null = null;\n if (!config.urlCallback) {\n eagerDefaultPopup = openBrowserPopup(undefined);\n }\n\n function cleanup() {\n eagerDefaultPopup?.close();\n realtime.unsubscribe();\n }\n\n return new Promise(async (resolve, reject) => {\n try {\n await realtime.subscribe('@oauth2', async (e) => {\n const oldState = realtime.clientId;\n\n try {\n if (!e.state || oldState !== e.state) {\n throw new Error(\"State parameters don't match.\");\n }\n\n // clear the non SendOptions props\n const options = Object.assign({}, config);\n delete options.provider;\n delete options.scopes;\n delete options.createData;\n delete options.urlCallback;\n\n const authData = await this.authWithOAuth2Code(\n provider.name,\n e.code,\n provider.codeVerifier,\n redirectUrl,\n config.createData,\n options,\n );\n\n resolve(authData);\n } catch (err) {\n reject(new ClientResponseError(err));\n }\n\n cleanup();\n });\n\n const replacements: {[key: string]: any} = {\n \"state\": realtime.clientId,\n }\n if (config.scopes?.length) {\n replacements[\"scope\"] = config.scopes.join(\" \");\n }\n\n const url = this._replaceQueryParams(provider.authUrl + redirectUrl, replacements);\n\n let urlCallback = config.urlCallback || function (url: string) {\n if (eagerDefaultPopup) {\n eagerDefaultPopup.location.href = url;\n } else {\n // it could have been blocked due to its empty initial url,\n // try again...\n eagerDefaultPopup = openBrowserPopup(url);\n }\n }\n\n await urlCallback(url);\n } catch (err) {\n cleanup();\n reject(new ClientResponseError(err));\n }\n });\n }\n\n /**\n * Refreshes the current authenticated record instance and\n * returns a new token and record data.\n *\n * On success this method also automatically updates the client's AuthStore.\n */\n authRefresh(options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise>\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-refresh', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Sends auth record password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-password-reset', options).then(() => true);\n }\n\n /**\n * Confirms auth record password reset request.\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n options?: CommonOptions,\n ): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(passwordResetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n body?: any,\n query?: any,\n ): Promise\n\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': passwordResetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(token, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(token, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Sends auth record verification email request.\n */\n requestVerification(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestVerification(email, options?).\n */\n requestVerification(email: string, body?: any, query?: any): Promise\n\n requestVerification(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestVerification(email, body?, query?) is deprecated. Consider replacing it with requestVerification(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-verification', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record email verification request.\n */\n confirmVerification(verificationToken: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmVerification(verificationToken, options?).\n */\n confirmVerification(verificationToken: string, body?: any, query?: any): Promise\n\n confirmVerification(verificationToken: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': verificationToken,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmVerification(token, body?, query?) is deprecated. Consider replacing it with confirmVerification(token, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-verification', options)\n .then(() => true);\n }\n\n /**\n * Sends an email change request to the authenticated record model.\n */\n requestEmailChange(newEmail: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestEmailChange(newEmail, options?).\n */\n requestEmailChange(newEmail: string, body?: any, query?: any): Promise\n\n requestEmailChange(newEmail: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'newEmail': newEmail,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestEmailChange(newEmail, body?, query?) is deprecated. Consider replacing it with requestEmailChange(newEmail, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-email-change', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record's new email address.\n */\n confirmEmailChange(emailChangeToken: string, password: string, options?: CommonOptions): Promise\n\n\n /**\n * @deprecated\n * Consider using confirmEmailChange(emailChangeToken, password, options?).\n */\n confirmEmailChange(emailChangeToken: string, password: string, body?: any, query?: any): Promise\n\n confirmEmailChange(emailChangeToken: string, password: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': emailChangeToken,\n 'password': password,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmEmailChange(token, password, body?, query?) is deprecated. Consider replacing it with confirmEmailChange(token, password, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-email-change', options)\n .then(() => true);\n }\n\n /**\n * Lists all linked external auth providers for the specified auth record.\n */\n listExternalAuths(recordId: string, options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths', options);\n }\n\n /**\n * Unlink a single external auth provider from the specified auth record.\n */\n unlinkExternalAuth(recordId: string, provider: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths/' + encodeURIComponent(provider), options)\n .then(() => true);\n }\n\n // ---------------------------------------------------------------\n\n // very rudimentary url query params replacement because at the moment\n // URL (and URLSearchParams) doesn't seem to be fully supported in React Native\n //\n // note: for details behind some of the decode/encode parsing check https://unixpapa.com/js/querystring.html\n private _replaceQueryParams(url: string, replacements: {[key: string]: any} = {}): string {\n let urlPath = url\n let query = \"\";\n\n const queryIndex = url.indexOf(\"?\");\n if (queryIndex >= 0) {\n urlPath = url.substring(0, url.indexOf(\"?\"));\n query = url.substring(url.indexOf(\"?\") + 1);\n }\n\n const parsedParams: {[key: string]: string} = {};\n\n // parse the query parameters\n const rawParams = query.split(\"&\");\n for (const param of rawParams) {\n if (param == \"\") {\n continue\n }\n\n const pair = param.split(\"=\");\n parsedParams[decodeURIComponent(pair[0].replace(/\\+/g,' '))] = decodeURIComponent((pair[1] || \"\").replace(/\\+/g,' '));\n }\n\n // apply the replacements\n for (let key in replacements) {\n if (!replacements.hasOwnProperty(key)) {\n continue;\n }\n\n if (replacements[key] == null) {\n delete parsedParams[key];\n } else {\n parsedParams[key] = replacements[key];\n }\n }\n\n // construct back the full query string\n query = \"\";\n for (let key in parsedParams) {\n if (!parsedParams.hasOwnProperty(key)) {\n continue;\n }\n\n if (query != \"\") {\n query += \"&\";\n }\n\n query += encodeURIComponent(key.replace(/%20/g,'+')) + \"=\" + encodeURIComponent(parsedParams[key].replace(/%20/g,'+'));\n }\n\n return query != \"\" ? (urlPath + \"?\" + query) : urlPath;\n }\n}\n\nfunction openBrowserPopup(url?: string): Window|null {\n if (typeof window === \"undefined\" || !window?.open) {\n throw new ClientResponseError(new Error(`Not in a browser context - please pass a custom urlCallback function.`));\n }\n\n let width = 1024;\n let height = 768;\n\n let windowWidth = window.innerWidth;\n let windowHeight = window.innerHeight;\n\n // normalize window size\n width = width > windowWidth ? windowWidth : width;\n height = height > windowHeight ? windowHeight : height;\n\n let left = (windowWidth / 2) - (width / 2);\n let top = (windowHeight / 2) - (height / 2);\n\n // note: we don't use the noopener and noreferrer attributes since\n // for some reason browser blocks such windows then url is undefined/blank\n return window.open(\n url,\n 'popup_window',\n 'width='+width+',height='+height+',top='+top+',left='+left+',resizable,menubar=no'\n );\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { CollectionModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport class CollectionService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/collections';\n }\n\n /**\n * Imports the provided collections.\n *\n * If `deleteMissing` is `true`, all local collections and schema fields,\n * that are not present in the imported configuration, WILL BE DELETED\n * (including their related records data)!\n */\n async import(\n collections: Array,\n deleteMissing: boolean = false,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PUT',\n 'body': {\n 'collections': collections,\n 'deleteMissing': deleteMissing,\n }\n }, options);\n\n return this.client.send(this.baseCrudPath + '/import', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ListResult, LogRequestModel } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n LogStatsOptions,\n} from '@/services/utils/options';\n\nexport interface HourlyStats {\n total: number;\n date: string;\n}\n\nexport class LogService extends BaseService {\n /**\n * Returns paginated logged requests list.\n */\n getRequestsList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({'method': 'GET'}, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send('/api/logs/requests', options);\n }\n\n /**\n * Returns a single logged request by its id.\n */\n getRequest(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/' + encodeURIComponent(id), options);\n }\n\n /**\n * Returns request logs statistics.\n */\n getRequestsStats(options?: LogStatsOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/stats', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface HealthCheckResponse {\n code: number;\n message: string;\n data: {[key: string]: any};\n}\n\nexport class HealthService extends BaseService {\n /**\n * Checks the health status of the api.\n */\n check(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/health', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions, FileOptions } from '@/services/utils/options';\n\nexport class FileService extends BaseService {\n /**\n * Builds and returns an absolute record file url for the provided filename.\n */\n getUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n if (\n !filename ||\n !record?.id ||\n !(record?.collectionId || record?.collectionName)\n ) {\n return '';\n }\n\n const parts = [];\n parts.push('api')\n parts.push('files')\n parts.push(encodeURIComponent(record.collectionId || record.collectionName))\n parts.push(encodeURIComponent(record.id))\n parts.push(encodeURIComponent(filename))\n\n let result = this.client.buildUrl(parts.join('/'));\n\n if (Object.keys(queryParams).length) {\n // normalize the download query param for consistency with the Dart sdk\n if (queryParams.download === false) {\n delete(queryParams.download);\n }\n\n const params = new URLSearchParams(queryParams);\n\n result += (result.includes('?') ? '&' : '?') + params;\n }\n\n return result\n }\n\n /**\n * Requests a new private file access token for the current auth model (admin or record).\n */\n getToken(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send('/api/files/token', options)\n .then((data) => data?.token || '');\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface BackupFileInfo {\n key: string;\n size: number;\n modified: string;\n}\n\nexport class BackupService extends BaseService {\n /**\n * Returns list with all available backup files.\n */\n getFullList(options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/backups', options);\n }\n\n /**\n * Initializes a new backup.\n */\n create(basename: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'name': basename,\n },\n }, options);\n\n return this.client.send('/api/backups', options)\n .then(() => true);\n }\n\n /**\n * Deletes a single backup file.\n */\n delete(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}`, options)\n .then(() => true);\n }\n\n /**\n * Initializes an app data restore from an existing backup.\n */\n restore(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}/restore`, options)\n .then(() => true);\n }\n\n /**\n * Builds a download url for a single existing backup using an\n * admin file token and the backup file key.\n *\n * The file token can be generated via `pb.files.getToken()`.\n */\n getDownloadUrl(token: string, key: string): string {\n return this.client.buildUrl(`/api/backups/${encodeURIComponent(key)}?token=${encodeURIComponent(token)}`);\n }\n}\n","import { ClientResponseError } from '@/ClientResponseError';\nimport { BaseAuthStore } from '@/stores/BaseAuthStore';\nimport { LocalAuthStore } from '@/stores/LocalAuthStore';\nimport { SettingsService } from '@/services/SettingsService';\nimport { AdminService } from '@/services/AdminService';\nimport { RecordService } from '@/services/RecordService';\nimport { CollectionService } from '@/services/CollectionService';\nimport { LogService } from '@/services/LogService';\nimport { RealtimeService } from '@/services/RealtimeService';\nimport { HealthService } from '@/services/HealthService';\nimport { FileService } from '@/services/FileService';\nimport { BackupService } from '@/services/BackupService';\nimport { SendOptions, FileOptions } from '@/services/utils/options';\n\n// list of known SendOptions keys (everything else is treated as query param)\nconst knownSendOptionsKeys = [\n 'requestKey',\n '$cancelKey',\n '$autoCancel',\n 'fetch',\n 'headers',\n 'body',\n 'query',\n 'params',\n // ---,\n 'cache',\n 'credentials',\n 'headers',\n 'integrity',\n 'keepalive',\n 'method',\n 'mode',\n 'redirect',\n 'referrer',\n 'referrerPolicy',\n 'signal',\n 'window',\n];\n\nexport interface BeforeSendResult {\n [key: string]: any, // for backward compatibility\n url?: string,\n options?: {[key: string]: any}\n}\n\n/**\n * PocketBase JS Client.\n */\nexport default class Client {\n /**\n * The base PocketBase backend url address (eg. 'http://127.0.0.1.8090').\n */\n baseUrl: string;\n\n /**\n * Hook that get triggered right before sending the fetch request,\n * allowing you to inspect and modify the url and request options.\n *\n * For list of the possible options check https://developer.mozilla.org/en-US/docs/Web/API/fetch#options\n *\n * You can return a non-empty result object `{ url, options }` to replace the url and request options entirely.\n *\n * Example:\n * ```js\n * client.beforeSend = function (url, options) {\n * options.headers = Object.assign({}, options.headers, {\n * 'X-Custom-Header': 'example',\n * });\n *\n * return { url, options }\n * };\n * ```\n */\n beforeSend?: (url: string, options: SendOptions) => BeforeSendResult|Promise;\n\n /**\n * Hook that get triggered after successfully sending the fetch request,\n * allowing you to inspect/modify the response object and its parsed data.\n *\n * Returns the new Promise resolved `data` that will be returned to the client.\n *\n * Example:\n * ```js\n * client.afterSend = function (response, data) {\n * if (response.status != 200) {\n * throw new ClientResponseError({\n * url: response.url,\n * status: response.status,\n * data: data,\n * });\n * }\n *\n * return data;\n * };\n * ```\n */\n afterSend?: (response: Response, data: any) => any;\n\n /**\n * Optional language code (default to `en-US`) that will be sent\n * with the requests to the server as `Accept-Language` header.\n */\n lang: string;\n\n /**\n * A replaceable instance of the local auth store service.\n */\n authStore: BaseAuthStore;\n\n /**\n * An instance of the service that handles the **Settings APIs**.\n */\n readonly settings: SettingsService;\n\n /**\n * An instance of the service that handles the **Admin APIs**.\n */\n readonly admins: AdminService;\n\n /**\n * An instance of the service that handles the **Collection APIs**.\n */\n readonly collections: CollectionService;\n\n /**\n * An instance of the service that handles the **File APIs**.\n */\n readonly files: FileService;\n\n /**\n * An instance of the service that handles the **Log APIs**.\n */\n readonly logs: LogService;\n\n /**\n * An instance of the service that handles the **Realtime APIs**.\n */\n readonly realtime: RealtimeService;\n\n /**\n * An instance of the service that handles the **Health APIs**.\n */\n readonly health: HealthService;\n\n /**\n * An instance of the service that handles the **Backup APIs**.\n */\n readonly backups: BackupService;\n\n private cancelControllers: { [key: string]: AbortController } = {};\n private recordServices: { [key: string]: RecordService } = {};\n private enableAutoCancellation: boolean = true;\n\n constructor(\n baseUrl = '/',\n authStore?: BaseAuthStore | null,\n lang = 'en-US',\n ) {\n this.baseUrl = baseUrl;\n this.lang = lang;\n this.authStore = authStore || new LocalAuthStore();\n\n // services\n this.admins = new AdminService(this);\n this.collections = new CollectionService(this);\n this.files = new FileService(this);\n this.logs = new LogService(this);\n this.settings = new SettingsService(this);\n this.realtime = new RealtimeService(this);\n this.health = new HealthService(this);\n this.backups = new BackupService(this);\n }\n\n /**\n * Returns the RecordService associated to the specified collection.\n *\n * @param {string} idOrName\n * @return {RecordService}\n */\n collection(idOrName: string): RecordService {\n if (!this.recordServices[idOrName]) {\n this.recordServices[idOrName] = new RecordService(this, idOrName);\n }\n\n return this.recordServices[idOrName];\n }\n\n /**\n * Globally enable or disable auto cancellation for pending duplicated requests.\n */\n autoCancellation(enable: boolean): Client {\n this.enableAutoCancellation = !!enable;\n\n return this;\n }\n\n /**\n * Cancels single request by its cancellation key.\n */\n cancelRequest(requestKey: string): Client {\n if (this.cancelControllers[requestKey]) {\n this.cancelControllers[requestKey].abort();\n delete this.cancelControllers[requestKey];\n }\n\n return this;\n }\n\n /**\n * Cancels all pending requests.\n */\n cancelAllRequests(): Client {\n for (let k in this.cancelControllers) {\n this.cancelControllers[k].abort();\n }\n\n this.cancelControllers = {};\n\n return this;\n }\n\n /**\n * Legacy alias of `pb.files.getUrl()`.\n */\n getFileUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n return this.files.getUrl(record, filename, queryParams);\n }\n\n /**\n * Builds a full client url by safely concatenating the provided path.\n */\n buildUrl(path: string): string {\n let url = this.baseUrl;\n\n // construct an absolute base url if in a browser environment\n if (\n typeof window !== 'undefined' &&\n !!window.location &&\n !url.startsWith('https://') &&\n !url.startsWith('http://')\n ) {\n url = window.location.origin?.endsWith('/') ?\n window.location.origin.substring(0, window.location.origin.length - 1) :\n (window.location.origin || '');\n\n if (!this.baseUrl.startsWith('/')) {\n url += window.location.pathname || '/';\n url += url.endsWith('/') ? '' : '/';\n }\n\n url += this.baseUrl;\n }\n\n // concatenate the path\n if (path) {\n url += url.endsWith('/') ? '' : '/'; // append trailing slash if missing\n url += path.startsWith('/') ? path.substring(1) : path;\n }\n\n return url;\n }\n\n /**\n * Sends an api http request.\n */\n async send(path: string, options: SendOptions): Promise {\n options = this.initSendOptions(path, options);\n\n // build url + path\n let url = this.buildUrl(path);\n\n // serialize the query parameters\n if (typeof options.query !== 'undefined') {\n const query = this.serializeQueryParams(options.query)\n if (query) {\n url += (url.includes('?') ? '&' : '?') + query;\n }\n delete options.query;\n }\n\n if (this.beforeSend) {\n const result = Object.assign({}, await this.beforeSend(url, options));\n if (typeof result.url !== 'undefined' || typeof result.options !== 'undefined') {\n url = result.url || url;\n options = result.options || options;\n } else if (Object.keys(result).length) {\n // legacy behavior\n options = result as SendOptions;\n console?.warn && console.warn('Deprecated format of beforeSend return: please use `return { url, options }`, instead of `return options`.');\n }\n }\n\n // ensures that the json body is serialized\n if (\n this.getHeader(options.headers, 'Content-Type') == 'application/json' &&\n options.body && typeof options.body !== 'string'\n ) {\n options.body = JSON.stringify(options.body);\n }\n\n const fetchFunc = options.fetch || fetch;\n\n // send the request\n return fetchFunc(url, options)\n .then(async (response) => {\n let data : any = {};\n\n try {\n data = await response.json();\n } catch (_) {\n // all api responses are expected to return json\n // with the exception of the realtime event and 204\n }\n\n if (this.afterSend) {\n data = await this.afterSend(response, data);\n }\n\n if (response.status >= 400) {\n throw new ClientResponseError({\n url: response.url,\n status: response.status,\n data: data,\n });\n }\n\n return data as T;\n }).catch((err) => {\n // wrap to normalize all errors\n throw new ClientResponseError(err);\n });\n }\n\n /**\n * Shallow copy the provided object and takes care to initialize\n * any options required to preserve the backward compatability.\n *\n * @param {SendOptions} options\n * @return {SendOptions}\n */\n private initSendOptions(path: string, options: SendOptions): SendOptions {\n options = Object.assign({ method: 'GET' } as SendOptions, options)\n options.query = options.query || {};\n\n // auto convert the body to FormData, if needed\n options.body = this.convertToFormDataIfNeeded(options.body);\n\n // move unknown send options as query parameters\n for (let key in options) {\n if (knownSendOptionsKeys.includes(key)) {\n continue\n }\n\n options.query[key] = options[key];\n delete (options[key]);\n }\n\n // requestKey normalizations for backward-compatibility\n // ---\n options.query = Object.assign({}, options.params, options.query);\n if (typeof options.requestKey === 'undefined') {\n if (options.$autoCancel === false || options.query.$autoCancel === false) {\n options.requestKey = null;\n } else if (options.$cancelKey || options.query.$cancelKey) {\n options.requestKey = options.$cancelKey || options.query.$cancelKey;\n }\n }\n // remove the deprecated special cancellation params from the other query params\n delete options.$autoCancel;\n delete options.query.$autoCancel;\n delete options.$cancelKey;\n delete options.query.$cancelKey;\n // ---\n\n // add the json header, if not explicitly set\n // (for FormData body the Content-Type header should be skipped since the boundary is autogenerated)\n if (\n this.getHeader(options.headers, 'Content-Type') === null &&\n !this.isFormData(options.body)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Content-Type': 'application/json',\n });\n }\n\n // add Accept-Language header, if not explicitly set\n if (this.getHeader(options.headers, 'Accept-Language') === null) {\n options.headers = Object.assign({}, options.headers, {\n 'Accept-Language': this.lang,\n });\n }\n\n // check if Authorization header can be added\n if (\n // has valid token\n this.authStore.token &&\n // auth header is not explicitly set\n (this.getHeader(options.headers, 'Authorization') === null)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Authorization': this.authStore.token,\n });\n }\n\n // handle auto cancelation for duplicated pending request\n if (this.enableAutoCancellation && options.requestKey !== null) {\n const requestKey = options.requestKey || ((options.method || 'GET') + path);\n\n delete options.requestKey;\n\n // cancel previous pending requests\n this.cancelRequest(requestKey);\n\n const controller = new AbortController();\n this.cancelControllers[requestKey] = controller;\n options.signal = controller.signal;\n }\n\n return options\n }\n\n /**\n * Converts analyzes the provided body and converts it to FormData\n * in case a plain object with File/Blob values is used.\n */\n private convertToFormDataIfNeeded(body: any): any {\n if (\n typeof FormData === 'undefined' ||\n typeof body === \"undefined\" ||\n typeof body !== \"object\" ||\n body === null ||\n this.isFormData(body) ||\n !this.hasBlobField(body)\n ) {\n return body;\n }\n\n const form = new FormData();\n\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let val of values) {\n form.append(key, val);\n }\n }\n\n return form;\n }\n\n /**\n * Checks if the submitted body object has at least one Blob/File field.\n */\n private hasBlobField(body: {[key:string]: any}): boolean {\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let v of values) {\n if (\n (typeof Blob !== 'undefined' && v instanceof Blob) ||\n (typeof File !== 'undefined' && v instanceof File)\n ) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /**\n * Extracts the header with the provided name in case-insensitive manner.\n * Returns `null` if no header matching the name is found.\n */\n private getHeader(headers: {[key:string]:string}|undefined, name: string): string|null {\n headers = headers || {};\n name = name.toLowerCase();\n\n for (let key in headers) {\n if (key.toLowerCase() == name) {\n return headers[key];\n }\n }\n\n return null;\n }\n\n /**\n * Loosely checks if the specified body is a FormData instance.\n */\n private isFormData(body: any): boolean {\n return body && (\n // we are checking the constructor name because FormData\n // is not available natively in some environments and the\n // polyfill(s) may not be globally accessible\n body.constructor.name === 'FormData' ||\n // fallback to global FormData instance check\n // note: this is needed because the constructor.name could be different in case of\n // custom global FormData implementation, eg. React Native on Android/iOS\n (typeof FormData !== 'undefined' && body instanceof FormData)\n )\n }\n\n /**\n * Serializes the provided query parameters into a query string.\n */\n private serializeQueryParams(params: {[key: string]: any}): string {\n const result: Array = [];\n for (const key in params) {\n if (params[key] === null) {\n // skip null query params\n continue;\n }\n\n const value = params[key];\n const encodedKey = encodeURIComponent(key);\n\n if (Array.isArray(value)) {\n // repeat array params\n for (const v of value) {\n result.push(encodedKey + '=' + encodeURIComponent(v));\n }\n } else if (value instanceof Date) {\n result.push(encodedKey + '=' + encodeURIComponent(value.toISOString()));\n } else if (typeof value !== null && typeof value === 'object') {\n result.push(encodedKey + '=' + encodeURIComponent(JSON.stringify(value)));\n } else {\n result.push(encodedKey + '=' + encodeURIComponent(value));\n }\n }\n\n return result.join('&');\n }\n}\n","import { BaseAuthStore, AuthModel } from '@/stores/BaseAuthStore';\n\nexport type AsyncSaveFunc = (serializedPayload: string) => Promise;\n\nexport type AsyncClearFunc = () => Promise;\n\ntype queueFunc = () => Promise;\n\n/**\n * AsyncAuthStore is a helper auth store implementation\n * that could be used with any external async persistent layer\n * (key-value db, local file, etc.).\n *\n * Here is an example with the React Native AsyncStorage package:\n *\n * ```\n * import AsyncStorage from \"@react-native-async-storage/async-storage\";\n * import PocketBase, { AsyncAuthStore } from \"pocketbase\";\n *\n * const store = new AsyncAuthStore({\n * save: async (serialized) => AsyncStorage.setItem(\"pb_auth\", serialized),\n * initial: await AsyncStorage.getItem(\"pb_auth\"),\n * });\n *\n * const pb = new PocketBase(\"https://example.com\", store)\n * ```\n */\nexport class AsyncAuthStore extends BaseAuthStore {\n private saveFunc: AsyncSaveFunc;\n private clearFunc?: AsyncClearFunc;\n private queue: Array = [];\n\n constructor(config: {\n // The async function that is called every time\n // when the auth store state needs to be persisted.\n save: AsyncSaveFunc,\n\n /// An *optional* async function that is called every time\n /// when the auth store needs to be cleared.\n ///\n /// If not explicitly set, `saveFunc` with empty data will be used.\n clear?: AsyncClearFunc,\n\n // initial data to load into the store\n initial?: string,\n }) {\n super();\n\n this.saveFunc = config.save;\n this.clearFunc = config.clear;\n\n this._loadInitial(config.initial);\n }\n\n /**\n * @inheritdoc\n */\n save(token: string, model?: AuthModel): void {\n super.save(token, model);\n\n let value = '';\n try {\n value = JSON.stringify({token, model})\n } catch (err) {\n console.warn('AsyncAuthStore: failed to stringify the new state');\n }\n\n this._enqueue(() => this.saveFunc(value));\n }\n\n /**\n * @inheritdoc\n */\n clear(): void {\n super.clear();\n\n if (this.clearFunc) {\n this._enqueue(() => this.clearFunc!());\n } else {\n this._enqueue(() => this.saveFunc(\"\"));\n }\n }\n\n\n /**\n * Initializes the auth store state.\n */\n private _loadInitial(payload?: string) {\n if (!payload) {\n return; // nothing to load\n }\n\n try {\n const parsed = JSON.parse(payload) || {};\n\n this.save(parsed.token || \"\", parsed.model || null);\n } catch (_) {}\n }\n\n /**\n * Appends an async function to the queue.\n */\n private _enqueue(asyncCallback: () => Promise) {\n this.queue.push(asyncCallback);\n\n if (this.queue.length == 1) {\n this._dequeue();\n }\n }\n\n /**\n * Starts the queue processing.\n */\n private _dequeue() {\n if (!this.queue.length) {\n return;\n }\n\n this.queue[0]().finally(() => {\n this.queue.shift();\n\n if (!this.queue.length) {\n return;\n }\n\n this._dequeue();\n });\n }\n}\n"],"names":["ClientResponseError","Error","constructor","errData","super","this","url","status","response","isAbort","originalError","Object","setPrototypeOf","prototype","data","DOMException","name","message","_a","_d","_c","_b","cause","includes","toJSON","assign","fieldContentRegExp","cookieParse","str","options","result","decode","defaultDecode","index","length","eqIdx","indexOf","endIdx","lastIndexOf","key","slice","trim","undefined","val","charCodeAt","_","cookieSerialize","opt","encode","defaultEncode","test","TypeError","value","maxAge","isNaN","isFinite","Math","floor","domain","path","expires","isDate","toString","call","Date","valueOf","toUTCString","httpOnly","secure","priority","toLowerCase","sameSite","decodeURIComponent","encodeURIComponent","atobPolyfill","getTokenPayload","token","encodedPayload","split","map","c","join","JSON","parse","e","isTokenExpired","expirationThreshold","payload","keys","exp","now","atob","input","String","replace","bs","buffer","bc","idx","output","charAt","fromCharCode","defaultCookieKey","BaseAuthStore","baseToken","baseModel","_onChangeCallbacks","model","isValid","isAdmin","type","isAuthRecord","save","triggerChange","clear","loadFromCookie","cookie","rawData","Array","isArray","exportToCookie","defaultOptions","stringify","resultLength","Blob","size","id","email","extraProps","prop","onChange","callback","fireImmediately","push","i","splice","LocalAuthStore","storageKey","storageFallback","_bindStorageEvent","_storageGet","_storageSet","_storageRemove","window","localStorage","rawValue","getItem","normalizedVal","setItem","removeItem","addEventListener","BaseService","client","SettingsService","getAll","method","send","update","bodyParams","body","testS3","filesystem","then","testEmail","toEmail","emailTemplate","template","generateAppleClientSecret","clientId","teamId","keyId","privateKey","duration","CrudService","getFullList","batchOrqueryParams","_getFullList","batch","getList","page","perPage","query","baseCrudPath","responseData","items","item","getFirstListItem","filter","requestKey","skipTotal","code","getOne","create","batchSize","request","__awaiter","list","concat","normalizeLegacyOptionsArgs","legacyWarn","baseOptions","bodyOrOptions","hasQuery","console","warn","AdminService","authStore","collectionId","delete","success","authResponse","admin","authWithPassword","password","identity","bind","authRefresh","requestPasswordReset","confirmPasswordReset","resetToken","passwordConfirm","RealtimeService","eventSource","subscriptions","lastSentTopics","maxConnectTimeout","reconnectAttempts","maxReconnectAttempts","Infinity","predefinedReconnectIntervals","pendingConnects","isConnected","subscribe","topic","listener","msgEvent","submitSubscriptions","connect","unsubscribeByTopicAndListener","unsubscribe","hasSubscriptionListeners","removeEventListener","disconnect","unsubscribeByPrefix","topicPrefix","hasAtleastOneTopic","startsWith","exist","topicToCheck","addAllSubscriptionListeners","getNonEmptySubscriptionTopics","getSubscriptionsCancelKey","catch","err","removeAllSubscriptionListeners","Promise","resolve","reject","initConnect","clearTimeout","connectTimeoutId","setTimeout","connectErrorHandler","EventSource","buildUrl","onerror","lastEventId","retries","hasUnsentSubscriptions","p","reconnectTimeoutId","latestTopics","t","timeout","fromReconnect","cancelRequest","close","RecordService","collectionIdOrName","baseCollectionPath","subscribeOne","recordId","realtime","topicOrCallback","batchOrOptions","params","collectionName","record","listAuthMethods","usernamePassword","emailPassword","authProviders","usernameOrEmail","authWithOAuth2Code","provider","codeVerifier","redirectUrl","createData","authWithOAuth2","args","config","find","eagerDefaultPopup","cleanup","urlCallback","openBrowserPopup","oldState","state","scopes","authData","replacements","_replaceQueryParams","authUrl","location","href","passwordResetToken","requestVerification","confirmVerification","verificationToken","requestEmailChange","newEmail","confirmEmailChange","emailChangeToken","listExternalAuths","unlinkExternalAuth","urlPath","substring","parsedParams","rawParams","param","pair","hasOwnProperty","open","width","height","windowWidth","innerWidth","windowHeight","innerHeight","left","top","CollectionService","import","collections","deleteMissing","LogService","getRequestsList","getRequest","getRequestsStats","HealthService","check","FileService","getUrl","filename","queryParams","parts","download","URLSearchParams","getToken","BackupService","basename","restore","getDownloadUrl","knownSendOptionsKeys","Client","baseUrl","lang","cancelControllers","recordServices","enableAutoCancellation","admins","files","logs","settings","health","backups","collection","idOrName","autoCancellation","enable","abort","cancelAllRequests","k","getFileUrl","origin","endsWith","pathname","initSendOptions","serializeQueryParams","beforeSend","getHeader","headers","fetch","json","afterSend","convertToFormDataIfNeeded","$autoCancel","$cancelKey","isFormData","Authorization","controller","AbortController","signal","FormData","hasBlobField","form","values","append","v","File","encodedKey","toISOString","AsyncAuthStore","queue","saveFunc","clearFunc","_loadInitial","initial","_enqueue","parsed","asyncCallback","_dequeue","finally","shift"],"mappings":"4ZAIM,MAAOA,4BAA4BC,MAOrC,WAAAC,CAAYC,eACRC,MAAM,uBAPVC,KAAGC,IAA8B,GACjCD,KAAME,OAA2B,EACjCF,KAAQG,SAAyB,GACjCH,KAAOI,SAA0B,EACjCJ,KAAaK,cAAoB,KAO7BC,OAAOC,eAAeP,KAAML,oBAAoBa,WAEhC,OAAZV,GAAuC,iBAAZA,IAC3BE,KAAKC,IAAuC,iBAAhBH,EAAQG,IAAmBH,EAAQG,IAAM,GACrED,KAAKE,OAA0C,iBAAnBJ,EAAQI,OAAsBJ,EAAQI,OAAS,EAC3EF,KAAKI,UAAkBN,EAAQM,QAC/BJ,KAAKK,cAAgBP,EAAQO,cAEJ,OAArBP,EAAQK,UAAiD,iBAArBL,EAAQK,SAC5CH,KAAKG,SAAYL,EAAQK,SACD,OAAjBL,EAAQW,MAAyC,iBAAjBX,EAAQW,KAC/CT,KAAKG,SAAYL,EAAQW,KAEzBT,KAAKG,SAAY,IAIpBH,KAAKK,eAAmBP,aAAmBH,sBAC5CK,KAAKK,cAAgBP,GAGG,oBAAjBY,cAAgCZ,aAAmBY,eAC1DV,KAAKI,SAAU,GAGnBJ,KAAKW,KAAO,uBAAyBX,KAAKE,OAC1CF,KAAKY,QAAyB,QAAfC,EAAAb,KAAKG,gBAAU,IAAAU,OAAA,EAAAA,EAAAD,QACzBZ,KAAKY,UACFZ,KAAKI,QACLJ,KAAKY,QAAU,oHAC4B,QAApCE,EAAyB,QAAzBC,EAAkB,QAAlBC,EAAAhB,KAA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/pocketbase.iife.d.ts @@ -1021,9 +1021,9 @@ declare class Client { /** * Legacy alias of `pb.files.getUrl()`. */ - getFileUrl(record: Pick<{ + getFileUrl(record: { [key: string]: any; - }, 'id' | 'collectionId' | 'collectionName'>, filename: string, queryParams?: FileOptions): string; + }, filename: string, queryParams?: FileOptions): string; /** * Builds a full client url by safely concatenating the provided path. */ diff --git a/dist/pocketbase.iife.js.map b/dist/pocketbase.iife.js.map index a75829b..3d34d97 100644 --- a/dist/pocketbase.iife.js.map +++ b/dist/pocketbase.iife.js.map @@ -1 +1 @@ -{"version":3,"file":"pocketbase.iife.js","sources":["../src/ClientResponseError.ts","../src/stores/utils/cookie.ts","../src/stores/utils/jwt.ts","../src/stores/BaseAuthStore.ts","../src/stores/LocalAuthStore.ts","../src/services/utils/BaseService.ts","../src/services/SettingsService.ts","../src/services/utils/CrudService.ts","../src/services/utils/legacy.ts","../src/services/AdminService.ts","../src/services/RealtimeService.ts","../src/services/RecordService.ts","../src/services/CollectionService.ts","../src/services/LogService.ts","../src/services/HealthService.ts","../src/services/FileService.ts","../src/services/BackupService.ts","../src/Client.ts"],"sourcesContent":["/**\n * ClientResponseError is a custom Error class that is intended to wrap\n * and normalize any error thrown by `Client.send()`.\n */\nexport class ClientResponseError extends Error {\n url: string = '';\n status: number = 0;\n response: {[key: string]: any} = {};\n isAbort: boolean = false;\n originalError: any = null;\n\n constructor(errData?: any) {\n super(\"ClientResponseError\");\n\n // Set the prototype explicitly.\n // https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\n Object.setPrototypeOf(this, ClientResponseError.prototype);\n\n if (errData !== null && typeof errData === 'object') {\n this.url = typeof errData.url === 'string' ? errData.url : '';\n this.status = typeof errData.status === 'number' ? errData.status : 0;\n this.isAbort = !!errData.isAbort;\n this.originalError = errData.originalError;\n\n if (errData.response !== null && typeof errData.response === 'object') {\n this.response = errData.response;\n } else if (errData.data !== null && typeof errData.data === 'object') {\n this.response = errData.data;\n } else {\n this.response = {};\n }\n }\n\n if (!this.originalError && !(errData instanceof ClientResponseError)) {\n this.originalError = errData;\n }\n\n if (typeof DOMException !== 'undefined' && errData instanceof DOMException) {\n this.isAbort = true;\n }\n\n this.name = \"ClientResponseError \" + this.status;\n this.message = this.response?.message;\n if (!this.message) {\n if (this.isAbort) {\n this.message = 'The request was autocancelled. You can find more info in https://github.com/pocketbase/js-sdk#auto-cancellation.';\n } else if (this.originalError?.cause?.message?.includes(\"ECONNREFUSED ::1\")) {\n this.message = 'Failed to connect to the PocketBase server. Try changing the SDK URL from localhost to 127.0.0.1 (https://github.com/pocketbase/js-sdk/issues/21).';\n } else {\n this.message = 'Something went wrong while processing your request.';\n }\n }\n }\n\n /**\n * Alias for `this.response` to preserve the backward compatibility.\n */\n get data() {\n return this.response;\n }\n\n /**\n * Make a POJO's copy of the current error class instance.\n * @see https://github.com/vuex-orm/vuex-orm/issues/255\n */\n toJSON() {\n return { ...this };\n }\n}\n","/**\n * -------------------------------------------------------------------\n * Simple cookie parse and serialize utilities mostly based on the\n * node module https://github.com/jshttp/cookie.\n * -------------------------------------------------------------------\n */\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\nconst fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;\n\nexport interface ParseOptions{\n decode?: (val: string) => string,\n}\n\n/**\n* Parses the given cookie header string into an object\n* The object has the various cookies as keys(names) => values\n*/\nexport function cookieParse(str: string, options?: ParseOptions): { [key: string]: any } {\n const result: { [key: string]: any } = {};\n\n if (typeof str !== 'string') {\n return result;\n }\n\n const opt = Object.assign({}, options || {});\n const decode = opt.decode || defaultDecode;\n\n let index = 0;\n while (index < str.length) {\n const eqIdx = str.indexOf('=', index);\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break;\n }\n\n let endIdx = str.indexOf(';', index);\n\n if (endIdx === -1) {\n endIdx = str.length;\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(';', eqIdx - 1) + 1;\n continue;\n }\n\n const key = str.slice(index, eqIdx).trim();\n\n // only assign once\n if (undefined === result[key]) {\n let val = str.slice(eqIdx + 1, endIdx).trim();\n\n // quoted values\n if (val.charCodeAt(0) === 0x22) {\n val = val.slice(1, -1);\n }\n\n try {\n result[key] = decode(val);\n } catch (_) {\n result[key] = val; // no decoding\n }\n }\n\n index = endIdx + 1;\n }\n\n return result;\n};\n\nexport interface SerializeOptions {\n encode?: (val: string | number | boolean) => string,\n maxAge?: number,\n domain?: string,\n path?: string,\n expires?: Date,\n httpOnly?: boolean,\n secure?: boolean,\n priority?: string,\n sameSite?: boolean|string,\n}\n\n/**\n * Serialize data into a cookie header.\n *\n * Serialize the a name value pair into a cookie string suitable for\n * http headers. An optional options object specified cookie parameters.\n *\n * ```js\n * cookieSerialize('foo', 'bar', { httpOnly: true }) // \"foo=bar; httpOnly\"\n * ```\n */\nexport function cookieSerialize(name: string, val: string, options?: SerializeOptions): string {\n const opt = Object.assign({}, options || {});\n const encode = opt.encode || defaultEncode;\n\n if (!fieldContentRegExp.test(name)) {\n throw new TypeError('argument name is invalid');\n }\n\n const value = encode(val);\n\n if (value && !fieldContentRegExp.test(value)) {\n throw new TypeError('argument val is invalid');\n }\n\n let result = name + '=' + value;\n\n if (opt.maxAge != null) {\n const maxAge = opt.maxAge - 0;\n\n if (isNaN(maxAge) || !isFinite(maxAge)) {\n throw new TypeError('option maxAge is invalid');\n }\n\n result += '; Max-Age=' + Math.floor(maxAge);\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new TypeError('option domain is invalid');\n }\n\n result += '; Domain=' + opt.domain;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new TypeError('option path is invalid');\n }\n\n result += '; Path=' + opt.path;\n }\n\n if (opt.expires) {\n if (!isDate(opt.expires) || isNaN(opt.expires.valueOf())) {\n throw new TypeError('option expires is invalid');\n }\n\n result += '; Expires=' + opt.expires.toUTCString();\n }\n\n if (opt.httpOnly) {\n result += '; HttpOnly';\n }\n\n if (opt.secure) {\n result += '; Secure';\n }\n\n if (opt.priority) {\n const priority = typeof opt.priority === 'string' ? opt.priority.toLowerCase() : opt.priority;\n\n switch (priority) {\n case 'low':\n result += '; Priority=Low';\n break;\n case 'medium':\n result += '; Priority=Medium';\n break;\n case 'high':\n result += '; Priority=High';\n break;\n default:\n throw new TypeError('option priority is invalid');\n }\n }\n\n if (opt.sameSite) {\n const sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;\n\n switch (sameSite) {\n case true:\n result += '; SameSite=Strict';\n break;\n case 'lax':\n result += '; SameSite=Lax';\n break;\n case 'strict':\n result += '; SameSite=Strict';\n break;\n case 'none':\n result += '; SameSite=None';\n break;\n default:\n throw new TypeError('option sameSite is invalid');\n }\n }\n\n return result;\n};\n\n/**\n * Default URL-decode string value function.\n * Optimized to skip native call when no `%`.\n */\nfunction defaultDecode(val: string): string {\n return val.indexOf('%') !== -1\n ? decodeURIComponent(val)\n : val;\n}\n\n/**\n * Default URL-encode value function.\n */\nfunction defaultEncode(val: string | number | boolean): string {\n return encodeURIComponent(val);\n}\n\n/**\n * Determines if value is a Date.\n */\nfunction isDate(val: any): boolean {\n return (\n Object.prototype.toString.call(val) === '[object Date]' ||\n val instanceof Date\n );\n}\n","let atobPolyfill: Function;\nif (typeof atob === 'function') {\n atobPolyfill = atob\n} else {\n /**\n * The code was extracted from:\n * https://github.com/davidchambers/Base64.js\n */\n atobPolyfill = (input: any) => {\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\n let str = String(input).replace(/=+$/, \"\");\n if (str.length % 4 == 1) {\n throw new Error(\"'atob' failed: The string to be decoded is not correctly encoded.\");\n }\n\n for (\n // initialize result and counters\n var bc = 0, bs, buffer, idx = 0, output = \"\";\n // get next character\n (buffer = str.charAt(idx++));\n // character found in table? initialize bit storage and add its ascii value;\n ~buffer &&\n ((bs = bc % 4 ? (bs as any) * 64 + buffer : buffer),\n // and if not first of each 4 characters,\n // convert the first 8 bits to one ascii character\n bc++ % 4) ?\n (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)))) :\n 0\n ) {\n // try to find character in table (0-63, not found => -1)\n buffer = chars.indexOf(buffer);\n }\n\n return output;\n };\n}\n\n/**\n * Returns JWT token's payload data.\n */\nexport function getTokenPayload(token: string): { [key: string]: any } {\n if (token) {\n try {\n const encodedPayload = decodeURIComponent(atobPolyfill(token.split('.')[1]).split('').map(function (c: string) {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n }).join(''));\n\n return JSON.parse(encodedPayload) || {};\n } catch (e) {\n }\n }\n\n return {};\n}\n\n/**\n * Checks whether a JWT token is expired or not.\n * Tokens without `exp` payload key are considered valid.\n * Tokens with empty payload (eg. invalid token strings) are considered expired.\n *\n * @param token The token to check.\n * @param [expirationThreshold] Time in seconds that will be subtracted from the token `exp` property.\n */\nexport function isTokenExpired(token: string, expirationThreshold = 0): boolean {\n let payload = getTokenPayload(token);\n\n if (\n Object.keys(payload).length > 0 &&\n (!payload.exp || (payload.exp - expirationThreshold) > (Date.now() / 1000))\n ) {\n return false;\n }\n\n return true;\n}\n","import { cookieParse, cookieSerialize, SerializeOptions } from '@/stores/utils/cookie';\nimport { isTokenExpired, getTokenPayload } from '@/stores/utils/jwt';\nimport { RecordModel, AdminModel } from '@/services/utils/dtos';\n\nexport type AuthModel = RecordModel|AdminModel|null;\n\nexport type OnStoreChangeFunc = (token: string, model: AuthModel) => void;\n\nconst defaultCookieKey = 'pb_auth';\n\n/**\n * Base AuthStore class that is intended to be extended by all other\n * PocketBase AuthStore implementations.\n */\nexport abstract class BaseAuthStore {\n protected baseToken: string = '';\n protected baseModel: AuthModel = null;\n\n private _onChangeCallbacks: Array = [];\n\n /**\n * Retrieves the stored token (if any).\n */\n get token(): string {\n return this.baseToken;\n }\n\n /**\n * Retrieves the stored model data (if any).\n */\n get model(): AuthModel {\n return this.baseModel;\n }\n\n /**\n * Loosely checks if the store has valid token (aka. existing and unexpired exp claim).\n */\n get isValid(): boolean {\n return !isTokenExpired(this.token);\n }\n\n /**\n * Checks whether the current store state is for admin authentication.\n */\n get isAdmin(): boolean {\n return getTokenPayload(this.token).type === \"admin\";\n }\n\n /**\n * Checks whether the current store state is for auth record authentication.\n */\n get isAuthRecord(): boolean {\n return getTokenPayload(this.token).type === \"authRecord\";\n }\n\n /**\n * Saves the provided new token and model data in the auth store.\n */\n save(token: string, model?: AuthModel): void {\n this.baseToken = token || '';\n this.baseModel = model || null;\n\n this.triggerChange();\n }\n\n /**\n * Removes the stored token and model data form the auth store.\n */\n clear(): void {\n this.baseToken = '';\n this.baseModel = null;\n this.triggerChange();\n }\n\n /**\n * Parses the provided cookie string and updates the store state\n * with the cookie's token and model data.\n *\n * NB! This function doesn't validate the token or its data.\n * Usually this isn't a concern if you are interacting only with the\n * PocketBase API because it has the proper server-side security checks in place,\n * but if you are using the store `isValid` state for permission controls\n * in a node server (eg. SSR), then it is recommended to call `authRefresh()`\n * after loading the cookie to ensure an up-to-date token and model state.\n * For example:\n *\n * ```js\n * pb.authStore.loadFromCookie(\"cookie string...\");\n *\n * try {\n * // get an up-to-date auth store state by veryfing and refreshing the loaded auth model (if any)\n * pb.authStore.isValid && await pb.collection('users').authRefresh();\n * } catch (_) {\n * // clear the auth store on failed refresh\n * pb.authStore.clear();\n * }\n * ```\n */\n loadFromCookie(cookie: string, key = defaultCookieKey): void {\n const rawData = cookieParse(cookie || '')[key] || '';\n\n let data: { [key: string]: any } = {};\n try {\n data = JSON.parse(rawData);\n // normalize\n if (typeof data === null || typeof data !== 'object' || Array.isArray(data)) {\n data = {};\n }\n } catch (_) {}\n\n this.save(data.token || '', data.model || null);\n }\n\n /**\n * Exports the current store state as cookie string.\n *\n * By default the following optional attributes are added:\n * - Secure\n * - HttpOnly\n * - SameSite=Strict\n * - Path=/\n * - Expires={the token expiration date}\n *\n * NB! If the generated cookie exceeds 4096 bytes, this method will\n * strip the model data to the bare minimum to try to fit within the\n * recommended size in https://www.rfc-editor.org/rfc/rfc6265#section-6.1.\n */\n exportToCookie(options?: SerializeOptions, key = defaultCookieKey): string {\n const defaultOptions: SerializeOptions = {\n secure: true,\n sameSite: true,\n httpOnly: true,\n path: \"/\",\n };\n\n // extract the token expiration date\n const payload = getTokenPayload(this.token);\n if (payload?.exp) {\n defaultOptions.expires = new Date(payload.exp * 1000);\n } else {\n defaultOptions.expires = new Date('1970-01-01');\n }\n\n // merge with the user defined options\n options = Object.assign({}, defaultOptions, options);\n\n const rawData = {\n token: this.token,\n model: this.model ? JSON.parse(JSON.stringify(this.model)) : null,\n };\n\n let result = cookieSerialize(key, JSON.stringify(rawData), options);\n\n const resultLength = typeof Blob !== 'undefined' ?\n (new Blob([result])).size : result.length;\n\n // strip down the model data to the bare minimum\n if (rawData.model && resultLength > 4096) {\n rawData.model = {id: rawData?.model?.id, email: rawData?.model?.email};\n const extraProps = [\"collectionId\", \"username\", \"verified\"];\n for (const prop in this.model) {\n if (extraProps.includes(prop)) {\n rawData.model[prop] = this.model[prop];\n }\n }\n result = cookieSerialize(key, JSON.stringify(rawData), options);\n }\n\n return result;\n }\n\n /**\n * Register a callback function that will be called on store change.\n *\n * You can set the `fireImmediately` argument to true in order to invoke\n * the provided callback right after registration.\n *\n * Returns a removal function that you could call to \"unsubscribe\" from the changes.\n */\n onChange(callback: OnStoreChangeFunc, fireImmediately = false): () => void {\n this._onChangeCallbacks.push(callback);\n\n if (fireImmediately) {\n callback(this.token, this.model);\n }\n\n return () => {\n for (let i = this._onChangeCallbacks.length - 1; i >= 0; i--) {\n if (this._onChangeCallbacks[i] == callback) {\n delete this._onChangeCallbacks[i]; // removes the function reference\n this._onChangeCallbacks.splice(i, 1); // reindex the array\n return;\n }\n }\n }\n }\n\n protected triggerChange(): void {\n for (const callback of this._onChangeCallbacks) {\n callback && callback(this.token, this.model);\n }\n }\n}\n","import { BaseAuthStore, AuthModel } from '@/stores/BaseAuthStore';\n\n/**\n * The default token store for browsers with auto fallback\n * to runtime/memory if local storage is undefined (eg. in node env).\n */\nexport class LocalAuthStore extends BaseAuthStore {\n private storageFallback: { [key: string]: any } = {};\n private storageKey: string\n\n constructor(storageKey = \"pocketbase_auth\") {\n super();\n\n this.storageKey = storageKey;\n\n this._bindStorageEvent();\n }\n\n /**\n * @inheritdoc\n */\n get token(): string {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.token || '';\n }\n\n /**\n * @inheritdoc\n */\n get model(): AuthModel {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.model || null;\n }\n\n /**\n * @inheritdoc\n */\n save(token: string, model?: AuthModel) {\n this._storageSet(this.storageKey, {\n 'token': token,\n 'model': model,\n });\n\n super.save(token, model);\n }\n\n /**\n * @inheritdoc\n */\n clear() {\n this._storageRemove(this.storageKey);\n\n super.clear();\n }\n\n // ---------------------------------------------------------------\n // Internal helpers:\n // ---------------------------------------------------------------\n\n /**\n * Retrieves `key` from the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageGet(key: string): any {\n if (typeof window !== 'undefined' && window?.localStorage) {\n const rawValue = window.localStorage.getItem(key) || '';\n try {\n return JSON.parse(rawValue);\n } catch (e) { // not a json\n return rawValue;\n }\n }\n\n // fallback\n return this.storageFallback[key];\n }\n\n /**\n * Stores a new data in the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageSet(key: string, value: any) {\n if (typeof window !== 'undefined' && window?.localStorage) {\n // store in local storage\n let normalizedVal = value;\n if (typeof value !== 'string') {\n normalizedVal = JSON.stringify(value);\n }\n window.localStorage.setItem(key, normalizedVal);\n } else {\n // store in fallback\n this.storageFallback[key] = value;\n }\n }\n\n /**\n * Removes `key` from the browser's local storage and the runtime/memory.\n */\n private _storageRemove(key: string) {\n // delete from local storage\n if (typeof window !== 'undefined' && window?.localStorage) {\n window.localStorage?.removeItem(key);\n }\n\n // delete from fallback\n delete this.storageFallback[key];\n }\n\n /**\n * Updates the current store state on localStorage change.\n */\n private _bindStorageEvent() {\n if (typeof window === 'undefined' || !window?.localStorage || !window.addEventListener) {\n return;\n }\n\n window.addEventListener('storage', (e) => {\n if (e.key != this.storageKey) {\n return;\n }\n\n const data = this._storageGet(this.storageKey) || {};\n\n super.save(data.token || '', data.model || null);\n });\n }\n}\n","import Client from '@/Client';\n\n/**\n * BaseService class that should be inherited from all API services.\n */\nexport abstract class BaseService {\n readonly client: Client\n\n constructor(client: Client) {\n this.client = client;\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\ninterface appleClientSecret {\n secret: string;\n}\n\nexport class SettingsService extends BaseService {\n /**\n * Fetch all available app settings.\n */\n getAll(options?: CommonOptions): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Bulk updates app settings.\n */\n update(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Performs a S3 filesystem connection test.\n *\n * The currently supported `filesystem` are \"storage\" and \"backups\".\n */\n testS3(filesystem: string = \"storage\", options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'filesystem': filesystem,\n },\n }, options);\n\n return this.client.send('/api/settings/test/s3', options)\n .then(() => true);\n }\n\n /**\n * Sends a test email.\n *\n * The possible `emailTemplate` values are:\n * - verification\n * - password-reset\n * - email-change\n */\n testEmail(toEmail: string, emailTemplate: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'email': toEmail,\n 'template': emailTemplate,\n },\n }, options);\n\n return this.client.send('/api/settings/test/email', options)\n .then(() => true);\n }\n\n /**\n * Generates a new Apple OAuth2 client secret.\n */\n generateAppleClientSecret(\n clientId: string,\n teamId: string,\n keyId: string,\n privateKey: string,\n duration: number,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n clientId,\n teamId,\n keyId,\n privateKey,\n duration,\n },\n }, options);\n\n return this.client.send('/api/settings/apple/generate-client-secret', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n FullListOptions\n} from '@/services/utils/options';\n\nexport abstract class CrudService extends BaseService {\n /**\n * Base path for the crud actions (without trailing slash, eg. '/admins').\n */\n abstract get baseCrudPath(): string\n\n /**\n * Response data decoder.\n */\n decode(data: { [key: string]: any }): T {\n return data as T;\n }\n\n /**\n * Returns a promise with all list items batch fetched at once\n * (by default 500 items per request; to change it set the `batch` query param).\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getFullList(options?: FullListOptions): Promise>\n\n /**\n * Legacy version of getFullList with explicitly specified batch size.\n */\n getFullList(batch?: number, options?: ListOptions): Promise>\n\n getFullList(batchOrqueryParams?: number|FullListOptions, options?: ListOptions): Promise> {\n if (typeof batchOrqueryParams == \"number\") {\n return this._getFullList(batchOrqueryParams, options);\n }\n\n options = Object.assign({}, batchOrqueryParams, options);\n\n let batch = 500;\n if (options.batch) {\n batch = options.batch;\n delete options.batch;\n }\n\n return this._getFullList(batch, options);\n }\n\n /**\n * Returns paginated items list.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({\n method: 'GET'\n }, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => {\n responseData.items = responseData.items?.map((item: any) => {\n return this.decode(item);\n }) || [];\n\n return responseData;\n });\n }\n\n /**\n * Returns the first found item by the specified filter.\n *\n * Internally it calls `getList(1, 1, { filter, skipTotal })` and\n * returns the first found item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n *\n * For consistency with `getOne`, this method will throw a 404\n * ClientResponseError if no item was found.\n */\n getFirstListItem(filter: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'requestKey': 'one_by_filter_' + this.baseCrudPath + \"_\" + filter,\n }, options);\n\n options.query = Object.assign({\n 'filter': filter,\n 'skipTotal': 1,\n }, options.query);\n\n return this.getList(1, 1, options)\n .then((result) => {\n if (!result?.items?.length) {\n throw new ClientResponseError({\n status: 404,\n data: {\n code: 404,\n message: \"The requested resource wasn't found.\",\n data: {},\n },\n });\n }\n\n return result.items[0];\n });\n }\n\n /**\n * Returns single item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getOne(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Creates a new item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n create(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Updates an existing item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Deletes an existing item by its id.\n */\n delete(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then(() => true);\n }\n\n /**\n * Returns a promise with all list items batch fetched at once.\n */\n protected _getFullList(batchSize = 500, options?: ListOptions): Promise> {\n options = options || {};\n options.query = Object.assign({\n 'skipTotal': 1,\n }, options.query);\n\n let result: Array = [];\n\n let request = async (page: number): Promise> => {\n return this.getList(page, batchSize || 500, options).then((list) => {\n const castedList = (list as any as ListResult);\n const items = castedList.items;\n\n result = result.concat(items);\n\n if (items.length == list.perPage) {\n return request(page + 1);\n }\n\n return result;\n });\n }\n\n return request(1);\n }\n}\n","import { SendOptions } from '@/services/utils/options';\n\nexport function normalizeLegacyOptionsArgs(legacyWarn: string, baseOptions: SendOptions, bodyOrOptions?: any, query?: any): SendOptions {\n const hasBodyOrOptions = typeof bodyOrOptions !== 'undefined';\n const hasQuery = typeof query !== 'undefined';\n\n if (!hasQuery && !hasBodyOrOptions) {\n return baseOptions;\n }\n\n if (hasQuery) {\n console.warn(legacyWarn);\n baseOptions.body = Object.assign({}, baseOptions.body, bodyOrOptions);\n baseOptions.query = Object.assign({}, baseOptions.query, query);\n\n return baseOptions;\n }\n\n baseOptions = Object.assign(baseOptions, bodyOrOptions);\n return baseOptions;\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { AdminModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface AdminAuthResponse {\n [key: string]: any;\n\n token: string;\n admin: AdminModel;\n}\n\nexport class AdminService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/admins';\n }\n\n // ---------------------------------------------------------------\n // Post update/delete AuthStore sync\n // ---------------------------------------------------------------\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n // update the store state if the updated item id matches with the stored model\n if (\n this.client.authStore.model?.id === item.id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n // clear the store state if the deleted item id matches with the stored model\n if (\n success &&\n this.client.authStore.model?.id === id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful authorize response.\n */\n protected authResponse(responseData: any): AdminAuthResponse {\n const admin = this.decode(responseData?.admin || {});\n\n if (responseData?.token && responseData?.admin) {\n this.client.authStore.save(responseData.token, admin);\n }\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'admin': admin,\n });\n }\n\n /**\n * Authenticate an admin account with its email and password\n * and returns a new admin token and data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authWithPassword(email: string, password: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authWithPassword(email, password, options?).\n */\n authWithPassword(email: string, password: string, body?: any, query?: any): Promise\n\n authWithPassword(\n email: string,\n password: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': email,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(email, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(email, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-with-password', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Refreshes the current admin authenticated instance and\n * returns a new token and admin data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authRefresh(options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-refresh', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Sends admin password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/request-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Confirms admin password reset request.\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(resetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, body?: any, query?: any): Promise\n\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, bodyOrOptions?: any, query?: any): Promise{\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': resetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(resetToken, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(resetToken, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\n\ninterface promiseCallbacks {\n resolve: Function\n reject: Function\n}\n\nexport type UnsubscribeFunc = () => Promise;\n\nexport class RealtimeService extends BaseService {\n clientId: string = \"\";\n\n private eventSource: EventSource | null = null;\n private subscriptions: { [key: string]: Array } = {};\n private lastSentTopics: Array = [];\n private connectTimeoutId: any;\n private maxConnectTimeout: number = 15000;\n private reconnectTimeoutId: any;\n private reconnectAttempts: number = 0;\n private maxReconnectAttempts: number = Infinity;\n private predefinedReconnectIntervals: Array = [\n 200, 300, 500, 1000, 1200, 1500, 2000,\n ];\n private pendingConnects: Array = [];\n\n /**\n * Returns whether the realtime connection has been established.\n */\n get isConnected(): boolean {\n return !!this.eventSource && !!this.clientId && !this.pendingConnects.length;\n }\n\n /**\n * Register the subscription listener.\n *\n * You can subscribe multiple times to the same topic.\n *\n * If the SSE connection is not started yet,\n * this method will also initialize it.\n */\n async subscribe(topic: string, callback: (data: any) => void): Promise {\n if (!topic) {\n throw new Error('topic must be set.')\n }\n\n const listener = function (e: Event) {\n const msgEvent = (e as MessageEvent);\n\n let data;\n try {\n data = JSON.parse(msgEvent?.data);\n } catch {}\n\n callback(data || {});\n };\n\n // store the listener\n if (!this.subscriptions[topic]) {\n this.subscriptions[topic] = [];\n }\n this.subscriptions[topic].push(listener);\n\n if (!this.isConnected) {\n // initialize sse connection\n await this.connect();\n } else if (this.subscriptions[topic].length === 1) {\n // send the updated subscriptions (if it is the first for the topic)\n await this.submitSubscriptions();\n } else {\n // only register the listener\n this.eventSource?.addEventListener(topic, listener);\n }\n\n return async (): Promise => {\n return this.unsubscribeByTopicAndListener(topic, listener);\n };\n }\n\n /**\n * Unsubscribe from all subscription listeners with the specified topic.\n *\n * If `topic` is not provided, then this method will unsubscribe\n * from all active subscriptions.\n *\n * This method is no-op if there are no active subscriptions.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribe(topic?: string): Promise {\n if (!this.hasSubscriptionListeners(topic)) {\n return; // already unsubscribed\n }\n\n if (!topic) {\n // remove all subscriptions\n this.subscriptions = {};\n } else {\n // remove all topic listeners\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n /**\n * Unsubscribe from all subscription listeners starting with the specified topic prefix.\n *\n * This method is no-op if there are no active subscriptions with the specified topic prefix.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByPrefix(topicPrefix: string): Promise {\n let hasAtleastOneTopic = false;\n for (let topic in this.subscriptions) {\n if (!topic.startsWith(topicPrefix)) {\n continue;\n }\n\n hasAtleastOneTopic = true;\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!hasAtleastOneTopic) {\n return; // nothing to unsubscribe from\n }\n\n if (this.hasSubscriptionListeners()) {\n // submit the deleted subscriptions\n await this.submitSubscriptions();\n } else {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n }\n }\n\n /**\n * Unsubscribe from all subscriptions matching the specified topic and listener function.\n *\n * This method is no-op if there are no active subscription with\n * the specified topic and listener.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByTopicAndListener(topic: string, listener: EventListener): Promise {\n if (!Array.isArray(this.subscriptions[topic]) || !this.subscriptions[topic].length) {\n return; // already unsubscribed\n }\n\n let exist = false;\n for (let i = this.subscriptions[topic].length - 1; i >= 0; i--) {\n if (this.subscriptions[topic][i] !== listener) {\n continue;\n }\n\n exist = true; // has at least one matching listener\n delete this.subscriptions[topic][i]; // removes the function reference\n this.subscriptions[topic].splice(i, 1); // reindex the array\n this.eventSource?.removeEventListener(topic, listener);\n }\n if (!exist) {\n return;\n }\n\n // remove the topic from the subscriptions list if there are no other listeners\n if (!this.subscriptions[topic].length) {\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n private hasSubscriptionListeners(topicToCheck?: string): boolean {\n this.subscriptions = this.subscriptions || {};\n\n // check the specified topic\n if (topicToCheck) {\n return !!this.subscriptions[topicToCheck]?.length;\n }\n\n // check for at least one non-empty topic\n for (let topic in this.subscriptions) {\n if (!!this.subscriptions[topic]?.length) {\n return true\n }\n }\n\n return false;\n }\n\n private async submitSubscriptions(): Promise {\n if (!this.clientId) {\n return; // no client/subscriber\n }\n\n // optimistic update\n this.addAllSubscriptionListeners();\n\n this.lastSentTopics = this.getNonEmptySubscriptionTopics();\n\n return this.client.send('/api/realtime', {\n 'method': 'POST',\n 'body': {\n 'clientId': this.clientId,\n 'subscriptions': this.lastSentTopics,\n },\n 'query': {\n 'requestKey': this.getSubscriptionsCancelKey(),\n },\n }).catch((err) => {\n if (err?.isAbort) {\n return; // silently ignore aborted pending requests\n }\n throw err;\n });\n }\n\n private getSubscriptionsCancelKey(): string {\n return \"realtime_\" + this.clientId;\n }\n\n private getNonEmptySubscriptionTopics(): Array {\n const result : Array = [];\n\n for (let topic in this.subscriptions) {\n if (this.subscriptions[topic].length) {\n result.push(topic);\n }\n }\n\n return result;\n }\n\n private addAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n this.removeAllSubscriptionListeners();\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.addEventListener(topic, listener);\n }\n }\n }\n\n private removeAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.removeEventListener(topic, listener);\n }\n }\n }\n\n private async connect(): Promise {\n if (this.reconnectAttempts > 0) {\n // immediately resolve the promise to avoid indefinitely\n // blocking the client during reconnection\n return;\n }\n\n return new Promise((resolve, reject) => {\n this.pendingConnects.push({ resolve, reject });\n\n if (this.pendingConnects.length > 1) {\n // all promises will be resolved once the connection is established\n return;\n }\n\n this.initConnect();\n })\n }\n\n private initConnect() {\n this.disconnect(true);\n\n // wait up to 15s for connect\n clearTimeout(this.connectTimeoutId);\n this.connectTimeoutId = setTimeout(() => {\n this.connectErrorHandler(new Error(\"EventSource connect took too long.\"));\n }, this.maxConnectTimeout);\n\n this.eventSource = new EventSource(this.client.buildUrl('/api/realtime'))\n\n this.eventSource.onerror = (_) => {\n this.connectErrorHandler(new Error(\"Failed to establish realtime connection.\"));\n };\n\n this.eventSource.addEventListener('PB_CONNECT', (e) => {\n const msgEvent = (e as MessageEvent);\n this.clientId = msgEvent?.lastEventId;\n\n this.submitSubscriptions()\n .then(async () => {\n let retries = 3;\n while (this.hasUnsentSubscriptions() && retries > 0) {\n retries--;\n // resubscribe to ensure that the latest topics are submitted\n //\n // This is needed because missed topics could happen on reconnect\n // if after the pending sent `submitSubscriptions()` call another `subscribe()`\n // was made before the submit was able to complete.\n await this.submitSubscriptions();\n }\n }).then(() => {\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n\n // reset connect meta\n this.pendingConnects = [];\n this.reconnectAttempts = 0;\n clearTimeout(this.reconnectTimeoutId);\n clearTimeout(this.connectTimeoutId);\n }).catch((err) => {\n this.clientId = \"\";\n this.connectErrorHandler(err);\n });\n });\n }\n\n private hasUnsentSubscriptions(): boolean {\n const latestTopics = this.getNonEmptySubscriptionTopics();\n if (latestTopics.length != this.lastSentTopics.length) {\n return true;\n }\n\n for (const t of latestTopics) {\n if (!this.lastSentTopics.includes(t)) {\n return true;\n }\n }\n\n return false;\n }\n\n private connectErrorHandler(err: any) {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n\n if (\n // wasn't previously connected -> direct reject\n (!this.clientId && !this.reconnectAttempts) ||\n // was previously connected but the max reconnection limit has been reached\n this.reconnectAttempts > this.maxReconnectAttempts\n ) {\n for (let p of this.pendingConnects) {\n p.reject(new ClientResponseError(err));\n }\n this.pendingConnects = [];\n this.disconnect();\n return;\n }\n\n // otherwise -> reconnect in the background\n this.disconnect(true);\n const timeout = this.predefinedReconnectIntervals[this.reconnectAttempts] || this.predefinedReconnectIntervals[this.predefinedReconnectIntervals.length - 1];\n this.reconnectAttempts++;\n this.reconnectTimeoutId = setTimeout(() => {\n this.initConnect();\n }, timeout);\n }\n\n private disconnect(fromReconnect = false): void {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n this.removeAllSubscriptionListeners();\n this.client.cancelRequest(this.getSubscriptionsCancelKey());\n this.eventSource?.close();\n this.eventSource = null;\n this.clientId = \"\";\n\n if (!fromReconnect) {\n this.reconnectAttempts = 0;\n\n // resolve any remaining connect promises\n //\n // this is done to avoid unnecessary throwing errors in case\n // unsubscribe is called before the pending connect promises complete\n // (see https://github.com/pocketbase/pocketbase/discussions/2897#discussioncomment-6423818)\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n this.pendingConnects = [];\n }\n }\n}\n","import Client from '@/Client';\nimport { CrudService } from '@/services/utils/CrudService';\nimport { RealtimeService, UnsubscribeFunc } from '@/services/RealtimeService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult, RecordModel, ExternalAuthModel } from '@/services/utils/dtos';\nimport {\n SendOptions,\n CommonOptions,\n RecordOptions,\n RecordListOptions,\n RecordFullListOptions,\n} from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface RecordAuthResponse {\n // The signed PocketBase auth record.\n record: T;\n\n // The PocketBase record auth token.\n //\n // If you are looking for the OAuth2 access and refresh tokens\n // they are available under the `meta.accessToken` and `meta.refreshToken` props.\n token: string;\n\n // Auth meta data usually filled when OAuth2 is used.\n meta?: {[key: string]: any};\n}\n\nexport interface AuthProviderInfo {\n name: string;\n state: string;\n codeVerifier: string;\n codeChallenge: string;\n codeChallengeMethod: string;\n authUrl: string;\n}\n\nexport interface AuthMethodsList {\n usernamePassword: boolean;\n emailPassword: boolean;\n authProviders: Array;\n}\n\nexport interface RecordSubscription {\n action: string; // eg. create, update, delete\n record: T;\n}\n\nexport type OAuth2UrlCallback = (url: string) => void|Promise;\n\nexport interface OAuth2AuthConfig extends SendOptions {\n // the name of the OAuth2 provider (eg. \"google\")\n provider: string;\n\n // custom scopes to overwrite the default ones\n scopes?: Array;\n\n // optional record create data\n createData?: {[key: string]: any};\n\n // optional callback that is triggered after the OAuth2 sign-in/sign-up url generation\n urlCallback?: OAuth2UrlCallback;\n\n // optional query params to send with the PocketBase auth request (eg. fields, expand, etc.)\n query?: RecordOptions;\n}\n\nexport class RecordService extends CrudService {\n readonly collectionIdOrName: string;\n\n constructor(client: Client, collectionIdOrName: string) {\n super(client);\n\n this.collectionIdOrName = collectionIdOrName;\n }\n\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return this.baseCollectionPath + '/records';\n }\n\n /**\n * Returns the current collection service base path.\n */\n get baseCollectionPath(): string {\n return '/api/collections/' + encodeURIComponent(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Realtime handlers\n // ---------------------------------------------------------------\n\n /**\n * @deprecated Use subscribe(recordId, callback) instead.\n *\n * Subscribe to the realtime changes of a single record in the collection.\n */\n async subscribeOne(recordId: string, callback: (data: RecordSubscription) => void): Promise {\n console.warn(\"PocketBase: subscribeOne(recordId, callback) is deprecated. Please replace it with subscribe(recordId, callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName + \"/\" + recordId, callback);\n }\n\n /**\n * @deprecated This form of subscribe is deprecated. Please use `subscribe(\"*\", callback)`.\n */\n async subscribe(callback: (data: RecordSubscription) => void): Promise\n\n /**\n * Subscribe to realtime changes to the specified topic (\"*\" or record id).\n *\n * If `topic` is the wildcard \"*\", then this method will subscribe to\n * any record changes in the collection.\n *\n * If `topic` is a record id, then this method will subscribe only\n * to changes of the specified record id.\n *\n * It's OK to subscribe multiple times to the same topic.\n * You can use the returned `UnsubscribeFunc` to remove only a single subscription.\n * Or use `unsubscribe(topic)` if you want to remove all subscriptions attached to the topic.\n */\n async subscribe(topic: string, callback: (data: RecordSubscription) => void): Promise\n\n async subscribe(\n topicOrCallback: string|((data: RecordSubscription) => void),\n callback?: (data: RecordSubscription) => void\n ): Promise {\n if (typeof topicOrCallback === 'function') {\n console.warn(\"PocketBase: subscribe(callback) is deprecated. Please replace it with subscribe('*', callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName, topicOrCallback);\n }\n\n if (!callback) {\n throw new Error(\"Missing subscription callback.\");\n }\n\n if (topicOrCallback === \"\") {\n throw new Error(\"Missing topic.\");\n }\n\n let topic = this.collectionIdOrName;\n if (topicOrCallback !== \"*\") {\n topic += ('/' + topicOrCallback);\n }\n\n return this.client.realtime.subscribe(topic, callback)\n }\n\n /**\n * Unsubscribe from all subscriptions of the specified topic\n * (\"*\" or record id).\n *\n * If `topic` is not set, then this method will unsubscribe from\n * all subscriptions associated to the current collection.\n */\n async unsubscribe(topic?: string): Promise {\n // unsubscribe wildcard topic\n if (topic === \"*\") {\n return this.client.realtime.unsubscribe(this.collectionIdOrName);\n }\n\n // unsubscribe recordId topic\n if (topic) {\n return this.client.realtime.unsubscribe(this.collectionIdOrName + \"/\" + topic);\n }\n\n // unsubscribe from everything related to the collection\n return this.client.realtime.unsubscribeByPrefix(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Crud handers\n // ---------------------------------------------------------------\n /**\n * @inheritdoc\n */\n getFullList(options?: RecordFullListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batch?: number, options?: RecordListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batchOrOptions?: number|RecordFullListOptions, options?: RecordListOptions): Promise> {\n if (typeof batchOrOptions == \"number\") {\n return super.getFullList(batchOrOptions, options);\n }\n\n const params = Object.assign({}, batchOrOptions, options);\n\n return super.getFullList(params);\n }\n\n /**\n * @inheritdoc\n */\n getList(page = 1, perPage = 30, options?: RecordListOptions): Promise> {\n return super.getList(page, perPage, options);\n }\n\n /**\n * @inheritdoc\n */\n getFirstListItem(filter: string, options?: RecordListOptions): Promise {\n return super.getFirstListItem(filter, options);\n }\n\n /**\n * @inheritdoc\n */\n getOne(id: string, options?: RecordOptions): Promise {\n return super.getOne(id, options);\n }\n\n /**\n * @inheritdoc\n */\n create(bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.create(bodyParams, options);\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(id: string, bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n if (\n // is record auth\n this.client.authStore.model?.id === item?.id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n if (\n success &&\n // is record auth\n this.client.authStore.model?.id === id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful collection authorization response.\n */\n protected authResponse(responseData: any): RecordAuthResponse {\n const record = this.decode(responseData?.record || {});\n\n this.client.authStore.save(responseData?.token, record);\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'record': record as any as T,\n });\n }\n\n /**\n * Returns all available collection auth methods.\n */\n listAuthMethods(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCollectionPath + '/auth-methods', options)\n .then((responseData: any) => {\n return Object.assign({}, responseData, {\n // normalize common fields\n 'usernamePassword': !!responseData?.usernamePassword,\n 'emailPassword': !!responseData?.emailPassword,\n 'authProviders': Array.isArray(responseData?.authProviders) ? responseData?.authProviders : [],\n });\n });\n }\n\n /**\n * Authenticate a single auth collection record via its username/email and password.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n */\n authWithPassword(usernameOrEmail: string, password: string, options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authWithPassword(usernameOrEmail, password, options?).\n */\n authWithPassword(usernameOrEmail: string, password: string, body?: any, query?: any): Promise>\n\n authWithPassword(usernameOrEmail: string, password: string, bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': usernameOrEmail,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(usernameOrEmail, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(usernameOrEmail, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-password', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Authenticate a single auth collection record with OAuth2 code.\n *\n * If you don't have an OAuth2 code you may also want to check `authWithOAuth2` method.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n options?: RecordOptions,\n ): Promise>\n\n /**\n * @deprecated\n * Consider using authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createdData, options?).\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n body?: any,\n query?: any\n ): Promise>\n\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n bodyOrOptions?: any,\n query?: any\n ): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'provider': provider,\n 'code': code,\n 'codeVerifier': codeVerifier,\n 'redirectUrl': redirectUrl,\n 'createData': createData,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, body?, query?) is deprecated. Consider replacing it with authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-oauth2', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * @deprecated This form of authWithOAuth2 is deprecated.\n *\n * Please use `authWithOAuth2Code()` OR its simplified realtime version\n * as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\n */\n async authWithOAuth2(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key: string]: any},\n bodyParams?: {[key: string]: any},\n queryParams?: RecordOptions,\n ): Promise>\n\n /**\n * Authenticate a single auth collection record with OAuth2\n * **without custom redirects, deeplinks or even page reload**.\n *\n * This method initializes a one-off realtime subscription and will\n * open a popup window with the OAuth2 vendor page to authenticate.\n * Once the external OAuth2 sign-in/sign-up flow is completed, the popup\n * window will be automatically closed and the OAuth2 data sent back\n * to the user through the previously established realtime connection.\n *\n * You can specify an optional `urlCallback` prop to customize\n * the default url `window.open` behavior.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n *\n * Example:\n *\n * ```js\n * const authData = await pb.collection(\"users\").authWithOAuth2({\n * provider: \"google\",\n * })\n * ```\n *\n * _Site-note_: when creating the OAuth2 app in the provider dashboard\n * you have to configure `https://yourdomain.com/api/oauth2-redirect`\n * as redirect URL.\n */\n async authWithOAuth2(options: OAuth2AuthConfig): Promise>\n\n async authWithOAuth2(...args: any): Promise> {\n // fallback to legacy format\n if (args.length > 1 || typeof args?.[0] === 'string') {\n console.warn(\"PocketBase: This form of authWithOAuth2() is deprecated and may get removed in the future. Please replace with authWithOAuth2Code() OR use the authWithOAuth2() realtime form as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\");\n return this.authWithOAuth2Code(\n args?.[0] || '',\n args?.[1] || '',\n args?.[2] || '',\n args?.[3] || '',\n args?.[4] || {},\n args?.[5] || {},\n args?.[6] || {},\n );\n }\n\n const config = args?.[0] || {};\n\n const authMethods = await this.listAuthMethods();\n\n const provider = authMethods.authProviders.find((p) => p.name === config.provider);\n if (!provider) {\n throw new ClientResponseError(new Error(`Missing or invalid provider \"${config.provider}\".`));\n }\n\n const redirectUrl = this.client.buildUrl('/api/oauth2-redirect');\n\n // initialize a one-off realtime service\n const realtime = new RealtimeService(this.client);\n\n // open a new popup window in case config.urlCallback is not set\n //\n // note: it is opened before the async call due to Safari restrictions\n // (see https://github.com/pocketbase/pocketbase/discussions/2429#discussioncomment-5943061)\n let eagerDefaultPopup: Window|null = null;\n if (!config.urlCallback) {\n eagerDefaultPopup = openBrowserPopup(undefined);\n }\n\n function cleanup() {\n eagerDefaultPopup?.close();\n realtime.unsubscribe();\n }\n\n return new Promise(async (resolve, reject) => {\n try {\n await realtime.subscribe('@oauth2', async (e) => {\n const oldState = realtime.clientId;\n\n try {\n if (!e.state || oldState !== e.state) {\n throw new Error(\"State parameters don't match.\");\n }\n\n // clear the non SendOptions props\n const options = Object.assign({}, config);\n delete options.provider;\n delete options.scopes;\n delete options.createData;\n delete options.urlCallback;\n\n const authData = await this.authWithOAuth2Code(\n provider.name,\n e.code,\n provider.codeVerifier,\n redirectUrl,\n config.createData,\n options,\n );\n\n resolve(authData);\n } catch (err) {\n reject(new ClientResponseError(err));\n }\n\n cleanup();\n });\n\n const replacements: {[key: string]: any} = {\n \"state\": realtime.clientId,\n }\n if (config.scopes?.length) {\n replacements[\"scope\"] = config.scopes.join(\" \");\n }\n\n const url = this._replaceQueryParams(provider.authUrl + redirectUrl, replacements);\n\n let urlCallback = config.urlCallback || function (url: string) {\n if (eagerDefaultPopup) {\n eagerDefaultPopup.location.href = url;\n } else {\n // it could have been blocked due to its empty initial url,\n // try again...\n eagerDefaultPopup = openBrowserPopup(url);\n }\n }\n\n await urlCallback(url);\n } catch (err) {\n cleanup();\n reject(new ClientResponseError(err));\n }\n });\n }\n\n /**\n * Refreshes the current authenticated record instance and\n * returns a new token and record data.\n *\n * On success this method also automatically updates the client's AuthStore.\n */\n authRefresh(options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise>\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-refresh', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Sends auth record password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-password-reset', options).then(() => true);\n }\n\n /**\n * Confirms auth record password reset request.\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n options?: CommonOptions,\n ): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(passwordResetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n body?: any,\n query?: any,\n ): Promise\n\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': passwordResetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(token, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(token, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Sends auth record verification email request.\n */\n requestVerification(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestVerification(email, options?).\n */\n requestVerification(email: string, body?: any, query?: any): Promise\n\n requestVerification(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestVerification(email, body?, query?) is deprecated. Consider replacing it with requestVerification(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-verification', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record email verification request.\n */\n confirmVerification(verificationToken: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmVerification(verificationToken, options?).\n */\n confirmVerification(verificationToken: string, body?: any, query?: any): Promise\n\n confirmVerification(verificationToken: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': verificationToken,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmVerification(token, body?, query?) is deprecated. Consider replacing it with confirmVerification(token, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-verification', options)\n .then(() => true);\n }\n\n /**\n * Sends an email change request to the authenticated record model.\n */\n requestEmailChange(newEmail: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestEmailChange(newEmail, options?).\n */\n requestEmailChange(newEmail: string, body?: any, query?: any): Promise\n\n requestEmailChange(newEmail: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'newEmail': newEmail,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestEmailChange(newEmail, body?, query?) is deprecated. Consider replacing it with requestEmailChange(newEmail, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-email-change', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record's new email address.\n */\n confirmEmailChange(emailChangeToken: string, password: string, options?: CommonOptions): Promise\n\n\n /**\n * @deprecated\n * Consider using confirmEmailChange(emailChangeToken, password, options?).\n */\n confirmEmailChange(emailChangeToken: string, password: string, body?: any, query?: any): Promise\n\n confirmEmailChange(emailChangeToken: string, password: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': emailChangeToken,\n 'password': password,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmEmailChange(token, password, body?, query?) is deprecated. Consider replacing it with confirmEmailChange(token, password, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-email-change', options)\n .then(() => true);\n }\n\n /**\n * Lists all linked external auth providers for the specified auth record.\n */\n listExternalAuths(recordId: string, options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths', options);\n }\n\n /**\n * Unlink a single external auth provider from the specified auth record.\n */\n unlinkExternalAuth(recordId: string, provider: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths/' + encodeURIComponent(provider), options)\n .then(() => true);\n }\n\n // ---------------------------------------------------------------\n\n // very rudimentary url query params replacement because at the moment\n // URL (and URLSearchParams) doesn't seem to be fully supported in React Native\n //\n // note: for details behind some of the decode/encode parsing check https://unixpapa.com/js/querystring.html\n private _replaceQueryParams(url: string, replacements: {[key: string]: any} = {}): string {\n let urlPath = url\n let query = \"\";\n\n const queryIndex = url.indexOf(\"?\");\n if (queryIndex >= 0) {\n urlPath = url.substring(0, url.indexOf(\"?\"));\n query = url.substring(url.indexOf(\"?\") + 1);\n }\n\n const parsedParams: {[key: string]: string} = {};\n\n // parse the query parameters\n const rawParams = query.split(\"&\");\n for (const param of rawParams) {\n if (param == \"\") {\n continue\n }\n\n const pair = param.split(\"=\");\n parsedParams[decodeURIComponent(pair[0].replace(/\\+/g,' '))] = decodeURIComponent((pair[1] || \"\").replace(/\\+/g,' '));\n }\n\n // apply the replacements\n for (let key in replacements) {\n if (!replacements.hasOwnProperty(key)) {\n continue;\n }\n\n if (replacements[key] == null) {\n delete parsedParams[key];\n } else {\n parsedParams[key] = replacements[key];\n }\n }\n\n // construct back the full query string\n query = \"\";\n for (let key in parsedParams) {\n if (!parsedParams.hasOwnProperty(key)) {\n continue;\n }\n\n if (query != \"\") {\n query += \"&\";\n }\n\n query += encodeURIComponent(key.replace(/%20/g,'+')) + \"=\" + encodeURIComponent(parsedParams[key].replace(/%20/g,'+'));\n }\n\n return query != \"\" ? (urlPath + \"?\" + query) : urlPath;\n }\n}\n\nfunction openBrowserPopup(url?: string): Window|null {\n if (typeof window === \"undefined\" || !window?.open) {\n throw new ClientResponseError(new Error(`Not in a browser context - please pass a custom urlCallback function.`));\n }\n\n let width = 1024;\n let height = 768;\n\n let windowWidth = window.innerWidth;\n let windowHeight = window.innerHeight;\n\n // normalize window size\n width = width > windowWidth ? windowWidth : width;\n height = height > windowHeight ? windowHeight : height;\n\n let left = (windowWidth / 2) - (width / 2);\n let top = (windowHeight / 2) - (height / 2);\n\n // note: we don't use the noopener and noreferrer attributes since\n // for some reason browser blocks such windows then url is undefined/blank\n return window.open(\n url,\n 'popup_window',\n 'width='+width+',height='+height+',top='+top+',left='+left+',resizable,menubar=no'\n );\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { CollectionModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport class CollectionService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/collections';\n }\n\n /**\n * Imports the provided collections.\n *\n * If `deleteMissing` is `true`, all local collections and schema fields,\n * that are not present in the imported configuration, WILL BE DELETED\n * (including their related records data)!\n */\n async import(\n collections: Array,\n deleteMissing: boolean = false,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PUT',\n 'body': {\n 'collections': collections,\n 'deleteMissing': deleteMissing,\n }\n }, options);\n\n return this.client.send(this.baseCrudPath + '/import', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ListResult, LogRequestModel } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n LogStatsOptions,\n} from '@/services/utils/options';\n\nexport interface HourlyStats {\n total: number;\n date: string;\n}\n\nexport class LogService extends BaseService {\n /**\n * Returns paginated logged requests list.\n */\n getRequestsList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({'method': 'GET'}, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send('/api/logs/requests', options);\n }\n\n /**\n * Returns a single logged request by its id.\n */\n getRequest(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/' + encodeURIComponent(id), options);\n }\n\n /**\n * Returns request logs statistics.\n */\n getRequestsStats(options?: LogStatsOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/stats', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface HealthCheckResponse {\n code: number;\n message: string;\n data: {[key: string]: any};\n}\n\nexport class HealthService extends BaseService {\n /**\n * Checks the health status of the api.\n */\n check(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/health', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions, FileOptions } from '@/services/utils/options';\n\nexport class FileService extends BaseService {\n /**\n * Builds and returns an absolute record file url for the provided filename.\n */\n getUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n if (\n !filename ||\n !record?.id ||\n !(record?.collectionId || record?.collectionName)\n ) {\n return '';\n }\n\n const parts = [];\n parts.push('api')\n parts.push('files')\n parts.push(encodeURIComponent(record.collectionId || record.collectionName))\n parts.push(encodeURIComponent(record.id))\n parts.push(encodeURIComponent(filename))\n\n let result = this.client.buildUrl(parts.join('/'));\n\n if (Object.keys(queryParams).length) {\n // normalize the download query param for consistency with the Dart sdk\n if (queryParams.download === false) {\n delete(queryParams.download);\n }\n\n const params = new URLSearchParams(queryParams);\n\n result += (result.includes('?') ? '&' : '?') + params;\n }\n\n return result\n }\n\n /**\n * Requests a new private file access token for the current auth model (admin or record).\n */\n getToken(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send('/api/files/token', options)\n .then((data) => data?.token || '');\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface BackupFileInfo {\n key: string;\n size: number;\n modified: string;\n}\n\nexport class BackupService extends BaseService {\n /**\n * Returns list with all available backup files.\n */\n getFullList(options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/backups', options);\n }\n\n /**\n * Initializes a new backup.\n */\n create(basename: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'name': basename,\n },\n }, options);\n\n return this.client.send('/api/backups', options)\n .then(() => true);\n }\n\n /**\n * Deletes a single backup file.\n */\n delete(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}`, options)\n .then(() => true);\n }\n\n /**\n * Initializes an app data restore from an existing backup.\n */\n restore(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}/restore`, options)\n .then(() => true);\n }\n\n /**\n * Builds a download url for a single existing backup using an\n * admin file token and the backup file key.\n *\n * The file token can be generated via `pb.files.getToken()`.\n */\n getDownloadUrl(token: string, key: string): string {\n return this.client.buildUrl(`/api/backups/${encodeURIComponent(key)}?token=${encodeURIComponent(token)}`);\n }\n}\n","import { ClientResponseError } from '@/ClientResponseError';\nimport { BaseAuthStore } from '@/stores/BaseAuthStore';\nimport { LocalAuthStore } from '@/stores/LocalAuthStore';\nimport { SettingsService } from '@/services/SettingsService';\nimport { AdminService } from '@/services/AdminService';\nimport { RecordService } from '@/services/RecordService';\nimport { CollectionService } from '@/services/CollectionService';\nimport { LogService } from '@/services/LogService';\nimport { RealtimeService } from '@/services/RealtimeService';\nimport { HealthService } from '@/services/HealthService';\nimport { FileService } from '@/services/FileService';\nimport { BackupService } from '@/services/BackupService';\nimport { SendOptions, FileOptions } from '@/services/utils/options';\n\n// list of known SendOptions keys (everything else is treated as query param)\nconst knownSendOptionsKeys = [\n 'requestKey',\n '$cancelKey',\n '$autoCancel',\n 'fetch',\n 'headers',\n 'body',\n 'query',\n 'params',\n // ---,\n 'cache',\n 'credentials',\n 'headers',\n 'integrity',\n 'keepalive',\n 'method',\n 'mode',\n 'redirect',\n 'referrer',\n 'referrerPolicy',\n 'signal',\n 'window',\n];\n\nexport interface BeforeSendResult {\n [key: string]: any, // for backward compatibility\n url?: string,\n options?: {[key: string]: any}\n}\n\n/**\n * PocketBase JS Client.\n */\nexport default class Client {\n /**\n * The base PocketBase backend url address (eg. 'http://127.0.0.1.8090').\n */\n baseUrl: string;\n\n /**\n * Hook that get triggered right before sending the fetch request,\n * allowing you to inspect and modify the url and request options.\n *\n * For list of the possible options check https://developer.mozilla.org/en-US/docs/Web/API/fetch#options\n *\n * You can return a non-empty result object `{ url, options }` to replace the url and request options entirely.\n *\n * Example:\n * ```js\n * client.beforeSend = function (url, options) {\n * options.headers = Object.assign({}, options.headers, {\n * 'X-Custom-Header': 'example',\n * });\n *\n * return { url, options }\n * };\n * ```\n */\n beforeSend?: (url: string, options: SendOptions) => BeforeSendResult|Promise;\n\n /**\n * Hook that get triggered after successfully sending the fetch request,\n * allowing you to inspect/modify the response object and its parsed data.\n *\n * Returns the new Promise resolved `data` that will be returned to the client.\n *\n * Example:\n * ```js\n * client.afterSend = function (response, data) {\n * if (response.status != 200) {\n * throw new ClientResponseError({\n * url: response.url,\n * status: response.status,\n * data: data,\n * });\n * }\n *\n * return data;\n * };\n * ```\n */\n afterSend?: (response: Response, data: any) => any;\n\n /**\n * Optional language code (default to `en-US`) that will be sent\n * with the requests to the server as `Accept-Language` header.\n */\n lang: string;\n\n /**\n * A replaceable instance of the local auth store service.\n */\n authStore: BaseAuthStore;\n\n /**\n * An instance of the service that handles the **Settings APIs**.\n */\n readonly settings: SettingsService;\n\n /**\n * An instance of the service that handles the **Admin APIs**.\n */\n readonly admins: AdminService;\n\n /**\n * An instance of the service that handles the **Collection APIs**.\n */\n readonly collections: CollectionService;\n\n /**\n * An instance of the service that handles the **File APIs**.\n */\n readonly files: FileService;\n\n /**\n * An instance of the service that handles the **Log APIs**.\n */\n readonly logs: LogService;\n\n /**\n * An instance of the service that handles the **Realtime APIs**.\n */\n readonly realtime: RealtimeService;\n\n /**\n * An instance of the service that handles the **Health APIs**.\n */\n readonly health: HealthService;\n\n /**\n * An instance of the service that handles the **Backup APIs**.\n */\n readonly backups: BackupService;\n\n private cancelControllers: { [key: string]: AbortController } = {};\n private recordServices: { [key: string]: RecordService } = {};\n private enableAutoCancellation: boolean = true;\n\n constructor(\n baseUrl = '/',\n authStore?: BaseAuthStore | null,\n lang = 'en-US',\n ) {\n this.baseUrl = baseUrl;\n this.lang = lang;\n this.authStore = authStore || new LocalAuthStore();\n\n // services\n this.admins = new AdminService(this);\n this.collections = new CollectionService(this);\n this.files = new FileService(this);\n this.logs = new LogService(this);\n this.settings = new SettingsService(this);\n this.realtime = new RealtimeService(this);\n this.health = new HealthService(this);\n this.backups = new BackupService(this);\n }\n\n /**\n * Returns the RecordService associated to the specified collection.\n *\n * @param {string} idOrName\n * @return {RecordService}\n */\n collection(idOrName: string): RecordService {\n if (!this.recordServices[idOrName]) {\n this.recordServices[idOrName] = new RecordService(this, idOrName);\n }\n\n return this.recordServices[idOrName];\n }\n\n /**\n * Globally enable or disable auto cancellation for pending duplicated requests.\n */\n autoCancellation(enable: boolean): Client {\n this.enableAutoCancellation = !!enable;\n\n return this;\n }\n\n /**\n * Cancels single request by its cancellation key.\n */\n cancelRequest(requestKey: string): Client {\n if (this.cancelControllers[requestKey]) {\n this.cancelControllers[requestKey].abort();\n delete this.cancelControllers[requestKey];\n }\n\n return this;\n }\n\n /**\n * Cancels all pending requests.\n */\n cancelAllRequests(): Client {\n for (let k in this.cancelControllers) {\n this.cancelControllers[k].abort();\n }\n\n this.cancelControllers = {};\n\n return this;\n }\n\n /**\n * Legacy alias of `pb.files.getUrl()`.\n */\n getFileUrl(\n record: Pick<{[key:string]:any}, 'id' | 'collectionId' | 'collectionName'>,\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n return this.files.getUrl(record, filename, queryParams);\n }\n\n /**\n * Builds a full client url by safely concatenating the provided path.\n */\n buildUrl(path: string): string {\n let url = this.baseUrl;\n\n // construct an absolute base url if in a browser environment\n if (\n typeof window !== 'undefined' &&\n !!window.location &&\n !url.startsWith('https://') &&\n !url.startsWith('http://')\n ) {\n url = window.location.origin?.endsWith('/') ?\n window.location.origin.substring(0, window.location.origin.length - 1) :\n (window.location.origin || '');\n\n if (!this.baseUrl.startsWith('/')) {\n url += window.location.pathname || '/';\n url += url.endsWith('/') ? '' : '/';\n }\n\n url += this.baseUrl;\n }\n\n // concatenate the path\n if (path) {\n url += url.endsWith('/') ? '' : '/'; // append trailing slash if missing\n url += path.startsWith('/') ? path.substring(1) : path;\n }\n\n return url;\n }\n\n /**\n * Sends an api http request.\n */\n async send(path: string, options: SendOptions): Promise {\n options = this.initSendOptions(path, options);\n\n // build url + path\n let url = this.buildUrl(path);\n\n // serialize the query parameters\n if (typeof options.query !== 'undefined') {\n const query = this.serializeQueryParams(options.query)\n if (query) {\n url += (url.includes('?') ? '&' : '?') + query;\n }\n delete options.query;\n }\n\n if (this.beforeSend) {\n const result = Object.assign({}, await this.beforeSend(url, options));\n if (typeof result.url !== 'undefined' || typeof result.options !== 'undefined') {\n url = result.url || url;\n options = result.options || options;\n } else if (Object.keys(result).length) {\n // legacy behavior\n options = result as SendOptions;\n console?.warn && console.warn('Deprecated format of beforeSend return: please use `return { url, options }`, instead of `return options`.');\n }\n }\n\n // ensures that the json body is serialized\n if (\n this.getHeader(options.headers, 'Content-Type') == 'application/json' &&\n options.body && typeof options.body !== 'string'\n ) {\n options.body = JSON.stringify(options.body);\n }\n\n const fetchFunc = options.fetch || fetch;\n\n // send the request\n return fetchFunc(url, options)\n .then(async (response) => {\n let data : any = {};\n\n try {\n data = await response.json();\n } catch (_) {\n // all api responses are expected to return json\n // with the exception of the realtime event and 204\n }\n\n if (this.afterSend) {\n data = await this.afterSend(response, data);\n }\n\n if (response.status >= 400) {\n throw new ClientResponseError({\n url: response.url,\n status: response.status,\n data: data,\n });\n }\n\n return data as T;\n }).catch((err) => {\n // wrap to normalize all errors\n throw new ClientResponseError(err);\n });\n }\n\n /**\n * Shallow copy the provided object and takes care to initialize\n * any options required to preserve the backward compatability.\n *\n * @param {SendOptions} options\n * @return {SendOptions}\n */\n private initSendOptions(path: string, options: SendOptions): SendOptions {\n options = Object.assign({ method: 'GET' } as SendOptions, options)\n options.query = options.query || {};\n\n // auto convert the body to FormData, if needed\n options.body = this.convertToFormDataIfNeeded(options.body);\n\n // move unknown send options as query parameters\n for (let key in options) {\n if (knownSendOptionsKeys.includes(key)) {\n continue\n }\n\n options.query[key] = options[key];\n delete (options[key]);\n }\n\n // requestKey normalizations for backward-compatibility\n // ---\n options.query = Object.assign({}, options.params, options.query);\n if (typeof options.requestKey === 'undefined') {\n if (options.$autoCancel === false || options.query.$autoCancel === false) {\n options.requestKey = null;\n } else if (options.$cancelKey || options.query.$cancelKey) {\n options.requestKey = options.$cancelKey || options.query.$cancelKey;\n }\n }\n // remove the deprecated special cancellation params from the other query params\n delete options.$autoCancel;\n delete options.query.$autoCancel;\n delete options.$cancelKey;\n delete options.query.$cancelKey;\n // ---\n\n // add the json header, if not explicitly set\n // (for FormData body the Content-Type header should be skipped since the boundary is autogenerated)\n if (\n this.getHeader(options.headers, 'Content-Type') === null &&\n !this.isFormData(options.body)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Content-Type': 'application/json',\n });\n }\n\n // add Accept-Language header, if not explicitly set\n if (this.getHeader(options.headers, 'Accept-Language') === null) {\n options.headers = Object.assign({}, options.headers, {\n 'Accept-Language': this.lang,\n });\n }\n\n // check if Authorization header can be added\n if (\n // has valid token\n this.authStore.token &&\n // auth header is not explicitly set\n (this.getHeader(options.headers, 'Authorization') === null)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Authorization': this.authStore.token,\n });\n }\n\n // handle auto cancelation for duplicated pending request\n if (this.enableAutoCancellation && options.requestKey !== null) {\n const requestKey = options.requestKey || ((options.method || 'GET') + path);\n\n delete options.requestKey;\n\n // cancel previous pending requests\n this.cancelRequest(requestKey);\n\n const controller = new AbortController();\n this.cancelControllers[requestKey] = controller;\n options.signal = controller.signal;\n }\n\n return options\n }\n\n /**\n * Converts analyzes the provided body and converts it to FormData\n * in case a plain object with File/Blob values is used.\n */\n private convertToFormDataIfNeeded(body: any): any {\n if (\n typeof FormData === 'undefined' ||\n typeof body === \"undefined\" ||\n typeof body !== \"object\" ||\n body === null ||\n this.isFormData(body) ||\n !this.hasBlobField(body)\n ) {\n return body;\n }\n\n const form = new FormData();\n\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let val of values) {\n form.append(key, val);\n }\n }\n\n return form;\n }\n\n /**\n * Checks if the submitted body object has at least one Blob/File field.\n */\n private hasBlobField(body: {[key:string]: any}): boolean {\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let v of values) {\n if (\n (typeof Blob !== 'undefined' && v instanceof Blob) ||\n (typeof File !== 'undefined' && v instanceof File)\n ) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /**\n * Extracts the header with the provided name in case-insensitive manner.\n * Returns `null` if no header matching the name is found.\n */\n private getHeader(headers: {[key:string]:string}|undefined, name: string): string|null {\n headers = headers || {};\n name = name.toLowerCase();\n\n for (let key in headers) {\n if (key.toLowerCase() == name) {\n return headers[key];\n }\n }\n\n return null;\n }\n\n /**\n * Loosely checks if the specified body is a FormData instance.\n */\n private isFormData(body: any): boolean {\n return body && (\n // we are checking the constructor name because FormData\n // is not available natively in some environments and the\n // polyfill(s) may not be globally accessible\n body.constructor.name === 'FormData' ||\n // fallback to global FormData instance check\n // note: this is needed because the constructor.name could be different in case of\n // custom global FormData implementation, eg. React Native on Android/iOS\n (typeof FormData !== 'undefined' && body instanceof FormData)\n )\n }\n\n /**\n * Serializes the provided query parameters into a query string.\n */\n private serializeQueryParams(params: {[key: string]: any}): string {\n const result: Array = [];\n for (const key in params) {\n if (params[key] === null) {\n // skip null query params\n continue;\n }\n\n const value = params[key];\n const encodedKey = encodeURIComponent(key);\n\n if (Array.isArray(value)) {\n // repeat array params\n for (const v of value) {\n result.push(encodedKey + '=' + encodeURIComponent(v));\n }\n } else if (value instanceof Date) {\n result.push(encodedKey + '=' + encodeURIComponent(value.toISOString()));\n } else if (typeof value !== null && typeof value === 'object') {\n result.push(encodedKey + '=' + encodeURIComponent(JSON.stringify(value)));\n } else {\n result.push(encodedKey + '=' + encodeURIComponent(value));\n }\n }\n\n return result.join('&');\n }\n}\n"],"names":["ClientResponseError","Error","constructor","errData","super","this","url","status","response","isAbort","originalError","Object","setPrototypeOf","prototype","data","DOMException","name","message","_a","_d","_c","_b","cause","includes","toJSON","assign","fieldContentRegExp","cookieSerialize","val","options","opt","encode","defaultEncode","test","TypeError","value","result","maxAge","isNaN","isFinite","Math","floor","domain","path","expires","isDate","toString","call","Date","valueOf","toUTCString","httpOnly","secure","priority","toLowerCase","sameSite","defaultDecode","indexOf","decodeURIComponent","encodeURIComponent","atobPolyfill","getTokenPayload","token","encodedPayload","split","map","c","charCodeAt","slice","join","JSON","parse","e","atob","input","str","String","replace","length","bs","buffer","bc","idx","output","charAt","fromCharCode","defaultCookieKey","BaseAuthStore","baseToken","baseModel","_onChangeCallbacks","model","isValid","isTokenExpired","expirationThreshold","payload","keys","exp","now","isAdmin","type","isAuthRecord","save","triggerChange","clear","loadFromCookie","cookie","key","rawData","cookieParse","decode","index","eqIdx","endIdx","lastIndexOf","trim","undefined","_","Array","isArray","exportToCookie","defaultOptions","stringify","resultLength","Blob","size","id","email","extraProps","prop","onChange","callback","fireImmediately","push","i","splice","LocalAuthStore","storageKey","storageFallback","_bindStorageEvent","_storageGet","_storageSet","_storageRemove","window","localStorage","rawValue","getItem","normalizedVal","setItem","removeItem","addEventListener","BaseService","client","SettingsService","getAll","method","send","update","bodyParams","body","testS3","filesystem","then","testEmail","toEmail","emailTemplate","template","generateAppleClientSecret","clientId","teamId","keyId","privateKey","duration","CrudService","getFullList","batchOrqueryParams","_getFullList","batch","getList","page","perPage","query","baseCrudPath","responseData","items","item","getFirstListItem","filter","requestKey","skipTotal","code","getOne","create","batchSize","request","__awaiter","list","concat","normalizeLegacyOptionsArgs","legacyWarn","baseOptions","bodyOrOptions","hasQuery","console","warn","AdminService","authStore","collectionId","delete","success","authResponse","admin","authWithPassword","password","identity","bind","authRefresh","requestPasswordReset","confirmPasswordReset","resetToken","passwordConfirm","RealtimeService","eventSource","subscriptions","lastSentTopics","maxConnectTimeout","reconnectAttempts","maxReconnectAttempts","Infinity","predefinedReconnectIntervals","pendingConnects","isConnected","subscribe","topic","listener","msgEvent","submitSubscriptions","connect","unsubscribeByTopicAndListener","unsubscribe","hasSubscriptionListeners","removeEventListener","disconnect","unsubscribeByPrefix","topicPrefix","hasAtleastOneTopic","startsWith","exist","topicToCheck","addAllSubscriptionListeners","getNonEmptySubscriptionTopics","getSubscriptionsCancelKey","catch","err","removeAllSubscriptionListeners","Promise","resolve","reject","initConnect","clearTimeout","connectTimeoutId","setTimeout","connectErrorHandler","EventSource","buildUrl","onerror","lastEventId","retries","hasUnsentSubscriptions","p","reconnectTimeoutId","latestTopics","t","timeout","fromReconnect","cancelRequest","close","RecordService","collectionIdOrName","baseCollectionPath","subscribeOne","recordId","realtime","topicOrCallback","batchOrOptions","params","collectionName","record","listAuthMethods","usernamePassword","emailPassword","authProviders","usernameOrEmail","authWithOAuth2Code","provider","codeVerifier","redirectUrl","createData","authWithOAuth2","args","config","find","eagerDefaultPopup","cleanup","urlCallback","openBrowserPopup","oldState","state","scopes","authData","replacements","_replaceQueryParams","authUrl","location","href","passwordResetToken","requestVerification","confirmVerification","verificationToken","requestEmailChange","newEmail","confirmEmailChange","emailChangeToken","listExternalAuths","unlinkExternalAuth","urlPath","substring","parsedParams","rawParams","param","pair","hasOwnProperty","open","width","height","windowWidth","innerWidth","windowHeight","innerHeight","left","top","CollectionService","import","collections","deleteMissing","LogService","getRequestsList","getRequest","getRequestsStats","HealthService","check","FileService","getUrl","filename","queryParams","parts","download","URLSearchParams","getToken","BackupService","basename","restore","getDownloadUrl","knownSendOptionsKeys","Client","baseUrl","lang","cancelControllers","recordServices","enableAutoCancellation","admins","files","logs","settings","health","backups","collection","idOrName","autoCancellation","enable","abort","cancelAllRequests","k","getFileUrl","origin","endsWith","pathname","initSendOptions","serializeQueryParams","beforeSend","getHeader","headers","fetch","json","afterSend","convertToFormDataIfNeeded","$autoCancel","$cancelKey","isFormData","Authorization","controller","AbortController","signal","FormData","hasBlobField","form","values","append","v","File","encodedKey","toISOString"],"mappings":"mcAIM,MAAOA,4BAA4BC,MAOrC,WAAAC,CAAYC,eACRC,MAAM,uBAPVC,KAAGC,IAA8B,GACjCD,KAAME,OAA2B,EACjCF,KAAQG,SAAyB,GACjCH,KAAOI,SAA0B,EACjCJ,KAAaK,cAAoB,KAO7BC,OAAOC,eAAeP,KAAML,oBAAoBa,WAEhC,OAAZV,GAAuC,iBAAZA,IAC3BE,KAAKC,IAAuC,iBAAhBH,EAAQG,IAAmBH,EAAQG,IAAM,GACrED,KAAKE,OAA0C,iBAAnBJ,EAAQI,OAAsBJ,EAAQI,OAAS,EAC3EF,KAAKI,UAAkBN,EAAQM,QAC/BJ,KAAKK,cAAgBP,EAAQO,cAEJ,OAArBP,EAAQK,UAAiD,iBAArBL,EAAQK,SAC5CH,KAAKG,SAAYL,EAAQK,SACD,OAAjBL,EAAQW,MAAyC,iBAAjBX,EAAQW,KAC/CT,KAAKG,SAAYL,EAAQW,KAEzBT,KAAKG,SAAY,IAIpBH,KAAKK,eAAmBP,aAAmBH,sBAC5CK,KAAKK,cAAgBP,GAGG,oBAAjBY,cAAgC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mBAAmBgD,GAEtC,GAAIW,MAAMC,QAAQpF,GAEd,IAAK,MAAMqX,KAAKrX,EACZC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmB6V,SAE/CrX,aAAiBa,KACxBZ,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBxB,EAAMwX,gBAChC,cAAVxX,GAAmC,iBAAVA,EACvCC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBW,KAAKoD,UAAUvF,KAEjEC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBxB,GAEzD,CAED,OAAOC,EAAOiC,KAAK,IACtB"} \ No newline at end of file +{"version":3,"file":"pocketbase.iife.js","sources":["../src/ClientResponseError.ts","../src/stores/utils/cookie.ts","../src/stores/utils/jwt.ts","../src/stores/BaseAuthStore.ts","../src/stores/LocalAuthStore.ts","../src/services/utils/BaseService.ts","../src/services/SettingsService.ts","../src/services/utils/CrudService.ts","../src/services/utils/legacy.ts","../src/services/AdminService.ts","../src/services/RealtimeService.ts","../src/services/RecordService.ts","../src/services/CollectionService.ts","../src/services/LogService.ts","../src/services/HealthService.ts","../src/services/FileService.ts","../src/services/BackupService.ts","../src/Client.ts"],"sourcesContent":["/**\n * ClientResponseError is a custom Error class that is intended to wrap\n * and normalize any error thrown by `Client.send()`.\n */\nexport class ClientResponseError extends Error {\n url: string = '';\n status: number = 0;\n response: {[key: string]: any} = {};\n isAbort: boolean = false;\n originalError: any = null;\n\n constructor(errData?: any) {\n super(\"ClientResponseError\");\n\n // Set the prototype explicitly.\n // https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\n Object.setPrototypeOf(this, ClientResponseError.prototype);\n\n if (errData !== null && typeof errData === 'object') {\n this.url = typeof errData.url === 'string' ? errData.url : '';\n this.status = typeof errData.status === 'number' ? errData.status : 0;\n this.isAbort = !!errData.isAbort;\n this.originalError = errData.originalError;\n\n if (errData.response !== null && typeof errData.response === 'object') {\n this.response = errData.response;\n } else if (errData.data !== null && typeof errData.data === 'object') {\n this.response = errData.data;\n } else {\n this.response = {};\n }\n }\n\n if (!this.originalError && !(errData instanceof ClientResponseError)) {\n this.originalError = errData;\n }\n\n if (typeof DOMException !== 'undefined' && errData instanceof DOMException) {\n this.isAbort = true;\n }\n\n this.name = \"ClientResponseError \" + this.status;\n this.message = this.response?.message;\n if (!this.message) {\n if (this.isAbort) {\n this.message = 'The request was autocancelled. You can find more info in https://github.com/pocketbase/js-sdk#auto-cancellation.';\n } else if (this.originalError?.cause?.message?.includes(\"ECONNREFUSED ::1\")) {\n this.message = 'Failed to connect to the PocketBase server. Try changing the SDK URL from localhost to 127.0.0.1 (https://github.com/pocketbase/js-sdk/issues/21).';\n } else {\n this.message = 'Something went wrong while processing your request.';\n }\n }\n }\n\n /**\n * Alias for `this.response` to preserve the backward compatibility.\n */\n get data() {\n return this.response;\n }\n\n /**\n * Make a POJO's copy of the current error class instance.\n * @see https://github.com/vuex-orm/vuex-orm/issues/255\n */\n toJSON() {\n return { ...this };\n }\n}\n","/**\n * -------------------------------------------------------------------\n * Simple cookie parse and serialize utilities mostly based on the\n * node module https://github.com/jshttp/cookie.\n * -------------------------------------------------------------------\n */\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\nconst fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;\n\nexport interface ParseOptions{\n decode?: (val: string) => string,\n}\n\n/**\n* Parses the given cookie header string into an object\n* The object has the various cookies as keys(names) => values\n*/\nexport function cookieParse(str: string, options?: ParseOptions): { [key: string]: any } {\n const result: { [key: string]: any } = {};\n\n if (typeof str !== 'string') {\n return result;\n }\n\n const opt = Object.assign({}, options || {});\n const decode = opt.decode || defaultDecode;\n\n let index = 0;\n while (index < str.length) {\n const eqIdx = str.indexOf('=', index);\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break;\n }\n\n let endIdx = str.indexOf(';', index);\n\n if (endIdx === -1) {\n endIdx = str.length;\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(';', eqIdx - 1) + 1;\n continue;\n }\n\n const key = str.slice(index, eqIdx).trim();\n\n // only assign once\n if (undefined === result[key]) {\n let val = str.slice(eqIdx + 1, endIdx).trim();\n\n // quoted values\n if (val.charCodeAt(0) === 0x22) {\n val = val.slice(1, -1);\n }\n\n try {\n result[key] = decode(val);\n } catch (_) {\n result[key] = val; // no decoding\n }\n }\n\n index = endIdx + 1;\n }\n\n return result;\n};\n\nexport interface SerializeOptions {\n encode?: (val: string | number | boolean) => string,\n maxAge?: number,\n domain?: string,\n path?: string,\n expires?: Date,\n httpOnly?: boolean,\n secure?: boolean,\n priority?: string,\n sameSite?: boolean|string,\n}\n\n/**\n * Serialize data into a cookie header.\n *\n * Serialize the a name value pair into a cookie string suitable for\n * http headers. An optional options object specified cookie parameters.\n *\n * ```js\n * cookieSerialize('foo', 'bar', { httpOnly: true }) // \"foo=bar; httpOnly\"\n * ```\n */\nexport function cookieSerialize(name: string, val: string, options?: SerializeOptions): string {\n const opt = Object.assign({}, options || {});\n const encode = opt.encode || defaultEncode;\n\n if (!fieldContentRegExp.test(name)) {\n throw new TypeError('argument name is invalid');\n }\n\n const value = encode(val);\n\n if (value && !fieldContentRegExp.test(value)) {\n throw new TypeError('argument val is invalid');\n }\n\n let result = name + '=' + value;\n\n if (opt.maxAge != null) {\n const maxAge = opt.maxAge - 0;\n\n if (isNaN(maxAge) || !isFinite(maxAge)) {\n throw new TypeError('option maxAge is invalid');\n }\n\n result += '; Max-Age=' + Math.floor(maxAge);\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new TypeError('option domain is invalid');\n }\n\n result += '; Domain=' + opt.domain;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new TypeError('option path is invalid');\n }\n\n result += '; Path=' + opt.path;\n }\n\n if (opt.expires) {\n if (!isDate(opt.expires) || isNaN(opt.expires.valueOf())) {\n throw new TypeError('option expires is invalid');\n }\n\n result += '; Expires=' + opt.expires.toUTCString();\n }\n\n if (opt.httpOnly) {\n result += '; HttpOnly';\n }\n\n if (opt.secure) {\n result += '; Secure';\n }\n\n if (opt.priority) {\n const priority = typeof opt.priority === 'string' ? opt.priority.toLowerCase() : opt.priority;\n\n switch (priority) {\n case 'low':\n result += '; Priority=Low';\n break;\n case 'medium':\n result += '; Priority=Medium';\n break;\n case 'high':\n result += '; Priority=High';\n break;\n default:\n throw new TypeError('option priority is invalid');\n }\n }\n\n if (opt.sameSite) {\n const sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;\n\n switch (sameSite) {\n case true:\n result += '; SameSite=Strict';\n break;\n case 'lax':\n result += '; SameSite=Lax';\n break;\n case 'strict':\n result += '; SameSite=Strict';\n break;\n case 'none':\n result += '; SameSite=None';\n break;\n default:\n throw new TypeError('option sameSite is invalid');\n }\n }\n\n return result;\n};\n\n/**\n * Default URL-decode string value function.\n * Optimized to skip native call when no `%`.\n */\nfunction defaultDecode(val: string): string {\n return val.indexOf('%') !== -1\n ? decodeURIComponent(val)\n : val;\n}\n\n/**\n * Default URL-encode value function.\n */\nfunction defaultEncode(val: string | number | boolean): string {\n return encodeURIComponent(val);\n}\n\n/**\n * Determines if value is a Date.\n */\nfunction isDate(val: any): boolean {\n return (\n Object.prototype.toString.call(val) === '[object Date]' ||\n val instanceof Date\n );\n}\n","let atobPolyfill: Function;\nif (typeof atob === 'function') {\n atobPolyfill = atob\n} else {\n /**\n * The code was extracted from:\n * https://github.com/davidchambers/Base64.js\n */\n atobPolyfill = (input: any) => {\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\n let str = String(input).replace(/=+$/, \"\");\n if (str.length % 4 == 1) {\n throw new Error(\"'atob' failed: The string to be decoded is not correctly encoded.\");\n }\n\n for (\n // initialize result and counters\n var bc = 0, bs, buffer, idx = 0, output = \"\";\n // get next character\n (buffer = str.charAt(idx++));\n // character found in table? initialize bit storage and add its ascii value;\n ~buffer &&\n ((bs = bc % 4 ? (bs as any) * 64 + buffer : buffer),\n // and if not first of each 4 characters,\n // convert the first 8 bits to one ascii character\n bc++ % 4) ?\n (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)))) :\n 0\n ) {\n // try to find character in table (0-63, not found => -1)\n buffer = chars.indexOf(buffer);\n }\n\n return output;\n };\n}\n\n/**\n * Returns JWT token's payload data.\n */\nexport function getTokenPayload(token: string): { [key: string]: any } {\n if (token) {\n try {\n const encodedPayload = decodeURIComponent(atobPolyfill(token.split('.')[1]).split('').map(function (c: string) {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n }).join(''));\n\n return JSON.parse(encodedPayload) || {};\n } catch (e) {\n }\n }\n\n return {};\n}\n\n/**\n * Checks whether a JWT token is expired or not.\n * Tokens without `exp` payload key are considered valid.\n * Tokens with empty payload (eg. invalid token strings) are considered expired.\n *\n * @param token The token to check.\n * @param [expirationThreshold] Time in seconds that will be subtracted from the token `exp` property.\n */\nexport function isTokenExpired(token: string, expirationThreshold = 0): boolean {\n let payload = getTokenPayload(token);\n\n if (\n Object.keys(payload).length > 0 &&\n (!payload.exp || (payload.exp - expirationThreshold) > (Date.now() / 1000))\n ) {\n return false;\n }\n\n return true;\n}\n","import { cookieParse, cookieSerialize, SerializeOptions } from '@/stores/utils/cookie';\nimport { isTokenExpired, getTokenPayload } from '@/stores/utils/jwt';\nimport { RecordModel, AdminModel } from '@/services/utils/dtos';\n\nexport type AuthModel = RecordModel|AdminModel|null;\n\nexport type OnStoreChangeFunc = (token: string, model: AuthModel) => void;\n\nconst defaultCookieKey = 'pb_auth';\n\n/**\n * Base AuthStore class that is intended to be extended by all other\n * PocketBase AuthStore implementations.\n */\nexport abstract class BaseAuthStore {\n protected baseToken: string = '';\n protected baseModel: AuthModel = null;\n\n private _onChangeCallbacks: Array = [];\n\n /**\n * Retrieves the stored token (if any).\n */\n get token(): string {\n return this.baseToken;\n }\n\n /**\n * Retrieves the stored model data (if any).\n */\n get model(): AuthModel {\n return this.baseModel;\n }\n\n /**\n * Loosely checks if the store has valid token (aka. existing and unexpired exp claim).\n */\n get isValid(): boolean {\n return !isTokenExpired(this.token);\n }\n\n /**\n * Checks whether the current store state is for admin authentication.\n */\n get isAdmin(): boolean {\n return getTokenPayload(this.token).type === \"admin\";\n }\n\n /**\n * Checks whether the current store state is for auth record authentication.\n */\n get isAuthRecord(): boolean {\n return getTokenPayload(this.token).type === \"authRecord\";\n }\n\n /**\n * Saves the provided new token and model data in the auth store.\n */\n save(token: string, model?: AuthModel): void {\n this.baseToken = token || '';\n this.baseModel = model || null;\n\n this.triggerChange();\n }\n\n /**\n * Removes the stored token and model data form the auth store.\n */\n clear(): void {\n this.baseToken = '';\n this.baseModel = null;\n this.triggerChange();\n }\n\n /**\n * Parses the provided cookie string and updates the store state\n * with the cookie's token and model data.\n *\n * NB! This function doesn't validate the token or its data.\n * Usually this isn't a concern if you are interacting only with the\n * PocketBase API because it has the proper server-side security checks in place,\n * but if you are using the store `isValid` state for permission controls\n * in a node server (eg. SSR), then it is recommended to call `authRefresh()`\n * after loading the cookie to ensure an up-to-date token and model state.\n * For example:\n *\n * ```js\n * pb.authStore.loadFromCookie(\"cookie string...\");\n *\n * try {\n * // get an up-to-date auth store state by veryfing and refreshing the loaded auth model (if any)\n * pb.authStore.isValid && await pb.collection('users').authRefresh();\n * } catch (_) {\n * // clear the auth store on failed refresh\n * pb.authStore.clear();\n * }\n * ```\n */\n loadFromCookie(cookie: string, key = defaultCookieKey): void {\n const rawData = cookieParse(cookie || '')[key] || '';\n\n let data: { [key: string]: any } = {};\n try {\n data = JSON.parse(rawData);\n // normalize\n if (typeof data === null || typeof data !== 'object' || Array.isArray(data)) {\n data = {};\n }\n } catch (_) {}\n\n this.save(data.token || '', data.model || null);\n }\n\n /**\n * Exports the current store state as cookie string.\n *\n * By default the following optional attributes are added:\n * - Secure\n * - HttpOnly\n * - SameSite=Strict\n * - Path=/\n * - Expires={the token expiration date}\n *\n * NB! If the generated cookie exceeds 4096 bytes, this method will\n * strip the model data to the bare minimum to try to fit within the\n * recommended size in https://www.rfc-editor.org/rfc/rfc6265#section-6.1.\n */\n exportToCookie(options?: SerializeOptions, key = defaultCookieKey): string {\n const defaultOptions: SerializeOptions = {\n secure: true,\n sameSite: true,\n httpOnly: true,\n path: \"/\",\n };\n\n // extract the token expiration date\n const payload = getTokenPayload(this.token);\n if (payload?.exp) {\n defaultOptions.expires = new Date(payload.exp * 1000);\n } else {\n defaultOptions.expires = new Date('1970-01-01');\n }\n\n // merge with the user defined options\n options = Object.assign({}, defaultOptions, options);\n\n const rawData = {\n token: this.token,\n model: this.model ? JSON.parse(JSON.stringify(this.model)) : null,\n };\n\n let result = cookieSerialize(key, JSON.stringify(rawData), options);\n\n const resultLength = typeof Blob !== 'undefined' ?\n (new Blob([result])).size : result.length;\n\n // strip down the model data to the bare minimum\n if (rawData.model && resultLength > 4096) {\n rawData.model = {id: rawData?.model?.id, email: rawData?.model?.email};\n const extraProps = [\"collectionId\", \"username\", \"verified\"];\n for (const prop in this.model) {\n if (extraProps.includes(prop)) {\n rawData.model[prop] = this.model[prop];\n }\n }\n result = cookieSerialize(key, JSON.stringify(rawData), options);\n }\n\n return result;\n }\n\n /**\n * Register a callback function that will be called on store change.\n *\n * You can set the `fireImmediately` argument to true in order to invoke\n * the provided callback right after registration.\n *\n * Returns a removal function that you could call to \"unsubscribe\" from the changes.\n */\n onChange(callback: OnStoreChangeFunc, fireImmediately = false): () => void {\n this._onChangeCallbacks.push(callback);\n\n if (fireImmediately) {\n callback(this.token, this.model);\n }\n\n return () => {\n for (let i = this._onChangeCallbacks.length - 1; i >= 0; i--) {\n if (this._onChangeCallbacks[i] == callback) {\n delete this._onChangeCallbacks[i]; // removes the function reference\n this._onChangeCallbacks.splice(i, 1); // reindex the array\n return;\n }\n }\n }\n }\n\n protected triggerChange(): void {\n for (const callback of this._onChangeCallbacks) {\n callback && callback(this.token, this.model);\n }\n }\n}\n","import { BaseAuthStore, AuthModel } from '@/stores/BaseAuthStore';\n\n/**\n * The default token store for browsers with auto fallback\n * to runtime/memory if local storage is undefined (eg. in node env).\n */\nexport class LocalAuthStore extends BaseAuthStore {\n private storageFallback: { [key: string]: any } = {};\n private storageKey: string\n\n constructor(storageKey = \"pocketbase_auth\") {\n super();\n\n this.storageKey = storageKey;\n\n this._bindStorageEvent();\n }\n\n /**\n * @inheritdoc\n */\n get token(): string {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.token || '';\n }\n\n /**\n * @inheritdoc\n */\n get model(): AuthModel {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.model || null;\n }\n\n /**\n * @inheritdoc\n */\n save(token: string, model?: AuthModel) {\n this._storageSet(this.storageKey, {\n 'token': token,\n 'model': model,\n });\n\n super.save(token, model);\n }\n\n /**\n * @inheritdoc\n */\n clear() {\n this._storageRemove(this.storageKey);\n\n super.clear();\n }\n\n // ---------------------------------------------------------------\n // Internal helpers:\n // ---------------------------------------------------------------\n\n /**\n * Retrieves `key` from the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageGet(key: string): any {\n if (typeof window !== 'undefined' && window?.localStorage) {\n const rawValue = window.localStorage.getItem(key) || '';\n try {\n return JSON.parse(rawValue);\n } catch (e) { // not a json\n return rawValue;\n }\n }\n\n // fallback\n return this.storageFallback[key];\n }\n\n /**\n * Stores a new data in the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageSet(key: string, value: any) {\n if (typeof window !== 'undefined' && window?.localStorage) {\n // store in local storage\n let normalizedVal = value;\n if (typeof value !== 'string') {\n normalizedVal = JSON.stringify(value);\n }\n window.localStorage.setItem(key, normalizedVal);\n } else {\n // store in fallback\n this.storageFallback[key] = value;\n }\n }\n\n /**\n * Removes `key` from the browser's local storage and the runtime/memory.\n */\n private _storageRemove(key: string) {\n // delete from local storage\n if (typeof window !== 'undefined' && window?.localStorage) {\n window.localStorage?.removeItem(key);\n }\n\n // delete from fallback\n delete this.storageFallback[key];\n }\n\n /**\n * Updates the current store state on localStorage change.\n */\n private _bindStorageEvent() {\n if (typeof window === 'undefined' || !window?.localStorage || !window.addEventListener) {\n return;\n }\n\n window.addEventListener('storage', (e) => {\n if (e.key != this.storageKey) {\n return;\n }\n\n const data = this._storageGet(this.storageKey) || {};\n\n super.save(data.token || '', data.model || null);\n });\n }\n}\n","import Client from '@/Client';\n\n/**\n * BaseService class that should be inherited from all API services.\n */\nexport abstract class BaseService {\n readonly client: Client\n\n constructor(client: Client) {\n this.client = client;\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\ninterface appleClientSecret {\n secret: string;\n}\n\nexport class SettingsService extends BaseService {\n /**\n * Fetch all available app settings.\n */\n getAll(options?: CommonOptions): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Bulk updates app settings.\n */\n update(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Performs a S3 filesystem connection test.\n *\n * The currently supported `filesystem` are \"storage\" and \"backups\".\n */\n testS3(filesystem: string = \"storage\", options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'filesystem': filesystem,\n },\n }, options);\n\n return this.client.send('/api/settings/test/s3', options)\n .then(() => true);\n }\n\n /**\n * Sends a test email.\n *\n * The possible `emailTemplate` values are:\n * - verification\n * - password-reset\n * - email-change\n */\n testEmail(toEmail: string, emailTemplate: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'email': toEmail,\n 'template': emailTemplate,\n },\n }, options);\n\n return this.client.send('/api/settings/test/email', options)\n .then(() => true);\n }\n\n /**\n * Generates a new Apple OAuth2 client secret.\n */\n generateAppleClientSecret(\n clientId: string,\n teamId: string,\n keyId: string,\n privateKey: string,\n duration: number,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n clientId,\n teamId,\n keyId,\n privateKey,\n duration,\n },\n }, options);\n\n return this.client.send('/api/settings/apple/generate-client-secret', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n FullListOptions\n} from '@/services/utils/options';\n\nexport abstract class CrudService extends BaseService {\n /**\n * Base path for the crud actions (without trailing slash, eg. '/admins').\n */\n abstract get baseCrudPath(): string\n\n /**\n * Response data decoder.\n */\n decode(data: { [key: string]: any }): T {\n return data as T;\n }\n\n /**\n * Returns a promise with all list items batch fetched at once\n * (by default 500 items per request; to change it set the `batch` query param).\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getFullList(options?: FullListOptions): Promise>\n\n /**\n * Legacy version of getFullList with explicitly specified batch size.\n */\n getFullList(batch?: number, options?: ListOptions): Promise>\n\n getFullList(batchOrqueryParams?: number|FullListOptions, options?: ListOptions): Promise> {\n if (typeof batchOrqueryParams == \"number\") {\n return this._getFullList(batchOrqueryParams, options);\n }\n\n options = Object.assign({}, batchOrqueryParams, options);\n\n let batch = 500;\n if (options.batch) {\n batch = options.batch;\n delete options.batch;\n }\n\n return this._getFullList(batch, options);\n }\n\n /**\n * Returns paginated items list.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({\n method: 'GET'\n }, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => {\n responseData.items = responseData.items?.map((item: any) => {\n return this.decode(item);\n }) || [];\n\n return responseData;\n });\n }\n\n /**\n * Returns the first found item by the specified filter.\n *\n * Internally it calls `getList(1, 1, { filter, skipTotal })` and\n * returns the first found item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n *\n * For consistency with `getOne`, this method will throw a 404\n * ClientResponseError if no item was found.\n */\n getFirstListItem(filter: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'requestKey': 'one_by_filter_' + this.baseCrudPath + \"_\" + filter,\n }, options);\n\n options.query = Object.assign({\n 'filter': filter,\n 'skipTotal': 1,\n }, options.query);\n\n return this.getList(1, 1, options)\n .then((result) => {\n if (!result?.items?.length) {\n throw new ClientResponseError({\n status: 404,\n data: {\n code: 404,\n message: \"The requested resource wasn't found.\",\n data: {},\n },\n });\n }\n\n return result.items[0];\n });\n }\n\n /**\n * Returns single item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getOne(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Creates a new item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n create(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Updates an existing item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Deletes an existing item by its id.\n */\n delete(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then(() => true);\n }\n\n /**\n * Returns a promise with all list items batch fetched at once.\n */\n protected _getFullList(batchSize = 500, options?: ListOptions): Promise> {\n options = options || {};\n options.query = Object.assign({\n 'skipTotal': 1,\n }, options.query);\n\n let result: Array = [];\n\n let request = async (page: number): Promise> => {\n return this.getList(page, batchSize || 500, options).then((list) => {\n const castedList = (list as any as ListResult);\n const items = castedList.items;\n\n result = result.concat(items);\n\n if (items.length == list.perPage) {\n return request(page + 1);\n }\n\n return result;\n });\n }\n\n return request(1);\n }\n}\n","import { SendOptions } from '@/services/utils/options';\n\nexport function normalizeLegacyOptionsArgs(legacyWarn: string, baseOptions: SendOptions, bodyOrOptions?: any, query?: any): SendOptions {\n const hasBodyOrOptions = typeof bodyOrOptions !== 'undefined';\n const hasQuery = typeof query !== 'undefined';\n\n if (!hasQuery && !hasBodyOrOptions) {\n return baseOptions;\n }\n\n if (hasQuery) {\n console.warn(legacyWarn);\n baseOptions.body = Object.assign({}, baseOptions.body, bodyOrOptions);\n baseOptions.query = Object.assign({}, baseOptions.query, query);\n\n return baseOptions;\n }\n\n baseOptions = Object.assign(baseOptions, bodyOrOptions);\n return baseOptions;\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { AdminModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface AdminAuthResponse {\n [key: string]: any;\n\n token: string;\n admin: AdminModel;\n}\n\nexport class AdminService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/admins';\n }\n\n // ---------------------------------------------------------------\n // Post update/delete AuthStore sync\n // ---------------------------------------------------------------\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n // update the store state if the updated item id matches with the stored model\n if (\n this.client.authStore.model?.id === item.id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n // clear the store state if the deleted item id matches with the stored model\n if (\n success &&\n this.client.authStore.model?.id === id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful authorize response.\n */\n protected authResponse(responseData: any): AdminAuthResponse {\n const admin = this.decode(responseData?.admin || {});\n\n if (responseData?.token && responseData?.admin) {\n this.client.authStore.save(responseData.token, admin);\n }\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'admin': admin,\n });\n }\n\n /**\n * Authenticate an admin account with its email and password\n * and returns a new admin token and data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authWithPassword(email: string, password: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authWithPassword(email, password, options?).\n */\n authWithPassword(email: string, password: string, body?: any, query?: any): Promise\n\n authWithPassword(\n email: string,\n password: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': email,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(email, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(email, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-with-password', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Refreshes the current admin authenticated instance and\n * returns a new token and admin data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authRefresh(options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-refresh', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Sends admin password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/request-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Confirms admin password reset request.\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(resetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, body?: any, query?: any): Promise\n\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, bodyOrOptions?: any, query?: any): Promise{\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': resetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(resetToken, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(resetToken, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\n\ninterface promiseCallbacks {\n resolve: Function\n reject: Function\n}\n\nexport type UnsubscribeFunc = () => Promise;\n\nexport class RealtimeService extends BaseService {\n clientId: string = \"\";\n\n private eventSource: EventSource | null = null;\n private subscriptions: { [key: string]: Array } = {};\n private lastSentTopics: Array = [];\n private connectTimeoutId: any;\n private maxConnectTimeout: number = 15000;\n private reconnectTimeoutId: any;\n private reconnectAttempts: number = 0;\n private maxReconnectAttempts: number = Infinity;\n private predefinedReconnectIntervals: Array = [\n 200, 300, 500, 1000, 1200, 1500, 2000,\n ];\n private pendingConnects: Array = [];\n\n /**\n * Returns whether the realtime connection has been established.\n */\n get isConnected(): boolean {\n return !!this.eventSource && !!this.clientId && !this.pendingConnects.length;\n }\n\n /**\n * Register the subscription listener.\n *\n * You can subscribe multiple times to the same topic.\n *\n * If the SSE connection is not started yet,\n * this method will also initialize it.\n */\n async subscribe(topic: string, callback: (data: any) => void): Promise {\n if (!topic) {\n throw new Error('topic must be set.')\n }\n\n const listener = function (e: Event) {\n const msgEvent = (e as MessageEvent);\n\n let data;\n try {\n data = JSON.parse(msgEvent?.data);\n } catch {}\n\n callback(data || {});\n };\n\n // store the listener\n if (!this.subscriptions[topic]) {\n this.subscriptions[topic] = [];\n }\n this.subscriptions[topic].push(listener);\n\n if (!this.isConnected) {\n // initialize sse connection\n await this.connect();\n } else if (this.subscriptions[topic].length === 1) {\n // send the updated subscriptions (if it is the first for the topic)\n await this.submitSubscriptions();\n } else {\n // only register the listener\n this.eventSource?.addEventListener(topic, listener);\n }\n\n return async (): Promise => {\n return this.unsubscribeByTopicAndListener(topic, listener);\n };\n }\n\n /**\n * Unsubscribe from all subscription listeners with the specified topic.\n *\n * If `topic` is not provided, then this method will unsubscribe\n * from all active subscriptions.\n *\n * This method is no-op if there are no active subscriptions.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribe(topic?: string): Promise {\n if (!this.hasSubscriptionListeners(topic)) {\n return; // already unsubscribed\n }\n\n if (!topic) {\n // remove all subscriptions\n this.subscriptions = {};\n } else {\n // remove all topic listeners\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n /**\n * Unsubscribe from all subscription listeners starting with the specified topic prefix.\n *\n * This method is no-op if there are no active subscriptions with the specified topic prefix.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByPrefix(topicPrefix: string): Promise {\n let hasAtleastOneTopic = false;\n for (let topic in this.subscriptions) {\n if (!topic.startsWith(topicPrefix)) {\n continue;\n }\n\n hasAtleastOneTopic = true;\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!hasAtleastOneTopic) {\n return; // nothing to unsubscribe from\n }\n\n if (this.hasSubscriptionListeners()) {\n // submit the deleted subscriptions\n await this.submitSubscriptions();\n } else {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n }\n }\n\n /**\n * Unsubscribe from all subscriptions matching the specified topic and listener function.\n *\n * This method is no-op if there are no active subscription with\n * the specified topic and listener.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByTopicAndListener(topic: string, listener: EventListener): Promise {\n if (!Array.isArray(this.subscriptions[topic]) || !this.subscriptions[topic].length) {\n return; // already unsubscribed\n }\n\n let exist = false;\n for (let i = this.subscriptions[topic].length - 1; i >= 0; i--) {\n if (this.subscriptions[topic][i] !== listener) {\n continue;\n }\n\n exist = true; // has at least one matching listener\n delete this.subscriptions[topic][i]; // removes the function reference\n this.subscriptions[topic].splice(i, 1); // reindex the array\n this.eventSource?.removeEventListener(topic, listener);\n }\n if (!exist) {\n return;\n }\n\n // remove the topic from the subscriptions list if there are no other listeners\n if (!this.subscriptions[topic].length) {\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n private hasSubscriptionListeners(topicToCheck?: string): boolean {\n this.subscriptions = this.subscriptions || {};\n\n // check the specified topic\n if (topicToCheck) {\n return !!this.subscriptions[topicToCheck]?.length;\n }\n\n // check for at least one non-empty topic\n for (let topic in this.subscriptions) {\n if (!!this.subscriptions[topic]?.length) {\n return true\n }\n }\n\n return false;\n }\n\n private async submitSubscriptions(): Promise {\n if (!this.clientId) {\n return; // no client/subscriber\n }\n\n // optimistic update\n this.addAllSubscriptionListeners();\n\n this.lastSentTopics = this.getNonEmptySubscriptionTopics();\n\n return this.client.send('/api/realtime', {\n 'method': 'POST',\n 'body': {\n 'clientId': this.clientId,\n 'subscriptions': this.lastSentTopics,\n },\n 'query': {\n 'requestKey': this.getSubscriptionsCancelKey(),\n },\n }).catch((err) => {\n if (err?.isAbort) {\n return; // silently ignore aborted pending requests\n }\n throw err;\n });\n }\n\n private getSubscriptionsCancelKey(): string {\n return \"realtime_\" + this.clientId;\n }\n\n private getNonEmptySubscriptionTopics(): Array {\n const result : Array = [];\n\n for (let topic in this.subscriptions) {\n if (this.subscriptions[topic].length) {\n result.push(topic);\n }\n }\n\n return result;\n }\n\n private addAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n this.removeAllSubscriptionListeners();\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.addEventListener(topic, listener);\n }\n }\n }\n\n private removeAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.removeEventListener(topic, listener);\n }\n }\n }\n\n private async connect(): Promise {\n if (this.reconnectAttempts > 0) {\n // immediately resolve the promise to avoid indefinitely\n // blocking the client during reconnection\n return;\n }\n\n return new Promise((resolve, reject) => {\n this.pendingConnects.push({ resolve, reject });\n\n if (this.pendingConnects.length > 1) {\n // all promises will be resolved once the connection is established\n return;\n }\n\n this.initConnect();\n })\n }\n\n private initConnect() {\n this.disconnect(true);\n\n // wait up to 15s for connect\n clearTimeout(this.connectTimeoutId);\n this.connectTimeoutId = setTimeout(() => {\n this.connectErrorHandler(new Error(\"EventSource connect took too long.\"));\n }, this.maxConnectTimeout);\n\n this.eventSource = new EventSource(this.client.buildUrl('/api/realtime'))\n\n this.eventSource.onerror = (_) => {\n this.connectErrorHandler(new Error(\"Failed to establish realtime connection.\"));\n };\n\n this.eventSource.addEventListener('PB_CONNECT', (e) => {\n const msgEvent = (e as MessageEvent);\n this.clientId = msgEvent?.lastEventId;\n\n this.submitSubscriptions()\n .then(async () => {\n let retries = 3;\n while (this.hasUnsentSubscriptions() && retries > 0) {\n retries--;\n // resubscribe to ensure that the latest topics are submitted\n //\n // This is needed because missed topics could happen on reconnect\n // if after the pending sent `submitSubscriptions()` call another `subscribe()`\n // was made before the submit was able to complete.\n await this.submitSubscriptions();\n }\n }).then(() => {\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n\n // reset connect meta\n this.pendingConnects = [];\n this.reconnectAttempts = 0;\n clearTimeout(this.reconnectTimeoutId);\n clearTimeout(this.connectTimeoutId);\n }).catch((err) => {\n this.clientId = \"\";\n this.connectErrorHandler(err);\n });\n });\n }\n\n private hasUnsentSubscriptions(): boolean {\n const latestTopics = this.getNonEmptySubscriptionTopics();\n if (latestTopics.length != this.lastSentTopics.length) {\n return true;\n }\n\n for (const t of latestTopics) {\n if (!this.lastSentTopics.includes(t)) {\n return true;\n }\n }\n\n return false;\n }\n\n private connectErrorHandler(err: any) {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n\n if (\n // wasn't previously connected -> direct reject\n (!this.clientId && !this.reconnectAttempts) ||\n // was previously connected but the max reconnection limit has been reached\n this.reconnectAttempts > this.maxReconnectAttempts\n ) {\n for (let p of this.pendingConnects) {\n p.reject(new ClientResponseError(err));\n }\n this.pendingConnects = [];\n this.disconnect();\n return;\n }\n\n // otherwise -> reconnect in the background\n this.disconnect(true);\n const timeout = this.predefinedReconnectIntervals[this.reconnectAttempts] || this.predefinedReconnectIntervals[this.predefinedReconnectIntervals.length - 1];\n this.reconnectAttempts++;\n this.reconnectTimeoutId = setTimeout(() => {\n this.initConnect();\n }, timeout);\n }\n\n private disconnect(fromReconnect = false): void {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n this.removeAllSubscriptionListeners();\n this.client.cancelRequest(this.getSubscriptionsCancelKey());\n this.eventSource?.close();\n this.eventSource = null;\n this.clientId = \"\";\n\n if (!fromReconnect) {\n this.reconnectAttempts = 0;\n\n // resolve any remaining connect promises\n //\n // this is done to avoid unnecessary throwing errors in case\n // unsubscribe is called before the pending connect promises complete\n // (see https://github.com/pocketbase/pocketbase/discussions/2897#discussioncomment-6423818)\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n this.pendingConnects = [];\n }\n }\n}\n","import Client from '@/Client';\nimport { CrudService } from '@/services/utils/CrudService';\nimport { RealtimeService, UnsubscribeFunc } from '@/services/RealtimeService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult, RecordModel, ExternalAuthModel } from '@/services/utils/dtos';\nimport {\n SendOptions,\n CommonOptions,\n RecordOptions,\n RecordListOptions,\n RecordFullListOptions,\n} from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface RecordAuthResponse {\n // The signed PocketBase auth record.\n record: T;\n\n // The PocketBase record auth token.\n //\n // If you are looking for the OAuth2 access and refresh tokens\n // they are available under the `meta.accessToken` and `meta.refreshToken` props.\n token: string;\n\n // Auth meta data usually filled when OAuth2 is used.\n meta?: {[key: string]: any};\n}\n\nexport interface AuthProviderInfo {\n name: string;\n state: string;\n codeVerifier: string;\n codeChallenge: string;\n codeChallengeMethod: string;\n authUrl: string;\n}\n\nexport interface AuthMethodsList {\n usernamePassword: boolean;\n emailPassword: boolean;\n authProviders: Array;\n}\n\nexport interface RecordSubscription {\n action: string; // eg. create, update, delete\n record: T;\n}\n\nexport type OAuth2UrlCallback = (url: string) => void|Promise;\n\nexport interface OAuth2AuthConfig extends SendOptions {\n // the name of the OAuth2 provider (eg. \"google\")\n provider: string;\n\n // custom scopes to overwrite the default ones\n scopes?: Array;\n\n // optional record create data\n createData?: {[key: string]: any};\n\n // optional callback that is triggered after the OAuth2 sign-in/sign-up url generation\n urlCallback?: OAuth2UrlCallback;\n\n // optional query params to send with the PocketBase auth request (eg. fields, expand, etc.)\n query?: RecordOptions;\n}\n\nexport class RecordService extends CrudService {\n readonly collectionIdOrName: string;\n\n constructor(client: Client, collectionIdOrName: string) {\n super(client);\n\n this.collectionIdOrName = collectionIdOrName;\n }\n\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return this.baseCollectionPath + '/records';\n }\n\n /**\n * Returns the current collection service base path.\n */\n get baseCollectionPath(): string {\n return '/api/collections/' + encodeURIComponent(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Realtime handlers\n // ---------------------------------------------------------------\n\n /**\n * @deprecated Use subscribe(recordId, callback) instead.\n *\n * Subscribe to the realtime changes of a single record in the collection.\n */\n async subscribeOne(recordId: string, callback: (data: RecordSubscription) => void): Promise {\n console.warn(\"PocketBase: subscribeOne(recordId, callback) is deprecated. Please replace it with subscribe(recordId, callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName + \"/\" + recordId, callback);\n }\n\n /**\n * @deprecated This form of subscribe is deprecated. Please use `subscribe(\"*\", callback)`.\n */\n async subscribe(callback: (data: RecordSubscription) => void): Promise\n\n /**\n * Subscribe to realtime changes to the specified topic (\"*\" or record id).\n *\n * If `topic` is the wildcard \"*\", then this method will subscribe to\n * any record changes in the collection.\n *\n * If `topic` is a record id, then this method will subscribe only\n * to changes of the specified record id.\n *\n * It's OK to subscribe multiple times to the same topic.\n * You can use the returned `UnsubscribeFunc` to remove only a single subscription.\n * Or use `unsubscribe(topic)` if you want to remove all subscriptions attached to the topic.\n */\n async subscribe(topic: string, callback: (data: RecordSubscription) => void): Promise\n\n async subscribe(\n topicOrCallback: string|((data: RecordSubscription) => void),\n callback?: (data: RecordSubscription) => void\n ): Promise {\n if (typeof topicOrCallback === 'function') {\n console.warn(\"PocketBase: subscribe(callback) is deprecated. Please replace it with subscribe('*', callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName, topicOrCallback);\n }\n\n if (!callback) {\n throw new Error(\"Missing subscription callback.\");\n }\n\n if (topicOrCallback === \"\") {\n throw new Error(\"Missing topic.\");\n }\n\n let topic = this.collectionIdOrName;\n if (topicOrCallback !== \"*\") {\n topic += ('/' + topicOrCallback);\n }\n\n return this.client.realtime.subscribe(topic, callback)\n }\n\n /**\n * Unsubscribe from all subscriptions of the specified topic\n * (\"*\" or record id).\n *\n * If `topic` is not set, then this method will unsubscribe from\n * all subscriptions associated to the current collection.\n */\n async unsubscribe(topic?: string): Promise {\n // unsubscribe wildcard topic\n if (topic === \"*\") {\n return this.client.realtime.unsubscribe(this.collectionIdOrName);\n }\n\n // unsubscribe recordId topic\n if (topic) {\n return this.client.realtime.unsubscribe(this.collectionIdOrName + \"/\" + topic);\n }\n\n // unsubscribe from everything related to the collection\n return this.client.realtime.unsubscribeByPrefix(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Crud handers\n // ---------------------------------------------------------------\n /**\n * @inheritdoc\n */\n getFullList(options?: RecordFullListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batch?: number, options?: RecordListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batchOrOptions?: number|RecordFullListOptions, options?: RecordListOptions): Promise> {\n if (typeof batchOrOptions == \"number\") {\n return super.getFullList(batchOrOptions, options);\n }\n\n const params = Object.assign({}, batchOrOptions, options);\n\n return super.getFullList(params);\n }\n\n /**\n * @inheritdoc\n */\n getList(page = 1, perPage = 30, options?: RecordListOptions): Promise> {\n return super.getList(page, perPage, options);\n }\n\n /**\n * @inheritdoc\n */\n getFirstListItem(filter: string, options?: RecordListOptions): Promise {\n return super.getFirstListItem(filter, options);\n }\n\n /**\n * @inheritdoc\n */\n getOne(id: string, options?: RecordOptions): Promise {\n return super.getOne(id, options);\n }\n\n /**\n * @inheritdoc\n */\n create(bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.create(bodyParams, options);\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(id: string, bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n if (\n // is record auth\n this.client.authStore.model?.id === item?.id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n if (\n success &&\n // is record auth\n this.client.authStore.model?.id === id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful collection authorization response.\n */\n protected authResponse(responseData: any): RecordAuthResponse {\n const record = this.decode(responseData?.record || {});\n\n this.client.authStore.save(responseData?.token, record);\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'record': record as any as T,\n });\n }\n\n /**\n * Returns all available collection auth methods.\n */\n listAuthMethods(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCollectionPath + '/auth-methods', options)\n .then((responseData: any) => {\n return Object.assign({}, responseData, {\n // normalize common fields\n 'usernamePassword': !!responseData?.usernamePassword,\n 'emailPassword': !!responseData?.emailPassword,\n 'authProviders': Array.isArray(responseData?.authProviders) ? responseData?.authProviders : [],\n });\n });\n }\n\n /**\n * Authenticate a single auth collection record via its username/email and password.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n */\n authWithPassword(usernameOrEmail: string, password: string, options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authWithPassword(usernameOrEmail, password, options?).\n */\n authWithPassword(usernameOrEmail: string, password: string, body?: any, query?: any): Promise>\n\n authWithPassword(usernameOrEmail: string, password: string, bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': usernameOrEmail,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(usernameOrEmail, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(usernameOrEmail, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-password', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Authenticate a single auth collection record with OAuth2 code.\n *\n * If you don't have an OAuth2 code you may also want to check `authWithOAuth2` method.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n options?: RecordOptions,\n ): Promise>\n\n /**\n * @deprecated\n * Consider using authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createdData, options?).\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n body?: any,\n query?: any\n ): Promise>\n\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n bodyOrOptions?: any,\n query?: any\n ): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'provider': provider,\n 'code': code,\n 'codeVerifier': codeVerifier,\n 'redirectUrl': redirectUrl,\n 'createData': createData,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, body?, query?) is deprecated. Consider replacing it with authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-oauth2', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * @deprecated This form of authWithOAuth2 is deprecated.\n *\n * Please use `authWithOAuth2Code()` OR its simplified realtime version\n * as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\n */\n async authWithOAuth2(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key: string]: any},\n bodyParams?: {[key: string]: any},\n queryParams?: RecordOptions,\n ): Promise>\n\n /**\n * Authenticate a single auth collection record with OAuth2\n * **without custom redirects, deeplinks or even page reload**.\n *\n * This method initializes a one-off realtime subscription and will\n * open a popup window with the OAuth2 vendor page to authenticate.\n * Once the external OAuth2 sign-in/sign-up flow is completed, the popup\n * window will be automatically closed and the OAuth2 data sent back\n * to the user through the previously established realtime connection.\n *\n * You can specify an optional `urlCallback` prop to customize\n * the default url `window.open` behavior.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n *\n * Example:\n *\n * ```js\n * const authData = await pb.collection(\"users\").authWithOAuth2({\n * provider: \"google\",\n * })\n * ```\n *\n * _Site-note_: when creating the OAuth2 app in the provider dashboard\n * you have to configure `https://yourdomain.com/api/oauth2-redirect`\n * as redirect URL.\n */\n async authWithOAuth2(options: OAuth2AuthConfig): Promise>\n\n async authWithOAuth2(...args: any): Promise> {\n // fallback to legacy format\n if (args.length > 1 || typeof args?.[0] === 'string') {\n console.warn(\"PocketBase: This form of authWithOAuth2() is deprecated and may get removed in the future. Please replace with authWithOAuth2Code() OR use the authWithOAuth2() realtime form as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\");\n return this.authWithOAuth2Code(\n args?.[0] || '',\n args?.[1] || '',\n args?.[2] || '',\n args?.[3] || '',\n args?.[4] || {},\n args?.[5] || {},\n args?.[6] || {},\n );\n }\n\n const config = args?.[0] || {};\n\n const authMethods = await this.listAuthMethods();\n\n const provider = authMethods.authProviders.find((p) => p.name === config.provider);\n if (!provider) {\n throw new ClientResponseError(new Error(`Missing or invalid provider \"${config.provider}\".`));\n }\n\n const redirectUrl = this.client.buildUrl('/api/oauth2-redirect');\n\n // initialize a one-off realtime service\n const realtime = new RealtimeService(this.client);\n\n // open a new popup window in case config.urlCallback is not set\n //\n // note: it is opened before the async call due to Safari restrictions\n // (see https://github.com/pocketbase/pocketbase/discussions/2429#discussioncomment-5943061)\n let eagerDefaultPopup: Window|null = null;\n if (!config.urlCallback) {\n eagerDefaultPopup = openBrowserPopup(undefined);\n }\n\n function cleanup() {\n eagerDefaultPopup?.close();\n realtime.unsubscribe();\n }\n\n return new Promise(async (resolve, reject) => {\n try {\n await realtime.subscribe('@oauth2', async (e) => {\n const oldState = realtime.clientId;\n\n try {\n if (!e.state || oldState !== e.state) {\n throw new Error(\"State parameters don't match.\");\n }\n\n // clear the non SendOptions props\n const options = Object.assign({}, config);\n delete options.provider;\n delete options.scopes;\n delete options.createData;\n delete options.urlCallback;\n\n const authData = await this.authWithOAuth2Code(\n provider.name,\n e.code,\n provider.codeVerifier,\n redirectUrl,\n config.createData,\n options,\n );\n\n resolve(authData);\n } catch (err) {\n reject(new ClientResponseError(err));\n }\n\n cleanup();\n });\n\n const replacements: {[key: string]: any} = {\n \"state\": realtime.clientId,\n }\n if (config.scopes?.length) {\n replacements[\"scope\"] = config.scopes.join(\" \");\n }\n\n const url = this._replaceQueryParams(provider.authUrl + redirectUrl, replacements);\n\n let urlCallback = config.urlCallback || function (url: string) {\n if (eagerDefaultPopup) {\n eagerDefaultPopup.location.href = url;\n } else {\n // it could have been blocked due to its empty initial url,\n // try again...\n eagerDefaultPopup = openBrowserPopup(url);\n }\n }\n\n await urlCallback(url);\n } catch (err) {\n cleanup();\n reject(new ClientResponseError(err));\n }\n });\n }\n\n /**\n * Refreshes the current authenticated record instance and\n * returns a new token and record data.\n *\n * On success this method also automatically updates the client's AuthStore.\n */\n authRefresh(options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise>\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-refresh', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Sends auth record password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-password-reset', options).then(() => true);\n }\n\n /**\n * Confirms auth record password reset request.\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n options?: CommonOptions,\n ): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(passwordResetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n body?: any,\n query?: any,\n ): Promise\n\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': passwordResetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(token, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(token, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Sends auth record verification email request.\n */\n requestVerification(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestVerification(email, options?).\n */\n requestVerification(email: string, body?: any, query?: any): Promise\n\n requestVerification(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestVerification(email, body?, query?) is deprecated. Consider replacing it with requestVerification(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-verification', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record email verification request.\n */\n confirmVerification(verificationToken: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmVerification(verificationToken, options?).\n */\n confirmVerification(verificationToken: string, body?: any, query?: any): Promise\n\n confirmVerification(verificationToken: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': verificationToken,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmVerification(token, body?, query?) is deprecated. Consider replacing it with confirmVerification(token, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-verification', options)\n .then(() => true);\n }\n\n /**\n * Sends an email change request to the authenticated record model.\n */\n requestEmailChange(newEmail: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestEmailChange(newEmail, options?).\n */\n requestEmailChange(newEmail: string, body?: any, query?: any): Promise\n\n requestEmailChange(newEmail: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'newEmail': newEmail,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestEmailChange(newEmail, body?, query?) is deprecated. Consider replacing it with requestEmailChange(newEmail, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-email-change', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record's new email address.\n */\n confirmEmailChange(emailChangeToken: string, password: string, options?: CommonOptions): Promise\n\n\n /**\n * @deprecated\n * Consider using confirmEmailChange(emailChangeToken, password, options?).\n */\n confirmEmailChange(emailChangeToken: string, password: string, body?: any, query?: any): Promise\n\n confirmEmailChange(emailChangeToken: string, password: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': emailChangeToken,\n 'password': password,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmEmailChange(token, password, body?, query?) is deprecated. Consider replacing it with confirmEmailChange(token, password, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-email-change', options)\n .then(() => true);\n }\n\n /**\n * Lists all linked external auth providers for the specified auth record.\n */\n listExternalAuths(recordId: string, options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths', options);\n }\n\n /**\n * Unlink a single external auth provider from the specified auth record.\n */\n unlinkExternalAuth(recordId: string, provider: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths/' + encodeURIComponent(provider), options)\n .then(() => true);\n }\n\n // ---------------------------------------------------------------\n\n // very rudimentary url query params replacement because at the moment\n // URL (and URLSearchParams) doesn't seem to be fully supported in React Native\n //\n // note: for details behind some of the decode/encode parsing check https://unixpapa.com/js/querystring.html\n private _replaceQueryParams(url: string, replacements: {[key: string]: any} = {}): string {\n let urlPath = url\n let query = \"\";\n\n const queryIndex = url.indexOf(\"?\");\n if (queryIndex >= 0) {\n urlPath = url.substring(0, url.indexOf(\"?\"));\n query = url.substring(url.indexOf(\"?\") + 1);\n }\n\n const parsedParams: {[key: string]: string} = {};\n\n // parse the query parameters\n const rawParams = query.split(\"&\");\n for (const param of rawParams) {\n if (param == \"\") {\n continue\n }\n\n const pair = param.split(\"=\");\n parsedParams[decodeURIComponent(pair[0].replace(/\\+/g,' '))] = decodeURIComponent((pair[1] || \"\").replace(/\\+/g,' '));\n }\n\n // apply the replacements\n for (let key in replacements) {\n if (!replacements.hasOwnProperty(key)) {\n continue;\n }\n\n if (replacements[key] == null) {\n delete parsedParams[key];\n } else {\n parsedParams[key] = replacements[key];\n }\n }\n\n // construct back the full query string\n query = \"\";\n for (let key in parsedParams) {\n if (!parsedParams.hasOwnProperty(key)) {\n continue;\n }\n\n if (query != \"\") {\n query += \"&\";\n }\n\n query += encodeURIComponent(key.replace(/%20/g,'+')) + \"=\" + encodeURIComponent(parsedParams[key].replace(/%20/g,'+'));\n }\n\n return query != \"\" ? (urlPath + \"?\" + query) : urlPath;\n }\n}\n\nfunction openBrowserPopup(url?: string): Window|null {\n if (typeof window === \"undefined\" || !window?.open) {\n throw new ClientResponseError(new Error(`Not in a browser context - please pass a custom urlCallback function.`));\n }\n\n let width = 1024;\n let height = 768;\n\n let windowWidth = window.innerWidth;\n let windowHeight = window.innerHeight;\n\n // normalize window size\n width = width > windowWidth ? windowWidth : width;\n height = height > windowHeight ? windowHeight : height;\n\n let left = (windowWidth / 2) - (width / 2);\n let top = (windowHeight / 2) - (height / 2);\n\n // note: we don't use the noopener and noreferrer attributes since\n // for some reason browser blocks such windows then url is undefined/blank\n return window.open(\n url,\n 'popup_window',\n 'width='+width+',height='+height+',top='+top+',left='+left+',resizable,menubar=no'\n );\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { CollectionModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport class CollectionService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/collections';\n }\n\n /**\n * Imports the provided collections.\n *\n * If `deleteMissing` is `true`, all local collections and schema fields,\n * that are not present in the imported configuration, WILL BE DELETED\n * (including their related records data)!\n */\n async import(\n collections: Array,\n deleteMissing: boolean = false,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PUT',\n 'body': {\n 'collections': collections,\n 'deleteMissing': deleteMissing,\n }\n }, options);\n\n return this.client.send(this.baseCrudPath + '/import', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ListResult, LogRequestModel } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n LogStatsOptions,\n} from '@/services/utils/options';\n\nexport interface HourlyStats {\n total: number;\n date: string;\n}\n\nexport class LogService extends BaseService {\n /**\n * Returns paginated logged requests list.\n */\n getRequestsList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({'method': 'GET'}, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send('/api/logs/requests', options);\n }\n\n /**\n * Returns a single logged request by its id.\n */\n getRequest(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/' + encodeURIComponent(id), options);\n }\n\n /**\n * Returns request logs statistics.\n */\n getRequestsStats(options?: LogStatsOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/stats', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface HealthCheckResponse {\n code: number;\n message: string;\n data: {[key: string]: any};\n}\n\nexport class HealthService extends BaseService {\n /**\n * Checks the health status of the api.\n */\n check(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/health', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions, FileOptions } from '@/services/utils/options';\n\nexport class FileService extends BaseService {\n /**\n * Builds and returns an absolute record file url for the provided filename.\n */\n getUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n if (\n !filename ||\n !record?.id ||\n !(record?.collectionId || record?.collectionName)\n ) {\n return '';\n }\n\n const parts = [];\n parts.push('api')\n parts.push('files')\n parts.push(encodeURIComponent(record.collectionId || record.collectionName))\n parts.push(encodeURIComponent(record.id))\n parts.push(encodeURIComponent(filename))\n\n let result = this.client.buildUrl(parts.join('/'));\n\n if (Object.keys(queryParams).length) {\n // normalize the download query param for consistency with the Dart sdk\n if (queryParams.download === false) {\n delete(queryParams.download);\n }\n\n const params = new URLSearchParams(queryParams);\n\n result += (result.includes('?') ? '&' : '?') + params;\n }\n\n return result\n }\n\n /**\n * Requests a new private file access token for the current auth model (admin or record).\n */\n getToken(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send('/api/files/token', options)\n .then((data) => data?.token || '');\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface BackupFileInfo {\n key: string;\n size: number;\n modified: string;\n}\n\nexport class BackupService extends BaseService {\n /**\n * Returns list with all available backup files.\n */\n getFullList(options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/backups', options);\n }\n\n /**\n * Initializes a new backup.\n */\n create(basename: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'name': basename,\n },\n }, options);\n\n return this.client.send('/api/backups', options)\n .then(() => true);\n }\n\n /**\n * Deletes a single backup file.\n */\n delete(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}`, options)\n .then(() => true);\n }\n\n /**\n * Initializes an app data restore from an existing backup.\n */\n restore(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}/restore`, options)\n .then(() => true);\n }\n\n /**\n * Builds a download url for a single existing backup using an\n * admin file token and the backup file key.\n *\n * The file token can be generated via `pb.files.getToken()`.\n */\n getDownloadUrl(token: string, key: string): string {\n return this.client.buildUrl(`/api/backups/${encodeURIComponent(key)}?token=${encodeURIComponent(token)}`);\n }\n}\n","import { ClientResponseError } from '@/ClientResponseError';\nimport { BaseAuthStore } from '@/stores/BaseAuthStore';\nimport { LocalAuthStore } from '@/stores/LocalAuthStore';\nimport { SettingsService } from '@/services/SettingsService';\nimport { AdminService } from '@/services/AdminService';\nimport { RecordService } from '@/services/RecordService';\nimport { CollectionService } from '@/services/CollectionService';\nimport { LogService } from '@/services/LogService';\nimport { RealtimeService } from '@/services/RealtimeService';\nimport { HealthService } from '@/services/HealthService';\nimport { FileService } from '@/services/FileService';\nimport { BackupService } from '@/services/BackupService';\nimport { SendOptions, FileOptions } from '@/services/utils/options';\n\n// list of known SendOptions keys (everything else is treated as query param)\nconst knownSendOptionsKeys = [\n 'requestKey',\n '$cancelKey',\n '$autoCancel',\n 'fetch',\n 'headers',\n 'body',\n 'query',\n 'params',\n // ---,\n 'cache',\n 'credentials',\n 'headers',\n 'integrity',\n 'keepalive',\n 'method',\n 'mode',\n 'redirect',\n 'referrer',\n 'referrerPolicy',\n 'signal',\n 'window',\n];\n\nexport interface BeforeSendResult {\n [key: string]: any, // for backward compatibility\n url?: string,\n options?: {[key: string]: any}\n}\n\n/**\n * PocketBase JS Client.\n */\nexport default class Client {\n /**\n * The base PocketBase backend url address (eg. 'http://127.0.0.1.8090').\n */\n baseUrl: string;\n\n /**\n * Hook that get triggered right before sending the fetch request,\n * allowing you to inspect and modify the url and request options.\n *\n * For list of the possible options check https://developer.mozilla.org/en-US/docs/Web/API/fetch#options\n *\n * You can return a non-empty result object `{ url, options }` to replace the url and request options entirely.\n *\n * Example:\n * ```js\n * client.beforeSend = function (url, options) {\n * options.headers = Object.assign({}, options.headers, {\n * 'X-Custom-Header': 'example',\n * });\n *\n * return { url, options }\n * };\n * ```\n */\n beforeSend?: (url: string, options: SendOptions) => BeforeSendResult|Promise;\n\n /**\n * Hook that get triggered after successfully sending the fetch request,\n * allowing you to inspect/modify the response object and its parsed data.\n *\n * Returns the new Promise resolved `data` that will be returned to the client.\n *\n * Example:\n * ```js\n * client.afterSend = function (response, data) {\n * if (response.status != 200) {\n * throw new ClientResponseError({\n * url: response.url,\n * status: response.status,\n * data: data,\n * });\n * }\n *\n * return data;\n * };\n * ```\n */\n afterSend?: (response: Response, data: any) => any;\n\n /**\n * Optional language code (default to `en-US`) that will be sent\n * with the requests to the server as `Accept-Language` header.\n */\n lang: string;\n\n /**\n * A replaceable instance of the local auth store service.\n */\n authStore: BaseAuthStore;\n\n /**\n * An instance of the service that handles the **Settings APIs**.\n */\n readonly settings: SettingsService;\n\n /**\n * An instance of the service that handles the **Admin APIs**.\n */\n readonly admins: AdminService;\n\n /**\n * An instance of the service that handles the **Collection APIs**.\n */\n readonly collections: CollectionService;\n\n /**\n * An instance of the service that handles the **File APIs**.\n */\n readonly files: FileService;\n\n /**\n * An instance of the service that handles the **Log APIs**.\n */\n readonly logs: LogService;\n\n /**\n * An instance of the service that handles the **Realtime APIs**.\n */\n readonly realtime: RealtimeService;\n\n /**\n * An instance of the service that handles the **Health APIs**.\n */\n readonly health: HealthService;\n\n /**\n * An instance of the service that handles the **Backup APIs**.\n */\n readonly backups: BackupService;\n\n private cancelControllers: { [key: string]: AbortController } = {};\n private recordServices: { [key: string]: RecordService } = {};\n private enableAutoCancellation: boolean = true;\n\n constructor(\n baseUrl = '/',\n authStore?: BaseAuthStore | null,\n lang = 'en-US',\n ) {\n this.baseUrl = baseUrl;\n this.lang = lang;\n this.authStore = authStore || new LocalAuthStore();\n\n // services\n this.admins = new AdminService(this);\n this.collections = new CollectionService(this);\n this.files = new FileService(this);\n this.logs = new LogService(this);\n this.settings = new SettingsService(this);\n this.realtime = new RealtimeService(this);\n this.health = new HealthService(this);\n this.backups = new BackupService(this);\n }\n\n /**\n * Returns the RecordService associated to the specified collection.\n *\n * @param {string} idOrName\n * @return {RecordService}\n */\n collection(idOrName: string): RecordService {\n if (!this.recordServices[idOrName]) {\n this.recordServices[idOrName] = new RecordService(this, idOrName);\n }\n\n return this.recordServices[idOrName];\n }\n\n /**\n * Globally enable or disable auto cancellation for pending duplicated requests.\n */\n autoCancellation(enable: boolean): Client {\n this.enableAutoCancellation = !!enable;\n\n return this;\n }\n\n /**\n * Cancels single request by its cancellation key.\n */\n cancelRequest(requestKey: string): Client {\n if (this.cancelControllers[requestKey]) {\n this.cancelControllers[requestKey].abort();\n delete this.cancelControllers[requestKey];\n }\n\n return this;\n }\n\n /**\n * Cancels all pending requests.\n */\n cancelAllRequests(): Client {\n for (let k in this.cancelControllers) {\n this.cancelControllers[k].abort();\n }\n\n this.cancelControllers = {};\n\n return this;\n }\n\n /**\n * Legacy alias of `pb.files.getUrl()`.\n */\n getFileUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n return this.files.getUrl(record, filename, queryParams);\n }\n\n /**\n * Builds a full client url by safely concatenating the provided path.\n */\n buildUrl(path: string): string {\n let url = this.baseUrl;\n\n // construct an absolute base url if in a browser environment\n if (\n typeof window !== 'undefined' &&\n !!window.location &&\n !url.startsWith('https://') &&\n !url.startsWith('http://')\n ) {\n url = window.location.origin?.endsWith('/') ?\n window.location.origin.substring(0, window.location.origin.length - 1) :\n (window.location.origin || '');\n\n if (!this.baseUrl.startsWith('/')) {\n url += window.location.pathname || '/';\n url += url.endsWith('/') ? '' : '/';\n }\n\n url += this.baseUrl;\n }\n\n // concatenate the path\n if (path) {\n url += url.endsWith('/') ? '' : '/'; // append trailing slash if missing\n url += path.startsWith('/') ? path.substring(1) : path;\n }\n\n return url;\n }\n\n /**\n * Sends an api http request.\n */\n async send(path: string, options: SendOptions): Promise {\n options = this.initSendOptions(path, options);\n\n // build url + path\n let url = this.buildUrl(path);\n\n // serialize the query parameters\n if (typeof options.query !== 'undefined') {\n const query = this.serializeQueryParams(options.query)\n if (query) {\n url += (url.includes('?') ? '&' : '?') + query;\n }\n delete options.query;\n }\n\n if (this.beforeSend) {\n const result = Object.assign({}, await this.beforeSend(url, options));\n if (typeof result.url !== 'undefined' || typeof result.options !== 'undefined') {\n url = result.url || url;\n options = result.options || options;\n } else if (Object.keys(result).length) {\n // legacy behavior\n options = result as SendOptions;\n console?.warn && console.warn('Deprecated format of beforeSend return: please use `return { url, options }`, instead of `return options`.');\n }\n }\n\n // ensures that the json body is serialized\n if (\n this.getHeader(options.headers, 'Content-Type') == 'application/json' &&\n options.body && typeof options.body !== 'string'\n ) {\n options.body = JSON.stringify(options.body);\n }\n\n const fetchFunc = options.fetch || fetch;\n\n // send the request\n return fetchFunc(url, options)\n .then(async (response) => {\n let data : any = {};\n\n try {\n data = await response.json();\n } catch (_) {\n // all api responses are expected to return json\n // with the exception of the realtime event and 204\n }\n\n if (this.afterSend) {\n data = await this.afterSend(response, data);\n }\n\n if (response.status >= 400) {\n throw new ClientResponseError({\n url: response.url,\n status: response.status,\n data: data,\n });\n }\n\n return data as T;\n }).catch((err) => {\n // wrap to normalize all errors\n throw new ClientResponseError(err);\n });\n }\n\n /**\n * Shallow copy the provided object and takes care to initialize\n * any options required to preserve the backward compatability.\n *\n * @param {SendOptions} options\n * @return {SendOptions}\n */\n private initSendOptions(path: string, options: SendOptions): SendOptions {\n options = Object.assign({ method: 'GET' } as SendOptions, options)\n options.query = options.query || {};\n\n // auto convert the body to FormData, if needed\n options.body = this.convertToFormDataIfNeeded(options.body);\n\n // move unknown send options as query parameters\n for (let key in options) {\n if (knownSendOptionsKeys.includes(key)) {\n continue\n }\n\n options.query[key] = options[key];\n delete (options[key]);\n }\n\n // requestKey normalizations for backward-compatibility\n // ---\n options.query = Object.assign({}, options.params, options.query);\n if (typeof options.requestKey === 'undefined') {\n if (options.$autoCancel === false || options.query.$autoCancel === false) {\n options.requestKey = null;\n } else if (options.$cancelKey || options.query.$cancelKey) {\n options.requestKey = options.$cancelKey || options.query.$cancelKey;\n }\n }\n // remove the deprecated special cancellation params from the other query params\n delete options.$autoCancel;\n delete options.query.$autoCancel;\n delete options.$cancelKey;\n delete options.query.$cancelKey;\n // ---\n\n // add the json header, if not explicitly set\n // (for FormData body the Content-Type header should be skipped since the boundary is autogenerated)\n if (\n this.getHeader(options.headers, 'Content-Type') === null &&\n !this.isFormData(options.body)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Content-Type': 'application/json',\n });\n }\n\n // add Accept-Language header, if not explicitly set\n if (this.getHeader(options.headers, 'Accept-Language') === null) {\n options.headers = Object.assign({}, options.headers, {\n 'Accept-Language': this.lang,\n });\n }\n\n // check if Authorization header can be added\n if (\n // has valid token\n this.authStore.token &&\n // auth header is not explicitly set\n (this.getHeader(options.headers, 'Authorization') === null)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Authorization': this.authStore.token,\n });\n }\n\n // handle auto cancelation for duplicated pending request\n if (this.enableAutoCancellation && options.requestKey !== null) {\n const requestKey = options.requestKey || ((options.method || 'GET') + path);\n\n delete options.requestKey;\n\n // cancel previous pending requests\n this.cancelRequest(requestKey);\n\n const controller = new AbortController();\n this.cancelControllers[requestKey] = controller;\n options.signal = controller.signal;\n }\n\n return options\n }\n\n /**\n * Converts analyzes the provided body and converts it to FormData\n * in case a plain object with File/Blob values is used.\n */\n private convertToFormDataIfNeeded(body: any): any {\n if (\n typeof FormData === 'undefined' ||\n typeof body === \"undefined\" ||\n typeof body !== \"object\" ||\n body === null ||\n this.isFormData(body) ||\n !this.hasBlobField(body)\n ) {\n return body;\n }\n\n const form = new FormData();\n\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let val of values) {\n form.append(key, val);\n }\n }\n\n return form;\n }\n\n /**\n * Checks if the submitted body object has at least one Blob/File field.\n */\n private hasBlobField(body: {[key:string]: any}): boolean {\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let v of values) {\n if (\n (typeof Blob !== 'undefined' && v instanceof Blob) ||\n (typeof File !== 'undefined' && v instanceof File)\n ) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /**\n * Extracts the header with the provided name in case-insensitive manner.\n * Returns `null` if no header matching the name is found.\n */\n private getHeader(headers: {[key:string]:string}|undefined, name: string): string|null {\n headers = headers || {};\n name = name.toLowerCase();\n\n for (let key in headers) {\n if (key.toLowerCase() == name) {\n return headers[key];\n }\n }\n\n return null;\n }\n\n /**\n * Loosely checks if the specified body is a FormData instance.\n */\n private isFormData(body: any): boolean {\n return body && (\n // we are checking the constructor name because FormData\n // is not available natively in some environments and the\n // polyfill(s) may not be globally accessible\n body.constructor.name === 'FormData' ||\n // fallback to global FormData instance check\n // note: this is needed because the constructor.name could be different in case of\n // custom global FormData implementation, eg. React Native on Android/iOS\n (typeof FormData !== 'undefined' && body instanceof FormData)\n )\n }\n\n /**\n * Serializes the provided query parameters into a query string.\n */\n private serializeQueryParams(params: {[key: string]: any}): string {\n const result: Array = [];\n for (const key in params) {\n if (params[key] === null) {\n // skip null query params\n continue;\n }\n\n const value = params[key];\n const encodedKey = encodeURIComponent(key);\n\n if (Array.isArray(value)) {\n // repeat array params\n for (const v of value) {\n result.push(encodedKey + '=' + encodeURIComponent(v));\n }\n } else if (value instanceof Date) {\n result.push(encodedKey + '=' + encodeURIComponent(value.toISOString()));\n } else if (typeof value !== null && typeof value === 'object') {\n result.push(encodedKey + '=' + encodeURIComponent(JSON.stringify(value)));\n } else {\n result.push(encodedKey + '=' + encodeURIComponent(value));\n }\n }\n\n return result.join('&');\n }\n}\n"],"names":["ClientResponseError","Error","constructor","errData","super","this","url","status","response","isAbort","originalError","Object","setPrototypeOf","prototype","data","DOMException","name","message","_a","_d","_c","_b","cause","includes","toJSON","assign","fieldContentRegExp","cookieSerialize","val","options","opt","encode","defaultEncode","test","TypeError","value","result","maxAge","isNaN","isFinite","Math","floor","domain","path","expires","isDate","toString","call","Date","valueOf","toUTCString","httpOnly","secure","priority","toLowerCase","sameSite","defaultDecode","indexOf","decodeURIComponent","encodeURIComponent","atobPolyfill","getTokenPayload","token","encodedPayload","split","map","c","charCodeAt","slice","join","JSON","parse","e","atob","input","str","String","replace","length","bs","buffer","bc","idx","output","charAt","fromCharCode","defaultCookieKey","BaseAuthStore","baseToken","baseModel","_onChangeCallbacks","model","isValid","isTokenExpired","expirationThreshold","payload","keys","exp","now","isAdmin","type","isAuthRecord","save","triggerChange","clear","loadFromCookie","cookie","key","rawData","cookieParse","decode","index","eqIdx","endIdx","lastIndexOf","trim","undefined","_","Array","isArray","exportToCookie","defaultOptions","stringify","resultLength","Blob","size","id","email","extraProps","prop","onChange","callback","fireImmediately","push","i","splice","LocalAuthStore","storageKey","storageFallback","_bindStorageEvent","_storageGet","_storageSet","_storageRemove","window","localStorage","rawValue","getItem","normalizedVal","setItem","removeItem","addEventListener","BaseService","client","SettingsService","getAll","method","send","update","bodyParams","body","testS3","filesystem","then","testEmail","toEmail","emailTemplate","template","generateAppleClientSecret","clientId","teamId","keyId","privateKey","duration","CrudService","getFullList","batchOrqueryParams","_getFullList","batch","getList","page","perPage","query","baseCrudPath","responseData","items","item","getFirstListItem","filter","requestKey","skipTotal","code","getOne","create","batchSize","request","__awaiter","list","concat","normalizeLegacyOptionsArgs","legacyWarn","baseOptions","bodyOrOptions","hasQuery","console","warn","AdminService","authStore","collectionId","delete","success","authResponse","admin","authWithPassword","password","identity","bind","authRefresh","requestPasswordReset","confirmPasswordReset","resetToken","passwordConfirm","RealtimeService","eventSource","subscriptions","lastSentTopics","maxConnectTimeout","reconnectAttempts","maxReconnectAttempts","Infinity","predefinedReconnectIntervals","pendingConnects","isConnected","subscribe","topic","listener","msgEvent","submitSubscriptions","connect","unsubscribeByTopicAndListener","unsubscribe","hasSubscriptionListeners","removeEventListener","disconnect","unsubscribeByPrefix","topicPrefix","hasAtleastOneTopic","startsWith","exist","topicToCheck","addAllSubscriptionListeners","getNonEmptySubscriptionTopics","getSubscriptionsCancelKey","catch","err","removeAllSubscriptionListeners","Promise","resolve","reject","initConnect","clearTimeout","connectTimeoutId","setTimeout","connectErrorHandler","EventSource","buildUrl","onerror","lastEventId","retries","hasUnsentSubscriptions","p","reconnectTimeoutId","latestTopics","t","timeout","fromReconnect","cancelRequest","close","RecordService","collectionIdOrName","baseCollectionPath","subscribeOne","recordId","realtime","topicOrCallback","batchOrOptions","params","collectionName","record","listAuthMethods","usernamePassword","emailPassword","authProviders","usernameOrEmail","authWithOAuth2Code","provider","codeVerifier","redirectUrl","createData","authWithOAuth2","args","config","find","eagerDefaultPopup","cleanup","urlCallback","openBrowserPopup","oldState","state","scopes","authData","replacements","_replaceQueryParams","authUrl","location","href","passwordResetToken","requestVerification","confirmVerification","verificationToken","requestEmailChange","newEmail","confirmEmailChange","emailChangeToken","listExternalAuths","unlinkExternalAuth","urlPath","substring","parsedParams","rawParams","param","pair","hasOwnProperty","open","width","height","windowWidth","innerWidth","windowHeight","innerHeight","left","top","CollectionService","import","collections","deleteMissing","LogService","getRequestsList","getRequest","getRequestsStats","HealthService","check","FileService","getUrl","filename","queryParams","parts","download","URLSearchParams","getToken","BackupService","basename","restore","getDownloadUrl","knownSendOptionsKeys","Client","baseUrl","lang","cancelControllers","recordServices","enableAutoCancellation","admins","files","logs","settings","health","backups","collection","idOrName","autoCancellation","enable","abort","cancelAllRequests","k","getFileUrl","origin","endsWith","pathname","initSendOptions","serializeQueryParams","beforeSend","getHeader","headers","fetch","json","afterSend","convertToFormDataIfNeeded","$autoCancel","$cancelKey","isFormData","Authorization","controller","AbortController","signal","FormData","hasBlobField","form","values","append","v","File","encodedKey","toISOString"],"mappings":"mcAIM,MAAOA,4BAA4BC,MAOrC,WAAAC,CAAYC,eACRC,MAAM,uBAPVC,KAAGC,IAA8B,GACjCD,KAAME,OAA2B,EACjCF,KAAQG,SAAyB,GACjCH,KAAOI,SAA0B,EACjCJ,KAAaK,cAAoB,KAO7BC,OAAOC,eAAeP,KAAML,oBAAoBa,WAEhC,OAAZV,GAAuC,iBAAZA,IAC3BE,KAAKC,IAAuC,iBAAhBH,EAAQG,IAAmBH,EAAQG,IAAM,GACrED,KAAKE,OAA0C,iBAAnBJ,EAAQI,OAAsBJ,EAAQI,OAAS,EAC3EF,KAAKI,UAAkBN,EAAQM,QAC/BJ,KAAKK,cAAgBP,EAAQO,cAEJ,OAArBP,EAAQK,UAAiD,iBAArBL,EAAQK,SAC5CH,KAAKG,SAAYL,EAAQK,SACD,OAAjBL,EAAQW,MAAyC,iBAAjBX,EAAQW,KAC/CT,KAAKG,SAAYL,EAAQW,KAEzBT,KAAKG,SAAY,IAIpBH,KAAKK,eAAmBP,aAAmBH,sBAC5CK,KAAKK,cAAgBP,GAGG,oBAAj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,EAAa/V,mBAAmBgD,GAEtC,GAAIW,MAAMC,QAAQpF,GAEd,IAAK,MAAMqX,KAAKrX,EACZC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmB6V,SAE/CrX,aAAiBa,KACxBZ,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBxB,EAAMwX,gBAChC,cAAVxX,GAAmC,iBAAVA,EACvCC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBW,KAAKoD,UAAUvF,KAEjEC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBxB,GAEzD,CAED,OAAOC,EAAOiC,KAAK,IACtB"} \ No newline at end of file diff --git a/dist/pocketbase.umd.d.ts b/dist/pocketbase.umd.d.ts index 87240a4..ac07ca2 100644 --- a/dist/pocketbase.umd.d.ts +++ b/dist/pocketbase.umd.d.ts @@ -1021,9 +1021,9 @@ declare class Client { /** * Legacy alias of `pb.files.getUrl()`. */ - getFileUrl(record: Pick<{ + getFileUrl(record: { [key: string]: any; - }, 'id' | 'collectionId' | 'collectionName'>, filename: string, queryParams?: FileOptions): string; + }, filename: string, queryParams?: FileOptions): string; /** * Builds a full client url by safely concatenating the provided path. */ diff --git a/dist/pocketbase.umd.js.map b/dist/pocketbase.umd.js.map index 58fabb5..c61c96e 100644 --- a/dist/pocketbase.umd.js.map +++ b/dist/pocketbase.umd.js.map @@ -1 +1 @@ -{"version":3,"file":"pocketbase.umd.js","sources":["../src/ClientResponseError.ts","../src/stores/utils/cookie.ts","../src/stores/utils/jwt.ts","../src/stores/BaseAuthStore.ts","../src/stores/LocalAuthStore.ts","../src/services/utils/BaseService.ts","../src/services/SettingsService.ts","../src/services/utils/CrudService.ts","../src/services/utils/legacy.ts","../src/services/AdminService.ts","../src/services/RealtimeService.ts","../src/services/RecordService.ts","../src/services/CollectionService.ts","../src/services/LogService.ts","../src/services/HealthService.ts","../src/services/FileService.ts","../src/services/BackupService.ts","../src/Client.ts"],"sourcesContent":["/**\n * ClientResponseError is a custom Error class that is intended to wrap\n * and normalize any error thrown by `Client.send()`.\n */\nexport class ClientResponseError extends Error {\n url: string = '';\n status: number = 0;\n response: {[key: string]: any} = {};\n isAbort: boolean = false;\n originalError: any = null;\n\n constructor(errData?: any) {\n super(\"ClientResponseError\");\n\n // Set the prototype explicitly.\n // https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\n Object.setPrototypeOf(this, ClientResponseError.prototype);\n\n if (errData !== null && typeof errData === 'object') {\n this.url = typeof errData.url === 'string' ? errData.url : '';\n this.status = typeof errData.status === 'number' ? errData.status : 0;\n this.isAbort = !!errData.isAbort;\n this.originalError = errData.originalError;\n\n if (errData.response !== null && typeof errData.response === 'object') {\n this.response = errData.response;\n } else if (errData.data !== null && typeof errData.data === 'object') {\n this.response = errData.data;\n } else {\n this.response = {};\n }\n }\n\n if (!this.originalError && !(errData instanceof ClientResponseError)) {\n this.originalError = errData;\n }\n\n if (typeof DOMException !== 'undefined' && errData instanceof DOMException) {\n this.isAbort = true;\n }\n\n this.name = \"ClientResponseError \" + this.status;\n this.message = this.response?.message;\n if (!this.message) {\n if (this.isAbort) {\n this.message = 'The request was autocancelled. You can find more info in https://github.com/pocketbase/js-sdk#auto-cancellation.';\n } else if (this.originalError?.cause?.message?.includes(\"ECONNREFUSED ::1\")) {\n this.message = 'Failed to connect to the PocketBase server. Try changing the SDK URL from localhost to 127.0.0.1 (https://github.com/pocketbase/js-sdk/issues/21).';\n } else {\n this.message = 'Something went wrong while processing your request.';\n }\n }\n }\n\n /**\n * Alias for `this.response` to preserve the backward compatibility.\n */\n get data() {\n return this.response;\n }\n\n /**\n * Make a POJO's copy of the current error class instance.\n * @see https://github.com/vuex-orm/vuex-orm/issues/255\n */\n toJSON() {\n return { ...this };\n }\n}\n","/**\n * -------------------------------------------------------------------\n * Simple cookie parse and serialize utilities mostly based on the\n * node module https://github.com/jshttp/cookie.\n * -------------------------------------------------------------------\n */\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\nconst fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;\n\nexport interface ParseOptions{\n decode?: (val: string) => string,\n}\n\n/**\n* Parses the given cookie header string into an object\n* The object has the various cookies as keys(names) => values\n*/\nexport function cookieParse(str: string, options?: ParseOptions): { [key: string]: any } {\n const result: { [key: string]: any } = {};\n\n if (typeof str !== 'string') {\n return result;\n }\n\n const opt = Object.assign({}, options || {});\n const decode = opt.decode || defaultDecode;\n\n let index = 0;\n while (index < str.length) {\n const eqIdx = str.indexOf('=', index);\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break;\n }\n\n let endIdx = str.indexOf(';', index);\n\n if (endIdx === -1) {\n endIdx = str.length;\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(';', eqIdx - 1) + 1;\n continue;\n }\n\n const key = str.slice(index, eqIdx).trim();\n\n // only assign once\n if (undefined === result[key]) {\n let val = str.slice(eqIdx + 1, endIdx).trim();\n\n // quoted values\n if (val.charCodeAt(0) === 0x22) {\n val = val.slice(1, -1);\n }\n\n try {\n result[key] = decode(val);\n } catch (_) {\n result[key] = val; // no decoding\n }\n }\n\n index = endIdx + 1;\n }\n\n return result;\n};\n\nexport interface SerializeOptions {\n encode?: (val: string | number | boolean) => string,\n maxAge?: number,\n domain?: string,\n path?: string,\n expires?: Date,\n httpOnly?: boolean,\n secure?: boolean,\n priority?: string,\n sameSite?: boolean|string,\n}\n\n/**\n * Serialize data into a cookie header.\n *\n * Serialize the a name value pair into a cookie string suitable for\n * http headers. An optional options object specified cookie parameters.\n *\n * ```js\n * cookieSerialize('foo', 'bar', { httpOnly: true }) // \"foo=bar; httpOnly\"\n * ```\n */\nexport function cookieSerialize(name: string, val: string, options?: SerializeOptions): string {\n const opt = Object.assign({}, options || {});\n const encode = opt.encode || defaultEncode;\n\n if (!fieldContentRegExp.test(name)) {\n throw new TypeError('argument name is invalid');\n }\n\n const value = encode(val);\n\n if (value && !fieldContentRegExp.test(value)) {\n throw new TypeError('argument val is invalid');\n }\n\n let result = name + '=' + value;\n\n if (opt.maxAge != null) {\n const maxAge = opt.maxAge - 0;\n\n if (isNaN(maxAge) || !isFinite(maxAge)) {\n throw new TypeError('option maxAge is invalid');\n }\n\n result += '; Max-Age=' + Math.floor(maxAge);\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new TypeError('option domain is invalid');\n }\n\n result += '; Domain=' + opt.domain;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new TypeError('option path is invalid');\n }\n\n result += '; Path=' + opt.path;\n }\n\n if (opt.expires) {\n if (!isDate(opt.expires) || isNaN(opt.expires.valueOf())) {\n throw new TypeError('option expires is invalid');\n }\n\n result += '; Expires=' + opt.expires.toUTCString();\n }\n\n if (opt.httpOnly) {\n result += '; HttpOnly';\n }\n\n if (opt.secure) {\n result += '; Secure';\n }\n\n if (opt.priority) {\n const priority = typeof opt.priority === 'string' ? opt.priority.toLowerCase() : opt.priority;\n\n switch (priority) {\n case 'low':\n result += '; Priority=Low';\n break;\n case 'medium':\n result += '; Priority=Medium';\n break;\n case 'high':\n result += '; Priority=High';\n break;\n default:\n throw new TypeError('option priority is invalid');\n }\n }\n\n if (opt.sameSite) {\n const sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;\n\n switch (sameSite) {\n case true:\n result += '; SameSite=Strict';\n break;\n case 'lax':\n result += '; SameSite=Lax';\n break;\n case 'strict':\n result += '; SameSite=Strict';\n break;\n case 'none':\n result += '; SameSite=None';\n break;\n default:\n throw new TypeError('option sameSite is invalid');\n }\n }\n\n return result;\n};\n\n/**\n * Default URL-decode string value function.\n * Optimized to skip native call when no `%`.\n */\nfunction defaultDecode(val: string): string {\n return val.indexOf('%') !== -1\n ? decodeURIComponent(val)\n : val;\n}\n\n/**\n * Default URL-encode value function.\n */\nfunction defaultEncode(val: string | number | boolean): string {\n return encodeURIComponent(val);\n}\n\n/**\n * Determines if value is a Date.\n */\nfunction isDate(val: any): boolean {\n return (\n Object.prototype.toString.call(val) === '[object Date]' ||\n val instanceof Date\n );\n}\n","let atobPolyfill: Function;\nif (typeof atob === 'function') {\n atobPolyfill = atob\n} else {\n /**\n * The code was extracted from:\n * https://github.com/davidchambers/Base64.js\n */\n atobPolyfill = (input: any) => {\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\n let str = String(input).replace(/=+$/, \"\");\n if (str.length % 4 == 1) {\n throw new Error(\"'atob' failed: The string to be decoded is not correctly encoded.\");\n }\n\n for (\n // initialize result and counters\n var bc = 0, bs, buffer, idx = 0, output = \"\";\n // get next character\n (buffer = str.charAt(idx++));\n // character found in table? initialize bit storage and add its ascii value;\n ~buffer &&\n ((bs = bc % 4 ? (bs as any) * 64 + buffer : buffer),\n // and if not first of each 4 characters,\n // convert the first 8 bits to one ascii character\n bc++ % 4) ?\n (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)))) :\n 0\n ) {\n // try to find character in table (0-63, not found => -1)\n buffer = chars.indexOf(buffer);\n }\n\n return output;\n };\n}\n\n/**\n * Returns JWT token's payload data.\n */\nexport function getTokenPayload(token: string): { [key: string]: any } {\n if (token) {\n try {\n const encodedPayload = decodeURIComponent(atobPolyfill(token.split('.')[1]).split('').map(function (c: string) {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n }).join(''));\n\n return JSON.parse(encodedPayload) || {};\n } catch (e) {\n }\n }\n\n return {};\n}\n\n/**\n * Checks whether a JWT token is expired or not.\n * Tokens without `exp` payload key are considered valid.\n * Tokens with empty payload (eg. invalid token strings) are considered expired.\n *\n * @param token The token to check.\n * @param [expirationThreshold] Time in seconds that will be subtracted from the token `exp` property.\n */\nexport function isTokenExpired(token: string, expirationThreshold = 0): boolean {\n let payload = getTokenPayload(token);\n\n if (\n Object.keys(payload).length > 0 &&\n (!payload.exp || (payload.exp - expirationThreshold) > (Date.now() / 1000))\n ) {\n return false;\n }\n\n return true;\n}\n","import { cookieParse, cookieSerialize, SerializeOptions } from '@/stores/utils/cookie';\nimport { isTokenExpired, getTokenPayload } from '@/stores/utils/jwt';\nimport { RecordModel, AdminModel } from '@/services/utils/dtos';\n\nexport type AuthModel = RecordModel|AdminModel|null;\n\nexport type OnStoreChangeFunc = (token: string, model: AuthModel) => void;\n\nconst defaultCookieKey = 'pb_auth';\n\n/**\n * Base AuthStore class that is intended to be extended by all other\n * PocketBase AuthStore implementations.\n */\nexport abstract class BaseAuthStore {\n protected baseToken: string = '';\n protected baseModel: AuthModel = null;\n\n private _onChangeCallbacks: Array = [];\n\n /**\n * Retrieves the stored token (if any).\n */\n get token(): string {\n return this.baseToken;\n }\n\n /**\n * Retrieves the stored model data (if any).\n */\n get model(): AuthModel {\n return this.baseModel;\n }\n\n /**\n * Loosely checks if the store has valid token (aka. existing and unexpired exp claim).\n */\n get isValid(): boolean {\n return !isTokenExpired(this.token);\n }\n\n /**\n * Checks whether the current store state is for admin authentication.\n */\n get isAdmin(): boolean {\n return getTokenPayload(this.token).type === \"admin\";\n }\n\n /**\n * Checks whether the current store state is for auth record authentication.\n */\n get isAuthRecord(): boolean {\n return getTokenPayload(this.token).type === \"authRecord\";\n }\n\n /**\n * Saves the provided new token and model data in the auth store.\n */\n save(token: string, model?: AuthModel): void {\n this.baseToken = token || '';\n this.baseModel = model || null;\n\n this.triggerChange();\n }\n\n /**\n * Removes the stored token and model data form the auth store.\n */\n clear(): void {\n this.baseToken = '';\n this.baseModel = null;\n this.triggerChange();\n }\n\n /**\n * Parses the provided cookie string and updates the store state\n * with the cookie's token and model data.\n *\n * NB! This function doesn't validate the token or its data.\n * Usually this isn't a concern if you are interacting only with the\n * PocketBase API because it has the proper server-side security checks in place,\n * but if you are using the store `isValid` state for permission controls\n * in a node server (eg. SSR), then it is recommended to call `authRefresh()`\n * after loading the cookie to ensure an up-to-date token and model state.\n * For example:\n *\n * ```js\n * pb.authStore.loadFromCookie(\"cookie string...\");\n *\n * try {\n * // get an up-to-date auth store state by veryfing and refreshing the loaded auth model (if any)\n * pb.authStore.isValid && await pb.collection('users').authRefresh();\n * } catch (_) {\n * // clear the auth store on failed refresh\n * pb.authStore.clear();\n * }\n * ```\n */\n loadFromCookie(cookie: string, key = defaultCookieKey): void {\n const rawData = cookieParse(cookie || '')[key] || '';\n\n let data: { [key: string]: any } = {};\n try {\n data = JSON.parse(rawData);\n // normalize\n if (typeof data === null || typeof data !== 'object' || Array.isArray(data)) {\n data = {};\n }\n } catch (_) {}\n\n this.save(data.token || '', data.model || null);\n }\n\n /**\n * Exports the current store state as cookie string.\n *\n * By default the following optional attributes are added:\n * - Secure\n * - HttpOnly\n * - SameSite=Strict\n * - Path=/\n * - Expires={the token expiration date}\n *\n * NB! If the generated cookie exceeds 4096 bytes, this method will\n * strip the model data to the bare minimum to try to fit within the\n * recommended size in https://www.rfc-editor.org/rfc/rfc6265#section-6.1.\n */\n exportToCookie(options?: SerializeOptions, key = defaultCookieKey): string {\n const defaultOptions: SerializeOptions = {\n secure: true,\n sameSite: true,\n httpOnly: true,\n path: \"/\",\n };\n\n // extract the token expiration date\n const payload = getTokenPayload(this.token);\n if (payload?.exp) {\n defaultOptions.expires = new Date(payload.exp * 1000);\n } else {\n defaultOptions.expires = new Date('1970-01-01');\n }\n\n // merge with the user defined options\n options = Object.assign({}, defaultOptions, options);\n\n const rawData = {\n token: this.token,\n model: this.model ? JSON.parse(JSON.stringify(this.model)) : null,\n };\n\n let result = cookieSerialize(key, JSON.stringify(rawData), options);\n\n const resultLength = typeof Blob !== 'undefined' ?\n (new Blob([result])).size : result.length;\n\n // strip down the model data to the bare minimum\n if (rawData.model && resultLength > 4096) {\n rawData.model = {id: rawData?.model?.id, email: rawData?.model?.email};\n const extraProps = [\"collectionId\", \"username\", \"verified\"];\n for (const prop in this.model) {\n if (extraProps.includes(prop)) {\n rawData.model[prop] = this.model[prop];\n }\n }\n result = cookieSerialize(key, JSON.stringify(rawData), options);\n }\n\n return result;\n }\n\n /**\n * Register a callback function that will be called on store change.\n *\n * You can set the `fireImmediately` argument to true in order to invoke\n * the provided callback right after registration.\n *\n * Returns a removal function that you could call to \"unsubscribe\" from the changes.\n */\n onChange(callback: OnStoreChangeFunc, fireImmediately = false): () => void {\n this._onChangeCallbacks.push(callback);\n\n if (fireImmediately) {\n callback(this.token, this.model);\n }\n\n return () => {\n for (let i = this._onChangeCallbacks.length - 1; i >= 0; i--) {\n if (this._onChangeCallbacks[i] == callback) {\n delete this._onChangeCallbacks[i]; // removes the function reference\n this._onChangeCallbacks.splice(i, 1); // reindex the array\n return;\n }\n }\n }\n }\n\n protected triggerChange(): void {\n for (const callback of this._onChangeCallbacks) {\n callback && callback(this.token, this.model);\n }\n }\n}\n","import { BaseAuthStore, AuthModel } from '@/stores/BaseAuthStore';\n\n/**\n * The default token store for browsers with auto fallback\n * to runtime/memory if local storage is undefined (eg. in node env).\n */\nexport class LocalAuthStore extends BaseAuthStore {\n private storageFallback: { [key: string]: any } = {};\n private storageKey: string\n\n constructor(storageKey = \"pocketbase_auth\") {\n super();\n\n this.storageKey = storageKey;\n\n this._bindStorageEvent();\n }\n\n /**\n * @inheritdoc\n */\n get token(): string {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.token || '';\n }\n\n /**\n * @inheritdoc\n */\n get model(): AuthModel {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.model || null;\n }\n\n /**\n * @inheritdoc\n */\n save(token: string, model?: AuthModel) {\n this._storageSet(this.storageKey, {\n 'token': token,\n 'model': model,\n });\n\n super.save(token, model);\n }\n\n /**\n * @inheritdoc\n */\n clear() {\n this._storageRemove(this.storageKey);\n\n super.clear();\n }\n\n // ---------------------------------------------------------------\n // Internal helpers:\n // ---------------------------------------------------------------\n\n /**\n * Retrieves `key` from the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageGet(key: string): any {\n if (typeof window !== 'undefined' && window?.localStorage) {\n const rawValue = window.localStorage.getItem(key) || '';\n try {\n return JSON.parse(rawValue);\n } catch (e) { // not a json\n return rawValue;\n }\n }\n\n // fallback\n return this.storageFallback[key];\n }\n\n /**\n * Stores a new data in the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageSet(key: string, value: any) {\n if (typeof window !== 'undefined' && window?.localStorage) {\n // store in local storage\n let normalizedVal = value;\n if (typeof value !== 'string') {\n normalizedVal = JSON.stringify(value);\n }\n window.localStorage.setItem(key, normalizedVal);\n } else {\n // store in fallback\n this.storageFallback[key] = value;\n }\n }\n\n /**\n * Removes `key` from the browser's local storage and the runtime/memory.\n */\n private _storageRemove(key: string) {\n // delete from local storage\n if (typeof window !== 'undefined' && window?.localStorage) {\n window.localStorage?.removeItem(key);\n }\n\n // delete from fallback\n delete this.storageFallback[key];\n }\n\n /**\n * Updates the current store state on localStorage change.\n */\n private _bindStorageEvent() {\n if (typeof window === 'undefined' || !window?.localStorage || !window.addEventListener) {\n return;\n }\n\n window.addEventListener('storage', (e) => {\n if (e.key != this.storageKey) {\n return;\n }\n\n const data = this._storageGet(this.storageKey) || {};\n\n super.save(data.token || '', data.model || null);\n });\n }\n}\n","import Client from '@/Client';\n\n/**\n * BaseService class that should be inherited from all API services.\n */\nexport abstract class BaseService {\n readonly client: Client\n\n constructor(client: Client) {\n this.client = client;\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\ninterface appleClientSecret {\n secret: string;\n}\n\nexport class SettingsService extends BaseService {\n /**\n * Fetch all available app settings.\n */\n getAll(options?: CommonOptions): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Bulk updates app settings.\n */\n update(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Performs a S3 filesystem connection test.\n *\n * The currently supported `filesystem` are \"storage\" and \"backups\".\n */\n testS3(filesystem: string = \"storage\", options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'filesystem': filesystem,\n },\n }, options);\n\n return this.client.send('/api/settings/test/s3', options)\n .then(() => true);\n }\n\n /**\n * Sends a test email.\n *\n * The possible `emailTemplate` values are:\n * - verification\n * - password-reset\n * - email-change\n */\n testEmail(toEmail: string, emailTemplate: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'email': toEmail,\n 'template': emailTemplate,\n },\n }, options);\n\n return this.client.send('/api/settings/test/email', options)\n .then(() => true);\n }\n\n /**\n * Generates a new Apple OAuth2 client secret.\n */\n generateAppleClientSecret(\n clientId: string,\n teamId: string,\n keyId: string,\n privateKey: string,\n duration: number,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n clientId,\n teamId,\n keyId,\n privateKey,\n duration,\n },\n }, options);\n\n return this.client.send('/api/settings/apple/generate-client-secret', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n FullListOptions\n} from '@/services/utils/options';\n\nexport abstract class CrudService extends BaseService {\n /**\n * Base path for the crud actions (without trailing slash, eg. '/admins').\n */\n abstract get baseCrudPath(): string\n\n /**\n * Response data decoder.\n */\n decode(data: { [key: string]: any }): T {\n return data as T;\n }\n\n /**\n * Returns a promise with all list items batch fetched at once\n * (by default 500 items per request; to change it set the `batch` query param).\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getFullList(options?: FullListOptions): Promise>\n\n /**\n * Legacy version of getFullList with explicitly specified batch size.\n */\n getFullList(batch?: number, options?: ListOptions): Promise>\n\n getFullList(batchOrqueryParams?: number|FullListOptions, options?: ListOptions): Promise> {\n if (typeof batchOrqueryParams == \"number\") {\n return this._getFullList(batchOrqueryParams, options);\n }\n\n options = Object.assign({}, batchOrqueryParams, options);\n\n let batch = 500;\n if (options.batch) {\n batch = options.batch;\n delete options.batch;\n }\n\n return this._getFullList(batch, options);\n }\n\n /**\n * Returns paginated items list.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({\n method: 'GET'\n }, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => {\n responseData.items = responseData.items?.map((item: any) => {\n return this.decode(item);\n }) || [];\n\n return responseData;\n });\n }\n\n /**\n * Returns the first found item by the specified filter.\n *\n * Internally it calls `getList(1, 1, { filter, skipTotal })` and\n * returns the first found item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n *\n * For consistency with `getOne`, this method will throw a 404\n * ClientResponseError if no item was found.\n */\n getFirstListItem(filter: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'requestKey': 'one_by_filter_' + this.baseCrudPath + \"_\" + filter,\n }, options);\n\n options.query = Object.assign({\n 'filter': filter,\n 'skipTotal': 1,\n }, options.query);\n\n return this.getList(1, 1, options)\n .then((result) => {\n if (!result?.items?.length) {\n throw new ClientResponseError({\n status: 404,\n data: {\n code: 404,\n message: \"The requested resource wasn't found.\",\n data: {},\n },\n });\n }\n\n return result.items[0];\n });\n }\n\n /**\n * Returns single item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getOne(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Creates a new item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n create(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Updates an existing item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Deletes an existing item by its id.\n */\n delete(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then(() => true);\n }\n\n /**\n * Returns a promise with all list items batch fetched at once.\n */\n protected _getFullList(batchSize = 500, options?: ListOptions): Promise> {\n options = options || {};\n options.query = Object.assign({\n 'skipTotal': 1,\n }, options.query);\n\n let result: Array = [];\n\n let request = async (page: number): Promise> => {\n return this.getList(page, batchSize || 500, options).then((list) => {\n const castedList = (list as any as ListResult);\n const items = castedList.items;\n\n result = result.concat(items);\n\n if (items.length == list.perPage) {\n return request(page + 1);\n }\n\n return result;\n });\n }\n\n return request(1);\n }\n}\n","import { SendOptions } from '@/services/utils/options';\n\nexport function normalizeLegacyOptionsArgs(legacyWarn: string, baseOptions: SendOptions, bodyOrOptions?: any, query?: any): SendOptions {\n const hasBodyOrOptions = typeof bodyOrOptions !== 'undefined';\n const hasQuery = typeof query !== 'undefined';\n\n if (!hasQuery && !hasBodyOrOptions) {\n return baseOptions;\n }\n\n if (hasQuery) {\n console.warn(legacyWarn);\n baseOptions.body = Object.assign({}, baseOptions.body, bodyOrOptions);\n baseOptions.query = Object.assign({}, baseOptions.query, query);\n\n return baseOptions;\n }\n\n baseOptions = Object.assign(baseOptions, bodyOrOptions);\n return baseOptions;\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { AdminModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface AdminAuthResponse {\n [key: string]: any;\n\n token: string;\n admin: AdminModel;\n}\n\nexport class AdminService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/admins';\n }\n\n // ---------------------------------------------------------------\n // Post update/delete AuthStore sync\n // ---------------------------------------------------------------\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n // update the store state if the updated item id matches with the stored model\n if (\n this.client.authStore.model?.id === item.id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n // clear the store state if the deleted item id matches with the stored model\n if (\n success &&\n this.client.authStore.model?.id === id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful authorize response.\n */\n protected authResponse(responseData: any): AdminAuthResponse {\n const admin = this.decode(responseData?.admin || {});\n\n if (responseData?.token && responseData?.admin) {\n this.client.authStore.save(responseData.token, admin);\n }\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'admin': admin,\n });\n }\n\n /**\n * Authenticate an admin account with its email and password\n * and returns a new admin token and data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authWithPassword(email: string, password: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authWithPassword(email, password, options?).\n */\n authWithPassword(email: string, password: string, body?: any, query?: any): Promise\n\n authWithPassword(\n email: string,\n password: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': email,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(email, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(email, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-with-password', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Refreshes the current admin authenticated instance and\n * returns a new token and admin data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authRefresh(options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-refresh', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Sends admin password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/request-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Confirms admin password reset request.\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(resetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, body?: any, query?: any): Promise\n\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, bodyOrOptions?: any, query?: any): Promise{\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': resetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(resetToken, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(resetToken, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\n\ninterface promiseCallbacks {\n resolve: Function\n reject: Function\n}\n\nexport type UnsubscribeFunc = () => Promise;\n\nexport class RealtimeService extends BaseService {\n clientId: string = \"\";\n\n private eventSource: EventSource | null = null;\n private subscriptions: { [key: string]: Array } = {};\n private lastSentTopics: Array = [];\n private connectTimeoutId: any;\n private maxConnectTimeout: number = 15000;\n private reconnectTimeoutId: any;\n private reconnectAttempts: number = 0;\n private maxReconnectAttempts: number = Infinity;\n private predefinedReconnectIntervals: Array = [\n 200, 300, 500, 1000, 1200, 1500, 2000,\n ];\n private pendingConnects: Array = [];\n\n /**\n * Returns whether the realtime connection has been established.\n */\n get isConnected(): boolean {\n return !!this.eventSource && !!this.clientId && !this.pendingConnects.length;\n }\n\n /**\n * Register the subscription listener.\n *\n * You can subscribe multiple times to the same topic.\n *\n * If the SSE connection is not started yet,\n * this method will also initialize it.\n */\n async subscribe(topic: string, callback: (data: any) => void): Promise {\n if (!topic) {\n throw new Error('topic must be set.')\n }\n\n const listener = function (e: Event) {\n const msgEvent = (e as MessageEvent);\n\n let data;\n try {\n data = JSON.parse(msgEvent?.data);\n } catch {}\n\n callback(data || {});\n };\n\n // store the listener\n if (!this.subscriptions[topic]) {\n this.subscriptions[topic] = [];\n }\n this.subscriptions[topic].push(listener);\n\n if (!this.isConnected) {\n // initialize sse connection\n await this.connect();\n } else if (this.subscriptions[topic].length === 1) {\n // send the updated subscriptions (if it is the first for the topic)\n await this.submitSubscriptions();\n } else {\n // only register the listener\n this.eventSource?.addEventListener(topic, listener);\n }\n\n return async (): Promise => {\n return this.unsubscribeByTopicAndListener(topic, listener);\n };\n }\n\n /**\n * Unsubscribe from all subscription listeners with the specified topic.\n *\n * If `topic` is not provided, then this method will unsubscribe\n * from all active subscriptions.\n *\n * This method is no-op if there are no active subscriptions.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribe(topic?: string): Promise {\n if (!this.hasSubscriptionListeners(topic)) {\n return; // already unsubscribed\n }\n\n if (!topic) {\n // remove all subscriptions\n this.subscriptions = {};\n } else {\n // remove all topic listeners\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n /**\n * Unsubscribe from all subscription listeners starting with the specified topic prefix.\n *\n * This method is no-op if there are no active subscriptions with the specified topic prefix.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByPrefix(topicPrefix: string): Promise {\n let hasAtleastOneTopic = false;\n for (let topic in this.subscriptions) {\n if (!topic.startsWith(topicPrefix)) {\n continue;\n }\n\n hasAtleastOneTopic = true;\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!hasAtleastOneTopic) {\n return; // nothing to unsubscribe from\n }\n\n if (this.hasSubscriptionListeners()) {\n // submit the deleted subscriptions\n await this.submitSubscriptions();\n } else {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n }\n }\n\n /**\n * Unsubscribe from all subscriptions matching the specified topic and listener function.\n *\n * This method is no-op if there are no active subscription with\n * the specified topic and listener.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByTopicAndListener(topic: string, listener: EventListener): Promise {\n if (!Array.isArray(this.subscriptions[topic]) || !this.subscriptions[topic].length) {\n return; // already unsubscribed\n }\n\n let exist = false;\n for (let i = this.subscriptions[topic].length - 1; i >= 0; i--) {\n if (this.subscriptions[topic][i] !== listener) {\n continue;\n }\n\n exist = true; // has at least one matching listener\n delete this.subscriptions[topic][i]; // removes the function reference\n this.subscriptions[topic].splice(i, 1); // reindex the array\n this.eventSource?.removeEventListener(topic, listener);\n }\n if (!exist) {\n return;\n }\n\n // remove the topic from the subscriptions list if there are no other listeners\n if (!this.subscriptions[topic].length) {\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n private hasSubscriptionListeners(topicToCheck?: string): boolean {\n this.subscriptions = this.subscriptions || {};\n\n // check the specified topic\n if (topicToCheck) {\n return !!this.subscriptions[topicToCheck]?.length;\n }\n\n // check for at least one non-empty topic\n for (let topic in this.subscriptions) {\n if (!!this.subscriptions[topic]?.length) {\n return true\n }\n }\n\n return false;\n }\n\n private async submitSubscriptions(): Promise {\n if (!this.clientId) {\n return; // no client/subscriber\n }\n\n // optimistic update\n this.addAllSubscriptionListeners();\n\n this.lastSentTopics = this.getNonEmptySubscriptionTopics();\n\n return this.client.send('/api/realtime', {\n 'method': 'POST',\n 'body': {\n 'clientId': this.clientId,\n 'subscriptions': this.lastSentTopics,\n },\n 'query': {\n 'requestKey': this.getSubscriptionsCancelKey(),\n },\n }).catch((err) => {\n if (err?.isAbort) {\n return; // silently ignore aborted pending requests\n }\n throw err;\n });\n }\n\n private getSubscriptionsCancelKey(): string {\n return \"realtime_\" + this.clientId;\n }\n\n private getNonEmptySubscriptionTopics(): Array {\n const result : Array = [];\n\n for (let topic in this.subscriptions) {\n if (this.subscriptions[topic].length) {\n result.push(topic);\n }\n }\n\n return result;\n }\n\n private addAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n this.removeAllSubscriptionListeners();\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.addEventListener(topic, listener);\n }\n }\n }\n\n private removeAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.removeEventListener(topic, listener);\n }\n }\n }\n\n private async connect(): Promise {\n if (this.reconnectAttempts > 0) {\n // immediately resolve the promise to avoid indefinitely\n // blocking the client during reconnection\n return;\n }\n\n return new Promise((resolve, reject) => {\n this.pendingConnects.push({ resolve, reject });\n\n if (this.pendingConnects.length > 1) {\n // all promises will be resolved once the connection is established\n return;\n }\n\n this.initConnect();\n })\n }\n\n private initConnect() {\n this.disconnect(true);\n\n // wait up to 15s for connect\n clearTimeout(this.connectTimeoutId);\n this.connectTimeoutId = setTimeout(() => {\n this.connectErrorHandler(new Error(\"EventSource connect took too long.\"));\n }, this.maxConnectTimeout);\n\n this.eventSource = new EventSource(this.client.buildUrl('/api/realtime'))\n\n this.eventSource.onerror = (_) => {\n this.connectErrorHandler(new Error(\"Failed to establish realtime connection.\"));\n };\n\n this.eventSource.addEventListener('PB_CONNECT', (e) => {\n const msgEvent = (e as MessageEvent);\n this.clientId = msgEvent?.lastEventId;\n\n this.submitSubscriptions()\n .then(async () => {\n let retries = 3;\n while (this.hasUnsentSubscriptions() && retries > 0) {\n retries--;\n // resubscribe to ensure that the latest topics are submitted\n //\n // This is needed because missed topics could happen on reconnect\n // if after the pending sent `submitSubscriptions()` call another `subscribe()`\n // was made before the submit was able to complete.\n await this.submitSubscriptions();\n }\n }).then(() => {\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n\n // reset connect meta\n this.pendingConnects = [];\n this.reconnectAttempts = 0;\n clearTimeout(this.reconnectTimeoutId);\n clearTimeout(this.connectTimeoutId);\n }).catch((err) => {\n this.clientId = \"\";\n this.connectErrorHandler(err);\n });\n });\n }\n\n private hasUnsentSubscriptions(): boolean {\n const latestTopics = this.getNonEmptySubscriptionTopics();\n if (latestTopics.length != this.lastSentTopics.length) {\n return true;\n }\n\n for (const t of latestTopics) {\n if (!this.lastSentTopics.includes(t)) {\n return true;\n }\n }\n\n return false;\n }\n\n private connectErrorHandler(err: any) {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n\n if (\n // wasn't previously connected -> direct reject\n (!this.clientId && !this.reconnectAttempts) ||\n // was previously connected but the max reconnection limit has been reached\n this.reconnectAttempts > this.maxReconnectAttempts\n ) {\n for (let p of this.pendingConnects) {\n p.reject(new ClientResponseError(err));\n }\n this.pendingConnects = [];\n this.disconnect();\n return;\n }\n\n // otherwise -> reconnect in the background\n this.disconnect(true);\n const timeout = this.predefinedReconnectIntervals[this.reconnectAttempts] || this.predefinedReconnectIntervals[this.predefinedReconnectIntervals.length - 1];\n this.reconnectAttempts++;\n this.reconnectTimeoutId = setTimeout(() => {\n this.initConnect();\n }, timeout);\n }\n\n private disconnect(fromReconnect = false): void {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n this.removeAllSubscriptionListeners();\n this.client.cancelRequest(this.getSubscriptionsCancelKey());\n this.eventSource?.close();\n this.eventSource = null;\n this.clientId = \"\";\n\n if (!fromReconnect) {\n this.reconnectAttempts = 0;\n\n // resolve any remaining connect promises\n //\n // this is done to avoid unnecessary throwing errors in case\n // unsubscribe is called before the pending connect promises complete\n // (see https://github.com/pocketbase/pocketbase/discussions/2897#discussioncomment-6423818)\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n this.pendingConnects = [];\n }\n }\n}\n","import Client from '@/Client';\nimport { CrudService } from '@/services/utils/CrudService';\nimport { RealtimeService, UnsubscribeFunc } from '@/services/RealtimeService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult, RecordModel, ExternalAuthModel } from '@/services/utils/dtos';\nimport {\n SendOptions,\n CommonOptions,\n RecordOptions,\n RecordListOptions,\n RecordFullListOptions,\n} from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface RecordAuthResponse {\n // The signed PocketBase auth record.\n record: T;\n\n // The PocketBase record auth token.\n //\n // If you are looking for the OAuth2 access and refresh tokens\n // they are available under the `meta.accessToken` and `meta.refreshToken` props.\n token: string;\n\n // Auth meta data usually filled when OAuth2 is used.\n meta?: {[key: string]: any};\n}\n\nexport interface AuthProviderInfo {\n name: string;\n state: string;\n codeVerifier: string;\n codeChallenge: string;\n codeChallengeMethod: string;\n authUrl: string;\n}\n\nexport interface AuthMethodsList {\n usernamePassword: boolean;\n emailPassword: boolean;\n authProviders: Array;\n}\n\nexport interface RecordSubscription {\n action: string; // eg. create, update, delete\n record: T;\n}\n\nexport type OAuth2UrlCallback = (url: string) => void|Promise;\n\nexport interface OAuth2AuthConfig extends SendOptions {\n // the name of the OAuth2 provider (eg. \"google\")\n provider: string;\n\n // custom scopes to overwrite the default ones\n scopes?: Array;\n\n // optional record create data\n createData?: {[key: string]: any};\n\n // optional callback that is triggered after the OAuth2 sign-in/sign-up url generation\n urlCallback?: OAuth2UrlCallback;\n\n // optional query params to send with the PocketBase auth request (eg. fields, expand, etc.)\n query?: RecordOptions;\n}\n\nexport class RecordService extends CrudService {\n readonly collectionIdOrName: string;\n\n constructor(client: Client, collectionIdOrName: string) {\n super(client);\n\n this.collectionIdOrName = collectionIdOrName;\n }\n\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return this.baseCollectionPath + '/records';\n }\n\n /**\n * Returns the current collection service base path.\n */\n get baseCollectionPath(): string {\n return '/api/collections/' + encodeURIComponent(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Realtime handlers\n // ---------------------------------------------------------------\n\n /**\n * @deprecated Use subscribe(recordId, callback) instead.\n *\n * Subscribe to the realtime changes of a single record in the collection.\n */\n async subscribeOne(recordId: string, callback: (data: RecordSubscription) => void): Promise {\n console.warn(\"PocketBase: subscribeOne(recordId, callback) is deprecated. Please replace it with subscribe(recordId, callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName + \"/\" + recordId, callback);\n }\n\n /**\n * @deprecated This form of subscribe is deprecated. Please use `subscribe(\"*\", callback)`.\n */\n async subscribe(callback: (data: RecordSubscription) => void): Promise\n\n /**\n * Subscribe to realtime changes to the specified topic (\"*\" or record id).\n *\n * If `topic` is the wildcard \"*\", then this method will subscribe to\n * any record changes in the collection.\n *\n * If `topic` is a record id, then this method will subscribe only\n * to changes of the specified record id.\n *\n * It's OK to subscribe multiple times to the same topic.\n * You can use the returned `UnsubscribeFunc` to remove only a single subscription.\n * Or use `unsubscribe(topic)` if you want to remove all subscriptions attached to the topic.\n */\n async subscribe(topic: string, callback: (data: RecordSubscription) => void): Promise\n\n async subscribe(\n topicOrCallback: string|((data: RecordSubscription) => void),\n callback?: (data: RecordSubscription) => void\n ): Promise {\n if (typeof topicOrCallback === 'function') {\n console.warn(\"PocketBase: subscribe(callback) is deprecated. Please replace it with subscribe('*', callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName, topicOrCallback);\n }\n\n if (!callback) {\n throw new Error(\"Missing subscription callback.\");\n }\n\n if (topicOrCallback === \"\") {\n throw new Error(\"Missing topic.\");\n }\n\n let topic = this.collectionIdOrName;\n if (topicOrCallback !== \"*\") {\n topic += ('/' + topicOrCallback);\n }\n\n return this.client.realtime.subscribe(topic, callback)\n }\n\n /**\n * Unsubscribe from all subscriptions of the specified topic\n * (\"*\" or record id).\n *\n * If `topic` is not set, then this method will unsubscribe from\n * all subscriptions associated to the current collection.\n */\n async unsubscribe(topic?: string): Promise {\n // unsubscribe wildcard topic\n if (topic === \"*\") {\n return this.client.realtime.unsubscribe(this.collectionIdOrName);\n }\n\n // unsubscribe recordId topic\n if (topic) {\n return this.client.realtime.unsubscribe(this.collectionIdOrName + \"/\" + topic);\n }\n\n // unsubscribe from everything related to the collection\n return this.client.realtime.unsubscribeByPrefix(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Crud handers\n // ---------------------------------------------------------------\n /**\n * @inheritdoc\n */\n getFullList(options?: RecordFullListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batch?: number, options?: RecordListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batchOrOptions?: number|RecordFullListOptions, options?: RecordListOptions): Promise> {\n if (typeof batchOrOptions == \"number\") {\n return super.getFullList(batchOrOptions, options);\n }\n\n const params = Object.assign({}, batchOrOptions, options);\n\n return super.getFullList(params);\n }\n\n /**\n * @inheritdoc\n */\n getList(page = 1, perPage = 30, options?: RecordListOptions): Promise> {\n return super.getList(page, perPage, options);\n }\n\n /**\n * @inheritdoc\n */\n getFirstListItem(filter: string, options?: RecordListOptions): Promise {\n return super.getFirstListItem(filter, options);\n }\n\n /**\n * @inheritdoc\n */\n getOne(id: string, options?: RecordOptions): Promise {\n return super.getOne(id, options);\n }\n\n /**\n * @inheritdoc\n */\n create(bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.create(bodyParams, options);\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(id: string, bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n if (\n // is record auth\n this.client.authStore.model?.id === item?.id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n if (\n success &&\n // is record auth\n this.client.authStore.model?.id === id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful collection authorization response.\n */\n protected authResponse(responseData: any): RecordAuthResponse {\n const record = this.decode(responseData?.record || {});\n\n this.client.authStore.save(responseData?.token, record);\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'record': record as any as T,\n });\n }\n\n /**\n * Returns all available collection auth methods.\n */\n listAuthMethods(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCollectionPath + '/auth-methods', options)\n .then((responseData: any) => {\n return Object.assign({}, responseData, {\n // normalize common fields\n 'usernamePassword': !!responseData?.usernamePassword,\n 'emailPassword': !!responseData?.emailPassword,\n 'authProviders': Array.isArray(responseData?.authProviders) ? responseData?.authProviders : [],\n });\n });\n }\n\n /**\n * Authenticate a single auth collection record via its username/email and password.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n */\n authWithPassword(usernameOrEmail: string, password: string, options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authWithPassword(usernameOrEmail, password, options?).\n */\n authWithPassword(usernameOrEmail: string, password: string, body?: any, query?: any): Promise>\n\n authWithPassword(usernameOrEmail: string, password: string, bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': usernameOrEmail,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(usernameOrEmail, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(usernameOrEmail, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-password', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Authenticate a single auth collection record with OAuth2 code.\n *\n * If you don't have an OAuth2 code you may also want to check `authWithOAuth2` method.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n options?: RecordOptions,\n ): Promise>\n\n /**\n * @deprecated\n * Consider using authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createdData, options?).\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n body?: any,\n query?: any\n ): Promise>\n\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n bodyOrOptions?: any,\n query?: any\n ): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'provider': provider,\n 'code': code,\n 'codeVerifier': codeVerifier,\n 'redirectUrl': redirectUrl,\n 'createData': createData,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, body?, query?) is deprecated. Consider replacing it with authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-oauth2', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * @deprecated This form of authWithOAuth2 is deprecated.\n *\n * Please use `authWithOAuth2Code()` OR its simplified realtime version\n * as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\n */\n async authWithOAuth2(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key: string]: any},\n bodyParams?: {[key: string]: any},\n queryParams?: RecordOptions,\n ): Promise>\n\n /**\n * Authenticate a single auth collection record with OAuth2\n * **without custom redirects, deeplinks or even page reload**.\n *\n * This method initializes a one-off realtime subscription and will\n * open a popup window with the OAuth2 vendor page to authenticate.\n * Once the external OAuth2 sign-in/sign-up flow is completed, the popup\n * window will be automatically closed and the OAuth2 data sent back\n * to the user through the previously established realtime connection.\n *\n * You can specify an optional `urlCallback` prop to customize\n * the default url `window.open` behavior.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n *\n * Example:\n *\n * ```js\n * const authData = await pb.collection(\"users\").authWithOAuth2({\n * provider: \"google\",\n * })\n * ```\n *\n * _Site-note_: when creating the OAuth2 app in the provider dashboard\n * you have to configure `https://yourdomain.com/api/oauth2-redirect`\n * as redirect URL.\n */\n async authWithOAuth2(options: OAuth2AuthConfig): Promise>\n\n async authWithOAuth2(...args: any): Promise> {\n // fallback to legacy format\n if (args.length > 1 || typeof args?.[0] === 'string') {\n console.warn(\"PocketBase: This form of authWithOAuth2() is deprecated and may get removed in the future. Please replace with authWithOAuth2Code() OR use the authWithOAuth2() realtime form as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\");\n return this.authWithOAuth2Code(\n args?.[0] || '',\n args?.[1] || '',\n args?.[2] || '',\n args?.[3] || '',\n args?.[4] || {},\n args?.[5] || {},\n args?.[6] || {},\n );\n }\n\n const config = args?.[0] || {};\n\n const authMethods = await this.listAuthMethods();\n\n const provider = authMethods.authProviders.find((p) => p.name === config.provider);\n if (!provider) {\n throw new ClientResponseError(new Error(`Missing or invalid provider \"${config.provider}\".`));\n }\n\n const redirectUrl = this.client.buildUrl('/api/oauth2-redirect');\n\n // initialize a one-off realtime service\n const realtime = new RealtimeService(this.client);\n\n // open a new popup window in case config.urlCallback is not set\n //\n // note: it is opened before the async call due to Safari restrictions\n // (see https://github.com/pocketbase/pocketbase/discussions/2429#discussioncomment-5943061)\n let eagerDefaultPopup: Window|null = null;\n if (!config.urlCallback) {\n eagerDefaultPopup = openBrowserPopup(undefined);\n }\n\n function cleanup() {\n eagerDefaultPopup?.close();\n realtime.unsubscribe();\n }\n\n return new Promise(async (resolve, reject) => {\n try {\n await realtime.subscribe('@oauth2', async (e) => {\n const oldState = realtime.clientId;\n\n try {\n if (!e.state || oldState !== e.state) {\n throw new Error(\"State parameters don't match.\");\n }\n\n // clear the non SendOptions props\n const options = Object.assign({}, config);\n delete options.provider;\n delete options.scopes;\n delete options.createData;\n delete options.urlCallback;\n\n const authData = await this.authWithOAuth2Code(\n provider.name,\n e.code,\n provider.codeVerifier,\n redirectUrl,\n config.createData,\n options,\n );\n\n resolve(authData);\n } catch (err) {\n reject(new ClientResponseError(err));\n }\n\n cleanup();\n });\n\n const replacements: {[key: string]: any} = {\n \"state\": realtime.clientId,\n }\n if (config.scopes?.length) {\n replacements[\"scope\"] = config.scopes.join(\" \");\n }\n\n const url = this._replaceQueryParams(provider.authUrl + redirectUrl, replacements);\n\n let urlCallback = config.urlCallback || function (url: string) {\n if (eagerDefaultPopup) {\n eagerDefaultPopup.location.href = url;\n } else {\n // it could have been blocked due to its empty initial url,\n // try again...\n eagerDefaultPopup = openBrowserPopup(url);\n }\n }\n\n await urlCallback(url);\n } catch (err) {\n cleanup();\n reject(new ClientResponseError(err));\n }\n });\n }\n\n /**\n * Refreshes the current authenticated record instance and\n * returns a new token and record data.\n *\n * On success this method also automatically updates the client's AuthStore.\n */\n authRefresh(options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise>\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-refresh', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Sends auth record password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-password-reset', options).then(() => true);\n }\n\n /**\n * Confirms auth record password reset request.\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n options?: CommonOptions,\n ): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(passwordResetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n body?: any,\n query?: any,\n ): Promise\n\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': passwordResetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(token, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(token, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Sends auth record verification email request.\n */\n requestVerification(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestVerification(email, options?).\n */\n requestVerification(email: string, body?: any, query?: any): Promise\n\n requestVerification(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestVerification(email, body?, query?) is deprecated. Consider replacing it with requestVerification(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-verification', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record email verification request.\n */\n confirmVerification(verificationToken: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmVerification(verificationToken, options?).\n */\n confirmVerification(verificationToken: string, body?: any, query?: any): Promise\n\n confirmVerification(verificationToken: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': verificationToken,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmVerification(token, body?, query?) is deprecated. Consider replacing it with confirmVerification(token, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-verification', options)\n .then(() => true);\n }\n\n /**\n * Sends an email change request to the authenticated record model.\n */\n requestEmailChange(newEmail: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestEmailChange(newEmail, options?).\n */\n requestEmailChange(newEmail: string, body?: any, query?: any): Promise\n\n requestEmailChange(newEmail: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'newEmail': newEmail,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestEmailChange(newEmail, body?, query?) is deprecated. Consider replacing it with requestEmailChange(newEmail, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-email-change', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record's new email address.\n */\n confirmEmailChange(emailChangeToken: string, password: string, options?: CommonOptions): Promise\n\n\n /**\n * @deprecated\n * Consider using confirmEmailChange(emailChangeToken, password, options?).\n */\n confirmEmailChange(emailChangeToken: string, password: string, body?: any, query?: any): Promise\n\n confirmEmailChange(emailChangeToken: string, password: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': emailChangeToken,\n 'password': password,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmEmailChange(token, password, body?, query?) is deprecated. Consider replacing it with confirmEmailChange(token, password, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-email-change', options)\n .then(() => true);\n }\n\n /**\n * Lists all linked external auth providers for the specified auth record.\n */\n listExternalAuths(recordId: string, options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths', options);\n }\n\n /**\n * Unlink a single external auth provider from the specified auth record.\n */\n unlinkExternalAuth(recordId: string, provider: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths/' + encodeURIComponent(provider), options)\n .then(() => true);\n }\n\n // ---------------------------------------------------------------\n\n // very rudimentary url query params replacement because at the moment\n // URL (and URLSearchParams) doesn't seem to be fully supported in React Native\n //\n // note: for details behind some of the decode/encode parsing check https://unixpapa.com/js/querystring.html\n private _replaceQueryParams(url: string, replacements: {[key: string]: any} = {}): string {\n let urlPath = url\n let query = \"\";\n\n const queryIndex = url.indexOf(\"?\");\n if (queryIndex >= 0) {\n urlPath = url.substring(0, url.indexOf(\"?\"));\n query = url.substring(url.indexOf(\"?\") + 1);\n }\n\n const parsedParams: {[key: string]: string} = {};\n\n // parse the query parameters\n const rawParams = query.split(\"&\");\n for (const param of rawParams) {\n if (param == \"\") {\n continue\n }\n\n const pair = param.split(\"=\");\n parsedParams[decodeURIComponent(pair[0].replace(/\\+/g,' '))] = decodeURIComponent((pair[1] || \"\").replace(/\\+/g,' '));\n }\n\n // apply the replacements\n for (let key in replacements) {\n if (!replacements.hasOwnProperty(key)) {\n continue;\n }\n\n if (replacements[key] == null) {\n delete parsedParams[key];\n } else {\n parsedParams[key] = replacements[key];\n }\n }\n\n // construct back the full query string\n query = \"\";\n for (let key in parsedParams) {\n if (!parsedParams.hasOwnProperty(key)) {\n continue;\n }\n\n if (query != \"\") {\n query += \"&\";\n }\n\n query += encodeURIComponent(key.replace(/%20/g,'+')) + \"=\" + encodeURIComponent(parsedParams[key].replace(/%20/g,'+'));\n }\n\n return query != \"\" ? (urlPath + \"?\" + query) : urlPath;\n }\n}\n\nfunction openBrowserPopup(url?: string): Window|null {\n if (typeof window === \"undefined\" || !window?.open) {\n throw new ClientResponseError(new Error(`Not in a browser context - please pass a custom urlCallback function.`));\n }\n\n let width = 1024;\n let height = 768;\n\n let windowWidth = window.innerWidth;\n let windowHeight = window.innerHeight;\n\n // normalize window size\n width = width > windowWidth ? windowWidth : width;\n height = height > windowHeight ? windowHeight : height;\n\n let left = (windowWidth / 2) - (width / 2);\n let top = (windowHeight / 2) - (height / 2);\n\n // note: we don't use the noopener and noreferrer attributes since\n // for some reason browser blocks such windows then url is undefined/blank\n return window.open(\n url,\n 'popup_window',\n 'width='+width+',height='+height+',top='+top+',left='+left+',resizable,menubar=no'\n );\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { CollectionModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport class CollectionService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/collections';\n }\n\n /**\n * Imports the provided collections.\n *\n * If `deleteMissing` is `true`, all local collections and schema fields,\n * that are not present in the imported configuration, WILL BE DELETED\n * (including their related records data)!\n */\n async import(\n collections: Array,\n deleteMissing: boolean = false,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PUT',\n 'body': {\n 'collections': collections,\n 'deleteMissing': deleteMissing,\n }\n }, options);\n\n return this.client.send(this.baseCrudPath + '/import', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ListResult, LogRequestModel } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n LogStatsOptions,\n} from '@/services/utils/options';\n\nexport interface HourlyStats {\n total: number;\n date: string;\n}\n\nexport class LogService extends BaseService {\n /**\n * Returns paginated logged requests list.\n */\n getRequestsList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({'method': 'GET'}, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send('/api/logs/requests', options);\n }\n\n /**\n * Returns a single logged request by its id.\n */\n getRequest(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/' + encodeURIComponent(id), options);\n }\n\n /**\n * Returns request logs statistics.\n */\n getRequestsStats(options?: LogStatsOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/stats', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface HealthCheckResponse {\n code: number;\n message: string;\n data: {[key: string]: any};\n}\n\nexport class HealthService extends BaseService {\n /**\n * Checks the health status of the api.\n */\n check(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/health', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions, FileOptions } from '@/services/utils/options';\n\nexport class FileService extends BaseService {\n /**\n * Builds and returns an absolute record file url for the provided filename.\n */\n getUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n if (\n !filename ||\n !record?.id ||\n !(record?.collectionId || record?.collectionName)\n ) {\n return '';\n }\n\n const parts = [];\n parts.push('api')\n parts.push('files')\n parts.push(encodeURIComponent(record.collectionId || record.collectionName))\n parts.push(encodeURIComponent(record.id))\n parts.push(encodeURIComponent(filename))\n\n let result = this.client.buildUrl(parts.join('/'));\n\n if (Object.keys(queryParams).length) {\n // normalize the download query param for consistency with the Dart sdk\n if (queryParams.download === false) {\n delete(queryParams.download);\n }\n\n const params = new URLSearchParams(queryParams);\n\n result += (result.includes('?') ? '&' : '?') + params;\n }\n\n return result\n }\n\n /**\n * Requests a new private file access token for the current auth model (admin or record).\n */\n getToken(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send('/api/files/token', options)\n .then((data) => data?.token || '');\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface BackupFileInfo {\n key: string;\n size: number;\n modified: string;\n}\n\nexport class BackupService extends BaseService {\n /**\n * Returns list with all available backup files.\n */\n getFullList(options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/backups', options);\n }\n\n /**\n * Initializes a new backup.\n */\n create(basename: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'name': basename,\n },\n }, options);\n\n return this.client.send('/api/backups', options)\n .then(() => true);\n }\n\n /**\n * Deletes a single backup file.\n */\n delete(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}`, options)\n .then(() => true);\n }\n\n /**\n * Initializes an app data restore from an existing backup.\n */\n restore(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}/restore`, options)\n .then(() => true);\n }\n\n /**\n * Builds a download url for a single existing backup using an\n * admin file token and the backup file key.\n *\n * The file token can be generated via `pb.files.getToken()`.\n */\n getDownloadUrl(token: string, key: string): string {\n return this.client.buildUrl(`/api/backups/${encodeURIComponent(key)}?token=${encodeURIComponent(token)}`);\n }\n}\n","import { ClientResponseError } from '@/ClientResponseError';\nimport { BaseAuthStore } from '@/stores/BaseAuthStore';\nimport { LocalAuthStore } from '@/stores/LocalAuthStore';\nimport { SettingsService } from '@/services/SettingsService';\nimport { AdminService } from '@/services/AdminService';\nimport { RecordService } from '@/services/RecordService';\nimport { CollectionService } from '@/services/CollectionService';\nimport { LogService } from '@/services/LogService';\nimport { RealtimeService } from '@/services/RealtimeService';\nimport { HealthService } from '@/services/HealthService';\nimport { FileService } from '@/services/FileService';\nimport { BackupService } from '@/services/BackupService';\nimport { SendOptions, FileOptions } from '@/services/utils/options';\n\n// list of known SendOptions keys (everything else is treated as query param)\nconst knownSendOptionsKeys = [\n 'requestKey',\n '$cancelKey',\n '$autoCancel',\n 'fetch',\n 'headers',\n 'body',\n 'query',\n 'params',\n // ---,\n 'cache',\n 'credentials',\n 'headers',\n 'integrity',\n 'keepalive',\n 'method',\n 'mode',\n 'redirect',\n 'referrer',\n 'referrerPolicy',\n 'signal',\n 'window',\n];\n\nexport interface BeforeSendResult {\n [key: string]: any, // for backward compatibility\n url?: string,\n options?: {[key: string]: any}\n}\n\n/**\n * PocketBase JS Client.\n */\nexport default class Client {\n /**\n * The base PocketBase backend url address (eg. 'http://127.0.0.1.8090').\n */\n baseUrl: string;\n\n /**\n * Hook that get triggered right before sending the fetch request,\n * allowing you to inspect and modify the url and request options.\n *\n * For list of the possible options check https://developer.mozilla.org/en-US/docs/Web/API/fetch#options\n *\n * You can return a non-empty result object `{ url, options }` to replace the url and request options entirely.\n *\n * Example:\n * ```js\n * client.beforeSend = function (url, options) {\n * options.headers = Object.assign({}, options.headers, {\n * 'X-Custom-Header': 'example',\n * });\n *\n * return { url, options }\n * };\n * ```\n */\n beforeSend?: (url: string, options: SendOptions) => BeforeSendResult|Promise;\n\n /**\n * Hook that get triggered after successfully sending the fetch request,\n * allowing you to inspect/modify the response object and its parsed data.\n *\n * Returns the new Promise resolved `data` that will be returned to the client.\n *\n * Example:\n * ```js\n * client.afterSend = function (response, data) {\n * if (response.status != 200) {\n * throw new ClientResponseError({\n * url: response.url,\n * status: response.status,\n * data: data,\n * });\n * }\n *\n * return data;\n * };\n * ```\n */\n afterSend?: (response: Response, data: any) => any;\n\n /**\n * Optional language code (default to `en-US`) that will be sent\n * with the requests to the server as `Accept-Language` header.\n */\n lang: string;\n\n /**\n * A replaceable instance of the local auth store service.\n */\n authStore: BaseAuthStore;\n\n /**\n * An instance of the service that handles the **Settings APIs**.\n */\n readonly settings: SettingsService;\n\n /**\n * An instance of the service that handles the **Admin APIs**.\n */\n readonly admins: AdminService;\n\n /**\n * An instance of the service that handles the **Collection APIs**.\n */\n readonly collections: CollectionService;\n\n /**\n * An instance of the service that handles the **File APIs**.\n */\n readonly files: FileService;\n\n /**\n * An instance of the service that handles the **Log APIs**.\n */\n readonly logs: LogService;\n\n /**\n * An instance of the service that handles the **Realtime APIs**.\n */\n readonly realtime: RealtimeService;\n\n /**\n * An instance of the service that handles the **Health APIs**.\n */\n readonly health: HealthService;\n\n /**\n * An instance of the service that handles the **Backup APIs**.\n */\n readonly backups: BackupService;\n\n private cancelControllers: { [key: string]: AbortController } = {};\n private recordServices: { [key: string]: RecordService } = {};\n private enableAutoCancellation: boolean = true;\n\n constructor(\n baseUrl = '/',\n authStore?: BaseAuthStore | null,\n lang = 'en-US',\n ) {\n this.baseUrl = baseUrl;\n this.lang = lang;\n this.authStore = authStore || new LocalAuthStore();\n\n // services\n this.admins = new AdminService(this);\n this.collections = new CollectionService(this);\n this.files = new FileService(this);\n this.logs = new LogService(this);\n this.settings = new SettingsService(this);\n this.realtime = new RealtimeService(this);\n this.health = new HealthService(this);\n this.backups = new BackupService(this);\n }\n\n /**\n * Returns the RecordService associated to the specified collection.\n *\n * @param {string} idOrName\n * @return {RecordService}\n */\n collection(idOrName: string): RecordService {\n if (!this.recordServices[idOrName]) {\n this.recordServices[idOrName] = new RecordService(this, idOrName);\n }\n\n return this.recordServices[idOrName];\n }\n\n /**\n * Globally enable or disable auto cancellation for pending duplicated requests.\n */\n autoCancellation(enable: boolean): Client {\n this.enableAutoCancellation = !!enable;\n\n return this;\n }\n\n /**\n * Cancels single request by its cancellation key.\n */\n cancelRequest(requestKey: string): Client {\n if (this.cancelControllers[requestKey]) {\n this.cancelControllers[requestKey].abort();\n delete this.cancelControllers[requestKey];\n }\n\n return this;\n }\n\n /**\n * Cancels all pending requests.\n */\n cancelAllRequests(): Client {\n for (let k in this.cancelControllers) {\n this.cancelControllers[k].abort();\n }\n\n this.cancelControllers = {};\n\n return this;\n }\n\n /**\n * Legacy alias of `pb.files.getUrl()`.\n */\n getFileUrl(\n record: Pick<{[key:string]:any}, 'id' | 'collectionId' | 'collectionName'>,\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n return this.files.getUrl(record, filename, queryParams);\n }\n\n /**\n * Builds a full client url by safely concatenating the provided path.\n */\n buildUrl(path: string): string {\n let url = this.baseUrl;\n\n // construct an absolute base url if in a browser environment\n if (\n typeof window !== 'undefined' &&\n !!window.location &&\n !url.startsWith('https://') &&\n !url.startsWith('http://')\n ) {\n url = window.location.origin?.endsWith('/') ?\n window.location.origin.substring(0, window.location.origin.length - 1) :\n (window.location.origin || '');\n\n if (!this.baseUrl.startsWith('/')) {\n url += window.location.pathname || '/';\n url += url.endsWith('/') ? '' : '/';\n }\n\n url += this.baseUrl;\n }\n\n // concatenate the path\n if (path) {\n url += url.endsWith('/') ? '' : '/'; // append trailing slash if missing\n url += path.startsWith('/') ? path.substring(1) : path;\n }\n\n return url;\n }\n\n /**\n * Sends an api http request.\n */\n async send(path: string, options: SendOptions): Promise {\n options = this.initSendOptions(path, options);\n\n // build url + path\n let url = this.buildUrl(path);\n\n // serialize the query parameters\n if (typeof options.query !== 'undefined') {\n const query = this.serializeQueryParams(options.query)\n if (query) {\n url += (url.includes('?') ? '&' : '?') + query;\n }\n delete options.query;\n }\n\n if (this.beforeSend) {\n const result = Object.assign({}, await this.beforeSend(url, options));\n if (typeof result.url !== 'undefined' || typeof result.options !== 'undefined') {\n url = result.url || url;\n options = result.options || options;\n } else if (Object.keys(result).length) {\n // legacy behavior\n options = result as SendOptions;\n console?.warn && console.warn('Deprecated format of beforeSend return: please use `return { url, options }`, instead of `return options`.');\n }\n }\n\n // ensures that the json body is serialized\n if (\n this.getHeader(options.headers, 'Content-Type') == 'application/json' &&\n options.body && typeof options.body !== 'string'\n ) {\n options.body = JSON.stringify(options.body);\n }\n\n const fetchFunc = options.fetch || fetch;\n\n // send the request\n return fetchFunc(url, options)\n .then(async (response) => {\n let data : any = {};\n\n try {\n data = await response.json();\n } catch (_) {\n // all api responses are expected to return json\n // with the exception of the realtime event and 204\n }\n\n if (this.afterSend) {\n data = await this.afterSend(response, data);\n }\n\n if (response.status >= 400) {\n throw new ClientResponseError({\n url: response.url,\n status: response.status,\n data: data,\n });\n }\n\n return data as T;\n }).catch((err) => {\n // wrap to normalize all errors\n throw new ClientResponseError(err);\n });\n }\n\n /**\n * Shallow copy the provided object and takes care to initialize\n * any options required to preserve the backward compatability.\n *\n * @param {SendOptions} options\n * @return {SendOptions}\n */\n private initSendOptions(path: string, options: SendOptions): SendOptions {\n options = Object.assign({ method: 'GET' } as SendOptions, options)\n options.query = options.query || {};\n\n // auto convert the body to FormData, if needed\n options.body = this.convertToFormDataIfNeeded(options.body);\n\n // move unknown send options as query parameters\n for (let key in options) {\n if (knownSendOptionsKeys.includes(key)) {\n continue\n }\n\n options.query[key] = options[key];\n delete (options[key]);\n }\n\n // requestKey normalizations for backward-compatibility\n // ---\n options.query = Object.assign({}, options.params, options.query);\n if (typeof options.requestKey === 'undefined') {\n if (options.$autoCancel === false || options.query.$autoCancel === false) {\n options.requestKey = null;\n } else if (options.$cancelKey || options.query.$cancelKey) {\n options.requestKey = options.$cancelKey || options.query.$cancelKey;\n }\n }\n // remove the deprecated special cancellation params from the other query params\n delete options.$autoCancel;\n delete options.query.$autoCancel;\n delete options.$cancelKey;\n delete options.query.$cancelKey;\n // ---\n\n // add the json header, if not explicitly set\n // (for FormData body the Content-Type header should be skipped since the boundary is autogenerated)\n if (\n this.getHeader(options.headers, 'Content-Type') === null &&\n !this.isFormData(options.body)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Content-Type': 'application/json',\n });\n }\n\n // add Accept-Language header, if not explicitly set\n if (this.getHeader(options.headers, 'Accept-Language') === null) {\n options.headers = Object.assign({}, options.headers, {\n 'Accept-Language': this.lang,\n });\n }\n\n // check if Authorization header can be added\n if (\n // has valid token\n this.authStore.token &&\n // auth header is not explicitly set\n (this.getHeader(options.headers, 'Authorization') === null)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Authorization': this.authStore.token,\n });\n }\n\n // handle auto cancelation for duplicated pending request\n if (this.enableAutoCancellation && options.requestKey !== null) {\n const requestKey = options.requestKey || ((options.method || 'GET') + path);\n\n delete options.requestKey;\n\n // cancel previous pending requests\n this.cancelRequest(requestKey);\n\n const controller = new AbortController();\n this.cancelControllers[requestKey] = controller;\n options.signal = controller.signal;\n }\n\n return options\n }\n\n /**\n * Converts analyzes the provided body and converts it to FormData\n * in case a plain object with File/Blob values is used.\n */\n private convertToFormDataIfNeeded(body: any): any {\n if (\n typeof FormData === 'undefined' ||\n typeof body === \"undefined\" ||\n typeof body !== \"object\" ||\n body === null ||\n this.isFormData(body) ||\n !this.hasBlobField(body)\n ) {\n return body;\n }\n\n const form = new FormData();\n\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let val of values) {\n form.append(key, val);\n }\n }\n\n return form;\n }\n\n /**\n * Checks if the submitted body object has at least one Blob/File field.\n */\n private hasBlobField(body: {[key:string]: any}): boolean {\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let v of values) {\n if (\n (typeof Blob !== 'undefined' && v instanceof Blob) ||\n (typeof File !== 'undefined' && v instanceof File)\n ) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /**\n * Extracts the header with the provided name in case-insensitive manner.\n * Returns `null` if no header matching the name is found.\n */\n private getHeader(headers: {[key:string]:string}|undefined, name: string): string|null {\n headers = headers || {};\n name = name.toLowerCase();\n\n for (let key in headers) {\n if (key.toLowerCase() == name) {\n return headers[key];\n }\n }\n\n return null;\n }\n\n /**\n * Loosely checks if the specified body is a FormData instance.\n */\n private isFormData(body: any): boolean {\n return body && (\n // we are checking the constructor name because FormData\n // is not available natively in some environments and the\n // polyfill(s) may not be globally accessible\n body.constructor.name === 'FormData' ||\n // fallback to global FormData instance check\n // note: this is needed because the constructor.name could be different in case of\n // custom global FormData implementation, eg. React Native on Android/iOS\n (typeof FormData !== 'undefined' && body instanceof FormData)\n )\n }\n\n /**\n * Serializes the provided query parameters into a query string.\n */\n private serializeQueryParams(params: {[key: string]: any}): string {\n const result: Array = [];\n for (const key in params) {\n if (params[key] === null) {\n // skip null query params\n continue;\n }\n\n const value = params[key];\n const encodedKey = encodeURIComponent(key);\n\n if (Array.isArray(value)) {\n // repeat array params\n for (const v of value) {\n result.push(encodedKey + '=' + encodeURIComponent(v));\n }\n } else if (value instanceof Date) {\n result.push(encodedKey + '=' + encodeURIComponent(value.toISOString()));\n } else if (typeof value !== null && typeof value === 'object') {\n result.push(encodedKey + '=' + encodeURIComponent(JSON.stringify(value)));\n } else {\n result.push(encodedKey + '=' + encodeURIComponent(value));\n }\n }\n\n return result.join('&');\n }\n}\n"],"names":["ClientResponseError","Error","constructor","errData","super","this","url","status","response","isAbort","originalError","Object","setPrototypeOf","prototype","data","DOMException","name","message","_a","_d","_c","_b","cause","includes","toJSON","assign","fieldContentRegExp","cookieSerialize","val","options","opt","encode","defaultEncode","test","TypeError","value","result","maxAge","isNaN","isFinite","Math","floor","domain","path","expires","isDate","toString","call","Date","valueOf","toUTCString","httpOnly","secure","priority","toLowerCase","sameSite","defaultDecode","indexOf","decodeURIComponent","encodeURIComponent","atobPolyfill","getTokenPayload","token","encodedPayload","split","map","c","charCodeAt","slice","join","JSON","parse","e","atob","input","str","String","replace","length","bs","buffer","bc","idx","output","charAt","fromCharCode","defaultCookieKey","BaseAuthStore","baseToken","baseModel","_onChangeCallbacks","model","isValid","isTokenExpired","expirationThreshold","payload","keys","exp","now","isAdmin","type","isAuthRecord","save","triggerChange","clear","loadFromCookie","cookie","key","rawData","cookieParse","decode","index","eqIdx","endIdx","lastIndexOf","trim","undefined","_","Array","isArray","exportToCookie","defaultOptions","stringify","resultLength","Blob","size","id","email","extraProps","prop","onChange","callback","fireImmediately","push","i","splice","LocalAuthStore","storageKey","storageFallback","_bindStorageEvent","_storageGet","_storageSet","_storageRemove","window","localStorage","rawValue","getItem","normalizedVal","setItem","removeItem","addEventListener","BaseService","client","SettingsService","getAll","method","send","update","bodyParams","body","testS3","filesystem","then","testEmail","toEmail","emailTemplate","template","generateAppleClientSecret","clientId","teamId","keyId","privateKey","duration","CrudService","getFullList","batchOrqueryParams","_getFullList","batch","getList","page","perPage","query","baseCrudPath","responseData","items","item","getFirstListItem","filter","requestKey","skipTotal","code","getOne","create","batchSize","request","__awaiter","list","concat","normalizeLegacyOptionsArgs","legacyWarn","baseOptions","bodyOrOptions","hasQuery","console","warn","AdminService","authStore","collectionId","delete","success","authResponse","admin","authWithPassword","password","identity","bind","authRefresh","requestPasswordReset","confirmPasswordReset","resetToken","passwordConfirm","RealtimeService","eventSource","subscriptions","lastSentTopics","maxConnectTimeout","reconnectAttempts","maxReconnectAttempts","Infinity","predefinedReconnectIntervals","pendingConnects","isConnected","subscribe","topic","listener","msgEvent","submitSubscriptions","connect","unsubscribeByTopicAndListener","unsubscribe","hasSubscriptionListeners","removeEventListener","disconnect","unsubscribeByPrefix","topicPrefix","hasAtleastOneTopic","startsWith","exist","topicToCheck","addAllSubscriptionListeners","getNonEmptySubscriptionTopics","getSubscriptionsCancelKey","catch","err","removeAllSubscriptionListeners","Promise","resolve","reject","initConnect","clearTimeout","connectTimeoutId","setTimeout","connectErrorHandler","EventSource","buildUrl","onerror","lastEventId","retries","hasUnsentSubscriptions","p","reconnectTimeoutId","latestTopics","t","timeout","fromReconnect","cancelRequest","close","RecordService","collectionIdOrName","baseCollectionPath","subscribeOne","recordId","realtime","topicOrCallback","batchOrOptions","params","collectionName","record","listAuthMethods","usernamePassword","emailPassword","authProviders","usernameOrEmail","authWithOAuth2Code","provider","codeVerifier","redirectUrl","createData","authWithOAuth2","args","config","find","eagerDefaultPopup","cleanup","urlCallback","openBrowserPopup","oldState","state","scopes","authData","replacements","_replaceQueryParams","authUrl","location","href","passwordResetToken","requestVerification","confirmVerification","verificationToken","requestEmailChange","newEmail","confirmEmailChange","emailChangeToken","listExternalAuths","unlinkExternalAuth","urlPath","substring","parsedParams","rawParams","param","pair","hasOwnProperty","open","width","height","windowWidth","innerWidth","windowHeight","innerHeight","left","top","CollectionService","import","collections","deleteMissing","LogService","getRequestsList","getRequest","getRequestsStats","HealthService","check","FileService","getUrl","filename","queryParams","parts","download","URLSearchParams","getToken","BackupService","basename","restore","getDownloadUrl","knownSendOptionsKeys","Client","baseUrl","lang","cancelControllers","recordServices","enableAutoCancellation","admins","files","logs","settings","health","backups","collection","idOrName","autoCancellation","enable","abort","cancelAllRequests","k","getFileUrl","origin","endsWith","pathname","initSendOptions","serializeQueryParams","beforeSend","getHeader","headers","fetch","json","afterSend","convertToFormDataIfNeeded","$autoCancel","$cancelKey","isFormData","Authorization","controller","AbortController","signal","FormData","hasBlobField","form","values","append","v","File","encodedKey","toISOString"],"mappings":"uoBAIM,MAAOA,4BAA4BC,MAOrC,WAAAC,CAAYC,eACRC,MAAM,uBAPVC,KAAGC,IAA8B,GACjCD,KAAME,OAA2B,EACjCF,KAAQG,SAAyB,GACjCH,KAAOI,SAA0B,EACjCJ,KAAaK,cAAo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AAwBD,aAAaC,KAE7C,OAAO,CAGlB,CAED,OAAO,CACV,CAMO,SAAAnB,CAAUC,EAA0CvX,GACxDuX,EAAUA,GAAW,GACrBvX,EAAOA,EAAKsC,cAEZ,IAAK,IAAIqD,KAAO4R,EACZ,GAAI5R,EAAIrD,eAAiBtC,EACrB,OAAOuX,EAAQ5R,GAIvB,OAAO,IACV,CAKO,UAAAmS,CAAW/O,GACf,OAAOA,IAIuB,aAA1BA,EAAK7J,YAAYc,MAII,oBAAbmY,UAA4BpP,aAAgBoP,SAE3D,CAKO,oBAAAf,CAAqBvG,GACzB,MAAMzP,EAAwB,GAC9B,IAAK,MAAMuE,KAAOkL,EAAQ,CACtB,GAAoB,OAAhBA,EAAOlL,GAEP,SAGJ,MAAMxE,EAAQ0P,EAAOlL,GACf+S,EAAa/V,mBAAmBgD,GAEtC,GAAIW,MAAMC,QAAQpF,GAEd,IAAK,MAAMqX,KAAKrX,EACZC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmB6V,SAE/CrX,aAAiBa,KACxBZ,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBxB,EAAMwX,gBAChC,cAAVxX,GAAmC,iBAAVA,EACvCC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBW,KAAKoD,UAAUvF,KAEjEC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBxB,GAEzD,CAED,OAAOC,EAAOiC,KAAK,IACtB"} \ No newline at end of file +{"version":3,"file":"pocketbase.umd.js","sources":["../src/ClientResponseError.ts","../src/stores/utils/cookie.ts","../src/stores/utils/jwt.ts","../src/stores/BaseAuthStore.ts","../src/stores/LocalAuthStore.ts","../src/services/utils/BaseService.ts","../src/services/SettingsService.ts","../src/services/utils/CrudService.ts","../src/services/utils/legacy.ts","../src/services/AdminService.ts","../src/services/RealtimeService.ts","../src/services/RecordService.ts","../src/services/CollectionService.ts","../src/services/LogService.ts","../src/services/HealthService.ts","../src/services/FileService.ts","../src/services/BackupService.ts","../src/Client.ts"],"sourcesContent":["/**\n * ClientResponseError is a custom Error class that is intended to wrap\n * and normalize any error thrown by `Client.send()`.\n */\nexport class ClientResponseError extends Error {\n url: string = '';\n status: number = 0;\n response: {[key: string]: any} = {};\n isAbort: boolean = false;\n originalError: any = null;\n\n constructor(errData?: any) {\n super(\"ClientResponseError\");\n\n // Set the prototype explicitly.\n // https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\n Object.setPrototypeOf(this, ClientResponseError.prototype);\n\n if (errData !== null && typeof errData === 'object') {\n this.url = typeof errData.url === 'string' ? errData.url : '';\n this.status = typeof errData.status === 'number' ? errData.status : 0;\n this.isAbort = !!errData.isAbort;\n this.originalError = errData.originalError;\n\n if (errData.response !== null && typeof errData.response === 'object') {\n this.response = errData.response;\n } else if (errData.data !== null && typeof errData.data === 'object') {\n this.response = errData.data;\n } else {\n this.response = {};\n }\n }\n\n if (!this.originalError && !(errData instanceof ClientResponseError)) {\n this.originalError = errData;\n }\n\n if (typeof DOMException !== 'undefined' && errData instanceof DOMException) {\n this.isAbort = true;\n }\n\n this.name = \"ClientResponseError \" + this.status;\n this.message = this.response?.message;\n if (!this.message) {\n if (this.isAbort) {\n this.message = 'The request was autocancelled. You can find more info in https://github.com/pocketbase/js-sdk#auto-cancellation.';\n } else if (this.originalError?.cause?.message?.includes(\"ECONNREFUSED ::1\")) {\n this.message = 'Failed to connect to the PocketBase server. Try changing the SDK URL from localhost to 127.0.0.1 (https://github.com/pocketbase/js-sdk/issues/21).';\n } else {\n this.message = 'Something went wrong while processing your request.';\n }\n }\n }\n\n /**\n * Alias for `this.response` to preserve the backward compatibility.\n */\n get data() {\n return this.response;\n }\n\n /**\n * Make a POJO's copy of the current error class instance.\n * @see https://github.com/vuex-orm/vuex-orm/issues/255\n */\n toJSON() {\n return { ...this };\n }\n}\n","/**\n * -------------------------------------------------------------------\n * Simple cookie parse and serialize utilities mostly based on the\n * node module https://github.com/jshttp/cookie.\n * -------------------------------------------------------------------\n */\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\nconst fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;\n\nexport interface ParseOptions{\n decode?: (val: string) => string,\n}\n\n/**\n* Parses the given cookie header string into an object\n* The object has the various cookies as keys(names) => values\n*/\nexport function cookieParse(str: string, options?: ParseOptions): { [key: string]: any } {\n const result: { [key: string]: any } = {};\n\n if (typeof str !== 'string') {\n return result;\n }\n\n const opt = Object.assign({}, options || {});\n const decode = opt.decode || defaultDecode;\n\n let index = 0;\n while (index < str.length) {\n const eqIdx = str.indexOf('=', index);\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break;\n }\n\n let endIdx = str.indexOf(';', index);\n\n if (endIdx === -1) {\n endIdx = str.length;\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(';', eqIdx - 1) + 1;\n continue;\n }\n\n const key = str.slice(index, eqIdx).trim();\n\n // only assign once\n if (undefined === result[key]) {\n let val = str.slice(eqIdx + 1, endIdx).trim();\n\n // quoted values\n if (val.charCodeAt(0) === 0x22) {\n val = val.slice(1, -1);\n }\n\n try {\n result[key] = decode(val);\n } catch (_) {\n result[key] = val; // no decoding\n }\n }\n\n index = endIdx + 1;\n }\n\n return result;\n};\n\nexport interface SerializeOptions {\n encode?: (val: string | number | boolean) => string,\n maxAge?: number,\n domain?: string,\n path?: string,\n expires?: Date,\n httpOnly?: boolean,\n secure?: boolean,\n priority?: string,\n sameSite?: boolean|string,\n}\n\n/**\n * Serialize data into a cookie header.\n *\n * Serialize the a name value pair into a cookie string suitable for\n * http headers. An optional options object specified cookie parameters.\n *\n * ```js\n * cookieSerialize('foo', 'bar', { httpOnly: true }) // \"foo=bar; httpOnly\"\n * ```\n */\nexport function cookieSerialize(name: string, val: string, options?: SerializeOptions): string {\n const opt = Object.assign({}, options || {});\n const encode = opt.encode || defaultEncode;\n\n if (!fieldContentRegExp.test(name)) {\n throw new TypeError('argument name is invalid');\n }\n\n const value = encode(val);\n\n if (value && !fieldContentRegExp.test(value)) {\n throw new TypeError('argument val is invalid');\n }\n\n let result = name + '=' + value;\n\n if (opt.maxAge != null) {\n const maxAge = opt.maxAge - 0;\n\n if (isNaN(maxAge) || !isFinite(maxAge)) {\n throw new TypeError('option maxAge is invalid');\n }\n\n result += '; Max-Age=' + Math.floor(maxAge);\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new TypeError('option domain is invalid');\n }\n\n result += '; Domain=' + opt.domain;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new TypeError('option path is invalid');\n }\n\n result += '; Path=' + opt.path;\n }\n\n if (opt.expires) {\n if (!isDate(opt.expires) || isNaN(opt.expires.valueOf())) {\n throw new TypeError('option expires is invalid');\n }\n\n result += '; Expires=' + opt.expires.toUTCString();\n }\n\n if (opt.httpOnly) {\n result += '; HttpOnly';\n }\n\n if (opt.secure) {\n result += '; Secure';\n }\n\n if (opt.priority) {\n const priority = typeof opt.priority === 'string' ? opt.priority.toLowerCase() : opt.priority;\n\n switch (priority) {\n case 'low':\n result += '; Priority=Low';\n break;\n case 'medium':\n result += '; Priority=Medium';\n break;\n case 'high':\n result += '; Priority=High';\n break;\n default:\n throw new TypeError('option priority is invalid');\n }\n }\n\n if (opt.sameSite) {\n const sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;\n\n switch (sameSite) {\n case true:\n result += '; SameSite=Strict';\n break;\n case 'lax':\n result += '; SameSite=Lax';\n break;\n case 'strict':\n result += '; SameSite=Strict';\n break;\n case 'none':\n result += '; SameSite=None';\n break;\n default:\n throw new TypeError('option sameSite is invalid');\n }\n }\n\n return result;\n};\n\n/**\n * Default URL-decode string value function.\n * Optimized to skip native call when no `%`.\n */\nfunction defaultDecode(val: string): string {\n return val.indexOf('%') !== -1\n ? decodeURIComponent(val)\n : val;\n}\n\n/**\n * Default URL-encode value function.\n */\nfunction defaultEncode(val: string | number | boolean): string {\n return encodeURIComponent(val);\n}\n\n/**\n * Determines if value is a Date.\n */\nfunction isDate(val: any): boolean {\n return (\n Object.prototype.toString.call(val) === '[object Date]' ||\n val instanceof Date\n );\n}\n","let atobPolyfill: Function;\nif (typeof atob === 'function') {\n atobPolyfill = atob\n} else {\n /**\n * The code was extracted from:\n * https://github.com/davidchambers/Base64.js\n */\n atobPolyfill = (input: any) => {\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\n let str = String(input).replace(/=+$/, \"\");\n if (str.length % 4 == 1) {\n throw new Error(\"'atob' failed: The string to be decoded is not correctly encoded.\");\n }\n\n for (\n // initialize result and counters\n var bc = 0, bs, buffer, idx = 0, output = \"\";\n // get next character\n (buffer = str.charAt(idx++));\n // character found in table? initialize bit storage and add its ascii value;\n ~buffer &&\n ((bs = bc % 4 ? (bs as any) * 64 + buffer : buffer),\n // and if not first of each 4 characters,\n // convert the first 8 bits to one ascii character\n bc++ % 4) ?\n (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)))) :\n 0\n ) {\n // try to find character in table (0-63, not found => -1)\n buffer = chars.indexOf(buffer);\n }\n\n return output;\n };\n}\n\n/**\n * Returns JWT token's payload data.\n */\nexport function getTokenPayload(token: string): { [key: string]: any } {\n if (token) {\n try {\n const encodedPayload = decodeURIComponent(atobPolyfill(token.split('.')[1]).split('').map(function (c: string) {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n }).join(''));\n\n return JSON.parse(encodedPayload) || {};\n } catch (e) {\n }\n }\n\n return {};\n}\n\n/**\n * Checks whether a JWT token is expired or not.\n * Tokens without `exp` payload key are considered valid.\n * Tokens with empty payload (eg. invalid token strings) are considered expired.\n *\n * @param token The token to check.\n * @param [expirationThreshold] Time in seconds that will be subtracted from the token `exp` property.\n */\nexport function isTokenExpired(token: string, expirationThreshold = 0): boolean {\n let payload = getTokenPayload(token);\n\n if (\n Object.keys(payload).length > 0 &&\n (!payload.exp || (payload.exp - expirationThreshold) > (Date.now() / 1000))\n ) {\n return false;\n }\n\n return true;\n}\n","import { cookieParse, cookieSerialize, SerializeOptions } from '@/stores/utils/cookie';\nimport { isTokenExpired, getTokenPayload } from '@/stores/utils/jwt';\nimport { RecordModel, AdminModel } from '@/services/utils/dtos';\n\nexport type AuthModel = RecordModel|AdminModel|null;\n\nexport type OnStoreChangeFunc = (token: string, model: AuthModel) => void;\n\nconst defaultCookieKey = 'pb_auth';\n\n/**\n * Base AuthStore class that is intended to be extended by all other\n * PocketBase AuthStore implementations.\n */\nexport abstract class BaseAuthStore {\n protected baseToken: string = '';\n protected baseModel: AuthModel = null;\n\n private _onChangeCallbacks: Array = [];\n\n /**\n * Retrieves the stored token (if any).\n */\n get token(): string {\n return this.baseToken;\n }\n\n /**\n * Retrieves the stored model data (if any).\n */\n get model(): AuthModel {\n return this.baseModel;\n }\n\n /**\n * Loosely checks if the store has valid token (aka. existing and unexpired exp claim).\n */\n get isValid(): boolean {\n return !isTokenExpired(this.token);\n }\n\n /**\n * Checks whether the current store state is for admin authentication.\n */\n get isAdmin(): boolean {\n return getTokenPayload(this.token).type === \"admin\";\n }\n\n /**\n * Checks whether the current store state is for auth record authentication.\n */\n get isAuthRecord(): boolean {\n return getTokenPayload(this.token).type === \"authRecord\";\n }\n\n /**\n * Saves the provided new token and model data in the auth store.\n */\n save(token: string, model?: AuthModel): void {\n this.baseToken = token || '';\n this.baseModel = model || null;\n\n this.triggerChange();\n }\n\n /**\n * Removes the stored token and model data form the auth store.\n */\n clear(): void {\n this.baseToken = '';\n this.baseModel = null;\n this.triggerChange();\n }\n\n /**\n * Parses the provided cookie string and updates the store state\n * with the cookie's token and model data.\n *\n * NB! This function doesn't validate the token or its data.\n * Usually this isn't a concern if you are interacting only with the\n * PocketBase API because it has the proper server-side security checks in place,\n * but if you are using the store `isValid` state for permission controls\n * in a node server (eg. SSR), then it is recommended to call `authRefresh()`\n * after loading the cookie to ensure an up-to-date token and model state.\n * For example:\n *\n * ```js\n * pb.authStore.loadFromCookie(\"cookie string...\");\n *\n * try {\n * // get an up-to-date auth store state by veryfing and refreshing the loaded auth model (if any)\n * pb.authStore.isValid && await pb.collection('users').authRefresh();\n * } catch (_) {\n * // clear the auth store on failed refresh\n * pb.authStore.clear();\n * }\n * ```\n */\n loadFromCookie(cookie: string, key = defaultCookieKey): void {\n const rawData = cookieParse(cookie || '')[key] || '';\n\n let data: { [key: string]: any } = {};\n try {\n data = JSON.parse(rawData);\n // normalize\n if (typeof data === null || typeof data !== 'object' || Array.isArray(data)) {\n data = {};\n }\n } catch (_) {}\n\n this.save(data.token || '', data.model || null);\n }\n\n /**\n * Exports the current store state as cookie string.\n *\n * By default the following optional attributes are added:\n * - Secure\n * - HttpOnly\n * - SameSite=Strict\n * - Path=/\n * - Expires={the token expiration date}\n *\n * NB! If the generated cookie exceeds 4096 bytes, this method will\n * strip the model data to the bare minimum to try to fit within the\n * recommended size in https://www.rfc-editor.org/rfc/rfc6265#section-6.1.\n */\n exportToCookie(options?: SerializeOptions, key = defaultCookieKey): string {\n const defaultOptions: SerializeOptions = {\n secure: true,\n sameSite: true,\n httpOnly: true,\n path: \"/\",\n };\n\n // extract the token expiration date\n const payload = getTokenPayload(this.token);\n if (payload?.exp) {\n defaultOptions.expires = new Date(payload.exp * 1000);\n } else {\n defaultOptions.expires = new Date('1970-01-01');\n }\n\n // merge with the user defined options\n options = Object.assign({}, defaultOptions, options);\n\n const rawData = {\n token: this.token,\n model: this.model ? JSON.parse(JSON.stringify(this.model)) : null,\n };\n\n let result = cookieSerialize(key, JSON.stringify(rawData), options);\n\n const resultLength = typeof Blob !== 'undefined' ?\n (new Blob([result])).size : result.length;\n\n // strip down the model data to the bare minimum\n if (rawData.model && resultLength > 4096) {\n rawData.model = {id: rawData?.model?.id, email: rawData?.model?.email};\n const extraProps = [\"collectionId\", \"username\", \"verified\"];\n for (const prop in this.model) {\n if (extraProps.includes(prop)) {\n rawData.model[prop] = this.model[prop];\n }\n }\n result = cookieSerialize(key, JSON.stringify(rawData), options);\n }\n\n return result;\n }\n\n /**\n * Register a callback function that will be called on store change.\n *\n * You can set the `fireImmediately` argument to true in order to invoke\n * the provided callback right after registration.\n *\n * Returns a removal function that you could call to \"unsubscribe\" from the changes.\n */\n onChange(callback: OnStoreChangeFunc, fireImmediately = false): () => void {\n this._onChangeCallbacks.push(callback);\n\n if (fireImmediately) {\n callback(this.token, this.model);\n }\n\n return () => {\n for (let i = this._onChangeCallbacks.length - 1; i >= 0; i--) {\n if (this._onChangeCallbacks[i] == callback) {\n delete this._onChangeCallbacks[i]; // removes the function reference\n this._onChangeCallbacks.splice(i, 1); // reindex the array\n return;\n }\n }\n }\n }\n\n protected triggerChange(): void {\n for (const callback of this._onChangeCallbacks) {\n callback && callback(this.token, this.model);\n }\n }\n}\n","import { BaseAuthStore, AuthModel } from '@/stores/BaseAuthStore';\n\n/**\n * The default token store for browsers with auto fallback\n * to runtime/memory if local storage is undefined (eg. in node env).\n */\nexport class LocalAuthStore extends BaseAuthStore {\n private storageFallback: { [key: string]: any } = {};\n private storageKey: string\n\n constructor(storageKey = \"pocketbase_auth\") {\n super();\n\n this.storageKey = storageKey;\n\n this._bindStorageEvent();\n }\n\n /**\n * @inheritdoc\n */\n get token(): string {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.token || '';\n }\n\n /**\n * @inheritdoc\n */\n get model(): AuthModel {\n const data = this._storageGet(this.storageKey) || {};\n\n return data.model || null;\n }\n\n /**\n * @inheritdoc\n */\n save(token: string, model?: AuthModel) {\n this._storageSet(this.storageKey, {\n 'token': token,\n 'model': model,\n });\n\n super.save(token, model);\n }\n\n /**\n * @inheritdoc\n */\n clear() {\n this._storageRemove(this.storageKey);\n\n super.clear();\n }\n\n // ---------------------------------------------------------------\n // Internal helpers:\n // ---------------------------------------------------------------\n\n /**\n * Retrieves `key` from the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageGet(key: string): any {\n if (typeof window !== 'undefined' && window?.localStorage) {\n const rawValue = window.localStorage.getItem(key) || '';\n try {\n return JSON.parse(rawValue);\n } catch (e) { // not a json\n return rawValue;\n }\n }\n\n // fallback\n return this.storageFallback[key];\n }\n\n /**\n * Stores a new data in the browser's local storage\n * (or runtime/memory if local storage is undefined).\n */\n private _storageSet(key: string, value: any) {\n if (typeof window !== 'undefined' && window?.localStorage) {\n // store in local storage\n let normalizedVal = value;\n if (typeof value !== 'string') {\n normalizedVal = JSON.stringify(value);\n }\n window.localStorage.setItem(key, normalizedVal);\n } else {\n // store in fallback\n this.storageFallback[key] = value;\n }\n }\n\n /**\n * Removes `key` from the browser's local storage and the runtime/memory.\n */\n private _storageRemove(key: string) {\n // delete from local storage\n if (typeof window !== 'undefined' && window?.localStorage) {\n window.localStorage?.removeItem(key);\n }\n\n // delete from fallback\n delete this.storageFallback[key];\n }\n\n /**\n * Updates the current store state on localStorage change.\n */\n private _bindStorageEvent() {\n if (typeof window === 'undefined' || !window?.localStorage || !window.addEventListener) {\n return;\n }\n\n window.addEventListener('storage', (e) => {\n if (e.key != this.storageKey) {\n return;\n }\n\n const data = this._storageGet(this.storageKey) || {};\n\n super.save(data.token || '', data.model || null);\n });\n }\n}\n","import Client from '@/Client';\n\n/**\n * BaseService class that should be inherited from all API services.\n */\nexport abstract class BaseService {\n readonly client: Client\n\n constructor(client: Client) {\n this.client = client;\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\ninterface appleClientSecret {\n secret: string;\n}\n\nexport class SettingsService extends BaseService {\n /**\n * Fetch all available app settings.\n */\n getAll(options?: CommonOptions): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Bulk updates app settings.\n */\n update(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise<{[key: string]:any}> {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send('/api/settings', options);\n }\n\n /**\n * Performs a S3 filesystem connection test.\n *\n * The currently supported `filesystem` are \"storage\" and \"backups\".\n */\n testS3(filesystem: string = \"storage\", options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'filesystem': filesystem,\n },\n }, options);\n\n return this.client.send('/api/settings/test/s3', options)\n .then(() => true);\n }\n\n /**\n * Sends a test email.\n *\n * The possible `emailTemplate` values are:\n * - verification\n * - password-reset\n * - email-change\n */\n testEmail(toEmail: string, emailTemplate: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'email': toEmail,\n 'template': emailTemplate,\n },\n }, options);\n\n return this.client.send('/api/settings/test/email', options)\n .then(() => true);\n }\n\n /**\n * Generates a new Apple OAuth2 client secret.\n */\n generateAppleClientSecret(\n clientId: string,\n teamId: string,\n keyId: string,\n privateKey: string,\n duration: number,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n clientId,\n teamId,\n keyId,\n privateKey,\n duration,\n },\n }, options);\n\n return this.client.send('/api/settings/apple/generate-client-secret', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n FullListOptions\n} from '@/services/utils/options';\n\nexport abstract class CrudService extends BaseService {\n /**\n * Base path for the crud actions (without trailing slash, eg. '/admins').\n */\n abstract get baseCrudPath(): string\n\n /**\n * Response data decoder.\n */\n decode(data: { [key: string]: any }): T {\n return data as T;\n }\n\n /**\n * Returns a promise with all list items batch fetched at once\n * (by default 500 items per request; to change it set the `batch` query param).\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getFullList(options?: FullListOptions): Promise>\n\n /**\n * Legacy version of getFullList with explicitly specified batch size.\n */\n getFullList(batch?: number, options?: ListOptions): Promise>\n\n getFullList(batchOrqueryParams?: number|FullListOptions, options?: ListOptions): Promise> {\n if (typeof batchOrqueryParams == \"number\") {\n return this._getFullList(batchOrqueryParams, options);\n }\n\n options = Object.assign({}, batchOrqueryParams, options);\n\n let batch = 500;\n if (options.batch) {\n batch = options.batch;\n delete options.batch;\n }\n\n return this._getFullList(batch, options);\n }\n\n /**\n * Returns paginated items list.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({\n method: 'GET'\n }, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => {\n responseData.items = responseData.items?.map((item: any) => {\n return this.decode(item);\n }) || [];\n\n return responseData;\n });\n }\n\n /**\n * Returns the first found item by the specified filter.\n *\n * Internally it calls `getList(1, 1, { filter, skipTotal })` and\n * returns the first found item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n *\n * For consistency with `getOne`, this method will throw a 404\n * ClientResponseError if no item was found.\n */\n getFirstListItem(filter: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'requestKey': 'one_by_filter_' + this.baseCrudPath + \"_\" + filter,\n }, options);\n\n options.query = Object.assign({\n 'filter': filter,\n 'skipTotal': 1,\n }, options.query);\n\n return this.getList(1, 1, options)\n .then((result) => {\n if (!result?.items?.length) {\n throw new ClientResponseError({\n status: 404,\n data: {\n code: 404,\n message: \"The requested resource wasn't found.\",\n data: {},\n },\n });\n }\n\n return result.items[0];\n });\n }\n\n /**\n * Returns single item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n getOne(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Creates a new item.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n create(\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath, options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Updates an existing item by its id.\n *\n * You can use the generic T to supply a wrapper type of the crud model.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PATCH',\n 'body': bodyParams,\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then((responseData: any) => this.decode(responseData));\n }\n\n /**\n * Deletes an existing item by its id.\n */\n delete(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(id), options)\n .then(() => true);\n }\n\n /**\n * Returns a promise with all list items batch fetched at once.\n */\n protected _getFullList(batchSize = 500, options?: ListOptions): Promise> {\n options = options || {};\n options.query = Object.assign({\n 'skipTotal': 1,\n }, options.query);\n\n let result: Array = [];\n\n let request = async (page: number): Promise> => {\n return this.getList(page, batchSize || 500, options).then((list) => {\n const castedList = (list as any as ListResult);\n const items = castedList.items;\n\n result = result.concat(items);\n\n if (items.length == list.perPage) {\n return request(page + 1);\n }\n\n return result;\n });\n }\n\n return request(1);\n }\n}\n","import { SendOptions } from '@/services/utils/options';\n\nexport function normalizeLegacyOptionsArgs(legacyWarn: string, baseOptions: SendOptions, bodyOrOptions?: any, query?: any): SendOptions {\n const hasBodyOrOptions = typeof bodyOrOptions !== 'undefined';\n const hasQuery = typeof query !== 'undefined';\n\n if (!hasQuery && !hasBodyOrOptions) {\n return baseOptions;\n }\n\n if (hasQuery) {\n console.warn(legacyWarn);\n baseOptions.body = Object.assign({}, baseOptions.body, bodyOrOptions);\n baseOptions.query = Object.assign({}, baseOptions.query, query);\n\n return baseOptions;\n }\n\n baseOptions = Object.assign(baseOptions, bodyOrOptions);\n return baseOptions;\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { AdminModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface AdminAuthResponse {\n [key: string]: any;\n\n token: string;\n admin: AdminModel;\n}\n\nexport class AdminService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/admins';\n }\n\n // ---------------------------------------------------------------\n // Post update/delete AuthStore sync\n // ---------------------------------------------------------------\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(\n id: string,\n bodyParams?: {[key:string]:any}|FormData,\n options?: CommonOptions,\n ): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n // update the store state if the updated item id matches with the stored model\n if (\n this.client.authStore.model?.id === item.id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n // clear the store state if the deleted item id matches with the stored model\n if (\n success &&\n this.client.authStore.model?.id === id &&\n typeof this.client.authStore.model?.collectionId === 'undefined' // is not record auth\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful authorize response.\n */\n protected authResponse(responseData: any): AdminAuthResponse {\n const admin = this.decode(responseData?.admin || {});\n\n if (responseData?.token && responseData?.admin) {\n this.client.authStore.save(responseData.token, admin);\n }\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'admin': admin,\n });\n }\n\n /**\n * Authenticate an admin account with its email and password\n * and returns a new admin token and data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authWithPassword(email: string, password: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authWithPassword(email, password, options?).\n */\n authWithPassword(email: string, password: string, body?: any, query?: any): Promise\n\n authWithPassword(\n email: string,\n password: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': email,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(email, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(email, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-with-password', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Refreshes the current admin authenticated instance and\n * returns a new token and admin data.\n *\n * On success this method automatically updates the client's AuthStore data.\n */\n authRefresh(options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/auth-refresh', options)\n .then(this.authResponse.bind(this));\n }\n\n /**\n * Sends admin password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/request-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Confirms admin password reset request.\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(resetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, body?: any, query?: any): Promise\n\n confirmPasswordReset(resetToken: string, password: string, passwordConfirm: string, bodyOrOptions?: any, query?: any): Promise{\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': resetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(resetToken, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(resetToken, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCrudPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ClientResponseError } from '@/ClientResponseError';\n\ninterface promiseCallbacks {\n resolve: Function\n reject: Function\n}\n\nexport type UnsubscribeFunc = () => Promise;\n\nexport class RealtimeService extends BaseService {\n clientId: string = \"\";\n\n private eventSource: EventSource | null = null;\n private subscriptions: { [key: string]: Array } = {};\n private lastSentTopics: Array = [];\n private connectTimeoutId: any;\n private maxConnectTimeout: number = 15000;\n private reconnectTimeoutId: any;\n private reconnectAttempts: number = 0;\n private maxReconnectAttempts: number = Infinity;\n private predefinedReconnectIntervals: Array = [\n 200, 300, 500, 1000, 1200, 1500, 2000,\n ];\n private pendingConnects: Array = [];\n\n /**\n * Returns whether the realtime connection has been established.\n */\n get isConnected(): boolean {\n return !!this.eventSource && !!this.clientId && !this.pendingConnects.length;\n }\n\n /**\n * Register the subscription listener.\n *\n * You can subscribe multiple times to the same topic.\n *\n * If the SSE connection is not started yet,\n * this method will also initialize it.\n */\n async subscribe(topic: string, callback: (data: any) => void): Promise {\n if (!topic) {\n throw new Error('topic must be set.')\n }\n\n const listener = function (e: Event) {\n const msgEvent = (e as MessageEvent);\n\n let data;\n try {\n data = JSON.parse(msgEvent?.data);\n } catch {}\n\n callback(data || {});\n };\n\n // store the listener\n if (!this.subscriptions[topic]) {\n this.subscriptions[topic] = [];\n }\n this.subscriptions[topic].push(listener);\n\n if (!this.isConnected) {\n // initialize sse connection\n await this.connect();\n } else if (this.subscriptions[topic].length === 1) {\n // send the updated subscriptions (if it is the first for the topic)\n await this.submitSubscriptions();\n } else {\n // only register the listener\n this.eventSource?.addEventListener(topic, listener);\n }\n\n return async (): Promise => {\n return this.unsubscribeByTopicAndListener(topic, listener);\n };\n }\n\n /**\n * Unsubscribe from all subscription listeners with the specified topic.\n *\n * If `topic` is not provided, then this method will unsubscribe\n * from all active subscriptions.\n *\n * This method is no-op if there are no active subscriptions.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribe(topic?: string): Promise {\n if (!this.hasSubscriptionListeners(topic)) {\n return; // already unsubscribed\n }\n\n if (!topic) {\n // remove all subscriptions\n this.subscriptions = {};\n } else {\n // remove all topic listeners\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n /**\n * Unsubscribe from all subscription listeners starting with the specified topic prefix.\n *\n * This method is no-op if there are no active subscriptions with the specified topic prefix.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByPrefix(topicPrefix: string): Promise {\n let hasAtleastOneTopic = false;\n for (let topic in this.subscriptions) {\n if (!topic.startsWith(topicPrefix)) {\n continue;\n }\n\n hasAtleastOneTopic = true;\n for (let listener of this.subscriptions[topic]) {\n this.eventSource?.removeEventListener(topic, listener);\n }\n delete this.subscriptions[topic];\n }\n\n if (!hasAtleastOneTopic) {\n return; // nothing to unsubscribe from\n }\n\n if (this.hasSubscriptionListeners()) {\n // submit the deleted subscriptions\n await this.submitSubscriptions();\n } else {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n }\n }\n\n /**\n * Unsubscribe from all subscriptions matching the specified topic and listener function.\n *\n * This method is no-op if there are no active subscription with\n * the specified topic and listener.\n *\n * The related sse connection will be autoclosed if after the\n * unsubscribe operation there are no active subscriptions left.\n */\n async unsubscribeByTopicAndListener(topic: string, listener: EventListener): Promise {\n if (!Array.isArray(this.subscriptions[topic]) || !this.subscriptions[topic].length) {\n return; // already unsubscribed\n }\n\n let exist = false;\n for (let i = this.subscriptions[topic].length - 1; i >= 0; i--) {\n if (this.subscriptions[topic][i] !== listener) {\n continue;\n }\n\n exist = true; // has at least one matching listener\n delete this.subscriptions[topic][i]; // removes the function reference\n this.subscriptions[topic].splice(i, 1); // reindex the array\n this.eventSource?.removeEventListener(topic, listener);\n }\n if (!exist) {\n return;\n }\n\n // remove the topic from the subscriptions list if there are no other listeners\n if (!this.subscriptions[topic].length) {\n delete this.subscriptions[topic];\n }\n\n if (!this.hasSubscriptionListeners()) {\n // no other active subscriptions -> close the sse connection\n this.disconnect();\n } else if (!this.hasSubscriptionListeners(topic)) {\n // submit subscriptions change if there are no other active subscriptions related to the topic\n await this.submitSubscriptions();\n }\n }\n\n private hasSubscriptionListeners(topicToCheck?: string): boolean {\n this.subscriptions = this.subscriptions || {};\n\n // check the specified topic\n if (topicToCheck) {\n return !!this.subscriptions[topicToCheck]?.length;\n }\n\n // check for at least one non-empty topic\n for (let topic in this.subscriptions) {\n if (!!this.subscriptions[topic]?.length) {\n return true\n }\n }\n\n return false;\n }\n\n private async submitSubscriptions(): Promise {\n if (!this.clientId) {\n return; // no client/subscriber\n }\n\n // optimistic update\n this.addAllSubscriptionListeners();\n\n this.lastSentTopics = this.getNonEmptySubscriptionTopics();\n\n return this.client.send('/api/realtime', {\n 'method': 'POST',\n 'body': {\n 'clientId': this.clientId,\n 'subscriptions': this.lastSentTopics,\n },\n 'query': {\n 'requestKey': this.getSubscriptionsCancelKey(),\n },\n }).catch((err) => {\n if (err?.isAbort) {\n return; // silently ignore aborted pending requests\n }\n throw err;\n });\n }\n\n private getSubscriptionsCancelKey(): string {\n return \"realtime_\" + this.clientId;\n }\n\n private getNonEmptySubscriptionTopics(): Array {\n const result : Array = [];\n\n for (let topic in this.subscriptions) {\n if (this.subscriptions[topic].length) {\n result.push(topic);\n }\n }\n\n return result;\n }\n\n private addAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n this.removeAllSubscriptionListeners();\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.addEventListener(topic, listener);\n }\n }\n }\n\n private removeAllSubscriptionListeners(): void {\n if (!this.eventSource) {\n return;\n }\n\n for (let topic in this.subscriptions) {\n for (let listener of this.subscriptions[topic]) {\n this.eventSource.removeEventListener(topic, listener);\n }\n }\n }\n\n private async connect(): Promise {\n if (this.reconnectAttempts > 0) {\n // immediately resolve the promise to avoid indefinitely\n // blocking the client during reconnection\n return;\n }\n\n return new Promise((resolve, reject) => {\n this.pendingConnects.push({ resolve, reject });\n\n if (this.pendingConnects.length > 1) {\n // all promises will be resolved once the connection is established\n return;\n }\n\n this.initConnect();\n })\n }\n\n private initConnect() {\n this.disconnect(true);\n\n // wait up to 15s for connect\n clearTimeout(this.connectTimeoutId);\n this.connectTimeoutId = setTimeout(() => {\n this.connectErrorHandler(new Error(\"EventSource connect took too long.\"));\n }, this.maxConnectTimeout);\n\n this.eventSource = new EventSource(this.client.buildUrl('/api/realtime'))\n\n this.eventSource.onerror = (_) => {\n this.connectErrorHandler(new Error(\"Failed to establish realtime connection.\"));\n };\n\n this.eventSource.addEventListener('PB_CONNECT', (e) => {\n const msgEvent = (e as MessageEvent);\n this.clientId = msgEvent?.lastEventId;\n\n this.submitSubscriptions()\n .then(async () => {\n let retries = 3;\n while (this.hasUnsentSubscriptions() && retries > 0) {\n retries--;\n // resubscribe to ensure that the latest topics are submitted\n //\n // This is needed because missed topics could happen on reconnect\n // if after the pending sent `submitSubscriptions()` call another `subscribe()`\n // was made before the submit was able to complete.\n await this.submitSubscriptions();\n }\n }).then(() => {\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n\n // reset connect meta\n this.pendingConnects = [];\n this.reconnectAttempts = 0;\n clearTimeout(this.reconnectTimeoutId);\n clearTimeout(this.connectTimeoutId);\n }).catch((err) => {\n this.clientId = \"\";\n this.connectErrorHandler(err);\n });\n });\n }\n\n private hasUnsentSubscriptions(): boolean {\n const latestTopics = this.getNonEmptySubscriptionTopics();\n if (latestTopics.length != this.lastSentTopics.length) {\n return true;\n }\n\n for (const t of latestTopics) {\n if (!this.lastSentTopics.includes(t)) {\n return true;\n }\n }\n\n return false;\n }\n\n private connectErrorHandler(err: any) {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n\n if (\n // wasn't previously connected -> direct reject\n (!this.clientId && !this.reconnectAttempts) ||\n // was previously connected but the max reconnection limit has been reached\n this.reconnectAttempts > this.maxReconnectAttempts\n ) {\n for (let p of this.pendingConnects) {\n p.reject(new ClientResponseError(err));\n }\n this.pendingConnects = [];\n this.disconnect();\n return;\n }\n\n // otherwise -> reconnect in the background\n this.disconnect(true);\n const timeout = this.predefinedReconnectIntervals[this.reconnectAttempts] || this.predefinedReconnectIntervals[this.predefinedReconnectIntervals.length - 1];\n this.reconnectAttempts++;\n this.reconnectTimeoutId = setTimeout(() => {\n this.initConnect();\n }, timeout);\n }\n\n private disconnect(fromReconnect = false): void {\n clearTimeout(this.connectTimeoutId);\n clearTimeout(this.reconnectTimeoutId);\n this.removeAllSubscriptionListeners();\n this.client.cancelRequest(this.getSubscriptionsCancelKey());\n this.eventSource?.close();\n this.eventSource = null;\n this.clientId = \"\";\n\n if (!fromReconnect) {\n this.reconnectAttempts = 0;\n\n // resolve any remaining connect promises\n //\n // this is done to avoid unnecessary throwing errors in case\n // unsubscribe is called before the pending connect promises complete\n // (see https://github.com/pocketbase/pocketbase/discussions/2897#discussioncomment-6423818)\n for (let p of this.pendingConnects) {\n p.resolve();\n }\n this.pendingConnects = [];\n }\n }\n}\n","import Client from '@/Client';\nimport { CrudService } from '@/services/utils/CrudService';\nimport { RealtimeService, UnsubscribeFunc } from '@/services/RealtimeService';\nimport { ClientResponseError } from '@/ClientResponseError';\nimport { ListResult, RecordModel, ExternalAuthModel } from '@/services/utils/dtos';\nimport {\n SendOptions,\n CommonOptions,\n RecordOptions,\n RecordListOptions,\n RecordFullListOptions,\n} from '@/services/utils/options';\nimport { normalizeLegacyOptionsArgs } from '@/services/utils/legacy';\n\nexport interface RecordAuthResponse {\n // The signed PocketBase auth record.\n record: T;\n\n // The PocketBase record auth token.\n //\n // If you are looking for the OAuth2 access and refresh tokens\n // they are available under the `meta.accessToken` and `meta.refreshToken` props.\n token: string;\n\n // Auth meta data usually filled when OAuth2 is used.\n meta?: {[key: string]: any};\n}\n\nexport interface AuthProviderInfo {\n name: string;\n state: string;\n codeVerifier: string;\n codeChallenge: string;\n codeChallengeMethod: string;\n authUrl: string;\n}\n\nexport interface AuthMethodsList {\n usernamePassword: boolean;\n emailPassword: boolean;\n authProviders: Array;\n}\n\nexport interface RecordSubscription {\n action: string; // eg. create, update, delete\n record: T;\n}\n\nexport type OAuth2UrlCallback = (url: string) => void|Promise;\n\nexport interface OAuth2AuthConfig extends SendOptions {\n // the name of the OAuth2 provider (eg. \"google\")\n provider: string;\n\n // custom scopes to overwrite the default ones\n scopes?: Array;\n\n // optional record create data\n createData?: {[key: string]: any};\n\n // optional callback that is triggered after the OAuth2 sign-in/sign-up url generation\n urlCallback?: OAuth2UrlCallback;\n\n // optional query params to send with the PocketBase auth request (eg. fields, expand, etc.)\n query?: RecordOptions;\n}\n\nexport class RecordService extends CrudService {\n readonly collectionIdOrName: string;\n\n constructor(client: Client, collectionIdOrName: string) {\n super(client);\n\n this.collectionIdOrName = collectionIdOrName;\n }\n\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return this.baseCollectionPath + '/records';\n }\n\n /**\n * Returns the current collection service base path.\n */\n get baseCollectionPath(): string {\n return '/api/collections/' + encodeURIComponent(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Realtime handlers\n // ---------------------------------------------------------------\n\n /**\n * @deprecated Use subscribe(recordId, callback) instead.\n *\n * Subscribe to the realtime changes of a single record in the collection.\n */\n async subscribeOne(recordId: string, callback: (data: RecordSubscription) => void): Promise {\n console.warn(\"PocketBase: subscribeOne(recordId, callback) is deprecated. Please replace it with subscribe(recordId, callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName + \"/\" + recordId, callback);\n }\n\n /**\n * @deprecated This form of subscribe is deprecated. Please use `subscribe(\"*\", callback)`.\n */\n async subscribe(callback: (data: RecordSubscription) => void): Promise\n\n /**\n * Subscribe to realtime changes to the specified topic (\"*\" or record id).\n *\n * If `topic` is the wildcard \"*\", then this method will subscribe to\n * any record changes in the collection.\n *\n * If `topic` is a record id, then this method will subscribe only\n * to changes of the specified record id.\n *\n * It's OK to subscribe multiple times to the same topic.\n * You can use the returned `UnsubscribeFunc` to remove only a single subscription.\n * Or use `unsubscribe(topic)` if you want to remove all subscriptions attached to the topic.\n */\n async subscribe(topic: string, callback: (data: RecordSubscription) => void): Promise\n\n async subscribe(\n topicOrCallback: string|((data: RecordSubscription) => void),\n callback?: (data: RecordSubscription) => void\n ): Promise {\n if (typeof topicOrCallback === 'function') {\n console.warn(\"PocketBase: subscribe(callback) is deprecated. Please replace it with subscribe('*', callback).\");\n return this.client.realtime.subscribe(this.collectionIdOrName, topicOrCallback);\n }\n\n if (!callback) {\n throw new Error(\"Missing subscription callback.\");\n }\n\n if (topicOrCallback === \"\") {\n throw new Error(\"Missing topic.\");\n }\n\n let topic = this.collectionIdOrName;\n if (topicOrCallback !== \"*\") {\n topic += ('/' + topicOrCallback);\n }\n\n return this.client.realtime.subscribe(topic, callback)\n }\n\n /**\n * Unsubscribe from all subscriptions of the specified topic\n * (\"*\" or record id).\n *\n * If `topic` is not set, then this method will unsubscribe from\n * all subscriptions associated to the current collection.\n */\n async unsubscribe(topic?: string): Promise {\n // unsubscribe wildcard topic\n if (topic === \"*\") {\n return this.client.realtime.unsubscribe(this.collectionIdOrName);\n }\n\n // unsubscribe recordId topic\n if (topic) {\n return this.client.realtime.unsubscribe(this.collectionIdOrName + \"/\" + topic);\n }\n\n // unsubscribe from everything related to the collection\n return this.client.realtime.unsubscribeByPrefix(this.collectionIdOrName);\n }\n\n // ---------------------------------------------------------------\n // Crud handers\n // ---------------------------------------------------------------\n /**\n * @inheritdoc\n */\n getFullList(options?: RecordFullListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batch?: number, options?: RecordListOptions): Promise>\n\n /**\n * @inheritdoc\n */\n getFullList(batchOrOptions?: number|RecordFullListOptions, options?: RecordListOptions): Promise> {\n if (typeof batchOrOptions == \"number\") {\n return super.getFullList(batchOrOptions, options);\n }\n\n const params = Object.assign({}, batchOrOptions, options);\n\n return super.getFullList(params);\n }\n\n /**\n * @inheritdoc\n */\n getList(page = 1, perPage = 30, options?: RecordListOptions): Promise> {\n return super.getList(page, perPage, options);\n }\n\n /**\n * @inheritdoc\n */\n getFirstListItem(filter: string, options?: RecordListOptions): Promise {\n return super.getFirstListItem(filter, options);\n }\n\n /**\n * @inheritdoc\n */\n getOne(id: string, options?: RecordOptions): Promise {\n return super.getOne(id, options);\n }\n\n /**\n * @inheritdoc\n */\n create(bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.create(bodyParams, options);\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the updated id, then\n * on success the `client.authStore.model` will be updated with the result.\n */\n update(id: string, bodyParams?: {[key:string]:any}|FormData, options?: RecordOptions): Promise {\n return super.update(id, bodyParams, options).then((item) => {\n if (\n // is record auth\n this.client.authStore.model?.id === item?.id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.save(this.client.authStore.token, item);\n }\n\n return item as any as T;\n });\n }\n\n /**\n * @inheritdoc\n *\n * If the current `client.authStore.model` matches with the deleted id,\n * then on success the `client.authStore` will be cleared.\n */\n delete(id: string, options?: CommonOptions): Promise {\n return super.delete(id, options).then((success) => {\n if (\n success &&\n // is record auth\n this.client.authStore.model?.id === id &&\n (\n this.client.authStore.model?.collectionId === this.collectionIdOrName ||\n this.client.authStore.model?.collectionName === this.collectionIdOrName\n )\n ) {\n this.client.authStore.clear();\n }\n\n return success;\n });\n }\n\n // ---------------------------------------------------------------\n // Auth handlers\n // ---------------------------------------------------------------\n\n /**\n * Prepare successful collection authorization response.\n */\n protected authResponse(responseData: any): RecordAuthResponse {\n const record = this.decode(responseData?.record || {});\n\n this.client.authStore.save(responseData?.token, record);\n\n return Object.assign({}, responseData, {\n // normalize common fields\n 'token': responseData?.token || '',\n 'record': record as any as T,\n });\n }\n\n /**\n * Returns all available collection auth methods.\n */\n listAuthMethods(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCollectionPath + '/auth-methods', options)\n .then((responseData: any) => {\n return Object.assign({}, responseData, {\n // normalize common fields\n 'usernamePassword': !!responseData?.usernamePassword,\n 'emailPassword': !!responseData?.emailPassword,\n 'authProviders': Array.isArray(responseData?.authProviders) ? responseData?.authProviders : [],\n });\n });\n }\n\n /**\n * Authenticate a single auth collection record via its username/email and password.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n */\n authWithPassword(usernameOrEmail: string, password: string, options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authWithPassword(usernameOrEmail, password, options?).\n */\n authWithPassword(usernameOrEmail: string, password: string, body?: any, query?: any): Promise>\n\n authWithPassword(usernameOrEmail: string, password: string, bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'identity': usernameOrEmail,\n 'password': password,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithPassword(usernameOrEmail, pass, body?, query?) is deprecated. Consider replacing it with authWithPassword(usernameOrEmail, pass, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-password', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Authenticate a single auth collection record with OAuth2 code.\n *\n * If you don't have an OAuth2 code you may also want to check `authWithOAuth2` method.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n options?: RecordOptions,\n ): Promise>\n\n /**\n * @deprecated\n * Consider using authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createdData, options?).\n */\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n body?: any,\n query?: any\n ): Promise>\n\n authWithOAuth2Code(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key:string]:any},\n bodyOrOptions?: any,\n query?: any\n ): Promise> {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'provider': provider,\n 'code': code,\n 'codeVerifier': codeVerifier,\n 'redirectUrl': redirectUrl,\n 'createData': createData,\n },\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, body?, query?) is deprecated. Consider replacing it with authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createData?, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-with-oauth2', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * @deprecated This form of authWithOAuth2 is deprecated.\n *\n * Please use `authWithOAuth2Code()` OR its simplified realtime version\n * as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\n */\n async authWithOAuth2(\n provider: string,\n code: string,\n codeVerifier: string,\n redirectUrl: string,\n createData?: {[key: string]: any},\n bodyParams?: {[key: string]: any},\n queryParams?: RecordOptions,\n ): Promise>\n\n /**\n * Authenticate a single auth collection record with OAuth2\n * **without custom redirects, deeplinks or even page reload**.\n *\n * This method initializes a one-off realtime subscription and will\n * open a popup window with the OAuth2 vendor page to authenticate.\n * Once the external OAuth2 sign-in/sign-up flow is completed, the popup\n * window will be automatically closed and the OAuth2 data sent back\n * to the user through the previously established realtime connection.\n *\n * You can specify an optional `urlCallback` prop to customize\n * the default url `window.open` behavior.\n *\n * On success, this method also automatically updates\n * the client's AuthStore data and returns:\n * - the authentication token\n * - the authenticated record model\n * - the OAuth2 account data (eg. name, email, avatar, etc.)\n *\n * Example:\n *\n * ```js\n * const authData = await pb.collection(\"users\").authWithOAuth2({\n * provider: \"google\",\n * })\n * ```\n *\n * _Site-note_: when creating the OAuth2 app in the provider dashboard\n * you have to configure `https://yourdomain.com/api/oauth2-redirect`\n * as redirect URL.\n */\n async authWithOAuth2(options: OAuth2AuthConfig): Promise>\n\n async authWithOAuth2(...args: any): Promise> {\n // fallback to legacy format\n if (args.length > 1 || typeof args?.[0] === 'string') {\n console.warn(\"PocketBase: This form of authWithOAuth2() is deprecated and may get removed in the future. Please replace with authWithOAuth2Code() OR use the authWithOAuth2() realtime form as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.\");\n return this.authWithOAuth2Code(\n args?.[0] || '',\n args?.[1] || '',\n args?.[2] || '',\n args?.[3] || '',\n args?.[4] || {},\n args?.[5] || {},\n args?.[6] || {},\n );\n }\n\n const config = args?.[0] || {};\n\n const authMethods = await this.listAuthMethods();\n\n const provider = authMethods.authProviders.find((p) => p.name === config.provider);\n if (!provider) {\n throw new ClientResponseError(new Error(`Missing or invalid provider \"${config.provider}\".`));\n }\n\n const redirectUrl = this.client.buildUrl('/api/oauth2-redirect');\n\n // initialize a one-off realtime service\n const realtime = new RealtimeService(this.client);\n\n // open a new popup window in case config.urlCallback is not set\n //\n // note: it is opened before the async call due to Safari restrictions\n // (see https://github.com/pocketbase/pocketbase/discussions/2429#discussioncomment-5943061)\n let eagerDefaultPopup: Window|null = null;\n if (!config.urlCallback) {\n eagerDefaultPopup = openBrowserPopup(undefined);\n }\n\n function cleanup() {\n eagerDefaultPopup?.close();\n realtime.unsubscribe();\n }\n\n return new Promise(async (resolve, reject) => {\n try {\n await realtime.subscribe('@oauth2', async (e) => {\n const oldState = realtime.clientId;\n\n try {\n if (!e.state || oldState !== e.state) {\n throw new Error(\"State parameters don't match.\");\n }\n\n // clear the non SendOptions props\n const options = Object.assign({}, config);\n delete options.provider;\n delete options.scopes;\n delete options.createData;\n delete options.urlCallback;\n\n const authData = await this.authWithOAuth2Code(\n provider.name,\n e.code,\n provider.codeVerifier,\n redirectUrl,\n config.createData,\n options,\n );\n\n resolve(authData);\n } catch (err) {\n reject(new ClientResponseError(err));\n }\n\n cleanup();\n });\n\n const replacements: {[key: string]: any} = {\n \"state\": realtime.clientId,\n }\n if (config.scopes?.length) {\n replacements[\"scope\"] = config.scopes.join(\" \");\n }\n\n const url = this._replaceQueryParams(provider.authUrl + redirectUrl, replacements);\n\n let urlCallback = config.urlCallback || function (url: string) {\n if (eagerDefaultPopup) {\n eagerDefaultPopup.location.href = url;\n } else {\n // it could have been blocked due to its empty initial url,\n // try again...\n eagerDefaultPopup = openBrowserPopup(url);\n }\n }\n\n await urlCallback(url);\n } catch (err) {\n cleanup();\n reject(new ClientResponseError(err));\n }\n });\n }\n\n /**\n * Refreshes the current authenticated record instance and\n * returns a new token and record data.\n *\n * On success this method also automatically updates the client's AuthStore.\n */\n authRefresh(options?: RecordOptions): Promise>\n\n /**\n * @deprecated\n * Consider using authRefresh(options?).\n */\n authRefresh(body?: any, query?: any): Promise>\n\n authRefresh(bodyOrOptions?: any, query?: any): Promise> {\n let options: any = {\n 'method': 'POST',\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/auth-refresh', options)\n .then((data) => this.authResponse(data));\n }\n\n /**\n * Sends auth record password reset request.\n */\n requestPasswordReset(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestPasswordReset(email, options?).\n */\n requestPasswordReset(email: string, body?: any, query?: any): Promise\n\n requestPasswordReset(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-password-reset', options).then(() => true);\n }\n\n /**\n * Confirms auth record password reset request.\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n options?: CommonOptions,\n ): Promise\n\n /**\n * @deprecated\n * Consider using confirmPasswordReset(passwordResetToken, password, passwordConfirm, options?).\n */\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n body?: any,\n query?: any,\n ): Promise\n\n confirmPasswordReset(\n passwordResetToken: string,\n password: string,\n passwordConfirm: string,\n bodyOrOptions?: any,\n query?: any,\n ): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': passwordResetToken,\n 'password': password,\n 'passwordConfirm': passwordConfirm,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmPasswordReset(token, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(token, password, passwordConfirm, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-password-reset', options)\n .then(() => true);\n }\n\n /**\n * Sends auth record verification email request.\n */\n requestVerification(email: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestVerification(email, options?).\n */\n requestVerification(email: string, body?: any, query?: any): Promise\n\n requestVerification(email: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'email': email,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestVerification(email, body?, query?) is deprecated. Consider replacing it with requestVerification(email, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-verification', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record email verification request.\n */\n confirmVerification(verificationToken: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using confirmVerification(verificationToken, options?).\n */\n confirmVerification(verificationToken: string, body?: any, query?: any): Promise\n\n confirmVerification(verificationToken: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': verificationToken,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmVerification(token, body?, query?) is deprecated. Consider replacing it with confirmVerification(token, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-verification', options)\n .then(() => true);\n }\n\n /**\n * Sends an email change request to the authenticated record model.\n */\n requestEmailChange(newEmail: string, options?: CommonOptions): Promise\n\n /**\n * @deprecated\n * Consider using requestEmailChange(newEmail, options?).\n */\n requestEmailChange(newEmail: string, body?: any, query?: any): Promise\n\n requestEmailChange(newEmail: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'newEmail': newEmail,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of requestEmailChange(newEmail, body?, query?) is deprecated. Consider replacing it with requestEmailChange(newEmail, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/request-email-change', options)\n .then(() => true);\n }\n\n /**\n * Confirms auth record's new email address.\n */\n confirmEmailChange(emailChangeToken: string, password: string, options?: CommonOptions): Promise\n\n\n /**\n * @deprecated\n * Consider using confirmEmailChange(emailChangeToken, password, options?).\n */\n confirmEmailChange(emailChangeToken: string, password: string, body?: any, query?: any): Promise\n\n confirmEmailChange(emailChangeToken: string, password: string, bodyOrOptions?: any, query?: any): Promise {\n let options: any = {\n 'method': 'POST',\n 'body': {\n 'token': emailChangeToken,\n 'password': password,\n }\n };\n\n options = normalizeLegacyOptionsArgs(\n 'This form of confirmEmailChange(token, password, body?, query?) is deprecated. Consider replacing it with confirmEmailChange(token, password, options?).',\n options,\n bodyOrOptions,\n query\n );\n\n return this.client.send(this.baseCollectionPath + '/confirm-email-change', options)\n .then(() => true);\n }\n\n /**\n * Lists all linked external auth providers for the specified auth record.\n */\n listExternalAuths(recordId: string, options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths', options);\n }\n\n /**\n * Unlink a single external auth provider from the specified auth record.\n */\n unlinkExternalAuth(recordId: string, provider: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(this.baseCrudPath + '/' + encodeURIComponent(recordId) + '/external-auths/' + encodeURIComponent(provider), options)\n .then(() => true);\n }\n\n // ---------------------------------------------------------------\n\n // very rudimentary url query params replacement because at the moment\n // URL (and URLSearchParams) doesn't seem to be fully supported in React Native\n //\n // note: for details behind some of the decode/encode parsing check https://unixpapa.com/js/querystring.html\n private _replaceQueryParams(url: string, replacements: {[key: string]: any} = {}): string {\n let urlPath = url\n let query = \"\";\n\n const queryIndex = url.indexOf(\"?\");\n if (queryIndex >= 0) {\n urlPath = url.substring(0, url.indexOf(\"?\"));\n query = url.substring(url.indexOf(\"?\") + 1);\n }\n\n const parsedParams: {[key: string]: string} = {};\n\n // parse the query parameters\n const rawParams = query.split(\"&\");\n for (const param of rawParams) {\n if (param == \"\") {\n continue\n }\n\n const pair = param.split(\"=\");\n parsedParams[decodeURIComponent(pair[0].replace(/\\+/g,' '))] = decodeURIComponent((pair[1] || \"\").replace(/\\+/g,' '));\n }\n\n // apply the replacements\n for (let key in replacements) {\n if (!replacements.hasOwnProperty(key)) {\n continue;\n }\n\n if (replacements[key] == null) {\n delete parsedParams[key];\n } else {\n parsedParams[key] = replacements[key];\n }\n }\n\n // construct back the full query string\n query = \"\";\n for (let key in parsedParams) {\n if (!parsedParams.hasOwnProperty(key)) {\n continue;\n }\n\n if (query != \"\") {\n query += \"&\";\n }\n\n query += encodeURIComponent(key.replace(/%20/g,'+')) + \"=\" + encodeURIComponent(parsedParams[key].replace(/%20/g,'+'));\n }\n\n return query != \"\" ? (urlPath + \"?\" + query) : urlPath;\n }\n}\n\nfunction openBrowserPopup(url?: string): Window|null {\n if (typeof window === \"undefined\" || !window?.open) {\n throw new ClientResponseError(new Error(`Not in a browser context - please pass a custom urlCallback function.`));\n }\n\n let width = 1024;\n let height = 768;\n\n let windowWidth = window.innerWidth;\n let windowHeight = window.innerHeight;\n\n // normalize window size\n width = width > windowWidth ? windowWidth : width;\n height = height > windowHeight ? windowHeight : height;\n\n let left = (windowWidth / 2) - (width / 2);\n let top = (windowHeight / 2) - (height / 2);\n\n // note: we don't use the noopener and noreferrer attributes since\n // for some reason browser blocks such windows then url is undefined/blank\n return window.open(\n url,\n 'popup_window',\n 'width='+width+',height='+height+',top='+top+',left='+left+',resizable,menubar=no'\n );\n}\n","import { CrudService } from '@/services/utils/CrudService';\nimport { CollectionModel } from '@/services/utils/dtos';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport class CollectionService extends CrudService {\n /**\n * @inheritdoc\n */\n get baseCrudPath(): string {\n return '/api/collections';\n }\n\n /**\n * Imports the provided collections.\n *\n * If `deleteMissing` is `true`, all local collections and schema fields,\n * that are not present in the imported configuration, WILL BE DELETED\n * (including their related records data)!\n */\n async import(\n collections: Array,\n deleteMissing: boolean = false,\n options?: CommonOptions,\n ): Promise {\n options = Object.assign({\n 'method': 'PUT',\n 'body': {\n 'collections': collections,\n 'deleteMissing': deleteMissing,\n }\n }, options);\n\n return this.client.send(this.baseCrudPath + '/import', options)\n .then(() => true);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { ListResult, LogRequestModel } from '@/services/utils/dtos';\nimport {\n CommonOptions,\n ListOptions,\n LogStatsOptions,\n} from '@/services/utils/options';\n\nexport interface HourlyStats {\n total: number;\n date: string;\n}\n\nexport class LogService extends BaseService {\n /**\n * Returns paginated logged requests list.\n */\n getRequestsList(page = 1, perPage = 30, options?: ListOptions): Promise> {\n options = Object.assign({'method': 'GET'}, options);\n\n options.query = Object.assign({\n 'page': page,\n 'perPage': perPage,\n }, options.query);\n\n return this.client.send('/api/logs/requests', options);\n }\n\n /**\n * Returns a single logged request by its id.\n */\n getRequest(id: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/' + encodeURIComponent(id), options);\n }\n\n /**\n * Returns request logs statistics.\n */\n getRequestsStats(options?: LogStatsOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/logs/requests/stats', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface HealthCheckResponse {\n code: number;\n message: string;\n data: {[key: string]: any};\n}\n\nexport class HealthService extends BaseService {\n /**\n * Checks the health status of the api.\n */\n check(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/health', options);\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions, FileOptions } from '@/services/utils/options';\n\nexport class FileService extends BaseService {\n /**\n * Builds and returns an absolute record file url for the provided filename.\n */\n getUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n if (\n !filename ||\n !record?.id ||\n !(record?.collectionId || record?.collectionName)\n ) {\n return '';\n }\n\n const parts = [];\n parts.push('api')\n parts.push('files')\n parts.push(encodeURIComponent(record.collectionId || record.collectionName))\n parts.push(encodeURIComponent(record.id))\n parts.push(encodeURIComponent(filename))\n\n let result = this.client.buildUrl(parts.join('/'));\n\n if (Object.keys(queryParams).length) {\n // normalize the download query param for consistency with the Dart sdk\n if (queryParams.download === false) {\n delete(queryParams.download);\n }\n\n const params = new URLSearchParams(queryParams);\n\n result += (result.includes('?') ? '&' : '?') + params;\n }\n\n return result\n }\n\n /**\n * Requests a new private file access token for the current auth model (admin or record).\n */\n getToken(options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send('/api/files/token', options)\n .then((data) => data?.token || '');\n }\n}\n","import { BaseService } from '@/services/utils/BaseService';\nimport { CommonOptions } from '@/services/utils/options';\n\nexport interface BackupFileInfo {\n key: string;\n size: number;\n modified: string;\n}\n\nexport class BackupService extends BaseService {\n /**\n * Returns list with all available backup files.\n */\n getFullList(options?: CommonOptions): Promise> {\n options = Object.assign({\n 'method': 'GET',\n }, options);\n\n return this.client.send('/api/backups', options);\n }\n\n /**\n * Initializes a new backup.\n */\n create(basename: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n 'body': {\n 'name': basename,\n },\n }, options);\n\n return this.client.send('/api/backups', options)\n .then(() => true);\n }\n\n /**\n * Deletes a single backup file.\n */\n delete(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'DELETE',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}`, options)\n .then(() => true);\n }\n\n /**\n * Initializes an app data restore from an existing backup.\n */\n restore(key: string, options?: CommonOptions): Promise {\n options = Object.assign({\n 'method': 'POST',\n }, options);\n\n return this.client.send(`/api/backups/${encodeURIComponent(key)}/restore`, options)\n .then(() => true);\n }\n\n /**\n * Builds a download url for a single existing backup using an\n * admin file token and the backup file key.\n *\n * The file token can be generated via `pb.files.getToken()`.\n */\n getDownloadUrl(token: string, key: string): string {\n return this.client.buildUrl(`/api/backups/${encodeURIComponent(key)}?token=${encodeURIComponent(token)}`);\n }\n}\n","import { ClientResponseError } from '@/ClientResponseError';\nimport { BaseAuthStore } from '@/stores/BaseAuthStore';\nimport { LocalAuthStore } from '@/stores/LocalAuthStore';\nimport { SettingsService } from '@/services/SettingsService';\nimport { AdminService } from '@/services/AdminService';\nimport { RecordService } from '@/services/RecordService';\nimport { CollectionService } from '@/services/CollectionService';\nimport { LogService } from '@/services/LogService';\nimport { RealtimeService } from '@/services/RealtimeService';\nimport { HealthService } from '@/services/HealthService';\nimport { FileService } from '@/services/FileService';\nimport { BackupService } from '@/services/BackupService';\nimport { SendOptions, FileOptions } from '@/services/utils/options';\n\n// list of known SendOptions keys (everything else is treated as query param)\nconst knownSendOptionsKeys = [\n 'requestKey',\n '$cancelKey',\n '$autoCancel',\n 'fetch',\n 'headers',\n 'body',\n 'query',\n 'params',\n // ---,\n 'cache',\n 'credentials',\n 'headers',\n 'integrity',\n 'keepalive',\n 'method',\n 'mode',\n 'redirect',\n 'referrer',\n 'referrerPolicy',\n 'signal',\n 'window',\n];\n\nexport interface BeforeSendResult {\n [key: string]: any, // for backward compatibility\n url?: string,\n options?: {[key: string]: any}\n}\n\n/**\n * PocketBase JS Client.\n */\nexport default class Client {\n /**\n * The base PocketBase backend url address (eg. 'http://127.0.0.1.8090').\n */\n baseUrl: string;\n\n /**\n * Hook that get triggered right before sending the fetch request,\n * allowing you to inspect and modify the url and request options.\n *\n * For list of the possible options check https://developer.mozilla.org/en-US/docs/Web/API/fetch#options\n *\n * You can return a non-empty result object `{ url, options }` to replace the url and request options entirely.\n *\n * Example:\n * ```js\n * client.beforeSend = function (url, options) {\n * options.headers = Object.assign({}, options.headers, {\n * 'X-Custom-Header': 'example',\n * });\n *\n * return { url, options }\n * };\n * ```\n */\n beforeSend?: (url: string, options: SendOptions) => BeforeSendResult|Promise;\n\n /**\n * Hook that get triggered after successfully sending the fetch request,\n * allowing you to inspect/modify the response object and its parsed data.\n *\n * Returns the new Promise resolved `data` that will be returned to the client.\n *\n * Example:\n * ```js\n * client.afterSend = function (response, data) {\n * if (response.status != 200) {\n * throw new ClientResponseError({\n * url: response.url,\n * status: response.status,\n * data: data,\n * });\n * }\n *\n * return data;\n * };\n * ```\n */\n afterSend?: (response: Response, data: any) => any;\n\n /**\n * Optional language code (default to `en-US`) that will be sent\n * with the requests to the server as `Accept-Language` header.\n */\n lang: string;\n\n /**\n * A replaceable instance of the local auth store service.\n */\n authStore: BaseAuthStore;\n\n /**\n * An instance of the service that handles the **Settings APIs**.\n */\n readonly settings: SettingsService;\n\n /**\n * An instance of the service that handles the **Admin APIs**.\n */\n readonly admins: AdminService;\n\n /**\n * An instance of the service that handles the **Collection APIs**.\n */\n readonly collections: CollectionService;\n\n /**\n * An instance of the service that handles the **File APIs**.\n */\n readonly files: FileService;\n\n /**\n * An instance of the service that handles the **Log APIs**.\n */\n readonly logs: LogService;\n\n /**\n * An instance of the service that handles the **Realtime APIs**.\n */\n readonly realtime: RealtimeService;\n\n /**\n * An instance of the service that handles the **Health APIs**.\n */\n readonly health: HealthService;\n\n /**\n * An instance of the service that handles the **Backup APIs**.\n */\n readonly backups: BackupService;\n\n private cancelControllers: { [key: string]: AbortController } = {};\n private recordServices: { [key: string]: RecordService } = {};\n private enableAutoCancellation: boolean = true;\n\n constructor(\n baseUrl = '/',\n authStore?: BaseAuthStore | null,\n lang = 'en-US',\n ) {\n this.baseUrl = baseUrl;\n this.lang = lang;\n this.authStore = authStore || new LocalAuthStore();\n\n // services\n this.admins = new AdminService(this);\n this.collections = new CollectionService(this);\n this.files = new FileService(this);\n this.logs = new LogService(this);\n this.settings = new SettingsService(this);\n this.realtime = new RealtimeService(this);\n this.health = new HealthService(this);\n this.backups = new BackupService(this);\n }\n\n /**\n * Returns the RecordService associated to the specified collection.\n *\n * @param {string} idOrName\n * @return {RecordService}\n */\n collection(idOrName: string): RecordService {\n if (!this.recordServices[idOrName]) {\n this.recordServices[idOrName] = new RecordService(this, idOrName);\n }\n\n return this.recordServices[idOrName];\n }\n\n /**\n * Globally enable or disable auto cancellation for pending duplicated requests.\n */\n autoCancellation(enable: boolean): Client {\n this.enableAutoCancellation = !!enable;\n\n return this;\n }\n\n /**\n * Cancels single request by its cancellation key.\n */\n cancelRequest(requestKey: string): Client {\n if (this.cancelControllers[requestKey]) {\n this.cancelControllers[requestKey].abort();\n delete this.cancelControllers[requestKey];\n }\n\n return this;\n }\n\n /**\n * Cancels all pending requests.\n */\n cancelAllRequests(): Client {\n for (let k in this.cancelControllers) {\n this.cancelControllers[k].abort();\n }\n\n this.cancelControllers = {};\n\n return this;\n }\n\n /**\n * Legacy alias of `pb.files.getUrl()`.\n */\n getFileUrl(\n record: {[key:string]:any},\n filename: string,\n queryParams: FileOptions = {}\n ): string {\n return this.files.getUrl(record, filename, queryParams);\n }\n\n /**\n * Builds a full client url by safely concatenating the provided path.\n */\n buildUrl(path: string): string {\n let url = this.baseUrl;\n\n // construct an absolute base url if in a browser environment\n if (\n typeof window !== 'undefined' &&\n !!window.location &&\n !url.startsWith('https://') &&\n !url.startsWith('http://')\n ) {\n url = window.location.origin?.endsWith('/') ?\n window.location.origin.substring(0, window.location.origin.length - 1) :\n (window.location.origin || '');\n\n if (!this.baseUrl.startsWith('/')) {\n url += window.location.pathname || '/';\n url += url.endsWith('/') ? '' : '/';\n }\n\n url += this.baseUrl;\n }\n\n // concatenate the path\n if (path) {\n url += url.endsWith('/') ? '' : '/'; // append trailing slash if missing\n url += path.startsWith('/') ? path.substring(1) : path;\n }\n\n return url;\n }\n\n /**\n * Sends an api http request.\n */\n async send(path: string, options: SendOptions): Promise {\n options = this.initSendOptions(path, options);\n\n // build url + path\n let url = this.buildUrl(path);\n\n // serialize the query parameters\n if (typeof options.query !== 'undefined') {\n const query = this.serializeQueryParams(options.query)\n if (query) {\n url += (url.includes('?') ? '&' : '?') + query;\n }\n delete options.query;\n }\n\n if (this.beforeSend) {\n const result = Object.assign({}, await this.beforeSend(url, options));\n if (typeof result.url !== 'undefined' || typeof result.options !== 'undefined') {\n url = result.url || url;\n options = result.options || options;\n } else if (Object.keys(result).length) {\n // legacy behavior\n options = result as SendOptions;\n console?.warn && console.warn('Deprecated format of beforeSend return: please use `return { url, options }`, instead of `return options`.');\n }\n }\n\n // ensures that the json body is serialized\n if (\n this.getHeader(options.headers, 'Content-Type') == 'application/json' &&\n options.body && typeof options.body !== 'string'\n ) {\n options.body = JSON.stringify(options.body);\n }\n\n const fetchFunc = options.fetch || fetch;\n\n // send the request\n return fetchFunc(url, options)\n .then(async (response) => {\n let data : any = {};\n\n try {\n data = await response.json();\n } catch (_) {\n // all api responses are expected to return json\n // with the exception of the realtime event and 204\n }\n\n if (this.afterSend) {\n data = await this.afterSend(response, data);\n }\n\n if (response.status >= 400) {\n throw new ClientResponseError({\n url: response.url,\n status: response.status,\n data: data,\n });\n }\n\n return data as T;\n }).catch((err) => {\n // wrap to normalize all errors\n throw new ClientResponseError(err);\n });\n }\n\n /**\n * Shallow copy the provided object and takes care to initialize\n * any options required to preserve the backward compatability.\n *\n * @param {SendOptions} options\n * @return {SendOptions}\n */\n private initSendOptions(path: string, options: SendOptions): SendOptions {\n options = Object.assign({ method: 'GET' } as SendOptions, options)\n options.query = options.query || {};\n\n // auto convert the body to FormData, if needed\n options.body = this.convertToFormDataIfNeeded(options.body);\n\n // move unknown send options as query parameters\n for (let key in options) {\n if (knownSendOptionsKeys.includes(key)) {\n continue\n }\n\n options.query[key] = options[key];\n delete (options[key]);\n }\n\n // requestKey normalizations for backward-compatibility\n // ---\n options.query = Object.assign({}, options.params, options.query);\n if (typeof options.requestKey === 'undefined') {\n if (options.$autoCancel === false || options.query.$autoCancel === false) {\n options.requestKey = null;\n } else if (options.$cancelKey || options.query.$cancelKey) {\n options.requestKey = options.$cancelKey || options.query.$cancelKey;\n }\n }\n // remove the deprecated special cancellation params from the other query params\n delete options.$autoCancel;\n delete options.query.$autoCancel;\n delete options.$cancelKey;\n delete options.query.$cancelKey;\n // ---\n\n // add the json header, if not explicitly set\n // (for FormData body the Content-Type header should be skipped since the boundary is autogenerated)\n if (\n this.getHeader(options.headers, 'Content-Type') === null &&\n !this.isFormData(options.body)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Content-Type': 'application/json',\n });\n }\n\n // add Accept-Language header, if not explicitly set\n if (this.getHeader(options.headers, 'Accept-Language') === null) {\n options.headers = Object.assign({}, options.headers, {\n 'Accept-Language': this.lang,\n });\n }\n\n // check if Authorization header can be added\n if (\n // has valid token\n this.authStore.token &&\n // auth header is not explicitly set\n (this.getHeader(options.headers, 'Authorization') === null)\n ) {\n options.headers = Object.assign({}, options.headers, {\n 'Authorization': this.authStore.token,\n });\n }\n\n // handle auto cancelation for duplicated pending request\n if (this.enableAutoCancellation && options.requestKey !== null) {\n const requestKey = options.requestKey || ((options.method || 'GET') + path);\n\n delete options.requestKey;\n\n // cancel previous pending requests\n this.cancelRequest(requestKey);\n\n const controller = new AbortController();\n this.cancelControllers[requestKey] = controller;\n options.signal = controller.signal;\n }\n\n return options\n }\n\n /**\n * Converts analyzes the provided body and converts it to FormData\n * in case a plain object with File/Blob values is used.\n */\n private convertToFormDataIfNeeded(body: any): any {\n if (\n typeof FormData === 'undefined' ||\n typeof body === \"undefined\" ||\n typeof body !== \"object\" ||\n body === null ||\n this.isFormData(body) ||\n !this.hasBlobField(body)\n ) {\n return body;\n }\n\n const form = new FormData();\n\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let val of values) {\n form.append(key, val);\n }\n }\n\n return form;\n }\n\n /**\n * Checks if the submitted body object has at least one Blob/File field.\n */\n private hasBlobField(body: {[key:string]: any}): boolean {\n for (let key in body) {\n const values = Array.isArray(body[key]) ? body[key] : [body[key]];\n for (let v of values) {\n if (\n (typeof Blob !== 'undefined' && v instanceof Blob) ||\n (typeof File !== 'undefined' && v instanceof File)\n ) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /**\n * Extracts the header with the provided name in case-insensitive manner.\n * Returns `null` if no header matching the name is found.\n */\n private getHeader(headers: {[key:string]:string}|undefined, name: string): string|null {\n headers = headers || {};\n name = name.toLowerCase();\n\n for (let key in headers) {\n if (key.toLowerCase() == name) {\n return headers[key];\n }\n }\n\n return null;\n }\n\n /**\n * Loosely checks if the specified body is a FormData instance.\n */\n private isFormData(body: any): boolean {\n return body && (\n // we are checking the constructor name because FormData\n // is not available natively in some environments and the\n // polyfill(s) may not be globally accessible\n body.constructor.name === 'FormData' ||\n // fallback to global FormData instance check\n // note: this is needed because the constructor.name could be different in case of\n // custom global FormData implementation, eg. React Native on Android/iOS\n (typeof FormData !== 'undefined' && body instanceof FormData)\n )\n }\n\n /**\n * Serializes the provided query parameters into a query string.\n */\n private serializeQueryParams(params: {[key: string]: any}): string {\n const result: Array = [];\n for (const key in params) {\n if (params[key] === null) {\n // skip null query params\n continue;\n }\n\n const value = params[key];\n const encodedKey = encodeURIComponent(key);\n\n if (Array.isArray(value)) {\n // repeat array params\n for (const v of value) {\n result.push(encodedKey + '=' + encodeURIComponent(v));\n }\n } else if (value instanceof Date) {\n result.push(encodedKey + '=' + encodeURIComponent(value.toISOString()));\n } else if (typeof value !== null && typeof value === 'object') {\n result.push(encodedKey + '=' + encodeURIComponent(JSON.stringify(value)));\n } else {\n result.push(encodedKey + '=' + encodeURIComponent(value));\n }\n }\n\n return result.join('&');\n }\n}\n"],"names":["ClientResponseError","Error","constructor","errData","super","this","url","status","response","isAbort","originalError","Object","setPrototypeOf","prototype","data","DOMException","name","message","_a","_d","_c","_b","cause","includes","toJSON","assign","fieldContentRegExp","cookieSerialize","val","options","opt","encode","defaultEncode","test","TypeError","value","result","maxAge","isNaN","isFinite","Math","floor","domain","path","expires","isDate","toString","call","Date","valueOf","toUTCString","httpOnly","secure","priority","toLowerCase","sameSite","defaultDecode","indexOf","decodeURIComponent","encodeURIComponent","atobPolyfill","getTokenPayload","token","encodedPayload","split","map","c","charCodeAt","slice","join","JSON","parse","e","atob","input","str","String","replace","length","bs","buffer","bc","idx","output","charAt","fromCharCode","defaultCookieKey","BaseAuthStore","baseToken","baseModel","_onChangeCallbacks","model","isValid","isTokenExpired","expirationThreshold","payload","keys","exp","now","isAdmin","type","isAuthRecord","save","triggerChange","clear","loadFromCookie","cookie","key","rawData","cookieParse","decode","index","eqIdx","endIdx","lastIndexOf","trim","undefined","_","Array","isArray","exportToCookie","defaultOptions","stringify","resultLength","Blob","size","id","email","extraProps","prop","onChange","callback","fireImmediately","push","i","splice","LocalAuthStore","storageKey","storageFallback","_bindStorageEvent","_storageGet","_storageSet","_storageRemove","window","localStorage","rawValue","getItem","normalizedVal","setItem","removeItem","addEventListener","BaseService","client","SettingsService","getAll","method","send","update","bodyParams","body","testS3","filesystem","then","testEmail","toEmail","emailTemplate","template","generateAppleClientSecret","clientId","teamId","keyId","privateKey","duration","CrudService","getFullList","batchOrqueryParams","_getFullList","batch","getList","page","perPage","query","baseCrudPath","responseData","items","item","getFirstListItem","filter","requestKey","skipTotal","code","getOne","create","batchSize","request","__awaiter","list","concat","normalizeLegacyOptionsArgs","legacyWarn","baseOptions","bodyOrOptions","hasQuery","console","warn","AdminService","authStore","collectionId","delete","success","authResponse","admin","authWithPassword","password","identity","bind","authRefresh","requestPasswordReset","confirmPasswordReset","resetToken","passwordConfirm","RealtimeService","eventSource","subscriptions","lastSentTopics","maxConnectTimeout","reconnectAttempts","maxReconnectAttempts","Infinity","predefinedReconnectIntervals","pendingConnects","isConnected","subscribe","topic","listener","msgEvent","submitSubscriptions","connect","unsubscribeByTopicAndListener","unsubscribe","hasSubscriptionListeners","removeEventListener","disconnect","unsubscribeByPrefix","topicPrefix","hasAtleastOneTopic","startsWith","exist","topicToCheck","addAllSubscriptionListeners","getNonEmptySubscriptionTopics","getSubscriptionsCancelKey","catch","err","removeAllSubscriptionListeners","Promise","resolve","reject","initConnect","clearTimeout","connectTimeoutId","setTimeout","connectErrorHandler","EventSource","buildUrl","onerror","lastEventId","retries","hasUnsentSubscriptions","p","reconnectTimeoutId","latestTopics","t","timeout","fromReconnect","cancelRequest","close","RecordService","collectionIdOrName","baseCollectionPath","subscribeOne","recordId","realtime","topicOrCallback","batchOrOptions","params","collectionName","record","listAuthMethods","usernamePassword","emailPassword","authProviders","usernameOrEmail","authWithOAuth2Code","provider","codeVerifier","redirectUrl","createData","authWithOAuth2","args","config","find","eagerDefaultPopup","cleanup","urlCallback","openBrowserPopup","oldState","state","scopes","authData","replacements","_replaceQueryParams","authUrl","location","href","passwordResetToken","requestVerification","confirmVerification","verificationToken","requestEmailChange","newEmail","confirmEmailChange","emailChangeToken","listExternalAuths","unlinkExternalAuth","urlPath","substring","parsedParams","rawParams","param","pair","hasOwnProperty","open","width","height","windowWidth","innerWidth","windowHeight","innerHeight","left","top","CollectionService","import","collections","deleteMissing","LogService","getRequestsList","getRequest","getRequestsStats","HealthService","check","FileService","getUrl","filename","queryParams","parts","download","URLSearchParams","getToken","BackupService","basename","restore","getDownloadUrl","knownSendOptionsKeys","Client","baseUrl","lang","cancelControllers","recordServices","enableAutoCancellation","admins","files","logs","settings","health","backups","collection","idOrName","autoCancellation","enable","abort","cancelAllRequests","k","getFileUrl","origin","endsWith","pathname","initSendOptions","serializeQueryParams","beforeSend","getHeader","headers","fetch","json","afterSend","convertToFormDataIfNeeded","$autoCancel","$cancelKey","isFormData","Authorization","controller","AbortController","signal","FormData","hasBlobField","form","values","append","v","File","encodedKey","toISOString"],"mappings":"uoBAIM,MAAOA,4BAA4BC,MAOrC,WAAAC,CAAYC,eACRC,MAAM,uBAPVC,KAAGC,IAA8B,GACjCD,KAAME,OAA2B,EACjCF,KAAQG,SAAyB,GACjCH,KAAOI,SAA0B,EACjCJ,K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oBAAT6R,MAAwBD,aAAaC,KAE7C,OAAO,CAGlB,CAED,OAAO,CACV,CAMO,SAAAnB,CAAUC,EAA0CvX,GACxDuX,EAAUA,GAAW,GACrBvX,EAAOA,EAAKsC,cAEZ,IAAK,IAAIqD,KAAO4R,EACZ,GAAI5R,EAAIrD,eAAiBtC,EACrB,OAAOuX,EAAQ5R,GAIvB,OAAO,IACV,CAKO,UAAAmS,CAAW/O,GACf,OAAOA,IAIuB,aAA1BA,EAAK7J,YAAYc,MAII,oBAAbmY,UAA4BpP,aAAgBoP,SAE3D,CAKO,oBAAAf,CAAqBvG,GACzB,MAAMzP,EAAwB,GAC9B,IAAK,MAAMuE,KAAOkL,EAAQ,CACtB,GAAoB,OAAhBA,EAAOlL,GAEP,SAGJ,MAAMxE,EAAQ0P,EAAOlL,GACf+S,EAAa/V,mBAAmBgD,GAEtC,GAAIW,MAAMC,QAAQpF,GAEd,IAAK,MAAMqX,KAAKrX,EACZC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmB6V,SAE/CrX,aAAiBa,KACxBZ,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBxB,EAAMwX,gBAChC,cAAVxX,GAAmC,iBAAVA,EACvCC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBW,KAAKoD,UAAUvF,KAEjEC,EAAOiG,KAAKqR,EAAa,IAAM/V,mBAAmBxB,GAEzD,CAED,OAAOC,EAAOiC,KAAK,IACtB"} \ No newline at end of file diff --git a/package.json b/package.json index 0b23e84..492f48e 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.17.2", + "version": "0.17.3", "name": "pocketbase", "description": "PocketBase JavaScript SDK", "author": "Gani Georgiev",