This commit is contained in:
1 parent
8d7c2f69ff
commit
a018f3da4c
18 files changed
+747
-46
No files matched your search
@@ -87,6 +87,27 @@ export class AuthClient {
|
||||
return this.projectKey ? { [PROJECT_KEY_HEADER]: this.projectKey } : {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomically replaces the AuthGuard base URL this client calls,
|
||||
* normalizing it the same way the constructor does. Mirrors Go's
|
||||
* authclient.Client.SetBaseURL / Python's AuthClient.set_base_url / Java's
|
||||
* AuthClient#setBaseUrl: the intended use is a project's own
|
||||
* coreconfig-equivalent push handler calling this on its live AuthClient
|
||||
* instance so a freshly pushed AuthGuard URL takes effect on the client's
|
||||
* very next call with no restart - including the very first URL a client
|
||||
* constructed with baseUrl "" (a "pending" client, not yet configured but
|
||||
* still meant to be used) ever receives. A blank baseUrl is ignored
|
||||
* (leaving the previous value in place) rather than leaving the client
|
||||
* unable to reach AuthGuard at all.
|
||||
* @param {string} baseUrl
|
||||
*/
|
||||
setBaseUrl(baseUrl) {
|
||||
const normalized = AuthClient._normalizeBaseUrl(baseUrl);
|
||||
if (normalized) {
|
||||
this.baseUrl = normalized;
|
||||
}
|
||||
}
|
||||
|
||||
static _normalizeBaseUrl(baseUrl) {
|
||||
const trimmed = String(baseUrl ?? '').trim().replace(/\/+$/, '');
|
||||
if (!trimmed) return trimmed;
|
||||
|
||||
Reference in new issue
Block a user