@mission_sciences/provider-sdk 0.1.2 → 0.2.0-dev.8e1d7d7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export declare const darkTheme: Theme;
5
5
 
6
6
  /**
7
7
  * Extract JWT token from URL parameter
8
- * @param paramName - URL parameter name (default: 'jwt')
8
+ * @param paramName - URL parameter name (default: 'gwSession')
9
9
  * @param url - URL to extract from (default: window.location.href)
10
10
  * @returns JWT token or null if not found
11
11
  */
@@ -332,10 +332,14 @@ export declare interface ModalStyles {
332
332
  * SDK Configuration
333
333
  */
334
334
  export declare interface SDKConfig {
335
- /** JWKS endpoint URL (default: https://api.generalwisdom.com/.well-known/jwks.json) */
335
+ /** JWKS endpoint URL (default: https://api.platform.generalwisdom.com/.well-known/jwks.json) */
336
336
  jwksUri?: string;
337
+ /** URL query parameter name containing the JWT (default: 'gwSession') */
338
+ jwtParamName?: string;
337
339
  /** API endpoint for backend integration (Phase 2) */
338
340
  apiEndpoint?: string;
341
+ /** JWT issuer for validation (default: 'generalwisdom.com') */
342
+ jwtIssuer?: string;
339
343
  /** Enable debug logging */
340
344
  debug?: boolean;
341
345
  /** Auto-start timer after initialization */
@@ -348,7 +352,7 @@ export declare interface SDKConfig {
348
352
  themeMode?: ThemeMode;
349
353
  /** Application ID for validation */
350
354
  applicationId?: string;
351
- /** Marketplace URL for redirects (default: https://d3p2yqofgy75sz.cloudfront.net/) */
355
+ /** Marketplace URL for redirects (default: https://platform.generalwisdom.com/) */
352
356
  marketplaceUrl?: string;
353
357
  /** Enable heartbeat system (default: false) */
354
358
  enableHeartbeat?: boolean;
@@ -1576,7 +1576,8 @@ class JWKSValidator {
1576
1576
  constructor(jwksUri, debug = false) {
1577
1577
  this.jwksUri = jwksUri;
1578
1578
  this.logger = new Logger(debug, "[JWKSValidator]");
1579
- this.jwks = createRemoteJWKSet(new URL(this.jwksUri));
1579
+ const resolvedUrl = this.jwksUri.startsWith("http") ? new URL(this.jwksUri) : new URL(this.jwksUri, typeof window !== "undefined" ? window.location.origin : void 0);
1580
+ this.jwks = createRemoteJWKSet(resolvedUrl);
1580
1581
  this.logger.info("Initialized with JWKS URI:", this.jwksUri);
1581
1582
  }
1582
1583
  /**
@@ -1661,7 +1662,8 @@ class JWKSValidator {
1661
1662
  */
1662
1663
  updateJwksUri(jwksUri) {
1663
1664
  this.jwksUri = jwksUri;
1664
- this.jwks = createRemoteJWKSet(new URL(this.jwksUri));
1665
+ const resolvedUrl = this.jwksUri.startsWith("http") ? new URL(this.jwksUri) : new URL(this.jwksUri, typeof window !== "undefined" ? window.location.origin : void 0);
1666
+ this.jwks = createRemoteJWKSet(resolvedUrl);
1665
1667
  this.logger.info("Updated JWKS URI:", this.jwksUri);
1666
1668
  }
1667
1669
  }
@@ -2482,7 +2484,7 @@ class WarningModal {
2482
2484
  }, durationMs);
2483
2485
  }
2484
2486
  }
2485
- function extractTokenFromURL(paramName = "jwt", url) {
2487
+ function extractTokenFromURL(paramName = "gwSession", url) {
2486
2488
  try {
2487
2489
  const targetUrl = url || (typeof window !== "undefined" ? window.location.href : "");
2488
2490
  if (!targetUrl) {
@@ -2512,15 +2514,17 @@ class MarketplaceSDK {
2512
2514
  this.jwtToken = null;
2513
2515
  this.endReason = "manual";
2514
2516
  this.config = {
2515
- jwksUri: config.jwksUri || "https://api.generalwisdom.com/.well-known/jwks.json",
2516
- apiEndpoint: config.apiEndpoint || "http://localhost:3000",
2517
+ jwksUri: config.jwksUri || "https://api.platform.generalwisdom.com/.well-known/jwks.json",
2518
+ jwtParamName: config.jwtParamName || "gwSession",
2519
+ apiEndpoint: config.apiEndpoint || "https://api.platform.generalwisdom.com",
2520
+ jwtIssuer: config.jwtIssuer || "generalwisdom.com",
2517
2521
  debug: config.debug ?? false,
2518
2522
  autoStart: config.autoStart ?? true,
2519
2523
  warningThresholdSeconds: config.warningThresholdSeconds ?? 300,
2520
2524
  customStyles: config.customStyles ?? {},
2521
2525
  themeMode: config.themeMode ?? "light",
2522
2526
  applicationId: config.applicationId ?? "",
2523
- marketplaceUrl: config.marketplaceUrl ?? "https://d3p2yqofgy75sz.cloudfront.net/",
2527
+ marketplaceUrl: config.marketplaceUrl ?? "https://platform.generalwisdom.com/",
2524
2528
  // Phase 2 options
2525
2529
  enableHeartbeat: config.enableHeartbeat ?? false,
2526
2530
  heartbeatIntervalSeconds: config.heartbeatIntervalSeconds ?? 30,
@@ -2535,6 +2539,7 @@ class MarketplaceSDK {
2535
2539
  this.logger = new Logger(this.config.debug, "[MarketplaceSDK]");
2536
2540
  this.logger.info("SDK initialized with config:", {
2537
2541
  jwksUri: this.config.jwksUri,
2542
+ jwtParamName: this.config.jwtParamName,
2538
2543
  apiEndpoint: this.config.apiEndpoint,
2539
2544
  enableHeartbeat: this.config.enableHeartbeat,
2540
2545
  enableTabSync: this.config.enableTabSync,
@@ -2594,7 +2599,7 @@ class MarketplaceSDK {
2594
2599
  this.logger.info("Initializing session...");
2595
2600
  try {
2596
2601
  const JWT_STORAGE_KEY = "gw_marketplace_jwt";
2597
- this.jwtToken = extractTokenFromURL("jwt");
2602
+ this.jwtToken = extractTokenFromURL(this.config.jwtParamName);
2598
2603
  if (!this.jwtToken && typeof sessionStorage !== "undefined") {
2599
2604
  this.jwtToken = sessionStorage.getItem(JWT_STORAGE_KEY);
2600
2605
  if (this.jwtToken) {
@@ -2603,7 +2608,7 @@ class MarketplaceSDK {
2603
2608
  }
2604
2609
  if (!this.jwtToken) {
2605
2610
  throw new SDKError(
2606
- "No jwt token found in URL or storage",
2611
+ `No token found in URL parameter '${this.config.jwtParamName}' or storage`,
2607
2612
  "MISSING_TOKEN"
2608
2613
  );
2609
2614
  }
@@ -2620,7 +2625,7 @@ class MarketplaceSDK {
2620
2625
  this.logger.log("Using JWKS validation");
2621
2626
  verifiedClaims = await this.validator.verify(
2622
2627
  this.jwtToken,
2623
- "generalwisdom.com",
2628
+ this.config.jwtIssuer,
2624
2629
  this.config.applicationId || void 0
2625
2630
  );
2626
2631
  }