javascript-ampache 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.m.js.map +1 -1
- package/dist/index.modern.mjs +1 -1
- package/dist/index.modern.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/system/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/base.ts +21 -12
- package/src/system/index.ts +2 -0
package/dist/base.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
type Config = {
|
|
2
2
|
url: string;
|
|
3
3
|
sessionKey?: string;
|
|
4
|
+
useBearerToken: false;
|
|
4
5
|
debug?: boolean;
|
|
5
6
|
};
|
|
6
7
|
export type Success = {
|
|
@@ -30,6 +31,7 @@ export declare abstract class Base {
|
|
|
30
31
|
sessionKey: string;
|
|
31
32
|
url: string;
|
|
32
33
|
version: string;
|
|
34
|
+
useBearerToken: boolean;
|
|
33
35
|
debug: boolean;
|
|
34
36
|
constructor(config: Config);
|
|
35
37
|
protected request<T>(endpoint: string): Promise<T>;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function t(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,e(t,r)}function e(t,r){return e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},e(t,r)}var r=Object.prototype.hasOwnProperty;function n(t){try{return encodeURIComponent(t)}catch(t){return null}}var s=function(t,e){e=e||"";var s,i,u=[];for(i in"string"!=typeof e&&(e="?"),t)if(r.call(t,i)){if((s=t[i])||null!=s&&!isNaN(s)||(s=""),i=n(i),s=n(s),null===i||null===s)continue;u.push(i+"="+s)}return u.length?e+u.join("&"):""},i={__proto__:null,default:function(t,e){return e=e||{},new Promise(function(r,n){var s=new XMLHttpRequest,i=[],u=[],o={},a=function(){return{ok:2==(s.status/100|0),statusText:s.statusText,status:s.status,url:s.responseURL,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(s.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([s.response]))},clone:a,headers:{keys:function(){return i},entries:function(){return u},get:function(t){return o[t.toLowerCase()]},has:function(t){return t.toLowerCase()in o}}}};for(var c in s.open(e.method||"get",t,!0),s.onload=function(){s.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(t,e,r){i.push(e=e.toLowerCase()),u.push([e,r]),o[e]=o[e]?o[e]+","+r:r}),r(a())},s.onerror=n,s.withCredentials="include"==e.credentials,e.headers)s.setRequestHeader(c,e.headers[c]);s.send(e.body||null)})}},u=self.fetch||(self.fetch=i.default||i),o=/*#__PURE__*/function(){function t(t){this.sessionKey=void 0,this.url=void 0,this.version="6.6.8",this.debug=void 0,this.sessionKey=t.sessionKey||null,this.url=t.url,this.debug=t.debug||!1}var e=t.prototype;return e.request=function(t){var e=this.url+"/server/json.server.php?action="+t+"&version="+this.version;return this.debug&&console.debug("javascript-ampache query URL %c"+e+"&auth="+this.sessionKey,"color: black; font-style: italic; background-color: orange;padding: 2px"),u(e,{method:"GET",headers:{Authorization:"Bearer "+this.sessionKey}}).then(function(t){if(t.ok)return t.json();throw new Error(t.statusText)})},e.binary=function(t){var e=this.url+"/server/json.server.php?action="+t+"&version="+this.version;return this.debug&&console.debug("javascript-ampache query URL %c"+e+"&auth="+this.sessionKey,"color: black; font-style: italic; background-color: orange;padding: 2px"),u(e,{method:"GET",headers:{Authorization:"Bearer "+this.sessionKey}}).then(function(t){return t.blob()}).then(function(t){return t})},e.setSessionKey=function(t){this.sessionKey=t},e.rawURL=function(t,e){var r=t;r+=s(e,"&");var n=this.url+"/server/json.server.php?action="+r+"&version="+this.version;return this.debug&&console.debug("javascript-ampache query URL %c"+n+"&auth="+this.sessionKey,"color: black; font-style: italic; background-color: orange;padding: 2px"),n},t}(),a=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.albums=function(t){var e="albums";return e+=s(t,"&"),this.request(e)},n.album=function(t){var e="album";return e+=s(t,"&"),this.request(e)},n.artistAlbums=function(t){var e="artist_albums";return e+=s(t,"&"),this.request(e)},n.genreAlbums=function(t){var e="genre_albums";return e+=s(t,"&"),this.request(e)},r}(o),c=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.artists=function(t){var e="artists";return e+=s(t,"&"),this.request(e)},n.artist=function(t){var e="artist";return e+=s(t,"&"),this.request(e)},n.genreArtists=function(t){var e="genre_artists";return e+=s(t,"&"),this.request(e)},n.labelArtists=function(t){var e="label_artists";return e+=s(t,"&"),this.request(e)},r}(o);const h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l="ARRAYBUFFER not supported by this environment",f="UINT8ARRAY not supported by this environment";function p(t,e,r,n){let s,i,u;const o=e||[0],a=(r=r||0)>>>3,c=-1===n?3:0;for(s=0;s<t.length;s+=1)u=s+a,i=u>>>2,o.length<=i&&o.push(0),o[i]|=t[s]<<8*(c+n*(u%4));return{value:o,binLen:8*t.length+r}}function d(t,e,r){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,n){return function(t,e,r,n){let s,i,u,o;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");const a=e||[0],c=(r=r||0)>>>3,h=-1===n?3:0;for(s=0;s<t.length;s+=2){if(i=parseInt(t.substr(s,2),16),isNaN(i))throw new Error("String of HEX type contains invalid characters");for(o=(s>>>1)+c,u=o>>>2;a.length<=u;)a.push(0);a[u]|=i<<8*(h+n*(o%4))}return{value:a,binLen:4*t.length+r}}(t,e,n,r)};case"TEXT":return function(t,n,s){return function(t,e,r,n,s){let i,u,o,a,c,h,l,f,p=0;const d=r||[0],v=(n=n||0)>>>3;if("UTF8"===e)for(l=-1===s?3:0,o=0;o<t.length;o+=1)for(i=t.charCodeAt(o),u=[],128>i?u.push(i):2048>i?(u.push(192|i>>>6),u.push(128|63&i)):55296>i||57344<=i?u.push(224|i>>>12,128|i>>>6&63,128|63&i):(o+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(o)),u.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),a=0;a<u.length;a+=1){for(h=p+v,c=h>>>2;d.length<=c;)d.push(0);d[c]|=u[a]<<8*(l+s*(h%4)),p+=1}else for(l=-1===s?2:0,f="UTF16LE"===e&&1!==s||"UTF16LE"!==e&&1===s,o=0;o<t.length;o+=1){for(i=t.charCodeAt(o),!0===f&&(a=255&i,i=a<<8|i>>>8),h=p+v,c=h>>>2;d.length<=c;)d.push(0);d[c]|=i<<8*(l+s*(h%4)),p+=2}return{value:d,binLen:8*p+n}}(t,e,n,s,r)};case"B64":return function(t,e,n){return function(t,e,r,n){let s,i,u,o,a,c,l,f=0;const p=e||[0],d=(r=r||0)>>>3,v=-1===n?3:0,g=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==g&&g<t.length)throw new Error("Invalid '=' found in base-64 string");for(i=0;i<t.length;i+=4){for(a=t.substr(i,4),o=0,u=0;u<a.length;u+=1)s=h.indexOf(a.charAt(u)),o|=s<<18-6*u;for(u=0;u<a.length-1;u+=1){for(l=f+d,c=l>>>2;p.length<=c;)p.push(0);p[c]|=(o>>>16-8*u&255)<<8*(v+n*(l%4)),f+=1}}return{value:p,binLen:8*f+r}}(t,e,n,r)};case"BYTES":return function(t,e,n){return function(t,e,r,n){let s,i,u,o;const a=e||[0],c=(r=r||0)>>>3,h=-1===n?3:0;for(i=0;i<t.length;i+=1)s=t.charCodeAt(i),o=i+c,u=o>>>2,a.length<=u&&a.push(0),a[u]|=s<<8*(h+n*(o%4));return{value:a,binLen:8*t.length+r}}(t,e,n,r)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error(l)}return function(t,e,n){return function(t,e,r,n){return p(new Uint8Array(t),e,r,n)}(t,e,n,r)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error(f)}return function(t,e,n){return p(t,e,n,r)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function v(t,e,r,n){switch(t){case"HEX":return function(t){return function(t,e,r,n){const s="0123456789abcdef";let i,u,o="";const a=e/8,c=-1===r?3:0;for(i=0;i<a;i+=1)u=t[i>>>2]>>>8*(c+r*(i%4)),o+=s.charAt(u>>>4&15)+s.charAt(15&u);return n.outputUpper?o.toUpperCase():o}(t,e,r,n)};case"B64":return function(t){return function(t,e,r,n){let s,i,u,o,a,c="";const l=e/8,f=-1===r?3:0;for(s=0;s<l;s+=3)for(o=s+1<l?t[s+1>>>2]:0,a=s+2<l?t[s+2>>>2]:0,u=(t[s>>>2]>>>8*(f+r*(s%4))&255)<<16|(o>>>8*(f+r*((s+1)%4))&255)<<8|a>>>8*(f+r*((s+2)%4))&255,i=0;i<4;i+=1)c+=8*s+6*i<=e?h.charAt(u>>>6*(3-i)&63):n.b64Pad;return c}(t,e,r,n)};case"BYTES":return function(t){return function(t,e,r){let n,s,i="";const u=e/8,o=-1===r?3:0;for(n=0;n<u;n+=1)s=t[n>>>2]>>>8*(o+r*(n%4))&255,i+=String.fromCharCode(s);return i}(t,e,r)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error(l)}return function(t){return function(t,e,r){let n;const s=e/8,i=new ArrayBuffer(s),u=new Uint8Array(i),o=-1===r?3:0;for(n=0;n<s;n+=1)u[n]=t[n>>>2]>>>8*(o+r*(n%4))&255;return i}(t,e,r)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error(f)}return function(t){return function(t,e,r){let n;const s=e/8,i=-1===r?3:0,u=new Uint8Array(s);for(n=0;n<s;n+=1)u[n]=t[n>>>2]>>>8*(i+r*(n%4))&255;return u}(t,e,r)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const g=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],y=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],m=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function q(t){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},r=t||{},n="Output length must be a multiple of 8";if(e.outputUpper=r.outputUpper||!1,r.b64Pad&&(e.b64Pad=r.b64Pad),r.outputLen){if(r.outputLen%8!=0)throw new Error(n);e.outputLen=r.outputLen}else if(r.shakeLen){if(r.shakeLen%8!=0)throw new Error(n);e.outputLen=r.shakeLen}if("boolean"!=typeof e.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw new Error("Invalid b64Pad formatting option");return e}class _{constructor(t,e,r){const n=r||{};if(this.t=e,this.i=n.encoding||"UTF8",this.numRounds=n.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=t,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.U=[],this.R=[]}update(t){let e,r=0;const n=this.T>>>5,s=this.F(t,this.h,this.u),i=s.binLen,u=s.value,o=i>>>5;for(e=0;e<o;e+=n)r+this.T<=i&&(this.m=this.g(u.slice(e,e+n),this.m),r+=this.T);return this.A+=r,this.h=u.slice(r>>>5),this.u=i%this.T,this.l=!0,this}getHash(t,e){let r,n,s=this.H;const i=q(e);if(this.B){if(-1===i.outputLen)throw new Error("Output length must be specified in options");s=i.outputLen}const u=v(t,s,this.v,i);if(this.p&&this.C)return u(this.C(i));for(n=this.Y(this.h.slice(),this.u,this.A,this.S(this.m),s),r=1;r<this.numRounds;r+=1)this.B&&s%32!=0&&(n[n.length-1]&=16777215>>>24-s%32),n=this.Y(n,s,0,this.I(this.o),s);return u(n)}setHMACKey(t,e,r){if(!this.L)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const n=d(e,(r||{}).encoding||"UTF8",this.v);this.M(n(t))}M(t){const e=this.T>>>3,r=e/4-1;let n;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(e<t.binLen/8&&(t.value=this.Y(t.value,t.binLen,0,this.I(this.o),this.H));t.value.length<=r;)t.value.push(0);for(n=0;n<=r;n+=1)this.U[n]=909522486^t.value[n],this.R[n]=1549556828^t.value[n];this.m=this.g(this.U,this.m),this.A=this.T,this.p=!0}getHMAC(t,e){const r=q(e);return v(t,this.H,this.v,r)(this.N())}N(){let t;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const e=this.Y(this.h.slice(),this.u,this.A,this.S(this.m),this.H);return t=this.g(this.R,this.I(this.o)),t=this.Y(e,this.H,this.T,t,this.H),t}}function b(t,e){return t>>>e|t<<32-e}function w(t,e){return t>>>e}function A(t,e,r){return t&e^~t&r}function E(t,e,r){return t&e^t&r^e&r}function R(t){return b(t,2)^b(t,13)^b(t,22)}function T(t,e){const r=(65535&t)+(65535&e);return(65535&(t>>>16)+(e>>>16)+(r>>>16))<<16|65535&r}function U(t,e,r,n){const s=(65535&t)+(65535&e)+(65535&r)+(65535&n);return(65535&(t>>>16)+(e>>>16)+(r>>>16)+(n>>>16)+(s>>>16))<<16|65535&s}function k(t,e,r,n,s){const i=(65535&t)+(65535&e)+(65535&r)+(65535&n)+(65535&s);return(65535&(t>>>16)+(e>>>16)+(r>>>16)+(n>>>16)+(s>>>16)+(i>>>16))<<16|65535&i}function S(t){return b(t,7)^b(t,18)^w(t,3)}function C(t){return b(t,6)^b(t,11)^b(t,25)}function L(t){let e;return e="SHA-224"==t?y.slice():m.slice(),e}function H(t,e){let r,n,s,i,u,o,a,c,h,l,f;const p=[];for(r=e[0],n=e[1],s=e[2],i=e[3],u=e[4],o=e[5],a=e[6],c=e[7],f=0;f<64;f+=1)p[f]=f<16?t[f]:U(b(d=p[f-2],17)^b(d,19)^w(d,10),p[f-7],S(p[f-15]),p[f-16]),h=k(c,C(u),A(u,o,a),g[f],p[f]),l=T(R(r),E(r,n,s)),c=a,a=o,o=u,u=T(i,h),i=s,s=n,n=r,r=T(h,l);var d;return e[0]=T(r,e[0]),e[1]=T(n,e[1]),e[2]=T(s,e[2]),e[3]=T(i,e[3]),e[4]=T(u,e[4]),e[5]=T(o,e[5]),e[6]=T(a,e[6]),e[7]=T(c,e[7]),e}class F extends _{constructor(t,e,r){if("SHA-224"!==t&&"SHA-256"!==t)throw new Error("Chosen SHA variant is not supported");super(t,e,r);const n=r||{};this.C=this.N,this.L=!0,this.v=-1,this.F=d(this.t,this.i,this.v),this.g=H,this.S=function(t){return t.slice()},this.I=L,this.Y=function(e,r,n,s){return function(t,e,r,n,s){let i,u;const o=15+(e+65>>>9<<4),a=e+r;for(;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[o]=4294967295&a,t[o-1]=a/4294967296|0,i=0;i<t.length;i+=16)n=H(t.slice(i,i+16),n);return u="SHA-224"===s?[n[0],n[1],n[2],n[3],n[4],n[5],n[6]]:n,u}(e,r,n,s,t)},this.m=L(t),this.T=512,this.H="SHA-224"===t?224:256,this.B=!1,n.hmacKey&&this.M(function(t,e,r,n){const s="hmacKey must include a value and format";if(!e)throw new Error(s);if(void 0===e.value||!e.format)throw new Error(s);return d(e.format,e.encoding||"UTF8",r)(e.value)}(0,n.hmacKey,this.v))}}var P,B=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.handshake=function(t){var e=this;t.timestamp||(t.timestamp=Math.floor((new Date).getTime()/1e3)),t.version&&(this.version=t.version),t.user||delete t.timestamp;var r=this.url+"/server/json.server.php?action=handshake";return r+=s(t,"&"),u(r).then(function(t){return t.json()}).then(function(t){return t.auth&&(e.sessionKey=t.auth),t})},n.ping=function(t){var e="ping";return e+=s(t,"&"),this.request(e)},n.goodbye=function(t){var e="goodbye";return e+=s(t,"&"),this.request(e)},n.lostPassword=function(t){var e="lost_password";return e+=s(t,"&"),this.request(e)},n.encryptPassword=function(t){var e=r(t.password);return r(t.time+e);function r(t){var e=new F("SHA-256","TEXT",{encoding:"UTF8"});return e.update(t),e.getHash("HEX")}},r}(o),Y=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.bookmark=function(t){var e="bookmark";return e+=s(t,"&"),this.request(e)},n.bookmarks=function(t){var e="bookmarks";return e+=s(t,"&"),this.request(e)},n.getBookmark=function(t){var e="get_bookmark";return e+=s(t,"&"),this.request(e)},n.bookmarkCreate=function(t){var e="bookmark_create";return e+=s(t,"&"),this.request(e)},n.bookmarkEdit=function(t){var e="bookmark_edit";return e+=s(t,"&"),this.request(e)},n.bookmarkDelete=function(t){var e="bookmark_delete";return e+=s(t,"&"),this.request(e)},r}(o),I=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.catalogs=function(t){var e="catalogs";return e+=s(t,"&"),this.request(e)},n.catalog=function(t){var e="catalog";return e+=s(t,"&"),this.request(e)},n.catalogAction=function(t){var e="catalog_action";return e+=s(t,"&"),this.request(e)},n.catalogFile=function(t){var e="catalog_file";return e+=s(t,"&"),this.request(e)},n.catalogAdd=function(t){var e="catalog_add";return e+=s(t,"&"),this.request(e)},n.catalogDelete=function(t){var e="catalog_delete";return e+=s(t,"&"),this.request(e)},r}(o),j=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.genres=function(t){var e="genres";return e+=s(t,"&"),this.request(e)},n.genre=function(t){var e="genre";return e+=s(t,"&"),this.request(e)},r}(o),x=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.labels=function(t){var e="labels";return e+=s(t,"&"),this.request(e)},n.label=function(t){var e="label";return e+=s(t,"&"),this.request(e)},r}(o),O=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.licenses=function(t){var e="licenses";return e+=s(t,"&"),this.request(e)},n.license=function(t){var e="license";return e+=s(t,"&"),this.request(e)},r}(o),N=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.liveStreams=function(t){var e="live_streams";return e+=s(t,"&"),this.request(e)},n.liveStream=function(t){var e="live_stream";return e+=s(t,"&"),this.request(e)},n.liveStreamCreate=function(t){var e="live_stream_create";return e+=s(t,"&"),this.request(e)},n.liveStreamEdit=function(t){var e="live_stream_edit";return e+=s(t,"&"),this.request(e)},n.liveStreamDelete=function(t){var e="live_stream_delete";return e+=s(t,"&"),this.request(e)},r}(o),K=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.playlists=function(t){var e="playlists";return e+=s(t,"&"),this.request(e)},n.smartlists=function(t){var e="playlists";return e+=s(t,"&"),this.request(e).then(function(t){return Array.isArray(t.playlist)&&(t.playlist=t.playlist.filter(function(t){return t.id.toString().startsWith("smart_")})),t})},n.playlist=function(t){var e="playlist";return e+=s(t,"&"),this.request(e)},n.userPlaylists=function(t){var e="user_playlists";return e+=s(t,"&"),this.request(e)},n.userSmartlists=function(t){var e="user_smartlists";return e+=s(t,"&"),this.request(e)},n.playlistCreate=function(t){var e="playlist_create";return e+=s(t,"&"),this.request(e)},n.playlistAdd=function(t){var e="playlist_add";return e+=s(t,"&"),this.request(e)},n.playlistEdit=function(t){var e="playlist_edit";return e+=s(t,"&"),this.request(e)},n.playlistDelete=function(t){var e="playlist_delete";return e+=s(t,"&"),this.request(e)},n.playlistAddSong=function(t){var e="playlist_add_song";return e+=s(t,"&"),this.request(e)},n.playlistRemoveSong=function(t){var e="playlist_remove_song";return e+=s(t,"&"),this.request(e)},n.playlistGenerate=function(t){var e="playlist_generate";return e+=s(t,"&"),this.request(e)},n.playlistHash=function(t){var e="playlist_hash";return e+=s(t,"&"),this.request(e)},r}(o),M=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.podcasts=function(t){var e="podcasts";return e+=s(t,"&"),this.request(e)},n.podcast=function(t){var e="podcast";return e+=s(t,"&"),this.request(e)},n.podcastCreate=function(t){var e="podcast_create";return e+=s(t,"&"),this.request(e)},n.podcastEdit=function(t){var e="podcast_edit";return e+=s(t,"&"),this.request(e)},n.podcastDelete=function(t){var e="podcast_delete";return e+=s(t,"&"),this.request(e)},n.podcastEpisodes=function(t){var e="podcast_episodes";return e+=s(t,"&"),this.request(e)},n.podcastEpisode=function(t){var e="podcast_episode";return e+=s(t,"&"),this.request(e)},n.podcastEpisodeDelete=function(t){var e="podcast_episode_delete";return e+=s(t,"&"),this.request(e)},n.updatePodcast=function(t){var e="update_podcast";return e+=s(t,"&"),this.request(e)},n.deletedPodcastEpisodes=function(t){var e="deleted_podcast_episodes";return e+=s(t,"&"),this.request(e)},r}(o),D=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.systemPreferences=function(){return this.request("system_preferences")},n.systemPreference=function(t){var e="system_preference";return e+=s(t,"&"),this.request(e)},n.userPreferences=function(){return this.request("user_preferences")},n.userPreference=function(t){var e="user_preference";return e+=s(t,"&"),this.request(e)},n.preferenceCreate=function(t){var e="preference_create";return e+=s(t,"&"),this.request(e)},n.preferenceEdit=function(t){var e="preference_edit";return e+=s(t,"&"),this.request(e)},n.preferenceDelete=function(t){var e="preference_delete";return e+=s(t,"&"),this.request(e)},r}(o),X=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.shares=function(t){var e="shares";return e+=s(t,"&"),this.request(e)},n.share=function(t){var e="share";return e+=s(t,"&"),this.request(e)},n.shareCreate=function(t){var e="share_create";return e+=s(t,"&"),this.request(e)},n.shareEdit=function(t){var e="share_edit";return e+=s(t,"&"),this.request(e)},n.shareDelete=function(t){var e="share_delete";return e+=s(t,"&"),this.request(e)},r}(o),G=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}return t(r,e),r.prototype.last_shouts=function(t){var e="last_shouts";return e+=s(t,"&"),this.request(e)},r}(o),z=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.songs=function(t){var e="songs";return e+=s(t,"&"),this.request(e)},n.song=function(t){var e="song";return e+=s(t,"&"),this.request(e)},n.artistSongs=function(t){var e="artist_songs";return e+=s(t,"&"),this.request(e)},n.albumSongs=function(t){var e="album_songs";return e+=s(t,"&"),this.request(e)},n.genreSongs=function(t){var e="genre_songs";return e+=s(t,"&"),this.request(e)},n.playlistSongs=function(t){var e="playlist_songs";return e+=s(t,"&"),this.request(e)},n.licenseSongs=function(t){var e="license_songs";return e+=s(t,"&"),this.request(e)},n.songDelete=function(t){var e="song_delete";return e+=s(t,"&"),this.request(e)},n.urlToSong=function(t){var e="url_to_song";return t.url=encodeURIComponent(t.url),e+=s(t,"&"),this.request(e)},n.searchSongs=function(t){var e="search_songs";return e+=s(t,"&"),this.request(e)},n.deletedSongs=function(t){var e="deleted_songs";return e+=s(t,"&"),this.request(e)},r}(o),V=/*#__PURE__*/function(e){function r(){for(var t,r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(t=e.call.apply(e,[this].concat(n))||this).search=t.advancedSearch,t}t(r,e);var n=r.prototype;return n.systemUpdate=function(){return this.request("system_update")},n.getIndexes=function(t){var e,r="get_indexes";switch(r+=s(t,"&"),t.type){case"song":case"album":case"artist":case"album_artist":case"playlist":case"podcast":case"podcast_episode":case"live_stream":e=this.request(r);break;default:return!1}return e},n.list=function(t){var e="list";return e+=s(t,"&"),this.request(e)},n.index=function(t){var e="index";return e+=s(t,"&"),this.request(e)},n.browse=function(t){var e="browse";return e+=s(t,"&"),this.request(e)},n.getSimilar=function(t){var e,r="get_similar";switch(r+=s(t,"&"),t.type){case"song":case"artist":e=this.request(r);break;default:return!1}return e},n.stats=function(t){var e,r="stats";switch(r+=s(t,"&"),t.type){case"song":case"album":case"artist":case"video":case"playlist":case"podcast":case"podcast_episode":e=this.request(r);break;default:return!1}return e},n.rate=function(t){var e="rate";return e+=s(t,"&"),this.request(e)},n.flag=function(t){var e="flag";return e+=s(t,"&"),this.request(e)},n.recordPlay=function(t){var e="record_play";return e+=s(t,"&"),this.request(e)},n.scrobble=function(t){var e="scrobble";return e+=s(t,"&"),this.request(e)},n.updateFromTags=function(t){var e="update_from_tags";return e+=s(t,"&"),this.request(e)},n.updateArtistInfo=function(t){var e="update_artist_info";return e+=s(t,"&"),this.request(e)},n.updateArt=function(t){var e="update_art";return e+=s(t,"&"),this.request(e)},n.stream=function(t){var e="stream";return e+=s(t,"&"),this.binary(e)},n.download=function(t){var e="download";return e+=s(t,"&"),this.binary(e)},n.getArt=function(t){var e="get_art";return e+=s(t,"&"),this.binary(e)},n.localplay=function(t){var e="localplay";return e+=s(t,"&"),this.request(e)},n.localplaySongs=function(){return this.request("localplay_songs")},n.democratic=function(t){var e="democratic";return e+=s(t,"&"),this.request(e)},n.nowPlaying=function(){return this.request("now_playing")},n.player=function(t){var e="player";return e+=s(t,"&"),this.request(e)},n.advancedSearch=function(t){for(var e,r="advanced_search",n=0;n<t.rules.length;n++){var i=t.rules[n],u=n+1;t["rule_"+u]=i[0],t["rule_"+u+"_operator"]=i[1],t["rule_"+u+"_input"]=i[2],"metadata"===i[0]&&(t["rule_"+u+"_subtype"]=i[3])}switch(delete t.rules,r+=s(t,"&"),t.type){case"song":case"album":case"artist":case"album_artist":case"song_artist":case"label":case"playlist":case"podcast":case"podcast_episode":case"genre":case"user":case"video":e=this.request(r);break;default:return!1}return e},n.searchGroup=function(t){for(var e="search_group",r=0;r<t.rules.length;r++){var n=t.rules[r],i=r+1;t["rule_"+i]=n[0],t["rule_"+i+"_operator"]=n[1],t["rule_"+i+"_input"]=n[2],"metadata"===n[0]&&(t["rule_"+i+"_subtype"]=n[3])}return delete t.rules,e+=s(t,"&"),this.request(e)},r}(o),J=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.users=function(){return this.request("users")},n.user=function(t){var e="user";return e+=s(t,"&"),this.request(e)},n.userCreate=function(t){var e="user_create";return e+=s(t,"&"),this.request(e)},n.register=function(t){var e="register";return e+=s(t,"&"),this.request(e)},n.userUpdate=function(t){var e="user_update";return e+=s(t,"&"),this.request(e)},n.userEdit=function(t){var e="user_edit";return e+=s(t,"&"),this.request(e)},n.userDelete=function(t){var e="user_delete";return e+=s(t,"&"),this.request(e)},n.followers=function(t){var e="followers";return e+=s(t,"&"),this.request(e)},n.following=function(t){var e="following";return e+=s(t,"&"),this.request(e)},n.toggleFollow=function(t){var e="toggle_follow";return e+=s(t,"&"),this.request(e)},n.timeline=function(t){var e="timeline";return e+=s(t,"&"),this.request(e)},n.friendsTimeline=function(t){var e="friends_timeline";return e+=s(t,"&"),this.request(e)},r}(o),W=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.videos=function(t){var e="videos";return e+=s(t,"&"),this.request(e)},n.video=function(t){var e="video";return e+=s(t,"&"),this.request(e)},n.deletedVideos=function(t){var e="deleted_videos";return e+=s(t,"&"),this.request(e)},r}(o),Z=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}return t(r,e),r}(o);P=Z,[a,c,B,Y,I,j,x,O,N,K,M,D,X,G,z,V,J,W].forEach(function(t){Object.getOwnPropertyNames(t.prototype).forEach(function(e){Object.defineProperty(P.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e))})}),module.exports=Z;
|
|
1
|
+
function t(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,e(t,r)}function e(t,r){return e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},e(t,r)}var r=Object.prototype.hasOwnProperty;function n(t){try{return encodeURIComponent(t)}catch(t){return null}}var s=function(t,e){e=e||"";var s,i,u=[];for(i in"string"!=typeof e&&(e="?"),t)if(r.call(t,i)){if((s=t[i])||null!=s&&!isNaN(s)||(s=""),i=n(i),s=n(s),null===i||null===s)continue;u.push(i+"="+s)}return u.length?e+u.join("&"):""},i={__proto__:null,default:function(t,e){return e=e||{},new Promise(function(r,n){var s=new XMLHttpRequest,i=[],u=[],o={},a=function(){return{ok:2==(s.status/100|0),statusText:s.statusText,status:s.status,url:s.responseURL,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(s.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([s.response]))},clone:a,headers:{keys:function(){return i},entries:function(){return u},get:function(t){return o[t.toLowerCase()]},has:function(t){return t.toLowerCase()in o}}}};for(var c in s.open(e.method||"get",t,!0),s.onload=function(){s.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(t,e,r){i.push(e=e.toLowerCase()),u.push([e,r]),o[e]=o[e]?o[e]+","+r:r}),r(a())},s.onerror=n,s.withCredentials="include"==e.credentials,e.headers)s.setRequestHeader(c,e.headers[c]);s.send(e.body||null)})}},u=self.fetch||(self.fetch=i.default||i),o=/*#__PURE__*/function(){function t(t){this.sessionKey=void 0,this.url=void 0,this.version="6.6.8",this.useBearerToken=void 0,this.debug=void 0,this.sessionKey=t.sessionKey||null,this.url=t.url,this.useBearerToken=t.useBearerToken||!1,this.debug=t.debug||!1}var e=t.prototype;return e.request=function(t){var e="&auth="+this.sessionKey,r=this.url+"/server/json.server.php?action="+t+"&version="+this.version;return this.useBearerToken||(r+=e),this.debug&&console.debug("javascript-ampache query URL %c"+r+e,"color: black; font-style: italic; background-color: orange;padding: 2px"),u(r,{method:"GET",headers:{Authorization:this.useBearerToken?"Bearer "+this.sessionKey:void 0}}).then(function(t){if(t.ok)return t.json();throw new Error(t.statusText)})},e.binary=function(t){var e="&auth="+this.sessionKey,r=this.url+"/server/json.server.php?action="+t+"&version="+this.version;return this.useBearerToken||(r+=e),this.debug&&console.debug("javascript-ampache query URL %c"+r+e,"color: black; font-style: italic; background-color: orange;padding: 2px"),u(r,{method:"GET",headers:{Authorization:this.useBearerToken?"Bearer "+this.sessionKey:void 0}}).then(function(t){return t.blob()}).then(function(t){return t})},e.setSessionKey=function(t){this.sessionKey=t},e.rawURL=function(t,e){var r=t;r+=s(e,"&");var n=this.url+"/server/json.server.php?action="+r+"&version="+this.version;return this.debug&&console.debug("javascript-ampache query URL %c"+n+"&auth="+this.sessionKey,"color: black; font-style: italic; background-color: orange;padding: 2px"),n},t}(),a=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.albums=function(t){var e="albums";return e+=s(t,"&"),this.request(e)},n.album=function(t){var e="album";return e+=s(t,"&"),this.request(e)},n.artistAlbums=function(t){var e="artist_albums";return e+=s(t,"&"),this.request(e)},n.genreAlbums=function(t){var e="genre_albums";return e+=s(t,"&"),this.request(e)},r}(o),c=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.artists=function(t){var e="artists";return e+=s(t,"&"),this.request(e)},n.artist=function(t){var e="artist";return e+=s(t,"&"),this.request(e)},n.genreArtists=function(t){var e="genre_artists";return e+=s(t,"&"),this.request(e)},n.labelArtists=function(t){var e="label_artists";return e+=s(t,"&"),this.request(e)},r}(o);const h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l="ARRAYBUFFER not supported by this environment",f="UINT8ARRAY not supported by this environment";function p(t,e,r,n){let s,i,u;const o=e||[0],a=(r=r||0)>>>3,c=-1===n?3:0;for(s=0;s<t.length;s+=1)u=s+a,i=u>>>2,o.length<=i&&o.push(0),o[i]|=t[s]<<8*(c+n*(u%4));return{value:o,binLen:8*t.length+r}}function d(t,e,r){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,n){return function(t,e,r,n){let s,i,u,o;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");const a=e||[0],c=(r=r||0)>>>3,h=-1===n?3:0;for(s=0;s<t.length;s+=2){if(i=parseInt(t.substr(s,2),16),isNaN(i))throw new Error("String of HEX type contains invalid characters");for(o=(s>>>1)+c,u=o>>>2;a.length<=u;)a.push(0);a[u]|=i<<8*(h+n*(o%4))}return{value:a,binLen:4*t.length+r}}(t,e,n,r)};case"TEXT":return function(t,n,s){return function(t,e,r,n,s){let i,u,o,a,c,h,l,f,p=0;const d=r||[0],v=(n=n||0)>>>3;if("UTF8"===e)for(l=-1===s?3:0,o=0;o<t.length;o+=1)for(i=t.charCodeAt(o),u=[],128>i?u.push(i):2048>i?(u.push(192|i>>>6),u.push(128|63&i)):55296>i||57344<=i?u.push(224|i>>>12,128|i>>>6&63,128|63&i):(o+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(o)),u.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),a=0;a<u.length;a+=1){for(h=p+v,c=h>>>2;d.length<=c;)d.push(0);d[c]|=u[a]<<8*(l+s*(h%4)),p+=1}else for(l=-1===s?2:0,f="UTF16LE"===e&&1!==s||"UTF16LE"!==e&&1===s,o=0;o<t.length;o+=1){for(i=t.charCodeAt(o),!0===f&&(a=255&i,i=a<<8|i>>>8),h=p+v,c=h>>>2;d.length<=c;)d.push(0);d[c]|=i<<8*(l+s*(h%4)),p+=2}return{value:d,binLen:8*p+n}}(t,e,n,s,r)};case"B64":return function(t,e,n){return function(t,e,r,n){let s,i,u,o,a,c,l,f=0;const p=e||[0],d=(r=r||0)>>>3,v=-1===n?3:0,g=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==g&&g<t.length)throw new Error("Invalid '=' found in base-64 string");for(i=0;i<t.length;i+=4){for(a=t.substr(i,4),o=0,u=0;u<a.length;u+=1)s=h.indexOf(a.charAt(u)),o|=s<<18-6*u;for(u=0;u<a.length-1;u+=1){for(l=f+d,c=l>>>2;p.length<=c;)p.push(0);p[c]|=(o>>>16-8*u&255)<<8*(v+n*(l%4)),f+=1}}return{value:p,binLen:8*f+r}}(t,e,n,r)};case"BYTES":return function(t,e,n){return function(t,e,r,n){let s,i,u,o;const a=e||[0],c=(r=r||0)>>>3,h=-1===n?3:0;for(i=0;i<t.length;i+=1)s=t.charCodeAt(i),o=i+c,u=o>>>2,a.length<=u&&a.push(0),a[u]|=s<<8*(h+n*(o%4));return{value:a,binLen:8*t.length+r}}(t,e,n,r)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error(l)}return function(t,e,n){return function(t,e,r,n){return p(new Uint8Array(t),e,r,n)}(t,e,n,r)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error(f)}return function(t,e,n){return p(t,e,n,r)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function v(t,e,r,n){switch(t){case"HEX":return function(t){return function(t,e,r,n){const s="0123456789abcdef";let i,u,o="";const a=e/8,c=-1===r?3:0;for(i=0;i<a;i+=1)u=t[i>>>2]>>>8*(c+r*(i%4)),o+=s.charAt(u>>>4&15)+s.charAt(15&u);return n.outputUpper?o.toUpperCase():o}(t,e,r,n)};case"B64":return function(t){return function(t,e,r,n){let s,i,u,o,a,c="";const l=e/8,f=-1===r?3:0;for(s=0;s<l;s+=3)for(o=s+1<l?t[s+1>>>2]:0,a=s+2<l?t[s+2>>>2]:0,u=(t[s>>>2]>>>8*(f+r*(s%4))&255)<<16|(o>>>8*(f+r*((s+1)%4))&255)<<8|a>>>8*(f+r*((s+2)%4))&255,i=0;i<4;i+=1)c+=8*s+6*i<=e?h.charAt(u>>>6*(3-i)&63):n.b64Pad;return c}(t,e,r,n)};case"BYTES":return function(t){return function(t,e,r){let n,s,i="";const u=e/8,o=-1===r?3:0;for(n=0;n<u;n+=1)s=t[n>>>2]>>>8*(o+r*(n%4))&255,i+=String.fromCharCode(s);return i}(t,e,r)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error(l)}return function(t){return function(t,e,r){let n;const s=e/8,i=new ArrayBuffer(s),u=new Uint8Array(i),o=-1===r?3:0;for(n=0;n<s;n+=1)u[n]=t[n>>>2]>>>8*(o+r*(n%4))&255;return i}(t,e,r)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error(f)}return function(t){return function(t,e,r){let n;const s=e/8,i=-1===r?3:0,u=new Uint8Array(s);for(n=0;n<s;n+=1)u[n]=t[n>>>2]>>>8*(i+r*(n%4))&255;return u}(t,e,r)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const g=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],y=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],m=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function q(t){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},r=t||{},n="Output length must be a multiple of 8";if(e.outputUpper=r.outputUpper||!1,r.b64Pad&&(e.b64Pad=r.b64Pad),r.outputLen){if(r.outputLen%8!=0)throw new Error(n);e.outputLen=r.outputLen}else if(r.shakeLen){if(r.shakeLen%8!=0)throw new Error(n);e.outputLen=r.shakeLen}if("boolean"!=typeof e.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw new Error("Invalid b64Pad formatting option");return e}class _{constructor(t,e,r){const n=r||{};if(this.t=e,this.i=n.encoding||"UTF8",this.numRounds=n.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.o=t,this.h=[],this.u=0,this.l=!1,this.A=0,this.p=!1,this.U=[],this.R=[]}update(t){let e,r=0;const n=this.T>>>5,s=this.F(t,this.h,this.u),i=s.binLen,u=s.value,o=i>>>5;for(e=0;e<o;e+=n)r+this.T<=i&&(this.m=this.g(u.slice(e,e+n),this.m),r+=this.T);return this.A+=r,this.h=u.slice(r>>>5),this.u=i%this.T,this.l=!0,this}getHash(t,e){let r,n,s=this.H;const i=q(e);if(this.B){if(-1===i.outputLen)throw new Error("Output length must be specified in options");s=i.outputLen}const u=v(t,s,this.v,i);if(this.p&&this.C)return u(this.C(i));for(n=this.Y(this.h.slice(),this.u,this.A,this.S(this.m),s),r=1;r<this.numRounds;r+=1)this.B&&s%32!=0&&(n[n.length-1]&=16777215>>>24-s%32),n=this.Y(n,s,0,this.I(this.o),s);return u(n)}setHMACKey(t,e,r){if(!this.L)throw new Error("Variant does not support HMAC");if(this.l)throw new Error("Cannot set MAC key after calling update");const n=d(e,(r||{}).encoding||"UTF8",this.v);this.M(n(t))}M(t){const e=this.T>>>3,r=e/4-1;let n;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.p)throw new Error("MAC key already set");for(e<t.binLen/8&&(t.value=this.Y(t.value,t.binLen,0,this.I(this.o),this.H));t.value.length<=r;)t.value.push(0);for(n=0;n<=r;n+=1)this.U[n]=909522486^t.value[n],this.R[n]=1549556828^t.value[n];this.m=this.g(this.U,this.m),this.A=this.T,this.p=!0}getHMAC(t,e){const r=q(e);return v(t,this.H,this.v,r)(this.N())}N(){let t;if(!this.p)throw new Error("Cannot call getHMAC without first setting MAC key");const e=this.Y(this.h.slice(),this.u,this.A,this.S(this.m),this.H);return t=this.g(this.R,this.I(this.o)),t=this.Y(e,this.H,this.T,t,this.H),t}}function b(t,e){return t>>>e|t<<32-e}function w(t,e){return t>>>e}function A(t,e,r){return t&e^~t&r}function E(t,e,r){return t&e^t&r^e&r}function T(t){return b(t,2)^b(t,13)^b(t,22)}function k(t,e){const r=(65535&t)+(65535&e);return(65535&(t>>>16)+(e>>>16)+(r>>>16))<<16|65535&r}function R(t,e,r,n){const s=(65535&t)+(65535&e)+(65535&r)+(65535&n);return(65535&(t>>>16)+(e>>>16)+(r>>>16)+(n>>>16)+(s>>>16))<<16|65535&s}function U(t,e,r,n,s){const i=(65535&t)+(65535&e)+(65535&r)+(65535&n)+(65535&s);return(65535&(t>>>16)+(e>>>16)+(r>>>16)+(n>>>16)+(s>>>16)+(i>>>16))<<16|65535&i}function S(t){return b(t,7)^b(t,18)^w(t,3)}function C(t){return b(t,6)^b(t,11)^b(t,25)}function L(t){let e;return e="SHA-224"==t?y.slice():m.slice(),e}function B(t,e){let r,n,s,i,u,o,a,c,h,l,f;const p=[];for(r=e[0],n=e[1],s=e[2],i=e[3],u=e[4],o=e[5],a=e[6],c=e[7],f=0;f<64;f+=1)p[f]=f<16?t[f]:R(b(d=p[f-2],17)^b(d,19)^w(d,10),p[f-7],S(p[f-15]),p[f-16]),h=U(c,C(u),A(u,o,a),g[f],p[f]),l=k(T(r),E(r,n,s)),c=a,a=o,o=u,u=k(i,h),i=s,s=n,n=r,r=k(h,l);var d;return e[0]=k(r,e[0]),e[1]=k(n,e[1]),e[2]=k(s,e[2]),e[3]=k(i,e[3]),e[4]=k(u,e[4]),e[5]=k(o,e[5]),e[6]=k(a,e[6]),e[7]=k(c,e[7]),e}class H extends _{constructor(t,e,r){if("SHA-224"!==t&&"SHA-256"!==t)throw new Error("Chosen SHA variant is not supported");super(t,e,r);const n=r||{};this.C=this.N,this.L=!0,this.v=-1,this.F=d(this.t,this.i,this.v),this.g=B,this.S=function(t){return t.slice()},this.I=L,this.Y=function(e,r,n,s){return function(t,e,r,n,s){let i,u;const o=15+(e+65>>>9<<4),a=e+r;for(;t.length<=o;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[o]=4294967295&a,t[o-1]=a/4294967296|0,i=0;i<t.length;i+=16)n=B(t.slice(i,i+16),n);return u="SHA-224"===s?[n[0],n[1],n[2],n[3],n[4],n[5],n[6]]:n,u}(e,r,n,s,t)},this.m=L(t),this.T=512,this.H="SHA-224"===t?224:256,this.B=!1,n.hmacKey&&this.M(function(t,e,r,n){const s="hmacKey must include a value and format";if(!e)throw new Error(s);if(void 0===e.value||!e.format)throw new Error(s);return d(e.format,e.encoding||"UTF8",r)(e.value)}(0,n.hmacKey,this.v))}}var F,P=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.handshake=function(t){var e=this;t.timestamp||(t.timestamp=Math.floor((new Date).getTime()/1e3)),t.version&&(this.version=t.version),t.user||delete t.timestamp;var r=this.url+"/server/json.server.php?action=handshake";return r+=s(t,"&"),u(r).then(function(t){return t.json()}).then(function(t){return t.auth&&(e.sessionKey=t.auth),t})},n.ping=function(t){var e="ping";return e+=s(t,"&"),this.request(e)},n.goodbye=function(t){var e="goodbye";return e+=s(t,"&"),this.request(e)},n.lostPassword=function(t){var e="lost_password";return e+=s(t,"&"),this.request(e)},n.encryptPassword=function(t){var e=r(t.password);return r(t.time+e);function r(t){var e=new H("SHA-256","TEXT",{encoding:"UTF8"});return e.update(t),e.getHash("HEX")}},r}(o),Y=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.bookmark=function(t){var e="bookmark";return e+=s(t,"&"),this.request(e)},n.bookmarks=function(t){var e="bookmarks";return e+=s(t,"&"),this.request(e)},n.getBookmark=function(t){var e="get_bookmark";return e+=s(t,"&"),this.request(e)},n.bookmarkCreate=function(t){var e="bookmark_create";return e+=s(t,"&"),this.request(e)},n.bookmarkEdit=function(t){var e="bookmark_edit";return e+=s(t,"&"),this.request(e)},n.bookmarkDelete=function(t){var e="bookmark_delete";return e+=s(t,"&"),this.request(e)},r}(o),I=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.catalogs=function(t){var e="catalogs";return e+=s(t,"&"),this.request(e)},n.catalog=function(t){var e="catalog";return e+=s(t,"&"),this.request(e)},n.catalogAction=function(t){var e="catalog_action";return e+=s(t,"&"),this.request(e)},n.catalogFile=function(t){var e="catalog_file";return e+=s(t,"&"),this.request(e)},n.catalogAdd=function(t){var e="catalog_add";return e+=s(t,"&"),this.request(e)},n.catalogDelete=function(t){var e="catalog_delete";return e+=s(t,"&"),this.request(e)},r}(o),j=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.genres=function(t){var e="genres";return e+=s(t,"&"),this.request(e)},n.genre=function(t){var e="genre";return e+=s(t,"&"),this.request(e)},r}(o),x=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.labels=function(t){var e="labels";return e+=s(t,"&"),this.request(e)},n.label=function(t){var e="label";return e+=s(t,"&"),this.request(e)},r}(o),O=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.licenses=function(t){var e="licenses";return e+=s(t,"&"),this.request(e)},n.license=function(t){var e="license";return e+=s(t,"&"),this.request(e)},r}(o),N=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.liveStreams=function(t){var e="live_streams";return e+=s(t,"&"),this.request(e)},n.liveStream=function(t){var e="live_stream";return e+=s(t,"&"),this.request(e)},n.liveStreamCreate=function(t){var e="live_stream_create";return e+=s(t,"&"),this.request(e)},n.liveStreamEdit=function(t){var e="live_stream_edit";return e+=s(t,"&"),this.request(e)},n.liveStreamDelete=function(t){var e="live_stream_delete";return e+=s(t,"&"),this.request(e)},r}(o),K=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.playlists=function(t){var e="playlists";return e+=s(t,"&"),this.request(e)},n.smartlists=function(t){var e="playlists";return e+=s(t,"&"),this.request(e).then(function(t){return Array.isArray(t.playlist)&&(t.playlist=t.playlist.filter(function(t){return t.id.toString().startsWith("smart_")})),t})},n.playlist=function(t){var e="playlist";return e+=s(t,"&"),this.request(e)},n.userPlaylists=function(t){var e="user_playlists";return e+=s(t,"&"),this.request(e)},n.userSmartlists=function(t){var e="user_smartlists";return e+=s(t,"&"),this.request(e)},n.playlistCreate=function(t){var e="playlist_create";return e+=s(t,"&"),this.request(e)},n.playlistAdd=function(t){var e="playlist_add";return e+=s(t,"&"),this.request(e)},n.playlistEdit=function(t){var e="playlist_edit";return e+=s(t,"&"),this.request(e)},n.playlistDelete=function(t){var e="playlist_delete";return e+=s(t,"&"),this.request(e)},n.playlistAddSong=function(t){var e="playlist_add_song";return e+=s(t,"&"),this.request(e)},n.playlistRemoveSong=function(t){var e="playlist_remove_song";return e+=s(t,"&"),this.request(e)},n.playlistGenerate=function(t){var e="playlist_generate";return e+=s(t,"&"),this.request(e)},n.playlistHash=function(t){var e="playlist_hash";return e+=s(t,"&"),this.request(e)},r}(o),M=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.podcasts=function(t){var e="podcasts";return e+=s(t,"&"),this.request(e)},n.podcast=function(t){var e="podcast";return e+=s(t,"&"),this.request(e)},n.podcastCreate=function(t){var e="podcast_create";return e+=s(t,"&"),this.request(e)},n.podcastEdit=function(t){var e="podcast_edit";return e+=s(t,"&"),this.request(e)},n.podcastDelete=function(t){var e="podcast_delete";return e+=s(t,"&"),this.request(e)},n.podcastEpisodes=function(t){var e="podcast_episodes";return e+=s(t,"&"),this.request(e)},n.podcastEpisode=function(t){var e="podcast_episode";return e+=s(t,"&"),this.request(e)},n.podcastEpisodeDelete=function(t){var e="podcast_episode_delete";return e+=s(t,"&"),this.request(e)},n.updatePodcast=function(t){var e="update_podcast";return e+=s(t,"&"),this.request(e)},n.deletedPodcastEpisodes=function(t){var e="deleted_podcast_episodes";return e+=s(t,"&"),this.request(e)},r}(o),D=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.systemPreferences=function(){return this.request("system_preferences")},n.systemPreference=function(t){var e="system_preference";return e+=s(t,"&"),this.request(e)},n.userPreferences=function(){return this.request("user_preferences")},n.userPreference=function(t){var e="user_preference";return e+=s(t,"&"),this.request(e)},n.preferenceCreate=function(t){var e="preference_create";return e+=s(t,"&"),this.request(e)},n.preferenceEdit=function(t){var e="preference_edit";return e+=s(t,"&"),this.request(e)},n.preferenceDelete=function(t){var e="preference_delete";return e+=s(t,"&"),this.request(e)},r}(o),X=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.shares=function(t){var e="shares";return e+=s(t,"&"),this.request(e)},n.share=function(t){var e="share";return e+=s(t,"&"),this.request(e)},n.shareCreate=function(t){var e="share_create";return e+=s(t,"&"),this.request(e)},n.shareEdit=function(t){var e="share_edit";return e+=s(t,"&"),this.request(e)},n.shareDelete=function(t){var e="share_delete";return e+=s(t,"&"),this.request(e)},r}(o),G=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}return t(r,e),r.prototype.last_shouts=function(t){var e="last_shouts";return e+=s(t,"&"),this.request(e)},r}(o),z=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.songs=function(t){var e="songs";return e+=s(t,"&"),this.request(e)},n.song=function(t){var e="song";return e+=s(t,"&"),this.request(e)},n.artistSongs=function(t){var e="artist_songs";return e+=s(t,"&"),this.request(e)},n.albumSongs=function(t){var e="album_songs";return e+=s(t,"&"),this.request(e)},n.genreSongs=function(t){var e="genre_songs";return e+=s(t,"&"),this.request(e)},n.playlistSongs=function(t){var e="playlist_songs";return e+=s(t,"&"),this.request(e)},n.licenseSongs=function(t){var e="license_songs";return e+=s(t,"&"),this.request(e)},n.songDelete=function(t){var e="song_delete";return e+=s(t,"&"),this.request(e)},n.urlToSong=function(t){var e="url_to_song";return t.url=encodeURIComponent(t.url),e+=s(t,"&"),this.request(e)},n.searchSongs=function(t){var e="search_songs";return e+=s(t,"&"),this.request(e)},n.deletedSongs=function(t){var e="deleted_songs";return e+=s(t,"&"),this.request(e)},r}(o),V=/*#__PURE__*/function(e){function r(){for(var t,r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(t=e.call.apply(e,[this].concat(n))||this).search=t.advancedSearch,t}t(r,e);var n=r.prototype;return n.systemUpdate=function(){return this.request("system_update")},n.getIndexes=function(t){var e,r="get_indexes";switch(r+=s(t,"&"),t.type){case"song":case"album":case"artist":case"album_artist":case"playlist":case"podcast":case"podcast_episode":case"live_stream":e=this.request(r);break;default:return!1}return e},n.list=function(t){var e="list";return e+=s(t,"&"),this.request(e)},n.index=function(t){var e="index";return e+=s(t,"&"),this.request(e)},n.browse=function(t){var e="browse";return e+=s(t,"&"),this.request(e)},n.getSimilar=function(t){var e,r="get_similar";switch(r+=s(t,"&"),t.type){case"song":case"artist":e=this.request(r);break;default:return!1}return e},n.stats=function(t){var e,r="stats";switch(r+=s(t,"&"),t.type){case"song":case"album":case"artist":case"video":case"playlist":case"podcast":case"podcast_episode":e=this.request(r);break;default:return!1}return e},n.rate=function(t){var e="rate";return e+=s(t,"&"),this.request(e)},n.flag=function(t){var e="flag";return e+=s(t,"&"),this.request(e)},n.recordPlay=function(t){var e="record_play";return e+=s(t,"&"),this.request(e)},n.scrobble=function(t){var e="scrobble";return e+=s(t,"&"),this.request(e)},n.updateFromTags=function(t){var e="update_from_tags";return e+=s(t,"&"),this.request(e)},n.updateArtistInfo=function(t){var e="update_artist_info";return e+=s(t,"&"),this.request(e)},n.updateArt=function(t){var e="update_art";return e+=s(t,"&"),this.request(e)},n.stream=function(t){var e="stream";return e+=s(t,"&"),this.binary(e)},n.download=function(t){var e="download";return e+=s(t,"&"),this.binary(e)},n.getArt=function(t){var e="get_art";return e+=s(t,"&"),this.binary(e)},n.localplay=function(t){var e="localplay";return e+=s(t,"&"),this.request(e)},n.localplaySongs=function(){return this.request("localplay_songs")},n.democratic=function(t){var e="democratic";return e+=s(t,"&"),this.request(e)},n.nowPlaying=function(){return this.request("now_playing")},n.player=function(t){var e="player";return e+=s(t,"&"),this.request(e)},n.advancedSearch=function(t){for(var e,r="advanced_search",n=0;n<t.rules.length;n++){var i=t.rules[n],u=n+1;t["rule_"+u]=i[0],t["rule_"+u+"_operator"]=i[1],t["rule_"+u+"_input"]=i[2],"metadata"===i[0]&&(t["rule_"+u+"_subtype"]=i[3])}switch(delete t.rules,r+=s(t,"&"),t.type){case"song":case"album":case"artist":case"album_artist":case"song_artist":case"label":case"playlist":case"podcast":case"podcast_episode":case"genre":case"user":case"video":e=this.request(r);break;default:return!1}return e},n.searchGroup=function(t){for(var e="search_group",r=0;r<t.rules.length;r++){var n=t.rules[r],i=r+1;t["rule_"+i]=n[0],t["rule_"+i+"_operator"]=n[1],t["rule_"+i+"_input"]=n[2],"metadata"===n[0]&&(t["rule_"+i+"_subtype"]=n[3])}return delete t.rules,e+=s(t,"&"),this.request(e)},r}(o),J=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.users=function(){return this.request("users")},n.user=function(t){var e="user";return e+=s(t,"&"),this.request(e)},n.userCreate=function(t){var e="user_create";return e+=s(t,"&"),this.request(e)},n.register=function(t){var e="register";return e+=s(t,"&"),this.request(e)},n.userUpdate=function(t){var e="user_update";return e+=s(t,"&"),this.request(e)},n.userEdit=function(t){var e="user_edit";return e+=s(t,"&"),this.request(e)},n.userDelete=function(t){var e="user_delete";return e+=s(t,"&"),this.request(e)},n.followers=function(t){var e="followers";return e+=s(t,"&"),this.request(e)},n.following=function(t){var e="following";return e+=s(t,"&"),this.request(e)},n.toggleFollow=function(t){var e="toggle_follow";return e+=s(t,"&"),this.request(e)},n.timeline=function(t){var e="timeline";return e+=s(t,"&"),this.request(e)},n.friendsTimeline=function(t){var e="friends_timeline";return e+=s(t,"&"),this.request(e)},r}(o),W=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}t(r,e);var n=r.prototype;return n.videos=function(t){var e="videos";return e+=s(t,"&"),this.request(e)},n.video=function(t){var e="video";return e+=s(t,"&"),this.request(e)},n.deletedVideos=function(t){var e="deleted_videos";return e+=s(t,"&"),this.request(e)},r}(o),Z=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}return t(r,e),r}(o);F=Z,[a,c,P,Y,I,j,x,O,N,K,M,D,X,G,z,V,J,W].forEach(function(t){Object.getOwnPropertyNames(t.prototype).forEach(function(e){Object.defineProperty(F.prototype,e,Object.getOwnPropertyDescriptor(t.prototype,e))})}),module.exports=Z;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|