@mission_sciences/provider-sdk 0.2.0 → 0.3.0-dev.6e896da
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/README.md +1 -40
- package/dist/adapters/react/index.d.ts +3 -0
- package/dist/adapters/react/index.d.ts.map +1 -0
- package/dist/adapters/react/index.js +75 -0
- package/dist/adapters/react/index.js.map +1 -0
- package/dist/adapters/react/useMarketplaceSession.d.ts +30 -0
- package/dist/adapters/react/useMarketplaceSession.d.ts.map +1 -0
- package/dist/adapters/vue/index.d.ts +3 -0
- package/dist/adapters/vue/index.d.ts.map +1 -0
- package/dist/adapters/vue/index.js +56 -0
- package/dist/adapters/vue/index.js.map +1 -0
- package/dist/adapters/vue/useMarketplaceSession.d.ts +78 -0
- package/dist/adapters/vue/useMarketplaceSession.d.ts.map +1 -0
- package/dist/core/HeartbeatManager.d.ts +43 -0
- package/dist/core/HeartbeatManager.d.ts.map +1 -0
- package/dist/core/JWKSValidator.d.ts +26 -0
- package/dist/core/JWKSValidator.d.ts.map +1 -0
- package/dist/core/JWTParser.d.ts +46 -0
- package/dist/core/JWTParser.d.ts.map +1 -0
- package/dist/core/MarketplaceSDK.d.ts +117 -0
- package/dist/core/MarketplaceSDK.d.ts.map +1 -0
- package/dist/core/PurchaseStateManager.d.ts +28 -0
- package/dist/core/PurchaseStateManager.d.ts.map +1 -0
- package/dist/core/TabSyncManager.d.ts +49 -0
- package/dist/core/TabSyncManager.d.ts.map +1 -0
- package/dist/core/TimerManager.d.ts +55 -0
- package/dist/core/TimerManager.d.ts.map +1 -0
- package/dist/index.d.ts +23 -769
- package/dist/index.d.ts.map +1 -0
- package/dist/marketplace-sdk.es.js +307 -4
- package/dist/marketplace-sdk.es.js.map +1 -1
- package/dist/marketplace-sdk.umd.js +1 -1
- package/dist/marketplace-sdk.umd.js.map +1 -1
- package/dist/styles/theme.d.ts +89 -0
- package/dist/styles/theme.d.ts.map +1 -0
- package/dist/types/index.d.ts +287 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/ui/PurchaseModal.d.ts +30 -0
- package/dist/ui/PurchaseModal.d.ts.map +1 -0
- package/dist/ui/SessionHeader.d.ts +46 -0
- package/dist/ui/SessionHeader.d.ts.map +1 -0
- package/dist/ui/WarningModal.d.ts +39 -0
- package/dist/ui/WarningModal.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +25 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/url.d.ts +12 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/package.json +17 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,769 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Heartbeat Manager for active session tracking
|
|
26
|
-
* Phase 2 Feature - Sends periodic heartbeats to backend
|
|
27
|
-
*/
|
|
28
|
-
export declare class HeartbeatManager {
|
|
29
|
-
private sessionId;
|
|
30
|
-
private apiEndpoint;
|
|
31
|
-
private token;
|
|
32
|
-
private onSync?;
|
|
33
|
-
private onError?;
|
|
34
|
-
private intervalId;
|
|
35
|
-
private heartbeatInterval;
|
|
36
|
-
private failureCount;
|
|
37
|
-
private maxFailures;
|
|
38
|
-
private isEnabled;
|
|
39
|
-
private logger;
|
|
40
|
-
constructor(sessionId: string, apiEndpoint: string, token: string, onSync?: ((remainingSeconds: number) => void) | undefined, onError?: ((error: Error) => void) | undefined, heartbeatIntervalSeconds?: number, debug?: boolean);
|
|
41
|
-
/**
|
|
42
|
-
* Start sending heartbeats
|
|
43
|
-
*/
|
|
44
|
-
start(): void;
|
|
45
|
-
/**
|
|
46
|
-
* Stop sending heartbeats
|
|
47
|
-
*/
|
|
48
|
-
stop(): void;
|
|
49
|
-
/**
|
|
50
|
-
* Send a single heartbeat to backend
|
|
51
|
-
*/
|
|
52
|
-
private sendHeartbeat;
|
|
53
|
-
/**
|
|
54
|
-
* Check if heartbeat is running
|
|
55
|
-
*/
|
|
56
|
-
isRunning(): boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Get failure count
|
|
59
|
-
*/
|
|
60
|
-
getFailureCount(): number;
|
|
61
|
-
/**
|
|
62
|
-
* Update heartbeat interval
|
|
63
|
-
*/
|
|
64
|
-
updateInterval(seconds: number): void;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Check if code is running in browser environment
|
|
69
|
-
*/
|
|
70
|
-
export declare function isBrowser(): boolean;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* JWKS Key
|
|
74
|
-
*/
|
|
75
|
-
export declare interface JWKSKey {
|
|
76
|
-
kty: string;
|
|
77
|
-
use: string;
|
|
78
|
-
kid: string;
|
|
79
|
-
alg: string;
|
|
80
|
-
n: string;
|
|
81
|
-
e: string;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* JWKS Response
|
|
86
|
-
*/
|
|
87
|
-
export declare interface JWKSResponse {
|
|
88
|
-
keys: JWKSKey[];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* JWKS Validator for RS256 JWT signature verification
|
|
93
|
-
* Uses jose library for browser and Node.js compatibility
|
|
94
|
-
*/
|
|
95
|
-
export declare class JWKSValidator {
|
|
96
|
-
private jwksUri;
|
|
97
|
-
private logger;
|
|
98
|
-
private jwks;
|
|
99
|
-
constructor(jwksUri: string, debug?: boolean);
|
|
100
|
-
/**
|
|
101
|
-
* Verify JWT signature using JWKS public key
|
|
102
|
-
* @param token - JWT token to verify
|
|
103
|
-
* @param expectedIssuer - Expected issuer (default: 'generalwisdom.com')
|
|
104
|
-
* @param expectedApplicationId - Optional application ID to validate
|
|
105
|
-
* @returns Decoded and verified JWT claims
|
|
106
|
-
*/
|
|
107
|
-
verify(token: string, expectedIssuer?: string, expectedApplicationId?: string): Promise<JWTClaims>;
|
|
108
|
-
/**
|
|
109
|
-
* Update JWKS URI
|
|
110
|
-
* @param jwksUri - New JWKS URI
|
|
111
|
-
*/
|
|
112
|
-
updateJwksUri(jwksUri: string): void;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* JWT Claims (raw payload from token)
|
|
117
|
-
*/
|
|
118
|
-
export declare interface JWTClaims {
|
|
119
|
-
sessionId: string;
|
|
120
|
-
applicationId: string;
|
|
121
|
-
userId: string;
|
|
122
|
-
orgId: string;
|
|
123
|
-
startTime: number;
|
|
124
|
-
durationMinutes: number;
|
|
125
|
-
iat: number;
|
|
126
|
-
exp: number;
|
|
127
|
-
iss: string;
|
|
128
|
-
sub: string;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* JWT Header
|
|
133
|
-
*/
|
|
134
|
-
export declare interface JWTHeader {
|
|
135
|
-
alg: string;
|
|
136
|
-
typ: string;
|
|
137
|
-
kid: string;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* JWT Parser for client-side token decoding
|
|
142
|
-
* Note: Does NOT verify signature - use JWKSValidator for verification
|
|
143
|
-
*/
|
|
144
|
-
export declare class JWTParser {
|
|
145
|
-
/**
|
|
146
|
-
* Decode JWT payload without verification
|
|
147
|
-
* @param token - JWT token string
|
|
148
|
-
* @returns Decoded payload
|
|
149
|
-
*/
|
|
150
|
-
static decode(token: string): JWTClaims;
|
|
151
|
-
/**
|
|
152
|
-
* Decode JWT header
|
|
153
|
-
* @param token - JWT token string
|
|
154
|
-
* @returns Decoded header
|
|
155
|
-
*/
|
|
156
|
-
static decodeHeader(token: string): JWTHeader;
|
|
157
|
-
/**
|
|
158
|
-
* Extract specific claim from JWT
|
|
159
|
-
* @param token - JWT token string
|
|
160
|
-
* @param claim - Claim name to extract
|
|
161
|
-
* @returns Claim value
|
|
162
|
-
*/
|
|
163
|
-
static extractClaim<T = any>(token: string, claim: string): T;
|
|
164
|
-
/**
|
|
165
|
-
* Check if JWT is expired (client-side only, not authoritative)
|
|
166
|
-
* @param token - JWT token string
|
|
167
|
-
* @returns True if token is expired
|
|
168
|
-
*/
|
|
169
|
-
static isExpired(token: string): boolean;
|
|
170
|
-
/**
|
|
171
|
-
* Get time remaining until expiration
|
|
172
|
-
* @param token - JWT token string
|
|
173
|
-
* @returns Seconds remaining (0 if expired)
|
|
174
|
-
*/
|
|
175
|
-
static getTimeRemaining(token: string): number;
|
|
176
|
-
/**
|
|
177
|
-
* Base64 URL decode
|
|
178
|
-
* @param str - Base64 URL encoded string
|
|
179
|
-
* @returns Decoded string
|
|
180
|
-
*/
|
|
181
|
-
private static base64UrlDecode;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Light theme matching gw-spa design system
|
|
186
|
-
*/
|
|
187
|
-
export declare const lightTheme: Theme;
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Simple logger with debug mode support
|
|
191
|
-
*/
|
|
192
|
-
export declare class Logger {
|
|
193
|
-
private debug;
|
|
194
|
-
private prefix;
|
|
195
|
-
constructor(debug?: boolean, prefix?: string);
|
|
196
|
-
/**
|
|
197
|
-
* Log debug message (only if debug enabled)
|
|
198
|
-
*/
|
|
199
|
-
log(...args: any[]): void;
|
|
200
|
-
/**
|
|
201
|
-
* Log info message (only if debug enabled)
|
|
202
|
-
*/
|
|
203
|
-
info(...args: any[]): void;
|
|
204
|
-
/**
|
|
205
|
-
* Log warning message (always shown)
|
|
206
|
-
*/
|
|
207
|
-
warn(...args: any[]): void;
|
|
208
|
-
/**
|
|
209
|
-
* Log error message (always shown)
|
|
210
|
-
*/
|
|
211
|
-
error(...args: any[]): void;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Marketplace SDK with Phase 2 Features
|
|
216
|
-
* - Heartbeat system
|
|
217
|
-
* - Multi-tab synchronization
|
|
218
|
-
* - Visibility API integration
|
|
219
|
-
* - Session extension/completion
|
|
220
|
-
* - Backend validation
|
|
221
|
-
*/
|
|
222
|
-
declare class MarketplaceSDK {
|
|
223
|
-
private config;
|
|
224
|
-
private validator;
|
|
225
|
-
private timer;
|
|
226
|
-
private heartbeat;
|
|
227
|
-
private tabSync;
|
|
228
|
-
private modal;
|
|
229
|
-
private logger;
|
|
230
|
-
private events;
|
|
231
|
-
private sessionData;
|
|
232
|
-
private jwtToken;
|
|
233
|
-
private endReason;
|
|
234
|
-
constructor(config: SDKConfig);
|
|
235
|
-
/**
|
|
236
|
-
* Register event handlers
|
|
237
|
-
*/
|
|
238
|
-
on<K extends keyof SDKEvents>(event: K, handler: SDKEvents[K]): void;
|
|
239
|
-
/**
|
|
240
|
-
* Execute a lifecycle hook with timeout
|
|
241
|
-
*/
|
|
242
|
-
private executeHook;
|
|
243
|
-
/**
|
|
244
|
-
* Calculate actual session duration in minutes
|
|
245
|
-
*/
|
|
246
|
-
private calculateActualDuration;
|
|
247
|
-
/**
|
|
248
|
-
* Initialize SDK and validate session
|
|
249
|
-
*/
|
|
250
|
-
initialize(): Promise<SessionData>;
|
|
251
|
-
/**
|
|
252
|
-
* Phase 2: Validate JWT with backend
|
|
253
|
-
*/
|
|
254
|
-
private validateWithBackend;
|
|
255
|
-
/**
|
|
256
|
-
* Phase 2: Handle tab sync messages
|
|
257
|
-
*/
|
|
258
|
-
private handleTabSyncMessage;
|
|
259
|
-
/**
|
|
260
|
-
* Phase 2: Initialize Visibility API handling
|
|
261
|
-
*/
|
|
262
|
-
private initializeVisibilityHandling;
|
|
263
|
-
/**
|
|
264
|
-
* Start session timer manually
|
|
265
|
-
*/
|
|
266
|
-
startTimer(): void;
|
|
267
|
-
/**
|
|
268
|
-
* Pause session timer
|
|
269
|
-
*/
|
|
270
|
-
pauseTimer(): void;
|
|
271
|
-
/**
|
|
272
|
-
* Resume session timer
|
|
273
|
-
*/
|
|
274
|
-
resumeTimer(): void;
|
|
275
|
-
/**
|
|
276
|
-
* Phase 2: Extend session
|
|
277
|
-
*/
|
|
278
|
-
extendSession(additionalMinutes: number): Promise<void>;
|
|
279
|
-
/**
|
|
280
|
-
* Phase 2: Complete session
|
|
281
|
-
*/
|
|
282
|
-
completeSession(actualUsageMinutes?: number): Promise<void>;
|
|
283
|
-
/**
|
|
284
|
-
* End session
|
|
285
|
-
*/
|
|
286
|
-
endSession(): Promise<void>;
|
|
287
|
-
/**
|
|
288
|
-
* Show warning modal
|
|
289
|
-
*/
|
|
290
|
-
private showWarningModal;
|
|
291
|
-
/**
|
|
292
|
-
* Get current session data
|
|
293
|
-
*/
|
|
294
|
-
getSessionData(): SessionData | null;
|
|
295
|
-
/**
|
|
296
|
-
* Get remaining time
|
|
297
|
-
*/
|
|
298
|
-
getRemainingTime(): number;
|
|
299
|
-
/**
|
|
300
|
-
* Get formatted time (MM:SS)
|
|
301
|
-
*/
|
|
302
|
-
getFormattedTime(): string;
|
|
303
|
-
/**
|
|
304
|
-
* Get formatted time with hours (HH:MM:SS)
|
|
305
|
-
*/
|
|
306
|
-
getFormattedTimeWithHours(): string;
|
|
307
|
-
/**
|
|
308
|
-
* Check if timer is running
|
|
309
|
-
*/
|
|
310
|
-
isTimerRunning(): boolean;
|
|
311
|
-
/**
|
|
312
|
-
* Cleanup and destroy SDK instance
|
|
313
|
-
*/
|
|
314
|
-
destroy(): void;
|
|
315
|
-
}
|
|
316
|
-
export { MarketplaceSDK }
|
|
317
|
-
export default MarketplaceSDK;
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Modal styling options (Legacy - prefer using theme)
|
|
321
|
-
* @deprecated Use theme configuration from src/styles/theme.ts instead
|
|
322
|
-
*/
|
|
323
|
-
export declare interface ModalStyles {
|
|
324
|
-
backgroundColor: string;
|
|
325
|
-
textColor: string;
|
|
326
|
-
primaryColor: string;
|
|
327
|
-
borderRadius: string;
|
|
328
|
-
fontFamily: string;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* SDK Configuration
|
|
333
|
-
*/
|
|
334
|
-
export declare interface SDKConfig {
|
|
335
|
-
/** JWKS endpoint URL (default: https://api.generalwisdom.com/.well-known/jwks.json) */
|
|
336
|
-
jwksUri?: string;
|
|
337
|
-
/** URL query parameter name containing the JWT (default: 'gwSession') */
|
|
338
|
-
jwtParamName?: string;
|
|
339
|
-
/** API endpoint for backend integration (Phase 2) */
|
|
340
|
-
apiEndpoint?: string;
|
|
341
|
-
/** Enable debug logging */
|
|
342
|
-
debug?: boolean;
|
|
343
|
-
/** Auto-start timer after initialization */
|
|
344
|
-
autoStart?: boolean;
|
|
345
|
-
/** Warning threshold in seconds (default: 300 = 5 minutes) */
|
|
346
|
-
warningThresholdSeconds?: number;
|
|
347
|
-
/** Custom styling for warning modal (Legacy - prefer using themeMode) */
|
|
348
|
-
customStyles?: Partial<ModalStyles>;
|
|
349
|
-
/** Theme mode for modal styling (default: 'light') */
|
|
350
|
-
themeMode?: ThemeMode;
|
|
351
|
-
/** Application ID for validation */
|
|
352
|
-
applicationId?: string;
|
|
353
|
-
/** Marketplace URL for redirects (default: https://d3p2yqofgy75sz.cloudfront.net/) */
|
|
354
|
-
marketplaceUrl?: string;
|
|
355
|
-
/** Enable heartbeat system (default: false) */
|
|
356
|
-
enableHeartbeat?: boolean;
|
|
357
|
-
/** Heartbeat interval in seconds (default: 30) */
|
|
358
|
-
heartbeatIntervalSeconds?: number;
|
|
359
|
-
/** Enable multi-tab synchronization (default: false) */
|
|
360
|
-
enableTabSync?: boolean;
|
|
361
|
-
/** Pause timer when tab is hidden (default: false) */
|
|
362
|
-
pauseOnHidden?: boolean;
|
|
363
|
-
/** Use backend validation instead of JWKS (default: false) */
|
|
364
|
-
useBackendValidation?: boolean;
|
|
365
|
-
/** Optional hooks for synchronizing app auth state with marketplace sessions */
|
|
366
|
-
hooks?: SessionLifecycleHooks;
|
|
367
|
-
/** Hook execution timeout in milliseconds (default: 5000) */
|
|
368
|
-
hookTimeoutMs?: number;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Custom SDK Error
|
|
373
|
-
*/
|
|
374
|
-
export declare class SDKError extends Error {
|
|
375
|
-
code: string;
|
|
376
|
-
statusCode?: number | undefined;
|
|
377
|
-
constructor(message: string, code: string, statusCode?: number | undefined);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* SDK Event Handlers
|
|
382
|
-
*/
|
|
383
|
-
export declare interface SDKEvents {
|
|
384
|
-
/** Called when session successfully initialized */
|
|
385
|
-
onSessionStart: (data: SessionData) => void;
|
|
386
|
-
/** Called when warning threshold reached */
|
|
387
|
-
onSessionWarning: (data: {
|
|
388
|
-
remainingSeconds: number;
|
|
389
|
-
}) => void;
|
|
390
|
-
/** Called when session expires or is ended */
|
|
391
|
-
onSessionEnd: () => void;
|
|
392
|
-
/** Called on any error */
|
|
393
|
-
onError: (error: Error) => void;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Session Data extracted from JWT
|
|
398
|
-
*/
|
|
399
|
-
export declare interface SessionData {
|
|
400
|
-
/** Unique session UUID */
|
|
401
|
-
sessionId: string;
|
|
402
|
-
/** Application ID */
|
|
403
|
-
applicationId: string;
|
|
404
|
-
/** User ID */
|
|
405
|
-
userId: string;
|
|
406
|
-
/** Organization ID */
|
|
407
|
-
orgId: string;
|
|
408
|
-
/** Session start time (Unix timestamp seconds) */
|
|
409
|
-
startTime: number;
|
|
410
|
-
/** Session duration in minutes */
|
|
411
|
-
durationMinutes: number;
|
|
412
|
-
/** Issued at timestamp (Unix seconds) */
|
|
413
|
-
iat: number;
|
|
414
|
-
/** Expiration timestamp (Unix seconds) */
|
|
415
|
-
exp: number;
|
|
416
|
-
/** Issuer */
|
|
417
|
-
iss: string;
|
|
418
|
-
/** Subject (user ID) */
|
|
419
|
-
sub: string;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
export declare interface SessionEndContext {
|
|
423
|
-
/** Unique session UUID */
|
|
424
|
-
sessionId: string;
|
|
425
|
-
/** User ID */
|
|
426
|
-
userId: string;
|
|
427
|
-
/** Reason for session end */
|
|
428
|
-
reason: 'expired' | 'manual' | 'error';
|
|
429
|
-
/** Actual session duration in minutes (if available) */
|
|
430
|
-
actualDurationMinutes?: number;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
export declare interface SessionExtendContext {
|
|
434
|
-
/** Unique session UUID */
|
|
435
|
-
sessionId: string;
|
|
436
|
-
/** User ID */
|
|
437
|
-
userId: string;
|
|
438
|
-
/** Additional minutes added to session */
|
|
439
|
-
additionalMinutes: number;
|
|
440
|
-
/** New expiration timestamp (Unix seconds) */
|
|
441
|
-
newExpiresAt: number;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* Session Header Component
|
|
446
|
-
* Compact header widget showing session timer with extend/end controls
|
|
447
|
-
*/
|
|
448
|
-
export declare class SessionHeader {
|
|
449
|
-
private container;
|
|
450
|
-
private theme;
|
|
451
|
-
private updateInterval;
|
|
452
|
-
private timeDisplay;
|
|
453
|
-
private getTimeCallback;
|
|
454
|
-
private onExtendCallback;
|
|
455
|
-
private onEndCallback;
|
|
456
|
-
private mounted;
|
|
457
|
-
constructor(themeMode?: ThemeMode);
|
|
458
|
-
private detectDarkMode;
|
|
459
|
-
/**
|
|
460
|
-
* Mount the session header to a DOM element
|
|
461
|
-
* @param targetElement - Element to mount to (or selector string)
|
|
462
|
-
* @param options - Configuration options
|
|
463
|
-
*/
|
|
464
|
-
mount(targetElement: HTMLElement | string, options: {
|
|
465
|
-
getTime: () => string;
|
|
466
|
-
onExtend?: () => void;
|
|
467
|
-
onEnd?: () => void;
|
|
468
|
-
position?: 'left' | 'center' | 'right';
|
|
469
|
-
}): void;
|
|
470
|
-
/**
|
|
471
|
-
* Start updating the time display
|
|
472
|
-
*/
|
|
473
|
-
private startUpdating;
|
|
474
|
-
/**
|
|
475
|
-
* Unmount and cleanup the session header
|
|
476
|
-
*/
|
|
477
|
-
unmount(): void;
|
|
478
|
-
/**
|
|
479
|
-
* Check if component is mounted
|
|
480
|
-
*/
|
|
481
|
-
isMounted(): boolean;
|
|
482
|
-
/**
|
|
483
|
-
* Update the theme
|
|
484
|
-
*/
|
|
485
|
-
updateTheme(themeMode: ThemeMode): void;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Session Lifecycle Hooks
|
|
490
|
-
* Optional callbacks that allow applications to synchronize their auth state with marketplace sessions
|
|
491
|
-
*/
|
|
492
|
-
export declare interface SessionLifecycleHooks {
|
|
493
|
-
/**
|
|
494
|
-
* Called after JWT validation succeeds but before session timer starts
|
|
495
|
-
* Use to: Auto-login user to your app's auth system
|
|
496
|
-
* Note: Hook failure will prevent session from starting
|
|
497
|
-
*/
|
|
498
|
-
onSessionStart?: (context: SessionStartContext) => Promise<void> | void;
|
|
499
|
-
/**
|
|
500
|
-
* Called when session expires or is manually ended, before redirect
|
|
501
|
-
* Use to: Force logout user from your app's auth system
|
|
502
|
-
* Note: Hook failure will be logged but won't prevent session end
|
|
503
|
-
*/
|
|
504
|
-
onSessionEnd?: (context: SessionEndContext) => Promise<void> | void;
|
|
505
|
-
/**
|
|
506
|
-
* Called when session extension succeeds
|
|
507
|
-
* Use to: Refresh app auth tokens if needed
|
|
508
|
-
*/
|
|
509
|
-
onSessionExtend?: (context: SessionExtendContext) => Promise<void> | void;
|
|
510
|
-
/**
|
|
511
|
-
* Called before session warning modal is shown
|
|
512
|
-
* Use to: Prepare user for session expiration
|
|
513
|
-
*/
|
|
514
|
-
onSessionWarning?: (context: SessionWarningContext) => Promise<void> | void;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* Session Lifecycle Hook Contexts
|
|
519
|
-
*/
|
|
520
|
-
export declare interface SessionStartContext {
|
|
521
|
-
/** Unique session UUID */
|
|
522
|
-
sessionId: string;
|
|
523
|
-
/** User ID from JWT */
|
|
524
|
-
userId: string;
|
|
525
|
-
/** User email (if available in JWT) */
|
|
526
|
-
email?: string;
|
|
527
|
-
/** Organization ID */
|
|
528
|
-
orgId: string;
|
|
529
|
-
/** Application ID */
|
|
530
|
-
applicationId: string;
|
|
531
|
-
/** Session duration in minutes */
|
|
532
|
-
durationMinutes: number;
|
|
533
|
-
/** Expiration timestamp (Unix seconds) */
|
|
534
|
-
expiresAt: number;
|
|
535
|
-
/** Full JWT token for app use */
|
|
536
|
-
jwt: string;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
export declare interface SessionWarningContext {
|
|
540
|
-
/** Unique session UUID */
|
|
541
|
-
sessionId: string;
|
|
542
|
-
/** User ID */
|
|
543
|
-
userId: string;
|
|
544
|
-
/** Remaining seconds until expiration */
|
|
545
|
-
remainingSeconds: number;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* Tab Synchronization Manager
|
|
550
|
-
* Phase 2 Feature - Syncs session state across multiple tabs
|
|
551
|
-
*/
|
|
552
|
-
export declare class TabSyncManager {
|
|
553
|
-
private sessionId;
|
|
554
|
-
private onMessage;
|
|
555
|
-
private channel;
|
|
556
|
-
private storageKey;
|
|
557
|
-
private logger;
|
|
558
|
-
private isMaster;
|
|
559
|
-
constructor(sessionId: string, onMessage: (message: TabSyncMessage) => void, debug?: boolean);
|
|
560
|
-
/**
|
|
561
|
-
* Initialize sync mechanism
|
|
562
|
-
*/
|
|
563
|
-
private initialize;
|
|
564
|
-
/**
|
|
565
|
-
* Broadcast message to other tabs
|
|
566
|
-
*/
|
|
567
|
-
broadcast(type: TabSyncMessage['type'], data?: Partial<TabSyncMessage>): void;
|
|
568
|
-
/**
|
|
569
|
-
* Handle incoming message
|
|
570
|
-
*/
|
|
571
|
-
private handleMessage;
|
|
572
|
-
/**
|
|
573
|
-
* Handle storage event (fallback mechanism)
|
|
574
|
-
*/
|
|
575
|
-
private handleStorageEvent;
|
|
576
|
-
/**
|
|
577
|
-
* Elect this tab as master if appropriate
|
|
578
|
-
* Master tab is responsible for heartbeats
|
|
579
|
-
*/
|
|
580
|
-
private electMaster;
|
|
581
|
-
/**
|
|
582
|
-
* Check if this tab is the master
|
|
583
|
-
*/
|
|
584
|
-
isMasterTab(): boolean;
|
|
585
|
-
/**
|
|
586
|
-
* Cleanup and destroy
|
|
587
|
-
*/
|
|
588
|
-
destroy(): void;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
export declare interface TabSyncMessage {
|
|
592
|
-
type: 'timer_update' | 'pause' | 'resume' | 'end';
|
|
593
|
-
sessionId: string;
|
|
594
|
-
remainingSeconds?: number;
|
|
595
|
-
timestamp: number;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
export declare interface Theme {
|
|
599
|
-
colors: ThemeColors;
|
|
600
|
-
typography: ThemeTypography;
|
|
601
|
-
spacing: ThemeSpacing;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* Theme configuration matching the General Wisdom SPA design system
|
|
606
|
-
* Based on gw-spa/src/styles/globals.css and Tailwind CSS v4
|
|
607
|
-
*/
|
|
608
|
-
export declare interface ThemeColors {
|
|
609
|
-
background: string;
|
|
610
|
-
foreground: string;
|
|
611
|
-
card: string;
|
|
612
|
-
cardForeground: string;
|
|
613
|
-
popover: string;
|
|
614
|
-
popoverForeground: string;
|
|
615
|
-
primary: string;
|
|
616
|
-
primaryForeground: string;
|
|
617
|
-
secondary: string;
|
|
618
|
-
secondaryForeground: string;
|
|
619
|
-
muted: string;
|
|
620
|
-
mutedForeground: string;
|
|
621
|
-
accent: string;
|
|
622
|
-
accentForeground: string;
|
|
623
|
-
destructive: string;
|
|
624
|
-
destructiveForeground: string;
|
|
625
|
-
success: string;
|
|
626
|
-
successForeground: string;
|
|
627
|
-
border: string;
|
|
628
|
-
input: string;
|
|
629
|
-
ring: string;
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
/**
|
|
633
|
-
* Theme mode for modal styling
|
|
634
|
-
*/
|
|
635
|
-
export declare type ThemeMode = 'light' | 'dark' | 'auto';
|
|
636
|
-
|
|
637
|
-
export declare interface ThemeSpacing {
|
|
638
|
-
borderRadius: {
|
|
639
|
-
sm: string;
|
|
640
|
-
md: string;
|
|
641
|
-
lg: string;
|
|
642
|
-
};
|
|
643
|
-
padding: {
|
|
644
|
-
sm: string;
|
|
645
|
-
md: string;
|
|
646
|
-
lg: string;
|
|
647
|
-
xl: string;
|
|
648
|
-
};
|
|
649
|
-
gap: {
|
|
650
|
-
sm: string;
|
|
651
|
-
md: string;
|
|
652
|
-
lg: string;
|
|
653
|
-
};
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
export declare interface ThemeTypography {
|
|
657
|
-
fontFamily: string;
|
|
658
|
-
fontSize: {
|
|
659
|
-
xs: string;
|
|
660
|
-
sm: string;
|
|
661
|
-
base: string;
|
|
662
|
-
lg: string;
|
|
663
|
-
xl: string;
|
|
664
|
-
'2xl': string;
|
|
665
|
-
};
|
|
666
|
-
fontWeight: {
|
|
667
|
-
normal: string;
|
|
668
|
-
medium: string;
|
|
669
|
-
semibold: string;
|
|
670
|
-
bold: string;
|
|
671
|
-
};
|
|
672
|
-
lineHeight: {
|
|
673
|
-
tight: string;
|
|
674
|
-
normal: string;
|
|
675
|
-
relaxed: string;
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
/**
|
|
680
|
-
* Timer Manager for session countdown
|
|
681
|
-
*/
|
|
682
|
-
export declare class TimerManager {
|
|
683
|
-
private remainingSeconds;
|
|
684
|
-
private intervalId;
|
|
685
|
-
private warningThreshold;
|
|
686
|
-
private warningShown;
|
|
687
|
-
private logger;
|
|
688
|
-
private events;
|
|
689
|
-
constructor(durationSeconds: number, warningThresholdSeconds?: number, events?: Partial<SDKEvents>, debug?: boolean);
|
|
690
|
-
/**
|
|
691
|
-
* Start countdown timer
|
|
692
|
-
*/
|
|
693
|
-
start(): void;
|
|
694
|
-
/**
|
|
695
|
-
* Stop timer
|
|
696
|
-
*/
|
|
697
|
-
stop(): void;
|
|
698
|
-
/**
|
|
699
|
-
* Pause timer
|
|
700
|
-
*/
|
|
701
|
-
pause(): void;
|
|
702
|
-
/**
|
|
703
|
-
* Resume timer
|
|
704
|
-
*/
|
|
705
|
-
resume(): void;
|
|
706
|
-
/**
|
|
707
|
-
* Get remaining time in seconds
|
|
708
|
-
*/
|
|
709
|
-
getRemainingSeconds(): number;
|
|
710
|
-
/**
|
|
711
|
-
* Get formatted time string (MM:SS)
|
|
712
|
-
*/
|
|
713
|
-
getFormattedTime(): string;
|
|
714
|
-
/**
|
|
715
|
-
* Get formatted time string with hours (HH:MM:SS)
|
|
716
|
-
*/
|
|
717
|
-
getFormattedTimeWithHours(): string;
|
|
718
|
-
/**
|
|
719
|
-
* Check if timer is running
|
|
720
|
-
*/
|
|
721
|
-
isRunning(): boolean;
|
|
722
|
-
/**
|
|
723
|
-
* Check if warning has been shown
|
|
724
|
-
*/
|
|
725
|
-
hasWarningBeenShown(): boolean;
|
|
726
|
-
/**
|
|
727
|
-
* Update remaining time (useful for syncing with server)
|
|
728
|
-
*/
|
|
729
|
-
updateRemainingTime(seconds: number): void;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
/**
|
|
733
|
-
* Warning Modal for session expiration alerts
|
|
734
|
-
*/
|
|
735
|
-
export declare class WarningModal {
|
|
736
|
-
private modal;
|
|
737
|
-
private theme;
|
|
738
|
-
private legacyStyles;
|
|
739
|
-
private updateInterval;
|
|
740
|
-
private timeDisplay;
|
|
741
|
-
private startTime;
|
|
742
|
-
private initialSeconds;
|
|
743
|
-
private onEndCallback;
|
|
744
|
-
constructor(themeMode?: ThemeMode, customStyles?: Partial<ModalStyles>);
|
|
745
|
-
private detectDarkMode;
|
|
746
|
-
/**
|
|
747
|
-
* Show warning modal
|
|
748
|
-
*/
|
|
749
|
-
show(options: {
|
|
750
|
-
remainingSeconds: number;
|
|
751
|
-
onExtend?: () => void;
|
|
752
|
-
onEnd?: () => void;
|
|
753
|
-
}): void;
|
|
754
|
-
/**
|
|
755
|
-
* Hide and remove modal
|
|
756
|
-
*/
|
|
757
|
-
hide(): void;
|
|
758
|
-
/**
|
|
759
|
-
* Check if modal is currently shown
|
|
760
|
-
*/
|
|
761
|
-
isShown(): boolean;
|
|
762
|
-
/**
|
|
763
|
-
* Show "Session Ending" modal before redirect
|
|
764
|
-
* Displays for a fixed duration (3 seconds) then calls callback
|
|
765
|
-
*/
|
|
766
|
-
showEndingMessage(onComplete: () => void, durationMs?: number): void;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
export { }
|
|
1
|
+
/**
|
|
2
|
+
* Marketplace Provider SDK
|
|
3
|
+
* JWT-based session management for application providers
|
|
4
|
+
*/
|
|
5
|
+
export { MarketplaceSDK } from './core/MarketplaceSDK';
|
|
6
|
+
export { JWTParser } from './core/JWTParser';
|
|
7
|
+
export { JWKSValidator } from './core/JWKSValidator';
|
|
8
|
+
export { TimerManager } from './core/TimerManager';
|
|
9
|
+
export { HeartbeatManager } from './core/HeartbeatManager';
|
|
10
|
+
export { TabSyncManager } from './core/TabSyncManager';
|
|
11
|
+
export type { TabSyncMessage } from './core/TabSyncManager';
|
|
12
|
+
export { WarningModal } from './ui/WarningModal';
|
|
13
|
+
export { SessionHeader } from './ui/SessionHeader';
|
|
14
|
+
export { PurchaseModal } from './ui/PurchaseModal';
|
|
15
|
+
export { lightTheme, darkTheme, getTheme, generateCSSVariables } from './styles/theme';
|
|
16
|
+
export type { Theme, ThemeColors, ThemeTypography, ThemeSpacing } from './styles/theme';
|
|
17
|
+
export type { SDKConfig, SessionData, SDKEvents, ModalStyles, ThemeMode, JWTHeader, JWTClaims, JWKSKey, JWKSResponse, SessionLifecycleHooks, SessionStartContext, SessionEndContext, SessionExtendContext, SessionWarningContext, } from './types';
|
|
18
|
+
export { SDKError, PurchaseError } from './types';
|
|
19
|
+
export type { PurchaseResult } from './types';
|
|
20
|
+
export { extractTokenFromURL, isBrowser } from './utils/url';
|
|
21
|
+
export { Logger } from './utils/logger';
|
|
22
|
+
export { MarketplaceSDK as default } from './core/MarketplaceSDK';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|