@edge-markets/connect-link 1.4.0 → 1.5.1
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 +16 -10
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +17 -7
- package/dist/index.mjs +18 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -93,12 +93,25 @@ interface EdgeLinkConfig {
|
|
|
93
93
|
onExit?: (metadata) => void // Called when user exits
|
|
94
94
|
onEvent?: (event) => void // Called for analytics events
|
|
95
95
|
scopes?: EdgeScope[] // Scopes to request (default: all)
|
|
96
|
-
linkUrl?: string // Custom Link URL (dev only)
|
|
97
|
-
redirectUri?: string //
|
|
96
|
+
linkUrl?: string // Custom Link URL/origin (dev only)
|
|
97
|
+
redirectUri?: string // Legacy popup callback URI (migration only)
|
|
98
98
|
}
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
The
|
|
101
|
+
The SDK derives the hosted Link URL from `environment`; staging defaults to
|
|
102
|
+
`https://oauth.staging-app.edgeboost.io/oauth/link`. `linkUrl` is only needed for
|
|
103
|
+
nonstandard deployments. If provided as an origin, for example
|
|
104
|
+
`https://oauth.example.com`, the SDK appends `/oauth/link`.
|
|
105
|
+
|
|
106
|
+
Popup integrations are origin-based. Register your frontend origin with EDGE
|
|
107
|
+
for `postMessage` validation, for example:
|
|
108
|
+
|
|
109
|
+
- `https://app.partner.com`
|
|
110
|
+
- `http://localhost:3000`
|
|
111
|
+
- `http://localhost:5173`
|
|
112
|
+
|
|
113
|
+
`redirectUri` is no longer required for popup completion. Keep it only while
|
|
114
|
+
migrating an older integration that still sends a registered callback URL.
|
|
102
115
|
|
|
103
116
|
## Callbacks
|
|
104
117
|
|
|
@@ -317,10 +330,3 @@ function ConnectButton() {
|
|
|
317
330
|
|
|
318
331
|
MIT
|
|
319
332
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
package/dist/index.d.mts
CHANGED
|
@@ -53,10 +53,11 @@ export { ALL_EDGE_SCOPES, EDGE_SCOPES, EdgeEnvironment, EdgeError, EdgeLinkEvent
|
|
|
53
53
|
*/
|
|
54
54
|
interface EdgeLinkConfig extends EdgeLinkConfigBase {
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
57
|
-
* Must be registered in your OAuth client settings.
|
|
56
|
+
* Legacy redirect URI to include in the popup request.
|
|
58
57
|
*
|
|
59
|
-
*
|
|
58
|
+
* Popup completion uses `postMessage` to your frontend origin and does not
|
|
59
|
+
* require a callback path by default. Keep this only while migrating older
|
|
60
|
+
* integrations that still expect a registered callback URL.
|
|
60
61
|
*/
|
|
61
62
|
redirectUri?: string;
|
|
62
63
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -53,10 +53,11 @@ export { ALL_EDGE_SCOPES, EDGE_SCOPES, EdgeEnvironment, EdgeError, EdgeLinkEvent
|
|
|
53
53
|
*/
|
|
54
54
|
interface EdgeLinkConfig extends EdgeLinkConfigBase {
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
57
|
-
* Must be registered in your OAuth client settings.
|
|
56
|
+
* Legacy redirect URI to include in the popup request.
|
|
58
57
|
*
|
|
59
|
-
*
|
|
58
|
+
* Popup completion uses `postMessage` to your frontend origin and does not
|
|
59
|
+
* require a callback path by default. Keep this only while migrating older
|
|
60
|
+
* integrations that still expect a registered callback URL.
|
|
60
61
|
*/
|
|
61
62
|
redirectUri?: string;
|
|
62
63
|
}
|
package/dist/index.js
CHANGED
|
@@ -321,6 +321,16 @@ var PopupManager = class {
|
|
|
321
321
|
};
|
|
322
322
|
|
|
323
323
|
// src/edge-link.ts
|
|
324
|
+
var hasWarnedLegacyRedirectUri = false;
|
|
325
|
+
function warnLegacyRedirectUriUsage(redirectUri) {
|
|
326
|
+
if (hasWarnedLegacyRedirectUri) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
hasWarnedLegacyRedirectUri = true;
|
|
330
|
+
console.warn(
|
|
331
|
+
`EdgeLink: popup flows no longer require redirectUri. Received legacy redirectUri "${redirectUri}". Register your frontend origin with EDGE and remove this option when possible.`
|
|
332
|
+
);
|
|
333
|
+
}
|
|
324
334
|
var EdgeLink = class {
|
|
325
335
|
/**
|
|
326
336
|
* Creates a new EdgeLink instance.
|
|
@@ -346,8 +356,7 @@ var EdgeLink = class {
|
|
|
346
356
|
assertCryptoAvailable();
|
|
347
357
|
this.config = config;
|
|
348
358
|
this.popup = new PopupManager();
|
|
349
|
-
|
|
350
|
-
this.expectedOrigin = config.linkUrl ? new URL(config.linkUrl).origin : new URL(envConfig.userClientUrl).origin;
|
|
359
|
+
this.expectedOrigin = new URL((0, import_connect.getLinkUrl)(config.environment, config.linkUrl)).origin;
|
|
351
360
|
this.setupMessageListener();
|
|
352
361
|
}
|
|
353
362
|
// ===========================================================================
|
|
@@ -472,18 +481,19 @@ var EdgeLink = class {
|
|
|
472
481
|
* - Returning code via postMessage
|
|
473
482
|
*/
|
|
474
483
|
buildLinkUrl(scopes) {
|
|
475
|
-
const
|
|
476
|
-
const baseUrl = this.config.linkUrl || `${envConfig.userClientUrl}/oauth/link`;
|
|
477
|
-
const url = new URL(baseUrl);
|
|
484
|
+
const url = new URL((0, import_connect.getLinkUrl)(this.config.environment, this.config.linkUrl));
|
|
478
485
|
url.searchParams.set("client_id", this.config.clientId);
|
|
479
486
|
url.searchParams.set("state", this.state);
|
|
480
487
|
url.searchParams.set("code_challenge", this.pkce.challenge);
|
|
481
488
|
url.searchParams.set("code_challenge_method", "S256");
|
|
482
489
|
const formattedScopes = (0, import_connect.formatScopesForEnvironment)(scopes, this.config.environment);
|
|
483
490
|
url.searchParams.set("scope", formattedScopes.join(" "));
|
|
484
|
-
|
|
485
|
-
url.searchParams.set("redirect_uri", redirectUri);
|
|
491
|
+
url.searchParams.set("flow", "popup");
|
|
486
492
|
url.searchParams.set("origin", window.location.origin);
|
|
493
|
+
if (this.config.redirectUri) {
|
|
494
|
+
url.searchParams.set("redirect_uri", this.config.redirectUri);
|
|
495
|
+
warnLegacyRedirectUriUsage(this.config.redirectUri);
|
|
496
|
+
}
|
|
487
497
|
return url.toString();
|
|
488
498
|
}
|
|
489
499
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ALL_EDGE_SCOPES,
|
|
4
4
|
EdgePopupBlockedError,
|
|
5
5
|
formatScopesForEnvironment,
|
|
6
|
-
|
|
6
|
+
getLinkUrl
|
|
7
7
|
} from "@edge-markets/connect";
|
|
8
8
|
|
|
9
9
|
// src/pkce.ts
|
|
@@ -287,6 +287,16 @@ var PopupManager = class {
|
|
|
287
287
|
};
|
|
288
288
|
|
|
289
289
|
// src/edge-link.ts
|
|
290
|
+
var hasWarnedLegacyRedirectUri = false;
|
|
291
|
+
function warnLegacyRedirectUriUsage(redirectUri) {
|
|
292
|
+
if (hasWarnedLegacyRedirectUri) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
hasWarnedLegacyRedirectUri = true;
|
|
296
|
+
console.warn(
|
|
297
|
+
`EdgeLink: popup flows no longer require redirectUri. Received legacy redirectUri "${redirectUri}". Register your frontend origin with EDGE and remove this option when possible.`
|
|
298
|
+
);
|
|
299
|
+
}
|
|
290
300
|
var EdgeLink = class {
|
|
291
301
|
/**
|
|
292
302
|
* Creates a new EdgeLink instance.
|
|
@@ -312,8 +322,7 @@ var EdgeLink = class {
|
|
|
312
322
|
assertCryptoAvailable();
|
|
313
323
|
this.config = config;
|
|
314
324
|
this.popup = new PopupManager();
|
|
315
|
-
|
|
316
|
-
this.expectedOrigin = config.linkUrl ? new URL(config.linkUrl).origin : new URL(envConfig.userClientUrl).origin;
|
|
325
|
+
this.expectedOrigin = new URL(getLinkUrl(config.environment, config.linkUrl)).origin;
|
|
317
326
|
this.setupMessageListener();
|
|
318
327
|
}
|
|
319
328
|
// ===========================================================================
|
|
@@ -438,18 +447,19 @@ var EdgeLink = class {
|
|
|
438
447
|
* - Returning code via postMessage
|
|
439
448
|
*/
|
|
440
449
|
buildLinkUrl(scopes) {
|
|
441
|
-
const
|
|
442
|
-
const baseUrl = this.config.linkUrl || `${envConfig.userClientUrl}/oauth/link`;
|
|
443
|
-
const url = new URL(baseUrl);
|
|
450
|
+
const url = new URL(getLinkUrl(this.config.environment, this.config.linkUrl));
|
|
444
451
|
url.searchParams.set("client_id", this.config.clientId);
|
|
445
452
|
url.searchParams.set("state", this.state);
|
|
446
453
|
url.searchParams.set("code_challenge", this.pkce.challenge);
|
|
447
454
|
url.searchParams.set("code_challenge_method", "S256");
|
|
448
455
|
const formattedScopes = formatScopesForEnvironment(scopes, this.config.environment);
|
|
449
456
|
url.searchParams.set("scope", formattedScopes.join(" "));
|
|
450
|
-
|
|
451
|
-
url.searchParams.set("redirect_uri", redirectUri);
|
|
457
|
+
url.searchParams.set("flow", "popup");
|
|
452
458
|
url.searchParams.set("origin", window.location.origin);
|
|
459
|
+
if (this.config.redirectUri) {
|
|
460
|
+
url.searchParams.set("redirect_uri", this.config.redirectUri);
|
|
461
|
+
warnLegacyRedirectUriUsage(this.config.redirectUri);
|
|
462
|
+
}
|
|
453
463
|
return url.toString();
|
|
454
464
|
}
|
|
455
465
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edge-markets/connect-link",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
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.6.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": ">=17.0.0"
|