@gw2me/client 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/package.json +5 -6
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var b=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var C=t=>{throw TypeError(t)};var E=(t,e)=>{for(var r in e)b(t,r,{get:e[r],enumerable:!0})},I=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of j(e))!z.call(t,o)&&o!==r&&b(t,o,{get:()=>e[o],enumerable:!(n=G(e,o))||n.enumerable});return t};var L=t=>I(b({},"__esModule",{value:!0}),t);var v=(t,e,r)=>e.has(t)||C("Cannot "+r);var s=(t,e,r)=>(v(t,e,"read from private field"),r?r.call(t):e.get(t)),a=(t,e,r)=>e.has(t)?C("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),h=(t,e,r,n)=>(v(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),c=(t,e,r)=>(v(t,e,"access private method"),r);var M={};E(M,{Gw2MeApi:()=>m,Gw2MeClient:()=>A,Scope:()=>T});module.exports=L(M);var T=(i=>(i.Identify="identify",i.Email="email",i.Accounts="accounts",i.Accounts_Verified="accounts.verified",i.Accounts_DisplayName="accounts.displayName",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_Wvw="gw2:wvw",i.GW2_Builds="gw2:builds",i.GW2_Progression="gw2:progression",i.GW2_Guilds="gw2:guilds",i))(T||{});async function l(t){let e=t.headers.get("Content-Type")==="application/json";if(!t.ok){let r;throw e&&(r=(await t.json()).error_description),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 f,x,m=class{constructor(e,r){this.access_token=e;this.options=r;a(this,f)}user(){return fetch(c(this,f,x).call(this,"api/user"),{headers:{Authorization:`Bearer ${this.access_token}`},cache:"no-store"}).then(l)}accounts(){return fetch(c(this,f,x).call(this,"api/accounts"),{headers:{Authorization:`Bearer ${this.access_token}`},cache:"no-store"}).then(l)}subtoken(e){return fetch(c(this,f,x).call(this,`api/accounts/${e}/subtoken`),{headers:{Authorization:`Bearer ${this.access_token}`},cache:"no-store"}).then(l)}};f=new WeakSet,x=function(e){return new URL(e,this.options?.url||"https://gw2.me/")};var _,w,R=class{constructor(e,r){a(this,_);a(this,w);h(this,_,e),h(this,w,r)}isSupported(){return typeof window<"u"&&"IdentityCredential"in window}request({mediation:e,signal:r,mode:n}){if(!this.isSupported())throw new Error("FedCM is not supported");return navigator.credentials.get({mediation:e,signal:r,identity:{providers:[{configURL:s(this,_),clientId:s(this,w)}],mode:n}})}};_=new WeakMap,w=new WeakMap;var p,d,y,g,k,A=class{constructor({client_id:e,client_secret:r},n){this.options=n;a(this,g);a(this,p);a(this,d);a(this,y);h(this,p,e),h(this,d,r),h(this,y,new R(c(this,g,k).call(this,"/fed-cm/config.json"),s(this,p)))}getAuthorizationUrl({redirect_uri:e,scopes:r,state:n,code_challenge:o,code_challenge_method:P,prompt:U,include_granted_scopes:O,verified_accounts_only:W}){let u=new URLSearchParams({client_id:s(this,p),response_type:"code",redirect_uri:e,scope:r.join(" ")});return n&&u.append("state",n),o&&P&&(u.append("code_challenge",o),u.append("code_challenge_method",P)),U&&u.append("prompt",U),O&&u.append("include_granted_scopes","true"),W&&u.append("verified_accounts_only","true"),c(this,g,k).call(this,`/oauth2/authorize?${u.toString()}`).toString()}async getAccessToken({code:e,redirect_uri:r,code_verifier:n}){let o=new URLSearchParams({grant_type:"authorization_code",code:e,client_id:s(this,p),redirect_uri:r});return s(this,d)&&o.set("client_secret",s(this,d)),n&&o.set("code_verifier",n),await fetch(c(this,g,k).call(this,"/api/token"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o,cache:"no-store"}).then(l)}async refreshToken({refresh_token:e}){if(!s(this,d))throw new Error("client_secret required");let r=new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:s(this,p),client_secret:s(this,d)});return await fetch(c(this,g,k).call(this,"/api/token"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r,cache:"no-store"}).then(l)}api(e){return new m(e,this.options)}get fedCM(){return s(this,y)}};p=new WeakMap,d=new WeakMap,y=new WeakMap,g=new WeakSet,k=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.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "gw2.me client library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -33,13 +33,12 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/gw2treasures/gw2.me#readme",
|
|
35
35
|
"devDependencies": {
|
|
36
|
+
"@gw2treasures/eslint-config": "0.0.4",
|
|
36
37
|
"@gw2treasures/publish-package": "0.0.1",
|
|
37
38
|
"@gw2treasures/tsconfig": "0.0.1",
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "7.16.0",
|
|
39
|
-
"@typescript-eslint/parser": "7.16.0",
|
|
40
39
|
"eslint": "8.57.0",
|
|
41
|
-
"tsup": "8.
|
|
42
|
-
"typescript": "5.5.
|
|
43
|
-
"undici-types": "6.19.
|
|
40
|
+
"tsup": "8.2.4",
|
|
41
|
+
"typescript": "5.5.4",
|
|
42
|
+
"undici-types": "6.19.8"
|
|
44
43
|
}
|
|
45
44
|
}
|