(auth: UnauthorizedAuth, protectedResourceMetadataUrl: string)
| 13 | `"${value.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`; |
| 14 | |
| 15 | export const bearerChallenge = (auth: UnauthorizedAuth, protectedResourceMetadataUrl: string) => { |
| 16 | const params = |
| 17 | auth.reason === "missing_bearer" |
| 18 | ? [`resource_metadata=${quoteAuthParam(protectedResourceMetadataUrl)}`] |
| 19 | : [ |
| 20 | 'error="invalid_token"', |
| 21 | `error_description=${quoteAuthParam( |
| 22 | auth.description ?? "The access token is invalid or expired", |
| 23 | )}`, |
| 24 | `resource_metadata=${quoteAuthParam(protectedResourceMetadataUrl)}`, |
| 25 | ]; |
| 26 | |
| 27 | return `Bearer ${params.join(", ")}`; |
| 28 | }; |
| 29 | |
| 30 | /** |
| 31 | * The cloud edge's JSON-RPC error `Response` (CORS-on — it crosses the browser |
no test coverage detected