@edge-markets/connect-link 1.6.0 → 1.8.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/README.md +1 -2
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +28 -1
- package/dist/index.mjs +39 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -188,7 +188,7 @@ const link = new EdgeLink({
|
|
|
188
188
|
scopes: [
|
|
189
189
|
EDGE_SCOPES.USER_READ, // Read profile
|
|
190
190
|
EDGE_SCOPES.BALANCE_READ, // Read balance
|
|
191
|
-
// EDGE_SCOPES.TRANSFER_WRITE
|
|
191
|
+
// EDGE_SCOPES.TRANSFER_WRITE is reserved and currently unavailable
|
|
192
192
|
],
|
|
193
193
|
onSuccess: handleSuccess,
|
|
194
194
|
})
|
|
@@ -329,4 +329,3 @@ function ConnectButton() {
|
|
|
329
329
|
## License
|
|
330
330
|
|
|
331
331
|
MIT
|
|
332
|
-
|
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, RESERVED_EDGE_SCOPES, 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, RESERVED_EDGE_SCOPES, 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,19 +20,24 @@ 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,
|
|
29
32
|
EdgeTransferVerify: () => EdgeTransferVerify,
|
|
30
33
|
IframeManager: () => IframeManager,
|
|
34
|
+
RESERVED_EDGE_SCOPES: () => import_connect4.RESERVED_EDGE_SCOPES,
|
|
31
35
|
assertCryptoAvailable: () => assertCryptoAvailable,
|
|
32
36
|
collectGeolocation: () => collectGeolocation,
|
|
33
37
|
generatePKCE: () => generatePKCE,
|
|
34
38
|
generateState: () => generateState,
|
|
35
39
|
isEdgeError: () => import_connect3.isEdgeError,
|
|
40
|
+
isFeatureUnavailableError: () => import_connect3.isFeatureUnavailableError,
|
|
36
41
|
useEdgeLink: () => useEdgeLink,
|
|
37
42
|
useEdgeTransferVerify: () => useEdgeTransferVerify
|
|
38
43
|
});
|
|
@@ -388,6 +393,8 @@ var EdgeLink = class {
|
|
|
388
393
|
if (this.isDestroyed) {
|
|
389
394
|
throw new Error("EdgeLink: Cannot open - instance has been destroyed");
|
|
390
395
|
}
|
|
396
|
+
const scopes = options.scopes || this.config.scopes || import_connect.ACTIVE_EDGE_SCOPES;
|
|
397
|
+
this.assertActiveScopes(scopes);
|
|
391
398
|
if (this.popup.isOpen() || this.isInitializing) {
|
|
392
399
|
this.popup.focus();
|
|
393
400
|
return;
|
|
@@ -407,7 +414,7 @@ var EdgeLink = class {
|
|
|
407
414
|
});
|
|
408
415
|
throw new import_connect.EdgePopupBlockedError();
|
|
409
416
|
}
|
|
410
|
-
this.initializeAuth(
|
|
417
|
+
this.initializeAuth(scopes);
|
|
411
418
|
}
|
|
412
419
|
/**
|
|
413
420
|
* Closes the EdgeLink popup if open.
|
|
@@ -484,6 +491,7 @@ var EdgeLink = class {
|
|
|
484
491
|
buildLinkUrl(scopes) {
|
|
485
492
|
const url = new URL((0, import_connect.getLinkUrl)(this.config.environment, this.config.linkUrl));
|
|
486
493
|
url.searchParams.set("client_id", this.config.clientId);
|
|
494
|
+
url.searchParams.set("environment", this.config.environment);
|
|
487
495
|
url.searchParams.set("state", this.state);
|
|
488
496
|
url.searchParams.set("code_challenge", this.pkce.challenge);
|
|
489
497
|
url.searchParams.set("code_challenge_method", "S256");
|
|
@@ -497,6 +505,11 @@ var EdgeLink = class {
|
|
|
497
505
|
}
|
|
498
506
|
return url.toString();
|
|
499
507
|
}
|
|
508
|
+
assertActiveScopes(scopes) {
|
|
509
|
+
if (scopes.some((scope) => (0, import_connect.isTransferWriteScope)(scope))) {
|
|
510
|
+
throw new import_connect.EdgeFeatureUnavailableError();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
500
513
|
/**
|
|
501
514
|
* Sets up the postMessage listener.
|
|
502
515
|
*/
|
|
@@ -871,6 +884,7 @@ var EdgeTransferVerify = class {
|
|
|
871
884
|
* ```
|
|
872
885
|
*/
|
|
873
886
|
open() {
|
|
887
|
+
assertTransferFeatureAvailable();
|
|
874
888
|
if (this.isDestroyed) {
|
|
875
889
|
throw new Error("EdgeTransferVerify: Cannot open - instance has been destroyed");
|
|
876
890
|
}
|
|
@@ -1168,6 +1182,14 @@ var EdgeTransferVerify = class {
|
|
|
1168
1182
|
this.config.onCancel?.(syntheticEvent);
|
|
1169
1183
|
}
|
|
1170
1184
|
};
|
|
1185
|
+
function assertTransferFeatureAvailable() {
|
|
1186
|
+
if (!isTransferFeatureAvailable()) {
|
|
1187
|
+
throw new import_connect2.EdgeFeatureUnavailableError();
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
function isTransferFeatureAvailable() {
|
|
1191
|
+
return false;
|
|
1192
|
+
}
|
|
1171
1193
|
|
|
1172
1194
|
// src/hooks.ts
|
|
1173
1195
|
function useEdgeLink(config) {
|
|
@@ -1345,19 +1367,24 @@ var import_connect3 = require("@edge-markets/connect");
|
|
|
1345
1367
|
var import_connect4 = require("@edge-markets/connect");
|
|
1346
1368
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1347
1369
|
0 && (module.exports = {
|
|
1370
|
+
ACTIVE_EDGE_SCOPES,
|
|
1348
1371
|
ALL_EDGE_SCOPES,
|
|
1372
|
+
EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE,
|
|
1349
1373
|
EDGE_SCOPES,
|
|
1350
1374
|
EdgeError,
|
|
1375
|
+
EdgeFeatureUnavailableError,
|
|
1351
1376
|
EdgeLink,
|
|
1352
1377
|
EdgePopupBlockedError,
|
|
1353
1378
|
EdgeStateMismatchError,
|
|
1354
1379
|
EdgeTransferVerify,
|
|
1355
1380
|
IframeManager,
|
|
1381
|
+
RESERVED_EDGE_SCOPES,
|
|
1356
1382
|
assertCryptoAvailable,
|
|
1357
1383
|
collectGeolocation,
|
|
1358
1384
|
generatePKCE,
|
|
1359
1385
|
generateState,
|
|
1360
1386
|
isEdgeError,
|
|
1387
|
+
isFeatureUnavailableError,
|
|
1361
1388
|
useEdgeLink,
|
|
1362
1389
|
useEdgeTransferVerify
|
|
1363
1390
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// src/edge-link.ts
|
|
2
2
|
import {
|
|
3
|
-
|
|
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(
|
|
379
|
+
this.initializeAuth(scopes);
|
|
376
380
|
}
|
|
377
381
|
/**
|
|
378
382
|
* Closes the EdgeLink popup if open.
|
|
@@ -449,6 +453,7 @@ var EdgeLink = class {
|
|
|
449
453
|
buildLinkUrl(scopes) {
|
|
450
454
|
const url = new URL(getLinkUrl(this.config.environment, this.config.linkUrl));
|
|
451
455
|
url.searchParams.set("client_id", this.config.clientId);
|
|
456
|
+
url.searchParams.set("environment", this.config.environment);
|
|
452
457
|
url.searchParams.set("state", this.state);
|
|
453
458
|
url.searchParams.set("code_challenge", this.pkce.challenge);
|
|
454
459
|
url.searchParams.set("code_challenge_method", "S256");
|
|
@@ -462,6 +467,11 @@ var EdgeLink = class {
|
|
|
462
467
|
}
|
|
463
468
|
return url.toString();
|
|
464
469
|
}
|
|
470
|
+
assertActiveScopes(scopes) {
|
|
471
|
+
if (scopes.some((scope) => isTransferWriteScope(scope))) {
|
|
472
|
+
throw new EdgeFeatureUnavailableError();
|
|
473
|
+
}
|
|
474
|
+
}
|
|
465
475
|
/**
|
|
466
476
|
* Sets up the postMessage listener.
|
|
467
477
|
*/
|
|
@@ -580,7 +590,7 @@ var EdgeLink = class {
|
|
|
580
590
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
581
591
|
|
|
582
592
|
// src/edge-transfer-verify.ts
|
|
583
|
-
import { EdgePopupBlockedError as EdgePopupBlockedError2 } from "@edge-markets/connect";
|
|
593
|
+
import { EdgeFeatureUnavailableError as EdgeFeatureUnavailableError2, EdgePopupBlockedError as EdgePopupBlockedError2 } from "@edge-markets/connect";
|
|
584
594
|
|
|
585
595
|
// src/iframe-manager.ts
|
|
586
596
|
var DEFAULT_TITLE = "EDGE Connect Transfer Verification";
|
|
@@ -836,6 +846,7 @@ var EdgeTransferVerify = class {
|
|
|
836
846
|
* ```
|
|
837
847
|
*/
|
|
838
848
|
open() {
|
|
849
|
+
assertTransferFeatureAvailable();
|
|
839
850
|
if (this.isDestroyed) {
|
|
840
851
|
throw new Error("EdgeTransferVerify: Cannot open - instance has been destroyed");
|
|
841
852
|
}
|
|
@@ -1133,6 +1144,14 @@ var EdgeTransferVerify = class {
|
|
|
1133
1144
|
this.config.onCancel?.(syntheticEvent);
|
|
1134
1145
|
}
|
|
1135
1146
|
};
|
|
1147
|
+
function assertTransferFeatureAvailable() {
|
|
1148
|
+
if (!isTransferFeatureAvailable()) {
|
|
1149
|
+
throw new EdgeFeatureUnavailableError2();
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
function isTransferFeatureAvailable() {
|
|
1153
|
+
return false;
|
|
1154
|
+
}
|
|
1136
1155
|
|
|
1137
1156
|
// src/hooks.ts
|
|
1138
1157
|
function useEdgeLink(config) {
|
|
@@ -1306,22 +1325,35 @@ async function collectGeolocation(options) {
|
|
|
1306
1325
|
}
|
|
1307
1326
|
|
|
1308
1327
|
// src/index.ts
|
|
1309
|
-
import {
|
|
1310
|
-
|
|
1328
|
+
import {
|
|
1329
|
+
EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE,
|
|
1330
|
+
EdgeError,
|
|
1331
|
+
EdgeFeatureUnavailableError as EdgeFeatureUnavailableError3,
|
|
1332
|
+
EdgePopupBlockedError as EdgePopupBlockedError3,
|
|
1333
|
+
EdgeStateMismatchError,
|
|
1334
|
+
isEdgeError,
|
|
1335
|
+
isFeatureUnavailableError
|
|
1336
|
+
} from "@edge-markets/connect";
|
|
1337
|
+
import { ACTIVE_EDGE_SCOPES as ACTIVE_EDGE_SCOPES2, ALL_EDGE_SCOPES, EDGE_SCOPES, RESERVED_EDGE_SCOPES } from "@edge-markets/connect";
|
|
1311
1338
|
export {
|
|
1312
|
-
|
|
1339
|
+
ACTIVE_EDGE_SCOPES2 as ACTIVE_EDGE_SCOPES,
|
|
1340
|
+
ALL_EDGE_SCOPES,
|
|
1341
|
+
EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE,
|
|
1313
1342
|
EDGE_SCOPES,
|
|
1314
1343
|
EdgeError,
|
|
1344
|
+
EdgeFeatureUnavailableError3 as EdgeFeatureUnavailableError,
|
|
1315
1345
|
EdgeLink,
|
|
1316
1346
|
EdgePopupBlockedError3 as EdgePopupBlockedError,
|
|
1317
1347
|
EdgeStateMismatchError,
|
|
1318
1348
|
EdgeTransferVerify,
|
|
1319
1349
|
IframeManager,
|
|
1350
|
+
RESERVED_EDGE_SCOPES,
|
|
1320
1351
|
assertCryptoAvailable,
|
|
1321
1352
|
collectGeolocation,
|
|
1322
1353
|
generatePKCE,
|
|
1323
1354
|
generateState,
|
|
1324
1355
|
isEdgeError,
|
|
1356
|
+
isFeatureUnavailableError,
|
|
1325
1357
|
useEdgeLink,
|
|
1326
1358
|
useEdgeTransferVerify
|
|
1327
1359
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edge-markets/connect-link",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.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.
|
|
24
|
+
"@edge-markets/connect": "^1.9.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": ">=17.0.0"
|