@edge-markets/connect-link 1.6.0 → 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
1
  import { EdgeLinkConfigBase, EdgeScope, SdkGeolocation, EdgeLinkSuccess, EdgeLinkExit, 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';
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
  */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { EdgeLinkConfigBase, EdgeScope, SdkGeolocation, EdgeLinkSuccess, EdgeLinkExit, 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';
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
  */
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,6 +36,7 @@ __export(index_exports, {
33
36
  generatePKCE: () => generatePKCE,
34
37
  generateState: () => generateState,
35
38
  isEdgeError: () => import_connect3.isEdgeError,
39
+ isFeatureUnavailableError: () => import_connect3.isFeatureUnavailableError,
36
40
  useEdgeLink: () => useEdgeLink,
37
41
  useEdgeTransferVerify: () => useEdgeTransferVerify
38
42
  });
@@ -388,6 +392,8 @@ var EdgeLink = class {
388
392
  if (this.isDestroyed) {
389
393
  throw new Error("EdgeLink: Cannot open - instance has been destroyed");
390
394
  }
395
+ const scopes = options.scopes || this.config.scopes || import_connect.ACTIVE_EDGE_SCOPES;
396
+ this.assertActiveScopes(scopes);
391
397
  if (this.popup.isOpen() || this.isInitializing) {
392
398
  this.popup.focus();
393
399
  return;
@@ -407,7 +413,7 @@ var EdgeLink = class {
407
413
  });
408
414
  throw new import_connect.EdgePopupBlockedError();
409
415
  }
410
- this.initializeAuth(options.scopes || this.config.scopes || import_connect.ALL_EDGE_SCOPES);
416
+ this.initializeAuth(scopes);
411
417
  }
412
418
  /**
413
419
  * Closes the EdgeLink popup if open.
@@ -497,6 +503,11 @@ var EdgeLink = class {
497
503
  }
498
504
  return url.toString();
499
505
  }
506
+ assertActiveScopes(scopes) {
507
+ if (scopes.some((scope) => (0, import_connect.isTransferWriteScope)(scope))) {
508
+ throw new import_connect.EdgeFeatureUnavailableError();
509
+ }
510
+ }
500
511
  /**
501
512
  * Sets up the postMessage listener.
502
513
  */
@@ -871,6 +882,7 @@ var EdgeTransferVerify = class {
871
882
  * ```
872
883
  */
873
884
  open() {
885
+ assertTransferFeatureAvailable();
874
886
  if (this.isDestroyed) {
875
887
  throw new Error("EdgeTransferVerify: Cannot open - instance has been destroyed");
876
888
  }
@@ -1168,6 +1180,14 @@ var EdgeTransferVerify = class {
1168
1180
  this.config.onCancel?.(syntheticEvent);
1169
1181
  }
1170
1182
  };
1183
+ function assertTransferFeatureAvailable() {
1184
+ if (!isTransferFeatureAvailable()) {
1185
+ throw new import_connect2.EdgeFeatureUnavailableError();
1186
+ }
1187
+ }
1188
+ function isTransferFeatureAvailable() {
1189
+ return false;
1190
+ }
1171
1191
 
1172
1192
  // src/hooks.ts
1173
1193
  function useEdgeLink(config) {
@@ -1345,9 +1365,12 @@ var import_connect3 = require("@edge-markets/connect");
1345
1365
  var import_connect4 = require("@edge-markets/connect");
1346
1366
  // Annotate the CommonJS export names for ESM import in node:
1347
1367
  0 && (module.exports = {
1368
+ ACTIVE_EDGE_SCOPES,
1348
1369
  ALL_EDGE_SCOPES,
1370
+ EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE,
1349
1371
  EDGE_SCOPES,
1350
1372
  EdgeError,
1373
+ EdgeFeatureUnavailableError,
1351
1374
  EdgeLink,
1352
1375
  EdgePopupBlockedError,
1353
1376
  EdgeStateMismatchError,
@@ -1358,6 +1381,7 @@ var import_connect4 = require("@edge-markets/connect");
1358
1381
  generatePKCE,
1359
1382
  generateState,
1360
1383
  isEdgeError,
1384
+ isFeatureUnavailableError,
1361
1385
  useEdgeLink,
1362
1386
  useEdgeTransferVerify
1363
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
  */
@@ -580,7 +589,7 @@ var EdgeLink = class {
580
589
  import { useCallback, useEffect, useRef, useState } from "react";
581
590
 
582
591
  // src/edge-transfer-verify.ts
583
- import { EdgePopupBlockedError as EdgePopupBlockedError2 } from "@edge-markets/connect";
592
+ import { EdgeFeatureUnavailableError as EdgeFeatureUnavailableError2, EdgePopupBlockedError as EdgePopupBlockedError2 } from "@edge-markets/connect";
584
593
 
585
594
  // src/iframe-manager.ts
586
595
  var DEFAULT_TITLE = "EDGE Connect Transfer Verification";
@@ -836,6 +845,7 @@ var EdgeTransferVerify = class {
836
845
  * ```
837
846
  */
838
847
  open() {
848
+ assertTransferFeatureAvailable();
839
849
  if (this.isDestroyed) {
840
850
  throw new Error("EdgeTransferVerify: Cannot open - instance has been destroyed");
841
851
  }
@@ -1133,6 +1143,14 @@ var EdgeTransferVerify = class {
1133
1143
  this.config.onCancel?.(syntheticEvent);
1134
1144
  }
1135
1145
  };
1146
+ function assertTransferFeatureAvailable() {
1147
+ if (!isTransferFeatureAvailable()) {
1148
+ throw new EdgeFeatureUnavailableError2();
1149
+ }
1150
+ }
1151
+ function isTransferFeatureAvailable() {
1152
+ return false;
1153
+ }
1136
1154
 
1137
1155
  // src/hooks.ts
1138
1156
  function useEdgeLink(config) {
@@ -1306,12 +1324,23 @@ async function collectGeolocation(options) {
1306
1324
  }
1307
1325
 
1308
1326
  // src/index.ts
1309
- import { EdgeError, EdgePopupBlockedError as EdgePopupBlockedError3, EdgeStateMismatchError, isEdgeError } from "@edge-markets/connect";
1310
- 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";
1311
1337
  export {
1312
- 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,
1313
1341
  EDGE_SCOPES,
1314
1342
  EdgeError,
1343
+ EdgeFeatureUnavailableError3 as EdgeFeatureUnavailableError,
1315
1344
  EdgeLink,
1316
1345
  EdgePopupBlockedError3 as EdgePopupBlockedError,
1317
1346
  EdgeStateMismatchError,
@@ -1322,6 +1351,7 @@ export {
1322
1351
  generatePKCE,
1323
1352
  generateState,
1324
1353
  isEdgeError,
1354
+ isFeatureUnavailableError,
1325
1355
  useEdgeLink,
1326
1356
  useEdgeTransferVerify
1327
1357
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edge-markets/connect-link",
3
- "version": "1.6.0",
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.7.0"
24
+ "@edge-markets/connect": "^1.8.0"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "react": ">=17.0.0"