@gw2me/client 0.2.1 → 0.2.2

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 (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +8 -7
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var k=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var b=(n,e)=>{for(var t in e)k(n,t,{get:e[t],enumerable:!0})},v=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of R(e))!T.call(n,s)&&s!==t&&k(n,s,{get:()=>e[s],enumerable:!(r=y(e,s))||r.enumerable});return n};var A=n=>v(k({},"__esModule",{value:!0}),n);var U=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var g=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)};var p=(n,e,t)=>(U(n,e,"access private method"),t);var w=(n,e,t)=>new Promise((r,s)=>{var a=c=>{try{h(t.next(c))}catch(o){s(o)}},d=c=>{try{h(t.throw(c))}catch(o){s(o)}},h=c=>c.done?r(c.value):Promise.resolve(c.value).then(a,d);h((t=t.apply(n,e)).next())});var W={};b(W,{Gw2MeApi:()=>_,Gw2MeClient:()=>P,Scope:()=>x});module.exports=A(W);var x=(i=>(i.Identify="identify",i.Email="email",i.GW2_Account="gw2:account",i.GW2_Inventories="gw2:inventories",i.GW2_Characters="gw2:characters",i.GW2_Tradingpost="gw2:tradingpost",i.GW2_Wallet="gw2:wallet",i.GW2_Unlocks="gw2:unlocks",i.GW2_Pvp="gw2:pvp",i.GW2_Builds="gw2:builds",i.GW2_Progression="gw2:progression",i.GW2_Guilds="gw2:guilds",i))(x||{});var l,f,_=class{constructor(e,t){this.access_token=e;this.options=t;g(this,l)}user(){return fetch(`${p(this,l,f).call(this)}api/user`,{headers:{Authorization:`Bearer ${this.access_token}`},cache:"no-store"}).then(e=>e.json())}accounts(){return fetch(`${p(this,l,f).call(this)}api/accounts`,{headers:{Authorization:`Bearer ${this.access_token}`},cache:"no-store"}).then(e=>e.json())}subtoken(e){return fetch(`${p(this,l,f).call(this)}api/accounts/${e}/subtoken`,{headers:{Authorization:`Bearer ${this.access_token}`},cache:"no-store"}).then(t=>t.json())}};l=new WeakSet,f=function(){var e;return((e=this.options)==null?void 0:e.url)||"https://gw2.me/"};var u,m,P=class{constructor({client_id:e,client_secret:t},r){this.options=r;g(this,u);this.client_id=e,this.client_secret=t}getAuthorizationUrl({redirect_uri:e,scopes:t,state:r,code_challenge:s,code_challenge_method:a,prompt:d,include_granted_scopes:h,verified_accounts_only:c}){let o=new URLSearchParams({client_id:this.client_id,response_type:"code",redirect_uri:e,scope:t.join(" ")});return r&&o.append("state",r),s&&a&&(o.append("code_challenge",s),o.append("code_challenge_method",a)),d&&o.append("prompt",d),h&&o.append("include_granted_scopes","true"),c&&o.append("verified_accounts_only","true"),`${p(this,u,m).call(this)}oauth2/authorize?${o.toString()}`}getAccessToken(s){return w(this,arguments,function*({code:e,redirect_uri:t,code_verifier:r}){let a=new URLSearchParams({grant_type:"authorization_code",code:e,client_id:this.client_id,redirect_uri:t});return this.client_secret&&a.set("client_secret",this.client_secret),r&&a.set("code_verifier",r),yield fetch(`${p(this,u,m).call(this)}api/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a,cache:"no-store"}).then(h=>h.json())})}refreshToken(t){return w(this,arguments,function*({refresh_token:e}){if(!this.client_secret)throw new Error("client_secret required");let r=new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:this.client_id,client_secret:this.client_secret});return yield fetch(`${p(this,u,m).call(this)}api/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r,cache:"no-store"}).then(a=>a.json())})}api(e){return new _(e,this.options)}};u=new WeakSet,m=function(){var e;return((e=this.options)==null?void 0:e.url)||"https://gw2.me/"};0&&(module.exports={Gw2MeApi,Gw2MeClient,Scope});
1
+ "use strict";var f=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var v=(t,e)=>{for(var r in e)f(t,r,{get:e[r],enumerable:!0})},U=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of R(e))!T.call(t,n)&&n!==r&&f(t,n,{get:()=>e[n],enumerable:!(i=P(e,n))||i.enumerable});return t};var b=t=>U(f({},"__esModule",{value:!0}),t);var A=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var u=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)};var o=(t,e,r)=>(A(t,e,"access private method"),r);var O={};v(O,{Gw2MeApi:()=>l,Gw2MeClient:()=>m,Scope:()=>k});module.exports=b(O);var k=(s=>(s.Identify="identify",s.Email="email",s.GW2_Account="gw2:account",s.GW2_Inventories="gw2:inventories",s.GW2_Characters="gw2:characters",s.GW2_Tradingpost="gw2:tradingpost",s.GW2_Wallet="gw2:wallet",s.GW2_Unlocks="gw2:unlocks",s.GW2_Pvp="gw2:pvp",s.GW2_Builds="gw2:builds",s.GW2_Progression="gw2:progression",s.GW2_Guilds="gw2:guilds",s))(k||{});async function c(t){let e=t.headers.get("Content-Type")==="application/json";if(!t.ok){let r;throw e&&(r=(await t.json()).error_message),new Error(`gw2.me returned an error: ${r??"Unknown error"}`)}if(!e)throw new Error("gw2.me did not return a valid JSON response");return t.json()}var p,d,l=class{constructor(e,r){this.access_token=e;this.options=r;u(this,p)}user(){return fetch(o(this,p,d).call(this,"api/user"),{headers:{Authorization:`Bearer ${this.access_token}`},cache:"no-store"}).then(c)}accounts(){return fetch(o(this,p,d).call(this,"api/accounts"),{headers:{Authorization:`Bearer ${this.access_token}`},cache:"no-store"}).then(c)}subtoken(e){return fetch(o(this,p,d).call(this,`api/accounts/${e}/subtoken`),{headers:{Authorization:`Bearer ${this.access_token}`},cache:"no-store"}).then(c)}};p=new WeakSet,d=function(e){return new URL(e,this.options?.url||"https://gw2.me/")};var h,g,m=class{constructor({client_id:e,client_secret:r},i){this.options=i;u(this,h);this.client_id=e,this.client_secret=r}getAuthorizationUrl({redirect_uri:e,scopes:r,state:i,code_challenge:n,code_challenge_method:_,prompt:w,include_granted_scopes:x,verified_accounts_only:y}){let a=new URLSearchParams({client_id:this.client_id,response_type:"code",redirect_uri:e,scope:r.join(" ")});return i&&a.append("state",i),n&&_&&(a.append("code_challenge",n),a.append("code_challenge_method",_)),w&&a.append("prompt",w),x&&a.append("include_granted_scopes","true"),y&&a.append("verified_accounts_only","true"),o(this,h,g).call(this,`/oauth2/authorize?${a.toString()}`).toString()}async getAccessToken({code:e,redirect_uri:r,code_verifier:i}){let n=new URLSearchParams({grant_type:"authorization_code",code:e,client_id:this.client_id,redirect_uri:r});return this.client_secret&&n.set("client_secret",this.client_secret),i&&n.set("code_verifier",i),await fetch(o(this,h,g).call(this,"/api/token"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n,cache:"no-store"}).then(c)}async refreshToken({refresh_token:e}){if(!this.client_secret)throw new Error("client_secret required");let r=new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:this.client_id,client_secret:this.client_secret});return await fetch(o(this,h,g).call(this,"/api/token"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r,cache:"no-store"}).then(c)}api(e){return new l(e,this.options)}};h=new WeakSet,g=function(e){return new URL(e,this.options?.url||"https://gw2.me/")};0&&(module.exports={Gw2MeApi,Gw2MeClient,Scope});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gw2me/client",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "gw2.me client library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "build:ci": "tsup src/index.ts --minify --dts",
11
11
  "clean": "rm -rf dist/",
12
12
  "lint": "eslint src",
13
- "publish-package": "if test `npm view . version | sed -n 2p` != $npm_package_version; then npm publish --access public; else echo not changed; fi"
13
+ "publish-package": "gw2treasures-publish-package"
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
@@ -33,12 +33,13 @@
33
33
  },
34
34
  "homepage": "https://github.com/gw2treasures/gw2.me#readme",
35
35
  "devDependencies": {
36
- "@tsconfig/recommended": "1.0.3",
37
- "@typescript-eslint/eslint-plugin": "6.14.0",
38
- "@typescript-eslint/parser": "6.14.0",
36
+ "@gw2treasures/publish-package": "0.0.1",
37
+ "@gw2treasures/tsconfig": "0.0.1",
38
+ "@typescript-eslint/eslint-plugin": "7.0.1",
39
+ "@typescript-eslint/parser": "7.0.1",
39
40
  "eslint": "8.56.0",
40
- "tsup": "8.0.1",
41
+ "tsup": "8.0.2",
41
42
  "typescript": "5.3.3",
42
- "undici-types": "6.0.1"
43
+ "undici-types": "6.6.2"
43
44
  }
44
45
  }