@gw2me/client 0.2.2 → 0.2.4
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 +6 -1
- package/dist/index.js +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
declare enum Scope {
|
|
2
2
|
Identify = "identify",
|
|
3
3
|
Email = "email",
|
|
4
|
+
Accounts = "accounts",
|
|
5
|
+
Accounts_Verified = "accounts.verified",
|
|
6
|
+
Accounts_DisplayName = "accounts.displayName",
|
|
4
7
|
GW2_Account = "gw2:account",
|
|
5
8
|
GW2_Inventories = "gw2:inventories",
|
|
6
9
|
GW2_Characters = "gw2:characters",
|
|
@@ -8,6 +11,7 @@ declare enum Scope {
|
|
|
8
11
|
GW2_Wallet = "gw2:wallet",
|
|
9
12
|
GW2_Unlocks = "gw2:unlocks",
|
|
10
13
|
GW2_Pvp = "gw2:pvp",
|
|
14
|
+
GW2_Wvw = "gw2:wvw",
|
|
11
15
|
GW2_Builds = "gw2:builds",
|
|
12
16
|
GW2_Progression = "gw2:progression",
|
|
13
17
|
GW2_Guilds = "gw2:guilds"
|
|
@@ -31,7 +35,8 @@ interface AccountsResponse {
|
|
|
31
35
|
accounts: {
|
|
32
36
|
id: string;
|
|
33
37
|
name: string;
|
|
34
|
-
verified
|
|
38
|
+
verified?: boolean;
|
|
39
|
+
displayName?: string | null;
|
|
35
40
|
}[];
|
|
36
41
|
}
|
|
37
42
|
interface SubtokenResponse {
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var k=t=>{throw TypeError(t)};var T=(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 s of R(e))!A.call(t,s)&&s!==r&&f(t,s,{get:()=>e[s],enumerable:!(i=v(e,s))||i.enumerable});return t};var b=t=>U(f({},"__esModule",{value:!0}),t);var W=(t,e,r)=>e.has(t)||k("Cannot "+r);var l=(t,e,r)=>e.has(t)?k("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r);var o=(t,e,r)=>(W(t,e,"access private method"),r);var G={};T(G,{Gw2MeApi:()=>u,Gw2MeClient:()=>m,Scope:()=>y});module.exports=b(G);var y=(n=>(n.Identify="identify",n.Email="email",n.Accounts="accounts",n.Accounts_Verified="accounts.verified",n.Accounts_DisplayName="accounts.displayName",n.GW2_Account="gw2:account",n.GW2_Inventories="gw2:inventories",n.GW2_Characters="gw2:characters",n.GW2_Tradingpost="gw2:tradingpost",n.GW2_Wallet="gw2:wallet",n.GW2_Unlocks="gw2:unlocks",n.GW2_Pvp="gw2:pvp",n.GW2_Wvw="gw2:wvw",n.GW2_Builds="gw2:builds",n.GW2_Progression="gw2:progression",n.GW2_Guilds="gw2:guilds",n))(y||{});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,u=class{constructor(e,r){this.access_token=e;this.options=r;l(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;l(this,h);this.client_id=e,this.client_secret=r}getAuthorizationUrl({redirect_uri:e,scopes:r,state:i,code_challenge:s,code_challenge_method:_,prompt:w,include_granted_scopes:x,verified_accounts_only:P}){let a=new URLSearchParams({client_id:this.client_id,response_type:"code",redirect_uri:e,scope:r.join(" ")});return i&&a.append("state",i),s&&_&&(a.append("code_challenge",s),a.append("code_challenge_method",_)),w&&a.append("prompt",w),x&&a.append("include_granted_scopes","true"),P&&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 s=new URLSearchParams({grant_type:"authorization_code",code:e,client_id:this.client_id,redirect_uri:r});return this.client_secret&&s.set("client_secret",this.client_secret),i&&s.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:s,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 u(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.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "gw2.me client library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@gw2treasures/publish-package": "0.0.1",
|
|
37
37
|
"@gw2treasures/tsconfig": "0.0.1",
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "7.0
|
|
39
|
-
"@typescript-eslint/parser": "7.0
|
|
40
|
-
"eslint": "8.
|
|
41
|
-
"tsup": "8.0
|
|
42
|
-
"typescript": "5.
|
|
43
|
-
"undici-types": "6.
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "7.16.0",
|
|
39
|
+
"@typescript-eslint/parser": "7.16.0",
|
|
40
|
+
"eslint": "8.57.0",
|
|
41
|
+
"tsup": "8.1.0",
|
|
42
|
+
"typescript": "5.5.3",
|
|
43
|
+
"undici-types": "6.19.2"
|
|
44
44
|
}
|
|
45
45
|
}
|