@blinkdotnew/sdk 0.14.2 → 0.14.4

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 CHANGED
@@ -1265,7 +1265,7 @@ All `{{secret_name}}` placeholders are replaced with encrypted values from your
1265
1265
 
1266
1266
  ### React
1267
1267
 
1268
- ```typitten
1268
+ ```typescript
1269
1269
  import { createClient } from '@blinkdotnew/sdk'
1270
1270
  import { useState, useEffect } from 'react'
1271
1271
 
package/dist/index.d.mts CHANGED
@@ -733,7 +733,6 @@ declare class HttpClient {
733
733
  /**
734
734
  * Blink Auth Module - Client-side authentication management
735
735
  * Handles token storage, user state, and authentication flows
736
- * Includes iframe token relay support for seamless preview authentication
737
736
  */
738
737
 
739
738
  type AuthStateChangeCallback = (state: AuthState) => void;
@@ -744,16 +743,17 @@ declare class BlinkAuth {
744
743
  private readonly authUrl;
745
744
  private parentWindowTokens;
746
745
  private isIframe;
747
- private tokenRequestSent;
746
+ private initializationPromise;
747
+ private isInitialized;
748
748
  constructor(config: BlinkClientConfig);
749
749
  /**
750
- * Setup listener for tokens from parent window (iframe only)
750
+ * Wait for authentication initialization to complete
751
751
  */
752
- private setupParentWindowListener;
752
+ private waitForInitialization;
753
753
  /**
754
- * Request tokens from parent window
754
+ * Setup listener for tokens from parent window
755
755
  */
756
- private requestTokensFromParent;
756
+ private setupParentWindowListener;
757
757
  /**
758
758
  * Initialize authentication from stored tokens or URL fragments
759
759
  */
@@ -792,6 +792,7 @@ declare class BlinkAuth {
792
792
  getValidToken(): Promise<string | null>;
793
793
  /**
794
794
  * Fetch current user profile from API
795
+ * Gracefully waits for auth initialization to complete before throwing errors
795
796
  */
796
797
  me(): Promise<BlinkUser>;
797
798
  /**
package/dist/index.d.ts CHANGED
@@ -733,7 +733,6 @@ declare class HttpClient {
733
733
  /**
734
734
  * Blink Auth Module - Client-side authentication management
735
735
  * Handles token storage, user state, and authentication flows
736
- * Includes iframe token relay support for seamless preview authentication
737
736
  */
738
737
 
739
738
  type AuthStateChangeCallback = (state: AuthState) => void;
@@ -744,16 +743,17 @@ declare class BlinkAuth {
744
743
  private readonly authUrl;
745
744
  private parentWindowTokens;
746
745
  private isIframe;
747
- private tokenRequestSent;
746
+ private initializationPromise;
747
+ private isInitialized;
748
748
  constructor(config: BlinkClientConfig);
749
749
  /**
750
- * Setup listener for tokens from parent window (iframe only)
750
+ * Wait for authentication initialization to complete
751
751
  */
752
- private setupParentWindowListener;
752
+ private waitForInitialization;
753
753
  /**
754
- * Request tokens from parent window
754
+ * Setup listener for tokens from parent window
755
755
  */
756
- private requestTokensFromParent;
756
+ private setupParentWindowListener;
757
757
  /**
758
758
  * Initialize authentication from stored tokens or URL fragments
759
759
  */
@@ -792,6 +792,7 @@ declare class BlinkAuth {
792
792
  getValidToken(): Promise<string | null>;
793
793
  /**
794
794
  * Fetch current user profile from API
795
+ * Gracefully waits for auth initialization to complete before throwing errors
795
796
  */
796
797
  me(): Promise<BlinkUser>;
797
798
  /**
package/dist/index.js CHANGED
@@ -869,7 +869,8 @@ var BlinkAuth = class {
869
869
  authUrl = "https://blink.new";
870
870
  parentWindowTokens = null;
871
871
  isIframe = false;
872
- tokenRequestSent = false;
872
+ initializationPromise = null;
873
+ isInitialized = false;
873
874
  constructor(config) {
874
875
  this.config = config;
875
876
  this.authState = {
@@ -880,45 +881,39 @@ var BlinkAuth = class {
880
881
  };
881
882
  if (typeof window !== "undefined") {
882
883
  this.isIframe = window.self !== window.top;
883
- if (this.isIframe) {
884
- console.log("\u{1F5BC}\uFE0F Detected iframe environment, setting up parent window communication");
885
- this.setupParentWindowListener();
886
- }
887
- this.initialize();
884
+ this.setupParentWindowListener();
885
+ this.initializationPromise = this.initialize();
886
+ } else {
887
+ this.isInitialized = true;
888
+ }
889
+ }
890
+ /**
891
+ * Wait for authentication initialization to complete
892
+ */
893
+ async waitForInitialization() {
894
+ if (this.isInitialized) return;
895
+ if (this.initializationPromise) {
896
+ await this.initializationPromise;
888
897
  }
889
898
  }
890
899
  /**
891
- * Setup listener for tokens from parent window (iframe only)
900
+ * Setup listener for tokens from parent window
892
901
  */
893
902
  setupParentWindowListener() {
894
903
  if (!this.isIframe) return;
895
904
  window.addEventListener("message", (event) => {
896
- const trustedOrigins = [
897
- "https://blink.new",
898
- "http://localhost:3000",
899
- "http://localhost:3001",
900
- "https://localhost:3000",
901
- "https://localhost:3001"
902
- ];
903
- if (!trustedOrigins.includes(event.origin)) {
905
+ if (event.origin !== "https://blink.new" && event.origin !== "http://localhost:3000" && event.origin !== "http://localhost:3001") {
904
906
  return;
905
907
  }
906
908
  if (event.data?.type === "BLINK_AUTH_TOKENS") {
907
- console.log("\u{1F4E5} Received auth tokens from parent window", {
908
- hasTokens: !!event.data.tokens,
909
- projectId: event.data.projectId
910
- });
911
- const { tokens, projectId } = event.data;
912
- if (projectId && projectId !== this.config.projectId) {
913
- console.log("\u26A0\uFE0F Ignoring tokens for different project:", projectId);
914
- return;
915
- }
909
+ console.log("\u{1F4E5} Received auth tokens from parent window");
910
+ const { tokens } = event.data;
916
911
  if (tokens) {
917
912
  this.parentWindowTokens = tokens;
918
913
  this.setTokens(tokens, false).then(() => {
919
- console.log("\u2705 Tokens from parent window applied successfully");
914
+ console.log("\u2705 Tokens from parent window applied");
920
915
  }).catch((error) => {
921
- console.error("\u274C Failed to apply parent window tokens:", error);
916
+ console.error("Failed to apply parent window tokens:", error);
922
917
  });
923
918
  }
924
919
  }
@@ -926,31 +921,13 @@ var BlinkAuth = class {
926
921
  console.log("\u{1F4E4} Received logout command from parent window");
927
922
  this.clearTokens();
928
923
  }
929
- if (event.data?.type === "BLINK_AUTH_REFRESH") {
930
- console.log("\u{1F504} Received token refresh from parent window");
931
- const { tokens } = event.data;
932
- if (tokens) {
933
- this.parentWindowTokens = tokens;
934
- this.setTokens(tokens, false).catch((error) => {
935
- console.error("\u274C Failed to apply refreshed tokens:", error);
936
- });
937
- }
938
- }
939
924
  });
940
- this.requestTokensFromParent();
941
- }
942
- /**
943
- * Request tokens from parent window
944
- */
945
- requestTokensFromParent() {
946
- if (!this.isIframe || this.tokenRequestSent) return;
947
925
  if (window.parent !== window) {
948
926
  console.log("\u{1F504} Requesting auth tokens from parent window");
949
927
  window.parent.postMessage({
950
928
  type: "BLINK_REQUEST_AUTH_TOKENS",
951
929
  projectId: this.config.projectId
952
930
  }, "*");
953
- this.tokenRequestSent = true;
954
931
  }
955
932
  }
956
933
  /**
@@ -962,15 +939,12 @@ var BlinkAuth = class {
962
939
  try {
963
940
  if (this.isIframe) {
964
941
  console.log("\u{1F50D} Detected iframe environment, waiting for parent tokens...");
965
- for (let i = 0; i < 10; i++) {
966
- if (this.parentWindowTokens) {
967
- console.log("\u2705 Using tokens from parent window");
968
- await this.setTokens(this.parentWindowTokens, false);
969
- return;
970
- }
971
- await new Promise((resolve) => setTimeout(resolve, 100));
942
+ await new Promise((resolve) => setTimeout(resolve, 100));
943
+ if (this.parentWindowTokens) {
944
+ console.log("\u2705 Using tokens from parent window");
945
+ await this.setTokens(this.parentWindowTokens, false);
946
+ return;
972
947
  }
973
- console.log("\u23F0 Timeout waiting for parent tokens, continuing with normal flow...");
974
948
  }
975
949
  const tokensFromUrl = this.extractTokensFromUrl();
976
950
  if (tokensFromUrl) {
@@ -1003,14 +977,6 @@ var BlinkAuth = class {
1003
977
  }
1004
978
  console.log("\u274C No tokens found");
1005
979
  if (this.config.authRequired) {
1006
- if (this.isIframe && !this.tokenRequestSent) {
1007
- this.requestTokensFromParent();
1008
- await new Promise((resolve) => setTimeout(resolve, 500));
1009
- if (this.parentWindowTokens) {
1010
- await this.setTokens(this.parentWindowTokens, false);
1011
- return;
1012
- }
1013
- }
1014
980
  console.log("\u{1F504} Auth required, redirecting to auth page...");
1015
981
  this.redirectToAuth();
1016
982
  } else {
@@ -1018,6 +984,7 @@ var BlinkAuth = class {
1018
984
  }
1019
985
  } finally {
1020
986
  this.setLoading(false);
987
+ this.isInitialized = true;
1021
988
  }
1022
989
  }
1023
990
  /**
@@ -1049,12 +1016,6 @@ var BlinkAuth = class {
1049
1016
  */
1050
1017
  logout(redirectUrl) {
1051
1018
  this.clearTokens();
1052
- if (this.isIframe && window.parent !== window) {
1053
- window.parent.postMessage({
1054
- type: "BLINK_AUTH_LOGOUT_IFRAME",
1055
- projectId: this.config.projectId
1056
- }, "*");
1057
- }
1058
1019
  if (redirectUrl && typeof window !== "undefined") {
1059
1020
  window.location.href = redirectUrl;
1060
1021
  }
@@ -1138,8 +1099,36 @@ var BlinkAuth = class {
1138
1099
  }
1139
1100
  /**
1140
1101
  * Fetch current user profile from API
1102
+ * Gracefully waits for auth initialization to complete before throwing errors
1141
1103
  */
1142
1104
  async me() {
1105
+ await this.waitForInitialization();
1106
+ if (this.authState.isAuthenticated && this.authState.user) {
1107
+ return this.authState.user;
1108
+ }
1109
+ if (!this.authState.isAuthenticated) {
1110
+ return new Promise((resolve, reject) => {
1111
+ if (this.authState.user) {
1112
+ resolve(this.authState.user);
1113
+ return;
1114
+ }
1115
+ const timeout = setTimeout(() => {
1116
+ unsubscribe();
1117
+ reject(new BlinkAuthError("Authentication timeout - no user available"));
1118
+ }, 5e3);
1119
+ const unsubscribe = this.onAuthStateChanged((state) => {
1120
+ if (state.user) {
1121
+ clearTimeout(timeout);
1122
+ unsubscribe();
1123
+ resolve(state.user);
1124
+ } else if (!state.isLoading && !state.isAuthenticated) {
1125
+ clearTimeout(timeout);
1126
+ unsubscribe();
1127
+ reject(new BlinkAuthError("Not authenticated"));
1128
+ }
1129
+ });
1130
+ });
1131
+ }
1143
1132
  let token = this.getToken();
1144
1133
  if (!token) {
1145
1134
  throw new BlinkAuthError("No access token available");
@@ -1273,7 +1262,7 @@ var BlinkAuth = class {
1273
1262
  token_type: data.token_type,
1274
1263
  expires_in: data.expires_in,
1275
1264
  refresh_expires_in: data.refresh_expires_in
1276
- }, !this.isIframe);
1265
+ }, true);
1277
1266
  return true;
1278
1267
  } catch (error) {
1279
1268
  console.error("Token refresh failed:", error);
@@ -1350,7 +1339,7 @@ var BlinkAuth = class {
1350
1339
  return false;
1351
1340
  }
1352
1341
  } catch (error) {
1353
- console.log("\uFFFD\uFFFD Error validating tokens:", error);
1342
+ console.log("\u{1F4A5} Error validating tokens:", error);
1354
1343
  return false;
1355
1344
  }
1356
1345
  }
@@ -1364,10 +1353,9 @@ var BlinkAuth = class {
1364
1353
  hasAccessToken: !!tokensWithTimestamp.access_token,
1365
1354
  hasRefreshToken: !!tokensWithTimestamp.refresh_token,
1366
1355
  expiresIn: tokensWithTimestamp.expires_in,
1367
- issuedAt: tokensWithTimestamp.issued_at,
1368
- isIframe: this.isIframe
1356
+ issuedAt: tokensWithTimestamp.issued_at
1369
1357
  });
1370
- if (persist && !this.isIframe && typeof window !== "undefined") {
1358
+ if (persist && typeof window !== "undefined") {
1371
1359
  try {
1372
1360
  localStorage.setItem("blink_tokens", JSON.stringify(tokensWithTimestamp));
1373
1361
  console.log("\u{1F4BE} Tokens persisted to localStorage");
@@ -1418,7 +1406,6 @@ var BlinkAuth = class {
1418
1406
  });
1419
1407
  }
1420
1408
  clearTokens() {
1421
- this.parentWindowTokens = null;
1422
1409
  if (typeof window !== "undefined") {
1423
1410
  try {
1424
1411
  localStorage.removeItem("blink_tokens");
@@ -1436,7 +1423,6 @@ var BlinkAuth = class {
1436
1423
  getStoredTokens() {
1437
1424
  if (typeof window === "undefined") return null;
1438
1425
  if (this.isIframe && this.parentWindowTokens) {
1439
- console.log("\u{1F4E6} Using parent window tokens");
1440
1426
  return this.parentWindowTokens;
1441
1427
  }
1442
1428
  try {
@@ -1445,7 +1431,7 @@ var BlinkAuth = class {
1445
1431
  hasStoredData: !!stored,
1446
1432
  storedLength: stored?.length || 0,
1447
1433
  origin: window.location.origin,
1448
- isIframe: this.isIframe
1434
+ isIframe: window.self !== window.top
1449
1435
  });
1450
1436
  if (stored) {
1451
1437
  const tokens = JSON.parse(stored);
package/dist/index.mjs CHANGED
@@ -867,7 +867,8 @@ var BlinkAuth = class {
867
867
  authUrl = "https://blink.new";
868
868
  parentWindowTokens = null;
869
869
  isIframe = false;
870
- tokenRequestSent = false;
870
+ initializationPromise = null;
871
+ isInitialized = false;
871
872
  constructor(config) {
872
873
  this.config = config;
873
874
  this.authState = {
@@ -878,45 +879,39 @@ var BlinkAuth = class {
878
879
  };
879
880
  if (typeof window !== "undefined") {
880
881
  this.isIframe = window.self !== window.top;
881
- if (this.isIframe) {
882
- console.log("\u{1F5BC}\uFE0F Detected iframe environment, setting up parent window communication");
883
- this.setupParentWindowListener();
884
- }
885
- this.initialize();
882
+ this.setupParentWindowListener();
883
+ this.initializationPromise = this.initialize();
884
+ } else {
885
+ this.isInitialized = true;
886
+ }
887
+ }
888
+ /**
889
+ * Wait for authentication initialization to complete
890
+ */
891
+ async waitForInitialization() {
892
+ if (this.isInitialized) return;
893
+ if (this.initializationPromise) {
894
+ await this.initializationPromise;
886
895
  }
887
896
  }
888
897
  /**
889
- * Setup listener for tokens from parent window (iframe only)
898
+ * Setup listener for tokens from parent window
890
899
  */
891
900
  setupParentWindowListener() {
892
901
  if (!this.isIframe) return;
893
902
  window.addEventListener("message", (event) => {
894
- const trustedOrigins = [
895
- "https://blink.new",
896
- "http://localhost:3000",
897
- "http://localhost:3001",
898
- "https://localhost:3000",
899
- "https://localhost:3001"
900
- ];
901
- if (!trustedOrigins.includes(event.origin)) {
903
+ if (event.origin !== "https://blink.new" && event.origin !== "http://localhost:3000" && event.origin !== "http://localhost:3001") {
902
904
  return;
903
905
  }
904
906
  if (event.data?.type === "BLINK_AUTH_TOKENS") {
905
- console.log("\u{1F4E5} Received auth tokens from parent window", {
906
- hasTokens: !!event.data.tokens,
907
- projectId: event.data.projectId
908
- });
909
- const { tokens, projectId } = event.data;
910
- if (projectId && projectId !== this.config.projectId) {
911
- console.log("\u26A0\uFE0F Ignoring tokens for different project:", projectId);
912
- return;
913
- }
907
+ console.log("\u{1F4E5} Received auth tokens from parent window");
908
+ const { tokens } = event.data;
914
909
  if (tokens) {
915
910
  this.parentWindowTokens = tokens;
916
911
  this.setTokens(tokens, false).then(() => {
917
- console.log("\u2705 Tokens from parent window applied successfully");
912
+ console.log("\u2705 Tokens from parent window applied");
918
913
  }).catch((error) => {
919
- console.error("\u274C Failed to apply parent window tokens:", error);
914
+ console.error("Failed to apply parent window tokens:", error);
920
915
  });
921
916
  }
922
917
  }
@@ -924,31 +919,13 @@ var BlinkAuth = class {
924
919
  console.log("\u{1F4E4} Received logout command from parent window");
925
920
  this.clearTokens();
926
921
  }
927
- if (event.data?.type === "BLINK_AUTH_REFRESH") {
928
- console.log("\u{1F504} Received token refresh from parent window");
929
- const { tokens } = event.data;
930
- if (tokens) {
931
- this.parentWindowTokens = tokens;
932
- this.setTokens(tokens, false).catch((error) => {
933
- console.error("\u274C Failed to apply refreshed tokens:", error);
934
- });
935
- }
936
- }
937
922
  });
938
- this.requestTokensFromParent();
939
- }
940
- /**
941
- * Request tokens from parent window
942
- */
943
- requestTokensFromParent() {
944
- if (!this.isIframe || this.tokenRequestSent) return;
945
923
  if (window.parent !== window) {
946
924
  console.log("\u{1F504} Requesting auth tokens from parent window");
947
925
  window.parent.postMessage({
948
926
  type: "BLINK_REQUEST_AUTH_TOKENS",
949
927
  projectId: this.config.projectId
950
928
  }, "*");
951
- this.tokenRequestSent = true;
952
929
  }
953
930
  }
954
931
  /**
@@ -960,15 +937,12 @@ var BlinkAuth = class {
960
937
  try {
961
938
  if (this.isIframe) {
962
939
  console.log("\u{1F50D} Detected iframe environment, waiting for parent tokens...");
963
- for (let i = 0; i < 10; i++) {
964
- if (this.parentWindowTokens) {
965
- console.log("\u2705 Using tokens from parent window");
966
- await this.setTokens(this.parentWindowTokens, false);
967
- return;
968
- }
969
- await new Promise((resolve) => setTimeout(resolve, 100));
940
+ await new Promise((resolve) => setTimeout(resolve, 100));
941
+ if (this.parentWindowTokens) {
942
+ console.log("\u2705 Using tokens from parent window");
943
+ await this.setTokens(this.parentWindowTokens, false);
944
+ return;
970
945
  }
971
- console.log("\u23F0 Timeout waiting for parent tokens, continuing with normal flow...");
972
946
  }
973
947
  const tokensFromUrl = this.extractTokensFromUrl();
974
948
  if (tokensFromUrl) {
@@ -1001,14 +975,6 @@ var BlinkAuth = class {
1001
975
  }
1002
976
  console.log("\u274C No tokens found");
1003
977
  if (this.config.authRequired) {
1004
- if (this.isIframe && !this.tokenRequestSent) {
1005
- this.requestTokensFromParent();
1006
- await new Promise((resolve) => setTimeout(resolve, 500));
1007
- if (this.parentWindowTokens) {
1008
- await this.setTokens(this.parentWindowTokens, false);
1009
- return;
1010
- }
1011
- }
1012
978
  console.log("\u{1F504} Auth required, redirecting to auth page...");
1013
979
  this.redirectToAuth();
1014
980
  } else {
@@ -1016,6 +982,7 @@ var BlinkAuth = class {
1016
982
  }
1017
983
  } finally {
1018
984
  this.setLoading(false);
985
+ this.isInitialized = true;
1019
986
  }
1020
987
  }
1021
988
  /**
@@ -1047,12 +1014,6 @@ var BlinkAuth = class {
1047
1014
  */
1048
1015
  logout(redirectUrl) {
1049
1016
  this.clearTokens();
1050
- if (this.isIframe && window.parent !== window) {
1051
- window.parent.postMessage({
1052
- type: "BLINK_AUTH_LOGOUT_IFRAME",
1053
- projectId: this.config.projectId
1054
- }, "*");
1055
- }
1056
1017
  if (redirectUrl && typeof window !== "undefined") {
1057
1018
  window.location.href = redirectUrl;
1058
1019
  }
@@ -1136,8 +1097,36 @@ var BlinkAuth = class {
1136
1097
  }
1137
1098
  /**
1138
1099
  * Fetch current user profile from API
1100
+ * Gracefully waits for auth initialization to complete before throwing errors
1139
1101
  */
1140
1102
  async me() {
1103
+ await this.waitForInitialization();
1104
+ if (this.authState.isAuthenticated && this.authState.user) {
1105
+ return this.authState.user;
1106
+ }
1107
+ if (!this.authState.isAuthenticated) {
1108
+ return new Promise((resolve, reject) => {
1109
+ if (this.authState.user) {
1110
+ resolve(this.authState.user);
1111
+ return;
1112
+ }
1113
+ const timeout = setTimeout(() => {
1114
+ unsubscribe();
1115
+ reject(new BlinkAuthError("Authentication timeout - no user available"));
1116
+ }, 5e3);
1117
+ const unsubscribe = this.onAuthStateChanged((state) => {
1118
+ if (state.user) {
1119
+ clearTimeout(timeout);
1120
+ unsubscribe();
1121
+ resolve(state.user);
1122
+ } else if (!state.isLoading && !state.isAuthenticated) {
1123
+ clearTimeout(timeout);
1124
+ unsubscribe();
1125
+ reject(new BlinkAuthError("Not authenticated"));
1126
+ }
1127
+ });
1128
+ });
1129
+ }
1141
1130
  let token = this.getToken();
1142
1131
  if (!token) {
1143
1132
  throw new BlinkAuthError("No access token available");
@@ -1271,7 +1260,7 @@ var BlinkAuth = class {
1271
1260
  token_type: data.token_type,
1272
1261
  expires_in: data.expires_in,
1273
1262
  refresh_expires_in: data.refresh_expires_in
1274
- }, !this.isIframe);
1263
+ }, true);
1275
1264
  return true;
1276
1265
  } catch (error) {
1277
1266
  console.error("Token refresh failed:", error);
@@ -1348,7 +1337,7 @@ var BlinkAuth = class {
1348
1337
  return false;
1349
1338
  }
1350
1339
  } catch (error) {
1351
- console.log("\uFFFD\uFFFD Error validating tokens:", error);
1340
+ console.log("\u{1F4A5} Error validating tokens:", error);
1352
1341
  return false;
1353
1342
  }
1354
1343
  }
@@ -1362,10 +1351,9 @@ var BlinkAuth = class {
1362
1351
  hasAccessToken: !!tokensWithTimestamp.access_token,
1363
1352
  hasRefreshToken: !!tokensWithTimestamp.refresh_token,
1364
1353
  expiresIn: tokensWithTimestamp.expires_in,
1365
- issuedAt: tokensWithTimestamp.issued_at,
1366
- isIframe: this.isIframe
1354
+ issuedAt: tokensWithTimestamp.issued_at
1367
1355
  });
1368
- if (persist && !this.isIframe && typeof window !== "undefined") {
1356
+ if (persist && typeof window !== "undefined") {
1369
1357
  try {
1370
1358
  localStorage.setItem("blink_tokens", JSON.stringify(tokensWithTimestamp));
1371
1359
  console.log("\u{1F4BE} Tokens persisted to localStorage");
@@ -1416,7 +1404,6 @@ var BlinkAuth = class {
1416
1404
  });
1417
1405
  }
1418
1406
  clearTokens() {
1419
- this.parentWindowTokens = null;
1420
1407
  if (typeof window !== "undefined") {
1421
1408
  try {
1422
1409
  localStorage.removeItem("blink_tokens");
@@ -1434,7 +1421,6 @@ var BlinkAuth = class {
1434
1421
  getStoredTokens() {
1435
1422
  if (typeof window === "undefined") return null;
1436
1423
  if (this.isIframe && this.parentWindowTokens) {
1437
- console.log("\u{1F4E6} Using parent window tokens");
1438
1424
  return this.parentWindowTokens;
1439
1425
  }
1440
1426
  try {
@@ -1443,7 +1429,7 @@ var BlinkAuth = class {
1443
1429
  hasStoredData: !!stored,
1444
1430
  storedLength: stored?.length || 0,
1445
1431
  origin: window.location.origin,
1446
- isIframe: this.isIframe
1432
+ isIframe: window.self !== window.top
1447
1433
  });
1448
1434
  if (stored) {
1449
1435
  const tokens = JSON.parse(stored);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkdotnew/sdk",
3
- "version": "0.14.2",
3
+ "version": "0.14.4",
4
4
  "description": "Blink TypeScript SDK for client-side applications - Zero-boilerplate CRUD + auth + AI + analytics + notifications for modern SaaS/AI apps",
5
5
  "keywords": [
6
6
  "blink",