@benji-money/connect-sdk 1.1.4-beta.6 → 1.1.4-beta.8

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
@@ -2,6 +2,8 @@
2
2
 
3
3
  A JavaScript Github Package SDK for integrating Benji Connect, Benji's authentication and verification services.
4
4
 
5
+ LOGIN mode (shells, timers, same-tab resume): [docs/login-mode.md](./docs/login-mode.md).
6
+
5
7
  ## Installation
6
8
 
7
9
  ```bash
@@ -0,0 +1,14 @@
1
+ // These are compile-time constants replaced by tsup's `define` option.
2
+ // Declaring them globally prevents TypeScript errors.
3
+
4
+
5
+ declare global {
6
+ const __VERSION__: string;
7
+ const __NAMESPACE__: string;
8
+
9
+ // Global browser exposure for UMD builds
10
+ interface Window {
11
+ // SDK main class (UMD builds attach this)
12
+ ConnectSDK?: any;
13
+ }
14
+ }
@@ -110,7 +110,7 @@ var ConnectSDK = (() => {
110
110
  // src/utils/config.ts
111
111
  var buildContext = () => ({
112
112
  namespace: "benji-connect-sdk" ? "benji-connect-sdk" : "benji-connect-sdk",
113
- version: "1.1.4-beta.6" ? String("1.1.4-beta.6") : "0.0.0"
113
+ version: "1.1.4-beta.8" ? String("1.1.4-beta.8") : "0.0.0"
114
114
  });
115
115
  function isBenjiConnectEnvironment(environment) {
116
116
  return environment === "local" /* LOCAL */ || environment === "development" /* DEVELOPMENT */ || environment === "sandbox" /* SANDBOX */ || environment === "production" /* PRODUCTION */;
@@ -216,6 +216,16 @@ var ConnectSDK = (() => {
216
216
  }
217
217
  }
218
218
 
219
+ // src/constants/login.ts
220
+ var LOGIN_RETURN_STATE_SEPARATOR = ".benji_return.";
221
+ var LOGIN_RESUME_QUERY_FLAG = "login_resume";
222
+ var LOGIN_PENDING_STORAGE_KEY = "benji_login_pending";
223
+ var LOGIN_FORCE_REDIRECT_STORAGE_KEY = "benji_force_login_redirect";
224
+ var LOGIN_POPUP_CLOSED_POLL_MS = 500;
225
+ var LOGIN_IFRAME_DELIVERABILITY_POLL_MS = 100;
226
+ var LOGIN_SAME_TAB_AUTH_REDELIVERY_MS = 500;
227
+ var LOGIN_SAME_TAB_RESUME_TIMEOUT_MS = 45e3;
228
+
219
229
  // src/utils/partnerAuthLink.ts
220
230
  var LOGIN_POPUP_QUERY_FLAG = "benji_login_popup";
221
231
  function ensureAuthLinkStateNonce(url, nonce) {
@@ -251,8 +261,7 @@ var ConnectSDK = (() => {
251
261
  var DEFAULT_LOCAL_VERIFY_ORIGIN = "http://localhost:3000";
252
262
  var REMOTE_VERIFY_ORIGINS = [
253
263
  "https://verifyapp-staging.withbenji.com",
254
- "https://verifyapp-dev.withbenji.com",
255
- "https://verifyapp.withbenji.com"
264
+ "https://verifyapp-dev.withbenji.com"
256
265
  ];
257
266
  function rewriteVerifyAppUrlForLocalConnect(partnerLoginLink, localOrigin = DEFAULT_LOCAL_VERIFY_ORIGIN) {
258
267
  if (!partnerLoginLink) {
@@ -271,19 +280,13 @@ var ConnectSDK = (() => {
271
280
  }
272
281
 
273
282
  // src/utils/loginTransport.ts
274
- var LOGIN_PENDING_STORAGE_KEY = "benji_login_pending";
275
- var LOGIN_FORCE_REDIRECT_STORAGE_KEY = "benji_force_login_redirect";
276
- var LOGIN_RESUME_QUERY_FLAG = "login_resume";
277
- var LOGIN_RETURN_STATE_SEPARATOR = ".benji_return.";
278
- function isIosSafari(userAgent, maxTouchPoints) {
279
- const isIos = /iPhone|iPad|iPod/.test(userAgent) || userAgent.includes("Macintosh") && maxTouchPoints > 1;
280
- const isSafari = /Safari/.test(userAgent) && !/CriOS|FxiOS|EdgiOS|OPiOS|Chrome/.test(userAgent);
281
- return isIos && isSafari;
283
+ function isIosDevice(userAgent, maxTouchPoints) {
284
+ return /iPhone|iPad|iPod/.test(userAgent) || userAgent.includes("Macintosh") && maxTouchPoints > 1;
282
285
  }
283
286
  function shouldUseSameTabLogin(args) {
284
287
  if (!args.isNonDummyLogin) return false;
285
288
  if (args.forceRedirect) return true;
286
- return isIosSafari(args.userAgent, args.maxTouchPoints);
289
+ return isIosDevice(args.userAgent, args.maxTouchPoints);
287
290
  }
288
291
  function isNonDummyLogin(mode, authType) {
289
292
  return mode === 5 /* LOGIN */ && authType != null && authType !== 0 /* DUMMY */;
@@ -884,7 +887,7 @@ var ConnectSDK = (() => {
884
887
  return false;
885
888
  }
886
889
  }
887
- function isPopupOriginatedAuth(event, loginPopup, iframeWindow, connectOrigin) {
890
+ function isLoginPopupOriginatedAuth(event, loginPopup, iframeWindow, connectOrigin) {
888
891
  if (iframeWindow && event.source === iframeWindow) {
889
892
  return false;
890
893
  }
@@ -896,7 +899,7 @@ var ConnectSDK = (() => {
896
899
  }
897
900
  return isMessageWindow(event.source) && event.origin === connectOrigin && event.source !== iframeWindow;
898
901
  }
899
- function canDeliverAuthToConnectIframe(iframe) {
902
+ function canDeliverLoginAuthToConnectIframe(iframe) {
900
903
  var _a;
901
904
  const iframeWindow = (_a = iframe == null ? void 0 : iframe.contentWindow) != null ? _a : null;
902
905
  if (!iframeWindow) return false;
@@ -912,13 +915,13 @@ var ConnectSDK = (() => {
912
915
  const type = data2.type;
913
916
  return typeof type === "string" ? type : void 0;
914
917
  }
915
- function resolveLoginPartnerWindow(loginPopup, lastVerifiedPopupSource) {
918
+ function resolveLoginPartnerWindow(loginPopup, lastVerifiedLoginPopupSource) {
916
919
  var _a;
917
920
  const candidates = [];
918
- if (lastVerifiedPopupSource && !lastVerifiedPopupSource.closed) {
919
- candidates.push(lastVerifiedPopupSource);
921
+ if (lastVerifiedLoginPopupSource && !lastVerifiedLoginPopupSource.closed) {
922
+ candidates.push(lastVerifiedLoginPopupSource);
920
923
  }
921
- if (loginPopup && !loginPopup.closed && loginPopup !== lastVerifiedPopupSource) {
924
+ if (loginPopup && !loginPopup.closed && loginPopup !== lastVerifiedLoginPopupSource) {
922
925
  candidates.push(loginPopup);
923
926
  }
924
927
  if (candidates.length === 0) {
@@ -936,9 +939,9 @@ var ConnectSDK = (() => {
936
939
  }
937
940
  return (_a = candidates[0]) != null ? _a : null;
938
941
  }
939
- function describeLoginPartnerWindowTarget(target, loginPopup, lastVerifiedPopupSource) {
942
+ function describeLoginPartnerWindowTarget(target, loginPopup, lastVerifiedLoginPopupSource) {
940
943
  if (!target) return "none";
941
- if (target === lastVerifiedPopupSource) return "lastVerified";
944
+ if (target === lastVerifiedLoginPopupSource) return "lastVerified";
942
945
  if (target === loginPopup) return "loginPopup";
943
946
  return "named";
944
947
  }
@@ -1061,8 +1064,6 @@ var ConnectSDK = (() => {
1061
1064
  };
1062
1065
 
1063
1066
  // src/router/message.ts
1064
- var IFRAME_DELIVERABILITY_POLL_MS = 100;
1065
- var HOST_AUTH_REDELIVERY_MS = 500;
1066
1067
  var _MessageRouter = class _MessageRouter {
1067
1068
  static configureMessageRouter(config) {
1068
1069
  this.onSuccess = config.onSuccess;
@@ -1079,10 +1080,10 @@ var ConnectSDK = (() => {
1079
1080
  this.mode = context.mode;
1080
1081
  this.connectOrigin = new URL(Endpoints.benji_connect_auth_url).origin;
1081
1082
  if (this.canDeliverToConnectIframe()) {
1082
- this.flushPendingHostAuth();
1083
- this.flushPendingPopupAuth();
1083
+ this.flushPendingLoginSameTabAuth();
1084
+ this.flushPendingLoginPopupAuth();
1084
1085
  } else {
1085
- this.startIframeDeliverabilityPoll();
1086
+ this.startLoginConnectIframeDeliverabilityPoll();
1086
1087
  }
1087
1088
  }
1088
1089
  static resetIframeReady() {
@@ -1091,7 +1092,7 @@ var ConnectSDK = (() => {
1091
1092
  static setMode(mode) {
1092
1093
  this.mode = mode;
1093
1094
  if (mode !== 5 /* LOGIN */) {
1094
- this.stopIframeDeliverabilityPoll();
1095
+ this.stopLoginConnectIframeDeliverabilityPoll();
1095
1096
  }
1096
1097
  }
1097
1098
  static addEventListeners() {
@@ -1105,17 +1106,17 @@ var ConnectSDK = (() => {
1105
1106
  window.removeEventListener("error", this.errorEventHandler);
1106
1107
  window.removeEventListener("unhandledrejection", this.errorEventHandler);
1107
1108
  window.removeEventListener("message", this.messageEventHandler);
1108
- this.stopIframeDeliverabilityPoll();
1109
- this.stopHostAuthRedelivery();
1109
+ this.stopLoginConnectIframeDeliverabilityPoll();
1110
+ this.stopLoginSameTabAuthRedelivery();
1110
1111
  this.configuredListeners = false;
1111
1112
  this.iframe = null;
1112
1113
  this.loginPopup = null;
1113
1114
  this.mode = 1 /* CONNECT */;
1114
1115
  this.connectOrigin = "";
1115
1116
  this.isIframeReady = false;
1116
- this.pendingPopupAuth = [];
1117
- this.pendingHostAuth = [];
1118
- this.lastVerifiedPopupSource = null;
1117
+ this.pendingLoginPopupAuth = [];
1118
+ this.pendingLoginSameTabAuth = [];
1119
+ this.lastVerifiedLoginPopupSource = null;
1119
1120
  }
1120
1121
  static handleErrorMessage(event) {
1121
1122
  switch (event.type) {
@@ -1136,53 +1137,53 @@ var ConnectSDK = (() => {
1136
1137
  }
1137
1138
  }
1138
1139
  static canDeliverToConnectIframe() {
1139
- return canDeliverAuthToConnectIframe(this.iframe);
1140
+ return canDeliverLoginAuthToConnectIframe(this.iframe);
1140
1141
  }
1141
- static startIframeDeliverabilityPoll() {
1142
- if (this.iframeDeliverabilityPoll !== null || this.mode !== 5 /* LOGIN */ || this.pendingPopupAuth.length === 0) {
1142
+ static startLoginConnectIframeDeliverabilityPoll() {
1143
+ if (this.loginConnectIframeDeliverabilityPoll !== null || this.mode !== 5 /* LOGIN */ || this.pendingLoginPopupAuth.length === 0) {
1143
1144
  return;
1144
1145
  }
1145
- this.iframeDeliverabilityPoll = window.setInterval(() => {
1146
- if (this.mode !== 5 /* LOGIN */ || this.pendingPopupAuth.length === 0) {
1147
- this.stopIframeDeliverabilityPoll();
1146
+ this.loginConnectIframeDeliverabilityPoll = window.setInterval(() => {
1147
+ if (this.mode !== 5 /* LOGIN */ || this.pendingLoginPopupAuth.length === 0) {
1148
+ this.stopLoginConnectIframeDeliverabilityPoll();
1148
1149
  return;
1149
1150
  }
1150
1151
  if (this.canDeliverToConnectIframe()) {
1151
- this.flushPendingPopupAuth();
1152
+ this.flushPendingLoginPopupAuth();
1152
1153
  }
1153
- }, IFRAME_DELIVERABILITY_POLL_MS);
1154
+ }, LOGIN_IFRAME_DELIVERABILITY_POLL_MS);
1154
1155
  }
1155
- static stopIframeDeliverabilityPoll() {
1156
- if (this.iframeDeliverabilityPoll === null) return;
1157
- window.clearInterval(this.iframeDeliverabilityPoll);
1158
- this.iframeDeliverabilityPoll = null;
1156
+ static stopLoginConnectIframeDeliverabilityPoll() {
1157
+ if (this.loginConnectIframeDeliverabilityPoll === null) return;
1158
+ window.clearInterval(this.loginConnectIframeDeliverabilityPoll);
1159
+ this.loginConnectIframeDeliverabilityPoll = null;
1159
1160
  }
1160
1161
  // Forward popup/tab auth payloads into Connect. Queue until deliverable.
1161
- static relayToIframe(event) {
1162
+ static relayToLoginConnectIframe(event) {
1162
1163
  var _a;
1163
1164
  const type = authMessageType(event.data);
1164
1165
  const deliverable = this.canDeliverToConnectIframe();
1165
1166
  const iframeWindow = (_a = this.iframe) == null ? void 0 : _a.contentWindow;
1166
1167
  if (!iframeWindow || !deliverable) {
1167
- this.pendingPopupAuth.push(event);
1168
- this.startIframeDeliverabilityPoll();
1169
- console.debug("[Benji Connect SDK] LOGIN relayToIframe queued", {
1168
+ this.pendingLoginPopupAuth.push(event);
1169
+ this.startLoginConnectIframeDeliverabilityPoll();
1170
+ console.debug("[Benji Connect SDK] LOGIN relayToLoginConnectIframe queued", {
1170
1171
  type,
1171
1172
  queued: true,
1172
- pendingCount: this.pendingPopupAuth.length,
1173
+ pendingCount: this.pendingLoginPopupAuth.length,
1173
1174
  isIframeReady: this.isIframeReady,
1174
1175
  deliverable
1175
1176
  });
1176
1177
  return;
1177
1178
  }
1178
- if (this.pendingPopupAuth.length > 0) {
1179
- this.flushPendingPopupAuth();
1179
+ if (this.pendingLoginPopupAuth.length > 0) {
1180
+ this.flushPendingLoginPopupAuth();
1180
1181
  }
1181
1182
  iframeWindow.postMessage(event.data, this.connectOrigin);
1182
- console.debug("[Benji Connect SDK] LOGIN relayToIframe posted", {
1183
+ console.debug("[Benji Connect SDK] LOGIN relayToLoginConnectIframe posted", {
1183
1184
  type,
1184
1185
  queued: false,
1185
- pendingCount: this.pendingPopupAuth.length,
1186
+ pendingCount: this.pendingLoginPopupAuth.length,
1186
1187
  isIframeReady: this.isIframeReady,
1187
1188
  deliverable
1188
1189
  });
@@ -1191,52 +1192,52 @@ var ConnectSDK = (() => {
1191
1192
  * Same-tab LOGIN resume: post immediately, then re-post on an interval until
1192
1193
  * FLOW_SUCCESS / onError / close stops redelivery. Connect dedupes repeats.
1193
1194
  */
1194
- static startHostAuthRedelivery(payload, intervalMs = HOST_AUTH_REDELIVERY_MS) {
1195
- this.stopHostAuthRedelivery();
1196
- this.upsertPendingHostAuth(payload);
1197
- this.flushPendingHostAuth();
1198
- this.hostAuthRedeliveryId = window.setInterval(() => {
1199
- if (!this.pendingHostAuth.length) {
1200
- this.stopHostAuthRedelivery();
1195
+ static startLoginSameTabAuthRedelivery(payload, intervalMs = LOGIN_SAME_TAB_AUTH_REDELIVERY_MS) {
1196
+ this.stopLoginSameTabAuthRedelivery();
1197
+ this.upsertPendingLoginSameTabAuth(payload);
1198
+ this.flushPendingLoginSameTabAuth();
1199
+ this.loginSameTabAuthRedeliveryId = window.setInterval(() => {
1200
+ if (!this.pendingLoginSameTabAuth.length) {
1201
+ this.stopLoginSameTabAuthRedelivery();
1201
1202
  return;
1202
1203
  }
1203
- this.flushPendingHostAuth();
1204
+ this.flushPendingLoginSameTabAuth();
1204
1205
  }, intervalMs);
1205
1206
  }
1206
- static stopHostAuthRedelivery() {
1207
- if (this.hostAuthRedeliveryId !== null) {
1208
- window.clearInterval(this.hostAuthRedeliveryId);
1209
- this.hostAuthRedeliveryId = null;
1207
+ static stopLoginSameTabAuthRedelivery() {
1208
+ if (this.loginSameTabAuthRedeliveryId !== null) {
1209
+ window.clearInterval(this.loginSameTabAuthRedeliveryId);
1210
+ this.loginSameTabAuthRedeliveryId = null;
1210
1211
  }
1211
- this.pendingHostAuth = [];
1212
+ this.pendingLoginSameTabAuth = [];
1212
1213
  }
1213
- static upsertPendingHostAuth(payload) {
1214
+ static upsertPendingLoginSameTabAuth(payload) {
1214
1215
  const type = authMessageType(payload);
1215
1216
  if (!type) {
1216
- this.pendingHostAuth.push(payload);
1217
+ this.pendingLoginSameTabAuth.push(payload);
1217
1218
  return;
1218
1219
  }
1219
- const existingIndex = this.pendingHostAuth.findIndex(
1220
+ const existingIndex = this.pendingLoginSameTabAuth.findIndex(
1220
1221
  (item) => authMessageType(item) === type
1221
1222
  );
1222
1223
  if (existingIndex >= 0) {
1223
- this.pendingHostAuth[existingIndex] = payload;
1224
+ this.pendingLoginSameTabAuth[existingIndex] = payload;
1224
1225
  } else {
1225
- this.pendingHostAuth.push(payload);
1226
+ this.pendingLoginSameTabAuth.push(payload);
1226
1227
  }
1227
1228
  }
1228
- static flushPendingHostAuth() {
1229
+ static flushPendingLoginSameTabAuth() {
1229
1230
  var _a, _b;
1230
- if (!this.pendingHostAuth.length) return;
1231
+ if (!this.pendingLoginSameTabAuth.length) return;
1231
1232
  const iframeWindow = (_b = (_a = this.iframe) == null ? void 0 : _a.contentWindow) != null ? _b : null;
1232
1233
  if (!iframeWindow || !this.canDeliverToConnectIframe()) {
1233
1234
  return;
1234
1235
  }
1235
- const queued = [...this.pendingHostAuth];
1236
+ const queued = [...this.pendingLoginSameTabAuth];
1236
1237
  for (const payload of queued) {
1237
1238
  iframeWindow.postMessage(payload, this.connectOrigin);
1238
1239
  }
1239
- console.debug("[Benji Connect SDK] LOGIN flushPendingHostAuth", {
1240
+ console.debug("[Benji Connect SDK] LOGIN flushPendingLoginSameTabAuth", {
1240
1241
  flushedCount: queued.length
1241
1242
  });
1242
1243
  }
@@ -1244,36 +1245,36 @@ var ConnectSDK = (() => {
1244
1245
  if (this.iframe !== iframe) return;
1245
1246
  this.isIframeReady = true;
1246
1247
  console.debug("[Benji Connect SDK] LOGIN iframe_load");
1247
- this.flushPendingHostAuth();
1248
- this.flushPendingPopupAuth();
1248
+ this.flushPendingLoginSameTabAuth();
1249
+ this.flushPendingLoginPopupAuth();
1249
1250
  }
1250
- static flushPendingPopupAuth() {
1251
+ static flushPendingLoginPopupAuth() {
1251
1252
  var _a, _b;
1252
1253
  const iframeWindow = (_b = (_a = this.iframe) == null ? void 0 : _a.contentWindow) != null ? _b : null;
1253
- if (!this.pendingPopupAuth.length) {
1254
- this.stopIframeDeliverabilityPoll();
1254
+ if (!this.pendingLoginPopupAuth.length) {
1255
+ this.stopLoginConnectIframeDeliverabilityPoll();
1255
1256
  return;
1256
1257
  }
1257
1258
  if (!iframeWindow) {
1258
- this.startIframeDeliverabilityPoll();
1259
+ this.startLoginConnectIframeDeliverabilityPoll();
1259
1260
  return;
1260
1261
  }
1261
1262
  if (!this.canDeliverToConnectIframe()) {
1262
- this.startIframeDeliverabilityPoll();
1263
- console.debug("[Benji Connect SDK] LOGIN flushPendingPopupAuth skipped", {
1264
- pendingCount: this.pendingPopupAuth.length,
1263
+ this.startLoginConnectIframeDeliverabilityPoll();
1264
+ console.debug("[Benji Connect SDK] LOGIN flushPendingLoginPopupAuth skipped", {
1265
+ pendingCount: this.pendingLoginPopupAuth.length,
1265
1266
  isIframeReady: this.isIframeReady,
1266
1267
  deliverable: false
1267
1268
  });
1268
1269
  return;
1269
1270
  }
1270
1271
  const expectedOrigin = this.connectOrigin || new URL(Endpoints.benji_connect_auth_url).origin;
1271
- const queued = [...this.pendingPopupAuth];
1272
+ const queued = [...this.pendingLoginPopupAuth];
1272
1273
  let flushedCount = 0;
1273
1274
  let skippedNotOriginated = 0;
1274
1275
  const remaining = [];
1275
1276
  for (const event of queued) {
1276
- if (!isPopupOriginatedAuth(
1277
+ if (!isLoginPopupOriginatedAuth(
1277
1278
  event,
1278
1279
  this.loginPopup,
1279
1280
  iframeWindow,
@@ -1289,45 +1290,45 @@ var ConnectSDK = (() => {
1289
1290
  iframeWindow.postMessage(event.data, this.connectOrigin);
1290
1291
  flushedCount += 1;
1291
1292
  }
1292
- this.pendingPopupAuth = remaining;
1293
- if (this.pendingPopupAuth.length === 0) {
1294
- this.stopIframeDeliverabilityPoll();
1293
+ this.pendingLoginPopupAuth = remaining;
1294
+ if (this.pendingLoginPopupAuth.length === 0) {
1295
+ this.stopLoginConnectIframeDeliverabilityPoll();
1295
1296
  } else {
1296
- this.startIframeDeliverabilityPoll();
1297
+ this.startLoginConnectIframeDeliverabilityPoll();
1297
1298
  }
1298
- console.debug("[Benji Connect SDK] LOGIN flushPendingPopupAuth", {
1299
+ console.debug("[Benji Connect SDK] LOGIN flushPendingLoginPopupAuth", {
1299
1300
  pendingCount: queued.length,
1300
1301
  flushedCount,
1301
1302
  skippedNotOriginated,
1302
- remainingCount: this.pendingPopupAuth.length
1303
+ remainingCount: this.pendingLoginPopupAuth.length
1303
1304
  });
1304
1305
  }
1305
- static relayToPopup(payload) {
1306
+ static relayToLoginPopup(payload) {
1306
1307
  var _a, _b, _c, _d, _e, _f, _g, _h;
1307
1308
  const type = authMessageType(payload);
1308
1309
  const target = resolveLoginPartnerWindow(
1309
1310
  this.loginPopup,
1310
- this.lastVerifiedPopupSource
1311
+ this.lastVerifiedLoginPopupSource
1311
1312
  );
1312
1313
  const targetLabel = describeLoginPartnerWindowTarget(
1313
1314
  target,
1314
1315
  this.loginPopup,
1315
- this.lastVerifiedPopupSource
1316
+ this.lastVerifiedLoginPopupSource
1316
1317
  );
1317
1318
  if (!target) {
1318
1319
  console.warn("[Benji Connect SDK] Skipping login auth relay, no live partner window", {
1319
1320
  type,
1320
1321
  target: targetLabel,
1321
1322
  loginPopupClosed: (_b = (_a = this.loginPopup) == null ? void 0 : _a.closed) != null ? _b : true,
1322
- lastVerifiedClosed: (_d = (_c = this.lastVerifiedPopupSource) == null ? void 0 : _c.closed) != null ? _d : true
1323
+ lastVerifiedClosed: (_d = (_c = this.lastVerifiedLoginPopupSource) == null ? void 0 : _c.closed) != null ? _d : true
1323
1324
  });
1324
1325
  return;
1325
1326
  }
1326
- console.debug("[Benji Connect SDK] LOGIN relayToPopup", {
1327
+ console.debug("[Benji Connect SDK] LOGIN relayToLoginPopup", {
1327
1328
  type,
1328
1329
  target: targetLabel,
1329
1330
  loginPopupClosed: (_f = (_e = this.loginPopup) == null ? void 0 : _e.closed) != null ? _f : true,
1330
- lastVerifiedClosed: (_h = (_g = this.lastVerifiedPopupSource) == null ? void 0 : _g.closed) != null ? _h : true
1331
+ lastVerifiedClosed: (_h = (_g = this.lastVerifiedLoginPopupSource) == null ? void 0 : _g.closed) != null ? _h : true
1331
1332
  });
1332
1333
  try {
1333
1334
  target.postMessage(payload, "*");
@@ -1355,19 +1356,19 @@ var ConnectSDK = (() => {
1355
1356
  origin: event.origin,
1356
1357
  direction: "iframe_to_popup"
1357
1358
  });
1358
- this.relayToPopup(event.data);
1359
+ this.relayToLoginPopup(event.data);
1359
1360
  return;
1360
1361
  }
1361
- if (isPopupOriginatedAuth(event, this.loginPopup, iframeWindow != null ? iframeWindow : null, expectedOrigin2)) {
1362
+ if (isLoginPopupOriginatedAuth(event, this.loginPopup, iframeWindow != null ? iframeWindow : null, expectedOrigin2)) {
1362
1363
  if (isMessageWindow(event.source)) {
1363
- this.lastVerifiedPopupSource = event.source;
1364
+ this.lastVerifiedLoginPopupSource = event.source;
1364
1365
  }
1365
1366
  console.debug("[Benji Connect SDK] LOGIN auth relay", {
1366
1367
  type,
1367
1368
  origin: event.origin,
1368
1369
  direction: "popup_to_iframe"
1369
1370
  });
1370
- this.relayToIframe(event);
1371
+ this.relayToLoginConnectIframe(event);
1371
1372
  return;
1372
1373
  }
1373
1374
  console.warn("[Benji Connect SDK] LOGIN auth relay unclassified", {
@@ -1449,19 +1450,19 @@ var ConnectSDK = (() => {
1449
1450
  _MessageRouter.mode = 1 /* CONNECT */;
1450
1451
  _MessageRouter.connectOrigin = "";
1451
1452
  _MessageRouter.isIframeReady = false;
1452
- _MessageRouter.pendingPopupAuth = [];
1453
+ _MessageRouter.pendingLoginPopupAuth = [];
1453
1454
  /**
1454
1455
  * Sticky host→iframe auth (same-tab LOGIN resume). Kept after each post so
1455
1456
  * redelivery can cover the window where the iframe is "deliverable" but
1456
1457
  * Connect has not installed its message listener yet.
1457
- * Invariant: only `startHostAuthRedelivery` writes this queue, and it always
1458
+ * Invariant: only `startLoginSameTabAuthRedelivery` writes this queue, and it always
1458
1459
  * owns a timer while the queue is non-empty. The deliverability poll is
1459
1460
  * popup-only so it cannot double-post this payload.
1460
1461
  */
1461
- _MessageRouter.pendingHostAuth = [];
1462
- _MessageRouter.hostAuthRedeliveryId = null;
1463
- _MessageRouter.lastVerifiedPopupSource = null;
1464
- _MessageRouter.iframeDeliverabilityPoll = null;
1462
+ _MessageRouter.pendingLoginSameTabAuth = [];
1463
+ _MessageRouter.loginSameTabAuthRedeliveryId = null;
1464
+ _MessageRouter.lastVerifiedLoginPopupSource = null;
1465
+ _MessageRouter.loginConnectIframeDeliverabilityPoll = null;
1465
1466
  _MessageRouter.errorEventHandler = (event) => {
1466
1467
  return _MessageRouter.handleErrorMessage(event);
1467
1468
  };
@@ -1471,8 +1472,6 @@ var ConnectSDK = (() => {
1471
1472
  var MessageRouter = _MessageRouter;
1472
1473
 
1473
1474
  // src/connect-sdk.ts
1474
- var POPUP_CLOSED_POLL_MS = 500;
1475
- var SAME_TAB_RESUME_TIMEOUT_MS = 45e3;
1476
1475
  var ConnectSDK = class {
1477
1476
  constructor(config) {
1478
1477
  this.iframe = null;
@@ -1595,7 +1594,7 @@ var ConnectSDK = (() => {
1595
1594
  onSuccess: (token, metadata) => {
1596
1595
  var _a, _b;
1597
1596
  this.clearSameTabResumeTimeout();
1598
- MessageRouter.stopHostAuthRedelivery();
1597
+ MessageRouter.stopLoginSameTabAuthRedelivery();
1599
1598
  (_b = (_a = this.sdkConfig).onSuccess) == null ? void 0 : _b.call(_a, token, metadata);
1600
1599
  },
1601
1600
  onError: (error, errorId, metadata) => {
@@ -1604,7 +1603,7 @@ var ConnectSDK = (() => {
1604
1603
  this.close();
1605
1604
  } else {
1606
1605
  this.clearSameTabResumeTimeout();
1607
- MessageRouter.stopHostAuthRedelivery();
1606
+ MessageRouter.stopLoginSameTabAuthRedelivery();
1608
1607
  }
1609
1608
  (_b = (_a = this.sdkConfig).onError) == null ? void 0 : _b.call(_a, error, errorId, metadata);
1610
1609
  },
@@ -1625,7 +1624,8 @@ var ConnectSDK = (() => {
1625
1624
  const partnerAuthLink = (_a = this.sdkConfig.tokenData) == null ? void 0 : _a.partnerAuthLink;
1626
1625
  const configToken = (_b = this.sdkConfig.tokenData) == null ? void 0 : _b.configToken;
1627
1626
  const preparedLink = partnerAuthLink && configToken ? preparePartnerAuthUrl(partnerAuthLink, configToken) : partnerAuthLink;
1628
- const popupUrl = preparedLink ? appendLoginPopupFlag(preparedLink) : "about:blank";
1627
+ const popupLink = preparedLink && Environment === "local" /* LOCAL */ ? rewriteVerifyAppUrlForLocalConnect(preparedLink) : preparedLink;
1628
+ const popupUrl = popupLink ? appendLoginPopupFlag(popupLink) : "about:blank";
1629
1629
  this.loginPopup = window.open(
1630
1630
  popupUrl,
1631
1631
  LOGIN_PARTNER_POPUP_NAME,
@@ -1641,7 +1641,7 @@ var ConnectSDK = (() => {
1641
1641
  );
1642
1642
  return false;
1643
1643
  }
1644
- if (preparedLink) {
1644
+ if (popupLink) {
1645
1645
  this.hasLoginPopupUrl = true;
1646
1646
  } else {
1647
1647
  writeLoginPopupLoadingDocument(this.loginPopup);
@@ -1657,7 +1657,7 @@ var ConnectSDK = (() => {
1657
1657
  if ((_a = this.loginPopup) == null ? void 0 : _a.closed) {
1658
1658
  const live = resolveLoginPartnerWindow(
1659
1659
  this.loginPopup,
1660
- MessageRouter.lastVerifiedPopupSource
1660
+ MessageRouter.lastVerifiedLoginPopupSource
1661
1661
  );
1662
1662
  if (live) {
1663
1663
  console.debug("[Benji Connect SDK] LOGIN popup_closed_poll skipped, live partner window remains");
@@ -1670,7 +1670,7 @@ var ConnectSDK = (() => {
1670
1670
  });
1671
1671
  this.close();
1672
1672
  }
1673
- }, POPUP_CLOSED_POLL_MS);
1673
+ }, LOGIN_POPUP_CLOSED_POLL_MS);
1674
1674
  }
1675
1675
  stopPopupClosedPoll() {
1676
1676
  if (this.popupClosedPollId != null) {
@@ -1748,7 +1748,7 @@ var ConnectSDK = (() => {
1748
1748
  token: params.state,
1749
1749
  redirectUri: (_a = params.redirectUri) != null ? _a : this.buildCallbackUrl(params.partnerId)
1750
1750
  });
1751
- MessageRouter.startHostAuthRedelivery(payload);
1751
+ MessageRouter.startLoginSameTabAuthRedelivery(payload);
1752
1752
  this.startSameTabResumeTimeout();
1753
1753
  }
1754
1754
  buildCallbackUrl(partnerId) {
@@ -1768,7 +1768,7 @@ var ConnectSDK = (() => {
1768
1768
  { context: buildContext() }
1769
1769
  );
1770
1770
  this.close();
1771
- }, SAME_TAB_RESUME_TIMEOUT_MS);
1771
+ }, LOGIN_SAME_TAB_RESUME_TIMEOUT_MS);
1772
1772
  }
1773
1773
  clearSameTabResumeTimeout() {
1774
1774
  if (this.sameTabResumeTimeoutId === null) return;
@@ -1794,7 +1794,7 @@ var ConnectSDK = (() => {
1794
1794
  applyOverlayBaseStyle(this.container);
1795
1795
  }
1796
1796
  console.debug("[Connect SDK] endpoints", Endpoints);
1797
- console.log("[Connect SDK] opeining URL", Endpoints.benji_connect_auth_url);
1797
+ console.debug("[Connect SDK] opening URL", Endpoints.benji_connect_auth_url);
1798
1798
  const url = new URL(Endpoints.benji_connect_auth_url);
1799
1799
  const connectToken = this.sdkConfig.token;
1800
1800
  url.searchParams.set("connect_token", connectToken);
@@ -1884,7 +1884,7 @@ var ConnectSDK = (() => {
1884
1884
  var _a, _b;
1885
1885
  this.abortInflightOpen();
1886
1886
  this.clearSameTabResumeTimeout();
1887
- MessageRouter.stopHostAuthRedelivery();
1887
+ MessageRouter.stopLoginSameTabAuthRedelivery();
1888
1888
  this.isResumingSameTabLogin = false;
1889
1889
  this.isClosing = true;
1890
1890
  this.stopPopupClosedPoll();