@edge-markets/connect-link 1.5.1 → 1.7.0

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.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { EdgeLinkConfigBase, EdgeScope, EdgeLinkSuccess, EdgeLinkExit, SdkGeolocation, PKCEPair } from '@edge-markets/connect';
2
- export { ALL_EDGE_SCOPES, EDGE_SCOPES, EdgeEnvironment, EdgeError, EdgeLinkEvent, EdgeLinkEventName, EdgeLinkExit, EdgeLinkSuccess, EdgePopupBlockedError, EdgeScope, EdgeStateMismatchError, PKCEPair, SdkGeolocation, isEdgeError } from '@edge-markets/connect';
1
+ import { EdgeLinkConfigBase, EdgeScope, SdkGeolocation, EdgeLinkSuccess, EdgeLinkExit, PKCEPair } from '@edge-markets/connect';
2
+ export { ACTIVE_EDGE_SCOPES, ALL_EDGE_SCOPES, EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE, EDGE_SCOPES, EdgeEnvironment, EdgeError, EdgeFeatureUnavailableError, EdgeLinkEvent, EdgeLinkEventName, EdgeLinkExit, EdgeLinkSuccess, EdgePopupBlockedError, EdgeScope, EdgeStateMismatchError, PKCEPair, SdkGeolocation, isEdgeError, isFeatureUnavailableError } from '@edge-markets/connect';
3
3
 
4
4
  /**
5
5
  * EdgeLink - Popup Authentication for EDGE Connect
@@ -170,6 +170,7 @@ declare class EdgeLink {
170
170
  * - Returning code via postMessage
171
171
  */
172
172
  private buildLinkUrl;
173
+ private assertActiveScopes;
173
174
  /**
174
175
  * Sets up the postMessage listener.
175
176
  */
@@ -200,18 +201,6 @@ declare class EdgeLink {
200
201
  private cleanup;
201
202
  }
202
203
 
203
- interface UseEdgeLinkConfig extends Omit<EdgeLinkConfig, 'onSuccess' | 'onExit'> {
204
- onSuccess?: (result: EdgeLinkSuccess) => void | Promise<void>;
205
- onExit?: (metadata: EdgeLinkExit) => void;
206
- }
207
- interface UseEdgeLinkReturn {
208
- open: (options?: EdgeLinkOpenOptions) => void;
209
- ready: boolean;
210
- error: Error | null;
211
- isOpen: boolean;
212
- }
213
- declare function useEdgeLink(config: UseEdgeLinkConfig): UseEdgeLinkReturn;
214
-
215
204
  /**
216
205
  * EdgeTransferVerify - Transfer Verification Launcher for EDGE Connect
217
206
  *
@@ -634,6 +623,37 @@ declare class EdgeTransferVerify {
634
623
  private handleUserClose;
635
624
  }
636
625
 
626
+ interface UseEdgeLinkConfig extends Omit<EdgeLinkConfig, 'onSuccess' | 'onExit'> {
627
+ onSuccess?: (result: EdgeLinkSuccess) => void | Promise<void>;
628
+ onExit?: (metadata: EdgeLinkExit) => void;
629
+ }
630
+ interface UseEdgeLinkReturn {
631
+ open: (options?: EdgeLinkOpenOptions) => void;
632
+ ready: boolean;
633
+ error: Error | null;
634
+ isOpen: boolean;
635
+ }
636
+ declare function useEdgeLink(config: UseEdgeLinkConfig): UseEdgeLinkReturn;
637
+ interface UseEdgeTransferVerifyConfig extends Omit<EdgeTransferVerifyConfig, 'onSuccess' | 'onError' | 'onCancel' | 'onExpired' | 'onLoaded' | 'onEvent'> {
638
+ onSuccess?: (event: TransferVerifyEvent) => void | Promise<void>;
639
+ onError?: (event: TransferVerifyEvent) => void | Promise<void>;
640
+ onCancel?: (event: TransferVerifyEvent) => void | Promise<void>;
641
+ onExpired?: (event: TransferVerifyEvent) => void | Promise<void>;
642
+ onLoaded?: (event: TransferVerifyEvent) => void | Promise<void>;
643
+ onEvent?: (event: TransferVerifyEvent) => void | Promise<void>;
644
+ }
645
+ interface UseEdgeTransferVerifyReturn {
646
+ open: () => void;
647
+ close: () => void;
648
+ destroy: () => void;
649
+ ready: boolean;
650
+ isOpen: boolean;
651
+ isLoaded: boolean;
652
+ lastEvent: TransferVerifyEvent | null;
653
+ error: Error | null;
654
+ }
655
+ declare function useEdgeTransferVerify(config: UseEdgeTransferVerifyConfig): UseEdgeTransferVerifyReturn;
656
+
637
657
  /**
638
658
  * Iframe Manager
639
659
  *
@@ -879,4 +899,4 @@ declare function generateState(): string;
879
899
  */
880
900
  declare function assertCryptoAvailable(): void;
881
901
 
882
- export { EdgeLink, type EdgeLinkConfig, type EdgeLinkOpenOptions, EdgeTransferVerify, type EdgeTransferVerifyConfig, type GeolocationOptions, type IframeCallbacks, type IframeConfig, IframeManager, type TransferVerifyEvent, type TransferVerifyEventType, type TransferVerifyMode, type UseEdgeLinkConfig, type UseEdgeLinkReturn, assertCryptoAvailable, collectGeolocation, generatePKCE, generateState, useEdgeLink };
902
+ export { EdgeLink, type EdgeLinkConfig, type EdgeLinkOpenOptions, EdgeTransferVerify, type EdgeTransferVerifyConfig, type GeolocationOptions, type IframeCallbacks, type IframeConfig, IframeManager, type TransferVerifyEvent, type TransferVerifyEventType, type TransferVerifyMode, type UseEdgeLinkConfig, type UseEdgeLinkReturn, type UseEdgeTransferVerifyConfig, type UseEdgeTransferVerifyReturn, assertCryptoAvailable, collectGeolocation, generatePKCE, generateState, useEdgeLink, useEdgeTransferVerify };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { EdgeLinkConfigBase, EdgeScope, EdgeLinkSuccess, EdgeLinkExit, SdkGeolocation, PKCEPair } from '@edge-markets/connect';
2
- export { ALL_EDGE_SCOPES, EDGE_SCOPES, EdgeEnvironment, EdgeError, EdgeLinkEvent, EdgeLinkEventName, EdgeLinkExit, EdgeLinkSuccess, EdgePopupBlockedError, EdgeScope, EdgeStateMismatchError, PKCEPair, SdkGeolocation, isEdgeError } from '@edge-markets/connect';
1
+ import { EdgeLinkConfigBase, EdgeScope, SdkGeolocation, EdgeLinkSuccess, EdgeLinkExit, PKCEPair } from '@edge-markets/connect';
2
+ export { ACTIVE_EDGE_SCOPES, ALL_EDGE_SCOPES, EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE, EDGE_SCOPES, EdgeEnvironment, EdgeError, EdgeFeatureUnavailableError, EdgeLinkEvent, EdgeLinkEventName, EdgeLinkExit, EdgeLinkSuccess, EdgePopupBlockedError, EdgeScope, EdgeStateMismatchError, PKCEPair, SdkGeolocation, isEdgeError, isFeatureUnavailableError } from '@edge-markets/connect';
3
3
 
4
4
  /**
5
5
  * EdgeLink - Popup Authentication for EDGE Connect
@@ -170,6 +170,7 @@ declare class EdgeLink {
170
170
  * - Returning code via postMessage
171
171
  */
172
172
  private buildLinkUrl;
173
+ private assertActiveScopes;
173
174
  /**
174
175
  * Sets up the postMessage listener.
175
176
  */
@@ -200,18 +201,6 @@ declare class EdgeLink {
200
201
  private cleanup;
201
202
  }
202
203
 
203
- interface UseEdgeLinkConfig extends Omit<EdgeLinkConfig, 'onSuccess' | 'onExit'> {
204
- onSuccess?: (result: EdgeLinkSuccess) => void | Promise<void>;
205
- onExit?: (metadata: EdgeLinkExit) => void;
206
- }
207
- interface UseEdgeLinkReturn {
208
- open: (options?: EdgeLinkOpenOptions) => void;
209
- ready: boolean;
210
- error: Error | null;
211
- isOpen: boolean;
212
- }
213
- declare function useEdgeLink(config: UseEdgeLinkConfig): UseEdgeLinkReturn;
214
-
215
204
  /**
216
205
  * EdgeTransferVerify - Transfer Verification Launcher for EDGE Connect
217
206
  *
@@ -634,6 +623,37 @@ declare class EdgeTransferVerify {
634
623
  private handleUserClose;
635
624
  }
636
625
 
626
+ interface UseEdgeLinkConfig extends Omit<EdgeLinkConfig, 'onSuccess' | 'onExit'> {
627
+ onSuccess?: (result: EdgeLinkSuccess) => void | Promise<void>;
628
+ onExit?: (metadata: EdgeLinkExit) => void;
629
+ }
630
+ interface UseEdgeLinkReturn {
631
+ open: (options?: EdgeLinkOpenOptions) => void;
632
+ ready: boolean;
633
+ error: Error | null;
634
+ isOpen: boolean;
635
+ }
636
+ declare function useEdgeLink(config: UseEdgeLinkConfig): UseEdgeLinkReturn;
637
+ interface UseEdgeTransferVerifyConfig extends Omit<EdgeTransferVerifyConfig, 'onSuccess' | 'onError' | 'onCancel' | 'onExpired' | 'onLoaded' | 'onEvent'> {
638
+ onSuccess?: (event: TransferVerifyEvent) => void | Promise<void>;
639
+ onError?: (event: TransferVerifyEvent) => void | Promise<void>;
640
+ onCancel?: (event: TransferVerifyEvent) => void | Promise<void>;
641
+ onExpired?: (event: TransferVerifyEvent) => void | Promise<void>;
642
+ onLoaded?: (event: TransferVerifyEvent) => void | Promise<void>;
643
+ onEvent?: (event: TransferVerifyEvent) => void | Promise<void>;
644
+ }
645
+ interface UseEdgeTransferVerifyReturn {
646
+ open: () => void;
647
+ close: () => void;
648
+ destroy: () => void;
649
+ ready: boolean;
650
+ isOpen: boolean;
651
+ isLoaded: boolean;
652
+ lastEvent: TransferVerifyEvent | null;
653
+ error: Error | null;
654
+ }
655
+ declare function useEdgeTransferVerify(config: UseEdgeTransferVerifyConfig): UseEdgeTransferVerifyReturn;
656
+
637
657
  /**
638
658
  * Iframe Manager
639
659
  *
@@ -879,4 +899,4 @@ declare function generateState(): string;
879
899
  */
880
900
  declare function assertCryptoAvailable(): void;
881
901
 
882
- export { EdgeLink, type EdgeLinkConfig, type EdgeLinkOpenOptions, EdgeTransferVerify, type EdgeTransferVerifyConfig, type GeolocationOptions, type IframeCallbacks, type IframeConfig, IframeManager, type TransferVerifyEvent, type TransferVerifyEventType, type TransferVerifyMode, type UseEdgeLinkConfig, type UseEdgeLinkReturn, assertCryptoAvailable, collectGeolocation, generatePKCE, generateState, useEdgeLink };
902
+ export { EdgeLink, type EdgeLinkConfig, type EdgeLinkOpenOptions, EdgeTransferVerify, type EdgeTransferVerifyConfig, type GeolocationOptions, type IframeCallbacks, type IframeConfig, IframeManager, type TransferVerifyEvent, type TransferVerifyEventType, type TransferVerifyMode, type UseEdgeLinkConfig, type UseEdgeLinkReturn, type UseEdgeTransferVerifyConfig, type UseEdgeTransferVerifyReturn, assertCryptoAvailable, collectGeolocation, generatePKCE, generateState, useEdgeLink, useEdgeTransferVerify };
package/dist/index.js CHANGED
@@ -20,9 +20,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ ACTIVE_EDGE_SCOPES: () => import_connect4.ACTIVE_EDGE_SCOPES,
23
24
  ALL_EDGE_SCOPES: () => import_connect4.ALL_EDGE_SCOPES,
25
+ EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE: () => import_connect3.EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE,
24
26
  EDGE_SCOPES: () => import_connect4.EDGE_SCOPES,
25
27
  EdgeError: () => import_connect3.EdgeError,
28
+ EdgeFeatureUnavailableError: () => import_connect3.EdgeFeatureUnavailableError,
26
29
  EdgeLink: () => EdgeLink,
27
30
  EdgePopupBlockedError: () => import_connect3.EdgePopupBlockedError,
28
31
  EdgeStateMismatchError: () => import_connect3.EdgeStateMismatchError,
@@ -33,7 +36,9 @@ __export(index_exports, {
33
36
  generatePKCE: () => generatePKCE,
34
37
  generateState: () => generateState,
35
38
  isEdgeError: () => import_connect3.isEdgeError,
36
- useEdgeLink: () => useEdgeLink
39
+ isFeatureUnavailableError: () => import_connect3.isFeatureUnavailableError,
40
+ useEdgeLink: () => useEdgeLink,
41
+ useEdgeTransferVerify: () => useEdgeTransferVerify
37
42
  });
38
43
  module.exports = __toCommonJS(index_exports);
39
44
 
@@ -387,6 +392,8 @@ var EdgeLink = class {
387
392
  if (this.isDestroyed) {
388
393
  throw new Error("EdgeLink: Cannot open - instance has been destroyed");
389
394
  }
395
+ const scopes = options.scopes || this.config.scopes || import_connect.ACTIVE_EDGE_SCOPES;
396
+ this.assertActiveScopes(scopes);
390
397
  if (this.popup.isOpen() || this.isInitializing) {
391
398
  this.popup.focus();
392
399
  return;
@@ -406,7 +413,7 @@ var EdgeLink = class {
406
413
  });
407
414
  throw new import_connect.EdgePopupBlockedError();
408
415
  }
409
- this.initializeAuth(options.scopes || this.config.scopes || import_connect.ALL_EDGE_SCOPES);
416
+ this.initializeAuth(scopes);
410
417
  }
411
418
  /**
412
419
  * Closes the EdgeLink popup if open.
@@ -496,6 +503,11 @@ var EdgeLink = class {
496
503
  }
497
504
  return url.toString();
498
505
  }
506
+ assertActiveScopes(scopes) {
507
+ if (scopes.some((scope) => (0, import_connect.isTransferWriteScope)(scope))) {
508
+ throw new import_connect.EdgeFeatureUnavailableError();
509
+ }
510
+ }
499
511
  /**
500
512
  * Sets up the postMessage listener.
501
513
  */
@@ -612,56 +624,6 @@ var EdgeLink = class {
612
624
 
613
625
  // src/hooks.ts
614
626
  var import_react = require("react");
615
- function useEdgeLink(config) {
616
- const linkRef = (0, import_react.useRef)(null);
617
- const [ready, setReady] = (0, import_react.useState)(false);
618
- const [error, setError] = (0, import_react.useState)(null);
619
- const [isOpen, setIsOpen] = (0, import_react.useState)(false);
620
- const configRef = (0, import_react.useRef)(config);
621
- configRef.current = config;
622
- (0, import_react.useEffect)(() => {
623
- try {
624
- linkRef.current = new EdgeLink({
625
- ...configRef.current,
626
- onSuccess: (result) => {
627
- setIsOpen(false);
628
- configRef.current.onSuccess?.(result);
629
- },
630
- onExit: (metadata) => {
631
- setIsOpen(false);
632
- configRef.current.onExit?.(metadata);
633
- },
634
- onEvent: (event) => {
635
- if (event.eventName === "OPEN") setIsOpen(true);
636
- if (event.eventName === "CLOSE") setIsOpen(false);
637
- configRef.current.onEvent?.(event);
638
- }
639
- });
640
- setReady(true);
641
- setError(null);
642
- } catch (err) {
643
- setError(err instanceof Error ? err : new Error("Failed to initialize EdgeLink"));
644
- setReady(false);
645
- }
646
- return () => {
647
- linkRef.current?.destroy();
648
- linkRef.current = null;
649
- setReady(false);
650
- };
651
- }, [config.clientId, config.environment]);
652
- const open = (0, import_react.useCallback)((options) => {
653
- if (!linkRef.current) {
654
- setError(new Error("EdgeLink not initialized"));
655
- return;
656
- }
657
- try {
658
- linkRef.current.open(options);
659
- } catch (err) {
660
- setError(err instanceof Error ? err : new Error("Failed to open EdgeLink"));
661
- }
662
- }, []);
663
- return { open, ready, error, isOpen };
664
- }
665
627
 
666
628
  // src/edge-transfer-verify.ts
667
629
  var import_connect2 = require("@edge-markets/connect");
@@ -920,6 +882,7 @@ var EdgeTransferVerify = class {
920
882
  * ```
921
883
  */
922
884
  open() {
885
+ assertTransferFeatureAvailable();
923
886
  if (this.isDestroyed) {
924
887
  throw new Error("EdgeTransferVerify: Cannot open - instance has been destroyed");
925
888
  }
@@ -1217,6 +1180,161 @@ var EdgeTransferVerify = class {
1217
1180
  this.config.onCancel?.(syntheticEvent);
1218
1181
  }
1219
1182
  };
1183
+ function assertTransferFeatureAvailable() {
1184
+ if (!isTransferFeatureAvailable()) {
1185
+ throw new import_connect2.EdgeFeatureUnavailableError();
1186
+ }
1187
+ }
1188
+ function isTransferFeatureAvailable() {
1189
+ return false;
1190
+ }
1191
+
1192
+ // src/hooks.ts
1193
+ function useEdgeLink(config) {
1194
+ const linkRef = (0, import_react.useRef)(null);
1195
+ const [ready, setReady] = (0, import_react.useState)(false);
1196
+ const [error, setError] = (0, import_react.useState)(null);
1197
+ const [isOpen, setIsOpen] = (0, import_react.useState)(false);
1198
+ const configRef = (0, import_react.useRef)(config);
1199
+ configRef.current = config;
1200
+ (0, import_react.useEffect)(() => {
1201
+ try {
1202
+ linkRef.current = new EdgeLink({
1203
+ ...configRef.current,
1204
+ onSuccess: (result) => {
1205
+ setIsOpen(false);
1206
+ configRef.current.onSuccess?.(result);
1207
+ },
1208
+ onExit: (metadata) => {
1209
+ setIsOpen(false);
1210
+ configRef.current.onExit?.(metadata);
1211
+ },
1212
+ onEvent: (event) => {
1213
+ if (event.eventName === "OPEN") setIsOpen(true);
1214
+ if (event.eventName === "CLOSE") setIsOpen(false);
1215
+ configRef.current.onEvent?.(event);
1216
+ }
1217
+ });
1218
+ setReady(true);
1219
+ setError(null);
1220
+ } catch (err) {
1221
+ setError(err instanceof Error ? err : new Error("Failed to initialize EdgeLink"));
1222
+ setReady(false);
1223
+ }
1224
+ return () => {
1225
+ linkRef.current?.destroy();
1226
+ linkRef.current = null;
1227
+ setReady(false);
1228
+ };
1229
+ }, [config.clientId, config.environment]);
1230
+ const open = (0, import_react.useCallback)((options) => {
1231
+ if (!linkRef.current) {
1232
+ setError(new Error("EdgeLink not initialized"));
1233
+ return;
1234
+ }
1235
+ try {
1236
+ linkRef.current.open(options);
1237
+ } catch (err) {
1238
+ setError(err instanceof Error ? err : new Error("Failed to open EdgeLink"));
1239
+ }
1240
+ }, []);
1241
+ return { open, ready, error, isOpen };
1242
+ }
1243
+ function useEdgeTransferVerify(config) {
1244
+ const verifyRef = (0, import_react.useRef)(null);
1245
+ const [ready, setReady] = (0, import_react.useState)(false);
1246
+ const [isOpen, setIsOpen] = (0, import_react.useState)(false);
1247
+ const [isLoaded, setIsLoaded] = (0, import_react.useState)(false);
1248
+ const [lastEvent, setLastEvent] = (0, import_react.useState)(null);
1249
+ const [error, setError] = (0, import_react.useState)(null);
1250
+ const configRef = (0, import_react.useRef)(config);
1251
+ configRef.current = config;
1252
+ (0, import_react.useEffect)(() => {
1253
+ if ((configRef.current.mode || "iframe") === "iframe" && !configRef.current.container) {
1254
+ verifyRef.current = null;
1255
+ setReady(false);
1256
+ setError(null);
1257
+ setIsLoaded(false);
1258
+ setLastEvent(null);
1259
+ return;
1260
+ }
1261
+ try {
1262
+ verifyRef.current = new EdgeTransferVerify({
1263
+ ...configRef.current,
1264
+ onSuccess: (event) => {
1265
+ setIsOpen(false);
1266
+ setLastEvent(event);
1267
+ void configRef.current.onSuccess?.(event);
1268
+ },
1269
+ onError: (event) => {
1270
+ setIsOpen(false);
1271
+ setLastEvent(event);
1272
+ setError(new Error(event.error || "EDGE transfer verification failed"));
1273
+ void configRef.current.onError?.(event);
1274
+ },
1275
+ onCancel: (event) => {
1276
+ setIsOpen(false);
1277
+ setLastEvent(event);
1278
+ void configRef.current.onCancel?.(event);
1279
+ },
1280
+ onExpired: (event) => {
1281
+ setIsOpen(false);
1282
+ setLastEvent(event);
1283
+ void configRef.current.onExpired?.(event);
1284
+ },
1285
+ onLoaded: (event) => {
1286
+ setIsLoaded(true);
1287
+ setLastEvent(event);
1288
+ void configRef.current.onLoaded?.(event);
1289
+ },
1290
+ onEvent: (event) => {
1291
+ setLastEvent(event);
1292
+ void configRef.current.onEvent?.(event);
1293
+ }
1294
+ });
1295
+ setReady(true);
1296
+ setError(null);
1297
+ setIsLoaded(false);
1298
+ setLastEvent(null);
1299
+ } catch (err) {
1300
+ setError(err instanceof Error ? err : new Error("Failed to initialize EdgeTransferVerify"));
1301
+ setReady(false);
1302
+ }
1303
+ return () => {
1304
+ verifyRef.current?.destroy();
1305
+ verifyRef.current = null;
1306
+ setReady(false);
1307
+ setIsOpen(false);
1308
+ setIsLoaded(false);
1309
+ };
1310
+ }, [config.verificationUrl, config.sessionId, config.nonce, config.mode, config.container]);
1311
+ const open = (0, import_react.useCallback)(() => {
1312
+ if (!verifyRef.current) {
1313
+ setError(new Error("EdgeTransferVerify not initialized"));
1314
+ return;
1315
+ }
1316
+ try {
1317
+ verifyRef.current.open();
1318
+ setIsOpen(true);
1319
+ setError(null);
1320
+ } catch (err) {
1321
+ setError(err instanceof Error ? err : new Error("Failed to open EdgeTransferVerify"));
1322
+ setIsOpen(false);
1323
+ }
1324
+ }, []);
1325
+ const close = (0, import_react.useCallback)(() => {
1326
+ verifyRef.current?.close();
1327
+ setIsOpen(false);
1328
+ }, []);
1329
+ const destroy = (0, import_react.useCallback)(() => {
1330
+ verifyRef.current?.destroy();
1331
+ verifyRef.current = null;
1332
+ setReady(false);
1333
+ setIsOpen(false);
1334
+ setIsLoaded(false);
1335
+ }, []);
1336
+ return { open, close, destroy, ready, isOpen, isLoaded, lastEvent, error };
1337
+ }
1220
1338
 
1221
1339
  // src/geolocation.ts
1222
1340
  async function collectGeolocation(options) {
@@ -1247,9 +1365,12 @@ var import_connect3 = require("@edge-markets/connect");
1247
1365
  var import_connect4 = require("@edge-markets/connect");
1248
1366
  // Annotate the CommonJS export names for ESM import in node:
1249
1367
  0 && (module.exports = {
1368
+ ACTIVE_EDGE_SCOPES,
1250
1369
  ALL_EDGE_SCOPES,
1370
+ EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE,
1251
1371
  EDGE_SCOPES,
1252
1372
  EdgeError,
1373
+ EdgeFeatureUnavailableError,
1253
1374
  EdgeLink,
1254
1375
  EdgePopupBlockedError,
1255
1376
  EdgeStateMismatchError,
@@ -1260,5 +1381,7 @@ var import_connect4 = require("@edge-markets/connect");
1260
1381
  generatePKCE,
1261
1382
  generateState,
1262
1383
  isEdgeError,
1263
- useEdgeLink
1384
+ isFeatureUnavailableError,
1385
+ useEdgeLink,
1386
+ useEdgeTransferVerify
1264
1387
  });
package/dist/index.mjs CHANGED
@@ -1,9 +1,11 @@
1
1
  // src/edge-link.ts
2
2
  import {
3
- ALL_EDGE_SCOPES,
3
+ ACTIVE_EDGE_SCOPES,
4
+ EdgeFeatureUnavailableError,
4
5
  EdgePopupBlockedError,
5
6
  formatScopesForEnvironment,
6
- getLinkUrl
7
+ getLinkUrl,
8
+ isTransferWriteScope
7
9
  } from "@edge-markets/connect";
8
10
 
9
11
  // src/pkce.ts
@@ -353,6 +355,8 @@ var EdgeLink = class {
353
355
  if (this.isDestroyed) {
354
356
  throw new Error("EdgeLink: Cannot open - instance has been destroyed");
355
357
  }
358
+ const scopes = options.scopes || this.config.scopes || ACTIVE_EDGE_SCOPES;
359
+ this.assertActiveScopes(scopes);
356
360
  if (this.popup.isOpen() || this.isInitializing) {
357
361
  this.popup.focus();
358
362
  return;
@@ -372,7 +376,7 @@ var EdgeLink = class {
372
376
  });
373
377
  throw new EdgePopupBlockedError();
374
378
  }
375
- this.initializeAuth(options.scopes || this.config.scopes || ALL_EDGE_SCOPES);
379
+ this.initializeAuth(scopes);
376
380
  }
377
381
  /**
378
382
  * Closes the EdgeLink popup if open.
@@ -462,6 +466,11 @@ var EdgeLink = class {
462
466
  }
463
467
  return url.toString();
464
468
  }
469
+ assertActiveScopes(scopes) {
470
+ if (scopes.some((scope) => isTransferWriteScope(scope))) {
471
+ throw new EdgeFeatureUnavailableError();
472
+ }
473
+ }
465
474
  /**
466
475
  * Sets up the postMessage listener.
467
476
  */
@@ -577,60 +586,10 @@ var EdgeLink = class {
577
586
  };
578
587
 
579
588
  // src/hooks.ts
580
- import { useEffect, useRef, useCallback, useState } from "react";
581
- function useEdgeLink(config) {
582
- const linkRef = useRef(null);
583
- const [ready, setReady] = useState(false);
584
- const [error, setError] = useState(null);
585
- const [isOpen, setIsOpen] = useState(false);
586
- const configRef = useRef(config);
587
- configRef.current = config;
588
- useEffect(() => {
589
- try {
590
- linkRef.current = new EdgeLink({
591
- ...configRef.current,
592
- onSuccess: (result) => {
593
- setIsOpen(false);
594
- configRef.current.onSuccess?.(result);
595
- },
596
- onExit: (metadata) => {
597
- setIsOpen(false);
598
- configRef.current.onExit?.(metadata);
599
- },
600
- onEvent: (event) => {
601
- if (event.eventName === "OPEN") setIsOpen(true);
602
- if (event.eventName === "CLOSE") setIsOpen(false);
603
- configRef.current.onEvent?.(event);
604
- }
605
- });
606
- setReady(true);
607
- setError(null);
608
- } catch (err) {
609
- setError(err instanceof Error ? err : new Error("Failed to initialize EdgeLink"));
610
- setReady(false);
611
- }
612
- return () => {
613
- linkRef.current?.destroy();
614
- linkRef.current = null;
615
- setReady(false);
616
- };
617
- }, [config.clientId, config.environment]);
618
- const open = useCallback((options) => {
619
- if (!linkRef.current) {
620
- setError(new Error("EdgeLink not initialized"));
621
- return;
622
- }
623
- try {
624
- linkRef.current.open(options);
625
- } catch (err) {
626
- setError(err instanceof Error ? err : new Error("Failed to open EdgeLink"));
627
- }
628
- }, []);
629
- return { open, ready, error, isOpen };
630
- }
589
+ import { useCallback, useEffect, useRef, useState } from "react";
631
590
 
632
591
  // src/edge-transfer-verify.ts
633
- import { EdgePopupBlockedError as EdgePopupBlockedError2 } from "@edge-markets/connect";
592
+ import { EdgeFeatureUnavailableError as EdgeFeatureUnavailableError2, EdgePopupBlockedError as EdgePopupBlockedError2 } from "@edge-markets/connect";
634
593
 
635
594
  // src/iframe-manager.ts
636
595
  var DEFAULT_TITLE = "EDGE Connect Transfer Verification";
@@ -886,6 +845,7 @@ var EdgeTransferVerify = class {
886
845
  * ```
887
846
  */
888
847
  open() {
848
+ assertTransferFeatureAvailable();
889
849
  if (this.isDestroyed) {
890
850
  throw new Error("EdgeTransferVerify: Cannot open - instance has been destroyed");
891
851
  }
@@ -1183,6 +1143,161 @@ var EdgeTransferVerify = class {
1183
1143
  this.config.onCancel?.(syntheticEvent);
1184
1144
  }
1185
1145
  };
1146
+ function assertTransferFeatureAvailable() {
1147
+ if (!isTransferFeatureAvailable()) {
1148
+ throw new EdgeFeatureUnavailableError2();
1149
+ }
1150
+ }
1151
+ function isTransferFeatureAvailable() {
1152
+ return false;
1153
+ }
1154
+
1155
+ // src/hooks.ts
1156
+ function useEdgeLink(config) {
1157
+ const linkRef = useRef(null);
1158
+ const [ready, setReady] = useState(false);
1159
+ const [error, setError] = useState(null);
1160
+ const [isOpen, setIsOpen] = useState(false);
1161
+ const configRef = useRef(config);
1162
+ configRef.current = config;
1163
+ useEffect(() => {
1164
+ try {
1165
+ linkRef.current = new EdgeLink({
1166
+ ...configRef.current,
1167
+ onSuccess: (result) => {
1168
+ setIsOpen(false);
1169
+ configRef.current.onSuccess?.(result);
1170
+ },
1171
+ onExit: (metadata) => {
1172
+ setIsOpen(false);
1173
+ configRef.current.onExit?.(metadata);
1174
+ },
1175
+ onEvent: (event) => {
1176
+ if (event.eventName === "OPEN") setIsOpen(true);
1177
+ if (event.eventName === "CLOSE") setIsOpen(false);
1178
+ configRef.current.onEvent?.(event);
1179
+ }
1180
+ });
1181
+ setReady(true);
1182
+ setError(null);
1183
+ } catch (err) {
1184
+ setError(err instanceof Error ? err : new Error("Failed to initialize EdgeLink"));
1185
+ setReady(false);
1186
+ }
1187
+ return () => {
1188
+ linkRef.current?.destroy();
1189
+ linkRef.current = null;
1190
+ setReady(false);
1191
+ };
1192
+ }, [config.clientId, config.environment]);
1193
+ const open = useCallback((options) => {
1194
+ if (!linkRef.current) {
1195
+ setError(new Error("EdgeLink not initialized"));
1196
+ return;
1197
+ }
1198
+ try {
1199
+ linkRef.current.open(options);
1200
+ } catch (err) {
1201
+ setError(err instanceof Error ? err : new Error("Failed to open EdgeLink"));
1202
+ }
1203
+ }, []);
1204
+ return { open, ready, error, isOpen };
1205
+ }
1206
+ function useEdgeTransferVerify(config) {
1207
+ const verifyRef = useRef(null);
1208
+ const [ready, setReady] = useState(false);
1209
+ const [isOpen, setIsOpen] = useState(false);
1210
+ const [isLoaded, setIsLoaded] = useState(false);
1211
+ const [lastEvent, setLastEvent] = useState(null);
1212
+ const [error, setError] = useState(null);
1213
+ const configRef = useRef(config);
1214
+ configRef.current = config;
1215
+ useEffect(() => {
1216
+ if ((configRef.current.mode || "iframe") === "iframe" && !configRef.current.container) {
1217
+ verifyRef.current = null;
1218
+ setReady(false);
1219
+ setError(null);
1220
+ setIsLoaded(false);
1221
+ setLastEvent(null);
1222
+ return;
1223
+ }
1224
+ try {
1225
+ verifyRef.current = new EdgeTransferVerify({
1226
+ ...configRef.current,
1227
+ onSuccess: (event) => {
1228
+ setIsOpen(false);
1229
+ setLastEvent(event);
1230
+ void configRef.current.onSuccess?.(event);
1231
+ },
1232
+ onError: (event) => {
1233
+ setIsOpen(false);
1234
+ setLastEvent(event);
1235
+ setError(new Error(event.error || "EDGE transfer verification failed"));
1236
+ void configRef.current.onError?.(event);
1237
+ },
1238
+ onCancel: (event) => {
1239
+ setIsOpen(false);
1240
+ setLastEvent(event);
1241
+ void configRef.current.onCancel?.(event);
1242
+ },
1243
+ onExpired: (event) => {
1244
+ setIsOpen(false);
1245
+ setLastEvent(event);
1246
+ void configRef.current.onExpired?.(event);
1247
+ },
1248
+ onLoaded: (event) => {
1249
+ setIsLoaded(true);
1250
+ setLastEvent(event);
1251
+ void configRef.current.onLoaded?.(event);
1252
+ },
1253
+ onEvent: (event) => {
1254
+ setLastEvent(event);
1255
+ void configRef.current.onEvent?.(event);
1256
+ }
1257
+ });
1258
+ setReady(true);
1259
+ setError(null);
1260
+ setIsLoaded(false);
1261
+ setLastEvent(null);
1262
+ } catch (err) {
1263
+ setError(err instanceof Error ? err : new Error("Failed to initialize EdgeTransferVerify"));
1264
+ setReady(false);
1265
+ }
1266
+ return () => {
1267
+ verifyRef.current?.destroy();
1268
+ verifyRef.current = null;
1269
+ setReady(false);
1270
+ setIsOpen(false);
1271
+ setIsLoaded(false);
1272
+ };
1273
+ }, [config.verificationUrl, config.sessionId, config.nonce, config.mode, config.container]);
1274
+ const open = useCallback(() => {
1275
+ if (!verifyRef.current) {
1276
+ setError(new Error("EdgeTransferVerify not initialized"));
1277
+ return;
1278
+ }
1279
+ try {
1280
+ verifyRef.current.open();
1281
+ setIsOpen(true);
1282
+ setError(null);
1283
+ } catch (err) {
1284
+ setError(err instanceof Error ? err : new Error("Failed to open EdgeTransferVerify"));
1285
+ setIsOpen(false);
1286
+ }
1287
+ }, []);
1288
+ const close = useCallback(() => {
1289
+ verifyRef.current?.close();
1290
+ setIsOpen(false);
1291
+ }, []);
1292
+ const destroy = useCallback(() => {
1293
+ verifyRef.current?.destroy();
1294
+ verifyRef.current = null;
1295
+ setReady(false);
1296
+ setIsOpen(false);
1297
+ setIsLoaded(false);
1298
+ }, []);
1299
+ return { open, close, destroy, ready, isOpen, isLoaded, lastEvent, error };
1300
+ }
1186
1301
 
1187
1302
  // src/geolocation.ts
1188
1303
  async function collectGeolocation(options) {
@@ -1209,12 +1324,23 @@ async function collectGeolocation(options) {
1209
1324
  }
1210
1325
 
1211
1326
  // src/index.ts
1212
- import { EdgeError, EdgePopupBlockedError as EdgePopupBlockedError3, EdgeStateMismatchError, isEdgeError } from "@edge-markets/connect";
1213
- import { ALL_EDGE_SCOPES as ALL_EDGE_SCOPES2, EDGE_SCOPES } from "@edge-markets/connect";
1327
+ import {
1328
+ EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE,
1329
+ EdgeError,
1330
+ EdgeFeatureUnavailableError as EdgeFeatureUnavailableError3,
1331
+ EdgePopupBlockedError as EdgePopupBlockedError3,
1332
+ EdgeStateMismatchError,
1333
+ isEdgeError,
1334
+ isFeatureUnavailableError
1335
+ } from "@edge-markets/connect";
1336
+ import { ACTIVE_EDGE_SCOPES as ACTIVE_EDGE_SCOPES2, ALL_EDGE_SCOPES, EDGE_SCOPES } from "@edge-markets/connect";
1214
1337
  export {
1215
- ALL_EDGE_SCOPES2 as ALL_EDGE_SCOPES,
1338
+ ACTIVE_EDGE_SCOPES2 as ACTIVE_EDGE_SCOPES,
1339
+ ALL_EDGE_SCOPES,
1340
+ EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE,
1216
1341
  EDGE_SCOPES,
1217
1342
  EdgeError,
1343
+ EdgeFeatureUnavailableError3 as EdgeFeatureUnavailableError,
1218
1344
  EdgeLink,
1219
1345
  EdgePopupBlockedError3 as EdgePopupBlockedError,
1220
1346
  EdgeStateMismatchError,
@@ -1225,5 +1351,7 @@ export {
1225
1351
  generatePKCE,
1226
1352
  generateState,
1227
1353
  isEdgeError,
1228
- useEdgeLink
1354
+ isFeatureUnavailableError,
1355
+ useEdgeLink,
1356
+ useEdgeTransferVerify
1229
1357
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edge-markets/connect-link",
3
- "version": "1.5.1",
3
+ "version": "1.7.0",
4
4
  "description": "Browser SDK for EDGE Connect popup authentication",
5
5
  "author": "EdgeBoost",
6
6
  "license": "MIT",
@@ -21,7 +21,7 @@
21
21
  }
22
22
  },
23
23
  "dependencies": {
24
- "@edge-markets/connect": "^1.6.1"
24
+ "@edge-markets/connect": "^1.8.0"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "react": ">=17.0.0"