@oneidentity/safeguard 8.0.1 → 8.0.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.
@@ -1,447 +0,0 @@
1
- //#region src/http/types.d.ts
2
- /**
3
- * Platform-agnostic HTTP client interface for the Safeguard SDK.
4
- */
5
- interface HttpRequestOptions {
6
- url: string;
7
- method: string;
8
- headers?: Record<string, string>;
9
- body?: string | Buffer | null;
10
- signal?: AbortSignal;
11
- timeout?: number;
12
- }
13
- interface HttpResponse {
14
- status: number;
15
- headers: Record<string, string>;
16
- body: string;
17
- }
18
- /**
19
- * Abstract HTTP client interface.
20
- * Implementations: NodeHttpClient (undici), BrowserHttpClient (fetch).
21
- */
22
- interface HttpClient {
23
- request(options: HttpRequestOptions): Promise<HttpResponse>;
24
- dispose?(): void;
25
- }
26
- //# sourceMappingURL=types.d.ts.map
27
- //#endregion
28
- //#region src/storage/types.d.ts
29
- /**
30
- * Interface for token/state storage backends.
31
- */
32
- interface StorageProvider {
33
- get(key: string): string | null;
34
- set(key: string, value: string): void;
35
- remove(key: string): void;
36
- clear(): void;
37
- }
38
- /** Well-known storage keys used by the SDK. */
39
- declare const StorageKeys: {
40
- readonly STATE: "safeguard_state";
41
- readonly CODE_VERIFIER: "safeguard_code_verifier";
42
- };
43
- //# sourceMappingURL=types.d.ts.map
44
- //#endregion
45
- //#region src/secret.d.ts
46
- /**
47
- * A wrapper that prevents accidental logging of sensitive values.
48
- *
49
- * - `toString()` returns "[REDACTED]"
50
- * - `toJSON()` returns "[REDACTED]"
51
- * - `console.log(secretValue)` prints "[REDACTED]"
52
- * - `.expose()` returns the raw value when intentionally needed
53
- */
54
- declare class SecretValue {
55
- #private;
56
- constructor(value: string);
57
- /** Returns the raw secret. Use only when you intentionally need the plaintext. */
58
- expose(): string;
59
- toString(): string;
60
- toJSON(): string;
61
- get [Symbol.toStringTag](): string;
62
- }
63
- //# sourceMappingURL=secret.d.ts.map
64
- //#endregion
65
- //#region src/auth/types.d.ts
66
- /**
67
- * Token set returned by authentication.
68
- */
69
- interface TokenSet {
70
- /** The Safeguard user access token (wrapped to prevent accidental logging). */
71
- accessToken: SecretValue;
72
- /** Token lifetime in seconds from when it was issued. */
73
- expiresIn?: number;
74
- /** Timestamp (ms since epoch) when the token was acquired. */
75
- acquiredAt: number;
76
- }
77
- /**
78
- * Auth strategy interface. All authentication methods implement this.
79
- */
80
- interface Auth {
81
- /**
82
- * Authenticate against the Safeguard RSTS and return a token set.
83
- * @param host - Appliance hostname
84
- * @param httpClient - HTTP client to use for requests
85
- * @param storage - Storage provider for persisting tokens/state
86
- */
87
- authenticate(host: string, httpClient: HttpClient, storage: StorageProvider): Promise<TokenSet>;
88
- /**
89
- * Refresh the token if possible. Returns new token set or null if refresh not supported.
90
- */
91
- refreshToken?(host: string, httpClient: HttpClient, storage: StorageProvider): Promise<TokenSet | null>;
92
- /** Human-readable description of this auth strategy (for logging). */
93
- readonly description: string;
94
- }
95
- //# sourceMappingURL=types.d.ts.map
96
- //#endregion
97
- //#region src/types.d.ts
98
- /**
99
- * Safeguard appliance service endpoints.
100
- */
101
- declare enum Service {
102
- CORE = "core",
103
- APPLIANCE = "appliance",
104
- NOTIFICATION = "notification",
105
- A2A = "a2a",
106
- EVENT = "event",
107
- RSTS = "RSTS",
108
- }
109
- /**
110
- * HTTP methods supported by the Safeguard API.
111
- */
112
- declare enum HttpMethod {
113
- GET = "GET",
114
- POST = "POST",
115
- PUT = "PUT",
116
- DELETE = "DELETE",
117
- PATCH = "PATCH",
118
- }
119
- /**
120
- * Full response from a Safeguard API call (returned when fullResponse: true).
121
- */
122
- interface SafeguardResponse<T = unknown> {
123
- data: T;
124
- status: number;
125
- headers: Record<string, string>;
126
- }
127
- /**
128
- * Options for individual API requests.
129
- */
130
- interface RequestOptions {
131
- /** Request body as JSON-serializable object. */
132
- json?: unknown;
133
- /** Raw request body. */
134
- body?: BodyInit | null;
135
- /** Additional HTTP headers. */
136
- headers?: Record<string, string>;
137
- /** URL query parameters. */
138
- query?: Record<string, string | number | boolean>;
139
- /** AbortSignal for request cancellation. */
140
- signal?: AbortSignal;
141
- /** Request timeout in milliseconds (overrides client default). */
142
- timeout?: number;
143
- /** If true, returns full response with status and headers. */
144
- fullResponse?: boolean;
145
- }
146
- /**
147
- * Options for constructing a SafeguardClient.
148
- */
149
- interface SafeguardClientOptions {
150
- /** Authentication strategy. */
151
- auth: Auth;
152
- /** Custom CA certificate (PEM string or Buffer). Node.js only. */
153
- ca?: string | Buffer;
154
- /** Whether to verify TLS certificates. Default: true. */
155
- verify?: boolean;
156
- /** Safeguard API version prefix. Default: 'v4'. */
157
- apiVersion?: string;
158
- /** Request timeout in milliseconds. Default: 300_000 (5 min). */
159
- timeout?: number;
160
- /** Auto-refresh tokens before expiry. Default: true. */
161
- autoRefresh?: boolean;
162
- }
163
- //# sourceMappingURL=types.d.ts.map
164
- //#endregion
165
- //#region src/errors.d.ts
166
- /**
167
- * Error hierarchy for the Safeguard SDK.
168
- *
169
- * SafeguardError
170
- * ├── ApiError (HTTP errors from Safeguard API)
171
- * │ ├── AuthenticationError (401)
172
- * │ ├── AuthorizationError (403)
173
- * │ └── NotFoundError (404)
174
- * ├── TransportError (Network/connection failures)
175
- * └── ConfigurationError (Invalid client options)
176
- */
177
- declare class SafeguardError extends Error {
178
- constructor(message: string, options?: ErrorOptions);
179
- }
180
- interface ApiErrorBody {
181
- Code?: string;
182
- Message?: string;
183
- InnerError?: {
184
- Message?: string;
185
- };
186
- [key: string]: unknown;
187
- }
188
- declare class ApiError extends SafeguardError {
189
- readonly status: number;
190
- readonly body: ApiErrorBody | null;
191
- constructor(message: string, status: number, body?: ApiErrorBody | null, options?: ErrorOptions);
192
- /**
193
- * Creates an appropriate ApiError subclass based on HTTP status code.
194
- */
195
- static fromResponse(status: number, body: string | ApiErrorBody | null): ApiError;
196
- private static parseBody;
197
- private static buildMessage;
198
- }
199
- declare class AuthenticationError extends ApiError {
200
- constructor(message: string, body?: ApiErrorBody | null, options?: ErrorOptions);
201
- }
202
- declare class AuthorizationError extends ApiError {
203
- constructor(message: string, body?: ApiErrorBody | null, options?: ErrorOptions);
204
- }
205
- declare class NotFoundError extends ApiError {
206
- constructor(message: string, body?: ApiErrorBody | null, options?: ErrorOptions);
207
- }
208
- declare class TransportError extends SafeguardError {
209
- constructor(message: string, options?: ErrorOptions);
210
- }
211
- declare class ConfigurationError extends SafeguardError {
212
- constructor(message: string, options?: ErrorOptions);
213
- }
214
- //# sourceMappingURL=errors.d.ts.map
215
- //#endregion
216
- //#region src/utils.d.ts
217
- /**
218
- * Builds the base URL for a Safeguard service endpoint.
219
- *
220
- * @example
221
- * buildServiceUrl('appliance.example.com', Service.CORE)
222
- * // => 'https://appliance.example.com/service/core/v4'
223
- */
224
- declare function buildServiceUrl(host: string, service: Service, apiVersion?: string): string;
225
- /**
226
- * Builds a full API URL including path and optional query parameters.
227
- *
228
- * @example
229
- * buildRequestUrl('appliance.example.com', Service.CORE, 'Users', { filter: 'Name eq "admin"' })
230
- * // => 'https://appliance.example.com/service/core/v4/Users?filter=Name+eq+%22admin%22'
231
- */
232
- declare function buildRequestUrl(host: string, service: Service, relativeUrl: string, query?: Record<string, string | number | boolean>, apiVersion?: string): string;
233
- /**
234
- * Encodes bytes to a URL-safe base64 string (no padding).
235
- */
236
- declare function base64UrlEncode(bytes: Uint8Array): string;
237
- /**
238
- * Generates a cryptographically random code verifier for PKCE.
239
- * Returns a 43-character base64url string (32 random bytes).
240
- */
241
- declare function generateCodeVerifier(): string;
242
- /**
243
- * Computes the S256 code challenge from a code verifier.
244
- * Uses Web Crypto API (available in Node 20+ and all modern browsers).
245
- */
246
- declare function generateCodeChallenge(verifier: string): Promise<string>;
247
- /**
248
- * Generates a random state parameter for OAuth flows.
249
- */
250
- declare function generateState(): string;
251
- /**
252
- * Extracts the `exp` claim from a JWT and returns expiresIn (seconds from now).
253
- * Returns undefined if the token is not a valid JWT or has no `exp` claim.
254
- */
255
- //#endregion
256
- //#region src/storage/memory.d.ts
257
- /**
258
- * In-memory storage provider. Default for Node.js environments.
259
- * Data does not persist across process restarts.
260
- */
261
- declare class MemoryStorage implements StorageProvider {
262
- #private;
263
- get(key: string): string | null;
264
- set(key: string, value: string): void;
265
- remove(key: string): void;
266
- clear(): void;
267
- }
268
- //# sourceMappingURL=memory.d.ts.map
269
- //#endregion
270
- //#region src/storage/session.d.ts
271
- /**
272
- * Browser sessionStorage adapter. Data persists for the browser tab lifetime.
273
- * Requires a DOM environment (browser or jsdom).
274
- */
275
- declare class BrowserSessionStorage implements StorageProvider {
276
- get(key: string): string | null;
277
- set(key: string, value: string): void;
278
- remove(key: string): void;
279
- clear(): void;
280
- }
281
- //# sourceMappingURL=session.d.ts.map
282
- //#endregion
283
- //#region src/http/browser.d.ts
284
- /**
285
- * Browser HTTP client using native fetch API.
286
- * No TLS configuration needed — browser handles certificates.
287
- */
288
- declare class BrowserHttpClient implements HttpClient {
289
- #private;
290
- constructor(options?: {
291
- credentials?: RequestCredentials;
292
- });
293
- request(options: HttpRequestOptions): Promise<HttpResponse>;
294
- }
295
- //# sourceMappingURL=browser.d.ts.map
296
- //#endregion
297
- //#region src/auth/password.d.ts
298
- interface PasswordAuthOptions {
299
- username: string;
300
- password: string;
301
- /** Identity provider name. Default: 'local'. */
302
- provider?: string;
303
- }
304
- /**
305
- * Authenticates using username/password via RSTS Resource Owner grant.
306
- */
307
- declare class PasswordAuth implements Auth {
308
- #private;
309
- constructor(options: PasswordAuthOptions);
310
- get description(): string;
311
- authenticate(host: string, httpClient: HttpClient, _storage: StorageProvider): Promise<TokenSet>;
312
- refreshToken(host: string, httpClient: HttpClient, storage: StorageProvider): Promise<TokenSet | null>;
313
- }
314
- //# sourceMappingURL=password.d.ts.map
315
- //#endregion
316
- //#region src/auth/pkce.d.ts
317
- interface PkceAuthOptions {
318
- /** OAuth redirect URI (must match RSTS configuration). */
319
- redirectUri: string;
320
- /** Identity provider name. Default: 'local'. */
321
- provider?: string;
322
- }
323
- /**
324
- * Authenticates using PKCE (Proof Key for Code Exchange) with browser redirect.
325
- * For browser environments where the user is redirected to RSTS login.
326
- */
327
- declare class PkceAuth implements Auth {
328
- #private;
329
- constructor(options: PkceAuthOptions);
330
- get description(): string;
331
- /**
332
- * Initiates the PKCE flow. If a stored authorization code exists (from callback),
333
- * exchanges it for a token. Otherwise, redirects to RSTS login.
334
- */
335
- authenticate(host: string, httpClient: HttpClient, storage: StorageProvider): Promise<TokenSet>;
336
- }
337
- //# sourceMappingURL=pkce.d.ts.map
338
- //#endregion
339
- //#region src/auth/pkce-callback.d.ts
340
- interface PkceCallbackResult {
341
- code: string;
342
- state: string;
343
- }
344
- /**
345
- * Parses the PKCE callback URL and stores the authorization code.
346
- * Call this on the callback/redirect page to complete the PKCE flow.
347
- *
348
- * This is the explicit replacement for the legacy `safeguardJsAccessTokenChecker.js`
349
- * script that ran as a side-effect on import.
350
- *
351
- * @param storage - StorageProvider to persist the code
352
- * @param url - The callback URL to parse (defaults to window.location.href)
353
- * @returns The parsed code and state, or null if not a valid callback
354
- */
355
- declare function handlePkceCallback(storage: StorageProvider, url?: string): PkceCallbackResult | null;
356
- //# sourceMappingURL=pkce-callback.d.ts.map
357
- //#endregion
358
- //#region src/auth/token.d.ts
359
- interface TokenAuthOptions {
360
- /** Pre-existing Safeguard access token. */
361
- accessToken: string;
362
- }
363
- /**
364
- * Uses a pre-existing access token. No authentication flow — the token is assumed valid.
365
- * Useful when tokens are obtained externally or for service-to-service scenarios.
366
- */
367
- declare class TokenAuth implements Auth {
368
- #private;
369
- constructor(options: TokenAuthOptions);
370
- get description(): string;
371
- authenticate(_host: string, _httpClient: HttpClient, _storage: StorageProvider): Promise<TokenSet>;
372
- }
373
- //# sourceMappingURL=token.d.ts.map
374
- //#endregion
375
- //#region src/auth/anonymous.d.ts
376
- /**
377
- * Anonymous authentication — no credentials.
378
- * Used for accessing public Safeguard endpoints (e.g., appliance status).
379
- */
380
- declare class AnonymousAuth implements Auth {
381
- get description(): string;
382
- authenticate(_host: string, _httpClient: HttpClient, _storage: StorageProvider): Promise<TokenSet>;
383
- }
384
- //# sourceMappingURL=anonymous.d.ts.map
385
- //#endregion
386
- //#region src/client.d.ts
387
- /**
388
- * Main entry point for the Safeguard SDK.
389
- * Instance-based — no global state. Multiple clients to different appliances are supported.
390
- */
391
- declare class SafeguardClient {
392
- #private;
393
- constructor(host: string, options: SafeguardClientOptions);
394
- /** The appliance hostname this client connects to. */
395
- get host(): string;
396
- /** The API version prefix (e.g. 'v4'). */
397
- get apiVersion(): string;
398
- /** Custom CA certificate, if provided. */
399
- get ca(): string | Buffer | undefined;
400
- /** Whether TLS verification is enabled. */
401
- get verify(): boolean;
402
- /** Whether the client has an active authenticated session. */
403
- get isConnected(): boolean;
404
- /**
405
- * Sets a custom StorageProvider (e.g., BrowserSessionStorage).
406
- * Must be called before connect().
407
- */
408
- setStorage(storage: StorageProvider): this;
409
- /**
410
- * Sets the HttpClient implementation. If not called, must be set before connect().
411
- * The factory pattern allows platform-specific client injection:
412
- * - Node: `new NodeHttpClient({ ca, rejectUnauthorized })`
413
- * - Browser: `new BrowserHttpClient()`
414
- */
415
- setHttpClient(httpClient: HttpClient): this;
416
- /**
417
- * Authenticate and establish a session.
418
- * @throws {AuthenticationError} if authentication fails
419
- * @throws {ConfigurationError} if httpClient not set
420
- */
421
- connect(): Promise<void>;
422
- /**
423
- * Disconnect — dispose HTTP client and clear token.
424
- */
425
- disconnect(): Promise<void>;
426
- /**
427
- * Returns seconds until the current access token expires, or -1 if unknown.
428
- */
429
- getAccessTokenLifetimeRemaining(): number;
430
- get<T = unknown>(service: Service, relativeUrl: string, options?: RequestOptions): Promise<T>;
431
- post<T = unknown>(service: Service, relativeUrl: string, options?: RequestOptions): Promise<T>;
432
- put<T = unknown>(service: Service, relativeUrl: string, options?: RequestOptions): Promise<T>;
433
- delete<T = unknown>(service: Service, relativeUrl: string, options?: RequestOptions): Promise<T>;
434
- patch<T = unknown>(service: Service, relativeUrl: string, options?: RequestOptions): Promise<T>;
435
- /**
436
- * Low-level request method. Convenience verbs delegate here.
437
- *
438
- * When `options.fullResponse` is true, returns SafeguardResponse<T> with status + headers.
439
- * Otherwise returns just the parsed response body as T.
440
- */
441
- invoke<T = unknown>(service: Service, method: HttpMethod, relativeUrl: string, options?: RequestOptions): Promise<T>;
442
- }
443
- //# sourceMappingURL=client.d.ts.map
444
-
445
- //#endregion
446
- export { AnonymousAuth, ApiError, type ApiErrorBody, type Auth, AuthenticationError, AuthorizationError, BrowserHttpClient, BrowserSessionStorage, ConfigurationError, type HttpClient, HttpMethod, type HttpRequestOptions, type HttpResponse, MemoryStorage, NotFoundError, PasswordAuth, type PasswordAuthOptions, PkceAuth, type PkceAuthOptions, type PkceCallbackResult, type RequestOptions, SafeguardClient, type SafeguardClientOptions, SafeguardError, type SafeguardResponse, SecretValue, Service, StorageKeys, type StorageProvider, TokenAuth, type TokenAuthOptions, type TokenSet, TransportError, base64UrlEncode, buildRequestUrl, buildServiceUrl, generateCodeChallenge, generateCodeVerifier, generateState, handlePkceCallback };
447
- //# sourceMappingURL=browser-Df-ljVNJ.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser-Df-ljVNJ.d.ts","names":[],"sources":["../src/http/types.ts","../src/storage/types.ts","../src/secret.ts","../src/auth/types.ts","../src/types.ts","../src/errors.ts","../src/utils.ts","../src/storage/memory.ts","../src/storage/session.ts","../src/http/browser.ts","../src/auth/password.ts","../src/auth/pkce.ts","../src/auth/pkce-callback.ts","../src/auth/token.ts","../src/auth/anonymous.ts","../src/client.ts"],"mappings":";;AAIA;;AAGY,UAHK,kBAAA,CAGL;KACM,EAAA,MAAA;QACP,EAAA,MAAA;EAAW,OAAA,CAAA,EAFV,MAEU,CAAA,MAAA,EAAA,MAAA,CAAA;EAIL,IAAA,CAAA,EAAA,MAAA,GALC,MAKW,GAAA,IAElB;EAqBM,MAAA,CAAA,EA3BN,WA2BgB;EAAA,OAAA,CAAA,EAAA,MAAA;;AACqB,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qE,CXjGrE,CAAA;EAAA,GAAA,CAAA,IAAA,OAAA,CAAA,CAAA,OAAA,EWqGG,OXrGH,EAAA,WAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EWqG2C,cXrG3C,CAAA,EWqG4D,OXrG5D,CWqGoE,CXrGpE,CAAA;QAItB,CAAA,IAAA,OAAA,CAAA,CAAA,OAAA,EWqG4B,OXrG5B,EAAA,WAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EWqGoE,cXrGpE,CAAA,EWqGqF,OXrGrF,CWqG6F,CXrG7F,CAAA;OAEG,CAAA,IAAA,OAAA,CAAA,CAAA,OAAA,EWuGwB,OXvGxB,EAAA,WAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EWuGgE,cXvGhE,CAAA,EWuGiF,OXvGjF,CWuGyF,CXvGzF,CAAA;;;AAIU;AAUtB;;;QAIgB,CAAA,IAAA,OAAA,CAAA,CAAA,OAAA,EWkGH,OXlGG,EAAA,MAAA,EWmGJ,UXnGI,EAAA,WAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EWqGF,cXrGE,CAAA,EWsGX,OXtGW,CWsGH,CXtGG,CAAA;AAAM"}
@@ -1,185 +0,0 @@
1
- import { HubConnection } from "@microsoft/signalr";
2
-
3
- //#region src/events/types.d.ts
4
- /**
5
- * Event listener connection states.
6
- */
7
- type EventListenerState = 'starting' | 'connected' | 'disconnected' | 'reconnecting' | 'stopped';
8
- /**
9
- * Handler for Safeguard events (NotifyEventAsync messages from SignalR).
10
- */
11
- type EventHandler = (event: SafeguardEvent) => void;
12
- /**
13
- * Handler for state change notifications.
14
- */
15
- type StateChangeHandler = (state: EventListenerState) => void;
16
- /**
17
- * A Safeguard event as delivered by SignalR.
18
- */
19
- interface SafeguardEvent {
20
- EventName: string;
21
- [key: string]: unknown;
22
- }
23
- /**
24
- * Options for persistent event listeners.
25
- */
26
- interface PersistentListenerOptions {
27
- /** Delay between reconnection attempts in milliseconds. Default: 5000. */
28
- retryIntervalMs?: number;
29
- /** Maximum number of reconnect attempts before giving up. Default: unlimited. */
30
- maxRetries?: number;
31
- }
32
- //# sourceMappingURL=types.d.ts.map
33
- //#endregion
34
- //#region src/events/listener.d.ts
35
- /**
36
- * One-shot event listener wrapping a SignalR HubConnection.
37
- * For persistent auto-reconnect behavior, use PersistentSafeguardEventListener.
38
- */
39
- declare class SafeguardEventListener {
40
- #private;
41
- constructor(connection: HubConnection);
42
- /** Current connection state. */
43
- get state(): EventListenerState;
44
- /**
45
- * Register an event handler for Safeguard notifications.
46
- */
47
- on(_method: 'NotifyEventAsync', handler: EventHandler): this;
48
- /**
49
- * Start the SignalR connection.
50
- */
51
- start(): Promise<void>;
52
- /**
53
- * Stop the SignalR connection.
54
- */
55
- stop(): Promise<void>;
56
- }
57
- //# sourceMappingURL=listener.d.ts.map
58
- //#endregion
59
- //#region src/http/types.d.ts
60
- /**
61
- * Platform-agnostic HTTP client interface for the Safeguard SDK.
62
- */
63
- interface HttpRequestOptions {
64
- url: string;
65
- method: string;
66
- headers?: Record<string, string>;
67
- body?: string | Buffer | null;
68
- signal?: AbortSignal;
69
- timeout?: number;
70
- }
71
- interface HttpResponse {
72
- status: number;
73
- headers: Record<string, string>;
74
- body: string;
75
- }
76
- /**
77
- * Abstract HTTP client interface.
78
- * Implementations: NodeHttpClient (undici), BrowserHttpClient (fetch).
79
- */
80
- interface HttpClient {
81
- request(options: HttpRequestOptions): Promise<HttpResponse>;
82
- dispose?(): void;
83
- }
84
- //# sourceMappingURL=types.d.ts.map
85
- //#endregion
86
- //#region src/storage/types.d.ts
87
- /**
88
- * Interface for token/state storage backends.
89
- */
90
- interface StorageProvider {
91
- get(key: string): string | null;
92
- set(key: string, value: string): void;
93
- remove(key: string): void;
94
- clear(): void;
95
- }
96
- /** Well-known storage keys used by the SDK. */
97
- //#endregion
98
- //#region src/secret.d.ts
99
- /**
100
- * A wrapper that prevents accidental logging of sensitive values.
101
- *
102
- * - `toString()` returns "[REDACTED]"
103
- * - `toJSON()` returns "[REDACTED]"
104
- * - `console.log(secretValue)` prints "[REDACTED]"
105
- * - `.expose()` returns the raw value when intentionally needed
106
- */
107
- declare class SecretValue {
108
- #private;
109
- constructor(value: string);
110
- /** Returns the raw secret. Use only when you intentionally need the plaintext. */
111
- expose(): string;
112
- toString(): string;
113
- toJSON(): string;
114
- get [Symbol.toStringTag](): string;
115
- }
116
- //# sourceMappingURL=secret.d.ts.map
117
- //#endregion
118
- //#region src/auth/types.d.ts
119
- /**
120
- * Token set returned by authentication.
121
- */
122
- interface TokenSet {
123
- /** The Safeguard user access token (wrapped to prevent accidental logging). */
124
- accessToken: SecretValue;
125
- /** Token lifetime in seconds from when it was issued. */
126
- expiresIn?: number;
127
- /** Timestamp (ms since epoch) when the token was acquired. */
128
- acquiredAt: number;
129
- }
130
- /**
131
- * Auth strategy interface. All authentication methods implement this.
132
- */
133
- interface Auth {
134
- /**
135
- * Authenticate against the Safeguard RSTS and return a token set.
136
- * @param host - Appliance hostname
137
- * @param httpClient - HTTP client to use for requests
138
- * @param storage - Storage provider for persisting tokens/state
139
- */
140
- authenticate(host: string, httpClient: HttpClient, storage: StorageProvider): Promise<TokenSet>;
141
- /**
142
- * Refresh the token if possible. Returns new token set or null if refresh not supported.
143
- */
144
- refreshToken?(host: string, httpClient: HttpClient, storage: StorageProvider): Promise<TokenSet | null>;
145
- /** Human-readable description of this auth strategy (for logging). */
146
- readonly description: string;
147
- }
148
- //# sourceMappingURL=types.d.ts.map
149
- //#endregion
150
- //#region src/events/persistent.d.ts
151
- /**
152
- * Persistent event listener with automatic reconnection and token refresh.
153
- *
154
- * Wraps SignalR's built-in `withAutomaticReconnect()` AND adds:
155
- * - Token refresh on reconnect (re-authenticates if needed)
156
- * - State change event notifications
157
- * - Manual `stop()` that prevents further auto-reconnect
158
- */
159
- declare class PersistentSafeguardEventListener {
160
- #private;
161
- constructor(connection: HubConnection, auth: Auth, host: string, httpClient: HttpClient, storage: StorageProvider, options?: PersistentListenerOptions, tokenSet?: TokenSet);
162
- /** Current connection state. */
163
- get state(): EventListenerState;
164
- /**
165
- * Register an event handler for Safeguard notifications.
166
- */
167
- on(_method: 'NotifyEventAsync', handler: EventHandler): this;
168
- /**
169
- * Register a state change handler.
170
- */
171
- onStateChange(handler: StateChangeHandler): this;
172
- /**
173
- * Start the persistent connection.
174
- */
175
- start(): Promise<void>;
176
- /**
177
- * Stop the connection. Prevents auto-reconnect.
178
- */
179
- stop(): Promise<void>;
180
- }
181
- //# sourceMappingURL=persistent.d.ts.map
182
-
183
- //#endregion
184
- export { type EventHandler, type EventListenerState, type PersistentListenerOptions, PersistentSafeguardEventListener, type SafeguardEvent, SafeguardEventListener, type StateChangeHandler };
185
- //# sourceMappingURL=events-RcqBZBsR.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events-RcqBZBsR.d.ts","names":[],"sources":["../src/events/types.ts","../src/events/listener.ts","../src/http/types.ts","../src/storage/types.ts","../src/secret.ts","../src/auth/types.ts","../src/events/persistent.ts"],"mappings":";;;;;;AAGY,KAAA,kBAAA,GAAkB,UAAA,GAAA,WAAA,GAAA,cAAA,GAAA,cAAA,GAAA,SAAA;AAU9B;AAKA;AAKA;AAQiB,KAlBL,YAAA,GAkBK,CAAA,KAAyB,EAlBP,cAkBO,EAAA,GAAA,IAAA;;;;ACxB7B,KDWD,kBAAA,GCXuB,CAAA,KAAA,EDWM,kBCXN,EAAA,GAAA,IAAA;;;;AAoCQ,UDpB1B,cAAA,CCoB0B;WAQ1B,EAAA,MAAA;MASD,EAAA,MAAA,CAAA,EAAA,OAAA;AAAO;;;;ACxDN,UF2BA,yBAAA,CE3BkB;EAAA;iBAGvB,CAAA,EAAA,MAAA;;YAED,CAAA,EAAA,MAAA;AAAW;AAItB;;;;AFVA;AAUA;AAKA;AAKiB,cChBJ,sBAAA,CDgBkB;EAQd,CAAA,OAAA;0BCnBS;;eAwBX;EA7BF;;;KA6BE,OAAA,EAAA,kBAAA,EAAA,OAAA,EAO4B,YAP5B,CAAA,EAAA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