UNPKG

pocketbase-js

Version:
1 lines 126 kB
{"version":3,"file":"pocketbase.es.mjs","sources":["../node_modules/tslib/tslib.es6.js","../src/ClientResponseError.ts","../src/stores/utils/jwt.ts","../src/stores/utils/cookie.ts","../src/models/utils/BaseModel.ts","../src/models/Record.ts","../src/models/User.ts","../src/models/Admin.ts","../src/stores/BaseAuthStore.ts","../src/stores/LocalAuthStore.ts","../src/services/utils/BaseService.ts","../src/services/Settings.ts","../src/models/utils/ListResult.ts","../src/services/utils/BaseCrudService.ts","../src/services/utils/CrudService.ts","../src/services/Admins.ts","../src/models/ExternalAuth.ts","../src/services/Users.ts","../src/models/utils/SchemaField.ts","../src/models/Collection.ts","../src/services/Collections.ts","../src/services/Records.ts","../src/services/utils/SubCrudService.ts","../src/models/LogRequest.ts","../src/services/Logs.ts","../src/services/Realtime.ts","../src/Client.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\r\n * ClientResponseError is a custom Error class that is intended to wrap\r\n * and normalize any error thrown by `Client.send()`.\r\n */\r\nexport default class ClientResponseError extends Error {\r\n url: string = '';\r\n status: number = 0;\r\n data: {[key: string]: any} = {};\r\n isAbort: boolean = false;\r\n originalError: any = null;\r\n\r\n constructor(errData?: any) {\r\n super(\"ClientResponseError\");\r\n\r\n // Set the prototype explicitly.\r\n // https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\r\n Object.setPrototypeOf(this, ClientResponseError.prototype);\r\n\r\n if (!(errData instanceof ClientResponseError)) {\r\n this.originalError = errData;\r\n }\r\n\r\n if (errData !== null && typeof errData === 'object') {\r\n this.url = typeof errData.url === 'string' ? errData.url : '';\r\n this.status = typeof errData.status === 'number' ? errData.status : 0;\r\n this.data = errData.data !== null && typeof errData.data === 'object' ? errData.data : {};\r\n }\r\n\r\n if (typeof DOMException !== 'undefined' && errData instanceof DOMException) {\r\n this.isAbort = true;\r\n }\r\n\r\n this.name = \"ClientResponseError \" + this.status;\r\n this.message = this.data?.message || 'Something went wrong while processing your request.'\r\n }\r\n\r\n // Make a POJO's copy of the current error class instance.\r\n // @see https://github.com/vuex-orm/vuex-orm/issues/255\r\n toJSON () {\r\n return { ...this };\r\n }\r\n}\r\n","let atobPolyfill: Function;\r\nif (typeof atob === 'function') {\r\n atobPolyfill = atob\r\n} else {\r\n /**\r\n * The code was extracted from:\r\n * https://github.com/davidchambers/Base64.js\r\n */\r\n atobPolyfill = (input: any) => {\r\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\r\n\r\n let str = String(input).replace(/=+$/, \"\");\r\n if (str.length % 4 == 1) {\r\n throw new Error(\"'atob' failed: The string to be decoded is not correctly encoded.\");\r\n }\r\n\r\n for (\r\n // initialize result and counters\r\n var bc = 0, bs, buffer, idx = 0, output = \"\";\r\n // get next character\r\n (buffer = str.charAt(idx++));\r\n // character found in table? initialize bit storage and add its ascii value;\r\n ~buffer &&\r\n ((bs = bc % 4 ? (bs as any) * 64 + buffer : buffer),\r\n // and if not first of each 4 characters,\r\n // convert the first 8 bits to one ascii character\r\n bc++ % 4) ?\r\n (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)))) :\r\n 0\r\n ) {\r\n // try to find character in table (0-63, not found => -1)\r\n buffer = chars.indexOf(buffer);\r\n }\r\n\r\n return output;\r\n };\r\n}\r\n\r\n/**\r\n * Returns JWT token's payload data.\r\n */\r\nexport function getTokenPayload(token: string): { [key: string]: any } {\r\n if (token) {\r\n try {\r\n\r\n let base64 = decodeURIComponent(atobPolyfill(token.split('.')[1]).split('').map(function (c: string) {\r\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\r\n }).join(''));\r\n\r\n return JSON.parse(base64) || {};\r\n } catch (e) {\r\n }\r\n }\r\n\r\n return {};\r\n}\r\n\r\n/**\r\n * Checks whether a JWT token is expired or not.\r\n * Tokens without `exp` payload key are considered valid.\r\n * Tokens with empty payload (eg. invalid token strings) are considered expired.\r\n *\r\n * @param token The token to check.\r\n * @param [expirationThreshold] Time in seconds that will be subtracted from the token `exp` property.\r\n */\r\nexport function isTokenExpired(token: string, expirationThreshold = 0): boolean {\r\n let payload = getTokenPayload(token);\r\n\r\n if (\r\n Object.keys(payload).length > 0 &&\r\n (!payload.exp || (payload.exp - expirationThreshold) > (Date.now() / 1000))\r\n ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n}\r\n","/**\r\n * -------------------------------------------------------------------\r\n * Simple cookie parse and serialize utilities mostly based on the\r\n * node module https://github.com/jshttp/cookie.\r\n * -------------------------------------------------------------------\r\n */\r\n\r\n/**\r\n * RegExp to match field-content in RFC 7230 sec 3.2\r\n *\r\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\r\n * field-vchar = VCHAR / obs-text\r\n * obs-text = %x80-FF\r\n */\r\nconst fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;\r\n\r\nexport interface ParseOptions{\r\n decode?: (val: string) => string,\r\n}\r\n\r\n/**\r\n* Parses the given cookie header string into an object\r\n* The object has the various cookies as keys(names) => values\r\n*/\r\nexport function cookieParse(str: string, options?: ParseOptions): { [key: string]: any } {\r\n const result: { [key: string]: any } = {};\r\n\r\n if (typeof str !== 'string') {\r\n return result;\r\n }\r\n\r\n const opt = Object.assign({}, options || {});\r\n const decode = opt.decode || defaultDecode;\r\n\r\n let index = 0;\r\n while (index < str.length) {\r\n const eqIdx = str.indexOf('=', index);\r\n\r\n // no more cookie pairs\r\n if (eqIdx === -1) {\r\n break;\r\n }\r\n\r\n let endIdx = str.indexOf(';', index);\r\n\r\n if (endIdx === -1) {\r\n endIdx = str.length;\r\n } else if (endIdx < eqIdx) {\r\n // backtrack on prior semicolon\r\n index = str.lastIndexOf(';', eqIdx - 1) + 1;\r\n continue;\r\n }\r\n\r\n const key = str.slice(index, eqIdx).trim();\r\n\r\n // only assign once\r\n if (undefined === result[key]) {\r\n let val = str.slice(eqIdx + 1, endIdx).trim();\r\n\r\n // quoted values\r\n if (val.charCodeAt(0) === 0x22) {\r\n val = val.slice(1, -1);\r\n }\r\n\r\n try {\r\n result[key] = decode(val);\r\n } catch (_) {\r\n result[key] = val; // no decoding\r\n }\r\n }\r\n\r\n index = endIdx + 1;\r\n }\r\n\r\n return result;\r\n};\r\n\r\nexport interface SerializeOptions{\r\n encode?: (val: string | number | boolean) => string,\r\n maxAge?: number,\r\n domain?: string,\r\n path?: string,\r\n expires?: Date,\r\n httpOnly?: boolean,\r\n secure?: boolean,\r\n priority?: string,\r\n sameSite?: boolean|string,\r\n}\r\n\r\n/**\r\n * Serialize data into a cookie header.\r\n *\r\n * Serialize the a name value pair into a cookie string suitable for\r\n * http headers. An optional options object specified cookie parameters.\r\n *\r\n * ```js\r\n * cookieSerialize('foo', 'bar', { httpOnly: true }) // \"foo=bar; httpOnly\"\r\n * ```\r\n */\r\nexport function cookieSerialize(name: string, val: string, options?: SerializeOptions): string {\r\n const opt = Object.assign({}, options || {});\r\n const encode = opt.encode || defaultEncode;\r\n\r\n if (!fieldContentRegExp.test(name)) {\r\n throw new TypeError('argument name is invalid');\r\n }\r\n\r\n const value = encode(val);\r\n\r\n if (value && !fieldContentRegExp.test(value)) {\r\n throw new TypeError('argument val is invalid');\r\n }\r\n\r\n let result = name + '=' + value;\r\n\r\n if (opt.maxAge != null) {\r\n const maxAge = opt.maxAge - 0;\r\n\r\n if (isNaN(maxAge) || !isFinite(maxAge)) {\r\n throw new TypeError('option maxAge is invalid');\r\n }\r\n\r\n result += '; Max-Age=' + Math.floor(maxAge);\r\n }\r\n\r\n if (opt.domain) {\r\n if (!fieldContentRegExp.test(opt.domain)) {\r\n throw new TypeError('option domain is invalid');\r\n }\r\n\r\n result += '; Domain=' + opt.domain;\r\n }\r\n\r\n if (opt.path) {\r\n if (!fieldContentRegExp.test(opt.path)) {\r\n throw new TypeError('option path is invalid');\r\n }\r\n\r\n result += '; Path=' + opt.path;\r\n }\r\n\r\n if (opt.expires) {\r\n if (!isDate(opt.expires) || isNaN(opt.expires.valueOf())) {\r\n throw new TypeError('option expires is invalid');\r\n }\r\n\r\n result += '; Expires=' + opt.expires.toUTCString();\r\n }\r\n\r\n if (opt.httpOnly) {\r\n result += '; HttpOnly';\r\n }\r\n\r\n if (opt.secure) {\r\n result += '; Secure';\r\n }\r\n\r\n if (opt.priority) {\r\n const priority = typeof opt.priority === 'string' ? opt.priority.toLowerCase() : opt.priority;\r\n\r\n switch (priority) {\r\n case 'low':\r\n result += '; Priority=Low';\r\n break;\r\n case 'medium':\r\n result += '; Priority=Medium';\r\n break;\r\n case 'high':\r\n result += '; Priority=High';\r\n break;\r\n default:\r\n throw new TypeError('option priority is invalid');\r\n }\r\n }\r\n\r\n if (opt.sameSite) {\r\n const sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;\r\n\r\n switch (sameSite) {\r\n case true:\r\n result += '; SameSite=Strict';\r\n break;\r\n case 'lax':\r\n result += '; SameSite=Lax';\r\n break;\r\n case 'strict':\r\n result += '; SameSite=Strict';\r\n break;\r\n case 'none':\r\n result += '; SameSite=None';\r\n break;\r\n default:\r\n throw new TypeError('option sameSite is invalid');\r\n }\r\n }\r\n\r\n return result;\r\n};\r\n\r\n/**\r\n * Default URL-decode string value function.\r\n * Optimized to skip native call when no `%`.\r\n */\r\nfunction defaultDecode(val: string): string {\r\n return val.indexOf('%') !== -1\r\n ? decodeURIComponent(val)\r\n : val;\r\n}\r\n\r\n/**\r\n * Default URL-encode value function.\r\n */\r\nfunction defaultEncode(val: string | number | boolean): string {\r\n return encodeURIComponent(val);\r\n}\r\n\r\n/**\r\n * Determines if value is a Date.\r\n */\r\nfunction isDate(val: any): boolean {\r\n return (\r\n Object.prototype.toString.call(val) === '[object Date]' ||\r\n val instanceof Date\r\n );\r\n}\r\n","export default abstract class BaseModel {\r\n id!: string;\r\n created!: string;\r\n updated!: string;\r\n\r\n constructor(data: { [key: string]: any } = {}) {\r\n this.load(data || {});\r\n }\r\n\r\n /**\r\n * Loads `data` into the current model.\r\n */\r\n load(data: { [key: string]: any }) {\r\n this.id = typeof data.id !== 'undefined' ? data.id : '';\r\n this.created = typeof data.created !== 'undefined' ? data.created : '';\r\n this.updated = typeof data.updated !== 'undefined' ? data.updated : '';\r\n }\r\n\r\n /**\r\n * Returns whether the current loaded data represent a stored db record.\r\n */\r\n get isNew(): boolean {\r\n return (\r\n // id is not set\r\n !this.id ||\r\n // zero uuid value\r\n this.id === '00000000-0000-0000-0000-000000000000'\r\n );\r\n }\r\n\r\n /**\r\n * Robust deep clone of a model.\r\n */\r\n clone(): BaseModel {\r\n return new (this.constructor as any)(JSON.parse(JSON.stringify(this)));\r\n }\r\n\r\n /**\r\n * Exports all model properties as a new plain object.\r\n */\r\n export(): { [key: string]: any } {\r\n return Object.assign({}, this);\r\n }\r\n}\r\n","import BaseModel from '@/models/utils/BaseModel';\r\n\r\nexport default class Record extends BaseModel {\r\n [key: string]: any,\r\n\r\n '@collectionId'!: string;\r\n '@collectionName'!: string;\r\n '@expand'!: {[key: string]: any};\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n load(data: { [key: string]: any }) {\r\n super.load(data);\r\n\r\n for (const [key, value] of Object.entries(data)) {\r\n this[key] = value;\r\n }\r\n\r\n // normalize common fields\r\n this['@collectionId'] = typeof data['@collectionId'] !== 'undefined' ? data['@collectionId'] : '';\r\n this['@collectionName'] = typeof data['@collectionName'] !== 'undefined' ? data['@collectionName'] : '';\r\n this['@expand'] = typeof data['@expand'] !== 'undefined' ? data['@expand'] : {};\r\n }\r\n}\r\n","import BaseModel from '@/models/utils/BaseModel';\r\nimport Record from '@/models/Record';\r\n\r\nexport default class User extends BaseModel {\r\n email!: string;\r\n verified!: boolean;\r\n lastResetSentAt!: string;\r\n lastVerificationSentAt!: string;\r\n profile!: null|Record;\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n load(data: { [key: string]: any }) {\r\n super.load(data);\r\n\r\n this.email = typeof data.email === 'string' ? data.email : '';\r\n this.verified = !!data.verified;\r\n this.lastResetSentAt = typeof data.lastResetSentAt === 'string' ? data.lastResetSentAt : '';\r\n this.lastVerificationSentAt = typeof data.lastVerificationSentAt === 'string' ? data.lastVerificationSentAt : '';\r\n this.profile = data.profile ? new Record(data.profile) : null;\r\n }\r\n}\r\n","import BaseModel from '@/models/utils/BaseModel';\r\n\r\nexport default class Admin extends BaseModel {\r\n avatar!: number;\r\n email!: string;\r\n lastResetSentAt!: string;\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n load(data: { [key: string]: any }) {\r\n super.load(data);\r\n\r\n this.avatar = typeof data.avatar === 'number' ? data.avatar : 0;\r\n this.email = typeof data.email === 'string' ? data.email : '';\r\n this.lastResetSentAt = typeof data.lastResetSentAt === 'string' ? data.lastResetSentAt : '';\r\n }\r\n}\r\n","import { cookieParse, cookieSerialize, SerializeOptions } from '@/stores/utils/cookie';\r\nimport { isTokenExpired, getTokenPayload } from '@/stores/utils/jwt';\r\nimport User from '@/models/User';\r\nimport Admin from '@/models/Admin';\r\n\r\ntype onChangeFunc = (token: string, model: User|Admin|null) => void;\r\n\r\nconst defaultCookieKey = 'pb_auth';\r\n\r\n/**\r\n * Base AuthStore class that is intended to be extended by all other\r\n * PocketBase AuthStore implementations.\r\n */\r\nexport default abstract class BaseAuthStore {\r\n protected baseToken: string = '';\r\n protected baseModel: User|Admin|null = null;\r\n\r\n private _onChangeCallbacks: Array<onChangeFunc> = [];\r\n\r\n /**\r\n * Retrieves the stored token (if any).\r\n */\r\n get token(): string {\r\n return this.baseToken;\r\n }\r\n\r\n /**\r\n * Retrieves the stored model data (if any).\r\n */\r\n get model(): User|Admin|null {\r\n return this.baseModel;\r\n }\r\n\r\n /**\r\n * Checks if the store has valid (aka. existing and unexpired) token.\r\n */\r\n get isValid(): boolean {\r\n return !isTokenExpired(this.token);\r\n }\r\n\r\n /**\r\n * Saves the provided new token and model data in the auth store.\r\n */\r\n save(token: string, model: User|Admin|null): void {\r\n this.baseToken = token || '';\r\n\r\n // normalize the model instance\r\n if (model !== null && typeof model === 'object') {\r\n this.baseModel = (model as any)?.verified !== 'undefined' ?\r\n new User(model) : new Admin(model);\r\n } else {\r\n this.baseModel = null;\r\n }\r\n\r\n this.triggerChange();\r\n }\r\n\r\n /**\r\n * Removes the stored token and model data form the auth store.\r\n */\r\n clear(): void {\r\n this.baseToken = '';\r\n this.baseModel = null;\r\n this.triggerChange();\r\n }\r\n\r\n /**\r\n * Parses the provided cookie string and updates the store state\r\n * with the cookie's token and model data.\r\n */\r\n loadFromCookie(cookie: string, key = defaultCookieKey): void {\r\n const rawData = cookieParse(cookie || '')[key] || '';\r\n\r\n let data: { [key: string]: any } = {};\r\n try {\r\n data = JSON.parse(rawData);\r\n // normalize\r\n if (typeof data === null || typeof data !== 'object' || Array.isArray(data)) {\r\n data = {};\r\n }\r\n } catch (_) {}\r\n\r\n this.save(data.token || '', data.model || {});\r\n }\r\n\r\n /**\r\n * Exports the current store state as cookie string.\r\n *\r\n * By default the following optional attributes are added:\r\n * - Secure\r\n * - HttpOnly\r\n * - SameSite=Strict\r\n * - Path=/\r\n * - Expires={the token expiration date}\r\n *\r\n * NB! If the generated cookie exceeds 4096 bytes, this method will\r\n * strip the model data to the bare minimum to try to fit within the\r\n * recommended size in https://www.rfc-editor.org/rfc/rfc6265#section-6.1.\r\n */\r\n exportToCookie(options?: SerializeOptions, key = defaultCookieKey): string {\r\n const defaultOptions: SerializeOptions = {\r\n secure: true,\r\n sameSite: true,\r\n httpOnly: true,\r\n path: \"/\",\r\n };\r\n\r\n // extract the token expiration date\r\n const payload = getTokenPayload(this.token);\r\n if (payload?.exp) {\r\n defaultOptions.expires = new Date(payload.exp * 1000);\r\n } else {\r\n defaultOptions.expires = new Date('1970-01-01');\r\n }\r\n\r\n // merge with the user defined options\r\n options = Object.assign({}, defaultOptions, options);\r\n\r\n const rawData = {\r\n token: this.token,\r\n model: this.model?.export() || null,\r\n };\r\n\r\n let result = cookieSerialize(key, JSON.stringify(rawData), options);\r\n\r\n const resultLength = typeof Blob !== 'undefined' ?\r\n (new Blob([result])).size : result.length;\r\n\r\n // strip down the model data to the bare minimum\r\n if (rawData.model && resultLength > 4096) {\r\n rawData.model = {id: rawData?.model?.id, email: rawData?.model?.email};\r\n if (this.model instanceof User) {\r\n rawData.model.verified = this.model.verified;\r\n }\r\n result = cookieSerialize(key, JSON.stringify(rawData), options);\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Register a callback function that will be called on store change.\r\n *\r\n * You can set the `fireImmediately` argument to true in order to invoke\r\n * the provided callback right after registration.\r\n *\r\n * Returns a removal function that you could call to \"unsubscribe\" from the changes.\r\n */\r\n onChange(callback: onChangeFunc, fireImmediately = false): () => void {\r\n this._onChangeCallbacks.push(callback);\r\n\r\n if (fireImmediately) {\r\n callback(this.token, this.model);\r\n }\r\n\r\n return () => {\r\n for (let i = this._onChangeCallbacks.length - 1; i >= 0; i--) {\r\n if (this._onChangeCallbacks[i] == callback) {\r\n delete this._onChangeCallbacks[i]; // removes the function reference\r\n this._onChangeCallbacks.splice(i, 1); // reindex the array\r\n return;\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected triggerChange(): void {\r\n for (const callback of this._onChangeCallbacks) {\r\n callback && callback(this.token, this.model);\r\n }\r\n }\r\n}\r\n","import BaseAuthStore from '@/stores/BaseAuthStore';\r\nimport User from '@/models/User';\r\nimport Admin from '@/models/Admin';\r\n\r\n/**\r\n * The default token store for browsers with auto fallback\r\n * to runtime/memory if local storage is undefined (eg. in node env).\r\n */\r\nexport default class LocalAuthStore extends BaseAuthStore {\r\n private storageFallback: { [key: string]: any } = {};\r\n private storageKey: string\r\n\r\n constructor(storageKey = \"pocketbase_auth\") {\r\n super();\r\n\r\n this.storageKey = storageKey;\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n get token(): string {\r\n const data = this._storageGet(this.storageKey) || {};\r\n\r\n return data.token || '';\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n get model(): User|Admin|null {\r\n const data = this._storageGet(this.storageKey) || {};\r\n\r\n if (\r\n data === null ||\r\n typeof data !== 'object' ||\r\n data.model === null ||\r\n typeof data.model !== 'object'\r\n ) {\r\n return null;\r\n }\r\n\r\n // admins don't have `verified` prop\r\n if (typeof data.model?.verified !== 'undefined') {\r\n return new User(data.model);\r\n }\r\n\r\n return new Admin(data.model);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n save(token: string, model: User|Admin|null) {\r\n this._storageSet(this.storageKey, {\r\n 'token': token,\r\n 'model': model,\r\n });\r\n\r\n super.save(token, model);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n clear() {\r\n this._storageRemove(this.storageKey);\r\n\r\n super.clear();\r\n }\r\n\r\n // ---------------------------------------------------------------\r\n // Internal helpers:\r\n // ---------------------------------------------------------------\r\n\r\n /**\r\n * Retrieves `key` from the browser's local storage\r\n * (or runtime/memory if local storage is undefined).\r\n */\r\n private _storageGet(key: string): any {\r\n if (typeof window !== 'undefined' && window?.localStorage) {\r\n const rawValue = window?.localStorage?.getItem(key) || '';\r\n try {\r\n return JSON.parse(rawValue);\r\n } catch (e) { // not a json\r\n return rawValue;\r\n }\r\n }\r\n\r\n // fallback\r\n return this.storageFallback[key];\r\n }\r\n\r\n /**\r\n * Stores a new data in the browser's local storage\r\n * (or runtime/memory if local storage is undefined).\r\n */\r\n private _storageSet(key: string, value: any) {\r\n if (typeof window !== 'undefined' && window?.localStorage) {\r\n // store in local storage\r\n let normalizedVal = value;\r\n if (typeof value !== 'string') {\r\n normalizedVal = JSON.stringify(value);\r\n }\r\n window?.localStorage?.setItem(key, normalizedVal);\r\n } else {\r\n // store in fallback\r\n this.storageFallback[key] = value;\r\n }\r\n }\r\n\r\n /**\r\n * Removes `key` from the browser's local storage and the runtime/memory.\r\n */\r\n private _storageRemove(key: string) {\r\n // delete from local storage\r\n if (typeof window !== 'undefined') {\r\n window?.localStorage?.removeItem(key);\r\n }\r\n\r\n // delete from fallback\r\n delete this.storageFallback[key];\r\n }\r\n}\r\n","import Client from '@/Client';\r\n\r\n/**\r\n * BaseService class that should be inherited from all API services.\r\n */\r\nexport default abstract class BaseService {\r\n readonly client: Client\r\n\r\n constructor(client: Client) {\r\n this.client = client;\r\n }\r\n}\r\n","import BaseService from '@/services/utils/BaseService';\r\n\r\nexport default class Settings extends BaseService {\r\n /**\r\n * Fetch all available app settings.\r\n */\r\n getAll(queryParams = {}): Promise<{ [key: string]: any }> {\r\n return this.client.send('/api/settings', {\r\n 'method': 'GET',\r\n 'params': queryParams,\r\n }).then((responseData) => responseData || {});\r\n }\r\n\r\n /**\r\n * Bulk updates app settings.\r\n */\r\n update(bodyParams = {}, queryParams = {}): Promise<{ [key: string]: any }> {\r\n return this.client.send('/api/settings', {\r\n 'method': 'PATCH',\r\n 'params': queryParams,\r\n 'body': bodyParams,\r\n }).then((responseData) => responseData || {});\r\n }\r\n\r\n /**\r\n * Performs a S3 storage connection test.\r\n */\r\n testS3(queryParams = {}): Promise<boolean> {\r\n return this.client.send('/api/settings/test/s3', {\r\n 'method': 'POST',\r\n 'params': queryParams,\r\n }).then(() => true);\r\n }\r\n\r\n /**\r\n * Sends a test email.\r\n *\r\n * The possible `emailTemplate` values are:\r\n * - verification\r\n * - password-reset\r\n * - email-change\r\n */\r\n testEmail(toEmail: string, emailTemplate: string, queryParams = {}): Promise<boolean> {\r\n const bodyParams = {\r\n 'email': toEmail,\r\n 'template': emailTemplate,\r\n };\r\n\r\n return this.client.send('/api/settings/test/email', {\r\n 'method': 'POST',\r\n 'params': queryParams,\r\n 'body': bodyParams,\r\n }).then(() => true);\r\n }\r\n}\r\n","import BaseModel from './BaseModel';\r\n\r\nexport default class ListResult<M extends BaseModel> {\r\n page!: number;\r\n perPage!: number;\r\n totalItems!: number;\r\n totalPages!: number;\r\n items!: Array<M>;\r\n\r\n constructor(\r\n page: number,\r\n perPage: number,\r\n totalItems: number,\r\n totalPages: number,\r\n items: Array<M>,\r\n ) {\r\n this.page = page > 0 ? page : 1;\r\n this.perPage = perPage >= 0 ? perPage : 0;\r\n this.totalItems = totalItems >= 0 ? totalItems : 0;\r\n this.totalPages = totalPages >= 0 ? totalPages : 0;\r\n this.items = items || [];\r\n }\r\n}\r\n","import BaseModel from '@/models/utils/BaseModel';\r\nimport ListResult from '@/models/utils/ListResult';\r\nimport BaseService from '@/services/utils/BaseService';\r\n\r\nexport default abstract class BaseCrudService<M extends BaseModel> extends BaseService {\r\n /**\r\n * Response data decoder.\r\n */\r\n abstract decode(data: { [key: string]: any }): M\r\n\r\n /**\r\n * Returns a promise with all list items batch fetched at once.\r\n */\r\n protected _getFullList(basePath: string, batchSize = 100, queryParams = {}): Promise<Array<M>> {\r\n var result: Array<M> = [];\r\n\r\n let request = async (page: number): Promise<Array<any>> => {\r\n return this._getList(basePath, page, batchSize, queryParams).then((list) => {\r\n const castedList = (list as ListResult<M>);\r\n const items = castedList.items;\r\n const totalItems = castedList.totalItems;\r\n\r\n result = result.concat(items);\r\n\r\n if (items.length && totalItems > result.length) {\r\n return request(page + 1);\r\n }\r\n\r\n return result;\r\n });\r\n }\r\n\r\n return request(1);\r\n }\r\n\r\n /**\r\n * Returns paginated items list.\r\n */\r\n protected _getList(basePath: string, page = 1, perPage = 30, queryParams = {}): Promise<ListResult<M>> {\r\n queryParams = Object.assign({\r\n 'page': page,\r\n 'perPage': perPage,\r\n }, queryParams);\r\n\r\n return this.client.send(basePath, {\r\n 'method': 'GET',\r\n 'params': queryParams,\r\n }).then((responseData: any) => {\r\n const items: Array<M> = [];\r\n if (responseData?.items) {\r\n responseData.items = responseData.items || [];\r\n for (const item of responseData.items) {\r\n items.push(this.decode(item));\r\n }\r\n }\r\n\r\n return new ListResult<M>(\r\n responseData?.page || 1,\r\n responseData?.perPage || 0,\r\n responseData?.totalItems || 0,\r\n responseData?.totalPages || 0,\r\n items,\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Returns single item by its id.\r\n */\r\n protected _getOne(basePath: string, id: string, queryParams = {}): Promise<M> {\r\n return this.client.send(basePath + '/' + encodeURIComponent(id), {\r\n 'method': 'GET',\r\n 'params': queryParams\r\n }).then((responseData: any) => this.decode(responseData));\r\n }\r\n\r\n /**\r\n * Creates a new item.\r\n */\r\n protected _create(basePath: string, bodyParams = {}, queryParams = {}): Promise<M> {\r\n return this.client.send(basePath, {\r\n 'method': 'POST',\r\n 'params': queryParams,\r\n 'body': bodyParams,\r\n }).then((responseData: any) => this.decode(responseData));\r\n }\r\n\r\n /**\r\n * Updates an existing item by its id.\r\n */\r\n protected _update(basePath: string, id: string, bodyParams = {}, queryParams = {}): Promise<M> {\r\n return this.client.send(basePath + '/' + encodeURIComponent(id), {\r\n 'method': 'PATCH',\r\n 'params': queryParams,\r\n 'body': bodyParams,\r\n }).then((responseData: any) => this.decode(responseData));\r\n }\r\n\r\n /**\r\n * Deletes an existing item by its id.\r\n */\r\n protected _delete(basePath: string, id: string, queryParams = {}): Promise<boolean> {\r\n return this.client.send(basePath + '/' + encodeURIComponent(id), {\r\n 'method': 'DELETE',\r\n 'params': queryParams,\r\n }).then(() => true);\r\n }\r\n}\r\n","import ListResult from '@/models/utils/ListResult';\r\nimport BaseModel from '@/models/utils/BaseModel';\r\nimport BaseCrudService from '@/services/utils/BaseCrudService';\r\n\r\nexport default abstract class CrudService<M extends BaseModel> extends BaseCrudService<M> {\r\n /**\r\n * Base path for the crud actions (without trailing slash, eg. '/admins').\r\n */\r\n abstract baseCrudPath(): string\r\n\r\n /**\r\n * Returns a promise with all list items batch fetched at once.\r\n */\r\n getFullList(batchSize = 100, queryParams = {}): Promise<Array<M>> {\r\n return this._getFullList(this.baseCrudPath(), batchSize, queryParams);\r\n }\r\n\r\n /**\r\n * Returns paginated items list.\r\n */\r\n getList(page = 1, perPage = 30, queryParams = {}): Promise<ListResult<M>> {\r\n return this._getList(this.baseCrudPath(), page, perPage, queryParams);\r\n }\r\n\r\n /**\r\n * Returns single item by its id.\r\n */\r\n getOne(id: string, queryParams = {}): Promise<M> {\r\n return this._getOne(this.baseCrudPath(), id, queryParams);\r\n }\r\n\r\n /**\r\n * Creates a new item.\r\n */\r\n create(bodyParams = {}, queryParams = {}): Promise<M> {\r\n return this._create(this.baseCrudPath(), bodyParams, queryParams);\r\n }\r\n\r\n /**\r\n * Updates an existing item by its id.\r\n */\r\n update(id: string, bodyParams = {}, queryParams = {}): Promise<M> {\r\n return this._update(this.baseCrudPath(), id, bodyParams, queryParams);\r\n }\r\n\r\n /**\r\n * Deletes an existing item by its id.\r\n */\r\n delete(id: string, queryParams = {}): Promise<boolean> {\r\n return this._delete(this.baseCrudPath(), id, queryParams);\r\n }\r\n}\r\n","import CrudService from '@/services/utils/CrudService';\r\nimport Admin from '@/models/Admin';\r\n\r\nexport type AdminAuthResponse = {\r\n [key: string]: any,\r\n token: string,\r\n admin: Admin,\r\n}\r\n\r\nexport default class Admins extends CrudService<Admin> {\r\n /**\r\n * @inheritdoc\r\n */\r\n decode(data: { [key: string]: any }): Admin {\r\n return new Admin(data);\r\n }\r\n\r\n /**\r\n * @inheritdoc\r\n */\r\n baseCrudPath(): string {\r\n return '/api/admins';\r\n }\r\n\r\n /**\r\n * Prepare successful authorize response.\r\n */\r\n protected authResponse(responseData: any): AdminAuthResponse {\r\n const admin = this.decode(responseData?.admin || {});\r\n\r\n if (responseData?.token && responseData?.admin) {\r\n this.client.authStore.save(responseData.token, admin);\r\n }\r\n\r\n return Object.assign({}, responseData, {\r\n // normalize common fields\r\n 'token': responseData?.token || '',\r\n 'admin': admin,\r\n });\r\n }\r\n\r\n /**\r\n * Authenticate an admin account by its email and password\r\n * and returns a new admin token and data.\r\n *\r\n * On success this method automatically updates the client's AuthStore data.\r\n */\r\n authViaEmail(\r\n email: string,\r\n password: string,\r\n bodyParams = {},\r\n queryParams = {},\r\n ): Promise<AdminAuthResponse> {\r\n bodyParams = Object.assign({\r\n 'email': email,\r\n 'password': password,\r\n }, bodyParams);\r\n\r\n return this.client.send(this.baseCrudPath() + '/auth-via-email', {\r\n 'method': 'POST',\r\n 'params': queryParams,\r\n 'body': bodyParams,\r\n 'headers': {\r\n 'Authorization': '',\r\n },\r\n }).then(this.authResponse.bind(this));\r\n }\r\n\r\n /**\r\n * Refreshes the current admin authenticated instance and\r\n * returns a new token and admin data.\r\n *\r\n * On success this method automatically updates the client's AuthStore data.\r\n */\r\n refresh(bodyParams = {}, queryParams = {}): Promise<AdminAuthResponse> {\r\n return this.client.send(this.baseCrudPath() + '/refresh', {\r\n 'method': 'POST',\r\n 'params': queryParams,\r\n 'body': bodyParams,\r\n }).then(this.authResponse.bind(this));\r\n }\r\n\r\n /**\r\n * Sends admin password reset request.\r\n */\r\n requestPasswordReset(\r\n email: string,\r\n bodyParams = {},\r\n queryParams = {},\r\n ): Promise<boolean> {\r\n bodyParams = Object.assign({\r\n 'email': email,\r\n }, bodyParams);\r\n\r\n return this.client.send(this.baseCrudPath() + '/request-password-reset', {\r\n 'method': 'POST',\r\n 'params': queryParams,\r\n 'body': bodyParams,\r\n }).then(() => true);\r\n }\r\n\r\n /**\r\n * Confirms admin password reset request.\r\n */\r\n confirmPasswordReset(\r\n passwordResetToken: string,\r\n password: string,\r\n passwordConfirm: string,\r\n bodyParams = {},\r\n queryParams = {},\r\n ): Promise<AdminAuthResponse> {\r\n