hivesigner 3.3.5 → 4.1.0

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.
Files changed (58) hide show
  1. package/README.md +29 -2
  2. package/lib/client.d.ts +19 -3
  3. package/lib/hivesigner.min.js +1 -10
  4. package/lib/index.d.ts +4 -0
  5. package/lib/index.js +194 -225
  6. package/lib/methods/send-operation.method.d.ts +1 -2
  7. package/lib/methods/send-operations.method.d.ts +1 -2
  8. package/lib/methods/send-transaction.method.d.ts +1 -2
  9. package/lib/pkce.d.ts +16 -0
  10. package/lib/types/callback-function.type.d.ts +1 -1
  11. package/lib/types/hive.types.d.ts +13 -0
  12. package/lib/types/index.d.ts +2 -0
  13. package/lib/types/login-options.interface.d.ts +2 -0
  14. package/lib/types/send-response.type.d.ts +1 -1
  15. package/lib/types/token-response.interface.d.ts +8 -0
  16. package/package.json +11 -18
  17. package/.babelrc +0 -8
  18. package/.claude/settings.local.json +0 -12
  19. package/.eslintignore +0 -3
  20. package/.eslintrc.js +0 -16
  21. package/CLAUDE.md +0 -142
  22. package/docs/CNAME +0 -1
  23. package/docs/index.html +0 -221
  24. package/jest.config.js +0 -10
  25. package/rollup.config.js +0 -12
  26. package/src/client.spec.ts +0 -455
  27. package/src/client.ts +0 -317
  28. package/src/consts/api-url.const.ts +0 -1
  29. package/src/consts/base-url.const.ts +0 -1
  30. package/src/consts/beta-url.const.ts +0 -1
  31. package/src/consts/index.ts +0 -3
  32. package/src/default-import.spec.ts +0 -10
  33. package/src/factories/index.ts +0 -1
  34. package/src/factories/initialize.factory.spec.ts +0 -9
  35. package/src/factories/initialize.factory.ts +0 -7
  36. package/src/index.ts +0 -16
  37. package/src/methods/index.ts +0 -4
  38. package/src/methods/send-operation.method.spec.ts +0 -47
  39. package/src/methods/send-operation.method.ts +0 -15
  40. package/src/methods/send-operations.method.spec.ts +0 -47
  41. package/src/methods/send-operations.method.ts +0 -15
  42. package/src/methods/send-transaction.method.spec.ts +0 -47
  43. package/src/methods/send-transaction.method.ts +0 -15
  44. package/src/methods/sign.method.spec.ts +0 -60
  45. package/src/methods/sign.method.ts +0 -22
  46. package/src/modules-import.spec.ts +0 -11
  47. package/src/require-import.spec.js +0 -11
  48. package/src/require-import.spec.ts +0 -10
  49. package/src/types/callback-function.type.ts +0 -1
  50. package/src/types/client-config.interface.ts +0 -8
  51. package/src/types/index.ts +0 -5
  52. package/src/types/login-options.interface.ts +0 -3
  53. package/src/types/send-response.type.ts +0 -1
  54. package/src/types/sign-errors.interface.ts +0 -4
  55. package/src/utilities/index.ts +0 -1
  56. package/src/utilities/is-browser.util.ts +0 -3
  57. package/tsconfig.json +0 -15
  58. package/webpack.config.js +0 -26
package/README.md CHANGED
@@ -4,7 +4,20 @@
4
4
 
5
5
  # HiveSigner SDK
6
6
 
7
- The official HiveSigner JavaScript SDK, written in Typescript. Library supports both callback and promise functions. Learn more about integration: https://docs.hivesigner.com.
7
+ The official HiveSigner JavaScript SDK, written in Typescript. Library supports both callback and promise functions. Learn more about integration: https://hivesigner.com/docs.
8
+
9
+ ## Upgrading to v4
10
+
11
+ v4 includes breaking changes that reduce the bundle size by 71%. Please review before upgrading:
12
+
13
+ ### Requirements
14
+ - **Node.js 18+** is now required. The `cross-fetch` polyfill has been removed in favor of the native `fetch` API. If you are on Node.js < 18, stay on v3.x.
15
+ - **ES2017+ environments** — the build output now targets ES2017. IE11 and other pre-ES2017 browsers are no longer supported.
16
+
17
+ ### Removed dependencies
18
+ - `cross-fetch` — replaced by native `fetch`. If your environment does not provide a global `fetch`, you must polyfill it before using the SDK.
19
+ - `@babel/runtime` — no longer needed.
20
+ - `@hiveio/dhive` is no longer a peer/dev dependency. The `Operation` and `Transaction` types are now included directly in the SDK. If you were importing these types from `@hiveio/dhive` and passing them to SDK methods like `broadcast()`, they remain compatible — no code changes needed.
8
21
 
9
22
  ## Getting started
10
23
 
@@ -36,7 +49,7 @@ or
36
49
 
37
50
  For general information about HiveSigner and setting up your app you can checkout the developer documentation.
38
51
 
39
- **[Developers documentation](https://hivesigner.com/developers)**
52
+ **[Developers documentation](https://hivesigner.com/docs)**
40
53
 
41
54
  ## SDK methods
42
55
 
@@ -80,6 +93,20 @@ After logging in, HiveSigner will redirect the user to the "redirect_uri" specif
80
93
  - __expires_in__: The number of seconds until the access token expires.
81
94
  - __username__: The username of the current user.
82
95
 
96
+ ### Mobile and desktop apps: PKCE
97
+ An app that cannot keep a client secret (a mobile or desktop app) uses the code flow with PKCE. It may then use its own scheme as the callback, such as `myapp://callback`, registered on its app account.
98
+ ```js
99
+ import { Client, createPkcePair } from 'hivesigner';
100
+
101
+ const client = new Client({ app: 'myapp', callbackURL: 'myapp://callback', responseType: 'code', scope: ['posting'] });
102
+
103
+ const { codeVerifier, codeChallenge } = await createPkcePair(); // keep codeVerifier in memory
104
+ const link = client.getLoginURL(state, undefined, { codeChallenge });
105
+ // open link, then on myapp://callback?code=CODE&state=STATE:
106
+ const { access_token, username } = await client.exchangeCode(code, codeVerifier);
107
+ ```
108
+ The code can be exchanged once, within 10 minutes, and only with the verifier. A native app gets no refresh token. A server can pass its client secret as the third argument of `exchangeCode`. `createPkcePair` needs Web Crypto: Node.js 20+ or a modern browser. In React Native, add a `crypto.getRandomValues` and `crypto.subtle` polyfill, or make the pair with a native library and pass the challenge to `getLoginURL`. The rest of the SDK still runs on Node.js 18. Full guide: https://hivesigner.com/docs/pkce
109
+
83
110
  ### Get user profile
84
111
  Once a user is logged in to your app you can call the following method to get the details of their account:
85
112
  ```
package/lib/client.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { CallbackFunction, ClientConfig, LoginOptions, SendResponse } from './types';
2
- import { Operation } from '@hiveio/dhive';
1
+ import { CallbackFunction, ClientConfig, LoginOptions, Operation, SendResponse, TokenResponse } from './types';
3
2
  export declare class Client {
4
3
  apiURL: string;
5
4
  app: string;
@@ -15,8 +14,25 @@ export declare class Client {
15
14
  setAccessToken(accessToken: string): this;
16
15
  removeAccessToken(): this;
17
16
  setScope(scope: string[]): this;
18
- getLoginURL(state: string, account?: string): string;
17
+ /**
18
+ * The authorize URL. Pass `options.codeChallenge` (from createPkcePair) to
19
+ * protect a code flow sign-in with PKCE, which a native app needs for a
20
+ * custom scheme callback such as `myapp://callback`.
21
+ */
22
+ getLoginURL(state: string, account?: string, options?: {
23
+ codeChallenge?: string;
24
+ }): string;
19
25
  login(options: LoginOptions): void;
26
+ /**
27
+ * Exchange a code for tokens at /api/oauth2/token. With PKCE send the
28
+ * verifier; a native app sends no secret and gets no refresh token. A
29
+ * server may pass its client secret as well.
30
+ *
31
+ * Sent WITHOUT the Authorization header: the API reads that header before
32
+ * the body, so a token this client already holds would be read instead of
33
+ * the code.
34
+ */
35
+ exchangeCode(code: string, codeVerifier?: string, clientSecret?: string): Promise<TokenResponse>;
20
36
  me(): Promise<SendResponse>;
21
37
  me(cb: CallbackFunction): Promise<SendResponse>;
22
38
  decode(memo: string): Promise<SendResponse>;
@@ -1,10 +1 @@
1
- var hivesigner=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=10)}([function(t,e){t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,r){t.exports=r(11)},function(t,e,r){"use strict";(function(t,n){Object.defineProperty(e,"__esModule",{value:!0}),e.encodeOps=e.encodeOp=e.encodeTx=e.resolveCallback=e.resolveTransaction=e.decode=void 0,"undefined"==typeof URL&&(t.URL=r(5).URL),"undefined"==typeof URLSearchParams&&(t.URLSearchParams=r(5).URLSearchParams),"undefined"==typeof btoa&&(t.btoa=function(t){return new n(t,"binary").toString("base64")}),"undefined"==typeof atob&&(t.atob=function(t){return new n(t,"base64").toString("binary")});var o={"/":"_",_:"/","+":"-","-":"+","=":".",".":"="},i=function(t){return btoa(t).replace(/(\+|\/|=)/g,(function(t){return o[t]}))},s=function(t){return atob(t.replace(/(-|_|\.)/g,(function(t){return o[t]})))};e.decode=function(t){var e=t.slice(0,5),r=new URL(t.replace(/^hive:/,"http:"));if("hive:"!==e)throw new Error("Invalid protocol, expected 'hive:' got '"+e+"'");if("sign"!==r.host)throw new Error("Invalid action, expected 'sign' got '"+r.host+"'");var n,o,i=r.pathname.split("/").slice(1),a=i[0],u=i[1];try{n=JSON.parse(s(u))}catch(t){throw t.message="Invalid payload: "+t.message,t}switch(a){case"tx":o=n;break;case"op":case"ops":o={ref_block_num:"__ref_block_num",ref_block_prefix:"__ref_block_prefix",expiration:"__expiration",extensions:[],operations:"ops"===a?n:[n]};break;default:throw new Error("Invalid signing action '"+a+"'")}var h={};return r.searchParams.has("cb")&&(h.callback=s(r.searchParams.get("cb"))),r.searchParams.has("nb")&&(h.no_broadcast=!0),r.searchParams.has("s")&&(h.signer=r.searchParams.get("s")),{tx:o,params:h}};var a=/(__(ref_block_(num|prefix)|expiration|signer))/g;e.resolveTransaction=function(t,e,r){var n=e.signer||r.preferred_signer;if(!r.signers.includes(n))throw new Error("Signer '"+n+"' not available");var o={__ref_block_num:r.ref_block_num,__ref_block_prefix:r.ref_block_prefix,__expiration:r.expiration,__signer:n},i=function(t){var e=typeof t;switch("object"===e&&Array.isArray(t)?e="array":null===t&&(e="null"),e){case"string":return t.replace(a,(function(t){return o[t]}));case"array":return t.map(i);case"object":for(var r={},n=0,s=Object.entries(t);n<s.length;n++){var u=s[n],h=u[0],c=u[1];r[h]=i(c)}return r;default:return t}};return{signer:n,tx:i(t)}};var u=/({{(sig|id|block|txn)}})/g;function h(t){var e=new URLSearchParams;!0===t.no_broadcast&&e.set("nb",""),t.signer&&e.set("s",t.signer),t.callback&&e.set("cb",i(t.callback));var r=e.toString();return r.length>0&&(r="?"+r),r}function c(t){return i(JSON.stringify(t,null,0))}e.resolveCallback=function(t,e){return t.replace(u,(function(t,r,n){return e[n]||""}))},e.encodeTx=function(t,e){return void 0===e&&(e={}),"hive://sign/tx/"+c(t)+h(e)},e.encodeOp=function(t,e){return void 0===e&&(e={}),"hive://sign/op/"+c(t)+h(e)},e.encodeOps=function(t,e){return void 0===e&&(e={}),"hive://sign/ops/"+c(t)+h(e)}}).call(this,r(4),r(12).Buffer)},function(t,e){function r(t,e,r,n,o,i,s){try{var a=t[i](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,o)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var s=t.apply(e,n);function a(t){r(s,o,i,a,u,"next",t)}function u(t){r(s,o,i,a,u,"throw",t)}a(void 0)}))}},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";var n=r(16),o=r(18);function i(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}e.parse=b,e.resolve=function(t,e){return b(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?b(t,!1,!0).resolveObject(e):e},e.format=function(t){o.isString(t)&&(t=b(t));return t instanceof i?t.format():i.prototype.format.call(t)},e.Url=i;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,u=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,h=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(h),f=["%","/","?",";","#"].concat(c),l=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:!0,"javascript:":!0},v={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},m=r(19);function b(t,e,r){if(t&&o.isObject(t)&&t instanceof i)return t;var n=new i;return n.parse(t,e,r),n}i.prototype.parse=function(t,e,r){if(!o.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var i=t.indexOf("?"),a=-1!==i&&i<t.indexOf("#")?"?":"#",h=t.split(a);h[0]=h[0].replace(/\\/g,"/");var b=t=h.join(a);if(b=b.trim(),!r&&1===t.split("#").length){var w=u.exec(b);if(w)return this.path=b,this.href=b,this.pathname=w[1],w[2]?(this.search=w[2],this.query=e?m.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var _=s.exec(b);if(_){var x=(_=_[0]).toLowerCase();this.protocol=x,b=b.substr(_.length)}if(r||_||b.match(/^\/\/[^@\/]+@[^@\/]+/)){var A="//"===b.substr(0,2);!A||_&&v[_]||(b=b.substr(2),this.slashes=!0)}if(!v[_]&&(A||_&&!g[_])){for(var E,R,O=-1,T=0;T<l.length;T++){-1!==(P=b.indexOf(l[T]))&&(-1===O||P<O)&&(O=P)}-1!==(R=-1===O?b.lastIndexOf("@"):b.lastIndexOf("@",O))&&(E=b.slice(0,R),b=b.slice(R+1),this.auth=decodeURIComponent(E)),O=-1;for(T=0;T<f.length;T++){var P;-1!==(P=b.indexOf(f[T]))&&(-1===O||P<O)&&(O=P)}-1===O&&(O=b.length),this.host=b.slice(0,O),b=b.slice(O),this.parseHost(),this.hostname=this.hostname||"";var U="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!U)for(var k=this.hostname.split(/\./),S=(T=0,k.length);T<S;T++){var L=k[T];if(L&&!L.match(p)){for(var j="",B=0,I=L.length;B<I;B++)L.charCodeAt(B)>127?j+="x":j+=L[B];if(!j.match(p)){var C=k.slice(0,T),M=k.slice(T+1),D=L.match(d);D&&(C.push(D[1]),M.unshift(D[2])),M.length&&(b="/"+M.join(".")+b),this.hostname=C.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),U||(this.hostname=n.toASCII(this.hostname));var Y=this.port?":"+this.port:"",N=this.hostname||"";this.host=N+Y,this.href+=this.host,U&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==b[0]&&(b="/"+b))}if(!y[x])for(T=0,S=c.length;T<S;T++){var q=c[T];if(-1!==b.indexOf(q)){var F=encodeURIComponent(q);F===q&&(F=escape(q)),b=b.split(q).join(F)}}var z=b.indexOf("#");-1!==z&&(this.hash=b.substr(z),b=b.slice(0,z));var J=b.indexOf("?");if(-1!==J?(this.search=b.substr(J),this.query=b.substr(J+1),e&&(this.query=m.parse(this.query)),b=b.slice(0,J)):e&&(this.search="",this.query={}),b&&(this.pathname=b),g[x]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){Y=this.pathname||"";var G=this.search||"";this.path=Y+G}return this.href=this.format(),this},i.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",i=!1,s="";this.host?i=t+this.host:this.hostname&&(i=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&o.isObject(this.query)&&Object.keys(this.query).length&&(s=m.stringify(this.query));var a=this.search||s&&"?"+s||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||g[e])&&!1!==i?(i="//"+(i||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):i||(i=""),n&&"#"!==n.charAt(0)&&(n="#"+n),a&&"?"!==a.charAt(0)&&(a="?"+a),e+i+(r=r.replace(/[?#]/g,(function(t){return encodeURIComponent(t)})))+(a=a.replace("#","%23"))+n},i.prototype.resolve=function(t){return this.resolveObject(b(t,!1,!0)).format()},i.prototype.resolveObject=function(t){if(o.isString(t)){var e=new i;e.parse(t,!1,!0),t=e}for(var r=new i,n=Object.keys(this),s=0;s<n.length;s++){var a=n[s];r[a]=this[a]}if(r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var u=Object.keys(t),h=0;h<u.length;h++){var c=u[h];"protocol"!==c&&(r[c]=t[c])}return g[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!g[t.protocol]){for(var f=Object.keys(t),l=0;l<f.length;l++){var p=f[l];r[p]=t[p]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||v[t.protocol])r.pathname=t.pathname;else{for(var d=(t.pathname||"").split("/");d.length&&!(t.host=d.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),r.pathname=d.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var y=r.pathname||"",m=r.search||"";r.path=y+m}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var b=r.pathname&&"/"===r.pathname.charAt(0),w=t.host||t.pathname&&"/"===t.pathname.charAt(0),_=w||b||r.host&&t.pathname,x=_,A=r.pathname&&r.pathname.split("/")||[],E=(d=t.pathname&&t.pathname.split("/")||[],r.protocol&&!g[r.protocol]);if(E&&(r.hostname="",r.port=null,r.host&&(""===A[0]?A[0]=r.host:A.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===d[0]?d[0]=t.host:d.unshift(t.host)),t.host=null),_=_&&(""===d[0]||""===A[0])),w)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,A=d;else if(d.length)A||(A=[]),A.pop(),A=A.concat(d),r.search=t.search,r.query=t.query;else if(!o.isNullOrUndefined(t.search)){if(E)r.hostname=r.host=A.shift(),(U=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=U.shift(),r.host=r.hostname=U.shift());return r.search=t.search,r.query=t.query,o.isNull(r.pathname)&&o.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!A.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var R=A.slice(-1)[0],O=(r.host||t.host||A.length>1)&&("."===R||".."===R)||""===R,T=0,P=A.length;P>=0;P--)"."===(R=A[P])?A.splice(P,1):".."===R?(A.splice(P,1),T++):T&&(A.splice(P,1),T--);if(!_&&!x)for(;T--;T)A.unshift("..");!_||""===A[0]||A[0]&&"/"===A[0].charAt(0)||A.unshift(""),O&&"/"!==A.join("/").substr(-1)&&A.push("");var U,k=""===A[0]||A[0]&&"/"===A[0].charAt(0);E&&(r.hostname=r.host=k?"":A.length?A.shift():"",(U=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=U.shift(),r.host=r.hostname=U.shift()));return(_=_||r.host&&A.length)&&!k&&A.unshift(""),A.length?r.pathname=A.join("/"):(r.pathname=null,r.path=null),o.isNull(r.pathname)&&o.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},i.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){function r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){var r=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:this);!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,o="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),i="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function h(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function c(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function l(t){this.map={},t instanceof l?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function p(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function d(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function y(t){var e=new FileReader,r=d(e);return e.readAsArrayBuffer(t),r}function v(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function g(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:o&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:i&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&o&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=v(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var t=p(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?p(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var t,e,r,n=p(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=d(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(w)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(t,e){t=h(t),e=c(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},l.prototype.delete=function(t){delete this.map[h(t)]},l.prototype.get=function(t){return t=h(t),this.has(t)?this.map[t]:null},l.prototype.has=function(t){return this.map.hasOwnProperty(h(t))},l.prototype.set=function(t,e){this.map[h(t)]=c(e)},l.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},l.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),f(t)},l.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),f(t)},l.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),f(t)},n&&(l.prototype[Symbol.iterator]=l.prototype.entries);var m=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(t,e){var r,n,o=(e=e||{}).body;if(t instanceof b){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new l(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,o||null==t._bodyInit||(o=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new l(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),m.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function w(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}})),e}function _(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new l(e.headers),this.url=e.url||"",this._initBody(t)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},g.call(b.prototype),g.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},_.error=function(){var t=new _(null,{status:0,statusText:""});return t.type="error",t};var x=[301,302,303,307,308];_.redirect=function(t,e){if(-1===x.indexOf(e))throw new RangeError("Invalid status code");return new _(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function A(t,r){return new Promise((function(n,i){var s=new b(t,r);if(s.signal&&s.signal.aborted)return i(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new l,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}})),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var o="response"in a?a.response:a.responseText;n(new _(o,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&o&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",u)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}A.polyfill=!0,t.fetch||(t.fetch=A,t.Headers=l,t.Request=b,t.Response=_),e.Headers=l,e.Request=b,e.Response=_,e.fetch=A}({})}(r),delete r.fetch.polyfill,(e=r.fetch).default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,t.exports=e},function(t,e){function r(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(t.exports=r=function(t){return typeof t},t.exports.default=t.exports,t.exports.__esModule=!0):(t.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.default=t.exports,t.exports.__esModule=!0),r(e)}t.exports=r,t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,r){t.exports=r(22)},function(t,e,r){var n=function(t){"use strict";var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function a(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{a({},"")}catch(t){a=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),s=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return R()}for(r.method=o,r.arg=i;;){var s=r.delegate;if(s){var a=w(s,r);if(a){if(a===c)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=h(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,s),i}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var c={};function f(){}function l(){}function p(){}var d={};d[o]=function(){return this};var y=Object.getPrototypeOf,v=y&&y(y(E([])));v&&v!==e&&r.call(v,o)&&(d=v);var g=p.prototype=f.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){a(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var n;this._invoke=function(o,i){function s(){return new e((function(n,s){!function n(o,i,s,a){var u=h(t[o],t,i);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,s,a)}),(function(t){n("throw",t,s,a)})):e.resolve(f).then((function(t){c.value=t,s(c)}),(function(t){return n("throw",t,s,a)}))}a(u.arg)}(o,i,n,s)}))}return n=n?n.then(s,s):s()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return c;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var n=h(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,c;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,c):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,c)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:R}}function R(){return{value:void 0,done:!0}}return l.prototype=g.constructor=p,p.constructor=l,l.displayName=a(p,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,a(t,s,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(b.prototype),b.prototype[i]=function(){return this},t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var s=new b(u(e,r,n,o),i);return t.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},m(g),a(g,s,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return s.type="throw",s.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(a&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,c):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),c},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),c}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e,r){"use strict";(function(t){
2
- /*!
3
- * The buffer module from node.js, for the browser.
4
- *
5
- * @author Feross Aboukhadijeh <http://feross.org>
6
- * @license MIT
7
- */
8
- var n=r(13),o=r(14),i=r(15);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return h(this,t,e,r)}function h(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=l(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(e,r),o=(t=a(t,n)).write(e,r);o!==n&&(t=t.slice(0,o));return t}(t,e,r):function(t,e){if(u.isBuffer(e)){var r=0|p(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):l(t,e);if("Buffer"===e.type&&i(e.data))return l(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,e){if(c(e),t=a(t,e<0?0:0|p(e)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function l(t,e){var r=e.length<0?0:0|p(e.length);t=a(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function p(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function d(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(t).length;default:if(n)return N(t).length;e=(""+e).toLowerCase(),n=!0}}function y(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return U(this,e,r);case"utf8":case"utf-8":return O(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return R(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,o);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var c=-1;for(i=r;i<a;i++)if(h(t,i)===h(e,-1===c?0:i-c)){if(-1===c&&(c=i),i-c+1===u)return c*s}else-1!==c&&(i-=i-c),c=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var f=!0,l=0;l<u;l++)if(h(t,i+l)!==h(e,l)){f=!1;break}if(f)return i}return-1}function b(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function w(t,e,r,n){return F(N(e,t.length-r),t,r,n)}function _(t,e,r,n){return F(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function x(t,e,r,n){return _(t,e,r,n)}function A(t,e,r,n){return F(q(e),t,r,n)}function E(t,e,r,n){return F(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function R(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function O(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,a,u,h=t[o],c=null,f=h>239?4:h>223?3:h>191?2:1;if(o+f<=r)switch(f){case 1:h<128&&(c=h);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&h)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&h)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(c=u)}null===c?(c=65533,f=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=f}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,r){return h(null,t,e,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,r){return function(t,e,r,n){return c(e),e<=0?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}(null,t,e,r)},u.allocUnsafe=function(t){return f(null,t)},u.allocUnsafeSlow=function(t){return f(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!i(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=u.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},u.byteLength=d,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)v(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)v(this,e,e+3),v(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)v(this,e,e+7),v(this,e+1,e+6),v(this,e+2,e+5),v(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?O(this,0,t):y.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,r,n,o){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),h=this.slice(n,o),c=t.slice(e,r),f=0;f<a;++f)if(h[f]!==c[f]){i=h[f],s=c[f];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return g(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return g(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return w(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return x(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function P(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function U(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=Y(t[i]);return o}function k(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function S(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function L(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function j(t,e,r,n){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);o<i;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function B(t,e,r,n){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);o<i;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function I(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(t,e,r,n,i){return i||I(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,i){return i||I(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=u.prototype;else{var o=e-t;r=new u(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+t]}return r},u.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||S(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},u.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||S(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUInt8=function(t,e){return e||S(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||S(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||S(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||S(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||S(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||S(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){e||S(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||S(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||S(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||S(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||S(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||L(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||L(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):j(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):j(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):B(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);L(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);L(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):j(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):j(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):B(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o,i=n-r;if(this===t&&r<e&&e<n)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var s=u.isBuffer(t)?t:N(new u(t,n).toString()),a=s.length;for(i=0;i<r-e;++i)this[i+e]=s[i%a]}return this};var D=/[^+\/0-9A-Za-z-_]/g;function Y(t){return t<16?"0"+t.toString(16):t.toString(16)}function N(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function q(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(D,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}}).call(this,r(4))},function(t,e,r){"use strict";e.byteLength=function(t){var e=h(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,n=h(t),s=n[0],a=n[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),c=0,f=a>0?s-4:s;for(r=0;r<f;r+=4)e=o[t.charCodeAt(r)]<<18|o[t.charCodeAt(r+1)]<<12|o[t.charCodeAt(r+2)]<<6|o[t.charCodeAt(r+3)],u[c++]=e>>16&255,u[c++]=e>>8&255,u[c++]=255&e;2===a&&(e=o[t.charCodeAt(r)]<<2|o[t.charCodeAt(r+1)]>>4,u[c++]=255&e);1===a&&(e=o[t.charCodeAt(r)]<<10|o[t.charCodeAt(r+1)]<<4|o[t.charCodeAt(r+2)]>>2,u[c++]=e>>8&255,u[c++]=255&e);return u},e.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],s=0,a=r-o;s<a;s+=16383)i.push(c(t,s,s+16383>a?a:s+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function h(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,s=[],a=e;a<r;a+=3)o=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,e){
9
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
10
- e.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,h=u>>1,c=-7,f=r?o-1:0,l=r?-1:1,p=t[e+f];for(f+=l,i=p&(1<<-c)-1,p>>=-c,c+=a;c>0;i=256*i+t[e+f],f+=l,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=n;c>0;s=256*s+t[e+f],f+=l,c-=8);if(0===i)i=1-h;else{if(i===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=h}return(p?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,a,u,h=8*i-o-1,c=(1<<h)-1,f=c>>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+f>=1?l/u:l*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=c?(a=0,s=c):s+f>=1?(a=(e*u-1)*Math.pow(2,o),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;t[r+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,h+=o;h>0;t[r+p]=255&s,p+=d,s/=256,h-=8);t[r+p-d]|=128*y}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){(function(t,n){var o;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(i){e&&e.nodeType,t&&t.nodeType;var s="object"==typeof n&&n;s.global!==s&&s.window!==s&&s.self;var a,u=2147483647,h=/^xn--/,c=/[^\x20-\x7E]/,f=/[\x2E\u3002\uFF0E\uFF61]/g,l={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=Math.floor,d=String.fromCharCode;function y(t){throw new RangeError(l[t])}function v(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function g(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+v((t=t.replace(f,".")).split("."),e).join(".")}function m(t){for(var e,r,n=[],o=0,i=t.length;o<i;)(e=t.charCodeAt(o++))>=55296&&e<=56319&&o<i?56320==(64512&(r=t.charCodeAt(o++)))?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),o--):n.push(e);return n}function b(t){return v(t,(function(t){var e="";return t>65535&&(e+=d((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=d(t)})).join("")}function w(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function _(t,e,r){var n=0;for(t=r?p(t/700):t>>1,t+=p(t/e);t>455;n+=36)t=p(t/35);return p(n+36*t/(t+38))}function x(t){var e,r,n,o,i,s,a,h,c,f,l,d=[],v=t.length,g=0,m=128,w=72;for((r=t.lastIndexOf("-"))<0&&(r=0),n=0;n<r;++n)t.charCodeAt(n)>=128&&y("not-basic"),d.push(t.charCodeAt(n));for(o=r>0?r+1:0;o<v;){for(i=g,s=1,a=36;o>=v&&y("invalid-input"),((h=(l=t.charCodeAt(o++))-48<10?l-22:l-65<26?l-65:l-97<26?l-97:36)>=36||h>p((u-g)/s))&&y("overflow"),g+=h*s,!(h<(c=a<=w?1:a>=w+26?26:a-w));a+=36)s>p(u/(f=36-c))&&y("overflow"),s*=f;w=_(g-i,e=d.length+1,0==i),p(g/e)>u-m&&y("overflow"),m+=p(g/e),g%=e,d.splice(g++,0,m)}return b(d)}function A(t){var e,r,n,o,i,s,a,h,c,f,l,v,g,b,x,A=[];for(v=(t=m(t)).length,e=128,r=0,i=72,s=0;s<v;++s)(l=t[s])<128&&A.push(d(l));for(n=o=A.length,o&&A.push("-");n<v;){for(a=u,s=0;s<v;++s)(l=t[s])>=e&&l<a&&(a=l);for(a-e>p((u-r)/(g=n+1))&&y("overflow"),r+=(a-e)*g,e=a,s=0;s<v;++s)if((l=t[s])<e&&++r>u&&y("overflow"),l==e){for(h=r,c=36;!(h<(f=c<=i?1:c>=i+26?26:c-i));c+=36)x=h-f,b=36-f,A.push(d(w(f+x%b,0))),h=p(x/b);A.push(d(w(h,0))),i=_(r,g,n==o),r=0,++n}++r,++e}return A.join("")}a={version:"1.4.1",ucs2:{decode:m,encode:b},decode:x,encode:A,toASCII:function(t){return g(t,(function(t){return c.test(t)?"xn--"+A(t):t}))},toUnicode:function(t){return g(t,(function(t){return h.test(t)?x(t.slice(4).toLowerCase()):t}))}},void 0===(o=function(){return a}.call(e,r,e,t))||(t.exports=o)}()}).call(this,r(17)(t),r(4))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,r){"use strict";t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},function(t,e,r){"use strict";e.decode=e.parse=r(20),e.encode=e.stringify=r(21)},function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,r,i){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;i&&"number"==typeof i.maxKeys&&(u=i.maxKeys);var h=t.length;u>0&&h>u&&(h=u);for(var c=0;c<h;++c){var f,l,p,d,y=t[c].replace(a,"%20"),v=y.indexOf(r);v>=0?(f=y.substr(0,v),l=y.substr(v+1)):(f=y,l=""),p=decodeURIComponent(f),d=decodeURIComponent(l),n(s,p)?o(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s};var o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?i(s(t),(function(s){var a=encodeURIComponent(n(s))+r;return o(t[s])?i(t[s],(function(t){return a+encodeURIComponent(n(t))})).join(e):a+encodeURIComponent(n(t[s]))})).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function i(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n<t.length;n++)r.push(e(t[n],n));return r}var s=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return e}},function(t,e,r){"use strict";r.r(e),r.d(e,"Client",(function(){return g})),r.d(e,"sign",(function(){return w})),r.d(e,"sendOperation",(function(){return x})),r.d(e,"sendOperations",(function(){return A})),r.d(e,"sendTransaction",(function(){return E})),r.d(e,"Initialize",(function(){return R}));var n=r(3),o=r.n(n),i=r(6),s=r.n(i),a=r(7),u=r.n(a),h=r(0),c=r.n(h),f=r(1),l=r.n(f),p=r(8),d="https://hivesigner.com";function y(){return"undefined"!=typeof window&&!!window}var v=r.n(p).a.bind("undefined"!=typeof globalThis?globalThis:void 0),g=function(){function t(e){s()(this,t),c()(this,"apiURL",void 0),c()(this,"app",void 0),c()(this,"callbackURL",void 0),c()(this,"scope",void 0),c()(this,"responseType",void 0),c()(this,"accessToken",void 0),this.apiURL=e.apiURL||"https://hivesigner.com",this.app=e.app,this.callbackURL=e.callbackURL,this.accessToken=e.accessToken,this.scope=e.scope,this.responseType=e.responseType}var e,r,n;return u()(t,[{key:"setBaseURL",value:function(){return console.warn('The function "setBaseUrl" is deprecated, the base URL is always "https://hivesigner.com", you can only change the API URL with "setApiURL"'),this}},{key:"setApiURL",value:function(t){return this.apiURL=t,this}},{key:"setApp",value:function(t){return this.app=t,this}},{key:"setCallbackURL",value:function(t){return this.callbackURL=t,this}},{key:"setAccessToken",value:function(t){return this.accessToken=t,this}},{key:"removeAccessToken",value:function(){return delete this.accessToken,this}},{key:"setScope",value:function(t){return this.scope=t,this}},{key:"getLoginURL",value:function(t,e){var r=encodeURIComponent(this.callbackURL),n="".concat("https://hivesigner.com","/oauth2/authorize?client_id=").concat(this.app,"&redirect_uri=").concat(r);return"code"===this.responseType&&(n+="&response_type=".concat(this.responseType)),this.scope&&(n+="&scope=".concat(this.scope.join(","))),t&&(n+="&state=".concat(encodeURIComponent(t))),e&&(n+="&account=".concat(encodeURIComponent(e))),n}},{key:"login",value:function(t){y()&&(window.location=this.getLoginURL(t.state))}},{key:"me",value:function(t){return this.send("me","POST",{},t)}},{key:"decode",value:function(t,e){return this.send("decode","POST",{memo:t},e)}},{key:"vote",value:function(t,e,r,n,o){var i={voter:t,author:e,permlink:r,weight:n};return this.broadcast([["vote",i]],o)}},{key:"comment",value:function(t,e,r,n,o,i,s,a){var u=s;"string"!=typeof s&&(u=JSON.stringify(s));var h={parent_author:t,parent_permlink:e,author:r,permlink:n,title:o,body:i,json_metadata:u};return this.broadcast([["comment",h]],a)}},{key:"deleteComment",value:function(t,e,r){var n={author:t,permlink:e};return this.broadcast([["delete_comment",n]],r)}},{key:"customJson",value:function(t,e,r,n,o){var i={required_auths:t,required_posting_auths:e,id:r,json:n};return this.broadcast([["custom_json",i]],o)}},{key:"reblog",value:function(t,e,r,n){var o=["reblog",{account:t,author:e,permlink:r}];return this.customJson([],[t],"follow",JSON.stringify(o),n)}},{key:"follow",value:function(t,e,r){var n=["follow",{follower:t,following:e,what:["blog"]}];return this.customJson([],[t],"follow",JSON.stringify(n),r)}},{key:"unfollow",value:function(t,e,r){var n=["follow",{follower:t,following:e,what:[]}];return this.customJson([],[t],"follow",JSON.stringify(n),r)}},{key:"ignore",value:function(t,e,r){var n=["follow",{follower:t,following:e,what:["ignore"]}];return this.customJson([],[t],"follow",JSON.stringify(n),r)}},{key:"claimRewardBalance",value:function(t,e,r,n,o){var i={account:t,reward_hive:e,reward_hbd:r,reward_vests:n};return this.broadcast([["claim_reward_balance",i]],o)}},{key:"revokeToken",value:(n=o()(l.a.mark((function t(e){return l.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.send("oauth2/token/revoke","POST",{token:this.accessToken},e);case 2:return t.abrupt("return",this.removeAccessToken());case 3:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"updateUserMetadata",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;return console.warn('The function "updateUserMetadata" is deprecated.'),this.send("me","PUT",{user_metadata:t},e)}},{key:"send",value:(r=o()(l.a.mark((function t(e,r,n,o){var i,s;return l.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i="".concat(this.apiURL,"/api/").concat(e),o){t.next=3;break}return t.abrupt("return",this.makeRequest(i,r,n));case 3:return t.prev=3,t.next=6,this.makeRequest(i,r,n);case 6:return s=t.sent,t.abrupt("return",o(null,s));case 10:return t.prev=10,t.t0=t.catch(3),t.abrupt("return",o(t.t0,null));case 13:case"end":return t.stop()}}),t,this,[[3,10]])}))),function(t,e,n,o){return r.apply(this,arguments)})},{key:"broadcast",value:function(t,e){return this.send("broadcast","POST",{operations:t},e)}},{key:"makeRequest",value:(e=o()(l.a.mark((function t(e,r,n){var o,i;return l.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,v(e,{method:r,headers:{Accept:"application/json, text/plain, */*","Content-Type":"application/json",Authorization:this.accessToken},body:JSON.stringify(n)});case 2:return o=t.sent,t.next=5,o.json();case 5:if(i=t.sent,200===o.status&&!i.error){t.next=8;break}throw i;case 8:return t.abrupt("return",i);case 9:case"end":return t.stop()}}),t,this)}))),function(t,r,n){return e.apply(this,arguments)})}]),t}(),m=r(9),b=r.n(m);function w(t,e,r){if(console.warn('The function "sign" is deprecated.'),"string"!=typeof t||"object"!==b()(e)||null===e)return{error:"invalid_request",error_description:"Request has an invalid format"};var n="".concat("https://hivesigner.com","/sign/").concat(t,"?");return n+=Object.keys(e).map((function(t){return"".concat(t,"=").concat(encodeURIComponent(e[t]))})).join("&"),n+=r?"&redirect_uri=".concat(encodeURIComponent(r)):""}var _=r(2);function x(t,e,r){var n=Object(_.encodeOp)(t,e).replace("hive://","".concat(d,"/"));return r&&y()?window.open(n,"_blank").focus():n}function A(t,e,r){var n=Object(_.encodeOps)(t,e).replace("hive://","".concat(d,"/"));return r&&y()?window.open(n,"_blank").focus():n}function E(t,e,r){var n=Object(_.encodeTx)(t,e).replace("hive://","".concat(d,"/"));return r&&y()?window.open(n,"_blank").focus():n}function R(t){return console.warn('The function "Initialize" is deprecated, please use the class "Client" instead.'),new g(t)}e.default={Client:g,Initialize:R,sendTransaction:E,sendOperations:A,sendOperation:x,sign:w}}]);
1
+ var hivesigner;(()=>{"use strict";var e={536(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.encodeMsg=t.encodeOps=t.encodeOp=t.encodeTx=t.resolveCallback=t.resolveTransaction=t.decode=void 0;var n=o(160);"undefined"==typeof btoa&&(o.g.btoa=function(e){return Buffer.from(e,"binary").toString("base64")}),"undefined"==typeof atob&&(o.g.atob=function(e){return Buffer.from(e,"base64").toString("binary")});var r={"/":"_",_:"/","+":"-","-":"+","=":".",".":"="},s=function(e){return btoa(unescape(encodeURIComponent(e))).replace(/(\+|\/|=)/g,function(e){return r[e]})},i=function(e){return decodeURIComponent(escape(atob(e.replace(/(-|_|\.)/g,function(e){return r[e]}))))};t.decode=function(e){var t=e.slice(0,5),o=new n(e.replace(/^hive:/,"http:"));if("hive:"!==t)throw new Error("Invalid protocol, expected 'hive:' got '"+t+"'");if("sign"!==o.host)throw new Error("Invalid action, expected 'sign' got '"+o.host+"'");var r,s,a=o.pathname.split("/").slice(1),c=a[0],l=a[1];try{r=JSON.parse(i(l))}catch(e){throw e.message="Invalid payload: "+e.message,e}switch(c){case"tx":case"msg":s=r;break;case"op":case"ops":s={ref_block_num:"__ref_block_num",ref_block_prefix:"__ref_block_prefix",expiration:"__expiration",extensions:[],operations:"ops"===c?r:[r]};break;default:throw new Error("Invalid signing action '"+c+"'")}var u=Object.fromEntries(o.query.substring(1).split("&").filter(Boolean).map(function(e){var t=e.split("="),o=t[0],n=t[1],r=void 0===n?"":n;return[decodeURIComponent(o),decodeURIComponent(r)]})),p={};return u.cb&&(p.callback=i(u.cb)),void 0!==u.nb&&(p.no_broadcast=!0),u.a&&(p.authority=u.a),u.s&&(p.signer=u.s),{tx:s,params:p}};var a=/(__(ref_block_(num|prefix)|expiration|signer))/g;t.resolveTransaction=function(e,t,o){var n=t.signer||o.preferred_signer;if(!o.signers.includes(n))throw new Error("Signer '"+n+"' not available");var r={__ref_block_num:o.ref_block_num,__ref_block_prefix:o.ref_block_prefix,__expiration:o.expiration,__signer:n},s=function(e){var t=typeof e;switch("object"===t&&Array.isArray(e)?t="array":null===e&&(t="null"),t){case"string":return e.replace(a,function(e){return r[e]});case"array":return e.map(s);case"object":for(var o={},n=0,i=Object.entries(e);n<i.length;n++){var c=i[n],l=c[0],u=c[1];o[l]=s(u)}return o;default:return e}};return{signer:n,tx:s(e)}};var c=/({{(sig|id|block|txn|data)}})/g;function l(e){var t=[];return e.no_broadcast&&t.push("nb="),e.signer&&t.push("s="+e.signer),e.callback&&t.push("cb="+s(e.callback)),e.authority&&t.push("a="+e.authority),t.length?"?"+t.join("&"):""}function u(e){return s(JSON.stringify(e,null,0))}t.resolveCallback=function(e,t){return e.replace(c,function(e,o,n){return t[n]||""})},t.encodeTx=function(e,t){return void 0===t&&(t={}),"hive://sign/tx/"+u(e)+l(t)},t.encodeOp=function(e,t){return void 0===t&&(t={}),"hive://sign/op/"+u(e)+l(t)},t.encodeOps=function(e,t){return void 0===t&&(t={}),"hive://sign/ops/"+u(e)+l(t)},t.encodeMsg=function(e,t){return void 0===t&&(t={}),"hive://sign/msg/"+u(e)+l(t)}},992(e,t){var o=Object.prototype.hasOwnProperty;function n(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function r(e){try{return encodeURIComponent(e)}catch(e){return null}}t.stringify=function(e,t){t=t||"";var n,s,i=[];for(s in"string"!=typeof t&&(t="?"),e)if(o.call(e,s)){if((n=e[s])||null!=n&&!isNaN(n)||(n=""),s=r(s),n=r(n),null===s||null===n)continue;i.push(s+"="+n)}return i.length?t+i.join("&"):""},t.parse=function(e){for(var t,o=/([^=?#&]+)=?([^&]*)/g,r={};t=o.exec(e);){var s=n(t[1]),i=n(t[2]);null===s||null===i||s in r||(r[s]=i)}return r}},63(e){e.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},469(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.Client=void 0;const n=o(629),r=o(779);t.Client=class{constructor(e){this.apiURL=e.apiURL||n.API_URL,this.app=e.app,this.callbackURL=e.callbackURL,this.accessToken=e.accessToken,this.scope=e.scope,this.responseType=e.responseType}setBaseURL(){return console.warn('The function "setBaseUrl" is deprecated, the base URL is always "https://hivesigner.com", you can only change the API URL with "setApiURL"'),this}setApiURL(e){return this.apiURL=e,this}setApp(e){return this.app=e,this}setCallbackURL(e){return this.callbackURL=e,this}setAccessToken(e){return this.accessToken=e,this}removeAccessToken(){return delete this.accessToken,this}setScope(e){return this.scope=e,this}getLoginURL(e,t,o={}){const r=encodeURIComponent(this.callbackURL);let s=`${n.BASE_URL}/oauth2/authorize?client_id=${this.app}&redirect_uri=${r}`;return"code"===this.responseType&&(s+=`&response_type=${this.responseType}`),this.scope&&(s+=`&scope=${this.scope.join(",")}`),e&&(s+=`&state=${encodeURIComponent(e)}`),t&&(s+=`&account=${encodeURIComponent(t)}`),o.codeChallenge&&"code"===this.responseType&&(s+=`&code_challenge=${encodeURIComponent(o.codeChallenge)}&code_challenge_method=S256`),s}login(e){(0,r.isBrowser)()&&(window.location=this.getLoginURL(e.state,void 0,{codeChallenge:e.codeChallenge}))}async exchangeCode(e,t,o){const n={code:e};return t&&(n.code_verifier=t),o&&(n.client_secret=o),await this.makeRequest(`${this.apiURL}/api/oauth2/token`,"POST",n,!1)}me(e){return this.send("me","POST",{},e)}decode(e,t){return this.send("decode","POST",{memo:e},t)}vote(e,t,o,n,r){const s={voter:e,author:t,permlink:o,weight:n};return this.broadcast([["vote",s]],r)}comment(e,t,o,n,r,s,i,a){let c=i;"string"!=typeof i&&(c=JSON.stringify(i));const l={parent_author:e,parent_permlink:t,author:o,permlink:n,title:r,body:s,json_metadata:c};return this.broadcast([["comment",l]],a)}deleteComment(e,t,o){const n={author:e,permlink:t};return this.broadcast([["delete_comment",n]],o)}customJson(e,t,o,n,r){const s={required_auths:e,required_posting_auths:t,id:o,json:n};return this.broadcast([["custom_json",s]],r)}reblog(e,t,o,n){const r=["reblog",{account:e,author:t,permlink:o}];return this.customJson([],[e],"follow",JSON.stringify(r),n)}follow(e,t,o){const n=["follow",{follower:e,following:t,what:["blog"]}];return this.customJson([],[e],"follow",JSON.stringify(n),o)}unfollow(e,t,o){const n=["follow",{follower:e,following:t,what:[]}];return this.customJson([],[e],"follow",JSON.stringify(n),o)}ignore(e,t,o){const n=["follow",{follower:e,following:t,what:["ignore"]}];return this.customJson([],[e],"follow",JSON.stringify(n),o)}claimRewardBalance(e,t,o,n,r){const s={account:e,reward_hive:t,reward_hbd:o,reward_vests:n};return this.broadcast([["claim_reward_balance",s]],r)}async revokeToken(e){return await this.send("oauth2/token/revoke","POST",{token:this.accessToken},e),this.removeAccessToken()}updateUserMetadata(e={},t){return console.warn('The function "updateUserMetadata" is deprecated.'),this.send("me","PUT",{user_metadata:e},t)}async send(e,t,o,n){const r=`${this.apiURL}/api/${e}`;if(!n)return this.makeRequest(r,t,o);try{return n(null,await this.makeRequest(r,t,o))}catch(e){return n(e,null)}}broadcast(e,t){return this.send("broadcast","POST",{operations:e},t)}async makeRequest(e,t,o,n=!0){if("function"!=typeof globalThis.fetch)throw new Error("hivesigner: fetch is not available. Node.js 18+ or a modern browser is required. If you are in an older environment, provide a global fetch polyfill.");const r=await globalThis.fetch(e,{method:t,headers:Object.assign({Accept:"application/json, text/plain, */*","Content-Type":"application/json"},n?{Authorization:this.accessToken}:{}),body:JSON.stringify(o)}),s=await r.json();if(200!==r.status||s.error)throw s;return s}}},944(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.API_URL=void 0,t.API_URL="https://hivesigner.com"},69(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BASE_URL=void 0,t.BASE_URL="https://hivesigner.com"},290(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BETA_URL=void 0,t.BETA_URL="https://hivesigner.com"},629(e,t,o){var n=this&&this.__createBinding||(Object.create?function(e,t,o,n){void 0===n&&(n=o);var r=Object.getOwnPropertyDescriptor(t,o);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,n,r)}:function(e,t,o,n){void 0===n&&(n=o),e[n]=t[o]}),r=this&&this.__exportStar||function(e,t){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(t,o)||n(t,e,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(o(944),t),r(o(69),t),r(o(290),t)},261(e,t,o){var n=this&&this.__createBinding||(Object.create?function(e,t,o,n){void 0===n&&(n=o);var r=Object.getOwnPropertyDescriptor(t,o);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,n,r)}:function(e,t,o,n){void 0===n&&(n=o),e[n]=t[o]}),r=this&&this.__exportStar||function(e,t){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(t,o)||n(t,e,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(o(7),t)},7(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.Initialize=void 0;const n=o(469);t.Initialize=function(e){return console.warn('The function "Initialize" is deprecated, please use the class "Client" instead.'),new n.Client(e)}},440(e,t,o){var n=this&&this.__createBinding||(Object.create?function(e,t,o,n){void 0===n&&(n=o);var r=Object.getOwnPropertyDescriptor(t,o);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,n,r)}:function(e,t,o,n){void 0===n&&(n=o),e[n]=t[o]}),r=this&&this.__exportStar||function(e,t){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(t,o)||n(t,e,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(o(469),t),r(o(49),t),r(o(261),t),r(o(295),t);const s=o(469),i=o(261),a=o(49),c=o(295);t.default={Client:s.Client,Initialize:i.Initialize,sendTransaction:a.sendTransaction,sendOperations:a.sendOperations,sendOperation:a.sendOperation,sign:a.sign,createPkcePair:c.createPkcePair,pkceChallengeFor:c.pkceChallengeFor}},49(e,t,o){var n=this&&this.__createBinding||(Object.create?function(e,t,o,n){void 0===n&&(n=o);var r=Object.getOwnPropertyDescriptor(t,o);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,n,r)}:function(e,t,o,n){void 0===n&&(n=o),e[n]=t[o]}),r=this&&this.__exportStar||function(e,t){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(t,o)||n(t,e,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(o(893),t),r(o(640),t),r(o(243),t),r(o(887),t)},640(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.sendOperation=void 0;const n=o(629),r=o(536),s=o(779);t.sendOperation=function(e,t,o){const i=(0,r.encodeOp)(e,t).replace("hive://",`${n.BETA_URL}/`);return o&&(0,s.isBrowser)()?window.open(i,"_blank").focus():i}},243(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.sendOperations=void 0;const n=o(536),r=o(779),s=o(629);t.sendOperations=function(e,t,o){const i=(0,n.encodeOps)(e,t).replace("hive://",`${s.BETA_URL}/`);return o&&(0,r.isBrowser)()?window.open(i,"_blank").focus():i}},887(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.sendTransaction=void 0;const n=o(536),r=o(629),s=o(779);t.sendTransaction=function(e,t,o){const i=(0,n.encodeTx)(e,t).replace("hive://",`${r.BETA_URL}/`);return o&&(0,s.isBrowser)()?window.open(i,"_blank").focus():i}},893(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.sign=void 0;const n=o(629);t.sign=function(e,t,o){if(console.warn('The function "sign" is deprecated.'),"string"!=typeof e||"object"!=typeof t||null===t)return{error:"invalid_request",error_description:"Request has an invalid format"};let r=`${n.BASE_URL}/sign/${e}?`;return r+=Object.keys(t).map(e=>`${e}=${encodeURIComponent(t[e])}`).join("&"),r+=o?`&redirect_uri=${encodeURIComponent(o)}`:"",r}},295(e,t){function o(){const e=globalThis.crypto;if(!e||!e.subtle||"function"!=typeof e.getRandomValues)throw new Error("hivesigner: Web Crypto is not available. Node.js 20+ or a modern browser is required for PKCE.");return e}function n(e){let t="";return e.forEach(e=>{t+=String.fromCharCode(e)}),("function"==typeof btoa?btoa(t):Buffer.from(t,"binary").toString("base64")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function r(e){const t=await o().subtle.digest("SHA-256",(new TextEncoder).encode(e));return n(new Uint8Array(t))}Object.defineProperty(t,"__esModule",{value:!0}),t.createPkcePair=t.pkceChallengeFor=void 0,t.pkceChallengeFor=r,t.createPkcePair=async function(){const e=n(o().getRandomValues(new Uint8Array(32)));return{codeVerifier:e,codeChallenge:await r(e)}}},779(e,t,o){var n=this&&this.__createBinding||(Object.create?function(e,t,o,n){void 0===n&&(n=o);var r=Object.getOwnPropertyDescriptor(t,o);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,n,r)}:function(e,t,o,n){void 0===n&&(n=o),e[n]=t[o]}),r=this&&this.__exportStar||function(e,t){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(t,o)||n(t,e,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(o(790),t)},790(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowser=void 0,t.isBrowser=function(){return"undefined"!=typeof window&&!!window}},160(e,t,o){var n=o(63),r=o(992),s=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,i=/[\n\r\t]/g,a=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,c=/:\d+$/,l=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,u=/^[a-zA-Z]:/;function p(e){return(e||"").toString().replace(s,"")}var d=[["#","hash"],["?","query"],function(e,t){return g(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],h={hash:1,query:1};function f(e){var t,n=("undefined"!=typeof window?window:void 0!==o.g?o.g:"undefined"!=typeof self?self:{}).location||{},r={},s=typeof(e=e||n);if("blob:"===e.protocol)r=new v(unescape(e.pathname),{});else if("string"===s)for(t in r=new v(e,{}),h)delete r[t];else if("object"===s){for(t in e)t in h||(r[t]=e[t]);void 0===r.slashes&&(r.slashes=a.test(e.href))}return r}function g(e){return"file:"===e||"ftp:"===e||"http:"===e||"https:"===e||"ws:"===e||"wss:"===e}function b(e,t){e=(e=p(e)).replace(i,""),t=t||{};var o,n=l.exec(e),r=n[1]?n[1].toLowerCase():"",s=!!n[2],a=!!n[3],c=0;return s?a?(o=n[2]+n[3]+n[4],c=n[2].length+n[3].length):(o=n[2]+n[4],c=n[2].length):a?(o=n[3]+n[4],c=n[3].length):o=n[4],"file:"===r?c>=2&&(o=o.slice(2)):g(r)?o=n[4]:r?s&&(o=o.slice(2)):c>=2&&g(t.protocol)&&(o=n[4]),{protocol:r,slashes:s||g(r),slashesCount:c,rest:o}}function v(e,t,o){if(e=(e=p(e)).replace(i,""),!(this instanceof v))return new v(e,t,o);var s,a,c,l,h,_,m=d.slice(),w=typeof t,y=this,O=0;for("object"!==w&&"string"!==w&&(o=t,t=null),o&&"function"!=typeof o&&(o=r.parse),s=!(a=b(e||"",t=f(t))).protocol&&!a.slashes,y.slashes=a.slashes||s&&t.slashes,y.protocol=a.protocol||t.protocol||"",e=a.rest,("file:"===a.protocol&&(2!==a.slashesCount||u.test(e))||!a.slashes&&(a.protocol||a.slashesCount<2||!g(y.protocol)))&&(m[3]=[/(.*)/,"pathname"]);O<m.length;O++)"function"!=typeof(l=m[O])?(c=l[0],_=l[1],c!=c?y[_]=e:"string"==typeof c?~(h="@"===c?e.lastIndexOf(c):e.indexOf(c))&&("number"==typeof l[2]?(y[_]=e.slice(0,h),e=e.slice(h+l[2])):(y[_]=e.slice(h),e=e.slice(0,h))):(h=c.exec(e))&&(y[_]=h[1],e=e.slice(0,h.index)),y[_]=y[_]||s&&l[3]&&t[_]||"",l[4]&&(y[_]=y[_].toLowerCase())):e=l(e,y);o&&(y.query=o(y.query)),s&&t.slashes&&"/"!==y.pathname.charAt(0)&&(""!==y.pathname||""!==t.pathname)&&(y.pathname=function(e,t){if(""===e)return t;for(var o=(t||"/").split("/").slice(0,-1).concat(e.split("/")),n=o.length,r=o[n-1],s=!1,i=0;n--;)"."===o[n]?o.splice(n,1):".."===o[n]?(o.splice(n,1),i++):i&&(0===n&&(s=!0),o.splice(n,1),i--);return s&&o.unshift(""),"."!==r&&".."!==r||o.push(""),o.join("/")}(y.pathname,t.pathname)),"/"!==y.pathname.charAt(0)&&g(y.protocol)&&(y.pathname="/"+y.pathname),n(y.port,y.protocol)||(y.host=y.hostname,y.port=""),y.username=y.password="",y.auth&&(~(h=y.auth.indexOf(":"))?(y.username=y.auth.slice(0,h),y.username=encodeURIComponent(decodeURIComponent(y.username)),y.password=y.auth.slice(h+1),y.password=encodeURIComponent(decodeURIComponent(y.password))):y.username=encodeURIComponent(decodeURIComponent(y.auth)),y.auth=y.password?y.username+":"+y.password:y.username),y.origin="file:"!==y.protocol&&g(y.protocol)&&y.host?y.protocol+"//"+y.host:"null",y.href=y.toString()}v.prototype={set:function(e,t,o){var s=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(o||r.parse)(t)),s[e]=t;break;case"port":s[e]=t,n(t,s.protocol)?t&&(s.host=s.hostname+":"+t):(s.host=s.hostname,s[e]="");break;case"hostname":s[e]=t,s.port&&(t+=":"+s.port),s.host=t;break;case"host":s[e]=t,c.test(t)?(t=t.split(":"),s.port=t.pop(),s.hostname=t.join(":")):(s.hostname=t,s.port="");break;case"protocol":s.protocol=t.toLowerCase(),s.slashes=!o;break;case"pathname":case"hash":if(t){var i="pathname"===e?"/":"#";s[e]=t.charAt(0)!==i?i+t:t}else s[e]=t;break;case"username":case"password":s[e]=encodeURIComponent(t);break;case"auth":var a=t.indexOf(":");~a?(s.username=t.slice(0,a),s.username=encodeURIComponent(decodeURIComponent(s.username)),s.password=t.slice(a+1),s.password=encodeURIComponent(decodeURIComponent(s.password))):s.username=encodeURIComponent(decodeURIComponent(t))}for(var l=0;l<d.length;l++){var u=d[l];u[4]&&(s[u[1]]=s[u[1]].toLowerCase())}return s.auth=s.password?s.username+":"+s.password:s.username,s.origin="file:"!==s.protocol&&g(s.protocol)&&s.host?s.protocol+"//"+s.host:"null",s.href=s.toString(),s},toString:function(e){e&&"function"==typeof e||(e=r.stringify);var t,o=this,n=o.host,s=o.protocol;s&&":"!==s.charAt(s.length-1)&&(s+=":");var i=s+(o.protocol&&o.slashes||g(o.protocol)?"//":"");return o.username?(i+=o.username,o.password&&(i+=":"+o.password),i+="@"):o.password?(i+=":"+o.password,i+="@"):"file:"!==o.protocol&&g(o.protocol)&&!n&&"/"!==o.pathname&&(i+="@"),(":"===n[n.length-1]||c.test(o.hostname)&&!o.port)&&(n+=":"),i+=n+o.pathname,(t="object"==typeof o.query?e(o.query):o.query)&&(i+="?"!==t.charAt(0)?"?"+t:t),o.hash&&(i+=o.hash),i}},v.extractProtocol=b,v.location=f,v.trimLeft=p,v.qs=r,e.exports=v}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,o),s.exports}o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var n=o(440);hivesigner=n})();
package/lib/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  export * from './client';
2
2
  export * from './methods';
3
3
  export * from './factories';
4
+ export * from './pkce';
4
5
  import { Client } from './client';
5
6
  import { Initialize } from './factories';
6
7
  import { sendTransaction, sendOperations, sendOperation, sign } from './methods';
8
+ import { createPkcePair, pkceChallengeFor } from './pkce';
7
9
  declare const _default: {
8
10
  Client: typeof Client;
9
11
  Initialize: typeof Initialize;
@@ -11,5 +13,7 @@ declare const _default: {
11
13
  sendOperations: typeof sendOperations;
12
14
  sendOperation: typeof sendOperation;
13
15
  sign: typeof sign;
16
+ createPkcePair: typeof createPkcePair;
17
+ pkceChallengeFor: typeof pkceChallengeFor;
14
18
  };
15
19
  export default _default;