@mission_sciences/provider-sdk 0.1.1 → 0.1.2-dev.d7154d7

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
  */
@@ -334,6 +334,8 @@ export declare interface ModalStyles {
334
334
  export declare interface SDKConfig {
335
335
  /** JWKS endpoint URL (default: https://api.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;
339
341
  /** Enable debug logging */
@@ -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) {
@@ -2513,6 +2515,7 @@ class MarketplaceSDK {
2513
2515
  this.endReason = "manual";
2514
2516
  this.config = {
2515
2517
  jwksUri: config.jwksUri || "https://api.generalwisdom.com/.well-known/jwks.json",
2518
+ jwtParamName: config.jwtParamName || "gwSession",
2516
2519
  apiEndpoint: config.apiEndpoint || "http://localhost:3000",
2517
2520
  debug: config.debug ?? false,
2518
2521
  autoStart: config.autoStart ?? true,
@@ -2535,6 +2538,7 @@ class MarketplaceSDK {
2535
2538
  this.logger = new Logger(this.config.debug, "[MarketplaceSDK]");
2536
2539
  this.logger.info("SDK initialized with config:", {
2537
2540
  jwksUri: this.config.jwksUri,
2541
+ jwtParamName: this.config.jwtParamName,
2538
2542
  apiEndpoint: this.config.apiEndpoint,
2539
2543
  enableHeartbeat: this.config.enableHeartbeat,
2540
2544
  enableTabSync: this.config.enableTabSync,
@@ -2594,7 +2598,7 @@ class MarketplaceSDK {
2594
2598
  this.logger.info("Initializing session...");
2595
2599
  try {
2596
2600
  const JWT_STORAGE_KEY = "gw_marketplace_jwt";
2597
- this.jwtToken = extractTokenFromURL("jwt");
2601
+ this.jwtToken = extractTokenFromURL(this.config.jwtParamName);
2598
2602
  if (!this.jwtToken && typeof sessionStorage !== "undefined") {
2599
2603
  this.jwtToken = sessionStorage.getItem(JWT_STORAGE_KEY);
2600
2604
  if (this.jwtToken) {
@@ -2603,7 +2607,7 @@ class MarketplaceSDK {
2603
2607
  }
2604
2608
  if (!this.jwtToken) {
2605
2609
  throw new SDKError(
2606
- "No jwt token found in URL or storage",
2610
+ `No token found in URL parameter '${this.config.jwtParamName}' or storage`,
2607
2611
  "MISSING_TOKEN"
2608
2612
  );
2609
2613
  }