( config: FirstPartyOAuthClientConfig, )
| 678 | * client_credentials mints machine tokens under the OPERATOR's app identity, |
| 679 | * which must never be shared across tenants. */ |
| 680 | export const loadedFirstPartyClient = ( |
| 681 | config: FirstPartyOAuthClientConfig, |
| 682 | ): { |
| 683 | readonly slug: string; |
| 684 | readonly authorizationUrl: string; |
| 685 | readonly tokenUrl: string; |
| 686 | readonly grant: OAuthGrant; |
| 687 | readonly clientId: string; |
| 688 | readonly clientSecret: string; |
| 689 | readonly resource: string | null; |
| 690 | readonly tokenEndpointAuthMethod?: TokenEndpointAuthMethod; |
| 691 | readonly tokenRequestFormat?: "form" | "json"; |
| 692 | } => ({ |
| 693 | slug: String(firstPartyOAuthClientSlug(config.name)), |
| 694 | authorizationUrl: config.authorizationUrl, |
| 695 | tokenUrl: config.tokenUrl, |
| 696 | grant: "authorization_code", |
| 697 | clientId: config.clientId, |
| 698 | clientSecret: config.clientSecret, |
| 699 | resource: config.resource ?? null, |
| 700 | ...(config.tokenEndpointAuthMethod === undefined |
| 701 | ? {} |
| 702 | : { tokenEndpointAuthMethod: config.tokenEndpointAuthMethod }), |
| 703 | ...(config.tokenRequestFormat === undefined |
| 704 | ? {} |
| 705 | : { tokenRequestFormat: config.tokenRequestFormat }), |
| 706 | }); |
| 707 | |
| 708 | export const makeOAuthService = (deps: OAuthServiceDeps): OAuthService => { |
| 709 | const httpClientLayer = deps.httpClientLayer ?? FetchHttpClient.layer; |
no test coverage detected