diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index ee2c216..e12611e 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -14,11 +14,11 @@ Explain the **details** for making this change. What existing problem does the p Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. - + **Code formatting** - +Ensure your code follows the existing style. Run `npm run lint` before submitting. **Closing issues** diff --git a/README.md b/README.md index 3c6d4d7..f27502e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,13 @@ -![wrapsplash-logo](public/logo.png) -# WrapSplashTS v5.0.0 +
+wrapsplash-logo -[![license](https://img.shields.io/github/license/SandeepVattapparambil/wrapsplash.svg)](https://github.com/SandeepVattapparambil/wrapsplash/blob/master/LICENSE) ![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg) ![npm version](https://badge.fury.io/js/wrapsplash.svg) [![CI](https://github.com/SandeepVattapparambil/wrapsplash/workflows/CI/badge.svg)](https://github.com/SandeepVattapparambil/wrapsplash/actions?query=workflow%3ACI) [![codecov](https://codecov.io/gh/SandeepVattapparambil/wrapsplash/branch/main/graph/badge.svg)](https://codecov.io/gh/SandeepVattapparambil/wrapsplash) ![GitHub issues](https://img.shields.io/github/issues/SandeepVattapparambil/wrapsplash.svg) ![GitHub forks](https://img.shields.io/github/forks/SandeepVattapparambil/wrapsplash.svg) ![GitHub stars](https://img.shields.io/github/stars/SandeepVattapparambil/wrapsplash.svg) +# WrapSplashTS v5.1.0 +[![license](https://img.shields.io/github/license/SandeepVattapparambil/wrapsplash.svg)](https://github.com/SandeepVattapparambil/wrapsplash/blob/master/LICENSE) ![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg) ![npm version](https://badge.fury.io/js/wrapsplash.svg) [![CI](https://github.com/SandeepVattapparambil/wrapsplash/workflows/CI/badge.svg)](https://github.com/SandeepVattapparambil/wrapsplash/actions?query=workflow%3ACI) [![codecov](https://codecov.io/gh/SandeepVattapparambil/wrapsplash/branch/main/graph/badge.svg)](https://codecov.io/gh/SandeepVattapparambil/wrapsplash) ![coverage](https://img.shields.io/badge/coverage-97.8%25-brightgreen) ![GitHub issues](https://img.shields.io/github/issues/SandeepVattapparambil/wrapsplash.svg) ![GitHub forks](https://img.shields.io/github/forks/SandeepVattapparambil/wrapsplash.svg) ![GitHub stars](https://img.shields.io/github/stars/SandeepVattapparambil/wrapsplash.svg) + +wrapsplash-badge + +
WrapSplashTS is a simple, promise-based API wrapper for the popular [Unsplash](https://unsplash.com/) platform. The library is now written in **TypeScript**, bundled with **Vite**, and can be used in both Node.js and browser-based projects. Unsplash provides beautiful high quality free images and photos that you can download and use for any project without any attribution. @@ -13,13 +18,14 @@ Before using the Unsplash API, you need to **register as a developer** and **rea ## Table of Contents -* [About](#wrapsplashts-v500) +* [About](#wrapsplashts-v510) * [Installation](#installation) * [Sample Usage](#sample-usage) * [Development](#development) * [New API aliases](#new-api-aliases) * [Dependency](#dependency) * [Changelog](#changelog) + * [v5.1.0](#v510) * [v5.0.0](#v500) * [v4.2.0](#v420) * [v4.1.1](#v411) @@ -107,7 +113,7 @@ Install the package from NPM npm install --save wrapsplash ``` -The package exposes the main class through the CommonJS entry point in [index.js](index.js), which loads the built distribution bundle. +The package exposes the main class through ES module and CommonJS entry points configured via the `exports` field in `package.json`. ### Sample usage ```js @@ -115,7 +121,7 @@ The package exposes the main class through the CommonJS entry point in [index.js const WrapSplash = require('wrapsplash'); // ES modules -// import WrapSplash from 'wrapsplash'; +import WrapSplash from 'wrapsplash'; const unsplash = new WrapSplash(); @@ -154,6 +160,15 @@ npm run test:coverage # Coverage report will be generated in ./coverage directory ``` +#### Current Coverage (v5.1.0) + +| Metric | Coverage | Threshold | +| --- | --- | --- | +| Statements | 97.8% | 80% | +| Branches | 79.5% | 55% | +| Functions | 98.4% | 80% | +| Lines | 97.8% | 80% | + Coverage thresholds (enforced): - **Lines:** 80% - **Functions:** 80% @@ -184,9 +199,20 @@ unsplash.createNewCollection('My Collection'); } ``` ### Dependency -This library depends on [axios](https://www.npmjs.com/package/axios) and [crypto-js](https://www.npmjs.com/package/crypto-js) to make requests and generate required request headers for the [Unsplash API](https://unsplash.com/documentation). +This library depends on [axios](https://www.npmjs.com/package/axios) to make requests and generates required request headers for the [Unsplash API](https://unsplash.com/documentation). ### Changelog +#### v5.1.0 +- **Security:** Removed `crypto-js` dependency (CVE-2023-46233), replaced with Node.js built-in `crypto` module +- Added `files` field to `package.json` to prevent publishing unnecessary files to npm +- Added smart retry logic with exponential backoff and `Retry-After` header support +- Added retryable error filtering: only network errors, timeouts, 429, and 5xx responses are retried +- Removed stale root `index.js` entry point in favor of `package.json` exports configuration +- Removed `crypto-js` and `@types/crypto-js` from dependencies +- Updated Security Policy: 5.0.x is now a supported version +- Updated PR template to reference GitHub Actions instead of Travis/Circle CI +- Expanded test suite from 32 to 109 tests with 97.8% statement coverage + #### v5.0.0 - Rebranded project name from WrapSplashJS to WrapSplashTS to reflect TypeScript-first development - Fixed missing type definitions for `WrapSplashResponse` and `WrapSplashError` class @@ -197,8 +223,6 @@ This library depends on [axios](https://www.npmjs.com/package/axios) and [crypto - Integrated Codecov for automated code coverage tracking via GitHub Actions - Added V8 coverage provider with multiple output formats (text, LCOV, JSON, HTML) - Enforced coverage thresholds: 80% lines/functions/statements, 55% branches -- All 30 tests passing with verified production-ready code quality -- **Security:** Resolved all npm audit vulnerabilities (0 vulnerabilities) #### v4.2.0 - Added clearer convenience methods such as `getPhoto`, `getRandomPhoto`, `createCollection`, and `updateCollection` diff --git a/SECURITY.md b/SECURITY.md index 034e848..23cf4e9 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,20 +2,13 @@ ## Supported Versions -Use this section to tell people about which versions of your project are -currently being supported with security updates. - | Version | Supported | | ------- | ------------------ | | 5.1.x | :white_check_mark: | -| 5.0.x | :x: | -| 4.0.x | :white_check_mark: | +| 5.0.x | :white_check_mark: | +| 4.0.x | :x: | | < 4.0 | :x: | ## Reporting a Vulnerability -Use this section to tell people how to report a vulnerability. - -Tell them where to go, how often they can expect to get an update on a -reported vulnerability, what to expect if the vulnerability is accepted or -declined, etc. +If you discover a security vulnerability within WrapSplash, please send an email to Sandeep Vattapparambil via [GitHub](https://github.com/SandeepVattapparambil). All security vulnerabilities will be promptly addressed. diff --git a/dist/badge.png b/dist/badge.png new file mode 100644 index 0000000..1efd8b4 Binary files /dev/null and b/dist/badge.png differ diff --git a/dist/types/lib/axiosAjaxLib.d.ts b/dist/types/lib/axiosAjaxLib.d.ts index 7a8d1bc..b37619f 100644 --- a/dist/types/lib/axiosAjaxLib.d.ts +++ b/dist/types/lib/axiosAjaxLib.d.ts @@ -9,6 +9,8 @@ declare class AxiosAjax { private retryDelayMs; constructor(options?: AxiosAjaxOptions); private sleep; + private isRetryableError; + private getRetryDelay; makeRequest(url: string, method: string, queryParameters?: Record, body?: unknown): Promise>; } export default AxiosAjax; diff --git a/dist/wrapsplash.es.js b/dist/wrapsplash.es.js index 3583814..567b9ae 100644 --- a/dist/wrapsplash.es.js +++ b/dist/wrapsplash.es.js @@ -1,227 +1,7 @@ -import e from "axios"; -//#region \0rolldown/runtime.js -var t = Object.create, n = Object.defineProperty, r = Object.getOwnPropertyDescriptor, i = Object.getOwnPropertyNames, a = Object.getPrototypeOf, o = Object.prototype.hasOwnProperty, s = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), c = (e, t, a, s) => { - if (t && typeof t == "object" || typeof t == "function") for (var c = i(t), l = 0, u = c.length, d; l < u; l++) d = c[l], !o.call(e, d) && d !== a && n(e, d, { - get: ((e) => t[e]).bind(null, d), - enumerable: !(s = r(t, d)) || s.enumerable - }); - return e; -}, l = (e, r, i) => (i = e == null ? {} : t(a(e)), c(r || !e || !e.__esModule ? n(i, "default", { - value: e, - enumerable: !0 -}) : i, e)), u = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) { - if (typeof require < "u") return require.apply(this, arguments); - throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details."); -}), d = /* @__PURE__ */ s(((e, t) => { - t.exports = {}; -})), f = /* @__PURE__ */ s(((e, t) => { - (function(n, r) { - typeof e == "object" ? t.exports = e = r() : typeof define == "function" && define.amd ? define([], r) : n.CryptoJS = r(); - })(e, function() { - var e = e || function(e, t) { - var n; - if (typeof window < "u" && window.crypto && (n = window.crypto), typeof self < "u" && self.crypto && (n = self.crypto), typeof globalThis < "u" && globalThis.crypto && (n = globalThis.crypto), !n && typeof window < "u" && window.msCrypto && (n = window.msCrypto), !n && typeof global < "u" && global.crypto && (n = global.crypto), !n && typeof u == "function") try { - n = d(); - } catch {} - var r = function() { - if (n) { - if (typeof n.getRandomValues == "function") try { - return n.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0]; - } catch {} - if (typeof n.randomBytes == "function") try { - return n.randomBytes(4).readInt32LE(); - } catch {} - } - throw Error("Native crypto module could not be used to get secure random number."); - }, i = Object.create || function() { - function e() {} - return function(t) { - var n; - return e.prototype = t, n = new e(), e.prototype = null, n; - }; - }(), a = {}, o = a.lib = {}, s = o.Base = function() { - return { - extend: function(e) { - var t = i(this); - return e && t.mixIn(e), (!t.hasOwnProperty("init") || this.init === t.init) && (t.init = function() { - t.$super.init.apply(this, arguments); - }), t.init.prototype = t, t.$super = this, t; - }, - create: function() { - var e = this.extend(); - return e.init.apply(e, arguments), e; - }, - init: function() {}, - mixIn: function(e) { - for (var t in e) e.hasOwnProperty(t) && (this[t] = e[t]); - e.hasOwnProperty("toString") && (this.toString = e.toString); - }, - clone: function() { - return this.init.prototype.extend(this); - } - }; - }(), c = o.WordArray = s.extend({ - init: function(e, n) { - e = this.words = e || [], n == t ? this.sigBytes = e.length * 4 : this.sigBytes = n; - }, - toString: function(e) { - return (e || f).stringify(this); - }, - concat: function(e) { - var t = this.words, n = e.words, r = this.sigBytes, i = e.sigBytes; - if (this.clamp(), r % 4) for (var a = 0; a < i; a++) { - var o = n[a >>> 2] >>> 24 - a % 4 * 8 & 255; - t[r + a >>> 2] |= o << 24 - (r + a) % 4 * 8; - } - else for (var s = 0; s < i; s += 4) t[r + s >>> 2] = n[s >>> 2]; - return this.sigBytes += i, this; - }, - clamp: function() { - var t = this.words, n = this.sigBytes; - t[n >>> 2] &= 4294967295 << 32 - n % 4 * 8, t.length = e.ceil(n / 4); - }, - clone: function() { - var e = s.clone.call(this); - return e.words = this.words.slice(0), e; - }, - random: function(e) { - for (var t = [], n = 0; n < e; n += 4) t.push(r()); - return new c.init(t, e); - } - }), l = a.enc = {}, f = l.Hex = { - stringify: function(e) { - for (var t = e.words, n = e.sigBytes, r = [], i = 0; i < n; i++) { - var a = t[i >>> 2] >>> 24 - i % 4 * 8 & 255; - r.push((a >>> 4).toString(16)), r.push((a & 15).toString(16)); - } - return r.join(""); - }, - parse: function(e) { - for (var t = e.length, n = [], r = 0; r < t; r += 2) n[r >>> 3] |= parseInt(e.substr(r, 2), 16) << 24 - r % 8 * 4; - return new c.init(n, t / 2); - } - }, p = l.Latin1 = { - stringify: function(e) { - for (var t = e.words, n = e.sigBytes, r = [], i = 0; i < n; i++) { - var a = t[i >>> 2] >>> 24 - i % 4 * 8 & 255; - r.push(String.fromCharCode(a)); - } - return r.join(""); - }, - parse: function(e) { - for (var t = e.length, n = [], r = 0; r < t; r++) n[r >>> 2] |= (e.charCodeAt(r) & 255) << 24 - r % 4 * 8; - return new c.init(n, t); - } - }, m = l.Utf8 = { - stringify: function(e) { - try { - return decodeURIComponent(escape(p.stringify(e))); - } catch { - throw Error("Malformed UTF-8 data"); - } - }, - parse: function(e) { - return p.parse(unescape(encodeURIComponent(e))); - } - }, h = o.BufferedBlockAlgorithm = s.extend({ - reset: function() { - this._data = new c.init(), this._nDataBytes = 0; - }, - _append: function(e) { - typeof e == "string" && (e = m.parse(e)), this._data.concat(e), this._nDataBytes += e.sigBytes; - }, - _process: function(t) { - var n, r = this._data, i = r.words, a = r.sigBytes, o = this.blockSize, s = a / (o * 4); - s = t ? e.ceil(s) : e.max((s | 0) - this._minBufferSize, 0); - var l = s * o, u = e.min(l * 4, a); - if (l) { - for (var d = 0; d < l; d += o) this._doProcessBlock(i, d); - n = i.splice(0, l), r.sigBytes -= u; - } - return new c.init(n, u); - }, - clone: function() { - var e = s.clone.call(this); - return e._data = this._data.clone(), e; - }, - _minBufferSize: 0 - }); - o.Hasher = h.extend({ - cfg: s.extend(), - init: function(e) { - this.cfg = this.cfg.extend(e), this.reset(); - }, - reset: function() { - h.reset.call(this), this._doReset(); - }, - update: function(e) { - return this._append(e), this._process(), this; - }, - finalize: function(e) { - return e && this._append(e), this._doFinalize(); - }, - blockSize: 512 / 32, - _createHelper: function(e) { - return function(t, n) { - return new e.init(n).finalize(t); - }; - }, - _createHmacHelper: function(e) { - return function(t, n) { - return new g.HMAC.init(e, n).finalize(t); - }; - } - }); - var g = a.algo = {}; - return a; - }(Math); - return e; - }); -})), p = /* @__PURE__ */ l((/* @__PURE__ */ s(((e, t) => { - (function(n, r) { - typeof e == "object" ? t.exports = e = r(f()) : typeof define == "function" && define.amd ? define(["./core"], r) : r(n.CryptoJS); - })(e, function(e) { - return (function(t) { - var n = e, r = n.lib, i = r.WordArray, a = r.Hasher, o = n.algo, s = [], c = []; - (function() { - function e(e) { - for (var n = t.sqrt(e), r = 2; r <= n; r++) if (!(e % r)) return !1; - return !0; - } - function n(e) { - return (e - (e | 0)) * 4294967296 | 0; - } - for (var r = 2, i = 0; i < 64;) e(r) && (i < 8 && (s[i] = n(t.pow(r, 1 / 2))), c[i] = n(t.pow(r, 1 / 3)), i++), r++; - })(); - var l = [], u = o.SHA256 = a.extend({ - _doReset: function() { - this._hash = new i.init(s.slice(0)); - }, - _doProcessBlock: function(e, t) { - for (var n = this._hash.words, r = n[0], i = n[1], a = n[2], o = n[3], s = n[4], u = n[5], d = n[6], f = n[7], p = 0; p < 64; p++) { - if (p < 16) l[p] = e[t + p] | 0; - else { - var m = l[p - 15], h = (m << 25 | m >>> 7) ^ (m << 14 | m >>> 18) ^ m >>> 3, g = l[p - 2], _ = (g << 15 | g >>> 17) ^ (g << 13 | g >>> 19) ^ g >>> 10; - l[p] = h + l[p - 7] + _ + l[p - 16]; - } - var v = s & u ^ ~s & d, y = r & i ^ r & a ^ i & a, b = (r << 30 | r >>> 2) ^ (r << 19 | r >>> 13) ^ (r << 10 | r >>> 22), x = (s << 26 | s >>> 6) ^ (s << 21 | s >>> 11) ^ (s << 7 | s >>> 25), S = f + x + v + c[p] + l[p], C = b + y; - f = d, d = u, u = s, s = o + S | 0, o = a, a = i, i = r, r = S + C | 0; - } - n[0] = n[0] + r | 0, n[1] = n[1] + i | 0, n[2] = n[2] + a | 0, n[3] = n[3] + o | 0, n[4] = n[4] + s | 0, n[5] = n[5] + u | 0, n[6] = n[6] + d | 0, n[7] = n[7] + f | 0; - }, - _doFinalize: function() { - var e = this._data, n = e.words, r = this._nDataBytes * 8, i = e.sigBytes * 8; - return n[i >>> 5] |= 128 << 24 - i % 32, n[(i + 64 >>> 9 << 4) + 14] = t.floor(r / 4294967296), n[(i + 64 >>> 9 << 4) + 15] = r, e.sigBytes = n.length * 4, this._process(), this._hash; - }, - clone: function() { - var e = a.clone.call(this); - return e._hash = this._hash.clone(), e; - } - }); - n.SHA256 = a._createHelper(u), n.HmacSHA256 = a._createHmacHelper(u); - })(Math), e.SHA256; - }); -})))()), m = { +import { createHash as e } from "crypto"; +import t from "axios"; +//#region config/axiosConfig.ts +var n = { url: "", method: "", baseURL: "", @@ -236,15 +16,33 @@ var t = Object.create, n = Object.defineProperty, r = Object.getOwnPropertyDescr }, maxRedirects: 5, socketPath: null -}, h = class { +}, r = class { http; retries; retryDelayMs; - constructor(t) { - this.http = e.create(t || m), this.retries = t?.retries ?? 2, this.retryDelayMs = t?.retryDelayMs ?? 100; + constructor(e) { + this.http = t.create(e || n), this.retries = e?.retries ?? 2, this.retryDelayMs = e?.retryDelayMs ?? 100; } - async sleep(e) { - await new Promise((t) => setTimeout(t, e)); + sleep(e) { + return new Promise((t) => setTimeout(t, e)); + } + isRetryableError(e) { + if (t.isCancel(e)) return !1; + let n = e; + if (!n.response) return !0; + let r = n.response.status; + return r === 429 || r >= 500; + } + getRetryDelay(e, t) { + let n = e; + if (n.response) { + let e = n.response.headers?.["retry-after"]; + if (e) { + let t = Number(e); + if (!Number.isNaN(t) && t > 0) return t * 1e3; + } + } + return this.retryDelayMs * 2 ** t; } async makeRequest(e, t, n, r) { if (!e) throw Error("URL required"); @@ -257,12 +55,13 @@ var t = Object.create, n = Object.defineProperty, r = Object.getOwnPropertyDescr data: r }); } catch (e) { - if (i = e, a >= this.retries) throw e; - this.retryDelayMs > 0 && await this.sleep(this.retryDelayMs); + if (i = e, a >= this.retries || !this.isRetryableError(e)) throw e; + let t = this.getRetryDelay(e, a); + t > 0 && await this.sleep(t); } throw i; } -}, g = { +}, i = { API_LOCATION: "https://api.unsplash.com/", BEARER_TOKEN_URL: "https://unsplash.com/oauth/token", USERS_PUBLIC_PROFILE: "users/", @@ -300,13 +99,13 @@ var t = Object.create, n = Object.defineProperty, r = Object.getOwnPropertyDescr DELETE_COLLECTION: "collections/:id", ADD_PHOTO_TO_COLLECTION: "collections/:collection_id/add", REMOVE_PHOTO_FROM_COLLECTION: "collections/:collection_id/remove" -}, _ = class extends Error { +}, a = class extends Error { constructor(e, t, n, r) { super(e), this.name = "WrapSplashError", typeof t == "object" && t && !Array.isArray(t) ? (this.cause = t.cause, this.statusCode = t.statusCode, this.statusText = t.statusText) : typeof t == "number" && (this.statusCode = t, this.statusText = n, this.cause = r), Object.setPrototypeOf(this, new.target.prototype); } -}, v = class { +}, o = class { constructor() { - this.API_LOCATION = g.API_LOCATION, this.BEARER_TOKEN_URL = g.BEARER_TOKEN_URL, this.options = {}, this.access_key = "", this.secret_key = "", this.redirect_uri = "", this.code = "", this.grant_type = "authorization_code", this.bearer_token = "", this.timeout = 1e4, this.retries = 2, this.retryDelayMs = 100, this.headers = { + this.API_LOCATION = i.API_LOCATION, this.BEARER_TOKEN_URL = i.BEARER_TOKEN_URL, this.options = {}, this.access_key = "", this.secret_key = "", this.redirect_uri = "", this.code = "", this.grant_type = "authorization_code", this.bearer_token = "", this.timeout = 1e4, this.retries = 2, this.retryDelayMs = 100, this.headers = { "Content-type": "application/json", "X-Requested-With": "WrapSplash" }, this.availableOrders = [ @@ -318,7 +117,7 @@ var t = Object.create, n = Object.defineProperty, r = Object.getOwnPropertyDescr "portrait", "squarish" ], this.init = (e = {}) => { - if (!e || typeof e != "object" || Array.isArray(e)) throw new _("Initialisation parameters required!"); + if (!e || typeof e != "object" || Array.isArray(e)) throw new a("Initialisation parameters required!"); if (this.options = { ...e }, this.timeout = typeof this.options.timeout == "number" && this.options.timeout > 0 ? this.options.timeout : 1e4, this.retries = typeof this.options.retries == "number" && this.options.retries >= 0 ? this.options.retries : 2, this.retryDelayMs = typeof this.options.retryDelayMs == "number" && this.options.retryDelayMs >= 0 ? this.options.retryDelayMs : 100, this.bearer_token = this.options.bearer_token ?? "", this.headers = { "Content-type": "application/json", "X-Requested-With": "WrapSplash" @@ -331,13 +130,13 @@ var t = Object.create, n = Object.defineProperty, r = Object.getOwnPropertyDescr return; } this.access_key = this.options.access_key ? this.options.access_key : (() => { - throw new _("Access Key missing!"); + throw new a("Access Key missing!"); })(), this.secret_key = this.options.secret_key ? this.options.secret_key : (() => { - throw new _("Secret Key missing!"); + throw new a("Secret Key missing!"); })(), this.redirect_uri = this.options.redirect_uri ? this.options.redirect_uri : (() => { - throw new _("Redirect URI missing!"); + throw new a("Redirect URI missing!"); })(), this.code = this.options.code ? this.options.code : (() => { - throw new _("Authorization Code missing!"); + throw new a("Authorization Code missing!"); })(), this.headers = { ...this.headers, Authorization: `Client-ID ${this.options.access_key}`, @@ -349,69 +148,69 @@ var t = Object.create, n = Object.defineProperty, r = Object.getOwnPropertyDescr redirect_uri: this.redirect_uri, code: this.code, grant_type: this.grant_type - })), this.getCurrentUserProfile = () => this.fetchUrl(this.API_LOCATION + g.CURRENT_USER_PROFILE, "GET"), this.updateCurrentUserProfile = (e, t, n, r, i, a, o, s) => this.fetchUrl(this.API_LOCATION + g.UPDATE_CURRENT_USER_PROFILE, "PUT", { + })), this.getCurrentUserProfile = () => this.fetchUrl(this.API_LOCATION + i.CURRENT_USER_PROFILE, "GET"), this.updateCurrentUserProfile = (e, t, n, r, a, o, s, c) => this.fetchUrl(this.API_LOCATION + i.UPDATE_CURRENT_USER_PROFILE, "PUT", { username: e, first_name: t, last_name: n, email: r, - url: i, - location: a, - bio: o, - instagram_username: s - }), this.getPublicProfile = (e, t, n) => (this.validateRequired(e, "username"), this.fetchUrl(this.API_LOCATION + g.USERS_PUBLIC_PROFILE + e, "GET", { + url: a, + location: o, + bio: s, + instagram_username: c + }), this.getPublicProfile = (e, t, n) => (this.validateRequired(e, "username"), this.fetchUrl(this.API_LOCATION + i.USERS_PUBLIC_PROFILE + e, "GET", { w: t, h: n - })), this.getUserPortfolio = (e) => (this.validateRequired(e, "username"), this.fetchUrl(this.API_LOCATION + g.USERS_PORTFOLIO.replace(/:username/gi, e), "GET")), this.getUserPhotos = (e, t, n, r, i, a, o) => { - if (this.validateRequired(e, "username"), this.validateSupportedValue(o, this.availableOrders, "order_by"), r !== void 0 && typeof r != "boolean") throw new _("Parameter : stats is a boolean or optional!"); - return this.fetchUrl(this.API_LOCATION + g.USERS_PHOTOS.replace(/:username/gi, e), "GET", { + })), this.getUserPortfolio = (e) => (this.validateRequired(e, "username"), this.fetchUrl(this.API_LOCATION + i.USERS_PORTFOLIO.replace(/:username/gi, e), "GET")), this.getUserPhotos = (e, t, n, r, o, s, c) => { + if (this.validateRequired(e, "username"), this.validateSupportedValue(c, this.availableOrders, "order_by"), r !== void 0 && typeof r != "boolean") throw new a("Parameter : stats is a boolean or optional!"); + return this.fetchUrl(this.API_LOCATION + i.USERS_PHOTOS.replace(/:username/gi, e), "GET", { page: t ?? 1, per_page: n ?? 10, - order_by: o ?? "latest", + order_by: c ?? "latest", stats: r ?? !1, - resolution: i ?? "days", - quantity: a ?? 30 + resolution: o ?? "days", + quantity: s ?? 30 }); - }, this.getUserLikedPhotos = (e, t, n, r) => (this.validateRequired(e, "username"), this.validateSupportedValue(r, this.availableOrders, "order_by"), this.fetchUrl(this.API_LOCATION + g.USERS_LIKED_PHOTOS.replace(/:username/gi, e), "GET", { + }, this.getUserLikedPhotos = (e, t, n, r) => (this.validateRequired(e, "username"), this.validateSupportedValue(r, this.availableOrders, "order_by"), this.fetchUrl(this.API_LOCATION + i.USERS_LIKED_PHOTOS.replace(/:username/gi, e), "GET", { page: t ?? 1, per_page: n ?? 10, order_by: r ?? "latest" - })), this.getUserCollections = (e, t, n) => (this.validateRequired(e, "username"), this.fetchUrl(this.API_LOCATION + g.USERS_COLLECTIONS.replace(/:username/gi, e), "GET", { + })), this.getUserCollections = (e, t, n) => (this.validateRequired(e, "username"), this.fetchUrl(this.API_LOCATION + i.USERS_COLLECTIONS.replace(/:username/gi, e), "GET", { page: t ?? 1, per_page: n ?? 10 - })), this.getUserStatistics = (e, t, n) => (this.validateRequired(e, "username"), this.fetchUrl(this.API_LOCATION + g.USERS_STATISTICS.replace(/:username/gi, e), "GET", { + })), this.getUserStatistics = (e, t, n) => (this.validateRequired(e, "username"), this.fetchUrl(this.API_LOCATION + i.USERS_STATISTICS.replace(/:username/gi, e), "GET", { resolution: t ?? "days", quantity: n ?? 30 })), this.listPhotos = (e, t, n) => { - if (n !== void 0 && !this.availableOrders.includes(n)) throw new _("Parameter : order_by has an unsupported value!"); - return this.fetchUrl(this.API_LOCATION + g.LIST_PHOTOS, "GET", { + if (n !== void 0 && !this.availableOrders.includes(n)) throw new a("Parameter : order_by has an unsupported value!"); + return this.fetchUrl(this.API_LOCATION + i.LIST_PHOTOS, "GET", { page: e ?? 1, per_page: t ?? 10, order_by: n ?? "latest" }); }, this.listCuratedPhotos = (e, t, n) => { - if (n !== void 0 && !this.availableOrders.includes(n)) throw new _("Parameter : order_by has an unsupported value!"); - return this.fetchUrl(this.API_LOCATION + g.LIST_CURATED_PHOTOS, "GET", { + if (n !== void 0 && !this.availableOrders.includes(n)) throw new a("Parameter : order_by has an unsupported value!"); + return this.fetchUrl(this.API_LOCATION + i.LIST_CURATED_PHOTOS, "GET", { page: e ?? 1, per_page: t ?? 10, order_by: n ?? "latest" }); - }, this.getAPhoto = (e, t, n, r) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + g.GET_A_PHOTO.replace(/:id/gi, e), "GET", { + }, this.getAPhoto = (e, t, n, r) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + i.GET_A_PHOTO.replace(/:id/gi, e), "GET", { w: t, h: n, rect: typeof r == "string" ? r : void 0 - })), this.getARandomPhoto = (e, t, n, r, i, a, o, s) => (this.validateSupportedValue(o, this.availableOrientations, "orientation"), this.fetchUrl(this.API_LOCATION + g.GET_A_RANDOM_PHOTO, "GET", { + })), this.getARandomPhoto = (e, t, n, r, a, o, s, c) => (this.validateSupportedValue(s, this.availableOrientations, "orientation"), this.fetchUrl(this.API_LOCATION + i.GET_A_RANDOM_PHOTO, "GET", { collections: e === void 0 ? void 0 : String(e), featured: t ?? !1, username: n, query: r, - width: i, - height: a, - orientation: o ?? "landscape", - count: s ?? 1 - })), this.getPhotoStatistics = (e, t, n) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + g.GET_A_PHOTO_STATISTICS.replace(/:id/gi, e), "GET", { + width: a, + height: o, + orientation: s ?? "landscape", + count: c ?? 1 + })), this.getPhotoStatistics = (e, t, n) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + i.GET_A_PHOTO_STATISTICS.replace(/:id/gi, e), "GET", { resolution: t ?? "days", quantity: n ?? 30 - })), this.getPhotoLink = (e) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + g.GET_A_PHOTO_DOWNLOAD_LINK.replace(/:id/gi, e), "GET")), this.updatePhoto = (e, t = {}, n = {}) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + g.UPDATE_A_PHOTO.replace(/:id/gi, e), "PUT", { + })), this.getPhotoLink = (e) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + i.GET_A_PHOTO_DOWNLOAD_LINK.replace(/:id/gi, e), "GET")), this.updatePhoto = (e, t = {}, n = {}) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + i.UPDATE_A_PHOTO.replace(/:id/gi, e), "PUT", { ...t.latitude ? { "location[latitude]": t.latitude } : {}, ...t.longitude ? { "location[longitude]": t.longitude } : {}, ...t.name ? { "location[name]": t.name } : {}, @@ -424,53 +223,53 @@ var t = Object.create, n = Object.defineProperty, r = Object.getOwnPropertyDescr ...n.aperture_value ? { "exif[aperture_value]": n.aperture_value } : {}, ...n.focal_length ? { "exif[focal_length]": n.focal_length } : {}, ...n.iso_speed_ratings ? { "exif[iso_speed_ratings]": n.iso_speed_ratings } : {} - })), this.likePhoto = (e) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + g.LIKE_A_PHOTO.replace(/:id/gi, e), "POST")), this.unlikePhoto = (e) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + g.UNLIKE_A_PHOTO.replace(/:id/gi, e), "DELETE")), this.search = (e, t, n, r, i) => (this.validateRequired(e, "query"), this.validateSupportedValue(i, this.availableOrientations, "orientation"), this.fetchUrl(this.API_LOCATION + g.SEARCH_PHOTOS, "GET", { + })), this.likePhoto = (e) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + i.LIKE_A_PHOTO.replace(/:id/gi, e), "POST")), this.unlikePhoto = (e) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + i.UNLIKE_A_PHOTO.replace(/:id/gi, e), "DELETE")), this.search = (e, t, n, r, a) => (this.validateRequired(e, "query"), this.validateSupportedValue(a, this.availableOrientations, "orientation"), this.fetchUrl(this.API_LOCATION + i.SEARCH_PHOTOS, "GET", { query: e, page: t ?? 1, per_page: n ?? 10, collections: r === void 0 ? void 0 : String(r), - orientation: i - })), this.searchCollections = (e, t, n) => (this.validateRequired(e, "query"), this.fetchUrl(this.API_LOCATION + g.SEARCH_COLLECTIONS, "GET", { + orientation: a + })), this.searchCollections = (e, t, n) => (this.validateRequired(e, "query"), this.fetchUrl(this.API_LOCATION + i.SEARCH_COLLECTIONS, "GET", { query: e, page: t ?? 1, per_page: n ?? 10 - })), this.searchUsers = (e, t, n) => (this.validateRequired(e, "query"), this.fetchUrl(this.API_LOCATION + g.SEARCH_USERS, "GET", { + })), this.searchUsers = (e, t, n) => (this.validateRequired(e, "query"), this.fetchUrl(this.API_LOCATION + i.SEARCH_USERS, "GET", { query: e, page: t ?? 1, per_page: n ?? 10 - })), this.getStatsTotals = () => this.fetchUrl(this.API_LOCATION + g.STATS_TOTALS, "GET"), this.getStatsMonth = () => this.fetchUrl(this.API_LOCATION + g.STATS_MONTH, "GET"), this.listCollections = (e, t) => this.fetchUrl(this.API_LOCATION + g.LIST_COLLECTIONS, "GET", { + })), this.getStatsTotals = () => this.fetchUrl(this.API_LOCATION + i.STATS_TOTALS, "GET"), this.getStatsMonth = () => this.fetchUrl(this.API_LOCATION + i.STATS_MONTH, "GET"), this.listCollections = (e, t) => this.fetchUrl(this.API_LOCATION + i.LIST_COLLECTIONS, "GET", { page: e ?? 1, per_page: t ?? 10 - }), this.listFeaturedCollections = (e, t) => this.fetchUrl(this.API_LOCATION + g.LIST_FEATURED_COLLECTIONS, "GET", { + }), this.listFeaturedCollections = (e, t) => this.fetchUrl(this.API_LOCATION + i.LIST_FEATURED_COLLECTIONS, "GET", { page: e ?? 1, per_page: t ?? 10 - }), this.listCuratedCollections = (e, t) => this.fetchUrl(this.API_LOCATION + g.LIST_CURATED_COLLECTIONS, "GET", { + }), this.listCuratedCollections = (e, t) => this.fetchUrl(this.API_LOCATION + i.LIST_CURATED_COLLECTIONS, "GET", { page: e ?? 1, per_page: t ?? 10 - }), this.getCollection = (e) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + g.GET_COLLECTION.replace(/:id/gi, e), "GET")), this.getCuratedCollection = (e) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + g.GET_CURATED_COLLECTION.replace(/:id/gi, e), "GET")), this.getCollectionPhotos = (e, t, n) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + g.GET_COLLECTION_PHOTOS.replace(/:id/gi, e), "GET", { + }), this.getCollection = (e) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + i.GET_COLLECTION.replace(/:id/gi, e), "GET")), this.getCuratedCollection = (e) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + i.GET_CURATED_COLLECTION.replace(/:id/gi, e), "GET")), this.getCollectionPhotos = (e, t, n) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + i.GET_COLLECTION_PHOTOS.replace(/:id/gi, e), "GET", { page: t ?? 1, per_page: n ?? 10 - })), this.getCuratedCollectionPhotos = (e, t, n) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + g.GET_CURATED_COLLECTION_PHOTOS.replace(/:id/gi, e), "GET", { + })), this.getCuratedCollectionPhotos = (e, t, n) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + i.GET_CURATED_COLLECTION_PHOTOS.replace(/:id/gi, e), "GET", { page: t ?? 1, per_page: n ?? 10 - })), this.listRelatedCollections = (e) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + g.LIST_RELATED_COLLECTION.replace(/:id/gi, e), "GET")), this.getPhoto = (e, t, n, r) => this.getAPhoto(e, t, n, r), this.getRandomPhoto = (e, t, n, r, i, a, o, s) => this.getARandomPhoto(e, t, n, r, i, a, o, s), this.createNewCollection = (e, t, n = !1) => (this.validateRequired(e, "title"), this.fetchUrl(this.API_LOCATION + g.CREATE_NEW_COLLECTION, "POST", { + })), this.listRelatedCollections = (e) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + i.LIST_RELATED_COLLECTION.replace(/:id/gi, e), "GET")), this.getPhoto = (e, t, n, r) => this.getAPhoto(e, t, n, r), this.getRandomPhoto = (e, t, n, r, i, a, o, s) => this.getARandomPhoto(e, t, n, r, i, a, o, s), this.createNewCollection = (e, t, n = !1) => (this.validateRequired(e, "title"), this.fetchUrl(this.API_LOCATION + i.CREATE_NEW_COLLECTION, "POST", { title: e, description: t, private: n - })), this.createCollection = (e, t, n = !1) => this.createNewCollection(e, t, n), this.createNewColection = (e, t, n = !1) => this.createNewCollection(e, t, n), this.updateExistingCollection = (e, t, n, r = !1) => (this.validateRequired(e, "id"), this.validateRequired(t, "title"), this.fetchUrl(this.API_LOCATION + g.UPDATE_EXISTING_COLLECTION.replace(/:id/gi, e), "PUT", { + })), this.createCollection = (e, t, n = !1) => this.createNewCollection(e, t, n), this.createNewColection = (e, t, n = !1) => this.createNewCollection(e, t, n), this.updateExistingCollection = (e, t, n, r = !1) => (this.validateRequired(e, "id"), this.validateRequired(t, "title"), this.fetchUrl(this.API_LOCATION + i.UPDATE_EXISTING_COLLECTION.replace(/:id/gi, e), "PUT", { title: t, description: n, private: r - })), this.updateCollection = (e, t, n, r = !1) => this.updateExistingCollection(e, t, n, r), this.deleteCollection = (e) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + g.DELETE_COLLECTION.replace(/:id/gi, e), "DELETE")), this.addPhotoToCollection = (e, t) => (this.validateRequired(e, "collection_id"), this.validateRequired(t, "photo_id"), this.fetchUrl(this.API_LOCATION + g.ADD_PHOTO_TO_COLLECTION.replace(/:collection_id/gi, e), "POST", { photo_id: t })), this.removePhotoFromCollection = (e, t) => (this.validateRequired(e, "collection_id"), this.validateRequired(t, "photo_id"), this.fetchUrl(this.API_LOCATION + g.REMOVE_PHOTO_FROM_COLLECTION.replace(/:collection_id/gi, e), "DELETE", { photo_id: t })); + })), this.updateCollection = (e, t, n, r = !1) => this.updateExistingCollection(e, t, n, r), this.deleteCollection = (e) => (this.validateRequired(e, "id"), this.fetchUrl(this.API_LOCATION + i.DELETE_COLLECTION.replace(/:id/gi, e), "DELETE")), this.addPhotoToCollection = (e, t) => (this.validateRequired(e, "collection_id"), this.validateRequired(t, "photo_id"), this.fetchUrl(this.API_LOCATION + i.ADD_PHOTO_TO_COLLECTION.replace(/:collection_id/gi, e), "POST", { photo_id: t })), this.removePhotoFromCollection = (e, t) => (this.validateRequired(e, "collection_id"), this.validateRequired(t, "photo_id"), this.fetchUrl(this.API_LOCATION + i.REMOVE_PHOTO_FROM_COLLECTION.replace(/:collection_id/gi, e), "DELETE", { photo_id: t })); } - computeHash(e) { - return (0, p.default)(e).toString(); + computeHash(t) { + return e("sha256").update(t).digest("hex"); } validateRequired(e, t) { - if (e == null || e === "") throw new _(t === "id" ? "Parameter : id is required!" : t === "query" ? "Parameter : query is missing!" : `Parameter : ${t} is required and cannot be empty!`); + if (e == null || e === "") throw new a(t === "id" ? "Parameter : id is required!" : t === "query" ? "Parameter : query is missing!" : `Parameter : ${t} is required and cannot be empty!`); } validateSupportedValue(e, t, n) { - if (e !== void 0 && !t.includes(e)) throw new _(`Parameter : ${n} has an unsupported value!`); + if (e !== void 0 && !t.includes(e)) throw new a(`Parameter : ${n} has an unsupported value!`); } buildQueryParameters(e) { let t = {}; @@ -482,21 +281,21 @@ var t = Object.create, n = Object.defineProperty, r = Object.getOwnPropertyDescr return e instanceof Error ? e.message : typeof e == "string" ? e : "Request failed"; } createWrapSplashError(e) { - if (e instanceof _) return e; + if (e instanceof a) return e; let t = typeof e == "object" && e && "response" in e && e.response && typeof e.response == "object" && "status" in e.response ? e.response.status : void 0, n = typeof e == "object" && e && "response" in e && e.response && typeof e.response == "object" && "statusText" in e.response ? e.response.statusText : void 0; - return new _(this.getErrorMessage(e), { + return new a(this.getErrorMessage(e), { cause: e, statusCode: t, statusText: n }); } - fetchUrl(e, t, n = {}, r = void 0) { - return new h({ + fetchUrl(e, t, n = {}, i = void 0) { + return new r({ headers: this.headers, timeout: this.timeout, retries: this.retries, retryDelayMs: this.retryDelayMs - }).makeRequest(e, t.toLowerCase(), this.buildQueryParameters(n), r).then((e) => { + }).makeRequest(e, t.toLowerCase(), this.buildQueryParameters(n), i).then((e) => { let t = e; return t.status === 204 ? { status: t.status, @@ -511,6 +310,6 @@ var t = Object.create, n = Object.defineProperty, r = Object.getOwnPropertyDescr } }; //#endregion -export { _ as WrapSplashError, v as default }; +export { a as WrapSplashError, o as default }; //# sourceMappingURL=wrapsplash.es.js.map \ No newline at end of file diff --git a/dist/wrapsplash.es.js.map b/dist/wrapsplash.es.js.map index 927d809..b0ade9e 100644 --- a/dist/wrapsplash.es.js.map +++ b/dist/wrapsplash.es.js.map @@ -1 +1 @@ -{"version":3,"file":"wrapsplash.es.js","names":[],"sources":["../__vite-browser-external","../node_modules/crypto-js/core.js","../node_modules/crypto-js/sha256.js","../config/axiosConfig.ts","../lib/axiosAjaxLib.ts","../config/url_config.json","../src/index.ts"],"sourcesContent":["module.exports = {}",";(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory();\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\troot.CryptoJS = factory();\n\t}\n}(this, function () {\n\n\t/*globals window, global, require*/\n\n\t/**\n\t * CryptoJS core components.\n\t */\n\tvar CryptoJS = CryptoJS || (function (Math, undefined) {\n\n\t var crypto;\n\n\t // Native crypto from window (Browser)\n\t if (typeof window !== 'undefined' && window.crypto) {\n\t crypto = window.crypto;\n\t }\n\n\t // Native crypto in web worker (Browser)\n\t if (typeof self !== 'undefined' && self.crypto) {\n\t crypto = self.crypto;\n\t }\n\n\t // Native crypto from worker\n\t if (typeof globalThis !== 'undefined' && globalThis.crypto) {\n\t crypto = globalThis.crypto;\n\t }\n\n\t // Native (experimental IE 11) crypto from window (Browser)\n\t if (!crypto && typeof window !== 'undefined' && window.msCrypto) {\n\t crypto = window.msCrypto;\n\t }\n\n\t // Native crypto from global (NodeJS)\n\t if (!crypto && typeof global !== 'undefined' && global.crypto) {\n\t crypto = global.crypto;\n\t }\n\n\t // Native crypto import via require (NodeJS)\n\t if (!crypto && typeof require === 'function') {\n\t try {\n\t crypto = require('crypto');\n\t } catch (err) {}\n\t }\n\n\t /*\n\t * Cryptographically secure pseudorandom number generator\n\t *\n\t * As Math.random() is cryptographically not safe to use\n\t */\n\t var cryptoSecureRandomInt = function () {\n\t if (crypto) {\n\t // Use getRandomValues method (Browser)\n\t if (typeof crypto.getRandomValues === 'function') {\n\t try {\n\t return crypto.getRandomValues(new Uint32Array(1))[0];\n\t } catch (err) {}\n\t }\n\n\t // Use randomBytes method (NodeJS)\n\t if (typeof crypto.randomBytes === 'function') {\n\t try {\n\t return crypto.randomBytes(4).readInt32LE();\n\t } catch (err) {}\n\t }\n\t }\n\n\t throw new Error('Native crypto module could not be used to get secure random number.');\n\t };\n\n\t /*\n\t * Local polyfill of Object.create\n\n\t */\n\t var create = Object.create || (function () {\n\t function F() {}\n\n\t return function (obj) {\n\t var subtype;\n\n\t F.prototype = obj;\n\n\t subtype = new F();\n\n\t F.prototype = null;\n\n\t return subtype;\n\t };\n\t }());\n\n\t /**\n\t * CryptoJS namespace.\n\t */\n\t var C = {};\n\n\t /**\n\t * Library namespace.\n\t */\n\t var C_lib = C.lib = {};\n\n\t /**\n\t * Base object for prototypal inheritance.\n\t */\n\t var Base = C_lib.Base = (function () {\n\n\n\t return {\n\t /**\n\t * Creates a new object that inherits from this object.\n\t *\n\t * @param {Object} overrides Properties to copy into the new object.\n\t *\n\t * @return {Object} The new object.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var MyType = CryptoJS.lib.Base.extend({\n\t * field: 'value',\n\t *\n\t * method: function () {\n\t * }\n\t * });\n\t */\n\t extend: function (overrides) {\n\t // Spawn\n\t var subtype = create(this);\n\n\t // Augment\n\t if (overrides) {\n\t subtype.mixIn(overrides);\n\t }\n\n\t // Create default initializer\n\t if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {\n\t subtype.init = function () {\n\t subtype.$super.init.apply(this, arguments);\n\t };\n\t }\n\n\t // Initializer's prototype is the subtype object\n\t subtype.init.prototype = subtype;\n\n\t // Reference supertype\n\t subtype.$super = this;\n\n\t return subtype;\n\t },\n\n\t /**\n\t * Extends this object and runs the init method.\n\t * Arguments to create() will be passed to init().\n\t *\n\t * @return {Object} The new object.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var instance = MyType.create();\n\t */\n\t create: function () {\n\t var instance = this.extend();\n\t instance.init.apply(instance, arguments);\n\n\t return instance;\n\t },\n\n\t /**\n\t * Initializes a newly created object.\n\t * Override this method to add some logic when your objects are created.\n\t *\n\t * @example\n\t *\n\t * var MyType = CryptoJS.lib.Base.extend({\n\t * init: function () {\n\t * // ...\n\t * }\n\t * });\n\t */\n\t init: function () {\n\t },\n\n\t /**\n\t * Copies properties into this object.\n\t *\n\t * @param {Object} properties The properties to mix in.\n\t *\n\t * @example\n\t *\n\t * MyType.mixIn({\n\t * field: 'value'\n\t * });\n\t */\n\t mixIn: function (properties) {\n\t for (var propertyName in properties) {\n\t if (properties.hasOwnProperty(propertyName)) {\n\t this[propertyName] = properties[propertyName];\n\t }\n\t }\n\n\t // IE won't copy toString using the loop above\n\t if (properties.hasOwnProperty('toString')) {\n\t this.toString = properties.toString;\n\t }\n\t },\n\n\t /**\n\t * Creates a copy of this object.\n\t *\n\t * @return {Object} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = instance.clone();\n\t */\n\t clone: function () {\n\t return this.init.prototype.extend(this);\n\t }\n\t };\n\t }());\n\n\t /**\n\t * An array of 32-bit words.\n\t *\n\t * @property {Array} words The array of 32-bit words.\n\t * @property {number} sigBytes The number of significant bytes in this word array.\n\t */\n\t var WordArray = C_lib.WordArray = Base.extend({\n\t /**\n\t * Initializes a newly created word array.\n\t *\n\t * @param {Array} words (Optional) An array of 32-bit words.\n\t * @param {number} sigBytes (Optional) The number of significant bytes in the words.\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.lib.WordArray.create();\n\t * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);\n\t * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);\n\t */\n\t init: function (words, sigBytes) {\n\t words = this.words = words || [];\n\n\t if (sigBytes != undefined) {\n\t this.sigBytes = sigBytes;\n\t } else {\n\t this.sigBytes = words.length * 4;\n\t }\n\t },\n\n\t /**\n\t * Converts this word array to a string.\n\t *\n\t * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex\n\t *\n\t * @return {string} The stringified word array.\n\t *\n\t * @example\n\t *\n\t * var string = wordArray + '';\n\t * var string = wordArray.toString();\n\t * var string = wordArray.toString(CryptoJS.enc.Utf8);\n\t */\n\t toString: function (encoder) {\n\t return (encoder || Hex).stringify(this);\n\t },\n\n\t /**\n\t * Concatenates a word array to this word array.\n\t *\n\t * @param {WordArray} wordArray The word array to append.\n\t *\n\t * @return {WordArray} This word array.\n\t *\n\t * @example\n\t *\n\t * wordArray1.concat(wordArray2);\n\t */\n\t concat: function (wordArray) {\n\t // Shortcuts\n\t var thisWords = this.words;\n\t var thatWords = wordArray.words;\n\t var thisSigBytes = this.sigBytes;\n\t var thatSigBytes = wordArray.sigBytes;\n\n\t // Clamp excess bits\n\t this.clamp();\n\n\t // Concat\n\t if (thisSigBytes % 4) {\n\t // Copy one byte at a time\n\t for (var i = 0; i < thatSigBytes; i++) {\n\t var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);\n\t }\n\t } else {\n\t // Copy one word at a time\n\t for (var j = 0; j < thatSigBytes; j += 4) {\n\t thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];\n\t }\n\t }\n\t this.sigBytes += thatSigBytes;\n\n\t // Chainable\n\t return this;\n\t },\n\n\t /**\n\t * Removes insignificant bits.\n\t *\n\t * @example\n\t *\n\t * wordArray.clamp();\n\t */\n\t clamp: function () {\n\t // Shortcuts\n\t var words = this.words;\n\t var sigBytes = this.sigBytes;\n\n\t // Clamp\n\t words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);\n\t words.length = Math.ceil(sigBytes / 4);\n\t },\n\n\t /**\n\t * Creates a copy of this word array.\n\t *\n\t * @return {WordArray} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = wordArray.clone();\n\t */\n\t clone: function () {\n\t var clone = Base.clone.call(this);\n\t clone.words = this.words.slice(0);\n\n\t return clone;\n\t },\n\n\t /**\n\t * Creates a word array filled with random bytes.\n\t *\n\t * @param {number} nBytes The number of random bytes to generate.\n\t *\n\t * @return {WordArray} The random word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.lib.WordArray.random(16);\n\t */\n\t random: function (nBytes) {\n\t var words = [];\n\n\t for (var i = 0; i < nBytes; i += 4) {\n\t words.push(cryptoSecureRandomInt());\n\t }\n\n\t return new WordArray.init(words, nBytes);\n\t }\n\t });\n\n\t /**\n\t * Encoder namespace.\n\t */\n\t var C_enc = C.enc = {};\n\n\t /**\n\t * Hex encoding strategy.\n\t */\n\t var Hex = C_enc.Hex = {\n\t /**\n\t * Converts a word array to a hex string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The hex string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hexString = CryptoJS.enc.Hex.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t // Shortcuts\n\t var words = wordArray.words;\n\t var sigBytes = wordArray.sigBytes;\n\n\t // Convert\n\t var hexChars = [];\n\t for (var i = 0; i < sigBytes; i++) {\n\t var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t hexChars.push((bite >>> 4).toString(16));\n\t hexChars.push((bite & 0x0f).toString(16));\n\t }\n\n\t return hexChars.join('');\n\t },\n\n\t /**\n\t * Converts a hex string to a word array.\n\t *\n\t * @param {string} hexStr The hex string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Hex.parse(hexString);\n\t */\n\t parse: function (hexStr) {\n\t // Shortcut\n\t var hexStrLength = hexStr.length;\n\n\t // Convert\n\t var words = [];\n\t for (var i = 0; i < hexStrLength; i += 2) {\n\t words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);\n\t }\n\n\t return new WordArray.init(words, hexStrLength / 2);\n\t }\n\t };\n\n\t /**\n\t * Latin1 encoding strategy.\n\t */\n\t var Latin1 = C_enc.Latin1 = {\n\t /**\n\t * Converts a word array to a Latin1 string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The Latin1 string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t // Shortcuts\n\t var words = wordArray.words;\n\t var sigBytes = wordArray.sigBytes;\n\n\t // Convert\n\t var latin1Chars = [];\n\t for (var i = 0; i < sigBytes; i++) {\n\t var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t latin1Chars.push(String.fromCharCode(bite));\n\t }\n\n\t return latin1Chars.join('');\n\t },\n\n\t /**\n\t * Converts a Latin1 string to a word array.\n\t *\n\t * @param {string} latin1Str The Latin1 string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);\n\t */\n\t parse: function (latin1Str) {\n\t // Shortcut\n\t var latin1StrLength = latin1Str.length;\n\n\t // Convert\n\t var words = [];\n\t for (var i = 0; i < latin1StrLength; i++) {\n\t words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);\n\t }\n\n\t return new WordArray.init(words, latin1StrLength);\n\t }\n\t };\n\n\t /**\n\t * UTF-8 encoding strategy.\n\t */\n\t var Utf8 = C_enc.Utf8 = {\n\t /**\n\t * Converts a word array to a UTF-8 string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The UTF-8 string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t try {\n\t return decodeURIComponent(escape(Latin1.stringify(wordArray)));\n\t } catch (e) {\n\t throw new Error('Malformed UTF-8 data');\n\t }\n\t },\n\n\t /**\n\t * Converts a UTF-8 string to a word array.\n\t *\n\t * @param {string} utf8Str The UTF-8 string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);\n\t */\n\t parse: function (utf8Str) {\n\t return Latin1.parse(unescape(encodeURIComponent(utf8Str)));\n\t }\n\t };\n\n\t /**\n\t * Abstract buffered block algorithm template.\n\t *\n\t * The property blockSize must be implemented in a concrete subtype.\n\t *\n\t * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0\n\t */\n\t var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({\n\t /**\n\t * Resets this block algorithm's data buffer to its initial state.\n\t *\n\t * @example\n\t *\n\t * bufferedBlockAlgorithm.reset();\n\t */\n\t reset: function () {\n\t // Initial values\n\t this._data = new WordArray.init();\n\t this._nDataBytes = 0;\n\t },\n\n\t /**\n\t * Adds new data to this block algorithm's buffer.\n\t *\n\t * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.\n\t *\n\t * @example\n\t *\n\t * bufferedBlockAlgorithm._append('data');\n\t * bufferedBlockAlgorithm._append(wordArray);\n\t */\n\t _append: function (data) {\n\t // Convert string to WordArray, else assume WordArray already\n\t if (typeof data == 'string') {\n\t data = Utf8.parse(data);\n\t }\n\n\t // Append\n\t this._data.concat(data);\n\t this._nDataBytes += data.sigBytes;\n\t },\n\n\t /**\n\t * Processes available data blocks.\n\t *\n\t * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.\n\t *\n\t * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.\n\t *\n\t * @return {WordArray} The processed data.\n\t *\n\t * @example\n\t *\n\t * var processedData = bufferedBlockAlgorithm._process();\n\t * var processedData = bufferedBlockAlgorithm._process(!!'flush');\n\t */\n\t _process: function (doFlush) {\n\t var processedWords;\n\n\t // Shortcuts\n\t var data = this._data;\n\t var dataWords = data.words;\n\t var dataSigBytes = data.sigBytes;\n\t var blockSize = this.blockSize;\n\t var blockSizeBytes = blockSize * 4;\n\n\t // Count blocks ready\n\t var nBlocksReady = dataSigBytes / blockSizeBytes;\n\t if (doFlush) {\n\t // Round up to include partial blocks\n\t nBlocksReady = Math.ceil(nBlocksReady);\n\t } else {\n\t // Round down to include only full blocks,\n\t // less the number of blocks that must remain in the buffer\n\t nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);\n\t }\n\n\t // Count words ready\n\t var nWordsReady = nBlocksReady * blockSize;\n\n\t // Count bytes ready\n\t var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);\n\n\t // Process blocks\n\t if (nWordsReady) {\n\t for (var offset = 0; offset < nWordsReady; offset += blockSize) {\n\t // Perform concrete-algorithm logic\n\t this._doProcessBlock(dataWords, offset);\n\t }\n\n\t // Remove processed words\n\t processedWords = dataWords.splice(0, nWordsReady);\n\t data.sigBytes -= nBytesReady;\n\t }\n\n\t // Return processed words\n\t return new WordArray.init(processedWords, nBytesReady);\n\t },\n\n\t /**\n\t * Creates a copy of this object.\n\t *\n\t * @return {Object} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = bufferedBlockAlgorithm.clone();\n\t */\n\t clone: function () {\n\t var clone = Base.clone.call(this);\n\t clone._data = this._data.clone();\n\n\t return clone;\n\t },\n\n\t _minBufferSize: 0\n\t });\n\n\t /**\n\t * Abstract hasher template.\n\t *\n\t * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)\n\t */\n\t var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({\n\t /**\n\t * Configuration options.\n\t */\n\t cfg: Base.extend(),\n\n\t /**\n\t * Initializes a newly created hasher.\n\t *\n\t * @param {Object} cfg (Optional) The configuration options to use for this hash computation.\n\t *\n\t * @example\n\t *\n\t * var hasher = CryptoJS.algo.SHA256.create();\n\t */\n\t init: function (cfg) {\n\t // Apply config defaults\n\t this.cfg = this.cfg.extend(cfg);\n\n\t // Set initial values\n\t this.reset();\n\t },\n\n\t /**\n\t * Resets this hasher to its initial state.\n\t *\n\t * @example\n\t *\n\t * hasher.reset();\n\t */\n\t reset: function () {\n\t // Reset data buffer\n\t BufferedBlockAlgorithm.reset.call(this);\n\n\t // Perform concrete-hasher logic\n\t this._doReset();\n\t },\n\n\t /**\n\t * Updates this hasher with a message.\n\t *\n\t * @param {WordArray|string} messageUpdate The message to append.\n\t *\n\t * @return {Hasher} This hasher.\n\t *\n\t * @example\n\t *\n\t * hasher.update('message');\n\t * hasher.update(wordArray);\n\t */\n\t update: function (messageUpdate) {\n\t // Append\n\t this._append(messageUpdate);\n\n\t // Update the hash\n\t this._process();\n\n\t // Chainable\n\t return this;\n\t },\n\n\t /**\n\t * Finalizes the hash computation.\n\t * Note that the finalize operation is effectively a destructive, read-once operation.\n\t *\n\t * @param {WordArray|string} messageUpdate (Optional) A final message update.\n\t *\n\t * @return {WordArray} The hash.\n\t *\n\t * @example\n\t *\n\t * var hash = hasher.finalize();\n\t * var hash = hasher.finalize('message');\n\t * var hash = hasher.finalize(wordArray);\n\t */\n\t finalize: function (messageUpdate) {\n\t // Final message update\n\t if (messageUpdate) {\n\t this._append(messageUpdate);\n\t }\n\n\t // Perform concrete-hasher logic\n\t var hash = this._doFinalize();\n\n\t return hash;\n\t },\n\n\t blockSize: 512/32,\n\n\t /**\n\t * Creates a shortcut function to a hasher's object interface.\n\t *\n\t * @param {Hasher} hasher The hasher to create a helper for.\n\t *\n\t * @return {Function} The shortcut function.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);\n\t */\n\t _createHelper: function (hasher) {\n\t return function (message, cfg) {\n\t return new hasher.init(cfg).finalize(message);\n\t };\n\t },\n\n\t /**\n\t * Creates a shortcut function to the HMAC's object interface.\n\t *\n\t * @param {Hasher} hasher The hasher to use in this HMAC helper.\n\t *\n\t * @return {Function} The shortcut function.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);\n\t */\n\t _createHmacHelper: function (hasher) {\n\t return function (message, key) {\n\t return new C_algo.HMAC.init(hasher, key).finalize(message);\n\t };\n\t }\n\t });\n\n\t /**\n\t * Algorithm namespace.\n\t */\n\t var C_algo = C.algo = {};\n\n\t return C;\n\t}(Math));\n\n\n\treturn CryptoJS;\n\n}));",";(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory(require(\"./core\"));\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([\"./core\"], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\tfactory(root.CryptoJS);\n\t}\n}(this, function (CryptoJS) {\n\n\t(function (Math) {\n\t // Shortcuts\n\t var C = CryptoJS;\n\t var C_lib = C.lib;\n\t var WordArray = C_lib.WordArray;\n\t var Hasher = C_lib.Hasher;\n\t var C_algo = C.algo;\n\n\t // Initialization and round constants tables\n\t var H = [];\n\t var K = [];\n\n\t // Compute constants\n\t (function () {\n\t function isPrime(n) {\n\t var sqrtN = Math.sqrt(n);\n\t for (var factor = 2; factor <= sqrtN; factor++) {\n\t if (!(n % factor)) {\n\t return false;\n\t }\n\t }\n\n\t return true;\n\t }\n\n\t function getFractionalBits(n) {\n\t return ((n - (n | 0)) * 0x100000000) | 0;\n\t }\n\n\t var n = 2;\n\t var nPrime = 0;\n\t while (nPrime < 64) {\n\t if (isPrime(n)) {\n\t if (nPrime < 8) {\n\t H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));\n\t }\n\t K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));\n\n\t nPrime++;\n\t }\n\n\t n++;\n\t }\n\t }());\n\n\t // Reusable object\n\t var W = [];\n\n\t /**\n\t * SHA-256 hash algorithm.\n\t */\n\t var SHA256 = C_algo.SHA256 = Hasher.extend({\n\t _doReset: function () {\n\t this._hash = new WordArray.init(H.slice(0));\n\t },\n\n\t _doProcessBlock: function (M, offset) {\n\t // Shortcut\n\t var H = this._hash.words;\n\n\t // Working variables\n\t var a = H[0];\n\t var b = H[1];\n\t var c = H[2];\n\t var d = H[3];\n\t var e = H[4];\n\t var f = H[5];\n\t var g = H[6];\n\t var h = H[7];\n\n\t // Computation\n\t for (var i = 0; i < 64; i++) {\n\t if (i < 16) {\n\t W[i] = M[offset + i] | 0;\n\t } else {\n\t var gamma0x = W[i - 15];\n\t var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^\n\t ((gamma0x << 14) | (gamma0x >>> 18)) ^\n\t (gamma0x >>> 3);\n\n\t var gamma1x = W[i - 2];\n\t var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^\n\t ((gamma1x << 13) | (gamma1x >>> 19)) ^\n\t (gamma1x >>> 10);\n\n\t W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];\n\t }\n\n\t var ch = (e & f) ^ (~e & g);\n\t var maj = (a & b) ^ (a & c) ^ (b & c);\n\n\t var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));\n\t var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));\n\n\t var t1 = h + sigma1 + ch + K[i] + W[i];\n\t var t2 = sigma0 + maj;\n\n\t h = g;\n\t g = f;\n\t f = e;\n\t e = (d + t1) | 0;\n\t d = c;\n\t c = b;\n\t b = a;\n\t a = (t1 + t2) | 0;\n\t }\n\n\t // Intermediate hash value\n\t H[0] = (H[0] + a) | 0;\n\t H[1] = (H[1] + b) | 0;\n\t H[2] = (H[2] + c) | 0;\n\t H[3] = (H[3] + d) | 0;\n\t H[4] = (H[4] + e) | 0;\n\t H[5] = (H[5] + f) | 0;\n\t H[6] = (H[6] + g) | 0;\n\t H[7] = (H[7] + h) | 0;\n\t },\n\n\t _doFinalize: function () {\n\t // Shortcuts\n\t var data = this._data;\n\t var dataWords = data.words;\n\n\t var nBitsTotal = this._nDataBytes * 8;\n\t var nBitsLeft = data.sigBytes * 8;\n\n\t // Add padding\n\t dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);\n\t dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);\n\t dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;\n\t data.sigBytes = dataWords.length * 4;\n\n\t // Hash final blocks\n\t this._process();\n\n\t // Return final computed hash\n\t return this._hash;\n\t },\n\n\t clone: function () {\n\t var clone = Hasher.clone.call(this);\n\t clone._hash = this._hash.clone();\n\n\t return clone;\n\t }\n\t });\n\n\t /**\n\t * Shortcut function to the hasher's object interface.\n\t *\n\t * @param {WordArray|string} message The message to hash.\n\t *\n\t * @return {WordArray} The hash.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hash = CryptoJS.SHA256('message');\n\t * var hash = CryptoJS.SHA256(wordArray);\n\t */\n\t C.SHA256 = Hasher._createHelper(SHA256);\n\n\t /**\n\t * Shortcut function to the HMAC's object interface.\n\t *\n\t * @param {WordArray|string} message The message to hash.\n\t * @param {WordArray|string} key The secret key.\n\t *\n\t * @return {WordArray} The HMAC.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hmac = CryptoJS.HmacSHA256(message, key);\n\t */\n\t C.HmacSHA256 = Hasher._createHmacHelper(SHA256);\n\t}(Math));\n\n\n\treturn CryptoJS.SHA256;\n\n}));","import { AxiosRequestConfig } from \"axios\";\r\n\r\nconst axiosConfig: AxiosRequestConfig = {\r\n url: \"\",\r\n method: \"\",\r\n baseURL: \"\",\r\n headers: {},\r\n data: {},\r\n timeout: 1000,\r\n withCredentials: false,\r\n responseType: \"json\",\r\n responseEncoding: \"utf8\",\r\n validateStatus: function (status: number) {\r\n return status >= 200 && status < 300;\r\n },\r\n maxRedirects: 5,\r\n socketPath: null,\r\n};\r\n\r\nexport default axiosConfig;\r\n","import axios, { AxiosInstance, AxiosRequestConfig } from \"axios\";\r\nimport axiosConfig from \"../config/axiosConfig\";\r\n\r\ninterface AxiosAjaxOptions extends AxiosRequestConfig {\r\n retries?: number;\r\n retryDelayMs?: number;\r\n}\r\n\r\nclass AxiosAjax {\r\n private http: AxiosInstance;\r\n private retries: number;\r\n private retryDelayMs: number;\r\n\r\n constructor(options?: AxiosAjaxOptions) {\r\n this.http = axios.create(options || (axiosConfig as AxiosRequestConfig));\r\n this.retries = options?.retries ?? 2;\r\n this.retryDelayMs = options?.retryDelayMs ?? 100;\r\n }\r\n\r\n private async sleep(ms: number): Promise {\r\n await new Promise((resolve) => setTimeout(resolve, ms));\r\n }\r\n\r\n async makeRequest(\r\n url: string,\r\n method: string,\r\n queryParameters?: Record,\r\n body?: unknown\r\n ) {\r\n if (!url) {\r\n throw new Error(\"URL required\");\r\n }\r\n\r\n let lastError: unknown;\r\n\r\n for (let attempt = 0; attempt <= this.retries; attempt += 1) {\r\n try {\r\n return await this.http({\r\n method: method || \"get\",\r\n url,\r\n params: queryParameters,\r\n data: body,\r\n });\r\n } catch (error) {\r\n lastError = error;\r\n\r\n if (attempt >= this.retries) {\r\n throw error;\r\n }\r\n\r\n if (this.retryDelayMs > 0) {\r\n await this.sleep(this.retryDelayMs);\r\n }\r\n }\r\n }\r\n\r\n throw lastError;\r\n }\r\n}\r\n\r\nexport default AxiosAjax;\r\n"," {\r\n \"API_LOCATION\": \"https://api.unsplash.com/\",\r\n \"BEARER_TOKEN_URL\": \"https://unsplash.com/oauth/token\",\r\n\r\n \"USERS_PUBLIC_PROFILE\": \"users/\",\r\n \"USERS_PORTFOLIO\": \"users/:username/portfolio\",\r\n \"USERS_PHOTOS\": \"users/:username/photos\",\r\n \"USERS_LIKED_PHOTOS\": \"users/:username/likes\",\r\n \"USERS_COLLECTIONS\": \"users/:username/collections\",\r\n \"USERS_STATISTICS\": \"users/:username/statistics\",\r\n\r\n \"LIST_PHOTOS\": \"photos\",\r\n \"LIST_CURATED_PHOTOS\": \"photos/curated\",\r\n \"GET_A_PHOTO\": \"photos/:id\",\r\n \"GET_A_RANDOM_PHOTO\": \"photos/random\",\r\n \"GET_A_PHOTO_STATISTICS\": \"photos/:id/statistics\",\r\n \"GET_A_PHOTO_DOWNLOAD_LINK\": \"photos/:id/download\",\r\n \"UPDATE_A_PHOTO\": \"photos/:id\",\r\n \"LIKE_A_PHOTO\": \"photos/:id/like\",\r\n \"UNLIKE_A_PHOTO\": \"photos/:id/like\",\r\n\r\n \"SEARCH_PHOTOS\": \"search/photos\",\r\n \"SEARCH_COLLECTIONS\": \"search/collections\",\r\n \"SEARCH_USERS\": \"search/users\",\r\n\r\n \"CURRENT_USER_PROFILE\": \"me\",\r\n \"UPDATE_CURRENT_USER_PROFILE\": \"me\",\r\n\r\n \"STATS_TOTALS\": \"stats/total\",\r\n \"STATS_MONTH\": \"stats/month\",\r\n\r\n \"LIST_COLLECTIONS\": \"collections\",\r\n \"LIST_FEATURED_COLLECTIONS\": \"collections/featured\",\r\n \"LIST_CURATED_COLLECTIONS\": \"collections/curated\",\r\n \"GET_COLLECTION\": \"collections/:id\",\r\n \"GET_CURATED_COLLECTION\": \"collections/curated/:id\",\r\n \"GET_COLLECTION_PHOTOS\": \"collections/:id/photos\",\r\n \"GET_CURATED_COLLECTION_PHOTOS\": \"collections/curated/:id/photos\",\r\n \"LIST_RELATED_COLLECTION\": \"collections/:id/related\",\r\n \"CREATE_NEW_COLLECTION\": \"collections\",\r\n \"UPDATE_EXISTING_COLLECTION\": \"collections/:id\",\r\n \"DELETE_COLLECTION\": \"collections/:id\",\r\n \"ADD_PHOTO_TO_COLLECTION\": \"collections/:collection_id/add\",\r\n \"REMOVE_PHOTO_FROM_COLLECTION\": \"collections/:collection_id/remove\"\r\n }","import sha256 from \"crypto-js/sha256\";\r\nimport AxiosAjax from \"../lib/axiosAjaxLib\";\r\nimport urlConfig from \"../config/url_config.json\";\r\n\r\ntype WrapSplashOptions = {\r\n access_key?: string;\r\n secret_key?: string;\r\n redirect_uri?: string;\r\n code?: string;\r\n bearer_token?: string;\r\n timeout?: number;\r\n retries?: number;\r\n retryDelayMs?: number;\r\n};\r\n\r\ntype QueryParams = Record;\r\n\r\ntype Headers = Record;\r\n\r\ntype WrapSplashResponse = Record;\r\n\r\ninterface ErrorOptions {\r\n cause?: unknown;\r\n statusCode?: number;\r\n statusText?: string;\r\n}\r\n\r\nclass WrapSplashError extends Error {\r\n public statusCode?: number;\r\n public statusText?: string;\r\n public cause?: unknown;\r\n\r\n constructor(message: string, options?: ErrorOptions | number, statusText?: string, cause?: unknown) {\r\n super(message);\r\n this.name = \"WrapSplashError\";\r\n\r\n // Handle both old and new signatures for backward compatibility\r\n if (typeof options === \"object\" && options !== null && !Array.isArray(options)) {\r\n // New signature: (message, options)\r\n this.cause = options.cause;\r\n this.statusCode = options.statusCode;\r\n this.statusText = options.statusText;\r\n } else if (typeof options === \"number\") {\r\n // Old signature: (message, statusCode, statusText, cause)\r\n this.statusCode = options;\r\n this.statusText = statusText;\r\n this.cause = cause;\r\n }\r\n\r\n Object.setPrototypeOf(this, new.target.prototype);\r\n }\r\n}\r\n\r\nclass WrapSplashApi {\r\n private API_LOCATION: string = urlConfig.API_LOCATION;\r\n private BEARER_TOKEN_URL: string = urlConfig.BEARER_TOKEN_URL;\r\n private options: WrapSplashOptions = {};\r\n private access_key = \"\";\r\n private secret_key = \"\";\r\n private redirect_uri = \"\";\r\n private code = \"\";\r\n private grant_type = \"authorization_code\";\r\n private bearer_token = \"\";\r\n private timeout = 10000;\r\n private retries = 2;\r\n private retryDelayMs = 100;\r\n private headers: Headers = {\r\n \"Content-type\": \"application/json\",\r\n \"X-Requested-With\": \"WrapSplash\",\r\n };\r\n\r\n private computeHash(value: string): string {\r\n return sha256(value).toString();\r\n }\r\n\r\n private validateRequired(value: unknown, fieldName: string): void {\r\n if (value === undefined || value === null || value === \"\") {\r\n const message = fieldName === \"id\" ? \"Parameter : id is required!\" : fieldName === \"query\" ? \"Parameter : query is missing!\" : `Parameter : ${fieldName} is required and cannot be empty!`;\r\n throw new WrapSplashError(message);\r\n }\r\n }\r\n\r\n private validateSupportedValue(value: string | undefined, allowedValues: readonly string[], fieldName: string): void {\r\n if (value !== undefined && !allowedValues.includes(value)) {\r\n throw new WrapSplashError(`Parameter : ${fieldName} has an unsupported value!`);\r\n }\r\n }\r\n\r\n private availableOrders = [\"latest\", \"oldest\", \"popular\"];\r\n private availableOrientations = [\"landscape\", \"portrait\", \"squarish\"];\r\n\r\n /** Initialize the client with API credentials or a bearer token. */\r\n init = (options: WrapSplashOptions = {}): void => {\r\n if (!options || typeof options !== \"object\" || Array.isArray(options)) {\r\n throw new WrapSplashError(\"Initialisation parameters required!\");\r\n }\r\n\r\n this.options = { ...options };\r\n this.timeout = typeof this.options.timeout === \"number\" && this.options.timeout > 0 ? this.options.timeout : 10000;\r\n this.retries = typeof this.options.retries === \"number\" && this.options.retries >= 0 ? this.options.retries : 2;\r\n this.retryDelayMs = typeof this.options.retryDelayMs === \"number\" && this.options.retryDelayMs >= 0 ? this.options.retryDelayMs : 100;\r\n this.bearer_token = this.options.bearer_token ?? \"\";\r\n\r\n this.headers = {\r\n \"Content-type\": \"application/json\",\r\n \"X-Requested-With\": \"WrapSplash\",\r\n };\r\n\r\n if (this.options.bearer_token) {\r\n this.headers = {\r\n ...this.headers,\r\n Authorization: `Bearer ${this.options.bearer_token}`,\r\n \"X-WrapSplash-Header\": this.computeHash(this.options.bearer_token),\r\n };\r\n return;\r\n }\r\n\r\n this.access_key = this.options.access_key\r\n ? this.options.access_key\r\n : (() => {\r\n throw new WrapSplashError(\"Access Key missing!\");\r\n })();\r\n this.secret_key = this.options.secret_key\r\n ? this.options.secret_key\r\n : (() => {\r\n throw new WrapSplashError(\"Secret Key missing!\");\r\n })();\r\n this.redirect_uri = this.options.redirect_uri\r\n ? this.options.redirect_uri\r\n : (() => {\r\n throw new WrapSplashError(\"Redirect URI missing!\");\r\n })();\r\n this.code = this.options.code\r\n ? this.options.code\r\n : (() => {\r\n throw new WrapSplashError(\"Authorization Code missing!\");\r\n })();\r\n\r\n this.headers = {\r\n ...this.headers,\r\n Authorization: `Client-ID ${this.options.access_key}`,\r\n \"X-WrapSplash-Header\": this.computeHash(this.options.access_key),\r\n };\r\n };\r\n\r\n private buildQueryParameters(params: QueryParams): QueryParams {\r\n const cleanParams: QueryParams = {};\r\n Object.entries(params).forEach(([key, value]) => {\r\n if (value !== undefined && value !== null && value !== \"\") {\r\n cleanParams[key] = value;\r\n }\r\n });\r\n return cleanParams;\r\n }\r\n\r\n private getErrorMessage(error: unknown): string {\r\n if (error instanceof Error) {\r\n return error.message;\r\n }\r\n\r\n if (typeof error === \"string\") {\r\n return error;\r\n }\r\n\r\n return \"Request failed\";\r\n }\r\n\r\n private createWrapSplashError(error: unknown): WrapSplashError {\r\n if (error instanceof WrapSplashError) {\r\n return error;\r\n }\r\n\r\n const statusCode = typeof error === \"object\" && error !== null && \"response\" in error && error.response && typeof error.response === \"object\" && \"status\" in error.response ? (error.response as { status?: number }).status : undefined;\r\n const statusText = typeof error === \"object\" && error !== null && \"response\" in error && error.response && typeof error.response === \"object\" && \"statusText\" in error.response ? (error.response as { statusText?: string }).statusText : undefined;\r\n\r\n return new WrapSplashError(this.getErrorMessage(error), {\r\n cause: error,\r\n statusCode,\r\n statusText,\r\n });\r\n }\r\n\r\n private fetchUrl(\r\n url: string,\r\n method: string,\r\n queryParameters: QueryParams = {},\r\n body: unknown = undefined\r\n ): Promise {\r\n const ajax = new AxiosAjax({\r\n headers: this.headers,\r\n timeout: this.timeout,\r\n retries: this.retries,\r\n retryDelayMs: this.retryDelayMs,\r\n });\r\n\r\n return ajax\r\n .makeRequest(url, method.toLowerCase(), this.buildQueryParameters(queryParameters), body)\r\n .then((res) => {\r\n const response = res as { status?: number; statusText?: string; data?: T };\r\n\r\n if (response.status === 204) {\r\n return {\r\n status: response.status,\r\n statusText: response.statusText,\r\n message: \"Content Deleted\",\r\n } as T;\r\n }\r\n\r\n if (response.status === 403) {\r\n return {\r\n status: response.status,\r\n statusText: response.statusText,\r\n message: \"Rate Limit Exceeded\",\r\n } as T;\r\n }\r\n\r\n return response.data as T;\r\n })\r\n .catch((err: unknown) => Promise.reject(this.createWrapSplashError(err)));\r\n }\r\n\r\n /** Exchange the authorization code for a bearer token. */\r\n generateBearerToken = (): Promise => {\r\n this.validateRequired(this.access_key, \"access_key\");\r\n this.validateRequired(this.secret_key, \"secret_key\");\r\n this.validateRequired(this.redirect_uri, \"redirect_uri\");\r\n this.validateRequired(this.code, \"code\");\r\n\r\n return this.fetchUrl(this.BEARER_TOKEN_URL, \"POST\", {\r\n client_id: this.access_key,\r\n client_secret: this.secret_key,\r\n redirect_uri: this.redirect_uri,\r\n code: this.code,\r\n grant_type: this.grant_type,\r\n });\r\n };\r\n\r\n getCurrentUserProfile = (): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.CURRENT_USER_PROFILE, \"GET\");\r\n };\r\n\r\n updateCurrentUserProfile = (\r\n username?: string,\r\n first_name?: string,\r\n last_name?: string,\r\n email?: string,\r\n url?: string,\r\n location?: string,\r\n bio?: string,\r\n instagram_username?: string\r\n ): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UPDATE_CURRENT_USER_PROFILE, \"PUT\", {\r\n username,\r\n first_name,\r\n last_name,\r\n email,\r\n url,\r\n location,\r\n bio,\r\n instagram_username,\r\n });\r\n };\r\n\r\n getPublicProfile = (username: string, width?: number, height?: number): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.USERS_PUBLIC_PROFILE + username, \"GET\", {\r\n w: width,\r\n h: height,\r\n });\r\n };\r\n\r\n getUserPortfolio = (username: string): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_PORTFOLIO.replace(/:username/gi, username),\r\n \"GET\"\r\n );\r\n };\r\n\r\n getUserPhotos = (\r\n username: string,\r\n page?: number,\r\n per_page?: number,\r\n stats?: boolean,\r\n resolution?: string,\r\n quantity?: number,\r\n order_by?: string\r\n ): Promise => {\r\n this.validateRequired(username, \"username\");\r\n this.validateSupportedValue(order_by, this.availableOrders, \"order_by\");\r\n if (stats !== undefined && typeof stats !== \"boolean\") {\r\n throw new WrapSplashError(\"Parameter : stats is a boolean or optional!\");\r\n }\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_PHOTOS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n stats: stats ?? false,\r\n resolution: resolution ?? \"days\",\r\n quantity: quantity ?? 30,\r\n }\r\n );\r\n };\r\n\r\n getUserLikedPhotos = (\r\n username: string,\r\n page?: number,\r\n per_page?: number,\r\n order_by?: string\r\n ): Promise => {\r\n this.validateRequired(username, \"username\");\r\n this.validateSupportedValue(order_by, this.availableOrders, \"order_by\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_LIKED_PHOTOS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n }\r\n );\r\n };\r\n\r\n getUserCollections = (username: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_COLLECTIONS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n }\r\n );\r\n };\r\n\r\n getUserStatistics = (username: string, resolution?: string, quantity?: number): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_STATISTICS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n resolution: resolution ?? \"days\",\r\n quantity: quantity ?? 30,\r\n }\r\n );\r\n };\r\n\r\n listPhotos = (page?: number, per_page?: number, order_by?: string): Promise => {\r\n if (order_by !== undefined && !this.availableOrders.includes(order_by)) {\r\n throw new WrapSplashError(\"Parameter : order_by has an unsupported value!\");\r\n }\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_PHOTOS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n });\r\n };\r\n\r\n listCuratedPhotos = (page?: number, per_page?: number, order_by?: string): Promise => {\r\n if (order_by !== undefined && !this.availableOrders.includes(order_by)) {\r\n throw new WrapSplashError(\"Parameter : order_by has an unsupported value!\");\r\n }\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_CURATED_PHOTOS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n });\r\n };\r\n\r\n getAPhoto = (id: string, width?: number, height?: number, rect?: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_PHOTO.replace(/:id/gi, id), \"GET\", {\r\n w: width,\r\n h: height,\r\n rect: typeof rect === \"string\" ? rect : undefined,\r\n });\r\n };\r\n\r\n getARandomPhoto = (\r\n collections?: string | number,\r\n featured?: boolean,\r\n username?: string,\r\n query?: string,\r\n width?: number,\r\n height?: number,\r\n orientation?: string,\r\n count?: number\r\n ): Promise => {\r\n this.validateSupportedValue(orientation, this.availableOrientations, \"orientation\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_RANDOM_PHOTO, \"GET\", {\r\n collections: collections !== undefined ? String(collections) : undefined,\r\n featured: featured ?? false,\r\n username,\r\n query,\r\n width,\r\n height,\r\n orientation: orientation ?? \"landscape\",\r\n count: count ?? 1,\r\n });\r\n };\r\n\r\n getPhotoStatistics = (id: string, resolution?: string, quantity?: number): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_PHOTO_STATISTICS.replace(/:id/gi, id), \"GET\", {\r\n resolution: resolution ?? \"days\",\r\n quantity: quantity ?? 30,\r\n });\r\n };\r\n\r\n getPhotoLink = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_PHOTO_DOWNLOAD_LINK.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n updatePhoto = (\r\n id: string,\r\n location: Record = {},\r\n exif: Record = {}\r\n ): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UPDATE_A_PHOTO.replace(/:id/gi, id), \"PUT\", {\r\n ...(location.latitude ? { \"location[latitude]\": location.latitude } : {}),\r\n ...(location.longitude ? { \"location[longitude]\": location.longitude } : {}),\r\n ...(location.name ? { \"location[name]\": location.name } : {}),\r\n ...(location.city ? { \"location[city]\": location.city } : {}),\r\n ...(location.country ? { \"location[country]\": location.country } : {}),\r\n ...(location.confidential ? { \"location[confidential]\": location.confidential } : {}),\r\n ...(exif.make ? { \"exif[make]\": exif.make } : {}),\r\n ...(exif.model ? { \"exif[model]\": exif.model } : {}),\r\n ...(exif.exposure_time ? { \"exif[exposure_time]\": exif.exposure_time } : {}),\r\n ...(exif.aperture_value ? { \"exif[aperture_value]\": exif.aperture_value } : {}),\r\n ...(exif.focal_length ? { \"exif[focal_length]\": exif.focal_length } : {}),\r\n ...(exif.iso_speed_ratings ? { \"exif[iso_speed_ratings]\": exif.iso_speed_ratings } : {}),\r\n });\r\n };\r\n\r\n likePhoto = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIKE_A_PHOTO.replace(/:id/gi, id), \"POST\");\r\n };\r\n\r\n unlikePhoto = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UNLIKE_A_PHOTO.replace(/:id/gi, id), \"DELETE\");\r\n };\r\n\r\n search = (query: string, page?: number, per_page?: number, collections?: string | number, orientation?: string): Promise => {\r\n this.validateRequired(query, \"query\");\r\n this.validateSupportedValue(orientation, this.availableOrientations, \"orientation\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.SEARCH_PHOTOS, \"GET\", {\r\n query,\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n collections: collections !== undefined ? String(collections) : undefined,\r\n orientation,\r\n });\r\n };\r\n\r\n searchCollections = (query: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(query, \"query\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.SEARCH_COLLECTIONS, \"GET\", {\r\n query,\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n searchUsers = (query: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(query, \"query\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.SEARCH_USERS, \"GET\", {\r\n query,\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n getStatsTotals = (): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.STATS_TOTALS, \"GET\");\r\n };\r\n\r\n getStatsMonth = (): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.STATS_MONTH, \"GET\");\r\n };\r\n\r\n listCollections = (page?: number, per_page?: number): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_COLLECTIONS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n listFeaturedCollections = (page?: number, per_page?: number): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_FEATURED_COLLECTIONS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n listCuratedCollections = (page?: number, per_page?: number): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_CURATED_COLLECTIONS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n getCollection = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_COLLECTION.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n getCuratedCollection = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_CURATED_COLLECTION.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n getCollectionPhotos = (id: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_COLLECTION_PHOTOS.replace(/:id/gi, id), \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n getCuratedCollectionPhotos = (id: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_CURATED_COLLECTION_PHOTOS.replace(/:id/gi, id), \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n listRelatedCollections = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_RELATED_COLLECTION.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n /** Fetch a photo using the newer alias. */\r\n getPhoto = (id: string, width?: number, height?: number, rect?: string): Promise => {\r\n return this.getAPhoto(id, width, height, rect);\r\n };\r\n\r\n getRandomPhoto = (\r\n collections?: string | number,\r\n featured?: boolean,\r\n username?: string,\r\n query?: string,\r\n width?: number,\r\n height?: number,\r\n orientation?: string,\r\n count?: number\r\n ): Promise => {\r\n return this.getARandomPhoto(collections, featured, username, query, width, height, orientation, count);\r\n };\r\n\r\n createNewCollection = (title: string, description?: string, private_collection: boolean = false): Promise => {\r\n this.validateRequired(title, \"title\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.CREATE_NEW_COLLECTION, \"POST\", {\r\n title,\r\n description,\r\n private: private_collection,\r\n });\r\n };\r\n\r\n /** Create a collection using the newer alias. */\r\n createCollection = (title: string, description?: string, private_collection: boolean = false): Promise => {\r\n return this.createNewCollection(title, description, private_collection);\r\n };\r\n\r\n /**\r\n * Backward-compatible alias for createNewCollection.\r\n * @deprecated Use createNewCollection instead.\r\n */\r\n createNewColection = (title: string, description?: string, private_collection: boolean = false): Promise => {\r\n return this.createNewCollection(title, description, private_collection);\r\n };\r\n\r\n updateExistingCollection = (id: string, title: string, description?: string, private_collection: boolean = false): Promise => {\r\n this.validateRequired(id, \"id\");\r\n this.validateRequired(title, \"title\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UPDATE_EXISTING_COLLECTION.replace(/:id/gi, id), \"PUT\", {\r\n title,\r\n description,\r\n private: private_collection,\r\n });\r\n };\r\n\r\n /** Update an existing collection using the newer alias. */\r\n updateCollection = (id: string, title: string, description?: string, private_collection: boolean = false): Promise => {\r\n return this.updateExistingCollection(id, title, description, private_collection);\r\n };\r\n\r\n deleteCollection = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.DELETE_COLLECTION.replace(/:id/gi, id), \"DELETE\");\r\n };\r\n\r\n addPhotoToCollection = (collection_id: string, photo_id: string): Promise => {\r\n this.validateRequired(collection_id, \"collection_id\");\r\n this.validateRequired(photo_id, \"photo_id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.ADD_PHOTO_TO_COLLECTION.replace(/:collection_id/gi, collection_id), \"POST\", {\r\n photo_id,\r\n });\r\n };\r\n\r\n removePhotoFromCollection = (collection_id: string, photo_id: string): Promise => {\r\n this.validateRequired(collection_id, \"collection_id\");\r\n this.validateRequired(photo_id, \"photo_id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.REMOVE_PHOTO_FROM_COLLECTION.replace(/:collection_id/gi, collection_id), \"DELETE\", {\r\n photo_id,\r\n });\r\n };\r\n}\r\n\r\nexport { WrapSplashError };\r\nexport default WrapSplashApi;\r\n"],"x_google_ignoreList":[1,2],"mappings":";;;;;;;;;;;;;;;CAAA,EAAO,UAAU,CAAC;;CCAjB,CAAC,SAAU,GAAM,GAAS;EAC1B,AAAI,OAAO,KAAY,WAEtB,EAAO,UAAU,IAAU,EAAQ,IAE3B,OAAO,UAAW,cAAc,OAAO,MAE/C,OAAO,CAAC,GAAG,CAAO,IAIlB,EAAK,WAAW,EAAQ;CAE1B,EAAA,CAAC,GAAO,WAAY;EAOnB,IAAI,IAAW,KAAa,SAAU,GAAM,GAAW;GAEnD,IAAI;GA4BJ,IAzBI,OAAO,SAAW,OAAe,OAAO,WACxC,IAAS,OAAO,SAIhB,OAAO,OAAS,OAAe,KAAK,WACpC,IAAS,KAAK,SAId,OAAO,aAAe,OAAe,WAAW,WAChD,IAAS,WAAW,SAIpB,CAAC,KAAU,OAAO,SAAW,OAAe,OAAO,aACnD,IAAS,OAAO,WAIhB,CAAC,KAAU,OAAO,SAAW,OAAe,OAAO,WACnD,IAAS,OAAO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,GACJ;EAQZ,OAAO,IAPU,EAAU;GACzB,SAAS,KAAK;GACd,SAAS,KAAK;GACd,SAAS,KAAK;GACd,cAAc,KAAK;EACrB,CAEO,CAAA,CACJ,YAAY,GAAK,EAAO,YAAY,GAAG,KAAK,qBAAqB,CAAe,GAAG,CAAI,CAAC,CACxF,MAAM,MAAQ;GACb,IAAM,IAAW;GAkBjB,OAhBI,EAAS,WAAW,MACf;IACL,QAAQ,EAAS;IACjB,YAAY,EAAS;IACrB,SAAS;GACX,IAGE,EAAS,WAAW,MACf;IACL,QAAQ,EAAS;IACjB,YAAY,EAAS;IACrB,SAAS;GACX,IAGK,EAAS;EAClB,CAAC,CAAC,CACD,OAAO,MAAiB,QAAQ,OAAO,KAAK,sBAAsB,CAAG,CAAC,CAAC;CAC5E;AA2YF"} \ No newline at end of file +{"version":3,"file":"wrapsplash.es.js","names":[],"sources":["../config/axiosConfig.ts","../lib/axiosAjaxLib.ts","../config/url_config.json","../src/index.ts"],"sourcesContent":["import { AxiosRequestConfig } from \"axios\";\r\n\r\nconst axiosConfig: AxiosRequestConfig = {\r\n url: \"\",\r\n method: \"\",\r\n baseURL: \"\",\r\n headers: {},\r\n data: {},\r\n timeout: 1000,\r\n withCredentials: false,\r\n responseType: \"json\",\r\n responseEncoding: \"utf8\",\r\n validateStatus: function (status: number) {\r\n return status >= 200 && status < 300;\r\n },\r\n maxRedirects: 5,\r\n socketPath: null,\r\n};\r\n\r\nexport default axiosConfig;\r\n","import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from \"axios\";\nimport axiosConfig from \"../config/axiosConfig\";\n\ninterface AxiosAjaxOptions extends AxiosRequestConfig {\n retries?: number;\n retryDelayMs?: number;\n}\n\nclass AxiosAjax {\n private http: AxiosInstance;\n private retries: number;\n private retryDelayMs: number;\n\n constructor(options?: AxiosAjaxOptions) {\n this.http = axios.create(options || (axiosConfig as AxiosRequestConfig));\n this.retries = options?.retries ?? 2;\n this.retryDelayMs = options?.retryDelayMs ?? 100;\n }\n\n private sleep(ms: number): Promise {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n private isRetryableError(error: unknown): boolean {\n if (axios.isCancel(error)) {\n return false;\n }\n\n const axiosError = error as AxiosError;\n\n if (!axiosError.response) {\n return true;\n }\n\n const status = axiosError.response.status;\n return status === 429 || status >= 500;\n }\n\n private getRetryDelay(error: unknown, attempt: number): number {\n const axiosError = error as AxiosError;\n\n if (axiosError.response) {\n const retryAfterHeader = axiosError.response.headers?.[\"retry-after\"];\n if (retryAfterHeader) {\n const seconds = Number(retryAfterHeader);\n if (!Number.isNaN(seconds) && seconds > 0) {\n return seconds * 1000;\n }\n }\n }\n\n return this.retryDelayMs * Math.pow(2, attempt);\n }\n\n async makeRequest(\n url: string,\n method: string,\n queryParameters?: Record,\n body?: unknown\n ) {\n if (!url) {\n throw new Error(\"URL required\");\n }\n\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= this.retries; attempt += 1) {\n try {\n return await this.http({\n method: method || \"get\",\n url,\n params: queryParameters,\n data: body,\n });\n } catch (error) {\n lastError = error;\n\n if (attempt >= this.retries || !this.isRetryableError(error)) {\n throw error;\n }\n\n const delay = this.getRetryDelay(error, attempt);\n if (delay > 0) {\n await this.sleep(delay);\n }\n }\n }\n\n throw lastError;\n }\n}\n\nexport default AxiosAjax;\n"," {\r\n \"API_LOCATION\": \"https://api.unsplash.com/\",\r\n \"BEARER_TOKEN_URL\": \"https://unsplash.com/oauth/token\",\r\n\r\n \"USERS_PUBLIC_PROFILE\": \"users/\",\r\n \"USERS_PORTFOLIO\": \"users/:username/portfolio\",\r\n \"USERS_PHOTOS\": \"users/:username/photos\",\r\n \"USERS_LIKED_PHOTOS\": \"users/:username/likes\",\r\n \"USERS_COLLECTIONS\": \"users/:username/collections\",\r\n \"USERS_STATISTICS\": \"users/:username/statistics\",\r\n\r\n \"LIST_PHOTOS\": \"photos\",\r\n \"LIST_CURATED_PHOTOS\": \"photos/curated\",\r\n \"GET_A_PHOTO\": \"photos/:id\",\r\n \"GET_A_RANDOM_PHOTO\": \"photos/random\",\r\n \"GET_A_PHOTO_STATISTICS\": \"photos/:id/statistics\",\r\n \"GET_A_PHOTO_DOWNLOAD_LINK\": \"photos/:id/download\",\r\n \"UPDATE_A_PHOTO\": \"photos/:id\",\r\n \"LIKE_A_PHOTO\": \"photos/:id/like\",\r\n \"UNLIKE_A_PHOTO\": \"photos/:id/like\",\r\n\r\n \"SEARCH_PHOTOS\": \"search/photos\",\r\n \"SEARCH_COLLECTIONS\": \"search/collections\",\r\n \"SEARCH_USERS\": \"search/users\",\r\n\r\n \"CURRENT_USER_PROFILE\": \"me\",\r\n \"UPDATE_CURRENT_USER_PROFILE\": \"me\",\r\n\r\n \"STATS_TOTALS\": \"stats/total\",\r\n \"STATS_MONTH\": \"stats/month\",\r\n\r\n \"LIST_COLLECTIONS\": \"collections\",\r\n \"LIST_FEATURED_COLLECTIONS\": \"collections/featured\",\r\n \"LIST_CURATED_COLLECTIONS\": \"collections/curated\",\r\n \"GET_COLLECTION\": \"collections/:id\",\r\n \"GET_CURATED_COLLECTION\": \"collections/curated/:id\",\r\n \"GET_COLLECTION_PHOTOS\": \"collections/:id/photos\",\r\n \"GET_CURATED_COLLECTION_PHOTOS\": \"collections/curated/:id/photos\",\r\n \"LIST_RELATED_COLLECTION\": \"collections/:id/related\",\r\n \"CREATE_NEW_COLLECTION\": \"collections\",\r\n \"UPDATE_EXISTING_COLLECTION\": \"collections/:id\",\r\n \"DELETE_COLLECTION\": \"collections/:id\",\r\n \"ADD_PHOTO_TO_COLLECTION\": \"collections/:collection_id/add\",\r\n \"REMOVE_PHOTO_FROM_COLLECTION\": \"collections/:collection_id/remove\"\r\n }","import { createHash } from \"crypto\";\r\nimport AxiosAjax from \"../lib/axiosAjaxLib\";\r\nimport urlConfig from \"../config/url_config.json\";\r\n\r\ntype WrapSplashOptions = {\r\n access_key?: string;\r\n secret_key?: string;\r\n redirect_uri?: string;\r\n code?: string;\r\n bearer_token?: string;\r\n timeout?: number;\r\n retries?: number;\r\n retryDelayMs?: number;\r\n};\r\n\r\ntype QueryParams = Record;\r\n\r\ntype Headers = Record;\r\n\r\ntype WrapSplashResponse = Record;\r\n\r\ninterface ErrorOptions {\r\n cause?: unknown;\r\n statusCode?: number;\r\n statusText?: string;\r\n}\r\n\r\nclass WrapSplashError extends Error {\r\n public statusCode?: number;\r\n public statusText?: string;\r\n public cause?: unknown;\r\n\r\n constructor(message: string, options?: ErrorOptions | number, statusText?: string, cause?: unknown) {\r\n super(message);\r\n this.name = \"WrapSplashError\";\r\n\r\n // Handle both old and new signatures for backward compatibility\r\n if (typeof options === \"object\" && options !== null && !Array.isArray(options)) {\r\n // New signature: (message, options)\r\n this.cause = options.cause;\r\n this.statusCode = options.statusCode;\r\n this.statusText = options.statusText;\r\n } else if (typeof options === \"number\") {\r\n // Old signature: (message, statusCode, statusText, cause)\r\n this.statusCode = options;\r\n this.statusText = statusText;\r\n this.cause = cause;\r\n }\r\n\r\n Object.setPrototypeOf(this, new.target.prototype);\r\n }\r\n}\r\n\r\nclass WrapSplashApi {\r\n private API_LOCATION: string = urlConfig.API_LOCATION;\r\n private BEARER_TOKEN_URL: string = urlConfig.BEARER_TOKEN_URL;\r\n private options: WrapSplashOptions = {};\r\n private access_key = \"\";\r\n private secret_key = \"\";\r\n private redirect_uri = \"\";\r\n private code = \"\";\r\n private grant_type = \"authorization_code\";\r\n private bearer_token = \"\";\r\n private timeout = 10000;\r\n private retries = 2;\r\n private retryDelayMs = 100;\r\n private headers: Headers = {\r\n \"Content-type\": \"application/json\",\r\n \"X-Requested-With\": \"WrapSplash\",\r\n };\r\n\r\n private computeHash(value: string): string {\r\n return createHash(\"sha256\").update(value).digest(\"hex\");\r\n }\r\n\r\n private validateRequired(value: unknown, fieldName: string): void {\r\n if (value === undefined || value === null || value === \"\") {\r\n const message = fieldName === \"id\" ? \"Parameter : id is required!\" : fieldName === \"query\" ? \"Parameter : query is missing!\" : `Parameter : ${fieldName} is required and cannot be empty!`;\r\n throw new WrapSplashError(message);\r\n }\r\n }\r\n\r\n private validateSupportedValue(value: string | undefined, allowedValues: readonly string[], fieldName: string): void {\r\n if (value !== undefined && !allowedValues.includes(value)) {\r\n throw new WrapSplashError(`Parameter : ${fieldName} has an unsupported value!`);\r\n }\r\n }\r\n\r\n private availableOrders = [\"latest\", \"oldest\", \"popular\"];\r\n private availableOrientations = [\"landscape\", \"portrait\", \"squarish\"];\r\n\r\n /** Initialize the client with API credentials or a bearer token. */\r\n init = (options: WrapSplashOptions = {}): void => {\r\n if (!options || typeof options !== \"object\" || Array.isArray(options)) {\r\n throw new WrapSplashError(\"Initialisation parameters required!\");\r\n }\r\n\r\n this.options = { ...options };\r\n this.timeout = typeof this.options.timeout === \"number\" && this.options.timeout > 0 ? this.options.timeout : 10000;\r\n this.retries = typeof this.options.retries === \"number\" && this.options.retries >= 0 ? this.options.retries : 2;\r\n this.retryDelayMs = typeof this.options.retryDelayMs === \"number\" && this.options.retryDelayMs >= 0 ? this.options.retryDelayMs : 100;\r\n this.bearer_token = this.options.bearer_token ?? \"\";\r\n\r\n this.headers = {\r\n \"Content-type\": \"application/json\",\r\n \"X-Requested-With\": \"WrapSplash\",\r\n };\r\n\r\n if (this.options.bearer_token) {\r\n this.headers = {\r\n ...this.headers,\r\n Authorization: `Bearer ${this.options.bearer_token}`,\r\n \"X-WrapSplash-Header\": this.computeHash(this.options.bearer_token),\r\n };\r\n return;\r\n }\r\n\r\n this.access_key = this.options.access_key\r\n ? this.options.access_key\r\n : (() => {\r\n throw new WrapSplashError(\"Access Key missing!\");\r\n })();\r\n this.secret_key = this.options.secret_key\r\n ? this.options.secret_key\r\n : (() => {\r\n throw new WrapSplashError(\"Secret Key missing!\");\r\n })();\r\n this.redirect_uri = this.options.redirect_uri\r\n ? this.options.redirect_uri\r\n : (() => {\r\n throw new WrapSplashError(\"Redirect URI missing!\");\r\n })();\r\n this.code = this.options.code\r\n ? this.options.code\r\n : (() => {\r\n throw new WrapSplashError(\"Authorization Code missing!\");\r\n })();\r\n\r\n this.headers = {\r\n ...this.headers,\r\n Authorization: `Client-ID ${this.options.access_key}`,\r\n \"X-WrapSplash-Header\": this.computeHash(this.options.access_key),\r\n };\r\n };\r\n\r\n private buildQueryParameters(params: QueryParams): QueryParams {\r\n const cleanParams: QueryParams = {};\r\n Object.entries(params).forEach(([key, value]) => {\r\n if (value !== undefined && value !== null && value !== \"\") {\r\n cleanParams[key] = value;\r\n }\r\n });\r\n return cleanParams;\r\n }\r\n\r\n private getErrorMessage(error: unknown): string {\r\n if (error instanceof Error) {\r\n return error.message;\r\n }\r\n\r\n if (typeof error === \"string\") {\r\n return error;\r\n }\r\n\r\n return \"Request failed\";\r\n }\r\n\r\n private createWrapSplashError(error: unknown): WrapSplashError {\r\n if (error instanceof WrapSplashError) {\r\n return error;\r\n }\r\n\r\n const statusCode = typeof error === \"object\" && error !== null && \"response\" in error && error.response && typeof error.response === \"object\" && \"status\" in error.response ? (error.response as { status?: number }).status : undefined;\r\n const statusText = typeof error === \"object\" && error !== null && \"response\" in error && error.response && typeof error.response === \"object\" && \"statusText\" in error.response ? (error.response as { statusText?: string }).statusText : undefined;\r\n\r\n return new WrapSplashError(this.getErrorMessage(error), {\r\n cause: error,\r\n statusCode,\r\n statusText,\r\n });\r\n }\r\n\r\n private fetchUrl(\r\n url: string,\r\n method: string,\r\n queryParameters: QueryParams = {},\r\n body: unknown = undefined\r\n ): Promise {\r\n const ajax = new AxiosAjax({\r\n headers: this.headers,\r\n timeout: this.timeout,\r\n retries: this.retries,\r\n retryDelayMs: this.retryDelayMs,\r\n });\r\n\r\n return ajax\r\n .makeRequest(url, method.toLowerCase(), this.buildQueryParameters(queryParameters), body)\r\n .then((res) => {\r\n const response = res as { status?: number; statusText?: string; data?: T };\r\n\r\n if (response.status === 204) {\r\n return {\r\n status: response.status,\r\n statusText: response.statusText,\r\n message: \"Content Deleted\",\r\n } as T;\r\n }\r\n\r\n if (response.status === 403) {\r\n return {\r\n status: response.status,\r\n statusText: response.statusText,\r\n message: \"Rate Limit Exceeded\",\r\n } as T;\r\n }\r\n\r\n return response.data as T;\r\n })\r\n .catch((err: unknown) => Promise.reject(this.createWrapSplashError(err)));\r\n }\r\n\r\n /** Exchange the authorization code for a bearer token. */\r\n generateBearerToken = (): Promise => {\r\n this.validateRequired(this.access_key, \"access_key\");\r\n this.validateRequired(this.secret_key, \"secret_key\");\r\n this.validateRequired(this.redirect_uri, \"redirect_uri\");\r\n this.validateRequired(this.code, \"code\");\r\n\r\n return this.fetchUrl(this.BEARER_TOKEN_URL, \"POST\", {\r\n client_id: this.access_key,\r\n client_secret: this.secret_key,\r\n redirect_uri: this.redirect_uri,\r\n code: this.code,\r\n grant_type: this.grant_type,\r\n });\r\n };\r\n\r\n getCurrentUserProfile = (): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.CURRENT_USER_PROFILE, \"GET\");\r\n };\r\n\r\n updateCurrentUserProfile = (\r\n username?: string,\r\n first_name?: string,\r\n last_name?: string,\r\n email?: string,\r\n url?: string,\r\n location?: string,\r\n bio?: string,\r\n instagram_username?: string\r\n ): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UPDATE_CURRENT_USER_PROFILE, \"PUT\", {\r\n username,\r\n first_name,\r\n last_name,\r\n email,\r\n url,\r\n location,\r\n bio,\r\n instagram_username,\r\n });\r\n };\r\n\r\n getPublicProfile = (username: string, width?: number, height?: number): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.USERS_PUBLIC_PROFILE + username, \"GET\", {\r\n w: width,\r\n h: height,\r\n });\r\n };\r\n\r\n getUserPortfolio = (username: string): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_PORTFOLIO.replace(/:username/gi, username),\r\n \"GET\"\r\n );\r\n };\r\n\r\n getUserPhotos = (\r\n username: string,\r\n page?: number,\r\n per_page?: number,\r\n stats?: boolean,\r\n resolution?: string,\r\n quantity?: number,\r\n order_by?: string\r\n ): Promise => {\r\n this.validateRequired(username, \"username\");\r\n this.validateSupportedValue(order_by, this.availableOrders, \"order_by\");\r\n if (stats !== undefined && typeof stats !== \"boolean\") {\r\n throw new WrapSplashError(\"Parameter : stats is a boolean or optional!\");\r\n }\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_PHOTOS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n stats: stats ?? false,\r\n resolution: resolution ?? \"days\",\r\n quantity: quantity ?? 30,\r\n }\r\n );\r\n };\r\n\r\n getUserLikedPhotos = (\r\n username: string,\r\n page?: number,\r\n per_page?: number,\r\n order_by?: string\r\n ): Promise => {\r\n this.validateRequired(username, \"username\");\r\n this.validateSupportedValue(order_by, this.availableOrders, \"order_by\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_LIKED_PHOTOS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n }\r\n );\r\n };\r\n\r\n getUserCollections = (username: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_COLLECTIONS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n }\r\n );\r\n };\r\n\r\n getUserStatistics = (username: string, resolution?: string, quantity?: number): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_STATISTICS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n resolution: resolution ?? \"days\",\r\n quantity: quantity ?? 30,\r\n }\r\n );\r\n };\r\n\r\n listPhotos = (page?: number, per_page?: number, order_by?: string): Promise => {\r\n if (order_by !== undefined && !this.availableOrders.includes(order_by)) {\r\n throw new WrapSplashError(\"Parameter : order_by has an unsupported value!\");\r\n }\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_PHOTOS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n });\r\n };\r\n\r\n listCuratedPhotos = (page?: number, per_page?: number, order_by?: string): Promise => {\r\n if (order_by !== undefined && !this.availableOrders.includes(order_by)) {\r\n throw new WrapSplashError(\"Parameter : order_by has an unsupported value!\");\r\n }\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_CURATED_PHOTOS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n });\r\n };\r\n\r\n getAPhoto = (id: string, width?: number, height?: number, rect?: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_PHOTO.replace(/:id/gi, id), \"GET\", {\r\n w: width,\r\n h: height,\r\n rect: typeof rect === \"string\" ? rect : undefined,\r\n });\r\n };\r\n\r\n getARandomPhoto = (\r\n collections?: string | number,\r\n featured?: boolean,\r\n username?: string,\r\n query?: string,\r\n width?: number,\r\n height?: number,\r\n orientation?: string,\r\n count?: number\r\n ): Promise => {\r\n this.validateSupportedValue(orientation, this.availableOrientations, \"orientation\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_RANDOM_PHOTO, \"GET\", {\r\n collections: collections !== undefined ? String(collections) : undefined,\r\n featured: featured ?? false,\r\n username,\r\n query,\r\n width,\r\n height,\r\n orientation: orientation ?? \"landscape\",\r\n count: count ?? 1,\r\n });\r\n };\r\n\r\n getPhotoStatistics = (id: string, resolution?: string, quantity?: number): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_PHOTO_STATISTICS.replace(/:id/gi, id), \"GET\", {\r\n resolution: resolution ?? \"days\",\r\n quantity: quantity ?? 30,\r\n });\r\n };\r\n\r\n getPhotoLink = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_PHOTO_DOWNLOAD_LINK.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n updatePhoto = (\r\n id: string,\r\n location: Record = {},\r\n exif: Record = {}\r\n ): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UPDATE_A_PHOTO.replace(/:id/gi, id), \"PUT\", {\r\n ...(location.latitude ? { \"location[latitude]\": location.latitude } : {}),\r\n ...(location.longitude ? { \"location[longitude]\": location.longitude } : {}),\r\n ...(location.name ? { \"location[name]\": location.name } : {}),\r\n ...(location.city ? { \"location[city]\": location.city } : {}),\r\n ...(location.country ? { \"location[country]\": location.country } : {}),\r\n ...(location.confidential ? { \"location[confidential]\": location.confidential } : {}),\r\n ...(exif.make ? { \"exif[make]\": exif.make } : {}),\r\n ...(exif.model ? { \"exif[model]\": exif.model } : {}),\r\n ...(exif.exposure_time ? { \"exif[exposure_time]\": exif.exposure_time } : {}),\r\n ...(exif.aperture_value ? { \"exif[aperture_value]\": exif.aperture_value } : {}),\r\n ...(exif.focal_length ? { \"exif[focal_length]\": exif.focal_length } : {}),\r\n ...(exif.iso_speed_ratings ? { \"exif[iso_speed_ratings]\": exif.iso_speed_ratings } : {}),\r\n });\r\n };\r\n\r\n likePhoto = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIKE_A_PHOTO.replace(/:id/gi, id), \"POST\");\r\n };\r\n\r\n unlikePhoto = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UNLIKE_A_PHOTO.replace(/:id/gi, id), \"DELETE\");\r\n };\r\n\r\n search = (query: string, page?: number, per_page?: number, collections?: string | number, orientation?: string): Promise => {\r\n this.validateRequired(query, \"query\");\r\n this.validateSupportedValue(orientation, this.availableOrientations, \"orientation\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.SEARCH_PHOTOS, \"GET\", {\r\n query,\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n collections: collections !== undefined ? String(collections) : undefined,\r\n orientation,\r\n });\r\n };\r\n\r\n searchCollections = (query: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(query, \"query\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.SEARCH_COLLECTIONS, \"GET\", {\r\n query,\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n searchUsers = (query: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(query, \"query\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.SEARCH_USERS, \"GET\", {\r\n query,\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n getStatsTotals = (): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.STATS_TOTALS, \"GET\");\r\n };\r\n\r\n getStatsMonth = (): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.STATS_MONTH, \"GET\");\r\n };\r\n\r\n listCollections = (page?: number, per_page?: number): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_COLLECTIONS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n listFeaturedCollections = (page?: number, per_page?: number): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_FEATURED_COLLECTIONS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n listCuratedCollections = (page?: number, per_page?: number): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_CURATED_COLLECTIONS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n getCollection = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_COLLECTION.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n getCuratedCollection = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_CURATED_COLLECTION.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n getCollectionPhotos = (id: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_COLLECTION_PHOTOS.replace(/:id/gi, id), \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n getCuratedCollectionPhotos = (id: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_CURATED_COLLECTION_PHOTOS.replace(/:id/gi, id), \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n listRelatedCollections = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_RELATED_COLLECTION.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n /** Fetch a photo using the newer alias. */\r\n getPhoto = (id: string, width?: number, height?: number, rect?: string): Promise => {\r\n return this.getAPhoto(id, width, height, rect);\r\n };\r\n\r\n getRandomPhoto = (\r\n collections?: string | number,\r\n featured?: boolean,\r\n username?: string,\r\n query?: string,\r\n width?: number,\r\n height?: number,\r\n orientation?: string,\r\n count?: number\r\n ): Promise => {\r\n return this.getARandomPhoto(collections, featured, username, query, width, height, orientation, count);\r\n };\r\n\r\n createNewCollection = (title: string, description?: string, private_collection: boolean = false): Promise => {\r\n this.validateRequired(title, \"title\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.CREATE_NEW_COLLECTION, \"POST\", {\r\n title,\r\n description,\r\n private: private_collection,\r\n });\r\n };\r\n\r\n /** Create a collection using the newer alias. */\r\n createCollection = (title: string, description?: string, private_collection: boolean = false): Promise => {\r\n return this.createNewCollection(title, description, private_collection);\r\n };\r\n\r\n /**\r\n * Backward-compatible alias for createNewCollection.\r\n * @deprecated Use createNewCollection instead.\r\n */\r\n createNewColection = (title: string, description?: string, private_collection: boolean = false): Promise => {\r\n return this.createNewCollection(title, description, private_collection);\r\n };\r\n\r\n updateExistingCollection = (id: string, title: string, description?: string, private_collection: boolean = false): Promise => {\r\n this.validateRequired(id, \"id\");\r\n this.validateRequired(title, \"title\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UPDATE_EXISTING_COLLECTION.replace(/:id/gi, id), \"PUT\", {\r\n title,\r\n description,\r\n private: private_collection,\r\n });\r\n };\r\n\r\n /** Update an existing collection using the newer alias. */\r\n updateCollection = (id: string, title: string, description?: string, private_collection: boolean = false): Promise => {\r\n return this.updateExistingCollection(id, title, description, private_collection);\r\n };\r\n\r\n deleteCollection = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.DELETE_COLLECTION.replace(/:id/gi, id), \"DELETE\");\r\n };\r\n\r\n addPhotoToCollection = (collection_id: string, photo_id: string): Promise => {\r\n this.validateRequired(collection_id, \"collection_id\");\r\n this.validateRequired(photo_id, \"photo_id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.ADD_PHOTO_TO_COLLECTION.replace(/:collection_id/gi, collection_id), \"POST\", {\r\n photo_id,\r\n });\r\n };\r\n\r\n removePhotoFromCollection = (collection_id: string, photo_id: string): Promise => {\r\n this.validateRequired(collection_id, \"collection_id\");\r\n this.validateRequired(photo_id, \"photo_id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.REMOVE_PHOTO_FROM_COLLECTION.replace(/:collection_id/gi, collection_id), \"DELETE\", {\r\n photo_id,\r\n });\r\n };\r\n}\r\n\r\nexport { WrapSplashError };\r\nexport default WrapSplashApi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CAEA,gBAAwB,GAAwB;EAS9C,OARI,aAAiB,QACZ,EAAM,UAGX,OAAO,KAAU,WACZ,IAGF;CACT;CAEA,sBAA8B,GAAiC;EAC7D,IAAI,aAAiB,GACnB,OAAO;EAGT,IAAM,IAAa,OAAO,KAAU,YAAY,KAAkB,cAAc,KAAS,EAAM,YAAY,OAAO,EAAM,YAAa,YAAY,YAAY,EAAM,WAAY,EAAM,SAAiC,SAAS,KAAA,GACzN,IAAa,OAAO,KAAU,YAAY,KAAkB,cAAc,KAAS,EAAM,YAAY,OAAO,EAAM,YAAa,YAAY,gBAAgB,EAAM,WAAY,EAAM,SAAqC,aAAa,KAAA;EAE3O,OAAO,IAAI,EAAgB,KAAK,gBAAgB,CAAK,GAAG;GACtD,OAAO;GACP;GACA;EACF,CAAC;CACH;CAEA,SACE,GACA,GACA,IAA+B,CAAC,GAChC,IAAgB,KAAA,GACJ;EAQZ,OAAO,IAPU,EAAU;GACzB,SAAS,KAAK;GACd,SAAS,KAAK;GACd,SAAS,KAAK;GACd,cAAc,KAAK;EACrB,CAEO,CAAA,CACJ,YAAY,GAAK,EAAO,YAAY,GAAG,KAAK,qBAAqB,CAAe,GAAG,CAAI,CAAC,CACxF,MAAM,MAAQ;GACb,IAAM,IAAW;GAkBjB,OAhBI,EAAS,WAAW,MACf;IACL,QAAQ,EAAS;IACjB,YAAY,EAAS;IACrB,SAAS;GACX,IAGE,EAAS,WAAW,MACf;IACL,QAAQ,EAAS;IACjB,YAAY,EAAS;IACrB,SAAS;GACX,IAGK,EAAS;EAClB,CAAC,CAAC,CACD,OAAO,MAAiB,QAAQ,OAAO,KAAK,sBAAsB,CAAG,CAAC,CAAC;CAC5E;AA2YF"} \ No newline at end of file diff --git a/dist/wrapsplash.umd.js b/dist/wrapsplash.umd.js index d85f580..2a4b2a1 100644 --- a/dist/wrapsplash.umd.js +++ b/dist/wrapsplash.umd.js @@ -1,2 +1,2 @@ -(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("axios")):typeof define==`function`&&define.amd?define([`exports`,`axios`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.wrapsplash={},e.axios))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),l=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;lt[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e},u=(e,t,i)=>(i=e==null?{}:n(o(e)),l(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e));t=u(t);var d=c(((e,t)=>{t.exports={}})),f=c(((e,t)=>{(function(n,r){typeof e==`object`?t.exports=e=r():typeof define==`function`&&define.amd?define([],r):n.CryptoJS=r()})(e,function(){var e=e||function(e,t){var n;if(typeof window<`u`&&window.crypto&&(n=window.crypto),typeof self<`u`&&self.crypto&&(n=self.crypto),typeof globalThis<`u`&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<`u`&&window.msCrypto&&(n=window.msCrypto),!n&&typeof global<`u`&&global.crypto&&(n=global.crypto),!n&&typeof require==`function`)try{n=d()}catch{}var r=function(){if(n){if(typeof n.getRandomValues==`function`)try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes==`function`)try{return n.randomBytes(4).readInt32LE()}catch{}}throw Error(`Native crypto module could not be used to get secure random number.`)},i=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),a={},o=a.lib={},s=o.Base=function(){return{extend:function(e){var t=i(this);return e&&t.mixIn(e),(!t.hasOwnProperty(`init`)||this.init===t.init)&&(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty(`toString`)&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),c=o.WordArray=s.extend({init:function(e,n){e=this.words=e||[],n==t?this.sigBytes=e.length*4:this.sigBytes=n},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var a=0;a>>2]>>>24-a%4*8&255;t[r+a>>>2]|=o<<24-(r+a)%4*8}else for(var s=0;s>>2]=n[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n>>2]>>>24-i%4*8&255;r.push((a>>>4).toString(16)),r.push((a&15).toString(16))}return r.join(``)},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},f=l.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(a))}return r.join(``)},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(e.charCodeAt(r)&255)<<24-r%4*8;return new c.init(n,t)}},p=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch{throw Error(`Malformed UTF-8 data`)}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},m=o.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){typeof e==`string`&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,r=this._data,i=r.words,a=r.sigBytes,o=this.blockSize,s=a/(o*4);s=t?e.ceil(s):e.max((s|0)-this._minBufferSize,0);var l=s*o,u=e.min(l*4,a);if(l){for(var d=0;d{(function(n,r){typeof e==`object`?t.exports=e=r(f()):typeof define==`function`&&define.amd?define([`./core`],r):r(n.CryptoJS)})(e,function(e){return(function(t){var n=e,r=n.lib,i=r.WordArray,a=r.Hasher,o=n.algo,s=[],c=[];(function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(e){return(e-(e|0))*4294967296|0}for(var r=2,i=0;i<64;)e(r)&&(i<8&&(s[i]=n(t.pow(r,1/2))),c[i]=n(t.pow(r,1/3)),i++),r++})();var l=[],u=o.SHA256=a.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],u=n[5],d=n[6],f=n[7],p=0;p<64;p++){if(p<16)l[p]=e[t+p]|0;else{var m=l[p-15],h=(m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3,g=l[p-2],_=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;l[p]=h+l[p-7]+_+l[p-16]}var v=s&u^~s&d,y=r&i^r&a^i&a,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),x=(s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25),S=f+x+v+c[p]+l[p],C=b+y;f=d,d=u,u=s,s=o+S|0,o=a,a=i,i=r,r=S+C|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+s|0,n[5]=n[5]+u|0,n[6]=n[6]+d|0,n[7]=n[7]+f|0},_doFinalize:function(){var e=this._data,n=e.words,r=this._nDataBytes*8,i=e.sigBytes*8;return n[i>>>5]|=128<<24-i%32,n[(i+64>>>9<<4)+14]=t.floor(r/4294967296),n[(i+64>>>9<<4)+15]=r,e.sigBytes=n.length*4,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});n.SHA256=a._createHelper(u),n.HmacSHA256=a._createHmacHelper(u)})(Math),e.SHA256})}))()),m={url:``,method:``,baseURL:``,headers:{},data:{},timeout:1e3,withCredentials:!1,responseType:`json`,responseEncoding:`utf8`,validateStatus:function(e){return e>=200&&e<300},maxRedirects:5,socketPath:null},h=class{http;retries;retryDelayMs;constructor(e){this.http=t.default.create(e||m),this.retries=e?.retries??2,this.retryDelayMs=e?.retryDelayMs??100}async sleep(e){await new Promise(t=>setTimeout(t,e))}async makeRequest(e,t,n,r){if(!e)throw Error(`URL required`);let i;for(let a=0;a<=this.retries;a+=1)try{return await this.http({method:t||`get`,url:e,params:n,data:r})}catch(e){if(i=e,a>=this.retries)throw e;this.retryDelayMs>0&&await this.sleep(this.retryDelayMs)}throw i}},g={API_LOCATION:`https://api.unsplash.com/`,BEARER_TOKEN_URL:`https://unsplash.com/oauth/token`,USERS_PUBLIC_PROFILE:`users/`,USERS_PORTFOLIO:`users/:username/portfolio`,USERS_PHOTOS:`users/:username/photos`,USERS_LIKED_PHOTOS:`users/:username/likes`,USERS_COLLECTIONS:`users/:username/collections`,USERS_STATISTICS:`users/:username/statistics`,LIST_PHOTOS:`photos`,LIST_CURATED_PHOTOS:`photos/curated`,GET_A_PHOTO:`photos/:id`,GET_A_RANDOM_PHOTO:`photos/random`,GET_A_PHOTO_STATISTICS:`photos/:id/statistics`,GET_A_PHOTO_DOWNLOAD_LINK:`photos/:id/download`,UPDATE_A_PHOTO:`photos/:id`,LIKE_A_PHOTO:`photos/:id/like`,UNLIKE_A_PHOTO:`photos/:id/like`,SEARCH_PHOTOS:`search/photos`,SEARCH_COLLECTIONS:`search/collections`,SEARCH_USERS:`search/users`,CURRENT_USER_PROFILE:`me`,UPDATE_CURRENT_USER_PROFILE:`me`,STATS_TOTALS:`stats/total`,STATS_MONTH:`stats/month`,LIST_COLLECTIONS:`collections`,LIST_FEATURED_COLLECTIONS:`collections/featured`,LIST_CURATED_COLLECTIONS:`collections/curated`,GET_COLLECTION:`collections/:id`,GET_CURATED_COLLECTION:`collections/curated/:id`,GET_COLLECTION_PHOTOS:`collections/:id/photos`,GET_CURATED_COLLECTION_PHOTOS:`collections/curated/:id/photos`,LIST_RELATED_COLLECTION:`collections/:id/related`,CREATE_NEW_COLLECTION:`collections`,UPDATE_EXISTING_COLLECTION:`collections/:id`,DELETE_COLLECTION:`collections/:id`,ADD_PHOTO_TO_COLLECTION:`collections/:collection_id/add`,REMOVE_PHOTO_FROM_COLLECTION:`collections/:collection_id/remove`},_=class extends Error{constructor(e,t,n,r){super(e),this.name=`WrapSplashError`,typeof t==`object`&&t&&!Array.isArray(t)?(this.cause=t.cause,this.statusCode=t.statusCode,this.statusText=t.statusText):typeof t==`number`&&(this.statusCode=t,this.statusText=n,this.cause=r),Object.setPrototypeOf(this,new.target.prototype)}},v=class{constructor(){this.API_LOCATION=g.API_LOCATION,this.BEARER_TOKEN_URL=g.BEARER_TOKEN_URL,this.options={},this.access_key=``,this.secret_key=``,this.redirect_uri=``,this.code=``,this.grant_type=`authorization_code`,this.bearer_token=``,this.timeout=1e4,this.retries=2,this.retryDelayMs=100,this.headers={"Content-type":`application/json`,"X-Requested-With":`WrapSplash`},this.availableOrders=[`latest`,`oldest`,`popular`],this.availableOrientations=[`landscape`,`portrait`,`squarish`],this.init=(e={})=>{if(!e||typeof e!=`object`||Array.isArray(e))throw new _(`Initialisation parameters required!`);if(this.options={...e},this.timeout=typeof this.options.timeout==`number`&&this.options.timeout>0?this.options.timeout:1e4,this.retries=typeof this.options.retries==`number`&&this.options.retries>=0?this.options.retries:2,this.retryDelayMs=typeof this.options.retryDelayMs==`number`&&this.options.retryDelayMs>=0?this.options.retryDelayMs:100,this.bearer_token=this.options.bearer_token??``,this.headers={"Content-type":`application/json`,"X-Requested-With":`WrapSplash`},this.options.bearer_token){this.headers={...this.headers,Authorization:`Bearer ${this.options.bearer_token}`,"X-WrapSplash-Header":this.computeHash(this.options.bearer_token)};return}this.access_key=this.options.access_key?this.options.access_key:(()=>{throw new _(`Access Key missing!`)})(),this.secret_key=this.options.secret_key?this.options.secret_key:(()=>{throw new _(`Secret Key missing!`)})(),this.redirect_uri=this.options.redirect_uri?this.options.redirect_uri:(()=>{throw new _(`Redirect URI missing!`)})(),this.code=this.options.code?this.options.code:(()=>{throw new _(`Authorization Code missing!`)})(),this.headers={...this.headers,Authorization:`Client-ID ${this.options.access_key}`,"X-WrapSplash-Header":this.computeHash(this.options.access_key)}},this.generateBearerToken=()=>(this.validateRequired(this.access_key,`access_key`),this.validateRequired(this.secret_key,`secret_key`),this.validateRequired(this.redirect_uri,`redirect_uri`),this.validateRequired(this.code,`code`),this.fetchUrl(this.BEARER_TOKEN_URL,`POST`,{client_id:this.access_key,client_secret:this.secret_key,redirect_uri:this.redirect_uri,code:this.code,grant_type:this.grant_type})),this.getCurrentUserProfile=()=>this.fetchUrl(this.API_LOCATION+g.CURRENT_USER_PROFILE,`GET`),this.updateCurrentUserProfile=(e,t,n,r,i,a,o,s)=>this.fetchUrl(this.API_LOCATION+g.UPDATE_CURRENT_USER_PROFILE,`PUT`,{username:e,first_name:t,last_name:n,email:r,url:i,location:a,bio:o,instagram_username:s}),this.getPublicProfile=(e,t,n)=>(this.validateRequired(e,`username`),this.fetchUrl(this.API_LOCATION+g.USERS_PUBLIC_PROFILE+e,`GET`,{w:t,h:n})),this.getUserPortfolio=e=>(this.validateRequired(e,`username`),this.fetchUrl(this.API_LOCATION+g.USERS_PORTFOLIO.replace(/:username/gi,e),`GET`)),this.getUserPhotos=(e,t,n,r,i,a,o)=>{if(this.validateRequired(e,`username`),this.validateSupportedValue(o,this.availableOrders,`order_by`),r!==void 0&&typeof r!=`boolean`)throw new _(`Parameter : stats is a boolean or optional!`);return this.fetchUrl(this.API_LOCATION+g.USERS_PHOTOS.replace(/:username/gi,e),`GET`,{page:t??1,per_page:n??10,order_by:o??`latest`,stats:r??!1,resolution:i??`days`,quantity:a??30})},this.getUserLikedPhotos=(e,t,n,r)=>(this.validateRequired(e,`username`),this.validateSupportedValue(r,this.availableOrders,`order_by`),this.fetchUrl(this.API_LOCATION+g.USERS_LIKED_PHOTOS.replace(/:username/gi,e),`GET`,{page:t??1,per_page:n??10,order_by:r??`latest`})),this.getUserCollections=(e,t,n)=>(this.validateRequired(e,`username`),this.fetchUrl(this.API_LOCATION+g.USERS_COLLECTIONS.replace(/:username/gi,e),`GET`,{page:t??1,per_page:n??10})),this.getUserStatistics=(e,t,n)=>(this.validateRequired(e,`username`),this.fetchUrl(this.API_LOCATION+g.USERS_STATISTICS.replace(/:username/gi,e),`GET`,{resolution:t??`days`,quantity:n??30})),this.listPhotos=(e,t,n)=>{if(n!==void 0&&!this.availableOrders.includes(n))throw new _(`Parameter : order_by has an unsupported value!`);return this.fetchUrl(this.API_LOCATION+g.LIST_PHOTOS,`GET`,{page:e??1,per_page:t??10,order_by:n??`latest`})},this.listCuratedPhotos=(e,t,n)=>{if(n!==void 0&&!this.availableOrders.includes(n))throw new _(`Parameter : order_by has an unsupported value!`);return this.fetchUrl(this.API_LOCATION+g.LIST_CURATED_PHOTOS,`GET`,{page:e??1,per_page:t??10,order_by:n??`latest`})},this.getAPhoto=(e,t,n,r)=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+g.GET_A_PHOTO.replace(/:id/gi,e),`GET`,{w:t,h:n,rect:typeof r==`string`?r:void 0})),this.getARandomPhoto=(e,t,n,r,i,a,o,s)=>(this.validateSupportedValue(o,this.availableOrientations,`orientation`),this.fetchUrl(this.API_LOCATION+g.GET_A_RANDOM_PHOTO,`GET`,{collections:e===void 0?void 0:String(e),featured:t??!1,username:n,query:r,width:i,height:a,orientation:o??`landscape`,count:s??1})),this.getPhotoStatistics=(e,t,n)=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+g.GET_A_PHOTO_STATISTICS.replace(/:id/gi,e),`GET`,{resolution:t??`days`,quantity:n??30})),this.getPhotoLink=e=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+g.GET_A_PHOTO_DOWNLOAD_LINK.replace(/:id/gi,e),`GET`)),this.updatePhoto=(e,t={},n={})=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+g.UPDATE_A_PHOTO.replace(/:id/gi,e),`PUT`,{...t.latitude?{"location[latitude]":t.latitude}:{},...t.longitude?{"location[longitude]":t.longitude}:{},...t.name?{"location[name]":t.name}:{},...t.city?{"location[city]":t.city}:{},...t.country?{"location[country]":t.country}:{},...t.confidential?{"location[confidential]":t.confidential}:{},...n.make?{"exif[make]":n.make}:{},...n.model?{"exif[model]":n.model}:{},...n.exposure_time?{"exif[exposure_time]":n.exposure_time}:{},...n.aperture_value?{"exif[aperture_value]":n.aperture_value}:{},...n.focal_length?{"exif[focal_length]":n.focal_length}:{},...n.iso_speed_ratings?{"exif[iso_speed_ratings]":n.iso_speed_ratings}:{}})),this.likePhoto=e=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+g.LIKE_A_PHOTO.replace(/:id/gi,e),`POST`)),this.unlikePhoto=e=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+g.UNLIKE_A_PHOTO.replace(/:id/gi,e),`DELETE`)),this.search=(e,t,n,r,i)=>(this.validateRequired(e,`query`),this.validateSupportedValue(i,this.availableOrientations,`orientation`),this.fetchUrl(this.API_LOCATION+g.SEARCH_PHOTOS,`GET`,{query:e,page:t??1,per_page:n??10,collections:r===void 0?void 0:String(r),orientation:i})),this.searchCollections=(e,t,n)=>(this.validateRequired(e,`query`),this.fetchUrl(this.API_LOCATION+g.SEARCH_COLLECTIONS,`GET`,{query:e,page:t??1,per_page:n??10})),this.searchUsers=(e,t,n)=>(this.validateRequired(e,`query`),this.fetchUrl(this.API_LOCATION+g.SEARCH_USERS,`GET`,{query:e,page:t??1,per_page:n??10})),this.getStatsTotals=()=>this.fetchUrl(this.API_LOCATION+g.STATS_TOTALS,`GET`),this.getStatsMonth=()=>this.fetchUrl(this.API_LOCATION+g.STATS_MONTH,`GET`),this.listCollections=(e,t)=>this.fetchUrl(this.API_LOCATION+g.LIST_COLLECTIONS,`GET`,{page:e??1,per_page:t??10}),this.listFeaturedCollections=(e,t)=>this.fetchUrl(this.API_LOCATION+g.LIST_FEATURED_COLLECTIONS,`GET`,{page:e??1,per_page:t??10}),this.listCuratedCollections=(e,t)=>this.fetchUrl(this.API_LOCATION+g.LIST_CURATED_COLLECTIONS,`GET`,{page:e??1,per_page:t??10}),this.getCollection=e=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+g.GET_COLLECTION.replace(/:id/gi,e),`GET`)),this.getCuratedCollection=e=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+g.GET_CURATED_COLLECTION.replace(/:id/gi,e),`GET`)),this.getCollectionPhotos=(e,t,n)=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+g.GET_COLLECTION_PHOTOS.replace(/:id/gi,e),`GET`,{page:t??1,per_page:n??10})),this.getCuratedCollectionPhotos=(e,t,n)=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+g.GET_CURATED_COLLECTION_PHOTOS.replace(/:id/gi,e),`GET`,{page:t??1,per_page:n??10})),this.listRelatedCollections=e=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+g.LIST_RELATED_COLLECTION.replace(/:id/gi,e),`GET`)),this.getPhoto=(e,t,n,r)=>this.getAPhoto(e,t,n,r),this.getRandomPhoto=(e,t,n,r,i,a,o,s)=>this.getARandomPhoto(e,t,n,r,i,a,o,s),this.createNewCollection=(e,t,n=!1)=>(this.validateRequired(e,`title`),this.fetchUrl(this.API_LOCATION+g.CREATE_NEW_COLLECTION,`POST`,{title:e,description:t,private:n})),this.createCollection=(e,t,n=!1)=>this.createNewCollection(e,t,n),this.createNewColection=(e,t,n=!1)=>this.createNewCollection(e,t,n),this.updateExistingCollection=(e,t,n,r=!1)=>(this.validateRequired(e,`id`),this.validateRequired(t,`title`),this.fetchUrl(this.API_LOCATION+g.UPDATE_EXISTING_COLLECTION.replace(/:id/gi,e),`PUT`,{title:t,description:n,private:r})),this.updateCollection=(e,t,n,r=!1)=>this.updateExistingCollection(e,t,n,r),this.deleteCollection=e=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+g.DELETE_COLLECTION.replace(/:id/gi,e),`DELETE`)),this.addPhotoToCollection=(e,t)=>(this.validateRequired(e,`collection_id`),this.validateRequired(t,`photo_id`),this.fetchUrl(this.API_LOCATION+g.ADD_PHOTO_TO_COLLECTION.replace(/:collection_id/gi,e),`POST`,{photo_id:t})),this.removePhotoFromCollection=(e,t)=>(this.validateRequired(e,`collection_id`),this.validateRequired(t,`photo_id`),this.fetchUrl(this.API_LOCATION+g.REMOVE_PHOTO_FROM_COLLECTION.replace(/:collection_id/gi,e),`DELETE`,{photo_id:t}))}computeHash(e){return(0,p.default)(e).toString()}validateRequired(e,t){if(e==null||e===``)throw new _(t===`id`?`Parameter : id is required!`:t===`query`?`Parameter : query is missing!`:`Parameter : ${t} is required and cannot be empty!`)}validateSupportedValue(e,t,n){if(e!==void 0&&!t.includes(e))throw new _(`Parameter : ${n} has an unsupported value!`)}buildQueryParameters(e){let t={};return Object.entries(e).forEach(([e,n])=>{n!=null&&n!==``&&(t[e]=n)}),t}getErrorMessage(e){return e instanceof Error?e.message:typeof e==`string`?e:`Request failed`}createWrapSplashError(e){if(e instanceof _)return e;let t=typeof e==`object`&&e&&`response`in e&&e.response&&typeof e.response==`object`&&`status`in e.response?e.response.status:void 0,n=typeof e==`object`&&e&&`response`in e&&e.response&&typeof e.response==`object`&&`statusText`in e.response?e.response.statusText:void 0;return new _(this.getErrorMessage(e),{cause:e,statusCode:t,statusText:n})}fetchUrl(e,t,n={},r=void 0){return new h({headers:this.headers,timeout:this.timeout,retries:this.retries,retryDelayMs:this.retryDelayMs}).makeRequest(e,t.toLowerCase(),this.buildQueryParameters(n),r).then(e=>{let t=e;return t.status===204?{status:t.status,statusText:t.statusText,message:`Content Deleted`}:t.status===403?{status:t.status,statusText:t.statusText,message:`Rate Limit Exceeded`}:t.data}).catch(e=>Promise.reject(this.createWrapSplashError(e)))}};e.WrapSplashError=_,e.default=v}); +(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("crypto"),require("axios")):typeof define==`function`&&define.amd?define([`exports`,`crypto`,`axios`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.wrapsplash={},e.crypto,e.axios))})(this,function(e,t,n){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;lt[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)))(n);var u={url:``,method:``,baseURL:``,headers:{},data:{},timeout:1e3,withCredentials:!1,responseType:`json`,responseEncoding:`utf8`,validateStatus:function(e){return e>=200&&e<300},maxRedirects:5,socketPath:null},d=class{http;retries;retryDelayMs;constructor(e){this.http=n.default.create(e||u),this.retries=e?.retries??2,this.retryDelayMs=e?.retryDelayMs??100}sleep(e){return new Promise(t=>setTimeout(t,e))}isRetryableError(e){if(n.default.isCancel(e))return!1;let t=e;if(!t.response)return!0;let r=t.response.status;return r===429||r>=500}getRetryDelay(e,t){let n=e;if(n.response){let e=n.response.headers?.[`retry-after`];if(e){let t=Number(e);if(!Number.isNaN(t)&&t>0)return t*1e3}}return this.retryDelayMs*2**t}async makeRequest(e,t,n,r){if(!e)throw Error(`URL required`);let i;for(let a=0;a<=this.retries;a+=1)try{return await this.http({method:t||`get`,url:e,params:n,data:r})}catch(e){if(i=e,a>=this.retries||!this.isRetryableError(e))throw e;let t=this.getRetryDelay(e,a);t>0&&await this.sleep(t)}throw i}},f={API_LOCATION:`https://api.unsplash.com/`,BEARER_TOKEN_URL:`https://unsplash.com/oauth/token`,USERS_PUBLIC_PROFILE:`users/`,USERS_PORTFOLIO:`users/:username/portfolio`,USERS_PHOTOS:`users/:username/photos`,USERS_LIKED_PHOTOS:`users/:username/likes`,USERS_COLLECTIONS:`users/:username/collections`,USERS_STATISTICS:`users/:username/statistics`,LIST_PHOTOS:`photos`,LIST_CURATED_PHOTOS:`photos/curated`,GET_A_PHOTO:`photos/:id`,GET_A_RANDOM_PHOTO:`photos/random`,GET_A_PHOTO_STATISTICS:`photos/:id/statistics`,GET_A_PHOTO_DOWNLOAD_LINK:`photos/:id/download`,UPDATE_A_PHOTO:`photos/:id`,LIKE_A_PHOTO:`photos/:id/like`,UNLIKE_A_PHOTO:`photos/:id/like`,SEARCH_PHOTOS:`search/photos`,SEARCH_COLLECTIONS:`search/collections`,SEARCH_USERS:`search/users`,CURRENT_USER_PROFILE:`me`,UPDATE_CURRENT_USER_PROFILE:`me`,STATS_TOTALS:`stats/total`,STATS_MONTH:`stats/month`,LIST_COLLECTIONS:`collections`,LIST_FEATURED_COLLECTIONS:`collections/featured`,LIST_CURATED_COLLECTIONS:`collections/curated`,GET_COLLECTION:`collections/:id`,GET_CURATED_COLLECTION:`collections/curated/:id`,GET_COLLECTION_PHOTOS:`collections/:id/photos`,GET_CURATED_COLLECTION_PHOTOS:`collections/curated/:id/photos`,LIST_RELATED_COLLECTION:`collections/:id/related`,CREATE_NEW_COLLECTION:`collections`,UPDATE_EXISTING_COLLECTION:`collections/:id`,DELETE_COLLECTION:`collections/:id`,ADD_PHOTO_TO_COLLECTION:`collections/:collection_id/add`,REMOVE_PHOTO_FROM_COLLECTION:`collections/:collection_id/remove`},p=class extends Error{constructor(e,t,n,r){super(e),this.name=`WrapSplashError`,typeof t==`object`&&t&&!Array.isArray(t)?(this.cause=t.cause,this.statusCode=t.statusCode,this.statusText=t.statusText):typeof t==`number`&&(this.statusCode=t,this.statusText=n,this.cause=r),Object.setPrototypeOf(this,new.target.prototype)}},m=class{constructor(){this.API_LOCATION=f.API_LOCATION,this.BEARER_TOKEN_URL=f.BEARER_TOKEN_URL,this.options={},this.access_key=``,this.secret_key=``,this.redirect_uri=``,this.code=``,this.grant_type=`authorization_code`,this.bearer_token=``,this.timeout=1e4,this.retries=2,this.retryDelayMs=100,this.headers={"Content-type":`application/json`,"X-Requested-With":`WrapSplash`},this.availableOrders=[`latest`,`oldest`,`popular`],this.availableOrientations=[`landscape`,`portrait`,`squarish`],this.init=(e={})=>{if(!e||typeof e!=`object`||Array.isArray(e))throw new p(`Initialisation parameters required!`);if(this.options={...e},this.timeout=typeof this.options.timeout==`number`&&this.options.timeout>0?this.options.timeout:1e4,this.retries=typeof this.options.retries==`number`&&this.options.retries>=0?this.options.retries:2,this.retryDelayMs=typeof this.options.retryDelayMs==`number`&&this.options.retryDelayMs>=0?this.options.retryDelayMs:100,this.bearer_token=this.options.bearer_token??``,this.headers={"Content-type":`application/json`,"X-Requested-With":`WrapSplash`},this.options.bearer_token){this.headers={...this.headers,Authorization:`Bearer ${this.options.bearer_token}`,"X-WrapSplash-Header":this.computeHash(this.options.bearer_token)};return}this.access_key=this.options.access_key?this.options.access_key:(()=>{throw new p(`Access Key missing!`)})(),this.secret_key=this.options.secret_key?this.options.secret_key:(()=>{throw new p(`Secret Key missing!`)})(),this.redirect_uri=this.options.redirect_uri?this.options.redirect_uri:(()=>{throw new p(`Redirect URI missing!`)})(),this.code=this.options.code?this.options.code:(()=>{throw new p(`Authorization Code missing!`)})(),this.headers={...this.headers,Authorization:`Client-ID ${this.options.access_key}`,"X-WrapSplash-Header":this.computeHash(this.options.access_key)}},this.generateBearerToken=()=>(this.validateRequired(this.access_key,`access_key`),this.validateRequired(this.secret_key,`secret_key`),this.validateRequired(this.redirect_uri,`redirect_uri`),this.validateRequired(this.code,`code`),this.fetchUrl(this.BEARER_TOKEN_URL,`POST`,{client_id:this.access_key,client_secret:this.secret_key,redirect_uri:this.redirect_uri,code:this.code,grant_type:this.grant_type})),this.getCurrentUserProfile=()=>this.fetchUrl(this.API_LOCATION+f.CURRENT_USER_PROFILE,`GET`),this.updateCurrentUserProfile=(e,t,n,r,i,a,o,s)=>this.fetchUrl(this.API_LOCATION+f.UPDATE_CURRENT_USER_PROFILE,`PUT`,{username:e,first_name:t,last_name:n,email:r,url:i,location:a,bio:o,instagram_username:s}),this.getPublicProfile=(e,t,n)=>(this.validateRequired(e,`username`),this.fetchUrl(this.API_LOCATION+f.USERS_PUBLIC_PROFILE+e,`GET`,{w:t,h:n})),this.getUserPortfolio=e=>(this.validateRequired(e,`username`),this.fetchUrl(this.API_LOCATION+f.USERS_PORTFOLIO.replace(/:username/gi,e),`GET`)),this.getUserPhotos=(e,t,n,r,i,a,o)=>{if(this.validateRequired(e,`username`),this.validateSupportedValue(o,this.availableOrders,`order_by`),r!==void 0&&typeof r!=`boolean`)throw new p(`Parameter : stats is a boolean or optional!`);return this.fetchUrl(this.API_LOCATION+f.USERS_PHOTOS.replace(/:username/gi,e),`GET`,{page:t??1,per_page:n??10,order_by:o??`latest`,stats:r??!1,resolution:i??`days`,quantity:a??30})},this.getUserLikedPhotos=(e,t,n,r)=>(this.validateRequired(e,`username`),this.validateSupportedValue(r,this.availableOrders,`order_by`),this.fetchUrl(this.API_LOCATION+f.USERS_LIKED_PHOTOS.replace(/:username/gi,e),`GET`,{page:t??1,per_page:n??10,order_by:r??`latest`})),this.getUserCollections=(e,t,n)=>(this.validateRequired(e,`username`),this.fetchUrl(this.API_LOCATION+f.USERS_COLLECTIONS.replace(/:username/gi,e),`GET`,{page:t??1,per_page:n??10})),this.getUserStatistics=(e,t,n)=>(this.validateRequired(e,`username`),this.fetchUrl(this.API_LOCATION+f.USERS_STATISTICS.replace(/:username/gi,e),`GET`,{resolution:t??`days`,quantity:n??30})),this.listPhotos=(e,t,n)=>{if(n!==void 0&&!this.availableOrders.includes(n))throw new p(`Parameter : order_by has an unsupported value!`);return this.fetchUrl(this.API_LOCATION+f.LIST_PHOTOS,`GET`,{page:e??1,per_page:t??10,order_by:n??`latest`})},this.listCuratedPhotos=(e,t,n)=>{if(n!==void 0&&!this.availableOrders.includes(n))throw new p(`Parameter : order_by has an unsupported value!`);return this.fetchUrl(this.API_LOCATION+f.LIST_CURATED_PHOTOS,`GET`,{page:e??1,per_page:t??10,order_by:n??`latest`})},this.getAPhoto=(e,t,n,r)=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+f.GET_A_PHOTO.replace(/:id/gi,e),`GET`,{w:t,h:n,rect:typeof r==`string`?r:void 0})),this.getARandomPhoto=(e,t,n,r,i,a,o,s)=>(this.validateSupportedValue(o,this.availableOrientations,`orientation`),this.fetchUrl(this.API_LOCATION+f.GET_A_RANDOM_PHOTO,`GET`,{collections:e===void 0?void 0:String(e),featured:t??!1,username:n,query:r,width:i,height:a,orientation:o??`landscape`,count:s??1})),this.getPhotoStatistics=(e,t,n)=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+f.GET_A_PHOTO_STATISTICS.replace(/:id/gi,e),`GET`,{resolution:t??`days`,quantity:n??30})),this.getPhotoLink=e=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+f.GET_A_PHOTO_DOWNLOAD_LINK.replace(/:id/gi,e),`GET`)),this.updatePhoto=(e,t={},n={})=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+f.UPDATE_A_PHOTO.replace(/:id/gi,e),`PUT`,{...t.latitude?{"location[latitude]":t.latitude}:{},...t.longitude?{"location[longitude]":t.longitude}:{},...t.name?{"location[name]":t.name}:{},...t.city?{"location[city]":t.city}:{},...t.country?{"location[country]":t.country}:{},...t.confidential?{"location[confidential]":t.confidential}:{},...n.make?{"exif[make]":n.make}:{},...n.model?{"exif[model]":n.model}:{},...n.exposure_time?{"exif[exposure_time]":n.exposure_time}:{},...n.aperture_value?{"exif[aperture_value]":n.aperture_value}:{},...n.focal_length?{"exif[focal_length]":n.focal_length}:{},...n.iso_speed_ratings?{"exif[iso_speed_ratings]":n.iso_speed_ratings}:{}})),this.likePhoto=e=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+f.LIKE_A_PHOTO.replace(/:id/gi,e),`POST`)),this.unlikePhoto=e=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+f.UNLIKE_A_PHOTO.replace(/:id/gi,e),`DELETE`)),this.search=(e,t,n,r,i)=>(this.validateRequired(e,`query`),this.validateSupportedValue(i,this.availableOrientations,`orientation`),this.fetchUrl(this.API_LOCATION+f.SEARCH_PHOTOS,`GET`,{query:e,page:t??1,per_page:n??10,collections:r===void 0?void 0:String(r),orientation:i})),this.searchCollections=(e,t,n)=>(this.validateRequired(e,`query`),this.fetchUrl(this.API_LOCATION+f.SEARCH_COLLECTIONS,`GET`,{query:e,page:t??1,per_page:n??10})),this.searchUsers=(e,t,n)=>(this.validateRequired(e,`query`),this.fetchUrl(this.API_LOCATION+f.SEARCH_USERS,`GET`,{query:e,page:t??1,per_page:n??10})),this.getStatsTotals=()=>this.fetchUrl(this.API_LOCATION+f.STATS_TOTALS,`GET`),this.getStatsMonth=()=>this.fetchUrl(this.API_LOCATION+f.STATS_MONTH,`GET`),this.listCollections=(e,t)=>this.fetchUrl(this.API_LOCATION+f.LIST_COLLECTIONS,`GET`,{page:e??1,per_page:t??10}),this.listFeaturedCollections=(e,t)=>this.fetchUrl(this.API_LOCATION+f.LIST_FEATURED_COLLECTIONS,`GET`,{page:e??1,per_page:t??10}),this.listCuratedCollections=(e,t)=>this.fetchUrl(this.API_LOCATION+f.LIST_CURATED_COLLECTIONS,`GET`,{page:e??1,per_page:t??10}),this.getCollection=e=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+f.GET_COLLECTION.replace(/:id/gi,e),`GET`)),this.getCuratedCollection=e=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+f.GET_CURATED_COLLECTION.replace(/:id/gi,e),`GET`)),this.getCollectionPhotos=(e,t,n)=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+f.GET_COLLECTION_PHOTOS.replace(/:id/gi,e),`GET`,{page:t??1,per_page:n??10})),this.getCuratedCollectionPhotos=(e,t,n)=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+f.GET_CURATED_COLLECTION_PHOTOS.replace(/:id/gi,e),`GET`,{page:t??1,per_page:n??10})),this.listRelatedCollections=e=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+f.LIST_RELATED_COLLECTION.replace(/:id/gi,e),`GET`)),this.getPhoto=(e,t,n,r)=>this.getAPhoto(e,t,n,r),this.getRandomPhoto=(e,t,n,r,i,a,o,s)=>this.getARandomPhoto(e,t,n,r,i,a,o,s),this.createNewCollection=(e,t,n=!1)=>(this.validateRequired(e,`title`),this.fetchUrl(this.API_LOCATION+f.CREATE_NEW_COLLECTION,`POST`,{title:e,description:t,private:n})),this.createCollection=(e,t,n=!1)=>this.createNewCollection(e,t,n),this.createNewColection=(e,t,n=!1)=>this.createNewCollection(e,t,n),this.updateExistingCollection=(e,t,n,r=!1)=>(this.validateRequired(e,`id`),this.validateRequired(t,`title`),this.fetchUrl(this.API_LOCATION+f.UPDATE_EXISTING_COLLECTION.replace(/:id/gi,e),`PUT`,{title:t,description:n,private:r})),this.updateCollection=(e,t,n,r=!1)=>this.updateExistingCollection(e,t,n,r),this.deleteCollection=e=>(this.validateRequired(e,`id`),this.fetchUrl(this.API_LOCATION+f.DELETE_COLLECTION.replace(/:id/gi,e),`DELETE`)),this.addPhotoToCollection=(e,t)=>(this.validateRequired(e,`collection_id`),this.validateRequired(t,`photo_id`),this.fetchUrl(this.API_LOCATION+f.ADD_PHOTO_TO_COLLECTION.replace(/:collection_id/gi,e),`POST`,{photo_id:t})),this.removePhotoFromCollection=(e,t)=>(this.validateRequired(e,`collection_id`),this.validateRequired(t,`photo_id`),this.fetchUrl(this.API_LOCATION+f.REMOVE_PHOTO_FROM_COLLECTION.replace(/:collection_id/gi,e),`DELETE`,{photo_id:t}))}computeHash(e){return(0,t.createHash)(`sha256`).update(e).digest(`hex`)}validateRequired(e,t){if(e==null||e===``)throw new p(t===`id`?`Parameter : id is required!`:t===`query`?`Parameter : query is missing!`:`Parameter : ${t} is required and cannot be empty!`)}validateSupportedValue(e,t,n){if(e!==void 0&&!t.includes(e))throw new p(`Parameter : ${n} has an unsupported value!`)}buildQueryParameters(e){let t={};return Object.entries(e).forEach(([e,n])=>{n!=null&&n!==``&&(t[e]=n)}),t}getErrorMessage(e){return e instanceof Error?e.message:typeof e==`string`?e:`Request failed`}createWrapSplashError(e){if(e instanceof p)return e;let t=typeof e==`object`&&e&&`response`in e&&e.response&&typeof e.response==`object`&&`status`in e.response?e.response.status:void 0,n=typeof e==`object`&&e&&`response`in e&&e.response&&typeof e.response==`object`&&`statusText`in e.response?e.response.statusText:void 0;return new p(this.getErrorMessage(e),{cause:e,statusCode:t,statusText:n})}fetchUrl(e,t,n={},r=void 0){return new d({headers:this.headers,timeout:this.timeout,retries:this.retries,retryDelayMs:this.retryDelayMs}).makeRequest(e,t.toLowerCase(),this.buildQueryParameters(n),r).then(e=>{let t=e;return t.status===204?{status:t.status,statusText:t.statusText,message:`Content Deleted`}:t.status===403?{status:t.status,statusText:t.statusText,message:`Rate Limit Exceeded`}:t.data}).catch(e=>Promise.reject(this.createWrapSplashError(e)))}};e.WrapSplashError=p,e.default=m}); //# sourceMappingURL=wrapsplash.umd.js.map \ No newline at end of file diff --git a/dist/wrapsplash.umd.js.map b/dist/wrapsplash.umd.js.map index 292d3ca..9d9fccf 100644 --- a/dist/wrapsplash.umd.js.map +++ b/dist/wrapsplash.umd.js.map @@ -1 +1 @@ -{"version":3,"file":"wrapsplash.umd.js","names":[],"sources":["../__vite-browser-external","../node_modules/crypto-js/core.js","../node_modules/crypto-js/sha256.js","../config/axiosConfig.ts","../lib/axiosAjaxLib.ts","../config/url_config.json","../src/index.ts"],"sourcesContent":["module.exports = {}",";(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory();\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\troot.CryptoJS = factory();\n\t}\n}(this, function () {\n\n\t/*globals window, global, require*/\n\n\t/**\n\t * CryptoJS core components.\n\t */\n\tvar CryptoJS = CryptoJS || (function (Math, undefined) {\n\n\t var crypto;\n\n\t // Native crypto from window (Browser)\n\t if (typeof window !== 'undefined' && window.crypto) {\n\t crypto = window.crypto;\n\t }\n\n\t // Native crypto in web worker (Browser)\n\t if (typeof self !== 'undefined' && self.crypto) {\n\t crypto = self.crypto;\n\t }\n\n\t // Native crypto from worker\n\t if (typeof globalThis !== 'undefined' && globalThis.crypto) {\n\t crypto = globalThis.crypto;\n\t }\n\n\t // Native (experimental IE 11) crypto from window (Browser)\n\t if (!crypto && typeof window !== 'undefined' && window.msCrypto) {\n\t crypto = window.msCrypto;\n\t }\n\n\t // Native crypto from global (NodeJS)\n\t if (!crypto && typeof global !== 'undefined' && global.crypto) {\n\t crypto = global.crypto;\n\t }\n\n\t // Native crypto import via require (NodeJS)\n\t if (!crypto && typeof require === 'function') {\n\t try {\n\t crypto = require('crypto');\n\t } catch (err) {}\n\t }\n\n\t /*\n\t * Cryptographically secure pseudorandom number generator\n\t *\n\t * As Math.random() is cryptographically not safe to use\n\t */\n\t var cryptoSecureRandomInt = function () {\n\t if (crypto) {\n\t // Use getRandomValues method (Browser)\n\t if (typeof crypto.getRandomValues === 'function') {\n\t try {\n\t return crypto.getRandomValues(new Uint32Array(1))[0];\n\t } catch (err) {}\n\t }\n\n\t // Use randomBytes method (NodeJS)\n\t if (typeof crypto.randomBytes === 'function') {\n\t try {\n\t return crypto.randomBytes(4).readInt32LE();\n\t } catch (err) {}\n\t }\n\t }\n\n\t throw new Error('Native crypto module could not be used to get secure random number.');\n\t };\n\n\t /*\n\t * Local polyfill of Object.create\n\n\t */\n\t var create = Object.create || (function () {\n\t function F() {}\n\n\t return function (obj) {\n\t var subtype;\n\n\t F.prototype = obj;\n\n\t subtype = new F();\n\n\t F.prototype = null;\n\n\t return subtype;\n\t };\n\t }());\n\n\t /**\n\t * CryptoJS namespace.\n\t */\n\t var C = {};\n\n\t /**\n\t * Library namespace.\n\t */\n\t var C_lib = C.lib = {};\n\n\t /**\n\t * Base object for prototypal inheritance.\n\t */\n\t var Base = C_lib.Base = (function () {\n\n\n\t return {\n\t /**\n\t * Creates a new object that inherits from this object.\n\t *\n\t * @param {Object} overrides Properties to copy into the new object.\n\t *\n\t * @return {Object} The new object.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var MyType = CryptoJS.lib.Base.extend({\n\t * field: 'value',\n\t *\n\t * method: function () {\n\t * }\n\t * });\n\t */\n\t extend: function (overrides) {\n\t // Spawn\n\t var subtype = create(this);\n\n\t // Augment\n\t if (overrides) {\n\t subtype.mixIn(overrides);\n\t }\n\n\t // Create default initializer\n\t if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {\n\t subtype.init = function () {\n\t subtype.$super.init.apply(this, arguments);\n\t };\n\t }\n\n\t // Initializer's prototype is the subtype object\n\t subtype.init.prototype = subtype;\n\n\t // Reference supertype\n\t subtype.$super = this;\n\n\t return subtype;\n\t },\n\n\t /**\n\t * Extends this object and runs the init method.\n\t * Arguments to create() will be passed to init().\n\t *\n\t * @return {Object} The new object.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var instance = MyType.create();\n\t */\n\t create: function () {\n\t var instance = this.extend();\n\t instance.init.apply(instance, arguments);\n\n\t return instance;\n\t },\n\n\t /**\n\t * Initializes a newly created object.\n\t * Override this method to add some logic when your objects are created.\n\t *\n\t * @example\n\t *\n\t * var MyType = CryptoJS.lib.Base.extend({\n\t * init: function () {\n\t * // ...\n\t * }\n\t * });\n\t */\n\t init: function () {\n\t },\n\n\t /**\n\t * Copies properties into this object.\n\t *\n\t * @param {Object} properties The properties to mix in.\n\t *\n\t * @example\n\t *\n\t * MyType.mixIn({\n\t * field: 'value'\n\t * });\n\t */\n\t mixIn: function (properties) {\n\t for (var propertyName in properties) {\n\t if (properties.hasOwnProperty(propertyName)) {\n\t this[propertyName] = properties[propertyName];\n\t }\n\t }\n\n\t // IE won't copy toString using the loop above\n\t if (properties.hasOwnProperty('toString')) {\n\t this.toString = properties.toString;\n\t }\n\t },\n\n\t /**\n\t * Creates a copy of this object.\n\t *\n\t * @return {Object} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = instance.clone();\n\t */\n\t clone: function () {\n\t return this.init.prototype.extend(this);\n\t }\n\t };\n\t }());\n\n\t /**\n\t * An array of 32-bit words.\n\t *\n\t * @property {Array} words The array of 32-bit words.\n\t * @property {number} sigBytes The number of significant bytes in this word array.\n\t */\n\t var WordArray = C_lib.WordArray = Base.extend({\n\t /**\n\t * Initializes a newly created word array.\n\t *\n\t * @param {Array} words (Optional) An array of 32-bit words.\n\t * @param {number} sigBytes (Optional) The number of significant bytes in the words.\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.lib.WordArray.create();\n\t * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);\n\t * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);\n\t */\n\t init: function (words, sigBytes) {\n\t words = this.words = words || [];\n\n\t if (sigBytes != undefined) {\n\t this.sigBytes = sigBytes;\n\t } else {\n\t this.sigBytes = words.length * 4;\n\t }\n\t },\n\n\t /**\n\t * Converts this word array to a string.\n\t *\n\t * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex\n\t *\n\t * @return {string} The stringified word array.\n\t *\n\t * @example\n\t *\n\t * var string = wordArray + '';\n\t * var string = wordArray.toString();\n\t * var string = wordArray.toString(CryptoJS.enc.Utf8);\n\t */\n\t toString: function (encoder) {\n\t return (encoder || Hex).stringify(this);\n\t },\n\n\t /**\n\t * Concatenates a word array to this word array.\n\t *\n\t * @param {WordArray} wordArray The word array to append.\n\t *\n\t * @return {WordArray} This word array.\n\t *\n\t * @example\n\t *\n\t * wordArray1.concat(wordArray2);\n\t */\n\t concat: function (wordArray) {\n\t // Shortcuts\n\t var thisWords = this.words;\n\t var thatWords = wordArray.words;\n\t var thisSigBytes = this.sigBytes;\n\t var thatSigBytes = wordArray.sigBytes;\n\n\t // Clamp excess bits\n\t this.clamp();\n\n\t // Concat\n\t if (thisSigBytes % 4) {\n\t // Copy one byte at a time\n\t for (var i = 0; i < thatSigBytes; i++) {\n\t var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);\n\t }\n\t } else {\n\t // Copy one word at a time\n\t for (var j = 0; j < thatSigBytes; j += 4) {\n\t thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];\n\t }\n\t }\n\t this.sigBytes += thatSigBytes;\n\n\t // Chainable\n\t return this;\n\t },\n\n\t /**\n\t * Removes insignificant bits.\n\t *\n\t * @example\n\t *\n\t * wordArray.clamp();\n\t */\n\t clamp: function () {\n\t // Shortcuts\n\t var words = this.words;\n\t var sigBytes = this.sigBytes;\n\n\t // Clamp\n\t words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);\n\t words.length = Math.ceil(sigBytes / 4);\n\t },\n\n\t /**\n\t * Creates a copy of this word array.\n\t *\n\t * @return {WordArray} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = wordArray.clone();\n\t */\n\t clone: function () {\n\t var clone = Base.clone.call(this);\n\t clone.words = this.words.slice(0);\n\n\t return clone;\n\t },\n\n\t /**\n\t * Creates a word array filled with random bytes.\n\t *\n\t * @param {number} nBytes The number of random bytes to generate.\n\t *\n\t * @return {WordArray} The random word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.lib.WordArray.random(16);\n\t */\n\t random: function (nBytes) {\n\t var words = [];\n\n\t for (var i = 0; i < nBytes; i += 4) {\n\t words.push(cryptoSecureRandomInt());\n\t }\n\n\t return new WordArray.init(words, nBytes);\n\t }\n\t });\n\n\t /**\n\t * Encoder namespace.\n\t */\n\t var C_enc = C.enc = {};\n\n\t /**\n\t * Hex encoding strategy.\n\t */\n\t var Hex = C_enc.Hex = {\n\t /**\n\t * Converts a word array to a hex string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The hex string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hexString = CryptoJS.enc.Hex.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t // Shortcuts\n\t var words = wordArray.words;\n\t var sigBytes = wordArray.sigBytes;\n\n\t // Convert\n\t var hexChars = [];\n\t for (var i = 0; i < sigBytes; i++) {\n\t var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t hexChars.push((bite >>> 4).toString(16));\n\t hexChars.push((bite & 0x0f).toString(16));\n\t }\n\n\t return hexChars.join('');\n\t },\n\n\t /**\n\t * Converts a hex string to a word array.\n\t *\n\t * @param {string} hexStr The hex string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Hex.parse(hexString);\n\t */\n\t parse: function (hexStr) {\n\t // Shortcut\n\t var hexStrLength = hexStr.length;\n\n\t // Convert\n\t var words = [];\n\t for (var i = 0; i < hexStrLength; i += 2) {\n\t words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);\n\t }\n\n\t return new WordArray.init(words, hexStrLength / 2);\n\t }\n\t };\n\n\t /**\n\t * Latin1 encoding strategy.\n\t */\n\t var Latin1 = C_enc.Latin1 = {\n\t /**\n\t * Converts a word array to a Latin1 string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The Latin1 string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t // Shortcuts\n\t var words = wordArray.words;\n\t var sigBytes = wordArray.sigBytes;\n\n\t // Convert\n\t var latin1Chars = [];\n\t for (var i = 0; i < sigBytes; i++) {\n\t var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t latin1Chars.push(String.fromCharCode(bite));\n\t }\n\n\t return latin1Chars.join('');\n\t },\n\n\t /**\n\t * Converts a Latin1 string to a word array.\n\t *\n\t * @param {string} latin1Str The Latin1 string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);\n\t */\n\t parse: function (latin1Str) {\n\t // Shortcut\n\t var latin1StrLength = latin1Str.length;\n\n\t // Convert\n\t var words = [];\n\t for (var i = 0; i < latin1StrLength; i++) {\n\t words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);\n\t }\n\n\t return new WordArray.init(words, latin1StrLength);\n\t }\n\t };\n\n\t /**\n\t * UTF-8 encoding strategy.\n\t */\n\t var Utf8 = C_enc.Utf8 = {\n\t /**\n\t * Converts a word array to a UTF-8 string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The UTF-8 string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t try {\n\t return decodeURIComponent(escape(Latin1.stringify(wordArray)));\n\t } catch (e) {\n\t throw new Error('Malformed UTF-8 data');\n\t }\n\t },\n\n\t /**\n\t * Converts a UTF-8 string to a word array.\n\t *\n\t * @param {string} utf8Str The UTF-8 string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);\n\t */\n\t parse: function (utf8Str) {\n\t return Latin1.parse(unescape(encodeURIComponent(utf8Str)));\n\t }\n\t };\n\n\t /**\n\t * Abstract buffered block algorithm template.\n\t *\n\t * The property blockSize must be implemented in a concrete subtype.\n\t *\n\t * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0\n\t */\n\t var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({\n\t /**\n\t * Resets this block algorithm's data buffer to its initial state.\n\t *\n\t * @example\n\t *\n\t * bufferedBlockAlgorithm.reset();\n\t */\n\t reset: function () {\n\t // Initial values\n\t this._data = new WordArray.init();\n\t this._nDataBytes = 0;\n\t },\n\n\t /**\n\t * Adds new data to this block algorithm's buffer.\n\t *\n\t * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.\n\t *\n\t * @example\n\t *\n\t * bufferedBlockAlgorithm._append('data');\n\t * bufferedBlockAlgorithm._append(wordArray);\n\t */\n\t _append: function (data) {\n\t // Convert string to WordArray, else assume WordArray already\n\t if (typeof data == 'string') {\n\t data = Utf8.parse(data);\n\t }\n\n\t // Append\n\t this._data.concat(data);\n\t this._nDataBytes += data.sigBytes;\n\t },\n\n\t /**\n\t * Processes available data blocks.\n\t *\n\t * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.\n\t *\n\t * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.\n\t *\n\t * @return {WordArray} The processed data.\n\t *\n\t * @example\n\t *\n\t * var processedData = bufferedBlockAlgorithm._process();\n\t * var processedData = bufferedBlockAlgorithm._process(!!'flush');\n\t */\n\t _process: function (doFlush) {\n\t var processedWords;\n\n\t // Shortcuts\n\t var data = this._data;\n\t var dataWords = data.words;\n\t var dataSigBytes = data.sigBytes;\n\t var blockSize = this.blockSize;\n\t var blockSizeBytes = blockSize * 4;\n\n\t // Count blocks ready\n\t var nBlocksReady = dataSigBytes / blockSizeBytes;\n\t if (doFlush) {\n\t // Round up to include partial blocks\n\t nBlocksReady = Math.ceil(nBlocksReady);\n\t } else {\n\t // Round down to include only full blocks,\n\t // less the number of blocks that must remain in the buffer\n\t nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);\n\t }\n\n\t // Count words ready\n\t var nWordsReady = nBlocksReady * blockSize;\n\n\t // Count bytes ready\n\t var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);\n\n\t // Process blocks\n\t if (nWordsReady) {\n\t for (var offset = 0; offset < nWordsReady; offset += blockSize) {\n\t // Perform concrete-algorithm logic\n\t this._doProcessBlock(dataWords, offset);\n\t }\n\n\t // Remove processed words\n\t processedWords = dataWords.splice(0, nWordsReady);\n\t data.sigBytes -= nBytesReady;\n\t }\n\n\t // Return processed words\n\t return new WordArray.init(processedWords, nBytesReady);\n\t },\n\n\t /**\n\t * Creates a copy of this object.\n\t *\n\t * @return {Object} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = bufferedBlockAlgorithm.clone();\n\t */\n\t clone: function () {\n\t var clone = Base.clone.call(this);\n\t clone._data = this._data.clone();\n\n\t return clone;\n\t },\n\n\t _minBufferSize: 0\n\t });\n\n\t /**\n\t * Abstract hasher template.\n\t *\n\t * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)\n\t */\n\t var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({\n\t /**\n\t * Configuration options.\n\t */\n\t cfg: Base.extend(),\n\n\t /**\n\t * Initializes a newly created hasher.\n\t *\n\t * @param {Object} cfg (Optional) The configuration options to use for this hash computation.\n\t *\n\t * @example\n\t *\n\t * var hasher = CryptoJS.algo.SHA256.create();\n\t */\n\t init: function (cfg) {\n\t // Apply config defaults\n\t this.cfg = this.cfg.extend(cfg);\n\n\t // Set initial values\n\t this.reset();\n\t },\n\n\t /**\n\t * Resets this hasher to its initial state.\n\t *\n\t * @example\n\t *\n\t * hasher.reset();\n\t */\n\t reset: function () {\n\t // Reset data buffer\n\t BufferedBlockAlgorithm.reset.call(this);\n\n\t // Perform concrete-hasher logic\n\t this._doReset();\n\t },\n\n\t /**\n\t * Updates this hasher with a message.\n\t *\n\t * @param {WordArray|string} messageUpdate The message to append.\n\t *\n\t * @return {Hasher} This hasher.\n\t *\n\t * @example\n\t *\n\t * hasher.update('message');\n\t * hasher.update(wordArray);\n\t */\n\t update: function (messageUpdate) {\n\t // Append\n\t this._append(messageUpdate);\n\n\t // Update the hash\n\t this._process();\n\n\t // Chainable\n\t return this;\n\t },\n\n\t /**\n\t * Finalizes the hash computation.\n\t * Note that the finalize operation is effectively a destructive, read-once operation.\n\t *\n\t * @param {WordArray|string} messageUpdate (Optional) A final message update.\n\t *\n\t * @return {WordArray} The hash.\n\t *\n\t * @example\n\t *\n\t * var hash = hasher.finalize();\n\t * var hash = hasher.finalize('message');\n\t * var hash = hasher.finalize(wordArray);\n\t */\n\t finalize: function (messageUpdate) {\n\t // Final message update\n\t if (messageUpdate) {\n\t this._append(messageUpdate);\n\t }\n\n\t // Perform concrete-hasher logic\n\t var hash = this._doFinalize();\n\n\t return hash;\n\t },\n\n\t blockSize: 512/32,\n\n\t /**\n\t * Creates a shortcut function to a hasher's object interface.\n\t *\n\t * @param {Hasher} hasher The hasher to create a helper for.\n\t *\n\t * @return {Function} The shortcut function.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);\n\t */\n\t _createHelper: function (hasher) {\n\t return function (message, cfg) {\n\t return new hasher.init(cfg).finalize(message);\n\t };\n\t },\n\n\t /**\n\t * Creates a shortcut function to the HMAC's object interface.\n\t *\n\t * @param {Hasher} hasher The hasher to use in this HMAC helper.\n\t *\n\t * @return {Function} The shortcut function.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);\n\t */\n\t _createHmacHelper: function (hasher) {\n\t return function (message, key) {\n\t return new C_algo.HMAC.init(hasher, key).finalize(message);\n\t };\n\t }\n\t });\n\n\t /**\n\t * Algorithm namespace.\n\t */\n\t var C_algo = C.algo = {};\n\n\t return C;\n\t}(Math));\n\n\n\treturn CryptoJS;\n\n}));",";(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory(require(\"./core\"));\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([\"./core\"], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\tfactory(root.CryptoJS);\n\t}\n}(this, function (CryptoJS) {\n\n\t(function (Math) {\n\t // Shortcuts\n\t var C = CryptoJS;\n\t var C_lib = C.lib;\n\t var WordArray = C_lib.WordArray;\n\t var Hasher = C_lib.Hasher;\n\t var C_algo = C.algo;\n\n\t // Initialization and round constants tables\n\t var H = [];\n\t var K = [];\n\n\t // Compute constants\n\t (function () {\n\t function isPrime(n) {\n\t var sqrtN = Math.sqrt(n);\n\t for (var factor = 2; factor <= sqrtN; factor++) {\n\t if (!(n % factor)) {\n\t return false;\n\t }\n\t }\n\n\t return true;\n\t }\n\n\t function getFractionalBits(n) {\n\t return ((n - (n | 0)) * 0x100000000) | 0;\n\t }\n\n\t var n = 2;\n\t var nPrime = 0;\n\t while (nPrime < 64) {\n\t if (isPrime(n)) {\n\t if (nPrime < 8) {\n\t H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));\n\t }\n\t K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));\n\n\t nPrime++;\n\t }\n\n\t n++;\n\t }\n\t }());\n\n\t // Reusable object\n\t var W = [];\n\n\t /**\n\t * SHA-256 hash algorithm.\n\t */\n\t var SHA256 = C_algo.SHA256 = Hasher.extend({\n\t _doReset: function () {\n\t this._hash = new WordArray.init(H.slice(0));\n\t },\n\n\t _doProcessBlock: function (M, offset) {\n\t // Shortcut\n\t var H = this._hash.words;\n\n\t // Working variables\n\t var a = H[0];\n\t var b = H[1];\n\t var c = H[2];\n\t var d = H[3];\n\t var e = H[4];\n\t var f = H[5];\n\t var g = H[6];\n\t var h = H[7];\n\n\t // Computation\n\t for (var i = 0; i < 64; i++) {\n\t if (i < 16) {\n\t W[i] = M[offset + i] | 0;\n\t } else {\n\t var gamma0x = W[i - 15];\n\t var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^\n\t ((gamma0x << 14) | (gamma0x >>> 18)) ^\n\t (gamma0x >>> 3);\n\n\t var gamma1x = W[i - 2];\n\t var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^\n\t ((gamma1x << 13) | (gamma1x >>> 19)) ^\n\t (gamma1x >>> 10);\n\n\t W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];\n\t }\n\n\t var ch = (e & f) ^ (~e & g);\n\t var maj = (a & b) ^ (a & c) ^ (b & c);\n\n\t var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));\n\t var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));\n\n\t var t1 = h + sigma1 + ch + K[i] + W[i];\n\t var t2 = sigma0 + maj;\n\n\t h = g;\n\t g = f;\n\t f = e;\n\t e = (d + t1) | 0;\n\t d = c;\n\t c = b;\n\t b = a;\n\t a = (t1 + t2) | 0;\n\t }\n\n\t // Intermediate hash value\n\t H[0] = (H[0] + a) | 0;\n\t H[1] = (H[1] + b) | 0;\n\t H[2] = (H[2] + c) | 0;\n\t H[3] = (H[3] + d) | 0;\n\t H[4] = (H[4] + e) | 0;\n\t H[5] = (H[5] + f) | 0;\n\t H[6] = (H[6] + g) | 0;\n\t H[7] = (H[7] + h) | 0;\n\t },\n\n\t _doFinalize: function () {\n\t // Shortcuts\n\t var data = this._data;\n\t var dataWords = data.words;\n\n\t var nBitsTotal = this._nDataBytes * 8;\n\t var nBitsLeft = data.sigBytes * 8;\n\n\t // Add padding\n\t dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);\n\t dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);\n\t dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;\n\t data.sigBytes = dataWords.length * 4;\n\n\t // Hash final blocks\n\t this._process();\n\n\t // Return final computed hash\n\t return this._hash;\n\t },\n\n\t clone: function () {\n\t var clone = Hasher.clone.call(this);\n\t clone._hash = this._hash.clone();\n\n\t return clone;\n\t }\n\t });\n\n\t /**\n\t * Shortcut function to the hasher's object interface.\n\t *\n\t * @param {WordArray|string} message The message to hash.\n\t *\n\t * @return {WordArray} The hash.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hash = CryptoJS.SHA256('message');\n\t * var hash = CryptoJS.SHA256(wordArray);\n\t */\n\t C.SHA256 = Hasher._createHelper(SHA256);\n\n\t /**\n\t * Shortcut function to the HMAC's object interface.\n\t *\n\t * @param {WordArray|string} message The message to hash.\n\t * @param {WordArray|string} key The secret key.\n\t *\n\t * @return {WordArray} The HMAC.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hmac = CryptoJS.HmacSHA256(message, key);\n\t */\n\t C.HmacSHA256 = Hasher._createHmacHelper(SHA256);\n\t}(Math));\n\n\n\treturn CryptoJS.SHA256;\n\n}));","import { AxiosRequestConfig } from \"axios\";\r\n\r\nconst axiosConfig: AxiosRequestConfig = {\r\n url: \"\",\r\n method: \"\",\r\n baseURL: \"\",\r\n headers: {},\r\n data: {},\r\n timeout: 1000,\r\n withCredentials: false,\r\n responseType: \"json\",\r\n responseEncoding: \"utf8\",\r\n validateStatus: function (status: number) {\r\n return status >= 200 && status < 300;\r\n },\r\n maxRedirects: 5,\r\n socketPath: null,\r\n};\r\n\r\nexport default axiosConfig;\r\n","import axios, { AxiosInstance, AxiosRequestConfig } from \"axios\";\r\nimport axiosConfig from \"../config/axiosConfig\";\r\n\r\ninterface AxiosAjaxOptions extends AxiosRequestConfig {\r\n retries?: number;\r\n retryDelayMs?: number;\r\n}\r\n\r\nclass AxiosAjax {\r\n private http: AxiosInstance;\r\n private retries: number;\r\n private retryDelayMs: number;\r\n\r\n constructor(options?: AxiosAjaxOptions) {\r\n this.http = axios.create(options || (axiosConfig as AxiosRequestConfig));\r\n this.retries = options?.retries ?? 2;\r\n this.retryDelayMs = options?.retryDelayMs ?? 100;\r\n }\r\n\r\n private async sleep(ms: number): Promise {\r\n await new Promise((resolve) => setTimeout(resolve, ms));\r\n }\r\n\r\n async makeRequest(\r\n url: string,\r\n method: string,\r\n queryParameters?: Record,\r\n body?: unknown\r\n ) {\r\n if (!url) {\r\n throw new Error(\"URL required\");\r\n }\r\n\r\n let lastError: unknown;\r\n\r\n for (let attempt = 0; attempt <= this.retries; attempt += 1) {\r\n try {\r\n return await this.http({\r\n method: method || \"get\",\r\n url,\r\n params: queryParameters,\r\n data: body,\r\n });\r\n } catch (error) {\r\n lastError = error;\r\n\r\n if (attempt >= this.retries) {\r\n throw error;\r\n }\r\n\r\n if (this.retryDelayMs > 0) {\r\n await this.sleep(this.retryDelayMs);\r\n }\r\n }\r\n }\r\n\r\n throw lastError;\r\n }\r\n}\r\n\r\nexport default AxiosAjax;\r\n"," {\r\n \"API_LOCATION\": \"https://api.unsplash.com/\",\r\n \"BEARER_TOKEN_URL\": \"https://unsplash.com/oauth/token\",\r\n\r\n \"USERS_PUBLIC_PROFILE\": \"users/\",\r\n \"USERS_PORTFOLIO\": \"users/:username/portfolio\",\r\n \"USERS_PHOTOS\": \"users/:username/photos\",\r\n \"USERS_LIKED_PHOTOS\": \"users/:username/likes\",\r\n \"USERS_COLLECTIONS\": \"users/:username/collections\",\r\n \"USERS_STATISTICS\": \"users/:username/statistics\",\r\n\r\n \"LIST_PHOTOS\": \"photos\",\r\n \"LIST_CURATED_PHOTOS\": \"photos/curated\",\r\n \"GET_A_PHOTO\": \"photos/:id\",\r\n \"GET_A_RANDOM_PHOTO\": \"photos/random\",\r\n \"GET_A_PHOTO_STATISTICS\": \"photos/:id/statistics\",\r\n \"GET_A_PHOTO_DOWNLOAD_LINK\": \"photos/:id/download\",\r\n \"UPDATE_A_PHOTO\": \"photos/:id\",\r\n \"LIKE_A_PHOTO\": \"photos/:id/like\",\r\n \"UNLIKE_A_PHOTO\": \"photos/:id/like\",\r\n\r\n \"SEARCH_PHOTOS\": \"search/photos\",\r\n \"SEARCH_COLLECTIONS\": \"search/collections\",\r\n \"SEARCH_USERS\": \"search/users\",\r\n\r\n \"CURRENT_USER_PROFILE\": \"me\",\r\n \"UPDATE_CURRENT_USER_PROFILE\": \"me\",\r\n\r\n \"STATS_TOTALS\": \"stats/total\",\r\n \"STATS_MONTH\": \"stats/month\",\r\n\r\n \"LIST_COLLECTIONS\": \"collections\",\r\n \"LIST_FEATURED_COLLECTIONS\": \"collections/featured\",\r\n \"LIST_CURATED_COLLECTIONS\": \"collections/curated\",\r\n \"GET_COLLECTION\": \"collections/:id\",\r\n \"GET_CURATED_COLLECTION\": \"collections/curated/:id\",\r\n \"GET_COLLECTION_PHOTOS\": \"collections/:id/photos\",\r\n \"GET_CURATED_COLLECTION_PHOTOS\": \"collections/curated/:id/photos\",\r\n \"LIST_RELATED_COLLECTION\": \"collections/:id/related\",\r\n \"CREATE_NEW_COLLECTION\": \"collections\",\r\n \"UPDATE_EXISTING_COLLECTION\": \"collections/:id\",\r\n \"DELETE_COLLECTION\": \"collections/:id\",\r\n \"ADD_PHOTO_TO_COLLECTION\": \"collections/:collection_id/add\",\r\n \"REMOVE_PHOTO_FROM_COLLECTION\": \"collections/:collection_id/remove\"\r\n }","import sha256 from \"crypto-js/sha256\";\r\nimport AxiosAjax from \"../lib/axiosAjaxLib\";\r\nimport urlConfig from \"../config/url_config.json\";\r\n\r\ntype WrapSplashOptions = {\r\n access_key?: string;\r\n secret_key?: string;\r\n redirect_uri?: string;\r\n code?: string;\r\n bearer_token?: string;\r\n timeout?: number;\r\n retries?: number;\r\n retryDelayMs?: number;\r\n};\r\n\r\ntype QueryParams = Record;\r\n\r\ntype Headers = Record;\r\n\r\ntype WrapSplashResponse = Record;\r\n\r\ninterface ErrorOptions {\r\n cause?: unknown;\r\n statusCode?: number;\r\n statusText?: string;\r\n}\r\n\r\nclass WrapSplashError extends Error {\r\n public statusCode?: number;\r\n public statusText?: string;\r\n public cause?: unknown;\r\n\r\n constructor(message: string, options?: ErrorOptions | number, statusText?: string, cause?: unknown) {\r\n super(message);\r\n this.name = \"WrapSplashError\";\r\n\r\n // Handle both old and new signatures for backward compatibility\r\n if (typeof options === \"object\" && options !== null && !Array.isArray(options)) {\r\n // New signature: (message, options)\r\n this.cause = options.cause;\r\n this.statusCode = options.statusCode;\r\n this.statusText = options.statusText;\r\n } else if (typeof options === \"number\") {\r\n // Old signature: (message, statusCode, statusText, cause)\r\n this.statusCode = options;\r\n this.statusText = statusText;\r\n this.cause = cause;\r\n }\r\n\r\n Object.setPrototypeOf(this, new.target.prototype);\r\n }\r\n}\r\n\r\nclass WrapSplashApi {\r\n private API_LOCATION: string = urlConfig.API_LOCATION;\r\n private BEARER_TOKEN_URL: string = urlConfig.BEARER_TOKEN_URL;\r\n private options: WrapSplashOptions = {};\r\n private access_key = \"\";\r\n private secret_key = \"\";\r\n private redirect_uri = \"\";\r\n private code = \"\";\r\n private grant_type = \"authorization_code\";\r\n private bearer_token = \"\";\r\n private timeout = 10000;\r\n private retries = 2;\r\n private retryDelayMs = 100;\r\n private headers: Headers = {\r\n \"Content-type\": \"application/json\",\r\n \"X-Requested-With\": \"WrapSplash\",\r\n };\r\n\r\n private computeHash(value: string): string {\r\n return sha256(value).toString();\r\n }\r\n\r\n private validateRequired(value: unknown, fieldName: string): void {\r\n if (value === undefined || value === null || value === \"\") {\r\n const message = fieldName === \"id\" ? \"Parameter : id is required!\" : fieldName === \"query\" ? \"Parameter : query is missing!\" : `Parameter : ${fieldName} is required and cannot be empty!`;\r\n throw new WrapSplashError(message);\r\n }\r\n }\r\n\r\n private validateSupportedValue(value: string | undefined, allowedValues: readonly string[], fieldName: string): void {\r\n if (value !== undefined && !allowedValues.includes(value)) {\r\n throw new WrapSplashError(`Parameter : ${fieldName} has an unsupported value!`);\r\n }\r\n }\r\n\r\n private availableOrders = [\"latest\", \"oldest\", \"popular\"];\r\n private availableOrientations = [\"landscape\", \"portrait\", \"squarish\"];\r\n\r\n /** Initialize the client with API credentials or a bearer token. */\r\n init = (options: WrapSplashOptions = {}): void => {\r\n if (!options || typeof options !== \"object\" || Array.isArray(options)) {\r\n throw new WrapSplashError(\"Initialisation parameters required!\");\r\n }\r\n\r\n this.options = { ...options };\r\n this.timeout = typeof this.options.timeout === \"number\" && this.options.timeout > 0 ? this.options.timeout : 10000;\r\n this.retries = typeof this.options.retries === \"number\" && this.options.retries >= 0 ? this.options.retries : 2;\r\n this.retryDelayMs = typeof this.options.retryDelayMs === \"number\" && this.options.retryDelayMs >= 0 ? this.options.retryDelayMs : 100;\r\n this.bearer_token = this.options.bearer_token ?? \"\";\r\n\r\n this.headers = {\r\n \"Content-type\": \"application/json\",\r\n \"X-Requested-With\": \"WrapSplash\",\r\n };\r\n\r\n if (this.options.bearer_token) {\r\n this.headers = {\r\n ...this.headers,\r\n Authorization: `Bearer ${this.options.bearer_token}`,\r\n \"X-WrapSplash-Header\": this.computeHash(this.options.bearer_token),\r\n };\r\n return;\r\n }\r\n\r\n this.access_key = this.options.access_key\r\n ? this.options.access_key\r\n : (() => {\r\n throw new WrapSplashError(\"Access Key missing!\");\r\n })();\r\n this.secret_key = this.options.secret_key\r\n ? this.options.secret_key\r\n : (() => {\r\n throw new WrapSplashError(\"Secret Key missing!\");\r\n })();\r\n this.redirect_uri = this.options.redirect_uri\r\n ? this.options.redirect_uri\r\n : (() => {\r\n throw new WrapSplashError(\"Redirect URI missing!\");\r\n })();\r\n this.code = this.options.code\r\n ? this.options.code\r\n : (() => {\r\n throw new WrapSplashError(\"Authorization Code missing!\");\r\n })();\r\n\r\n this.headers = {\r\n ...this.headers,\r\n Authorization: `Client-ID ${this.options.access_key}`,\r\n \"X-WrapSplash-Header\": this.computeHash(this.options.access_key),\r\n };\r\n };\r\n\r\n private buildQueryParameters(params: QueryParams): QueryParams {\r\n const cleanParams: QueryParams = {};\r\n Object.entries(params).forEach(([key, value]) => {\r\n if (value !== undefined && value !== null && value !== \"\") {\r\n cleanParams[key] = value;\r\n }\r\n });\r\n return cleanParams;\r\n }\r\n\r\n private getErrorMessage(error: unknown): string {\r\n if (error instanceof Error) {\r\n return error.message;\r\n }\r\n\r\n if (typeof error === \"string\") {\r\n return error;\r\n }\r\n\r\n return \"Request failed\";\r\n }\r\n\r\n private createWrapSplashError(error: unknown): WrapSplashError {\r\n if (error instanceof WrapSplashError) {\r\n return error;\r\n }\r\n\r\n const statusCode = typeof error === \"object\" && error !== null && \"response\" in error && error.response && typeof error.response === \"object\" && \"status\" in error.response ? (error.response as { status?: number }).status : undefined;\r\n const statusText = typeof error === \"object\" && error !== null && \"response\" in error && error.response && typeof error.response === \"object\" && \"statusText\" in error.response ? (error.response as { statusText?: string }).statusText : undefined;\r\n\r\n return new WrapSplashError(this.getErrorMessage(error), {\r\n cause: error,\r\n statusCode,\r\n statusText,\r\n });\r\n }\r\n\r\n private fetchUrl(\r\n url: string,\r\n method: string,\r\n queryParameters: QueryParams = {},\r\n body: unknown = undefined\r\n ): Promise {\r\n const ajax = new AxiosAjax({\r\n headers: this.headers,\r\n timeout: this.timeout,\r\n retries: this.retries,\r\n retryDelayMs: this.retryDelayMs,\r\n });\r\n\r\n return ajax\r\n .makeRequest(url, method.toLowerCase(), this.buildQueryParameters(queryParameters), body)\r\n .then((res) => {\r\n const response = res as { status?: number; statusText?: string; data?: T };\r\n\r\n if (response.status === 204) {\r\n return {\r\n status: response.status,\r\n statusText: response.statusText,\r\n message: \"Content Deleted\",\r\n } as T;\r\n }\r\n\r\n if (response.status === 403) {\r\n return {\r\n status: response.status,\r\n statusText: response.statusText,\r\n message: \"Rate Limit Exceeded\",\r\n } as T;\r\n }\r\n\r\n return response.data as T;\r\n })\r\n .catch((err: unknown) => Promise.reject(this.createWrapSplashError(err)));\r\n }\r\n\r\n /** Exchange the authorization code for a bearer token. */\r\n generateBearerToken = (): Promise => {\r\n this.validateRequired(this.access_key, \"access_key\");\r\n this.validateRequired(this.secret_key, \"secret_key\");\r\n this.validateRequired(this.redirect_uri, \"redirect_uri\");\r\n this.validateRequired(this.code, \"code\");\r\n\r\n return this.fetchUrl(this.BEARER_TOKEN_URL, \"POST\", {\r\n client_id: this.access_key,\r\n client_secret: this.secret_key,\r\n redirect_uri: this.redirect_uri,\r\n code: this.code,\r\n grant_type: this.grant_type,\r\n });\r\n };\r\n\r\n getCurrentUserProfile = (): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.CURRENT_USER_PROFILE, \"GET\");\r\n };\r\n\r\n updateCurrentUserProfile = (\r\n username?: string,\r\n first_name?: string,\r\n last_name?: string,\r\n email?: string,\r\n url?: string,\r\n location?: string,\r\n bio?: string,\r\n instagram_username?: string\r\n ): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UPDATE_CURRENT_USER_PROFILE, \"PUT\", {\r\n username,\r\n first_name,\r\n last_name,\r\n email,\r\n url,\r\n location,\r\n bio,\r\n instagram_username,\r\n });\r\n };\r\n\r\n getPublicProfile = (username: string, width?: number, height?: number): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.USERS_PUBLIC_PROFILE + username, \"GET\", {\r\n w: width,\r\n h: height,\r\n });\r\n };\r\n\r\n getUserPortfolio = (username: string): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_PORTFOLIO.replace(/:username/gi, username),\r\n \"GET\"\r\n );\r\n };\r\n\r\n getUserPhotos = (\r\n username: string,\r\n page?: number,\r\n per_page?: number,\r\n stats?: boolean,\r\n resolution?: string,\r\n quantity?: number,\r\n order_by?: string\r\n ): Promise => {\r\n this.validateRequired(username, \"username\");\r\n this.validateSupportedValue(order_by, this.availableOrders, \"order_by\");\r\n if (stats !== undefined && typeof stats !== \"boolean\") {\r\n throw new WrapSplashError(\"Parameter : stats is a boolean or optional!\");\r\n }\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_PHOTOS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n stats: stats ?? false,\r\n resolution: resolution ?? \"days\",\r\n quantity: quantity ?? 30,\r\n }\r\n );\r\n };\r\n\r\n getUserLikedPhotos = (\r\n username: string,\r\n page?: number,\r\n per_page?: number,\r\n order_by?: string\r\n ): Promise => {\r\n this.validateRequired(username, \"username\");\r\n this.validateSupportedValue(order_by, this.availableOrders, \"order_by\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_LIKED_PHOTOS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n }\r\n );\r\n };\r\n\r\n getUserCollections = (username: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_COLLECTIONS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n }\r\n );\r\n };\r\n\r\n getUserStatistics = (username: string, resolution?: string, quantity?: number): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_STATISTICS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n resolution: resolution ?? \"days\",\r\n quantity: quantity ?? 30,\r\n }\r\n );\r\n };\r\n\r\n listPhotos = (page?: number, per_page?: number, order_by?: string): Promise => {\r\n if (order_by !== undefined && !this.availableOrders.includes(order_by)) {\r\n throw new WrapSplashError(\"Parameter : order_by has an unsupported value!\");\r\n }\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_PHOTOS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n });\r\n };\r\n\r\n listCuratedPhotos = (page?: number, per_page?: number, order_by?: string): Promise => {\r\n if (order_by !== undefined && !this.availableOrders.includes(order_by)) {\r\n throw new WrapSplashError(\"Parameter : order_by has an unsupported value!\");\r\n }\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_CURATED_PHOTOS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n });\r\n };\r\n\r\n getAPhoto = (id: string, width?: number, height?: number, rect?: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_PHOTO.replace(/:id/gi, id), \"GET\", {\r\n w: width,\r\n h: height,\r\n rect: typeof rect === \"string\" ? rect : undefined,\r\n });\r\n };\r\n\r\n getARandomPhoto = (\r\n collections?: string | number,\r\n featured?: boolean,\r\n username?: string,\r\n query?: string,\r\n width?: number,\r\n height?: number,\r\n orientation?: string,\r\n count?: number\r\n ): Promise => {\r\n this.validateSupportedValue(orientation, this.availableOrientations, \"orientation\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_RANDOM_PHOTO, \"GET\", {\r\n collections: collections !== undefined ? String(collections) : undefined,\r\n featured: featured ?? false,\r\n username,\r\n query,\r\n width,\r\n height,\r\n orientation: orientation ?? \"landscape\",\r\n count: count ?? 1,\r\n });\r\n };\r\n\r\n getPhotoStatistics = (id: string, resolution?: string, quantity?: number): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_PHOTO_STATISTICS.replace(/:id/gi, id), \"GET\", {\r\n resolution: resolution ?? \"days\",\r\n quantity: quantity ?? 30,\r\n });\r\n };\r\n\r\n getPhotoLink = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_PHOTO_DOWNLOAD_LINK.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n updatePhoto = (\r\n id: string,\r\n location: Record = {},\r\n exif: Record = {}\r\n ): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UPDATE_A_PHOTO.replace(/:id/gi, id), \"PUT\", {\r\n ...(location.latitude ? { \"location[latitude]\": location.latitude } : {}),\r\n ...(location.longitude ? { \"location[longitude]\": location.longitude } : {}),\r\n ...(location.name ? { \"location[name]\": location.name } : {}),\r\n ...(location.city ? { \"location[city]\": location.city } : {}),\r\n ...(location.country ? { \"location[country]\": location.country } : {}),\r\n ...(location.confidential ? { \"location[confidential]\": location.confidential } : {}),\r\n ...(exif.make ? { \"exif[make]\": exif.make } : {}),\r\n ...(exif.model ? { \"exif[model]\": exif.model } : {}),\r\n ...(exif.exposure_time ? { \"exif[exposure_time]\": exif.exposure_time } : {}),\r\n ...(exif.aperture_value ? { \"exif[aperture_value]\": exif.aperture_value } : {}),\r\n ...(exif.focal_length ? { \"exif[focal_length]\": exif.focal_length } : {}),\r\n ...(exif.iso_speed_ratings ? { \"exif[iso_speed_ratings]\": exif.iso_speed_ratings } : {}),\r\n });\r\n };\r\n\r\n likePhoto = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIKE_A_PHOTO.replace(/:id/gi, id), \"POST\");\r\n };\r\n\r\n unlikePhoto = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UNLIKE_A_PHOTO.replace(/:id/gi, id), \"DELETE\");\r\n };\r\n\r\n search = (query: string, page?: number, per_page?: number, collections?: string | number, orientation?: string): Promise => {\r\n this.validateRequired(query, \"query\");\r\n this.validateSupportedValue(orientation, this.availableOrientations, \"orientation\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.SEARCH_PHOTOS, \"GET\", {\r\n query,\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n collections: collections !== undefined ? String(collections) : undefined,\r\n orientation,\r\n });\r\n };\r\n\r\n searchCollections = (query: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(query, \"query\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.SEARCH_COLLECTIONS, \"GET\", {\r\n query,\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n searchUsers = (query: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(query, \"query\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.SEARCH_USERS, \"GET\", {\r\n query,\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n getStatsTotals = (): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.STATS_TOTALS, \"GET\");\r\n };\r\n\r\n getStatsMonth = (): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.STATS_MONTH, \"GET\");\r\n };\r\n\r\n listCollections = (page?: number, per_page?: number): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_COLLECTIONS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n listFeaturedCollections = (page?: number, per_page?: number): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_FEATURED_COLLECTIONS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n listCuratedCollections = (page?: number, per_page?: number): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_CURATED_COLLECTIONS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n getCollection = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_COLLECTION.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n getCuratedCollection = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_CURATED_COLLECTION.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n getCollectionPhotos = (id: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_COLLECTION_PHOTOS.replace(/:id/gi, id), \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n getCuratedCollectionPhotos = (id: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_CURATED_COLLECTION_PHOTOS.replace(/:id/gi, id), \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n listRelatedCollections = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_RELATED_COLLECTION.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n /** Fetch a photo using the newer alias. */\r\n getPhoto = (id: string, width?: number, height?: number, rect?: string): Promise => {\r\n return this.getAPhoto(id, width, height, rect);\r\n };\r\n\r\n getRandomPhoto = (\r\n collections?: string | number,\r\n featured?: boolean,\r\n username?: string,\r\n query?: string,\r\n width?: number,\r\n height?: number,\r\n orientation?: string,\r\n count?: number\r\n ): Promise => {\r\n return this.getARandomPhoto(collections, featured, username, query, width, height, orientation, count);\r\n };\r\n\r\n createNewCollection = (title: string, description?: string, private_collection: boolean = false): Promise => {\r\n this.validateRequired(title, \"title\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.CREATE_NEW_COLLECTION, \"POST\", {\r\n title,\r\n description,\r\n private: private_collection,\r\n });\r\n };\r\n\r\n /** Create a collection using the newer alias. */\r\n createCollection = (title: string, description?: string, private_collection: boolean = false): Promise => {\r\n return this.createNewCollection(title, description, private_collection);\r\n };\r\n\r\n /**\r\n * Backward-compatible alias for createNewCollection.\r\n * @deprecated Use createNewCollection instead.\r\n */\r\n createNewColection = (title: string, description?: string, private_collection: boolean = false): Promise => {\r\n return this.createNewCollection(title, description, private_collection);\r\n };\r\n\r\n updateExistingCollection = (id: string, title: string, description?: string, private_collection: boolean = false): Promise => {\r\n this.validateRequired(id, \"id\");\r\n this.validateRequired(title, \"title\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UPDATE_EXISTING_COLLECTION.replace(/:id/gi, id), \"PUT\", {\r\n title,\r\n description,\r\n private: private_collection,\r\n });\r\n };\r\n\r\n /** Update an existing collection using the newer alias. */\r\n updateCollection = (id: string, title: string, description?: string, private_collection: boolean = false): Promise => {\r\n return this.updateExistingCollection(id, title, description, private_collection);\r\n };\r\n\r\n deleteCollection = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.DELETE_COLLECTION.replace(/:id/gi, id), \"DELETE\");\r\n };\r\n\r\n addPhotoToCollection = (collection_id: string, photo_id: string): Promise => {\r\n this.validateRequired(collection_id, \"collection_id\");\r\n this.validateRequired(photo_id, \"photo_id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.ADD_PHOTO_TO_COLLECTION.replace(/:collection_id/gi, collection_id), \"POST\", {\r\n photo_id,\r\n });\r\n };\r\n\r\n removePhotoFromCollection = (collection_id: string, photo_id: string): Promise => {\r\n this.validateRequired(collection_id, \"collection_id\");\r\n this.validateRequired(photo_id, \"photo_id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.REMOVE_PHOTO_FROM_COLLECTION.replace(/:collection_id/gi, collection_id), \"DELETE\", {\r\n photo_id,\r\n });\r\n };\r\n}\r\n\r\nexport { WrapSplashError };\r\nexport default WrapSplashApi;\r\n"],"x_google_ignoreList":[1,2],"mappings":"04BAAA,EAAO,QAAU,CAAC,mBCAhB,SAAU,EAAM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Y,EAAM,SAAY,EAAM,SAAiC,OAAS,IAAA,GACzN,EAAa,OAAO,GAAU,UAAY,GAAkB,aAAc,GAAS,EAAM,UAAY,OAAO,EAAM,UAAa,UAAY,eAAgB,EAAM,SAAY,EAAM,SAAqC,WAAa,IAAA,GAE3O,OAAO,IAAI,EAAgB,KAAK,gBAAgB,CAAK,EAAG,CACtD,MAAO,EACP,aACA,YACF,CAAC,CACH,CAEA,SACE,EACA,EACA,EAA+B,CAAC,EAChC,EAAgB,IAAA,GACJ,CAQZ,OAAO,IAPU,EAAU,CACzB,QAAS,KAAK,QACd,QAAS,KAAK,QACd,QAAS,KAAK,QACd,aAAc,KAAK,YACrB,CAEO,CAAA,CACJ,YAAY,EAAK,EAAO,YAAY,EAAG,KAAK,qBAAqB,CAAe,EAAG,CAAI,CAAC,CACxF,KAAM,GAAQ,CACb,IAAM,EAAW,EAkBjB,OAhBI,EAAS,SAAW,IACf,CACL,OAAQ,EAAS,OACjB,WAAY,EAAS,WACrB,QAAS,iBACX,EAGE,EAAS,SAAW,IACf,CACL,OAAQ,EAAS,OACjB,WAAY,EAAS,WACrB,QAAS,qBACX,EAGK,EAAS,IAClB,CAAC,CAAC,CACD,MAAO,GAAiB,QAAQ,OAAO,KAAK,sBAAsB,CAAG,CAAC,CAAC,CAC5E,CA2YF"} \ No newline at end of file +{"version":3,"file":"wrapsplash.umd.js","names":[],"sources":["../config/axiosConfig.ts","../lib/axiosAjaxLib.ts","../config/url_config.json","../src/index.ts"],"sourcesContent":["import { AxiosRequestConfig } from \"axios\";\r\n\r\nconst axiosConfig: AxiosRequestConfig = {\r\n url: \"\",\r\n method: \"\",\r\n baseURL: \"\",\r\n headers: {},\r\n data: {},\r\n timeout: 1000,\r\n withCredentials: false,\r\n responseType: \"json\",\r\n responseEncoding: \"utf8\",\r\n validateStatus: function (status: number) {\r\n return status >= 200 && status < 300;\r\n },\r\n maxRedirects: 5,\r\n socketPath: null,\r\n};\r\n\r\nexport default axiosConfig;\r\n","import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from \"axios\";\nimport axiosConfig from \"../config/axiosConfig\";\n\ninterface AxiosAjaxOptions extends AxiosRequestConfig {\n retries?: number;\n retryDelayMs?: number;\n}\n\nclass AxiosAjax {\n private http: AxiosInstance;\n private retries: number;\n private retryDelayMs: number;\n\n constructor(options?: AxiosAjaxOptions) {\n this.http = axios.create(options || (axiosConfig as AxiosRequestConfig));\n this.retries = options?.retries ?? 2;\n this.retryDelayMs = options?.retryDelayMs ?? 100;\n }\n\n private sleep(ms: number): Promise {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n private isRetryableError(error: unknown): boolean {\n if (axios.isCancel(error)) {\n return false;\n }\n\n const axiosError = error as AxiosError;\n\n if (!axiosError.response) {\n return true;\n }\n\n const status = axiosError.response.status;\n return status === 429 || status >= 500;\n }\n\n private getRetryDelay(error: unknown, attempt: number): number {\n const axiosError = error as AxiosError;\n\n if (axiosError.response) {\n const retryAfterHeader = axiosError.response.headers?.[\"retry-after\"];\n if (retryAfterHeader) {\n const seconds = Number(retryAfterHeader);\n if (!Number.isNaN(seconds) && seconds > 0) {\n return seconds * 1000;\n }\n }\n }\n\n return this.retryDelayMs * Math.pow(2, attempt);\n }\n\n async makeRequest(\n url: string,\n method: string,\n queryParameters?: Record,\n body?: unknown\n ) {\n if (!url) {\n throw new Error(\"URL required\");\n }\n\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= this.retries; attempt += 1) {\n try {\n return await this.http({\n method: method || \"get\",\n url,\n params: queryParameters,\n data: body,\n });\n } catch (error) {\n lastError = error;\n\n if (attempt >= this.retries || !this.isRetryableError(error)) {\n throw error;\n }\n\n const delay = this.getRetryDelay(error, attempt);\n if (delay > 0) {\n await this.sleep(delay);\n }\n }\n }\n\n throw lastError;\n }\n}\n\nexport default AxiosAjax;\n"," {\r\n \"API_LOCATION\": \"https://api.unsplash.com/\",\r\n \"BEARER_TOKEN_URL\": \"https://unsplash.com/oauth/token\",\r\n\r\n \"USERS_PUBLIC_PROFILE\": \"users/\",\r\n \"USERS_PORTFOLIO\": \"users/:username/portfolio\",\r\n \"USERS_PHOTOS\": \"users/:username/photos\",\r\n \"USERS_LIKED_PHOTOS\": \"users/:username/likes\",\r\n \"USERS_COLLECTIONS\": \"users/:username/collections\",\r\n \"USERS_STATISTICS\": \"users/:username/statistics\",\r\n\r\n \"LIST_PHOTOS\": \"photos\",\r\n \"LIST_CURATED_PHOTOS\": \"photos/curated\",\r\n \"GET_A_PHOTO\": \"photos/:id\",\r\n \"GET_A_RANDOM_PHOTO\": \"photos/random\",\r\n \"GET_A_PHOTO_STATISTICS\": \"photos/:id/statistics\",\r\n \"GET_A_PHOTO_DOWNLOAD_LINK\": \"photos/:id/download\",\r\n \"UPDATE_A_PHOTO\": \"photos/:id\",\r\n \"LIKE_A_PHOTO\": \"photos/:id/like\",\r\n \"UNLIKE_A_PHOTO\": \"photos/:id/like\",\r\n\r\n \"SEARCH_PHOTOS\": \"search/photos\",\r\n \"SEARCH_COLLECTIONS\": \"search/collections\",\r\n \"SEARCH_USERS\": \"search/users\",\r\n\r\n \"CURRENT_USER_PROFILE\": \"me\",\r\n \"UPDATE_CURRENT_USER_PROFILE\": \"me\",\r\n\r\n \"STATS_TOTALS\": \"stats/total\",\r\n \"STATS_MONTH\": \"stats/month\",\r\n\r\n \"LIST_COLLECTIONS\": \"collections\",\r\n \"LIST_FEATURED_COLLECTIONS\": \"collections/featured\",\r\n \"LIST_CURATED_COLLECTIONS\": \"collections/curated\",\r\n \"GET_COLLECTION\": \"collections/:id\",\r\n \"GET_CURATED_COLLECTION\": \"collections/curated/:id\",\r\n \"GET_COLLECTION_PHOTOS\": \"collections/:id/photos\",\r\n \"GET_CURATED_COLLECTION_PHOTOS\": \"collections/curated/:id/photos\",\r\n \"LIST_RELATED_COLLECTION\": \"collections/:id/related\",\r\n \"CREATE_NEW_COLLECTION\": \"collections\",\r\n \"UPDATE_EXISTING_COLLECTION\": \"collections/:id\",\r\n \"DELETE_COLLECTION\": \"collections/:id\",\r\n \"ADD_PHOTO_TO_COLLECTION\": \"collections/:collection_id/add\",\r\n \"REMOVE_PHOTO_FROM_COLLECTION\": \"collections/:collection_id/remove\"\r\n }","import { createHash } from \"crypto\";\r\nimport AxiosAjax from \"../lib/axiosAjaxLib\";\r\nimport urlConfig from \"../config/url_config.json\";\r\n\r\ntype WrapSplashOptions = {\r\n access_key?: string;\r\n secret_key?: string;\r\n redirect_uri?: string;\r\n code?: string;\r\n bearer_token?: string;\r\n timeout?: number;\r\n retries?: number;\r\n retryDelayMs?: number;\r\n};\r\n\r\ntype QueryParams = Record;\r\n\r\ntype Headers = Record;\r\n\r\ntype WrapSplashResponse = Record;\r\n\r\ninterface ErrorOptions {\r\n cause?: unknown;\r\n statusCode?: number;\r\n statusText?: string;\r\n}\r\n\r\nclass WrapSplashError extends Error {\r\n public statusCode?: number;\r\n public statusText?: string;\r\n public cause?: unknown;\r\n\r\n constructor(message: string, options?: ErrorOptions | number, statusText?: string, cause?: unknown) {\r\n super(message);\r\n this.name = \"WrapSplashError\";\r\n\r\n // Handle both old and new signatures for backward compatibility\r\n if (typeof options === \"object\" && options !== null && !Array.isArray(options)) {\r\n // New signature: (message, options)\r\n this.cause = options.cause;\r\n this.statusCode = options.statusCode;\r\n this.statusText = options.statusText;\r\n } else if (typeof options === \"number\") {\r\n // Old signature: (message, statusCode, statusText, cause)\r\n this.statusCode = options;\r\n this.statusText = statusText;\r\n this.cause = cause;\r\n }\r\n\r\n Object.setPrototypeOf(this, new.target.prototype);\r\n }\r\n}\r\n\r\nclass WrapSplashApi {\r\n private API_LOCATION: string = urlConfig.API_LOCATION;\r\n private BEARER_TOKEN_URL: string = urlConfig.BEARER_TOKEN_URL;\r\n private options: WrapSplashOptions = {};\r\n private access_key = \"\";\r\n private secret_key = \"\";\r\n private redirect_uri = \"\";\r\n private code = \"\";\r\n private grant_type = \"authorization_code\";\r\n private bearer_token = \"\";\r\n private timeout = 10000;\r\n private retries = 2;\r\n private retryDelayMs = 100;\r\n private headers: Headers = {\r\n \"Content-type\": \"application/json\",\r\n \"X-Requested-With\": \"WrapSplash\",\r\n };\r\n\r\n private computeHash(value: string): string {\r\n return createHash(\"sha256\").update(value).digest(\"hex\");\r\n }\r\n\r\n private validateRequired(value: unknown, fieldName: string): void {\r\n if (value === undefined || value === null || value === \"\") {\r\n const message = fieldName === \"id\" ? \"Parameter : id is required!\" : fieldName === \"query\" ? \"Parameter : query is missing!\" : `Parameter : ${fieldName} is required and cannot be empty!`;\r\n throw new WrapSplashError(message);\r\n }\r\n }\r\n\r\n private validateSupportedValue(value: string | undefined, allowedValues: readonly string[], fieldName: string): void {\r\n if (value !== undefined && !allowedValues.includes(value)) {\r\n throw new WrapSplashError(`Parameter : ${fieldName} has an unsupported value!`);\r\n }\r\n }\r\n\r\n private availableOrders = [\"latest\", \"oldest\", \"popular\"];\r\n private availableOrientations = [\"landscape\", \"portrait\", \"squarish\"];\r\n\r\n /** Initialize the client with API credentials or a bearer token. */\r\n init = (options: WrapSplashOptions = {}): void => {\r\n if (!options || typeof options !== \"object\" || Array.isArray(options)) {\r\n throw new WrapSplashError(\"Initialisation parameters required!\");\r\n }\r\n\r\n this.options = { ...options };\r\n this.timeout = typeof this.options.timeout === \"number\" && this.options.timeout > 0 ? this.options.timeout : 10000;\r\n this.retries = typeof this.options.retries === \"number\" && this.options.retries >= 0 ? this.options.retries : 2;\r\n this.retryDelayMs = typeof this.options.retryDelayMs === \"number\" && this.options.retryDelayMs >= 0 ? this.options.retryDelayMs : 100;\r\n this.bearer_token = this.options.bearer_token ?? \"\";\r\n\r\n this.headers = {\r\n \"Content-type\": \"application/json\",\r\n \"X-Requested-With\": \"WrapSplash\",\r\n };\r\n\r\n if (this.options.bearer_token) {\r\n this.headers = {\r\n ...this.headers,\r\n Authorization: `Bearer ${this.options.bearer_token}`,\r\n \"X-WrapSplash-Header\": this.computeHash(this.options.bearer_token),\r\n };\r\n return;\r\n }\r\n\r\n this.access_key = this.options.access_key\r\n ? this.options.access_key\r\n : (() => {\r\n throw new WrapSplashError(\"Access Key missing!\");\r\n })();\r\n this.secret_key = this.options.secret_key\r\n ? this.options.secret_key\r\n : (() => {\r\n throw new WrapSplashError(\"Secret Key missing!\");\r\n })();\r\n this.redirect_uri = this.options.redirect_uri\r\n ? this.options.redirect_uri\r\n : (() => {\r\n throw new WrapSplashError(\"Redirect URI missing!\");\r\n })();\r\n this.code = this.options.code\r\n ? this.options.code\r\n : (() => {\r\n throw new WrapSplashError(\"Authorization Code missing!\");\r\n })();\r\n\r\n this.headers = {\r\n ...this.headers,\r\n Authorization: `Client-ID ${this.options.access_key}`,\r\n \"X-WrapSplash-Header\": this.computeHash(this.options.access_key),\r\n };\r\n };\r\n\r\n private buildQueryParameters(params: QueryParams): QueryParams {\r\n const cleanParams: QueryParams = {};\r\n Object.entries(params).forEach(([key, value]) => {\r\n if (value !== undefined && value !== null && value !== \"\") {\r\n cleanParams[key] = value;\r\n }\r\n });\r\n return cleanParams;\r\n }\r\n\r\n private getErrorMessage(error: unknown): string {\r\n if (error instanceof Error) {\r\n return error.message;\r\n }\r\n\r\n if (typeof error === \"string\") {\r\n return error;\r\n }\r\n\r\n return \"Request failed\";\r\n }\r\n\r\n private createWrapSplashError(error: unknown): WrapSplashError {\r\n if (error instanceof WrapSplashError) {\r\n return error;\r\n }\r\n\r\n const statusCode = typeof error === \"object\" && error !== null && \"response\" in error && error.response && typeof error.response === \"object\" && \"status\" in error.response ? (error.response as { status?: number }).status : undefined;\r\n const statusText = typeof error === \"object\" && error !== null && \"response\" in error && error.response && typeof error.response === \"object\" && \"statusText\" in error.response ? (error.response as { statusText?: string }).statusText : undefined;\r\n\r\n return new WrapSplashError(this.getErrorMessage(error), {\r\n cause: error,\r\n statusCode,\r\n statusText,\r\n });\r\n }\r\n\r\n private fetchUrl(\r\n url: string,\r\n method: string,\r\n queryParameters: QueryParams = {},\r\n body: unknown = undefined\r\n ): Promise {\r\n const ajax = new AxiosAjax({\r\n headers: this.headers,\r\n timeout: this.timeout,\r\n retries: this.retries,\r\n retryDelayMs: this.retryDelayMs,\r\n });\r\n\r\n return ajax\r\n .makeRequest(url, method.toLowerCase(), this.buildQueryParameters(queryParameters), body)\r\n .then((res) => {\r\n const response = res as { status?: number; statusText?: string; data?: T };\r\n\r\n if (response.status === 204) {\r\n return {\r\n status: response.status,\r\n statusText: response.statusText,\r\n message: \"Content Deleted\",\r\n } as T;\r\n }\r\n\r\n if (response.status === 403) {\r\n return {\r\n status: response.status,\r\n statusText: response.statusText,\r\n message: \"Rate Limit Exceeded\",\r\n } as T;\r\n }\r\n\r\n return response.data as T;\r\n })\r\n .catch((err: unknown) => Promise.reject(this.createWrapSplashError(err)));\r\n }\r\n\r\n /** Exchange the authorization code for a bearer token. */\r\n generateBearerToken = (): Promise => {\r\n this.validateRequired(this.access_key, \"access_key\");\r\n this.validateRequired(this.secret_key, \"secret_key\");\r\n this.validateRequired(this.redirect_uri, \"redirect_uri\");\r\n this.validateRequired(this.code, \"code\");\r\n\r\n return this.fetchUrl(this.BEARER_TOKEN_URL, \"POST\", {\r\n client_id: this.access_key,\r\n client_secret: this.secret_key,\r\n redirect_uri: this.redirect_uri,\r\n code: this.code,\r\n grant_type: this.grant_type,\r\n });\r\n };\r\n\r\n getCurrentUserProfile = (): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.CURRENT_USER_PROFILE, \"GET\");\r\n };\r\n\r\n updateCurrentUserProfile = (\r\n username?: string,\r\n first_name?: string,\r\n last_name?: string,\r\n email?: string,\r\n url?: string,\r\n location?: string,\r\n bio?: string,\r\n instagram_username?: string\r\n ): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UPDATE_CURRENT_USER_PROFILE, \"PUT\", {\r\n username,\r\n first_name,\r\n last_name,\r\n email,\r\n url,\r\n location,\r\n bio,\r\n instagram_username,\r\n });\r\n };\r\n\r\n getPublicProfile = (username: string, width?: number, height?: number): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.USERS_PUBLIC_PROFILE + username, \"GET\", {\r\n w: width,\r\n h: height,\r\n });\r\n };\r\n\r\n getUserPortfolio = (username: string): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_PORTFOLIO.replace(/:username/gi, username),\r\n \"GET\"\r\n );\r\n };\r\n\r\n getUserPhotos = (\r\n username: string,\r\n page?: number,\r\n per_page?: number,\r\n stats?: boolean,\r\n resolution?: string,\r\n quantity?: number,\r\n order_by?: string\r\n ): Promise => {\r\n this.validateRequired(username, \"username\");\r\n this.validateSupportedValue(order_by, this.availableOrders, \"order_by\");\r\n if (stats !== undefined && typeof stats !== \"boolean\") {\r\n throw new WrapSplashError(\"Parameter : stats is a boolean or optional!\");\r\n }\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_PHOTOS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n stats: stats ?? false,\r\n resolution: resolution ?? \"days\",\r\n quantity: quantity ?? 30,\r\n }\r\n );\r\n };\r\n\r\n getUserLikedPhotos = (\r\n username: string,\r\n page?: number,\r\n per_page?: number,\r\n order_by?: string\r\n ): Promise => {\r\n this.validateRequired(username, \"username\");\r\n this.validateSupportedValue(order_by, this.availableOrders, \"order_by\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_LIKED_PHOTOS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n }\r\n );\r\n };\r\n\r\n getUserCollections = (username: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_COLLECTIONS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n }\r\n );\r\n };\r\n\r\n getUserStatistics = (username: string, resolution?: string, quantity?: number): Promise => {\r\n this.validateRequired(username, \"username\");\r\n return this.fetchUrl(\r\n this.API_LOCATION + urlConfig.USERS_STATISTICS.replace(/:username/gi, username),\r\n \"GET\",\r\n {\r\n resolution: resolution ?? \"days\",\r\n quantity: quantity ?? 30,\r\n }\r\n );\r\n };\r\n\r\n listPhotos = (page?: number, per_page?: number, order_by?: string): Promise => {\r\n if (order_by !== undefined && !this.availableOrders.includes(order_by)) {\r\n throw new WrapSplashError(\"Parameter : order_by has an unsupported value!\");\r\n }\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_PHOTOS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n });\r\n };\r\n\r\n listCuratedPhotos = (page?: number, per_page?: number, order_by?: string): Promise => {\r\n if (order_by !== undefined && !this.availableOrders.includes(order_by)) {\r\n throw new WrapSplashError(\"Parameter : order_by has an unsupported value!\");\r\n }\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_CURATED_PHOTOS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n order_by: order_by ?? \"latest\",\r\n });\r\n };\r\n\r\n getAPhoto = (id: string, width?: number, height?: number, rect?: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_PHOTO.replace(/:id/gi, id), \"GET\", {\r\n w: width,\r\n h: height,\r\n rect: typeof rect === \"string\" ? rect : undefined,\r\n });\r\n };\r\n\r\n getARandomPhoto = (\r\n collections?: string | number,\r\n featured?: boolean,\r\n username?: string,\r\n query?: string,\r\n width?: number,\r\n height?: number,\r\n orientation?: string,\r\n count?: number\r\n ): Promise => {\r\n this.validateSupportedValue(orientation, this.availableOrientations, \"orientation\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_RANDOM_PHOTO, \"GET\", {\r\n collections: collections !== undefined ? String(collections) : undefined,\r\n featured: featured ?? false,\r\n username,\r\n query,\r\n width,\r\n height,\r\n orientation: orientation ?? \"landscape\",\r\n count: count ?? 1,\r\n });\r\n };\r\n\r\n getPhotoStatistics = (id: string, resolution?: string, quantity?: number): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_PHOTO_STATISTICS.replace(/:id/gi, id), \"GET\", {\r\n resolution: resolution ?? \"days\",\r\n quantity: quantity ?? 30,\r\n });\r\n };\r\n\r\n getPhotoLink = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_A_PHOTO_DOWNLOAD_LINK.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n updatePhoto = (\r\n id: string,\r\n location: Record = {},\r\n exif: Record = {}\r\n ): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UPDATE_A_PHOTO.replace(/:id/gi, id), \"PUT\", {\r\n ...(location.latitude ? { \"location[latitude]\": location.latitude } : {}),\r\n ...(location.longitude ? { \"location[longitude]\": location.longitude } : {}),\r\n ...(location.name ? { \"location[name]\": location.name } : {}),\r\n ...(location.city ? { \"location[city]\": location.city } : {}),\r\n ...(location.country ? { \"location[country]\": location.country } : {}),\r\n ...(location.confidential ? { \"location[confidential]\": location.confidential } : {}),\r\n ...(exif.make ? { \"exif[make]\": exif.make } : {}),\r\n ...(exif.model ? { \"exif[model]\": exif.model } : {}),\r\n ...(exif.exposure_time ? { \"exif[exposure_time]\": exif.exposure_time } : {}),\r\n ...(exif.aperture_value ? { \"exif[aperture_value]\": exif.aperture_value } : {}),\r\n ...(exif.focal_length ? { \"exif[focal_length]\": exif.focal_length } : {}),\r\n ...(exif.iso_speed_ratings ? { \"exif[iso_speed_ratings]\": exif.iso_speed_ratings } : {}),\r\n });\r\n };\r\n\r\n likePhoto = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIKE_A_PHOTO.replace(/:id/gi, id), \"POST\");\r\n };\r\n\r\n unlikePhoto = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UNLIKE_A_PHOTO.replace(/:id/gi, id), \"DELETE\");\r\n };\r\n\r\n search = (query: string, page?: number, per_page?: number, collections?: string | number, orientation?: string): Promise => {\r\n this.validateRequired(query, \"query\");\r\n this.validateSupportedValue(orientation, this.availableOrientations, \"orientation\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.SEARCH_PHOTOS, \"GET\", {\r\n query,\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n collections: collections !== undefined ? String(collections) : undefined,\r\n orientation,\r\n });\r\n };\r\n\r\n searchCollections = (query: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(query, \"query\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.SEARCH_COLLECTIONS, \"GET\", {\r\n query,\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n searchUsers = (query: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(query, \"query\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.SEARCH_USERS, \"GET\", {\r\n query,\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n getStatsTotals = (): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.STATS_TOTALS, \"GET\");\r\n };\r\n\r\n getStatsMonth = (): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.STATS_MONTH, \"GET\");\r\n };\r\n\r\n listCollections = (page?: number, per_page?: number): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_COLLECTIONS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n listFeaturedCollections = (page?: number, per_page?: number): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_FEATURED_COLLECTIONS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n listCuratedCollections = (page?: number, per_page?: number): Promise => {\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_CURATED_COLLECTIONS, \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n getCollection = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_COLLECTION.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n getCuratedCollection = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_CURATED_COLLECTION.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n getCollectionPhotos = (id: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_COLLECTION_PHOTOS.replace(/:id/gi, id), \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n getCuratedCollectionPhotos = (id: string, page?: number, per_page?: number): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.GET_CURATED_COLLECTION_PHOTOS.replace(/:id/gi, id), \"GET\", {\r\n page: page ?? 1,\r\n per_page: per_page ?? 10,\r\n });\r\n };\r\n\r\n listRelatedCollections = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.LIST_RELATED_COLLECTION.replace(/:id/gi, id), \"GET\");\r\n };\r\n\r\n /** Fetch a photo using the newer alias. */\r\n getPhoto = (id: string, width?: number, height?: number, rect?: string): Promise => {\r\n return this.getAPhoto(id, width, height, rect);\r\n };\r\n\r\n getRandomPhoto = (\r\n collections?: string | number,\r\n featured?: boolean,\r\n username?: string,\r\n query?: string,\r\n width?: number,\r\n height?: number,\r\n orientation?: string,\r\n count?: number\r\n ): Promise => {\r\n return this.getARandomPhoto(collections, featured, username, query, width, height, orientation, count);\r\n };\r\n\r\n createNewCollection = (title: string, description?: string, private_collection: boolean = false): Promise => {\r\n this.validateRequired(title, \"title\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.CREATE_NEW_COLLECTION, \"POST\", {\r\n title,\r\n description,\r\n private: private_collection,\r\n });\r\n };\r\n\r\n /** Create a collection using the newer alias. */\r\n createCollection = (title: string, description?: string, private_collection: boolean = false): Promise => {\r\n return this.createNewCollection(title, description, private_collection);\r\n };\r\n\r\n /**\r\n * Backward-compatible alias for createNewCollection.\r\n * @deprecated Use createNewCollection instead.\r\n */\r\n createNewColection = (title: string, description?: string, private_collection: boolean = false): Promise => {\r\n return this.createNewCollection(title, description, private_collection);\r\n };\r\n\r\n updateExistingCollection = (id: string, title: string, description?: string, private_collection: boolean = false): Promise => {\r\n this.validateRequired(id, \"id\");\r\n this.validateRequired(title, \"title\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.UPDATE_EXISTING_COLLECTION.replace(/:id/gi, id), \"PUT\", {\r\n title,\r\n description,\r\n private: private_collection,\r\n });\r\n };\r\n\r\n /** Update an existing collection using the newer alias. */\r\n updateCollection = (id: string, title: string, description?: string, private_collection: boolean = false): Promise => {\r\n return this.updateExistingCollection(id, title, description, private_collection);\r\n };\r\n\r\n deleteCollection = (id: string): Promise => {\r\n this.validateRequired(id, \"id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.DELETE_COLLECTION.replace(/:id/gi, id), \"DELETE\");\r\n };\r\n\r\n addPhotoToCollection = (collection_id: string, photo_id: string): Promise => {\r\n this.validateRequired(collection_id, \"collection_id\");\r\n this.validateRequired(photo_id, \"photo_id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.ADD_PHOTO_TO_COLLECTION.replace(/:collection_id/gi, collection_id), \"POST\", {\r\n photo_id,\r\n });\r\n };\r\n\r\n removePhotoFromCollection = (collection_id: string, photo_id: string): Promise => {\r\n this.validateRequired(collection_id, \"collection_id\");\r\n this.validateRequired(photo_id, \"photo_id\");\r\n return this.fetchUrl(this.API_LOCATION + urlConfig.REMOVE_PHOTO_FROM_COLLECTION.replace(/:collection_id/gi, collection_id), \"DELETE\", {\r\n photo_id,\r\n });\r\n };\r\n}\r\n\r\nexport { WrapSplashError };\r\nexport default WrapSplashApi;\r\n"],"mappings":"01BAEA,IAAM,EAAkC,CACtC,IAAK,GACL,OAAQ,GACR,QAAS,GACT,QAAS,CAAC,EACV,KAAM,CAAC,EACP,QAAS,IACT,gBAAiB,GACjB,aAAc,OACd,iBAAkB,OAClB,eAAgB,SAAU,EAAgB,CACxC,OAAO,GAAU,KAAO,EAAS,GACnC,EACA,aAAc,EACd,WAAY,IACd,ECTM,EAAN,KAAgB,CACd,KACA,QACA,aAEA,YAAY,EAA4B,CACtC,KAAK,KAAO,EAAA,QAAM,OAAO,GAAY,CAAkC,EACvE,KAAK,QAAU,GAAS,SAAW,EACnC,KAAK,aAAe,GAAS,cAAgB,GAC/C,CAEA,MAAc,EAA2B,CACvC,OAAO,IAAI,QAAS,GAAY,WAAW,EAAS,CAAE,CAAC,CACzD,CAEA,iBAAyB,EAAyB,CAChD,GAAI,EAAA,QAAM,SAAS,CAAK,EACtB,MAAO,GAGT,IAAM,EAAa,EAEnB,GAAI,CAAC,EAAW,SACd,MAAO,GAGT,IAAM,EAAS,EAAW,SAAS,OACnC,OAAO,IAAW,KAAO,GAAU,GACrC,CAEA,cAAsB,EAAgB,EAAyB,CAC7D,IAAM,EAAa,EAEnB,GAAI,EAAW,SAAU,CACvB,IAAM,EAAmB,EAAW,SAAS,UAAU,eACvD,GAAI,EAAkB,CACpB,IAAM,EAAU,OAAO,CAAgB,EACvC,GAAI,CAAC,OAAO,MAAM,CAAO,GAAK,EAAU,EACtC,OAAO,EAAU,GAErB,C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,MAAO,GAAiB,QAAQ,OAAO,KAAK,sBAAsB,CAAG,CAAC,CAAC,CAC5E,CA2YF"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 5ed461d..0000000 --- a/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./dist/wrapsplash.umd.js'); diff --git a/lib/axiosAjaxLib.ts b/lib/axiosAjaxLib.ts index af62516..091aeff 100644 --- a/lib/axiosAjaxLib.ts +++ b/lib/axiosAjaxLib.ts @@ -1,4 +1,4 @@ -import axios, { AxiosInstance, AxiosRequestConfig } from "axios"; +import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from "axios"; import axiosConfig from "../config/axiosConfig"; interface AxiosAjaxOptions extends AxiosRequestConfig { @@ -17,8 +17,39 @@ class AxiosAjax { this.retryDelayMs = options?.retryDelayMs ?? 100; } - private async sleep(ms: number): Promise { - await new Promise((resolve) => setTimeout(resolve, ms)); + private sleep(ms: number): Promise { + return new Promise((resolve) => setTimeout(resolve, ms)); + } + + private isRetryableError(error: unknown): boolean { + if (axios.isCancel(error)) { + return false; + } + + const axiosError = error as AxiosError; + + if (!axiosError.response) { + return true; + } + + const status = axiosError.response.status; + return status === 429 || status >= 500; + } + + private getRetryDelay(error: unknown, attempt: number): number { + const axiosError = error as AxiosError; + + if (axiosError.response) { + const retryAfterHeader = axiosError.response.headers?.["retry-after"]; + if (retryAfterHeader) { + const seconds = Number(retryAfterHeader); + if (!Number.isNaN(seconds) && seconds > 0) { + return seconds * 1000; + } + } + } + + return this.retryDelayMs * Math.pow(2, attempt); } async makeRequest( @@ -44,12 +75,13 @@ class AxiosAjax { } catch (error) { lastError = error; - if (attempt >= this.retries) { + if (attempt >= this.retries || !this.isRetryableError(error)) { throw error; } - if (this.retryDelayMs > 0) { - await this.sleep(this.retryDelayMs); + const delay = this.getRetryDelay(error, attempt); + if (delay > 0) { + await this.sleep(delay); } } } diff --git a/package.json b/package.json index 5cc72e2..3f52b70 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,14 @@ { "name": "wrapsplash", - "version": "5.0.0", + "version": "5.1.0", "description": "A simple npm wrapper module to use the popular Unsplash API.", "private": false, + "files": [ + "dist", + "lib", + "config", + "src" + ], "main": "dist/wrapsplash.umd.js", "module": "dist/wrapsplash.es.js", "types": "dist/types/index.d.ts", @@ -43,14 +49,12 @@ }, "homepage": "https://github.com/SandeepVattapparambil/wrapsplash#readme", "dependencies": { - "axios": "^1.6.1", - "crypto-js": "^4.1.1" + "axios": "^1.6.1" }, "directories": { "examples": "examples" }, "devDependencies": { - "@types/crypto-js": "^4.2.2", "@types/node": "^20.11.0", "@typescript-eslint/eslint-plugin": "^8.0.0", "@typescript-eslint/parser": "^8.0.0", diff --git a/public/badge.png b/public/badge.png new file mode 100644 index 0000000..1efd8b4 Binary files /dev/null and b/public/badge.png differ diff --git a/src/README.md b/src/README.md index 7ef8630..47f1360 100644 --- a/src/README.md +++ b/src/README.md @@ -1,2 +1,2 @@ -# WrapSplash Module Source ES7-8 Files -This folder contains the main source files for WrapSplash written in ES7 specification. +# WrapSplash Module Source Files +This folder contains the main TypeScript source files for WrapSplash. diff --git a/src/index.ts b/src/index.ts index 0e30f87..0e1555c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import sha256 from "crypto-js/sha256"; +import { createHash } from "crypto"; import AxiosAjax from "../lib/axiosAjaxLib"; import urlConfig from "../config/url_config.json"; @@ -70,7 +70,7 @@ class WrapSplashApi { }; private computeHash(value: string): string { - return sha256(value).toString(); + return createHash("sha256").update(value).digest("hex"); } private validateRequired(value: unknown, fieldName: string): void { diff --git a/test/axiosAjaxLib.spec.ts b/test/axiosAjaxLib.spec.ts new file mode 100644 index 0000000..4e41369 --- /dev/null +++ b/test/axiosAjaxLib.spec.ts @@ -0,0 +1,353 @@ +import { describe, expect, test, vi, beforeEach, afterEach } from "vitest"; +import axios from "axios"; +import AxiosAjax from "../lib/axiosAjaxLib"; + +vi.mock("axios"); + +const mockedAxios = vi.mocked(axios); + +function createMockInstance() { + const fn = vi.fn(); + return fn; +} + +beforeEach(() => { + vi.clearAllMocks(); +}); + +afterEach(() => { + vi.useRealTimers(); +}); + +describe("AxiosAjax", () => { + test("throws when url is empty", async () => { + const ajax = new AxiosAjax(); + await expect(ajax.makeRequest("", "get")).rejects.toThrow("URL required"); + }); + + test("passes method, params, and data to axios", async () => { + const instance = createMockInstance(); + instance.mockResolvedValue({ status: 200, data: "ok" }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ timeout: 5000 }); + await ajax.makeRequest("https://example.com/api", "post", { q: 1 }, { body: true }); + + expect(instance).toHaveBeenCalledWith({ + method: "post", + url: "https://example.com/api", + params: { q: 1 }, + data: { body: true }, + }); + }); + + test("defaults method to get when empty string", async () => { + const instance = createMockInstance(); + instance.mockResolvedValue({ status: 200 }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax(); + await ajax.makeRequest("https://example.com", ""); + + expect(instance).toHaveBeenCalledWith( + expect.objectContaining({ method: "get" }) + ); + }); + + test("does not retry on 4xx errors (non-429)", async () => { + vi.useFakeTimers(); + const instance = createMockInstance(); + const error400 = { + response: { status: 400, statusText: "Bad Request", headers: {} }, + isAxiosError: true, + message: "Request failed with status code 400", + }; + instance.mockRejectedValueOnce(error400); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 3, retryDelayMs: 100 }); + await expect(ajax.makeRequest("https://example.com", "get")).rejects.toThrow(); + expect(instance).toHaveBeenCalledTimes(1); + }); + + test("does not retry on 401 Unauthorized", async () => { + vi.useFakeTimers(); + const instance = createMockInstance(); + instance.mockRejectedValueOnce({ + response: { status: 401, statusText: "Unauthorized", headers: {} }, + isAxiosError: true, + }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 3, retryDelayMs: 100 }); + await expect(ajax.makeRequest("https://example.com", "get")).rejects.toThrow(); + expect(instance).toHaveBeenCalledTimes(1); + }); + + test("does not retry on 403 Forbidden", async () => { + vi.useFakeTimers(); + const instance = createMockInstance(); + instance.mockRejectedValueOnce({ + response: { status: 403, statusText: "Forbidden", headers: {} }, + isAxiosError: true, + }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 2, retryDelayMs: 100 }); + await expect(ajax.makeRequest("https://example.com", "get")).rejects.toThrow(); + expect(instance).toHaveBeenCalledTimes(1); + }); + + test("does not retry on 404 Not Found", async () => { + vi.useFakeTimers(); + const instance = createMockInstance(); + instance.mockRejectedValueOnce({ + response: { status: 404, statusText: "Not Found", headers: {} }, + isAxiosError: true, + }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 2, retryDelayMs: 100 }); + await expect(ajax.makeRequest("https://example.com", "get")).rejects.toThrow(); + expect(instance).toHaveBeenCalledTimes(1); + }); + + test("retries on 429 Too Many Requests", async () => { + vi.useFakeTimers(); + const instance = createMockInstance(); + const error429 = { + response: { status: 429, statusText: "Too Many Requests", headers: {} }, + isAxiosError: true, + }; + instance.mockRejectedValueOnce(error429).mockResolvedValueOnce({ status: 200, data: "ok" }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 2, retryDelayMs: 100 }); + const promise = ajax.makeRequest("https://example.com", "get"); + + await vi.advanceTimersByTimeAsync(200); + const result = await promise; + + expect(instance).toHaveBeenCalledTimes(2); + expect(result).toEqual({ status: 200, data: "ok" }); + }); + + test("retries on 500 Internal Server Error", async () => { + vi.useFakeTimers(); + const instance = createMockInstance(); + instance + .mockRejectedValueOnce({ + response: { status: 500, statusText: "Internal Server Error", headers: {} }, + isAxiosError: true, + }) + .mockResolvedValueOnce({ status: 200, data: "recovered" }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 2, retryDelayMs: 100 }); + const promise = ajax.makeRequest("https://example.com", "get"); + + await vi.advanceTimersByTimeAsync(200); + const result = await promise; + + expect(instance).toHaveBeenCalledTimes(2); + expect(result.data).toBe("recovered"); + }); + + test("retries on 502 Bad Gateway", async () => { + vi.useFakeTimers(); + const instance = createMockInstance(); + instance + .mockRejectedValueOnce({ + response: { status: 502, statusText: "Bad Gateway", headers: {} }, + isAxiosError: true, + }) + .mockResolvedValueOnce({ status: 200 }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 1, retryDelayMs: 100 }); + const promise = ajax.makeRequest("https://example.com", "get"); + + await vi.advanceTimersByTimeAsync(200); + await promise; + + expect(instance).toHaveBeenCalledTimes(2); + }); + + test("retries on network error (no response)", async () => { + vi.useFakeTimers(); + const instance = createMockInstance(); + instance + .mockRejectedValueOnce(new Error("Network Error")) + .mockResolvedValueOnce({ status: 200 }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 2, retryDelayMs: 100 }); + const promise = ajax.makeRequest("https://example.com", "get"); + + await vi.advanceTimersByTimeAsync(200); + const result = await promise; + + expect(instance).toHaveBeenCalledTimes(2); + expect(result.status).toBe(200); + }); + + test("retries on timeout error", async () => { + vi.useFakeTimers(); + const instance = createMockInstance(); + instance + .mockRejectedValueOnce({ code: "ECONNABORTED", message: "timeout" }) + .mockResolvedValueOnce({ status: 200 }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 2, retryDelayMs: 100 }); + const promise = ajax.makeRequest("https://example.com", "get"); + + await vi.advanceTimersByTimeAsync(200); + await promise; + + expect(instance).toHaveBeenCalledTimes(2); + }); + + test("exhausts all retries and throws last error", async () => { + const instance = createMockInstance(); + const failError = new Error("persistent failure"); + instance.mockRejectedValueOnce(failError).mockRejectedValueOnce(failError).mockRejectedValueOnce(failError); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 2, retryDelayMs: 0 }); + + await expect(ajax.makeRequest("https://example.com", "get")).rejects.toThrow("persistent failure"); + expect(instance).toHaveBeenCalledTimes(3); + }); + + test("uses exponential backoff delays", async () => { + vi.useFakeTimers(); + const instance = createMockInstance(); + instance + .mockRejectedValueOnce(new Error("fail 1")) + .mockRejectedValueOnce(new Error("fail 2")) + .mockResolvedValueOnce({ status: 200 }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 3, retryDelayMs: 100 }); + const promise = ajax.makeRequest("https://example.com", "get"); + + await vi.advanceTimersByTimeAsync(200); + await vi.advanceTimersByTimeAsync(400); + await promise; + + expect(instance).toHaveBeenCalledTimes(3); + }); + + test("respects Retry-After header in seconds", async () => { + vi.useFakeTimers(); + const instance = createMockInstance(); + instance + .mockRejectedValueOnce({ + response: { + status: 429, + statusText: "Too Many Requests", + headers: { "retry-after": "2" }, + }, + isAxiosError: true, + }) + .mockResolvedValueOnce({ status: 200 }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 2, retryDelayMs: 100 }); + const promise = ajax.makeRequest("https://example.com", "get"); + + await vi.advanceTimersByTimeAsync(3000); + const result = await promise; + + expect(instance).toHaveBeenCalledTimes(2); + expect(result.status).toBe(200); + }); + + test("falls back to exponential backoff for invalid Retry-After header", async () => { + vi.useFakeTimers(); + const instance = createMockInstance(); + instance + .mockRejectedValueOnce({ + response: { + status: 429, + statusText: "Too Many Requests", + headers: { "retry-after": "abc" }, + }, + isAxiosError: true, + }) + .mockResolvedValueOnce({ status: 200 }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 2, retryDelayMs: 100 }); + const promise = ajax.makeRequest("https://example.com", "get"); + + await vi.advanceTimersByTimeAsync(200); + await promise; + + expect(instance).toHaveBeenCalledTimes(2); + }); + + test("falls back to exponential backoff when Retry-After is 0", async () => { + vi.useFakeTimers(); + const instance = createMockInstance(); + instance + .mockRejectedValueOnce({ + response: { + status: 429, + statusText: "Too Many Requests", + headers: { "retry-after": "0" }, + }, + isAxiosError: true, + }) + .mockResolvedValueOnce({ status: 200 }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 2, retryDelayMs: 100 }); + const promise = ajax.makeRequest("https://example.com", "get"); + + await vi.advanceTimersByTimeAsync(200); + await promise; + + expect(instance).toHaveBeenCalledTimes(2); + }); + + test("does not retry when delay is 0 and retries left", async () => { + vi.useFakeTimers(); + const instance = createMockInstance(); + instance + .mockRejectedValueOnce(new Error("fail")) + .mockResolvedValueOnce({ status: 200 }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax({ retries: 2, retryDelayMs: 0 }); + const result = await ajax.makeRequest("https://example.com", "get"); + + expect(instance).toHaveBeenCalledTimes(2); + expect(result.status).toBe(200); + }); + + test("uses default options when none provided", async () => { + const instance = createMockInstance(); + instance.mockResolvedValue({ status: 200 }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax(); + await ajax.makeRequest("https://example.com", "get"); + + expect(instance).toHaveBeenCalledTimes(1); + }); + + test("passes default axios config when no options given", async () => { + const instance = createMockInstance(); + instance.mockResolvedValue({ status: 200 }); + mockedAxios.create.mockReturnValue(instance as any); + + const ajax = new AxiosAjax(); + await ajax.makeRequest("https://example.com", "get"); + + expect(mockedAxios.create).toHaveBeenCalledWith( + expect.objectContaining({ timeout: 1000 }) + ); + }); +}); diff --git a/test/wrapsplash.spec.ts b/test/wrapsplash.spec.ts index 2165a3b..c0f7752 100644 --- a/test/wrapsplash.spec.ts +++ b/test/wrapsplash.spec.ts @@ -575,4 +575,417 @@ describe("Wrapsplash API wrapper", () => { expect(() => wrapsplash.search(undefined as any)).toThrow("Parameter : query is missing!"); }); }); + + describe("WrapSplashError", () => { + test("constructs with new options object signature", () => { + const error = new WrapSplashError("test message", { + statusCode: 418, + statusText: "I'm a teapot", + cause: new Error("original"), + }); + + expect(error).toBeInstanceOf(Error); + expect(error.name).toBe("WrapSplashError"); + expect(error.message).toBe("test message"); + expect(error.statusCode).toBe(418); + expect(error.statusText).toBe("I'm a teapot"); + expect(error.cause).toBeInstanceOf(Error); + }); + + test("constructs with legacy positional signature", () => { + const cause = new Error("root cause"); + const error = new WrapSplashError("legacy", 500, "Server Error", cause); + + expect(error.statusCode).toBe(500); + expect(error.statusText).toBe("Server Error"); + expect(error.cause).toBe(cause); + }); + + test("constructs with no options", () => { + const error = new WrapSplashError("simple"); + expect(error.statusCode).toBeUndefined(); + expect(error.statusText).toBeUndefined(); + expect(error.cause).toBeUndefined(); + }); + + test("constructs with null options", () => { + const error = new WrapSplashError("with null", null as any); + expect(error.statusCode).toBeUndefined(); + }); + + test("preserves prototype chain for instanceof checks", () => { + const error = new WrapSplashError("proto test"); + expect(error instanceof WrapSplashError).toBe(true); + expect(error instanceof Error).toBe(true); + }); + }); + + describe("init validation", () => { + test("throws for non-object init parameter", () => { + const client = new WrapsplashLib(); + expect(() => client.init(null as any)).toThrow("Initialisation parameters required!"); + expect(() => client.init("string" as any)).toThrow("Initialisation parameters required!"); + expect(() => client.init(42 as any)).toThrow("Initialisation parameters required!"); + }); + + test("throws for array init parameter", () => { + const client = new WrapsplashLib(); + expect(() => client.init([] as any)).toThrow("Initialisation parameters required!"); + }); + + test("throws when access_key is missing in credential mode", () => { + const client = new WrapsplashLib(); + expect(() => + client.init({ secret_key: "sk", redirect_uri: "r", code: "c" } as any) + ).toThrow("Access Key missing!"); + }); + + test("throws when secret_key is missing in credential mode", () => { + const client = new WrapsplashLib(); + expect(() => + client.init({ access_key: "ak", redirect_uri: "r", code: "c" } as any) + ).toThrow("Secret Key missing!"); + }); + + test("throws when redirect_uri is missing in credential mode", () => { + const client = new WrapsplashLib(); + expect(() => + client.init({ access_key: "ak", secret_key: "sk", code: "c" } as any) + ).toThrow("Redirect URI missing!"); + }); + + test("throws when code is missing in credential mode", () => { + const client = new WrapsplashLib(); + expect(() => + client.init({ access_key: "ak", secret_key: "sk", redirect_uri: "r" } as any) + ).toThrow("Authorization Code missing!"); + }); + + test("applies custom timeout, retries, and retryDelayMs", async () => { + const client = new WrapsplashLib(); + client.init({ + bearer_token: "tok", + timeout: 5000, + retries: 5, + retryDelayMs: 500, + }); + + await client.getCurrentUserProfile(); + + expect(capturedAxiosOptions).toEqual( + expect.objectContaining({ + timeout: 5000, + retries: 5, + retryDelayMs: 500, + }) + ); + }); + + test("falls back to defaults for invalid timeout", async () => { + const client = new WrapsplashLib(); + client.init({ bearer_token: "tok", timeout: -1 }); + await client.getCurrentUserProfile(); + + expect(capturedAxiosOptions).toEqual(expect.objectContaining({ timeout: 10000 })); + }); + + test("falls back to defaults for non-number timeout", async () => { + const client = new WrapsplashLib(); + client.init({ bearer_token: "tok", timeout: "bad" as any }); + await client.getCurrentUserProfile(); + + expect(capturedAxiosOptions).toEqual(expect.objectContaining({ timeout: 10000 })); + }); + + test("falls back to defaults for invalid retries", async () => { + const client = new WrapsplashLib(); + client.init({ bearer_token: "tok", retries: -1 }); + await client.getCurrentUserProfile(); + + expect(capturedAxiosOptions).toEqual(expect.objectContaining({ retries: 2 })); + }); + + test("allows retries of 0", async () => { + const client = new WrapsplashLib(); + client.init({ bearer_token: "tok", retries: 0 }); + await client.getCurrentUserProfile(); + + expect(capturedAxiosOptions).toEqual(expect.objectContaining({ retries: 0 })); + }); + + test("falls back to defaults for invalid retryDelayMs", async () => { + const client = new WrapsplashLib(); + client.init({ bearer_token: "tok", retryDelayMs: -5 }); + await client.getCurrentUserProfile(); + + expect(capturedAxiosOptions).toEqual(expect.objectContaining({ retryDelayMs: 100 })); + }); + }); + + describe("response handling", () => { + test("handles 204 No Content response", async () => { + makeRequestMock.mockResolvedValueOnce({ + status: 204, + statusText: "No Content", + data: {}, + }); + + const response = await wrapsplash.getCurrentUserProfile(); + expect(response).toEqual({ + status: 204, + statusText: "No Content", + message: "Content Deleted", + }); + }); + + test("handles 403 rate limit response", async () => { + makeRequestMock.mockResolvedValueOnce({ + status: 403, + statusText: "Forbidden", + data: {}, + }); + + const response = await wrapsplash.getCurrentUserProfile(); + expect(response).toEqual({ + status: 403, + statusText: "Forbidden", + message: "Rate Limit Exceeded", + }); + }); + }); + + describe("error wrapping", () => { + test("wraps Axios-style error with response status", async () => { + makeRequestMock.mockRejectedValueOnce({ + response: { status: 404, statusText: "Not Found" }, + message: "Request failed with status code 404", + }); + + await expect(wrapsplash.getCurrentUserProfile()).rejects.toMatchObject({ + name: "WrapSplashError", + statusCode: 404, + statusText: "Not Found", + }); + }); + + test("wraps plain string error", async () => { + makeRequestMock.mockRejectedValueOnce("raw string error"); + + await expect(wrapsplash.getCurrentUserProfile()).rejects.toMatchObject({ + name: "WrapSplashError", + message: "raw string error", + }); + }); + + test("wraps unknown error type with fallback message", async () => { + makeRequestMock.mockRejectedValueOnce(42); + + await expect(wrapsplash.getCurrentUserProfile()).rejects.toMatchObject({ + name: "WrapSplashError", + message: "Request failed", + }); + }); + + test("wraps error without response object", async () => { + makeRequestMock.mockRejectedValueOnce(new Error("network down")); + + const error = await wrapsplash.getCurrentUserProfile().catch((e) => e); + expect(error).toBeInstanceOf(WrapSplashError); + expect(error.message).toBe("network down"); + expect(error.statusCode).toBeUndefined(); + }); + + test("preserves existing WrapSplashError", async () => { + const original = new WrapSplashError("already wrapped", { statusCode: 503 }); + makeRequestMock.mockRejectedValueOnce(original); + + await expect(wrapsplash.getCurrentUserProfile()).rejects.toBe(original); + }); + }); + + describe("parameter validation", () => { + test("listPhotos throws for invalid order_by", () => { + expect(() => wrapsplash.listPhotos(1, 10, "bad")).toThrow( + "Parameter : order_by has an unsupported value!" + ); + }); + + test("listCuratedPhotos throws for invalid order_by", () => { + expect(() => wrapsplash.listCuratedPhotos(1, 10, "bad")).toThrow( + "Parameter : order_by has an unsupported value!" + ); + }); + + test("getUserPhotos throws when username is empty", () => { + expect(() => wrapsplash.getUserPhotos("")).toThrow("Parameter : username is required and cannot be empty!"); + }); + + test("getUserLikedPhotos throws when username is empty", () => { + expect(() => wrapsplash.getUserLikedPhotos("")).toThrow("Parameter : username is required and cannot be empty!"); + }); + + test("getUserCollections throws when username is empty", () => { + expect(() => wrapsplash.getUserCollections("")).toThrow("Parameter : username is required and cannot be empty!"); + }); + + test("getUserStatistics throws when username is empty", () => { + expect(() => wrapsplash.getUserStatistics("")).toThrow("Parameter : username is required and cannot be empty!"); + }); + + test("getPhotoStatistics throws when id is empty", () => { + expect(() => wrapsplash.getPhotoStatistics("")).toThrow("Parameter : id is required!"); + }); + + test("getPhotoLink throws when id is empty", () => { + expect(() => wrapsplash.getPhotoLink("")).toThrow("Parameter : id is required!"); + }); + + test("updatePhoto throws when id is empty", () => { + expect(() => wrapsplash.updatePhoto("")).toThrow("Parameter : id is required!"); + }); + + test("likePhoto throws when id is empty", () => { + expect(() => wrapsplash.likePhoto("")).toThrow("Parameter : id is required!"); + }); + + test("unlikePhoto throws when id is empty", () => { + expect(() => wrapsplash.unlikePhoto("")).toThrow("Parameter : id is required!"); + }); + + test("searchCollections throws when query is empty", () => { + expect(() => wrapsplash.searchCollections("")).toThrow("Parameter : query is missing!"); + }); + + test("searchUsers throws when query is empty", () => { + expect(() => wrapsplash.searchUsers("")).toThrow("Parameter : query is missing!"); + }); + + test("getCollection throws when id is empty", () => { + expect(() => wrapsplash.getCollection("")).toThrow("Parameter : id is required!"); + }); + + test("getCuratedCollection throws when id is empty", () => { + expect(() => wrapsplash.getCuratedCollection("")).toThrow("Parameter : id is required!"); + }); + + test("getCollectionPhotos throws when id is empty", () => { + expect(() => wrapsplash.getCollectionPhotos("")).toThrow("Parameter : id is required!"); + }); + + test("getCuratedCollectionPhotos throws when id is empty", () => { + expect(() => wrapsplash.getCuratedCollectionPhotos("")).toThrow("Parameter : id is required!"); + }); + + test("listRelatedCollections throws when id is empty", () => { + expect(() => wrapsplash.listRelatedCollections("")).toThrow("Parameter : id is required!"); + }); + + test("deleteCollection throws when id is empty", () => { + expect(() => wrapsplash.deleteCollection("")).toThrow("Parameter : id is required!"); + }); + + test("addPhotoToCollection throws when collection_id is empty", () => { + expect(() => wrapsplash.addPhotoToCollection("", "pid")).toThrow("Parameter : collection_id is required"); + }); + + test("addPhotoToCollection throws when photo_id is empty", () => { + expect(() => wrapsplash.addPhotoToCollection("cid", "")).toThrow("Parameter : photo_id is required"); + }); + + test("removePhotoFromCollection throws when collection_id is empty", () => { + expect(() => wrapsplash.removePhotoFromCollection("", "pid")).toThrow("Parameter : collection_id is required"); + }); + + test("removePhotoFromCollection throws when photo_id is empty", () => { + expect(() => wrapsplash.removePhotoFromCollection("cid", "")).toThrow("Parameter : photo_id is required"); + }); + + test("createNewCollection throws when title is empty", () => { + expect(() => wrapsplash.createNewCollection("")).toThrow("Parameter : title is required"); + }); + + test("updateExistingCollection throws when id is empty", () => { + expect(() => wrapsplash.updateExistingCollection("", "title")).toThrow("Parameter : id is required!"); + }); + + test("updateExistingCollection throws when title is empty", () => { + expect(() => wrapsplash.updateExistingCollection("id", "")).toThrow("Parameter : title is required"); + }); + + test("getUserPhotos throws for invalid stats type", () => { + expect(() => wrapsplash.getUserPhotos("user", 1, 10, "yes" as any)).toThrow( + "Parameter : stats is a boolean or optional!" + ); + }); + + test("getARandomPhoto throws for invalid orientation", () => { + expect(() => wrapsplash.getARandomPhoto(undefined, false, undefined, undefined, undefined, undefined, "diagonal")).toThrow( + "Parameter : orientation has an unsupported value!" + ); + }); + + test("search throws for invalid orientation", () => { + expect(() => wrapsplash.search("q", 1, 10, undefined, "diagonal")).toThrow( + "Parameter : orientation has an unsupported value!" + ); + }); + }); + + describe("query parameter filtering", () => { + test("omits undefined parameters from query string", async () => { + const response = await wrapsplash.getUserPhotos("sandeepv", undefined, undefined, undefined, undefined, undefined, "oldest"); + + expect(makeRequestMock).toHaveBeenCalledWith( + expect.any(String), + "get", + expect.objectContaining({ order_by: "oldest" }), + undefined + ); + }); + + test("getPhoto omits undefined rect parameter", async () => { + await wrapsplash.getPhoto("id", 100, 200); + expect(makeRequestMock).toHaveBeenCalledWith( + expect.any(String), + "get", + { w: 100, h: 200, rect: undefined }, + undefined + ); + }); + }); + + describe("deprecated alias", () => { + test("createNewColection delegates to createNewCollection", async () => { + const response = await wrapsplash.createNewColection("Legacy Collection", "desc", false); + + expect(makeRequestMock).toHaveBeenCalledWith( + "https://api.unsplash.com/collections", + "post", + { title: "Legacy Collection", description: "desc", private: false }, + undefined + ); + }); + }); + + describe("updateCurrentUserProfile with partial params", () => { + test("sends only provided fields", async () => { + await wrapsplash.updateCurrentUserProfile("newuser"); + + expect(makeRequestMock).toHaveBeenCalledWith( + "https://api.unsplash.com/me", + "put", + { + username: "newuser", + first_name: undefined, + last_name: undefined, + email: undefined, + url: undefined, + location: undefined, + bio: undefined, + instagram_username: undefined, + }, + undefined + ); + }); + }); }); diff --git a/vite.config.ts b/vite.config.ts index 9c4bac3..1673c3c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -9,11 +9,12 @@ export default defineConfig({ fileName: (format) => `wrapsplash.${format}.js`, }, rollupOptions: { - external: ["axios"], + external: ["axios", "crypto"], output: { exports: "named", globals: { axios: "axios", + crypto: "crypto", }, }, },