@lgriffin/esi.ts 9.7.0 → 10.0.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 (216) hide show
  1. package/CHANGELOG.md +370 -0
  2. package/README.md +168 -231
  3. package/dist/EsiClient.d.ts +4 -0
  4. package/dist/EsiClient.d.ts.map +1 -1
  5. package/dist/EsiClientBuilder.d.ts.map +1 -1
  6. package/dist/auth/EsiTokenManager.d.ts +200 -0
  7. package/dist/auth/EsiTokenManager.d.ts.map +1 -0
  8. package/dist/auth/EveSsoClient.d.ts +88 -0
  9. package/dist/auth/EveSsoClient.d.ts.map +1 -0
  10. package/dist/auth/errors.d.ts +42 -0
  11. package/dist/auth/errors.d.ts.map +1 -0
  12. package/dist/auth/index.d.ts +14 -0
  13. package/dist/auth/index.d.ts.map +1 -0
  14. package/dist/auth/jwt.d.ts +43 -0
  15. package/dist/auth/jwt.d.ts.map +1 -0
  16. package/dist/auth/pkce.d.ts +21 -0
  17. package/dist/auth/pkce.d.ts.map +1 -0
  18. package/dist/auth/storage/FileTokenStorage.d.ts +44 -0
  19. package/dist/auth/storage/FileTokenStorage.d.ts.map +1 -0
  20. package/dist/auth/storage/MemoryTokenStorage.d.ts +18 -0
  21. package/dist/auth/storage/MemoryTokenStorage.d.ts.map +1 -0
  22. package/dist/auth/types.d.ts +42 -0
  23. package/dist/auth/types.d.ts.map +1 -0
  24. package/dist/chunk-3ZI5A37L.mjs +1065 -0
  25. package/dist/chunk-3ZI5A37L.mjs.map +1 -0
  26. package/dist/chunk-7A72QFDF.mjs +416 -0
  27. package/dist/chunk-7A72QFDF.mjs.map +1 -0
  28. package/dist/chunk-BBSHKVPI.js +71 -0
  29. package/dist/chunk-BBSHKVPI.js.map +1 -0
  30. package/dist/chunk-HPSACXX3.js +416 -0
  31. package/dist/chunk-HPSACXX3.js.map +1 -0
  32. package/dist/chunk-JIW4BXLP.mjs +17 -0
  33. package/dist/chunk-JIW4BXLP.mjs.map +1 -0
  34. package/dist/chunk-MSJHIJXA.js +1065 -0
  35. package/dist/chunk-MSJHIJXA.js.map +1 -0
  36. package/dist/chunk-PZ5AY32C.js +10 -0
  37. package/dist/chunk-PZ5AY32C.js.map +1 -0
  38. package/dist/chunk-R7D7M2LQ.mjs +71 -0
  39. package/dist/chunk-R7D7M2LQ.mjs.map +1 -0
  40. package/dist/chunk-SAQBXXTM.js +2614 -0
  41. package/dist/chunk-SAQBXXTM.js.map +1 -0
  42. package/dist/chunk-VZS32UQ3.mjs +2614 -0
  43. package/dist/chunk-VZS32UQ3.mjs.map +1 -0
  44. package/dist/clients/AllianceClient.d.ts.map +1 -1
  45. package/dist/clients/ContractsClient.d.ts +12 -9
  46. package/dist/clients/ContractsClient.d.ts.map +1 -1
  47. package/dist/clients/CorporationProjectsClient.d.ts +22 -12
  48. package/dist/clients/CorporationProjectsClient.d.ts.map +1 -1
  49. package/dist/clients/FactionClient.d.ts +4 -4
  50. package/dist/clients/FactionClient.d.ts.map +1 -1
  51. package/dist/clients/FreelanceJobsClient.d.ts +3 -3
  52. package/dist/clients/FreelanceJobsClient.d.ts.map +1 -1
  53. package/dist/clients/IndustryClient.d.ts +4 -4
  54. package/dist/clients/IndustryClient.d.ts.map +1 -1
  55. package/dist/clients/MailClient.d.ts +4 -4
  56. package/dist/clients/MailClient.d.ts.map +1 -1
  57. package/dist/clients/MetaClient.d.ts +3 -2
  58. package/dist/clients/MetaClient.d.ts.map +1 -1
  59. package/dist/clients/WalletClient.d.ts +4 -4
  60. package/dist/clients/WalletClient.d.ts.map +1 -1
  61. package/dist/core/ApiClient.d.ts +4 -0
  62. package/dist/core/ApiClient.d.ts.map +1 -1
  63. package/dist/core/ApiRequestHandler.d.ts.map +1 -1
  64. package/dist/core/BatchRequestHandler.d.ts.map +1 -1
  65. package/dist/core/RequestDeduplicator.d.ts +2 -0
  66. package/dist/core/RequestDeduplicator.d.ts.map +1 -1
  67. package/dist/core/RetryStrategy.d.ts +2 -0
  68. package/dist/core/RetryStrategy.d.ts.map +1 -1
  69. package/dist/core/cache/ETagCacheManager.d.ts +4 -0
  70. package/dist/core/cache/ETagCacheManager.d.ts.map +1 -1
  71. package/dist/core/circuitBreaker/CircuitBreaker.d.ts +3 -0
  72. package/dist/core/circuitBreaker/CircuitBreaker.d.ts.map +1 -1
  73. package/dist/core/configureApiClient.d.ts.map +1 -1
  74. package/dist/core/constants.d.ts +2 -2
  75. package/dist/core/constants.d.ts.map +1 -1
  76. package/dist/core/endpoints/calendarEndpoints.d.ts +7 -7
  77. package/dist/core/endpoints/characterEndpoints.d.ts +2 -2
  78. package/dist/core/endpoints/cloneEndpoints.d.ts +2 -2
  79. package/dist/core/endpoints/contractEndpoints.d.ts +15 -22
  80. package/dist/core/endpoints/contractEndpoints.d.ts.map +1 -1
  81. package/dist/core/endpoints/corporationEndpoints.d.ts +19 -22
  82. package/dist/core/endpoints/corporationEndpoints.d.ts.map +1 -1
  83. package/dist/core/endpoints/corporationProjectEndpoints.d.ts +75 -23
  84. package/dist/core/endpoints/corporationProjectEndpoints.d.ts.map +1 -1
  85. package/dist/core/endpoints/createClient.d.ts.map +1 -1
  86. package/dist/core/endpoints/dogmaEndpoints.d.ts +2 -2
  87. package/dist/core/endpoints/factionEndpoints.d.ts +36 -36
  88. package/dist/core/endpoints/factionEndpoints.d.ts.map +1 -1
  89. package/dist/core/endpoints/fleetEndpoints.d.ts +1 -1
  90. package/dist/core/endpoints/freelanceJobsEndpoints.d.ts +131 -122
  91. package/dist/core/endpoints/freelanceJobsEndpoints.d.ts.map +1 -1
  92. package/dist/core/endpoints/industryEndpoints.d.ts +6 -6
  93. package/dist/core/endpoints/industryEndpoints.d.ts.map +1 -1
  94. package/dist/core/endpoints/mailEndpoints.d.ts +3 -5
  95. package/dist/core/endpoints/mailEndpoints.d.ts.map +1 -1
  96. package/dist/core/endpoints/mercenaryEndpoints.d.ts +1 -1
  97. package/dist/core/endpoints/metaEndpoints.d.ts +5 -1
  98. package/dist/core/endpoints/metaEndpoints.d.ts.map +1 -1
  99. package/dist/core/endpoints/piEndpoints.d.ts +2 -2
  100. package/dist/core/endpoints/statusEndpoints.d.ts +1 -1
  101. package/dist/core/endpoints/universeEndpoints.d.ts +22 -22
  102. package/dist/core/endpoints/walletEndpoints.d.ts +2 -3
  103. package/dist/core/endpoints/walletEndpoints.d.ts.map +1 -1
  104. package/dist/core/logger/DefaultLogger.d.ts +31 -0
  105. package/dist/core/logger/DefaultLogger.d.ts.map +1 -0
  106. package/dist/core/logger/ILogger.d.ts +14 -4
  107. package/dist/core/logger/ILogger.d.ts.map +1 -1
  108. package/dist/core/logger/NoopLogger.d.ts +4 -0
  109. package/dist/core/logger/NoopLogger.d.ts.map +1 -1
  110. package/dist/core/logger/clientLog.d.ts +11 -0
  111. package/dist/core/logger/clientLog.d.ts.map +1 -0
  112. package/dist/core/logger/logger.d.ts +11 -3
  113. package/dist/core/logger/logger.d.ts.map +1 -1
  114. package/dist/core/logger/loggerUtil.d.ts +8 -6
  115. package/dist/core/logger/loggerUtil.d.ts.map +1 -1
  116. package/dist/core/logger/resolveLogger.d.ts +10 -0
  117. package/dist/core/logger/resolveLogger.d.ts.map +1 -0
  118. package/dist/core/pagination/AsyncPaginationIterator.d.ts.map +1 -1
  119. package/dist/core/pagination/CursorPaginationHandler.d.ts.map +1 -1
  120. package/dist/core/pagination/PaginationHandler.d.ts.map +1 -1
  121. package/dist/core/rateLimiter/RateLimiter.d.ts.map +1 -1
  122. package/dist/core/requestPipeline/cachePolicy.d.ts +14 -0
  123. package/dist/core/requestPipeline/cachePolicy.d.ts.map +1 -1
  124. package/dist/core/requestPipeline/fetchExecution.d.ts +1 -1
  125. package/dist/core/requestPipeline/fetchExecution.d.ts.map +1 -1
  126. package/dist/core/requestPipeline/headers.d.ts.map +1 -1
  127. package/dist/core/requestPipeline/index.d.ts +2 -2
  128. package/dist/core/requestPipeline/index.d.ts.map +1 -1
  129. package/dist/core/requestPipeline/paginationOrchestration.d.ts.map +1 -1
  130. package/dist/core/requestPipeline/statusHandling.d.ts +8 -2
  131. package/dist/core/requestPipeline/statusHandling.d.ts.map +1 -1
  132. package/dist/core/util/concurrency.d.ts +29 -0
  133. package/dist/core/util/concurrency.d.ts.map +1 -0
  134. package/dist/errors.d.ts +1 -0
  135. package/dist/errors.d.ts.map +1 -1
  136. package/dist/errors.js +53 -195
  137. package/dist/errors.js.map +1 -1
  138. package/dist/errors.mjs +37 -129
  139. package/dist/errors.mjs.map +1 -1
  140. package/dist/index.d.ts +6 -2
  141. package/dist/index.d.ts.map +1 -1
  142. package/dist/index.js +1972 -3472
  143. package/dist/index.js.map +1 -1
  144. package/dist/index.mjs +1606 -2995
  145. package/dist/index.mjs.map +1 -1
  146. package/dist/schemas/calendar.d.ts +9 -7
  147. package/dist/schemas/calendar.d.ts.map +1 -1
  148. package/dist/schemas/character.d.ts +2 -2
  149. package/dist/schemas/clones.d.ts +2 -2
  150. package/dist/schemas/contracts.d.ts +69 -6
  151. package/dist/schemas/contracts.d.ts.map +1 -1
  152. package/dist/schemas/corporation-projects.d.ts +96 -9
  153. package/dist/schemas/corporation-projects.d.ts.map +1 -1
  154. package/dist/schemas/corporation.d.ts +34 -22
  155. package/dist/schemas/corporation.d.ts.map +1 -1
  156. package/dist/schemas/dogma.d.ts +2 -2
  157. package/dist/schemas/faction-warfare.d.ts +125 -12
  158. package/dist/schemas/faction-warfare.d.ts.map +1 -1
  159. package/dist/schemas/fleet.d.ts +1 -1
  160. package/dist/schemas/freelance-jobs.d.ts +52 -22
  161. package/dist/schemas/freelance-jobs.d.ts.map +1 -1
  162. package/dist/schemas/index.js +420 -2479
  163. package/dist/schemas/index.js.map +1 -1
  164. package/dist/schemas/index.mjs +225 -2065
  165. package/dist/schemas/index.mjs.map +1 -1
  166. package/dist/schemas/industry.d.ts +33 -0
  167. package/dist/schemas/industry.d.ts.map +1 -1
  168. package/dist/schemas/mail.d.ts +24 -5
  169. package/dist/schemas/mail.d.ts.map +1 -1
  170. package/dist/schemas/mercenary.d.ts +1 -1
  171. package/dist/schemas/meta.d.ts +12 -1
  172. package/dist/schemas/meta.d.ts.map +1 -1
  173. package/dist/schemas/pi.d.ts +2 -2
  174. package/dist/schemas/status.d.ts +1 -1
  175. package/dist/schemas/universe.d.ts +22 -22
  176. package/dist/schemas/universe.d.ts.map +1 -1
  177. package/dist/schemas/wallet.d.ts +16 -0
  178. package/dist/schemas/wallet.d.ts.map +1 -1
  179. package/dist/sde/SdeDataProvider.d.ts.map +1 -1
  180. package/dist/sde/index.js +95 -1162
  181. package/dist/sde/index.js.map +1 -1
  182. package/dist/sde/index.mjs +73 -1091
  183. package/dist/sde/index.mjs.map +1 -1
  184. package/dist/sde/ingestion/SdeExtractor.d.ts.map +1 -1
  185. package/dist/sde/ingestion/metadata.d.ts +13 -0
  186. package/dist/sde/ingestion/metadata.d.ts.map +1 -0
  187. package/dist/sde/memory.js +21 -1095
  188. package/dist/sde/memory.js.map +1 -1
  189. package/dist/sde/memory.mjs +13 -1051
  190. package/dist/sde/memory.mjs.map +1 -1
  191. package/dist/sde/optionalPeers.d.ts +25 -0
  192. package/dist/sde/optionalPeers.d.ts.map +1 -0
  193. package/dist/testing/TestDataFactory.d.ts +28 -1
  194. package/dist/testing/TestDataFactory.d.ts.map +1 -1
  195. package/dist/testing/index.js +116 -125
  196. package/dist/testing/index.js.map +1 -1
  197. package/dist/testing/index.mjs +110 -82
  198. package/dist/testing/index.mjs.map +1 -1
  199. package/dist/types/contracts.d.ts +4 -1
  200. package/dist/types/contracts.d.ts.map +1 -1
  201. package/dist/types/corporation-projects.d.ts +5 -1
  202. package/dist/types/corporation-projects.d.ts.map +1 -1
  203. package/dist/types/faction-warfare.d.ts +9 -1
  204. package/dist/types/faction-warfare.d.ts.map +1 -1
  205. package/dist/types/freelance-jobs.d.ts +2 -1
  206. package/dist/types/freelance-jobs.d.ts.map +1 -1
  207. package/dist/types/generated/spec-alignment.check.d.ts +2 -2
  208. package/dist/types/industry.d.ts +2 -1
  209. package/dist/types/industry.d.ts.map +1 -1
  210. package/dist/types/mail.d.ts +2 -1
  211. package/dist/types/mail.d.ts.map +1 -1
  212. package/dist/types/meta.d.ts +2 -1
  213. package/dist/types/meta.d.ts.map +1 -1
  214. package/dist/types/wallet.d.ts +2 -1
  215. package/dist/types/wallet.d.ts.map +1 -1
  216. package/package.json +46 -23
@@ -0,0 +1,200 @@
1
+ import { EsiClient, EsiClientConfig } from '../EsiClient';
2
+ import type { FetchLike, TokenProvider } from '../core/ApiClient';
3
+ import type { ILogger } from '../core/logger/ILogger';
4
+ import { EveSsoClient, AuthorizationUrlOptions, ExchangeCodeOptions } from './EveSsoClient';
5
+ import type { ITokenStorage, StoredToken } from './types';
6
+ export interface EsiTokenManagerConfig {
7
+ /** The application's SSO client id. */
8
+ clientId: string;
9
+ /** The application's SSO client secret. Omit for a public (PKCE) client. */
10
+ clientSecret?: string;
11
+ /** Redirect URI registered for the application. */
12
+ callbackUrl?: string;
13
+ /** Where tokens are persisted. Defaults to {@link MemoryTokenStorage}. */
14
+ storage?: ITokenStorage;
15
+ /** Pre-built SSO client. When given, `clientId`, `clientSecret`, `callbackUrl` and `fetch` are ignored for SSO calls. */
16
+ ssoClient?: EveSsoClient;
17
+ /** Custom fetch for SSO calls. Defaults to `globalThis.fetch`. */
18
+ fetch?: FetchLike;
19
+ /**
20
+ * How long before expiry a token counts as stale, in milliseconds.
21
+ * Defaults to 60 000 (one minute).
22
+ */
23
+ refreshSkewMs?: number;
24
+ /**
25
+ * When true (the default), {@link EsiTokenManager.getToken} refreshes a
26
+ * stale token before returning it. When false it returns the stored token
27
+ * as-is and refresh only happens through {@link EsiTokenManager.refresh},
28
+ * {@link EsiTokenManager.refreshAll}, or the 401 path of a created client.
29
+ */
30
+ autoRefresh?: boolean;
31
+ /** Called after a token is refreshed and persisted. */
32
+ onRefresh?: (token: StoredToken) => void;
33
+ /** Called when a refresh fails for a reason other than revocation. */
34
+ onRefreshError?: (characterId: number, error: Error) => void;
35
+ /** Called when SSO reports a character's refresh token as invalid. */
36
+ onRevoked?: (characterId: number) => void;
37
+ /** Logger for refresh activity. Defaults to the library logger. */
38
+ logger?: ILogger;
39
+ /** Clock override for tests. */
40
+ now?: () => number;
41
+ }
42
+ export interface AddCharacterOptions extends ExchangeCodeOptions {
43
+ /**
44
+ * When the character already has a stored token, revoke its refresh token
45
+ * at SSO before replacing it. Defaults to false.
46
+ */
47
+ revokeReplaced?: boolean;
48
+ }
49
+ export interface RemoveCharacterOptions {
50
+ /** Revoke the refresh token at SSO before deleting it. Defaults to false. */
51
+ revoke?: boolean;
52
+ }
53
+ export interface RefreshAllOptions {
54
+ /** Maximum simultaneous SSO requests. Defaults to 5. */
55
+ concurrency?: number;
56
+ /**
57
+ * Only refresh tokens that expire within this many milliseconds (after
58
+ * applying the refresh skew). Omit to refresh every token.
59
+ */
60
+ expiringWithinMs?: number;
61
+ /** Abort the run; remaining tokens are reported as skipped. */
62
+ signal?: AbortSignal;
63
+ /**
64
+ * Progress callback, invoked after each token settles. A callback that
65
+ * throws does not stop the run; the exception is discarded.
66
+ */
67
+ onProgress?: (completed: number, total: number) => void;
68
+ }
69
+ export type RefreshStatus = 'refreshed' | 'skipped' | 'failed' | 'revoked';
70
+ export interface RefreshResult {
71
+ characterId: number;
72
+ status: RefreshStatus;
73
+ /** New expiry in epoch milliseconds, when refreshed. */
74
+ expiresAt?: number;
75
+ /** The error, when failed or revoked. */
76
+ error?: Error;
77
+ /** True when the failure was an SSO 429 or 5xx and can be retried later. */
78
+ retryable?: boolean;
79
+ /** Why the token was skipped. */
80
+ reason?: 'not-stale' | 'aborted';
81
+ }
82
+ /** Lightweight view of a stored character, without the secrets. */
83
+ export interface CharacterSummary {
84
+ characterId: number;
85
+ characterName: string;
86
+ scopes: string[];
87
+ expiresAt: number;
88
+ revoked: boolean;
89
+ }
90
+ /** EsiClient options a manager-created client accepts; token fields are supplied by the manager. */
91
+ export type ManagedClientConfig = Omit<EsiClientConfig, 'accessToken' | 'onTokenRefresh'>;
92
+ /**
93
+ * Keeps one valid SSO token per character on top of a pluggable
94
+ * {@link ITokenStorage}, refreshing ahead of expiry, coalescing concurrent
95
+ * refreshes, persisting rotated refresh tokens, and recording revocations so
96
+ * SSO is not hammered with a dead refresh token.
97
+ */
98
+ export declare class EsiTokenManager {
99
+ private readonly storage;
100
+ private readonly sso;
101
+ private readonly refreshSkewMs;
102
+ private readonly autoRefresh;
103
+ private readonly logger;
104
+ private readonly now;
105
+ private readonly hooks;
106
+ private readonly inFlight;
107
+ /**
108
+ * Per-character write generation. Bumped whenever a record is replaced or
109
+ * removed so a refresh that was already waiting on SSO can tell its result
110
+ * is stale and must not be persisted over the newer state.
111
+ */
112
+ private readonly generations;
113
+ constructor(config: EsiTokenManagerConfig);
114
+ /** The SSO client used for all token traffic. */
115
+ getSsoClient(): EveSsoClient;
116
+ /** The storage adapter backing this manager. */
117
+ getStorage(): ITokenStorage;
118
+ /** Build the SSO login URL. See {@link EveSsoClient.getAuthorizationUrl}. */
119
+ getAuthorizationUrl(options: AuthorizationUrlOptions): string;
120
+ /**
121
+ * Exchange an authorization code and store the resulting token under the
122
+ * character it belongs to. An existing token for that character is
123
+ * replaced; storage never holds two entries for one character.
124
+ */
125
+ addCharacter(code: string, options?: AddCharacterOptions): Promise<StoredToken>;
126
+ /**
127
+ * Import tokens obtained elsewhere (a previous library version, another
128
+ * tool, a migration). The character identity is decoded from the access
129
+ * token; `expiresIn` is in seconds and defaults to the JWT `exp` claim.
130
+ */
131
+ importToken(token: {
132
+ accessToken: string;
133
+ refreshToken: string;
134
+ expiresIn?: number;
135
+ }): Promise<StoredToken>;
136
+ /** Delete a character's token, optionally revoking it at SSO first. */
137
+ removeCharacter(characterId: number, options?: RemoveCharacterOptions): Promise<void>;
138
+ /** The stored record for a character, or null. */
139
+ getStoredToken(characterId: number): Promise<StoredToken | null>;
140
+ /** Every stored token. */
141
+ listTokens(): Promise<StoredToken[]>;
142
+ /** Every stored character without its secrets. */
143
+ listCharacters(): Promise<CharacterSummary[]>;
144
+ /** True when the stored token grants every listed scope. */
145
+ hasScopes(characterId: number, scopes: readonly string[]): Promise<boolean>;
146
+ /**
147
+ * A usable access token for the character. With `autoRefresh` on, a token
148
+ * inside the refresh skew is refreshed first.
149
+ *
150
+ * @throws CharacterNotFoundError when no token is stored
151
+ * @throws TokenRevokedError when the character's refresh token is revoked
152
+ */
153
+ getToken(characterId: number): Promise<string>;
154
+ /**
155
+ * Refresh a character's token through SSO regardless of expiry. Concurrent
156
+ * calls for the same character share one SSO request.
157
+ */
158
+ refresh(characterId: number): Promise<StoredToken>;
159
+ /**
160
+ * Refresh stored tokens with bounded concurrency. Per-character failures
161
+ * never reject: each character gets its own {@link RefreshResult}. The one
162
+ * rejection is a failing `storage.list()`, because with no records there
163
+ * is no character to attribute the fault to and a silent empty run would
164
+ * hide a broken store from a scheduler.
165
+ */
166
+ refreshAll(options?: RefreshAllOptions): Promise<RefreshResult[]>;
167
+ /**
168
+ * A {@link TokenProvider} bound to a character, for `onTokenRefresh`. Every
169
+ * invocation refreshes through SSO (coalesced), because the client only
170
+ * calls it after ESI has rejected the current token.
171
+ */
172
+ tokenProviderFor(characterId: number): TokenProvider;
173
+ /**
174
+ * An {@link EsiClient} whose access token and refresh provider are bound to
175
+ * the character. The token is validated (and refreshed if stale) first.
176
+ */
177
+ createClient(characterId: number, config?: ManagedClientConfig): Promise<EsiClient>;
178
+ private isStale;
179
+ private requireStored;
180
+ private generationOf;
181
+ private bumpGeneration;
182
+ /**
183
+ * After an SSO round trip, decide whether the refresh still owns the
184
+ * character's record. Returns null when it does. When the record was
185
+ * replaced meanwhile, returns the current record so the caller hands out
186
+ * the newer credentials; when it was removed, throws CharacterNotFoundError.
187
+ */
188
+ private supersededBy;
189
+ private doRefresh;
190
+ private refreshOne;
191
+ private storeResponse;
192
+ /**
193
+ * Build the record to persist. When adding a character the access token
194
+ * must decode, because it is the only source of the character id. On a
195
+ * refresh the identity is already known, so a token that does not decode
196
+ * (a proxy, a future SSO format) keeps the previous record's identity.
197
+ */
198
+ private buildStoredToken;
199
+ }
200
+ //# sourceMappingURL=EsiTokenManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EsiTokenManager.d.ts","sourceRoot":"","sources":["../../src/auth/EsiTokenManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGtD,OAAO,EACL,YAAY,EAEZ,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,WAAW,qBAAqB;IACpC,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,yHAAyH;IACzH,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,kEAAkE;IAClE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uDAAuD;IACvD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACzC,sEAAsE;IACtE,cAAc,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC7D,sEAAsE;IACtE,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,mEAAmE;I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AAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAWnD,4DAA4D;IACtD,SAAS,CACb,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,SAAS,MAAM,EAAE,GACxB,OAAO,CAAC,OAAO,CAAC;IAOnB;;;;;;OAMG;IACG,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAepD;;;OAGG;IACH,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAgBlD;;;;;;OAMG;IACG,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAmB3E;;;;OAIG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa;IAOpD;;;OAGG;IACG,YAAY,CAChB,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,mBAAwB,GAC/B,OAAO,CAAC,SAAS,CAAC;IAWrB,OAAO,CAAC,OAAO;YAID,aAAa;IAM3B,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,cAAc;IAItB;;;;;OAKG;YACW,YAAY;YAaZ,SAAS;YA8CT,UAAU;YA8CV,aAAa;IAuB3B;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;CAmCzB"}
@@ -0,0 +1,88 @@
1
+ import type { FetchLike } from '../core/ApiClient';
2
+ export declare const DEFAULT_SSO_BASE_URL = "https://login.eveonline.com";
3
+ export interface EveSsoClientConfig {
4
+ /** The application's client id from developers.eveonline.com. */
5
+ clientId: string;
6
+ /**
7
+ * The application's client secret. Omit for a public (PKCE) client; token
8
+ * requests then identify the application by `client_id` in the form body.
9
+ */
10
+ clientSecret?: string;
11
+ /** Redirect URI registered for the application. Used by {@link EveSsoClient.getAuthorizationUrl}. */
12
+ callbackUrl?: string;
13
+ /** Override the SSO host, for tests or a proxy. Defaults to https://login.eveonline.com. */
14
+ ssoBaseUrl?: string;
15
+ /** Custom fetch implementation. Defaults to `globalThis.fetch` resolved at call time. */
16
+ fetch?: FetchLike;
17
+ }
18
+ /** A successful response from the SSO token endpoint. */
19
+ export interface SsoTokenResponse {
20
+ accessToken: string;
21
+ refreshToken: string;
22
+ /** Lifetime of `accessToken` in seconds, as reported by SSO. */
23
+ expiresIn: number;
24
+ tokenType: string;
25
+ }
26
+ export interface AuthorizationUrlOptions {
27
+ /** Scopes to request. */
28
+ scopes: readonly string[];
29
+ /** Opaque value echoed back on the callback; use {@link generateState}. */
30
+ state: string;
31
+ /** PKCE challenge for public clients; see {@link generatePkcePair}. */
32
+ codeChallenge?: string;
33
+ /** Overrides `callbackUrl` from the config. */
34
+ redirectUri?: string;
35
+ }
36
+ export interface ExchangeCodeOptions {
37
+ /** PKCE verifier that produced the challenge sent in the authorization URL. */
38
+ codeVerifier?: string;
39
+ /**
40
+ * The redirect URI that was sent in the authorization request. Defaults to
41
+ * the configured `callbackUrl`; when neither is set the field is omitted.
42
+ */
43
+ redirectUri?: string;
44
+ }
45
+ export interface RefreshOptions {
46
+ /** Request a subset of the originally granted scopes. */
47
+ scopes?: readonly string[];
48
+ }
49
+ /**
50
+ * Minimal client for the EVE SSO OAuth2 endpoints: building the login URL,
51
+ * exchanging an authorization code, refreshing, and revoking.
52
+ *
53
+ * Supports confidential clients (HTTP Basic with the client secret) and
54
+ * public clients (PKCE with `client_id` in the body). No JWT signature
55
+ * verification is performed; tokens are trusted because they arrive directly
56
+ * from SSO over TLS.
57
+ */
58
+ export declare class EveSsoClient {
59
+ private readonly clientId;
60
+ private readonly clientSecret?;
61
+ private readonly callbackUrl?;
62
+ private readonly baseUrl;
63
+ private readonly fetchFn?;
64
+ constructor(config: EveSsoClientConfig);
65
+ /** True when a client secret is configured (confidential client). */
66
+ isConfidential(): boolean;
67
+ get tokenUrl(): string;
68
+ get authorizeUrl(): string;
69
+ get revokeUrl(): string;
70
+ /** Build the URL to send a player to for login. */
71
+ getAuthorizationUrl(options: AuthorizationUrlOptions): string;
72
+ /** Exchange the authorization code from the callback for tokens. */
73
+ exchangeCode(code: string, options?: ExchangeCodeOptions): Promise<SsoTokenResponse>;
74
+ /** Obtain a new access token (and rotated refresh token) from a refresh token. */
75
+ refresh(refreshToken: string, options?: RefreshOptions): Promise<SsoTokenResponse>;
76
+ /** Revoke a refresh token so it can no longer be used. */
77
+ revoke(token: string, tokenTypeHint?: 'refresh_token' | 'access_token'): Promise<void>;
78
+ private tokenRequest;
79
+ private post;
80
+ /**
81
+ * Map a non-2xx SSO response to an error. `invalid_grant` means "the
82
+ * refresh token is dead" only for a refresh grant; on a code exchange (or
83
+ * a revoke) it describes the login code or request, so it stays an
84
+ * `SsoError` and does not trigger the re-authentication path.
85
+ */
86
+ private errorFromResponse;
87
+ }
88
+ //# sourceMappingURL=EveSsoClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EveSsoClient.d.ts","sourceRoot":"","sources":["../../src/auth/EveSsoClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAInD,eAAO,MAAM,oBAAoB,gCAAgC,CAAC;AAElE,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qGAAqG;IACrG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4FAA4F;IAC5F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,yDAAyD;AACzD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC,yBAAyB;IACzB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,2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YAWF,YAAY;YAgDZ,IAAI;IAkBlB;;;;;OAKG;YACW,iBAAiB;CA2BhC"}
@@ -0,0 +1,42 @@
1
+ /** Base class for every error raised by the auth subsystem. */
2
+ export declare class AuthError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ /**
6
+ * EVE SSO answered a token or revoke request with a non-2xx status.
7
+ *
8
+ * `errorCode` is the OAuth2 `error` field from the response body
9
+ * (`invalid_client`, `invalid_request`, ...) or `unknown` when the body could
10
+ * not be parsed. `statusCode` is the HTTP status.
11
+ */
12
+ export declare class SsoError extends AuthError {
13
+ readonly statusCode: number;
14
+ readonly errorCode: string;
15
+ readonly errorDescription?: string;
16
+ constructor(statusCode: number, errorCode: string, errorDescription?: string);
17
+ /** True for statuses where the same request can be retried later. */
18
+ isRetryable(): boolean;
19
+ }
20
+ /**
21
+ * The refresh token is no longer accepted by SSO (`invalid_grant`), or the
22
+ * manager has already recorded that outcome for the character. The character
23
+ * must log in again; retrying cannot help.
24
+ */
25
+ export declare class TokenRevokedError extends AuthError {
26
+ readonly characterId?: number;
27
+ constructor(message: string, characterId?: number);
28
+ }
29
+ /** A JWT access token could not be decoded into the claims the manager needs. */
30
+ export declare class TokenDecodeError extends AuthError {
31
+ constructor(message: string);
32
+ }
33
+ /** No token is stored for the requested character. */
34
+ export declare class CharacterNotFoundError extends AuthError {
35
+ readonly characterId: number;
36
+ constructor(characterId: number);
37
+ }
38
+ export declare function isAuthError(error: unknown): error is AuthError;
39
+ export declare function isSsoError(error: unknown): error is SsoError;
40
+ export declare function isTokenRevoked(error: unknown): error is TokenRevokedError;
41
+ export declare function isCharacterNotFound(error: unknown): error is CharacterNotFoundError;
42
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/auth/errors.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;GAMG;AACH,qBAAa,QAAS,SAAQ,SAAS;IACrC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,gBAAgB,CAAC,EAAE,MAAM,CAAC;gBAGxC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,gBAAgB,CAAC,EAAE,MAAM;IAU3B,qEAAqE;IACrE,WAAW,IAAI,OAAO;CAGvB;AAED;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;IAC9C,SAAgB,WAAW,CAAC,EAAE,MAAM,CAAC;gBAEzB,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;CAKlD;AAED,iFAAiF;AACjF,qBAAa,gBAAiB,SAAQ,SAAS;gBACjC,OAAO,EAAE,MAAM;CAI5B;AAED,sDAAsD;AACtD,qBAAa,sBAAuB,SAAQ,SAAS;IACnD,SAAgB,WAAW,EAAE,MAAM,CAAC;gBAExB,WAAW,EAAE,MAAM;CAKhC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAEzE;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,sBAAsB,CAEjC"}
@@ -0,0 +1,14 @@
1
+ export type { ITokenStorage, StoredToken } from './types';
2
+ export { EveSsoClient, DEFAULT_SSO_BASE_URL } from './EveSsoClient';
3
+ export type { EveSsoClientConfig, SsoTokenResponse, AuthorizationUrlOptions, ExchangeCodeOptions, RefreshOptions, } from './EveSsoClient';
4
+ export { EsiTokenManager } from './EsiTokenManager';
5
+ export type { EsiTokenManagerConfig, AddCharacterOptions, RemoveCharacterOptions, RefreshAllOptions, RefreshResult, RefreshStatus, CharacterSummary, ManagedClientConfig, } from './EsiTokenManager';
6
+ export { MemoryTokenStorage } from './storage/MemoryTokenStorage';
7
+ export { FileTokenStorage } from './storage/FileTokenStorage';
8
+ export type { FileTokenStorageOptions } from './storage/FileTokenStorage';
9
+ export { AuthError, SsoError, TokenRevokedError, TokenDecodeError, CharacterNotFoundError, isAuthError, isSsoError, isTokenRevoked, isCharacterNotFound, } from './errors';
10
+ export { decodeAccessToken, decodeJwtPayload, parseCharacterId, parseScopes, } from './jwt';
11
+ export type { DecodedAccessToken, EveJwtClaims } from './jwt';
12
+ export { generatePkcePair, generateCodeVerifier, codeChallengeFromVerifier, generateState, } from './pkce';
13
+ export type { PkcePair } from './pkce';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACpE,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,cAAc,GACf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,YAAY,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE1E,OAAO,EACL,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,cAAc,EACd,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,GACZ,MAAM,OAAO,CAAC;AACf,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,aAAa,GACd,MAAM,QAAQ,CAAC;AAChB,YAAY,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,43 @@
1
+ /** Claims EVE SSO places in an access token. Only the ones the manager reads are typed. */
2
+ export interface EveJwtClaims {
3
+ /** `CHARACTER:EVE:<characterId>` */
4
+ sub: string;
5
+ /** Character name. */
6
+ name?: string;
7
+ /** Granted scopes: a single string, or an array when more than one. */
8
+ scp?: string | string[];
9
+ /** Expiry as epoch seconds. */
10
+ exp?: number;
11
+ /** Issued-at as epoch seconds. */
12
+ iat?: number;
13
+ /** Owner hash; changes on character transfer. */
14
+ owner?: string;
15
+ iss?: string;
16
+ aud?: string | string[];
17
+ [claim: string]: unknown;
18
+ }
19
+ /** Identity and lifetime information extracted from an EVE SSO access token. */
20
+ export interface DecodedAccessToken {
21
+ characterId: number;
22
+ characterName: string;
23
+ scopes: string[];
24
+ /** Epoch milliseconds, or undefined when the token carries no `exp`. */
25
+ expiresAt?: number;
26
+ ownerHash?: string;
27
+ claims: EveJwtClaims;
28
+ }
29
+ /**
30
+ * Decode the payload of a JWT without verifying its signature.
31
+ *
32
+ * Tokens reach the manager directly from SSO over TLS, so the payload is
33
+ * trusted for the purpose of learning which character it belongs to. Do not
34
+ * use this to authenticate tokens presented by third parties.
35
+ */
36
+ export declare function decodeJwtPayload(token: string): EveJwtClaims;
37
+ /** Parse the character id out of an SSO `sub` claim (`CHARACTER:EVE:123`). */
38
+ export declare function parseCharacterId(sub: unknown): number;
39
+ /** Normalise the `scp` claim, which SSO emits as a string for one scope and an array otherwise. */
40
+ export declare function parseScopes(scp: unknown): string[];
41
+ /** Decode an EVE SSO access token into the fields the token manager stores. */
42
+ export declare function decodeAccessToken(token: string): DecodedAccessToken;
43
+ //# sourceMappingURL=jwt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/auth/jwt.ts"],"names":[],"mappings":"AAEA,2FAA2F;AAC3F,MAAM,WAAW,YAAY;IAC3B,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,+BAA+B;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,gFAAgF;AAChF,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;CACtB;AAMD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAiB5D;AAED,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAWrD;AAED,mGAAmG;AACnG,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,EAAE,CAQlD;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAWnE"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * A PKCE verifier/challenge pair for the authorization-code flow of a public
3
+ * client (one that cannot hold a client secret).
4
+ */
5
+ export interface PkcePair {
6
+ /** Random secret sent with the token request as `code_verifier`. */
7
+ codeVerifier: string;
8
+ /** `BASE64URL(SHA256(codeVerifier))`, sent in the authorization URL. */
9
+ codeChallenge: string;
10
+ /** Always `S256`; EVE SSO does not accept the plain method. */
11
+ codeChallengeMethod: 'S256';
12
+ }
13
+ /** Generate a 32-byte base64url code verifier (43 characters). */
14
+ export declare function generateCodeVerifier(): string;
15
+ /** Derive the S256 code challenge for a verifier. */
16
+ export declare function codeChallengeFromVerifier(codeVerifier: string): string;
17
+ /** Generate a verifier and its challenge in one call. */
18
+ export declare function generatePkcePair(): PkcePair;
19
+ /** Generate an unguessable OAuth2 `state` value. */
20
+ export declare function generateState(): string;
21
+ //# sourceMappingURL=pkce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pkce.d.ts","sourceRoot":"","sources":["../../src/auth/pkce.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,oEAAoE;IACpE,YAAY,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,aAAa,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,kEAAkE;AAClE,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED,qDAAqD;AACrD,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,yDAAyD;AACzD,wBAAgB,gBAAgB,IAAI,QAAQ,CAO3C;AAED,oDAAoD;AACpD,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
@@ -0,0 +1,44 @@
1
+ import type { ITokenStorage, StoredToken } from '../types';
2
+ export interface FileTokenStorageOptions {
3
+ /**
4
+ * POSIX permission bits for the token file. Defaults to `0o600` (owner
5
+ * read/write only). Ignored on platforms without POSIX modes.
6
+ */
7
+ mode?: number;
8
+ }
9
+ /**
10
+ * JSON-file {@link ITokenStorage} for single-process applications.
11
+ *
12
+ * Writes go to a sibling temporary file that is renamed over the target, so a
13
+ * crash mid-write leaves the previous file intact. Writes are serialised
14
+ * within the process. Two processes sharing one file are not supported: each
15
+ * would rotate refresh tokens the other cannot see.
16
+ */
17
+ export declare class FileTokenStorage implements ITokenStorage {
18
+ private readonly filePath;
19
+ private readonly mode;
20
+ private cache;
21
+ private loading;
22
+ /** Bumped by invalidate() so a read that began earlier cannot repopulate the cache. */
23
+ private loadGeneration;
24
+ private writeChain;
25
+ constructor(filePath: string, options?: FileTokenStorageOptions);
26
+ /** Absolute path of the backing file. */
27
+ get path(): string;
28
+ get(characterId: number): Promise<StoredToken | null>;
29
+ set(characterId: number, token: StoredToken): Promise<void>;
30
+ delete(characterId: number): Promise<void>;
31
+ list(): Promise<StoredToken[]>;
32
+ /** Drop the in-memory copy so the next call re-reads the file. */
33
+ invalidate(): void;
34
+ /**
35
+ * Load once; overlapping first calls share the same read so none of them
36
+ * clobbers another's map. A read that started before invalidate() still
37
+ * resolves for its own callers but neither becomes the cache nor clears a
38
+ * newer in-flight read.
39
+ */
40
+ private load;
41
+ private readFile;
42
+ private persist;
43
+ }
44
+ //# sourceMappingURL=FileTokenStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileTokenStorage.d.ts","sourceRoot":"","sources":["../../../src/auth/storage/FileTokenStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAkC3D,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IACpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,KAAK,CAAyC;IACtD,OAAO,CAAC,OAAO,CAAkD;IACjE,uFAAuF;IACvF,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,UAAU,CAAoC;gBAE1C,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B;IAKnE,yCAAyC;IACzC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAEK,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAMrD,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAM3D,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO1C,IAAI,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAQpC,kEAAkE;IAClE,UAAU,IAAI,IAAI;IAMlB;;;;;OAKG;IACH,OAAO,CAAC,IAAI;YAiBE,QAAQ;IAqBtB,OAAO,CAAC,OAAO;CAqBhB"}
@@ -0,0 +1,18 @@
1
+ import type { ITokenStorage, StoredToken } from '../types';
2
+ /**
3
+ * In-memory {@link ITokenStorage}. Tokens live only as long as the process.
4
+ * Useful for tests, CLIs that log in on every run, and as a cache in front of
5
+ * a durable store.
6
+ */
7
+ export declare class MemoryTokenStorage implements ITokenStorage {
8
+ private readonly tokens;
9
+ constructor(initial?: readonly StoredToken[]);
10
+ get(characterId: number): Promise<StoredToken | null>;
11
+ set(characterId: number, token: StoredToken): Promise<void>;
12
+ delete(characterId: number): Promise<void>;
13
+ list(): Promise<StoredToken[]>;
14
+ /** Remove every token. */
15
+ clear(): void;
16
+ get size(): number;
17
+ }
18
+ //# sourceMappingURL=MemoryTokenStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryTokenStorage.d.ts","sourceRoot":"","sources":["../../../src/auth/storage/MemoryTokenStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE3D;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,aAAa;IACtD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkC;gBAE7C,OAAO,GAAE,SAAS,WAAW,EAAO;IAShD,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAOrD,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAK3D,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C,IAAI,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAS9B,0BAA0B;IAC1B,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * A character's SSO credentials as held by an {@link ITokenStorage}.
3
+ *
4
+ * Timestamps are epoch milliseconds so the record is JSON-safe and can be
5
+ * compared against `Date.now()` without parsing.
6
+ */
7
+ export interface StoredToken {
8
+ /** EVE character id, decoded from the access token's `sub` claim. */
9
+ characterId: number;
10
+ /** Character name, decoded from the access token's `name` claim. */
11
+ characterName: string;
12
+ /** Current bearer token for ESI requests. */
13
+ accessToken: string;
14
+ /** Refresh token as of the last SSO exchange; SSO rotates it on every use. */
15
+ refreshToken: string;
16
+ /** When `accessToken` expires, in epoch milliseconds. */
17
+ expiresAt: number;
18
+ /** Scopes granted to this token, decoded from the `scp` claim. */
19
+ scopes: string[];
20
+ /** The `owner` claim: changes if the character is transferred between accounts. */
21
+ ownerHash?: string;
22
+ /** When this record was last written, in epoch milliseconds. */
23
+ updatedAt: number;
24
+ /**
25
+ * Set when SSO rejected the refresh token as invalid. The manager stops
26
+ * contacting SSO for this character until it is added again.
27
+ */
28
+ revokedAt?: number;
29
+ }
30
+ /**
31
+ * Persistence contract for {@link StoredToken} records, keyed by character id.
32
+ *
33
+ * Implementations must return copies rather than shared references and must
34
+ * tolerate `get`/`delete` for ids they have never seen.
35
+ */
36
+ export interface ITokenStorage {
37
+ get(characterId: number): Promise<StoredToken | null>;
38
+ set(characterId: number, token: StoredToken): Promise<void>;
39
+ delete(characterId: number): Promise<void>;
40
+ list(): Promise<StoredToken[]>;
41
+ }
42
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,qEAAqE;IACrE,WAAW,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,aAAa,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,YAAY,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACtD,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;CAChC"}