diff --git a/packages/types/data/tokeninfo.ts b/packages/types/data/tokeninfo.ts new file mode 100644 index 0000000..10e9ebf --- /dev/null +++ b/packages/types/data/tokeninfo.ts @@ -0,0 +1,36 @@ +import { SchemaAfter, SchemaVersion } from "../schema"; + +export type Tokeninfo = + Schema extends undefined ? TokeninfoBase : + Schema extends SchemaAfter<'2019-05-22T00:00:00.000Z'> | 'latest' ? Tokeninfo_2019_05_22 : + TokeninfoBase; + +export type Permission = 'account' | 'builds' | 'characters' | 'guilds' | 'inventories' | 'progression' | 'pvp' | 'tradingpost' | 'unlocks' | 'wallet'; + +interface TokeninfoBase { + /** The toke id */ + id: number + + /** The name of the base API key */ + name: string + + /** List of permissions */ + permissions: Permission[] +} + +type Tokeninfo_2019_05_22 = TokeninfoBase & ({ + /** The type of the token */ + type: 'APIKey' +} | { + /** The type of the token */ + type: 'Subtoken' + + /** Expiration date (ISO8601) of the subtoken. */ + expires_at: string + + /** The issue date (ISO8601) of the subtoken */ + issued_at: string + + /** The URLs included in this subtoken */ + urls?: string[] +}); diff --git a/packages/types/endpoints.ts b/packages/types/endpoints.ts index 271e09e..dfc27a5 100644 --- a/packages/types/endpoints.ts +++ b/packages/types/endpoints.ts @@ -1,5 +1,6 @@ import { Account } from './data/account'; import { Item } from './data/item'; +import { Tokeninfo } from './data/tokeninfo'; import { SchemaVersion } from './schema'; export type KnwownAuthenticatedEndpoint = @@ -321,8 +322,7 @@ export type EndpointType : Url extends BulkExpandedEndpointUrl<'/v2/items', number> ? BulkExpandedResponseType<'/v2/items', Url, number, Item> : Url extends BulkExpandedEndpointUrl<'/v2/quaggans', string> ? BulkExpandedResponseType<'/v2/quaggans', Url, string, { id: string, url: string }> : - Url extends `/v2/characters?ids=${number}` ? { name: string }[] : - Url extends '/v2/characters' ? string[] : + Url extends '/v2/tokeninfo' ? Tokeninfo : // fallback for all bulk expanded urls Url extends BulkExpandedEndpointUrl ? BulkExpandedResponseType : // fallback for all other urls