From e6780f7a209b9df77f7bd48a0224e7203321fb94 Mon Sep 17 00:00:00 2001 From: Alan Bridgeman Date: Mon, 23 Feb 2026 15:36:33 -0600 Subject: [PATCH] Relatively small QOL updates + bumped auth library version --- package.json | 2 +- src/index.ts | 4 +++- src/oauth/OAuthApp.ts | 31 +++++++++++++++++++++++++++++++ yarn.lock | 8 ++++---- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 67e795b..a3cca37 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "create-ba-web-app": "node ./bin/create-project.js" }, "dependencies": { - "@BridgemanAccessible/ba-auth": "^1.0.39", + "@BridgemanAccessible/ba-auth": "^1.0.40", "@BridgemanAccessible/ba-logging": "^1.0.1", "express": "^4.19.2", "fs-extra": "^11.2.0", diff --git a/src/index.ts b/src/index.ts index 6dd48ae..49c433c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,13 +3,15 @@ import { Initializer } from './Initializer.js'; import { Router } from './Router.js'; import { Renderer } from './Renderer.js'; import { StaticFileResolver } from './StaticFileResolver.js'; +import { HealthCheckableRequestClient } from './utils/HealthCheckableRequestClient.js' export { App, Initializer, Router, Renderer, - StaticFileResolver + StaticFileResolver, + HealthCheckableRequestClient }; export * from './controllers/index.js'; diff --git a/src/oauth/OAuthApp.ts b/src/oauth/OAuthApp.ts index 037b7cf..e928203 100644 --- a/src/oauth/OAuthApp.ts +++ b/src/oauth/OAuthApp.ts @@ -233,6 +233,37 @@ export class OAuthApp extend // Because this is largely based on human intervention, exponentiation of the index by 5 (minutes), to a maximum of about 13 hours seemed reasonable let active = this.client.isActive(); if(!active) { + // Before we start waiting, we should check the status of the app once to see if it becomes active in the meantime (since there could be some time between when the client was set up and when we check the status here) + await (new HealthCheckableRequestClient('Authorization Server')).makeRequest( + new URL(`https://account.bridgemanaccessible.ca/api/v1/apps/${encodeURIComponent(baseAppUrl.toString())}/status`), + 'GET', + { + headers: { + Accept: 'application/json' + } + } + ) + .then((response) => { + if(response.status === 200) { + const data = response.data; + + if(data.status === 'active') { + logMessage('OAuth client is active!', LogLevel.INFO); + + active = true; + } + else { + logMessage('OAuth client is not active.', LogLevel.DEBUG); + } + } + else { + logMessage(`Received non-200 response when checking OAuth client status: ${response.status}`, LogLevel.ERROR); + } + }) + .catch((error) => { + logMessage(`Error checking OAuth client status: ${error}`, LogLevel.ERROR); + }); + for(let j = 0;j < 5 && !active;j++) { // Sleep for: // 0: ! Minute diff --git a/yarn.lock b/yarn.lock index 2825fa6..ebd477d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@BridgemanAccessible/ba-auth@^1.0.39": - version "1.0.39" - resolved "https://npm.pkg.bridgemanaccessible.ca/@BridgemanAccessible/ba-auth/-/ba-auth-1.0.39.tgz#d5b6f87d4ef3365a2d9e053cbd7799f61c5ebeaf" - integrity sha512-E/GT4ppc+b9Vtma1UvOt2zqXyiHqTWS0U9eiX7BH+encnSMMxmU2bFgWB8/ijumRieLbB+z/OdvoOKJJGpwxtg== +"@BridgemanAccessible/ba-auth@^1.0.40": + version "1.0.40" + resolved "https://npm.pkg.bridgemanaccessible.ca/@BridgemanAccessible/ba-auth/-/ba-auth-1.0.40.tgz#670a7cc76c972849662a7332d42d0cba8ac6cb44" + integrity sha512-gAEtbEv7Tm2lgLx6EE1501gChZXwa21B7P7AidzvjWIz9Nz3hqm0vBEu4OElMGejk2dEtsw1HHvY+v3O4rQNyg== dependencies: "@BridgemanAccessible/ba-auth_adapters" "^1.0.4" "@BridgemanAccessible/ba-auth_keystore" "^1.0.1"