2023-07-10 03:57:16 +03:00
|
|
|
/*
|
2024-09-09 16:57:16 +03:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2023-07-10 03:57:16 +03:00
|
|
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
|
|
|
2024-09-09 16:57:16 +03:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2023-07-10 03:57:16 +03:00
|
|
|
*/
|
|
|
|
|
2023-08-15 18:00:17 +03:00
|
|
|
import { OidcClientConfig } from "matrix-js-sdk/src/matrix";
|
2023-07-10 03:57:16 +03:00
|
|
|
import { ValidatedIssuerMetadata } from "matrix-js-sdk/src/oidc/validate";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Makes a valid OidcClientConfig with minimum valid values
|
|
|
|
* @param issuer used as the base for all other urls
|
|
|
|
* @returns OidcClientConfig
|
|
|
|
*/
|
|
|
|
export const makeDelegatedAuthConfig = (issuer = "https://auth.org/"): OidcClientConfig => {
|
|
|
|
const metadata = mockOpenIdConfiguration(issuer);
|
|
|
|
|
|
|
|
return {
|
2024-02-23 19:43:14 +03:00
|
|
|
accountManagementEndpoint: issuer + "account",
|
2023-07-10 03:57:16 +03:00
|
|
|
registrationEndpoint: metadata.registration_endpoint,
|
|
|
|
authorizationEndpoint: metadata.authorization_endpoint,
|
|
|
|
tokenEndpoint: metadata.token_endpoint,
|
|
|
|
metadata,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Useful for mocking <issuer>/.well-known/openid-configuration
|
|
|
|
* @param issuer used as the base for all other urls
|
|
|
|
* @returns ValidatedIssuerMetadata
|
|
|
|
*/
|
|
|
|
export const mockOpenIdConfiguration = (issuer = "https://auth.org/"): ValidatedIssuerMetadata => ({
|
|
|
|
issuer,
|
|
|
|
revocation_endpoint: issuer + "revoke",
|
|
|
|
token_endpoint: issuer + "token",
|
|
|
|
authorization_endpoint: issuer + "auth",
|
|
|
|
registration_endpoint: issuer + "registration",
|
2024-06-06 11:57:28 +03:00
|
|
|
device_authorization_endpoint: issuer + "device",
|
2023-07-10 03:57:16 +03:00
|
|
|
jwks_uri: issuer + "jwks",
|
|
|
|
response_types_supported: ["code"],
|
|
|
|
grant_types_supported: ["authorization_code", "refresh_token"],
|
|
|
|
code_challenge_methods_supported: ["S256"],
|
2024-02-23 19:43:14 +03:00
|
|
|
account_management_uri: issuer + "account",
|
2023-07-10 03:57:16 +03:00
|
|
|
});
|