{"version":3,"file":"index.mjs","sources":["../node_modules/tslib/tslib.es6.js","../src/utils.ts","../src/version.ts","../src/errors.ts","../src/resources/base.ts","../src/resources/auth.ts","../src/resources/identities.ts","../src/resources/accounts.ts","../src/resources/connections.ts","../src/resources/categories.ts","../src/resources/payments.ts","../src/resources/transfers.ts","../src/resources/transactions.ts","../src/resources/users.ts","../src/resources/webhooks.ts","../src/resources/parties.ts","../src/resources/authorisations.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 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\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 || 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","import axios from \"axios\";\nimport type { AxiosResponse, AxiosError } from \"axios\";\nexport type Protocol = \"http\" | \"https\";\n\n/**\n * Build a URL from constituent components.\n */\nexport function buildUrl({\n protocol,\n host,\n port,\n path = \"\",\n query = {},\n}: {\n protocol: Protocol;\n host: string;\n port?: number;\n path?: string;\n query?: Record;\n}): string {\n // If not specified, port will be chosen by browser based on protocol choice (http or https).\n const _port = port ? `:${port}` : \"\";\n\n // Clean `undefined` values from the query params\n const cleanedQuery = Object.fromEntries(\n Object.entries(query || {}).filter(([_, v]) => typeof v !== \"undefined\")\n ) as Record;\n\n // Convert to URL encoded query string\n const queryString =\n Object.keys(cleanedQuery).length !== 0\n ? \"?\" + new URLSearchParams(cleanedQuery).toString()\n : \"\";\n\n return `${protocol}://${host}${_port}/${path}${queryString}`;\n}\n\nexport function pick, TKey extends keyof TObj>(\n obj: TObj,\n ...props: TKey[]\n) {\n return Object.fromEntries(\n Object.entries(obj).filter(([k]) => props.includes(k as TKey))\n ) as Pick;\n}\n\n/**\n * Axios error interceptor to retry on network failures.\n * Dormant by default - is activated by including `retries` in the axios config.\n */\nexport function axiosRetryOnNetworkError(\n error: AxiosError\n): Promise {\n // Only handle axios errors.\n if (!error.isAxiosError) return Promise.reject(error);\n\n const { config }: any = error;\n const { method, headers, retries = 0, __retryCount = 0 } = config;\n\n // POST requests can only be retried if they include an idempotency key.\n // Other methods (i.e. get, patch, delete) are considered idempotent by default.\n const isIdempotent =\n method.toUpperCase() !== \"POST\" ||\n typeof headers[\"Idempotency-Key\"] === \"string\";\n\n const shouldRetry =\n isIdempotent &&\n __retryCount < retries &&\n isNetworkError(error) && // Don't retry due to server errors\n isRetryAllowed(error); // Don't retry if the error is permanent (e.g. SSL related)\n\n if (!shouldRetry) {\n return Promise.reject(error);\n }\n\n config.__retryCount = __retryCount + 1;\n return axios(config);\n}\n\n/**\n * Determine whether an axios error instance was caused by network error\n * (and should therefore be retryable).\n *\n * Borrowed from {@link https://github.com/softonic/axios-retry/blob/master/es/index.js}\n * with minor changes as we want to retry on timeout.\n */\nfunction isNetworkError(error: AxiosError): boolean {\n return (\n error.isAxiosError &&\n !error.response && // Network errors have no response\n !axios.isCancel(error)\n ); // Don't retry cancelled requests\n}\n\n/**\n * Inspect network error code from axios to determine if it makes sense to retry it.\n *\n * Borrowed from {@link https://github.com/sindresorhus/is-retry-allowed/blob/main/index.js}\n */\nfunction isRetryAllowed(error: AxiosError): boolean {\n return (\n error.code === undefined || // Errors due to timeout have no error code.\n !retryDenyList.has(error.code)\n );\n}\n\nconst retryDenyList = new Set([\n \"ENOTFOUND\",\n \"ENETUNREACH\",\n \"UNABLE_TO_GET_ISSUER_CERT\",\n \"UNABLE_TO_GET_CRL\",\n \"UNABLE_TO_DECRYPT_CERT_SIGNATURE\",\n \"UNABLE_TO_DECRYPT_CRL_SIGNATURE\",\n \"UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY\",\n \"CERT_SIGNATURE_FAILURE\",\n \"CRL_SIGNATURE_FAILURE\",\n \"CERT_NOT_YET_VALID\",\n \"CERT_HAS_EXPIRED\",\n \"CRL_NOT_YET_VALID\",\n \"CRL_HAS_EXPIRED\",\n \"ERROR_IN_CERT_NOT_BEFORE_FIELD\",\n \"ERROR_IN_CERT_NOT_AFTER_FIELD\",\n \"ERROR_IN_CRL_LAST_UPDATE_FIELD\",\n \"ERROR_IN_CRL_NEXT_UPDATE_FIELD\",\n \"OUT_OF_MEM\",\n \"DEPTH_ZERO_SELF_SIGNED_CERT\",\n \"SELF_SIGNED_CERT_IN_CHAIN\",\n \"UNABLE_TO_GET_ISSUER_CERT_LOCALLY\",\n \"UNABLE_TO_VERIFY_LEAF_SIGNATURE\",\n \"CERT_CHAIN_TOO_LONG\",\n \"CERT_REVOKED\",\n \"INVALID_CA\",\n \"PATH_LENGTH_EXCEEDED\",\n \"INVALID_PURPOSE\",\n \"CERT_UNTRUSTED\",\n \"CERT_REJECTED\",\n \"HOSTNAME_MISMATCH\",\n]);\n\n// https://github.com/flexdinesh/browser-or-node/blob/master/src/index.js\nexport const isBrowser = () =>\n typeof window !== \"undefined\" && typeof window.document !== \"undefined\";\n\nexport const isNode = () =>\n typeof process === \"object\" &&\n Boolean(process.versions?.node) &&\n !isReactNative();\n\n// https://github.com/facebook/react-native/commit/3c65e62183ce05893be0822da217cb803b121c61\nexport const isReactNative = () =>\n typeof navigator === \"object\" && navigator.product === \"ReactNative\";\n","export const version = \"2.5.1\";","import type { AxiosResponse } from \"axios\";\n\nclass AkahuError extends Error {\n /**\n * Flag that can be used to detect exceptions thrown by the Akahu SDK.\n */\n isAkahuError = true;\n /**\n * Legacy static property for backwards compatibility. Prefer the instance\n * property `isAkahuError` instead.\n * @deprecated\n */\n static isAkahuError = true;\n}\n\n/**\n * Error type for error responses received from the Akahu API.\n * An error response is characterised by a non 2XX status code and/or a body\n * payload that contains `success: false` along with an accompanying error message.\n *\n * @noInheritDoc\n * @category Error\n */\nexport class AkahuErrorResponse extends AkahuError {\n /**\n * The response status code.\n */\n status: number;\n /**\n * The full {@link https://axios-http.com/docs/res_schema AxiosReponse}\n * object from axios.\n */\n response: AxiosResponse;\n\n /** @internal */\n static oAuthErrorCodeMap: Record = {\n invalid_request: \"Invalid OAuth request.\",\n unauthorized_client:\n \"This application is not authorized to make this request.\",\n unsupported_response_type: \"Unsupported OAuth response type.\",\n invalid_scope: \"Unknown or invalid scope.\",\n server_error: \"Unknown server error.\",\n temporarily_unavailable:\n \"The authorization server is temporarily unavailable.\",\n invalid_grant: \"Invalid OAuth request.\",\n };\n\n /** @internal */\n constructor(response: AxiosResponse) {\n const { status, statusText, data = {} } = response;\n const { message, error, error_description } = data;\n let _message: string;\n\n // `error` and `error_description` are specific to the OAuth endpoints.\n // `error_description` is more user-friendly, but optional:\n // https://www.oauth.com/oauth2-servers/server-side-apps/possible-errors/\n if (typeof error_description === \"string\") {\n _message = error_description;\n } else if (error in AkahuErrorResponse.oAuthErrorCodeMap) {\n _message = AkahuErrorResponse.oAuthErrorCodeMap[error];\n } else {\n // Detail for other error responses are nested under the `message` key.\n // Include a fallback to statusText just in case things go really wrong.\n _message = message ?? statusText;\n }\n\n super(_message);\n this.status = status;\n this.response = response;\n }\n}\n\n/**\n * Error type for errors that occur during the webhook validation process.\n *\n * @noInheritDoc\n * @category Error\n */\nexport class AkahuWebhookValidationError extends AkahuError {}\n","import type { AkahuClient } from \"../client\";\n\n/**\n * @internal\n */\nexport class BaseResource {\n protected readonly _client: AkahuClient;\n\n /**\n * @internal\n */\n constructor(client: AkahuClient) {\n this._client = client;\n }\n}\n","import { Protocol, buildUrl } from \"../utils\";\nimport { BaseResource } from \"./base\";\nimport { AuthorizationToken } from \"../models\";\n\n/**\n * Utilities for authorizing users using OAuth2.\n *\n * {@link https://developers.akahu.nz/docs/authorizing-with-oauth2}\n *\n * @category Resource\n */\nexport class AuthResource extends BaseResource {\n /**\n * Build the OAuth Authorization URL\n *\n * @param options Options for customising the generated URL.\n *\n * {@link https://developers.akahu.nz/docs/authorizing-with-oauth2#the-authorization-request}\n */\n public buildAuthorizationUrl(options: {\n /**\n * Where to redirect the user once they have accepted or rejected the access request.\n * This **must** match one of your app's Redirect URIs.\n */\n redirect_uri: string;\n /**\n * This option is intended for mobile app developers.\n *\n * Specify a value of deep_link if your provided `redirect_uri` intends to activate your native\n * mobile application via iOS universal link or Android app link. When you supply this value,\n * the user will be required to tap to confirm before returning to your application. This\n * interaction ensures successful native app activation.\n */\n redirect_mode?: \"deep_link\",\n /**\n * The type of OAuth response. Currently `code` is the only supported option.\n *\n * @default `code`\n */\n response_type?: string;\n scope?: string;\n email?: string;\n connection?: string;\n state?: string;\n protocol?: Protocol;\n host?: string;\n port?: number;\n path?: string;\n }) {\n // Unpack options with defaults\n const {\n protocol,\n host,\n port,\n path,\n response_type,\n scope,\n redirect_uri,\n redirect_mode,\n state,\n email,\n connection,\n } = {\n protocol: \"https\" as const,\n host: \"oauth.akahu.nz\",\n path: \"\",\n response_type: \"code\",\n scope: \"ENDURING_CONSENT\",\n ...options,\n };\n\n // Construct main OAuth query params\n const { appToken: client_id } = this._client.authConfig;\n const query: Record = {\n response_type,\n redirect_uri,\n scope,\n client_id,\n };\n\n // Include optional params if specified in options\n if (email) query.email = email;\n if (connection) query.connection = connection;\n if (state) query.state = state;\n if (redirect_mode) query.redirect_mode = redirect_mode;\n\n return buildUrl({ protocol, host, port, path, query });\n }\n\n /**\n * Exchange an OAuth authorization code for an access token.\n *\n * {@link https://developers.akahu.nz/docs/authorizing-with-oauth2#exchanging-the-authorization-code}\n * {@link https://developers.akahu.nz/reference/post_token}\n */\n public async exchange(\n code: string,\n redirect_uri: string,\n grant_type: string = \"authorization_code\"\n ): Promise {\n // POST parameters for OAuth code exchange\n const { appToken: client_id, appSecret: client_secret } =\n this._client.authConfig;\n const data = { code, redirect_uri, grant_type, client_id, client_secret };\n\n return await this._client._apiCall({\n path: \"/token\",\n method: \"POST\",\n data,\n });\n }\n\n /**\n * Revoke the specified user auth token:\n *\n * {@link https://developers.akahu.nz/reference/delete_token}\n */\n public async revoke(token: string) {\n return await this._client._apiCall({\n path: \"/token\",\n method: \"DELETE\",\n auth: { token },\n });\n }\n}\n","import { BaseResource } from \"./base\";\nimport { Protocol } from \"../utils\";\nimport {\n IdentityResult,\n IdentityVerifyNameQuery,\n IdentityVerifyNameResult,\n} from \"../models\";\n\n/**\n * Utilities for requesting identity verification using OAuth2.\n *\n * {@link https://developers.akahu.nz/docs/identity-verification}\n *\n * @category Resource\n */\nexport class IdentitiesResource extends BaseResource {\n /**\n * Build the Identity OAuth Authorization URL.\n *\n * {@link https://developers.akahu.nz/docs/identity-verification#the-authorization-request}\n */\n public buildAuthorizationUrl(params: {\n protocol?: Protocol;\n host?: string;\n port?: number;\n path?: string;\n response_type?: string;\n redirect_uri: string;\n scope?: string;\n state?: string;\n }) {\n // Borrow implementation from `OAuthResource.buildAuthorizationUrl`\n return this._client.auth.buildAuthorizationUrl({\n scope: \"ONEOFF\",\n ...params,\n });\n }\n\n /**\n * Retrieve an identity result using the code/id returned after successful authorization using the\n * OAuth identity verification flow.\n *\n * {@link https://developers.akahu.nz/docs/identity-verification#retrieving-identity-results-with-the-oauth-result-code}\n */\n public async get(code: string) {\n return this._client._apiCall({\n path: `/identity/${code}`,\n auth: { basic: true },\n });\n }\n\n /**\n * (**BETA**) Verify the user's name against an identity result.\n *\n * {@link https://developers.akahu.nz/docs/oneoff-verify-name}\n */\n public async verifyName(code: string, query: IdentityVerifyNameQuery) {\n return this._client._apiCall({\n path: `/identity/${code}/verify/name`,\n method: \"POST\",\n data: query,\n auth: { basic: true },\n });\n }\n}\n","import { BaseResource } from \"./base\";\n\nimport {\n Account,\n Transaction,\n PendingTransaction,\n TransactionQueryParams,\n Paginated,\n} from \"../models\";\n\n/**\n * Utilities for managing Akahu accounts that have been linked by users.\n *\n * {@link https://developers.akahu.nz/docs/accessing-account-data}\n *\n * @category Resource\n */\nexport class AccountsResource extends BaseResource {\n /**\n * List all accounts that have been connected by the user associated with the specified `token`.\n *\n * {@link https://developers.akahu.nz/reference/get_accounts}\n */\n public async list(token: string): Promise {\n return await this._client._apiCall({\n path: \"/accounts\",\n auth: { token },\n });\n }\n\n /**\n * Get a single account that has been connected by the user associated with the specified `token`.\n *\n * {@link https://developers.akahu.nz/reference/get_accounts-id}\n */\n public async get(token: string, accountId: string): Promise {\n return await this._client._apiCall({\n path: `/accounts/${accountId}`,\n auth: { token },\n });\n }\n\n /**\n * List transactions for a specified account.\n *\n * {@link https://developers.akahu.nz/reference/get_accounts-id-transactions}\n */\n public async listTransactions(\n token: string,\n accountId: string,\n query: TransactionQueryParams = {}\n ): Promise> {\n return await this._client._apiCall>({\n path: `/accounts/${accountId}/transactions`,\n auth: { token },\n query,\n });\n }\n\n /**\n * List pending transactions for a specified account.\n *\n * {@link https://developers.akahu.nz/reference/get_accounts-id-transactions-pending}\n */\n public async listPendingTransactions(\n token: string,\n accountId: string\n ): Promise {\n return await this._client._apiCall({\n path: `/accounts/${accountId}/transactions/pending`,\n auth: { token },\n });\n }\n\n /**\n * Revoke a single account from the specified `token`.\n *\n * After this call the token will no longer have access to the specified account or it's associated data,\n * including transactions.\n *\n * {@link https://developers.akahu.nz/reference/delete_accounts-id}\n *\n * @deprecated Use {@link AuthorisationsResource.revoke | `authorisations.revoke`} instead.\n */\n public async revoke(token: string, accountId: string): Promise {\n return await this._client._apiCall({\n path: `/accounts/${accountId}`,\n method: \"DELETE\",\n auth: { token },\n });\n }\n\n /**\n * Refresh a single account that has been connected by the user associated with the specified `token`.\n *\n * {@link https://developers.akahu.nz/reference/post_refresh-id}\n */\n public async refresh(token: string, accountId: string): Promise {\n return await this._client._apiCall({\n path: `/refresh/${accountId}`,\n method: \"POST\",\n auth: { token },\n });\n }\n\n /**\n * Refresh all accounts that have been connected by the user associated with the specified `token`.\n *\n * {@link https://developers.akahu.nz/reference/post_refresh}\n */\n public async refreshAll(token: string): Promise {\n return await this._client._apiCall({\n path: \"/refresh\",\n method: \"POST\",\n auth: { token },\n });\n }\n}\n","import { BaseResource } from \"./base\";\nimport { Connection } from \"../models\";\n\n/**\n * Utilities to view connections that are available to your app, and refresh\n * accounts under a given connection.\n *\n * @category Resource\n */\nexport class ConnectionsResource extends BaseResource {\n /**\n * List all connections that the app has access to.\n *\n * {@link https://developers.akahu.nz/reference/get_connections}\n */\n public async list(): Promise {\n return await this._client._apiCall({\n path: \"/connections\",\n auth: { basic: true },\n });\n }\n\n /**\n * Get an individual connection detail.\n *\n * {@link https://developers.akahu.nz/reference/get_connections-id}\n */\n public async get(connectionId: string): Promise {\n return await this._client._apiCall({\n path: `/connections/${connectionId}`,\n auth: { basic: true },\n });\n }\n\n /**\n * Refresh all accounts that are made using the given connection and have been\n * connected by the user associated with the specified `token`.\n *\n * {@link https://developers.akahu.nz/reference/post_refresh-id}\n */\n public async refresh(token: string, connectionId: string): Promise {\n return await this._client._apiCall({\n path: `/refresh/${connectionId}`,\n method: \"POST\",\n auth: { token },\n });\n }\n}\n","import { BaseResource } from \"./base\";\nimport { Category } from \"../models\";\n\n/**\n * Utilities to view categories that are available to your app.\n *\n * @category Resource\n */\nexport class CategoriesResource extends BaseResource {\n /**\n * List all categories that the app has access to.\n *\n * {@link https://developers.akahu.nz/reference/get_categories}\n */\n public async list(): Promise {\n return await this._client._apiCall({\n path: \"/categories\",\n auth: { basic: true },\n });\n }\n\n /**\n * Get an individual category.\n *\n * {@link https://developers.akahu.nz/reference/get_categories-id}\n */\n public async get(categoryId: string): Promise {\n return await this._client._apiCall({\n path: `/categories/${categoryId}`,\n auth: { basic: true },\n });\n }\n}\n","import { BaseResource } from \"./base\";\nimport {\n Payment,\n PaymentCreateParams,\n PaymentQueryParams,\n PostRequestOptions,\n} from \"../models\";\nimport { IrdPaymentCreateParams } from \"../models/payments\";\n\n/**\n * Utilities for managing bank account payments on behalf of users.\n *\n * {@link https://developers.akahu.nz/docs/making-a-payment}\n *\n * @category Resource\n */\nexport class PaymentsResource extends BaseResource {\n /**\n * Get a single payment made by the user associated with the specified `token`.\n *\n * {@link https://developers.akahu.nz/reference/get_payments-id}\n */\n public async get(token: string, paymentId: string): Promise {\n return await this._client._apiCall({\n path: `/payments/${paymentId}`,\n auth: { token },\n });\n }\n\n /**\n * List all payments made in the provided date range by the user associated\n * with the specified `token`. Defaults to the last 30 days if no date range\n * is provided.\n *\n * {@link https://developers.akahu.nz/reference/get_payments}\n */\n public async list(\n token: string,\n query: PaymentQueryParams = {}\n ): Promise {\n // List endpoint with optional query params for date range\n return await this._client._apiCall({\n path: \"/payments\",\n auth: { token },\n query,\n });\n }\n\n /**\n * Initiate a payment to an external bank account on behalf of the user associated\n * with the specified `token`.\n *\n * {@link https://developers.akahu.nz/reference/post_payments}\n */\n public async create(\n token: string,\n payment: PaymentCreateParams,\n requestOptions?: PostRequestOptions\n ): Promise {\n return await this._client._apiCall({\n path: \"/payments\",\n method: \"POST\",\n auth: { token },\n data: payment,\n options: requestOptions,\n });\n }\n\n /**\n * Initiate a payment to the Inland Revenue Department on behalf of the user\n * associated with the specified `token`.\n *\n * {@link https://developers.akahu.nz/reference/post_payments-ird}\n */\n public async createToIrd(\n token: string,\n payment: IrdPaymentCreateParams,\n requestOptions?: PostRequestOptions\n ): Promise {\n return await this._client._apiCall({\n path: \"/payments/ird\",\n method: \"POST\",\n auth: { token },\n data: payment,\n options: requestOptions,\n });\n }\n\n /**\n * Cancel a payment that has a status of `PENDING_APPROVAL`.\n *\n * {@link https://developers.akahu.nz/reference/put_payments-id-cancel}\n * {@link https://developers.akahu.nz/docs/making-a-payment#manual-payment-approval}\n */\n public async cancel(token: string, paymentId: string) {\n return this._client._apiCall({\n path: `/payments/${paymentId}`,\n method: \"PUT\",\n auth: { token },\n });\n }\n}\n","import { BaseResource } from \"./base\";\nimport {\n Transfer,\n TransferCreateParams,\n TransferQueryParams,\n PostRequestOptions,\n} from \"../models\";\n\n/**\n * Utilities for managing bank account transfers on behalf of users.\n *\n * {@link https://developers.akahu.nz/docs/making-a-transfer}\n *\n * @category Resource\n */\nexport class TransfersResource extends BaseResource {\n /**\n * Get a single transfer made by the user associated with the specified `token`.\n *\n * {@link https://developers.akahu.nz/reference/get_transfers-id}\n */\n public async get(token: string, transferId: string): Promise {\n return await this._client._apiCall({\n path: `/transfers/${transferId}`,\n auth: { token },\n });\n }\n\n /**\n * List all transfers made in the provided date range by the user associated\n * with the specified `token`. Defaults to the last 30 days if no date range\n * is provided.\n *\n * {@link https://developers.akahu.nz/reference/get_transfers}\n */\n public async list(\n token: string,\n query: TransferQueryParams = {}\n ): Promise {\n // List endpoint with optional query params for date range\n return await this._client._apiCall({\n path: \"/transfers\",\n auth: { token },\n query,\n });\n }\n\n /**\n * Initiate a transfer between two of the users bank accounts.\n *\n * {@link https://developers.akahu.nz/reference/post_transfers}\n */\n public async create(\n token: string,\n transfer: TransferCreateParams,\n requestOptions?: PostRequestOptions\n ): Promise {\n return await this._client._apiCall({\n path: \"/transfers\",\n method: \"POST\",\n auth: { token },\n data: transfer,\n options: requestOptions,\n });\n }\n}\n","import { BaseResource } from \"./base\";\nimport {\n Transaction,\n PendingTransaction,\n TransactionQueryParams,\n Paginated,\n} from \"../models\";\n\n/**\n * Utilities for retrieving bank transactions from connected user accounts.\n *\n * {@link https://developers.akahu.nz/docs/accessing-transactional-data}\n *\n * @category Resource\n */\nexport class TransactionsResource extends BaseResource {\n /**\n * List all transactions for all accounts that have been connected by the user associated with the\n * specified `token`.\n *\n * {@link https://developers.akahu.nz/reference/get_transactions}\n */\n public async list(\n token: string,\n query: TransactionQueryParams = {}\n ): Promise> {\n // Paginated list endpoint with optional query params for date range & cursor\n return await this._client._apiCall>({\n path: \"/transactions\",\n auth: { token },\n query,\n });\n }\n\n /**\n * List all pending transactions for all accounts that have been connected by the user associated with the\n * specified `token`.\n *\n * {@link https://developers.akahu.nz/reference/get_transactions-pending}\n */\n public async listPending(token: string): Promise {\n // Non-paginated list endpoint of pending transactions\n return await this._client._apiCall({\n path: \"/transactions/pending\",\n auth: { token },\n });\n }\n\n /**\n * Get a single transaction from an account that has been connected by the user associated with\n * the specified `token`.\n *\n * {@link https://developers.akahu.nz/reference/get_transactions-id}\n */\n public async get(token: string, transactionId: string): Promise {\n return await this._client._apiCall({\n path: `/transactions/${transactionId}`,\n auth: { token },\n });\n }\n\n /**\n * Get multiple transactions by id.\n *\n * All transactions must belong to the user associated with the specified `token`.\n *\n * This method may be useful to bulk refresh changed transaction data\n * in response to a webhook event.\n *\n * {@link https://developers.akahu.nz/reference/post_transactions-ids}\n */\n public async getMany(\n token: string,\n transactionIds: string[]\n ): Promise {\n // Non-paginated list endpoint subset by transaction id\n return this._client._apiCall({\n path: \"/transactions/ids\",\n method: \"POST\",\n auth: { token },\n data: transactionIds,\n });\n }\n}\n","import { BaseResource } from \"./base\";\nimport { User } from \"../models\";\n\n/**\n * Utilities for retrieving information about the Akahu user.\n *\n * @category Resource\n */\nexport class UsersResource extends BaseResource {\n /**\n * Get the user associated with the specified `token`.\n *\n * {@link https://developers.akahu.nz/reference/get_me}\n */\n public async get(token: string): Promise {\n return await this._client._apiCall({ path: \"/me\", auth: { token } });\n }\n}\n","import { BaseResource } from \"./base\";\nimport { AkahuWebhookValidationError } from \"../errors\";\n\nimport type {\n Webhook,\n WebhookPayload,\n WebhookEvent,\n WebhookCreateParams,\n WebhookEventQueryParams,\n} from \"../models/webhooks\";\nimport { PostRequestOptions } from \"../models\";\n\ntype CryptoModule = typeof import(\"crypto\");\n\n// crypto may not be available on all platforms (e.g React Native).\n// This is ok as we only need it server side. We just need to handle the import conditionally.\nlet crypto: CryptoModule | undefined;\n\ntry {\n crypto = require(\"crypto\");\n} catch (e) {}\n\n/**\n * Setter and getter interface to enable external/shared caching of webhook\n * signing keys.\n *\n * Accessor functions may be async (by returning a Promise) or sync (by returning a value).\n *\n * See the project README for example usage.\n *\n * @category API client\n */\nexport interface WebhookSigningKeyCache {\n get(key: string): string | null | Promise;\n set(key: string, value: string): void | Promise;\n}\n\n/**\n * @category API client config\n */\nexport type WebhookCacheConfig = {\n cache: WebhookSigningKeyCache;\n key: string;\n maxAgeMs: number;\n};\n\ntype CachedKeyData = {\n id: number;\n key: string;\n lastRefreshed: string;\n};\n\n/**\n * Default in-memory cache for caching the webhook signing key.\n */\nclass DefaultKeyCache implements WebhookSigningKeyCache {\n private readonly _cache: Record = {};\n\n async get(key: string): Promise {\n return this._cache[key] ?? null;\n }\n\n async set(key: string, value: string): Promise {\n this._cache[key] = value;\n }\n}\n\n/**\n * Utilities for managing, retrieving, and validating webhooks.\n *\n * {@link https://developers.akahu.nz/docs/reference-webhooks}\n *\n * @category Resource\n */\nexport class WebhooksResource extends BaseResource {\n private defaultKeyCache = new DefaultKeyCache();\n\n /**\n * Gets active webhooks for the user associated with the specified `token`.\n *\n * {@link https://developers.akahu.nz/reference/get_webhooks}\n */\n public async list(token: string): Promise {\n return await this._client._apiCall({\n path: \"/webhooks\",\n auth: { token },\n });\n }\n\n /**\n * Subscribe to a webhook.\n *\n * @returns The newly created webhook id.\n *\n * {@link https://developers.akahu.nz/reference/post_webhooks}\n */\n public async subscribe(\n token: string,\n webhook: WebhookCreateParams,\n requestOptions?: PostRequestOptions\n ): Promise {\n return await this._client._apiCall({\n path: \"/webhooks\",\n method: \"POST\",\n auth: { token },\n data: webhook,\n options: requestOptions,\n });\n }\n\n /**\n * Unsubscribe from a previously created webhook.\n *\n * {@link https://developers.akahu.nz/reference/delete_webhooks-id}\n */\n public async unsubscribe(token: string, webhookId: string): Promise {\n return await this._client._apiCall({\n path: `/webhooks/${webhookId}`,\n method: \"DELETE\",\n auth: { token },\n });\n }\n\n /**\n * List all webhook events with the specified status in the specified date\n * range (defaults to last 30 days).\n *\n * {@link https://developers.akahu.nz/reference/get_webhook-events}\n */\n public async listEvents(\n query: WebhookEventQueryParams\n ): Promise {\n return await this._client._apiCall({\n path: \"/webhook-events\",\n auth: { basic: true },\n query,\n });\n }\n\n /**\n * Get a webhook signing public-key by id.\n *\n * {@link https://developers.akahu.nz/reference/get_keys-id}\n */\n public async getPublicKey(keyId: string | number): Promise {\n return await this._client._apiCall({\n path: `/keys/${keyId}`,\n auth: { basic: true },\n });\n }\n\n /**\n * Helper to validate a webhook request payload.\n *\n * See the project README for example usage.\n *\n * @returns The deserialized webhook payload after successful validation\n *\n * @throws {@link AkahuWebhookValidationError}\n * if validation of the webhook fails due to invalid signature or expired signing key.\n *\n * @throws {@link AkahuErrorResponse}\n * if the client fails to fetch the specified signing key from the Akahu API.\n *\n * {@link https://developers.akahu.nz/docs/reference-webhooks}\n */\n public async validateWebhook(\n keyId: string | number,\n signature: string,\n webhookRequestBody: string,\n cacheConfig: Partial = {}\n ): Promise {\n // Coerce keyId as a number\n const _keyId = Number(keyId);\n\n // Validate that keyId is an integer. Includes null check because Number(null) === 0\n if (!Number.isInteger(_keyId) || keyId === null) {\n throw new AkahuWebhookValidationError(\n `Can't validate webhook request. keyId must be an integer (received ${keyId}).`\n );\n }\n\n // Initialize cache config with defaults\n const _cacheConfig = {\n cache: this.defaultKeyCache,\n key: \"akahu__webhook_key\",\n maxAgeMs: 24 * 60 * 60 * 1000, // 24 hours\n ...cacheConfig,\n };\n\n // Get the public key matching keyId - either from cache or API lookup\n const publicKey = await this._getPublicKey(_keyId, _cacheConfig);\n\n // Validate the webhook signature using the retreived public key\n const isValid = this._validateWebhookSignature(\n publicKey,\n signature,\n webhookRequestBody\n );\n\n if (!isValid) {\n throw new AkahuWebhookValidationError(\n \"Webhook signature verificaton failed.\"\n );\n }\n\n return JSON.parse(webhookRequestBody) as WebhookPayload;\n }\n\n /**\n * Get the public key (by id) to validate a webhook signature.\n * The key will be retrieved from cache if possible, falling back to API lookup.\n * If a cached key exists with a newer id, an error will be thrown, as the existence of a newer\n * key implies that the key has been rotated and the requested key is no longer valid.\n *\n * {@link https://developers.akahu.nz/docs/reference-webhooks#caching}\n */\n private async _getPublicKey(\n keyId: number,\n cacheConfig: WebhookCacheConfig\n ): Promise {\n // Attempt to lookup key from cache\n const keyDataFromCache = await this._getPublicKeyFromCache(cacheConfig);\n\n // Validate the cached key matches\n if (keyDataFromCache !== null) {\n const { id, key } = keyDataFromCache;\n\n // Validate that the cached key has same id as requested key\n if (keyId === id) {\n return key;\n }\n\n // Throw an error if the requested key has been superseded\n if (keyId < id) {\n throw new AkahuWebhookValidationError(\n `Webhook signing key (id: ${keyId}) has expired. Unable to validate webhook.`\n );\n }\n\n // Fallback to lookup via API\n }\n\n // Lookup key data from API\n const freshKeyData: CachedKeyData = {\n id: keyId,\n lastRefreshed: new Date().toISOString(),\n key: await this.getPublicKey(keyId),\n };\n\n // Cache the updated key data\n await this._cacheKeyData(freshKeyData, cacheConfig);\n\n return freshKeyData.key;\n }\n\n /**\n * Lookup current active public key from the cache.\n * If the key has been in the cache for more than `maxAgeMs` milliseconds, it is considered\n * stale, and will be ignored - causing it to be re-fetched from Akahu. `maxAgeMs` defaults to 24 hours.\n *\n * {@link https://developers.akahu.nz/docs/reference-webhooks#caching}\n */\n private async _getPublicKeyFromCache(\n cacheConfig: WebhookCacheConfig\n ): Promise {\n const { cache, key: cacheKey, maxAgeMs } = cacheConfig;\n\n // Lookup key data from cache\n const rawFromCache = await cache.get(cacheKey);\n\n // Cache hit\n if (typeof rawFromCache === \"string\") {\n let keyData: CachedKeyData | undefined;\n\n // Deserialize key data JSON from cache\n try {\n keyData = JSON.parse(rawFromCache);\n } catch (e) {\n // Warn but no error if invalid JSON in cache data\n console.warn(\n `akahu-sdk: Failed to deserialize webhook key data from cache (key: ${cacheKey}).`\n );\n }\n\n // Validate the key data from cache\n if (typeof keyData !== \"undefined\") {\n // Ensure that the cache is at most `maxAgeMs` old\n const cacheAgeMs = Date.now() - Date.parse(keyData.lastRefreshed);\n // NaN check in case lastRefreshed is invalid date string or undefined somehow\n if (!Number.isNaN(cacheAgeMs) && cacheAgeMs < maxAgeMs) {\n return keyData;\n }\n }\n }\n\n // Cache miss or invalid cache data\n return null;\n }\n\n /**\n * Add the public key that has been fetched from the API to the cache.\n *\n * {@link https://developers.akahu.nz/docs/reference-webhooks#caching}\n */\n private async _cacheKeyData(\n keyData: CachedKeyData,\n cacheConfig: WebhookCacheConfig\n ): Promise {\n const { cache, key } = cacheConfig;\n await cache.set(key, JSON.stringify(keyData));\n }\n\n /**\n * Validate a webhook and associated signature using the public key fetched from the Akahu API.\n *\n * {@link https://developers.akahu.nz/docs/reference-webhooks#verification}\n */\n private _validateWebhookSignature(\n publicKey: string,\n signature: string,\n webhookBody: string\n ): boolean {\n if (typeof crypto === \"undefined\") {\n throw new Error(\n \"Webhook validation is only supported on Node.js environments.\"\n );\n }\n\n const verify = crypto.createVerify(\"sha256\");\n verify.update(webhookBody);\n verify.end();\n\n return verify.verify(publicKey, signature, \"base64\");\n }\n}\n","import { BaseResource } from \"./base\";\n\nimport { Party } from \"../models\";\n\n/**\n * Fetch identity data relating to the party that the user has logged-in to\n * their institution as when connecting accounts to Akahu. i.e. the user's\n * \"profile\" information at the connected institution.\n * @category Resource\n */\nexport class PartiesResource extends BaseResource {\n /**\n * List all parties related to accounts which the user has shared with your\n * app.\n *\n * {@link https://developers.akahu.nz/reference/get_parties}\n */\n public async list(token: string): Promise {\n return await this._client._apiCall({\n path: \"/parties\",\n auth: { token },\n });\n }\n}\n","import { BaseResource } from \"./base\";\n\n/**\n * Utilities for managing Akahu authorisations that have been linked by users.\n *\n * @category Resource\n */\nexport class AuthorisationsResource extends BaseResource {\n /**\n * Revoke a single authorisation from the specified `token`.\n *\n * After this call the token will no longer have access to the specified authorisation or it's associated data,\n * including accounts and transactions.\n *\n * {@link https://developers.akahu.nz/reference/delete_authorisations-id}\n */\n public async revoke(token: string, authorisationId: string): Promise {\n return await this._client._apiCall({\n path: `/authorisations/${authorisationId}`,\n method: \"DELETE\",\n auth: { token },\n });\n }\n}\n","import axios, { AxiosError } from \"axios\";\nimport type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from \"axios\";\n\nimport { v4 as uuidv4 } from \"uuid\";\n\nimport {\n buildUrl,\n pick,\n Protocol,\n isNode,\n isBrowser,\n axiosRetryOnNetworkError,\n} from \"./utils\";\nimport { version } from \"./version\";\nimport { AkahuErrorResponse } from \"./errors\";\n\nimport { Paginated, PostRequestOptions } from \"./models\";\nimport { AuthResource } from \"./resources/auth\";\nimport { IdentitiesResource } from \"./resources/identities\";\nimport { AccountsResource } from \"./resources/accounts\";\nimport { ConnectionsResource } from \"./resources/connections\";\nimport { CategoriesResource } from \"./resources/categories\";\nimport { PaymentsResource } from \"./resources/payments\";\nimport { TransfersResource } from \"./resources/transfers\";\nimport { TransactionsResource } from \"./resources/transactions\";\nimport { UsersResource } from \"./resources/users\";\nimport { WebhooksResource } from \"./resources/webhooks\";\nimport { PartiesResource } from \"./resources/parties\";\nimport { AuthorisationsResource } from \"./resources/authorisations\";\n\n// We will set this header to report SDK version\nconst X_AKAHU_SDK = `akahu-sdk-js/${version}`;\n\ntype ApiVersion = \"v1\";\ntype RequestOptions = PostRequestOptions;\n\n/**\n * @category API client config\n */\nexport { Protocol } from \"./utils\";\n\n/**\n * Authentication and API endpoint configuration for {@link AkahuClient}.\n * @category API client config\n */\nexport type AkahuClientConfig = {\n /**\n * appToken is required to access the Akahu API.\n */\n appToken: string;\n /**\n * appSecret is only required for completing an OAuth code exchange, or to\n * access app-specific endpoints.\n *\n * For security reasons, this option must not be used client-side in the browser.\n *\n * {@link https://developers.akahu.nz/reference}\n *\n * @defaultValue `undefined`\n */\n appSecret?: string;\n /**\n * The Akahu API version. Currently the only supported value is \"v1\".\n *\n * @defaultValue `v1`\n */\n apiVersion?: ApiVersion;\n /**\n * The protocol used for Akahu API calls.\n * The Akahu API only supports connections over HTTPS, so this option is only\n * useful for test environments etc.\n *\n * @defaultValue `https`\n */\n protocol?: Protocol;\n /**\n * The Akahu API hostname.\n * It may be useful to override this in staging / testing environments.\n *\n * @defaultValue `api.akahu.io`\n */\n host?: string;\n /**\n * The Akahu API port.\n * It may be useful to override this in staging / testing environments.\n *\n * @defaultValue `undefined`\n */\n port?: number;\n /**\n * Additional headers that will be included in each request.\n */\n headers?: Record;\n /**\n * Timeout in ms for each request to the Akahu API.\n *\n * If used in combination with `retries`, the timeout will be applied to\n * each retried request. This means that the total time until an error is\n * thrown due to a timeout will be `timeout * (retries + 1)` milliseconds.\n *\n * @defaultValue `0` (no timeout)\n */\n timeout?: number;\n /**\n * The number of times that API requests will be retried in the case of\n * network errors. Error responses from the Akahu API will not result in\n * a retry.\n *\n * @defaultValue `0`\n */\n retries?: number;\n /**\n * Optional configuration for an HTTP proxy.\n *\n * See the proxy section of the axios {@link https://axios-http.com/docs/req_config request config}\n * for more details.\n */\n proxy?: {\n host: string;\n port: number;\n auth?: {\n username: string;\n password: string;\n };\n protocol?: string;\n };\n /**\n * Optional adapter function which will be passed through to the underlying\n * Axios instance.\n *\n * See {@link https://github.com/axios/axios/tree/v1.8.3/lib/adapters}.\n */\n adapter?: AxiosRequestConfig[\"adapter\"];\n};\n\n// We allow custom axios configuration using this subset of options\nconst allowedAxiosOptions = [\n \"headers\",\n \"timeout\",\n \"proxy\",\n \"retries\",\n \"adapter\",\n] as const;\n\n// Internal flag to switch between API authentication methods\ntype AuthMethod = { basic: true } | { token: string };\n\n// Internal union type to capture the different shapes of response payloads\ntype ApiResponsePayload =\n | Record // Generic `item` response\n | Record[] // `items` list response\n | Paginated> // Paginated `items` list response\n | string // `item_id` response\n | void; // No response payload\n\n/**\n * The AkahuClient provides a simple interface to the Akahu API and utilities\n * that assist with common usage patterns.\n *\n * AkahuClient uses {@link https://axios-http.com/docs/intro axios} under the hood to make\n * API requests. A subset of axios request options can be passed through to the underlying axios\n * instance using the options available in {@link AkahuClientConfig}.\n *\n * In the case of an error while making an API request, you can expect to handle one of the\n * following two exceptions:\n *\n * - {@link AkahuErrorResponse} When an error response is returned from the API\n * - {@link https://github.com/axios/axios/blob/v0.21.1/index.d.ts#L85 AxiosError} when an error\n * occurred during the request process, but no response was received (i.e. due to network issues).\n *\n * @category API client\n */\nexport class AkahuClient {\n private readonly axios: AxiosInstance;\n /** @internal */\n readonly authConfig: { appToken: string; appSecret?: string };\n\n /**\n * @category Resource\n * @inheritDoc AuthResource\n * */\n auth: AuthResource;\n /**\n * @category Resource\n * @inheritDoc IdentitiesResource\n * */\n identities: IdentitiesResource;\n /**\n * @category Resource\n * @inheritDoc UsersResource\n * */\n users: UsersResource;\n /**\n * @category Resource\n * @inheritDoc ConnectionsResource\n * */\n connections: ConnectionsResource;\n /**\n * @category Resource\n * @inheritDoc CategoriesResource\n * */\n categories: CategoriesResource;\n /**\n * @category Resource\n * @inheritDoc AccountsResource\n * */\n accounts: AccountsResource;\n /**\n * @category Resource\n * @inheritDoc AuthorisationsResource\n * */\n authorisations: AuthorisationsResource;\n /**\n * @category Resource\n * @inheritDoc PaymentsResource\n * */\n payments: PaymentsResource;\n /**\n * @category Resource\n * @inheritDoc TransfersResource\n * */\n transfers: TransfersResource;\n /**\n * @category Resource\n * @inheritDoc TransactionsResource\n * */\n transactions: TransactionsResource;\n /**\n * @category Resource\n * @inheritDoc WebhooksResource\n * */\n webhooks: WebhooksResource;\n /**\n * @category Resource\n * @inheritDoc PartiesResource\n * */\n parties: PartiesResource;\n\n constructor(config: AkahuClientConfig) {\n const {\n appToken,\n appSecret,\n apiVersion,\n protocol,\n host,\n port,\n ...axiosOptions\n } = {\n apiVersion: \"v1\" as const,\n protocol: \"https\" as const,\n host: \"api.akahu.io\",\n ...config,\n };\n\n // Sanity check to warn against insecure App Secret usage\n if (typeof appSecret !== \"undefined\" && !isNode()) {\n console.warn(\n \"Warning: do not use the appSecret option with AkahuClient in a client-side \" +\n \"application. This option is only intended to be used on a server environment.\"\n );\n }\n\n // Make sure the appToken is included and follows the expected format\n if (typeof appToken !== \"string\" || !appToken.startsWith(\"app_token_\")) {\n throw new Error(\n `Invalid appToken value: ${appToken}. ` +\n \"appToken must be a string beginning with app_token_\"\n );\n }\n\n this.authConfig = { appToken, appSecret };\n\n // Common headers that we will send with each request\n const akahuHeaders: Record = {\n \"X-Akahu-Sdk\": X_AKAHU_SDK, // Report the SDK version\n \"X-Akahu-Id\": appToken, // Identify the calling app\n };\n\n // Also report SDK version in the User-Agent for convenience / visibility in logs. However\n // we don't want to set this in a browser environment as not all browsers support overriding\n // this header and it may result in un-suppressible errors in the browser console.\n // e.g: https://github.com/axios/axios/issues/1231\n if (!isBrowser()) {\n akahuHeaders[\"User-Agent\"] = X_AKAHU_SDK;\n }\n\n // Filter user-provided config to ensure we only include supported options.\n const filteredAxiosOptions = pick(axiosOptions, ...allowedAxiosOptions);\n\n this.axios = axios.create({\n ...filteredAxiosOptions,\n baseURL: buildUrl({ protocol, host, port, path: apiVersion }),\n headers: { ...filteredAxiosOptions.headers, ...akahuHeaders },\n });\n\n this.axios.interceptors.response.use(undefined, axiosRetryOnNetworkError);\n\n // Initialise client resources\n this.auth = new AuthResource(this);\n this.identities = new IdentitiesResource(this);\n this.users = new UsersResource(this);\n this.connections = new ConnectionsResource(this);\n this.categories = new CategoriesResource(this);\n this.accounts = new AccountsResource(this);\n this.authorisations = new AuthorisationsResource(this);\n this.payments = new PaymentsResource(this);\n this.transfers = new TransfersResource(this);\n this.transactions = new TransactionsResource(this);\n this.webhooks = new WebhooksResource(this);\n this.parties = new PartiesResource(this);\n }\n\n private _authorizeRequest(\n config: AxiosRequestConfig,\n auth?: AuthMethod\n ): AxiosRequestConfig {\n if (typeof auth !== \"undefined\") {\n // Basic HTTP auth is use for \"app\" endpoints\n if (\"basic\" in auth && auth.basic) {\n const { appToken, appSecret } = this.authConfig;\n\n if (typeof appSecret === \"undefined\") {\n throw new Error(\n \"This resource requires authentication using your Akahu app secret. \" +\n \"Include this using the `appSecret` option when initializing the AkahuClient.\"\n );\n }\n return { ...config, auth: { username: appToken, password: appSecret } };\n }\n // Token auth is used for user-specific endpoints\n if (\"token\" in auth) {\n return {\n ...config,\n headers: {\n ...config.headers,\n Authorization: `Bearer ${auth.token}`,\n },\n };\n }\n }\n\n return config;\n }\n\n private _makeIdempotent(\n config: AxiosRequestConfig,\n options: RequestOptions\n ): AxiosRequestConfig {\n if (config.method?.toUpperCase() === \"POST\") {\n return {\n ...config,\n headers: {\n ...config.headers,\n \"Idempotency-Key\": options.idempotencyKey ?? uuidv4(),\n },\n };\n }\n\n return config;\n }\n\n private _sanitizeQuery(query: Record): Record {\n // Sanity check for attempts to paginate with a `null` cursor. This might\n // happen if the user blindly passes in the \"next\" cursor from a paginated\n // response without checking its value. `query.cursor` must either be\n // `undefined` or a string value.\n if (query.cursor === null) {\n throw new Error(\n \"Pagination cursor cannot be null. A null next cursor in an API \" +\n \"response indicates that the final page has been reached.\"\n );\n }\n\n return query;\n }\n\n /**\n * Generic API wrapper, exposed for use by client resources.\n * @internal\n */\n async _apiCall({\n path,\n method = \"GET\",\n query,\n data,\n auth,\n options = {},\n }: {\n path: string;\n method?: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n query?: Record;\n data?: any;\n auth?: AuthMethod;\n options?: RequestOptions;\n }): Promise {\n let params = query;\n\n if (typeof params !== \"undefined\") {\n params = this._sanitizeQuery(params);\n }\n\n // Build up the request config object for axios\n let requestConfig: AxiosRequestConfig = { url: path, method, params, data };\n requestConfig = this._authorizeRequest(requestConfig, auth);\n requestConfig = this._makeIdempotent(requestConfig, options);\n\n let response: AxiosResponse;\n\n try {\n response = await this.axios.request(requestConfig);\n } catch (e) {\n const err = e as AxiosError;\n // Wrap error responses from the API\n if (typeof err.response !== \"undefined\") {\n throw new AkahuErrorResponse(err.response);\n }\n // All other errors are re-raised.\n throw err;\n }\n\n // Unpack response:\n // - success will always be present\n // - cursor will be present in the case of paginated responses\n // - response value will generally be nested under `item`, `items`, or `item_id`\n const { success, cursor, ...payload } = response.data;\n\n // Check status flag from API. Generally we shouldn't hit this, as any response\n // with `success: false` should return a 4xx or 5xx status which would\n // cause an exception above.\n if (!success) throw new AkahuErrorResponse(response);\n\n // Results from paginated responses are always nested under `items`\n if (cursor) {\n return { cursor, items: payload.items } as T;\n }\n\n // Unpacking of non-paginated response formats:\n // https://developers.akahu.nz/docs/response-formatting\n // Order is important here, as some endpoints return both `item` and\n // `item_id`, the latter of which is deprecated.\n return (payload.item ?? // Single item response\n payload.item_id ?? // Item id response\n payload.items ?? // Item list response\n (Object.keys(payload).length !== 0\n ? payload // OAuth response data is not nested to be spec-compliant\n : undefined)) as T; // No response payload: no return value\n }\n}\n"],"names":["uuidv4"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA4BA;AACO,SAAS,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE;AAC7B,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AACf,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AACvF,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpB,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,OAAO,MAAM,CAAC,qBAAqB,KAAK,UAAU;AACvE,QAAQ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAChF,YAA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