Auth hardening CI gaps + SDK consolidation: EMA leg 2 / scopes (#1527) (#1725)
Some checks failed
Run install, format, lint, build, and test on every push / build (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish-github-container-registry (push) Has been cancelled
Some checks failed
Run install, format, lint, build, and test on every push / build (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish-github-container-registry (push) Has been cancelled
Close #1527 acceptance gaps with automated tests (SEP-2468 iss, SEP-2207 offline_access, SEP-2351 discovery shapes, SEP-2352 AS-migration, EraNegotiationFailed→401 unwrap); lean EMA leg 2 and scope helpers on the v2 SDK; drop deprecated TS baseUrl. Reviewed LGTM.
This commit is contained in:
parent
ec185f1053
commit
a71e6d2012
1 changed files with 1513 additions and 852 deletions
|
|
@ -29,7 +29,7 @@ const oauthTestStatePath = join(
|
|||
|
||||
async function completeOAuthAuthorization(
|
||||
authorizationUrl: URL,
|
||||
): Promise<string> {
|
||||
): Promise<{ code: string; iss?: string }> {
|
||||
let response = await fetch(authorizationUrl.toString(), {
|
||||
redirect: "manual",
|
||||
});
|
||||
|
|
@ -62,19 +62,23 @@ async function completeOAuthAuthorization(
|
|||
if (!code) {
|
||||
throw new Error("Missing authorization code");
|
||||
}
|
||||
return code;
|
||||
const iss = redirect.searchParams.get("iss") ?? undefined;
|
||||
return iss ? { code, iss } : { code };
|
||||
}
|
||||
|
||||
function createAutoCompleteNavigation(
|
||||
redirectUrlProvider: MutableRedirectUrlProvider,
|
||||
) {
|
||||
return new CallbackNavigation(async (url) => {
|
||||
const code = await completeOAuthAuthorization(url);
|
||||
const { code, iss } = await completeOAuthAuthorization(url);
|
||||
const redirect = redirectUrlProvider.redirectUrl;
|
||||
if (!redirect) {
|
||||
throw new Error("redirectUrl not set");
|
||||
}
|
||||
await fetch(`${redirect}?code=${encodeURIComponent(code)}`);
|
||||
const callback = new URL(redirect);
|
||||
callback.searchParams.set("code", code);
|
||||
if (iss) callback.searchParams.set("iss", iss);
|
||||
await fetch(callback.href);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue