@faable/auth-sdk 2.5.37 → 2.5.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FaableAuthApi.d.ts +1 -0
- package/dist/FaableAuthApi.js +14 -3
- package/package.json +1 -1
package/dist/FaableAuthApi.d.ts
CHANGED
package/dist/FaableAuthApi.js
CHANGED
|
@@ -10,9 +10,17 @@ import { version } from "./version.js";
|
|
|
10
10
|
// resolves the account by host and exposes its id as `account`) lazily on the
|
|
11
11
|
// first token request, and memoize it. Omitting `scope` then yields the full
|
|
12
12
|
// management catalog server-side (Auth0 parity), so no scope wiring is needed.
|
|
13
|
+
//
|
|
14
|
+
// The memo is module-level, keyed by host. It used to be a closure created per
|
|
15
|
+
// constructor, so it only ever helped an instance that outlived several token
|
|
16
|
+
// refreshes — and a multi-tenant consumer does the opposite: it builds one
|
|
17
|
+
// instance per tenant (a tenant is scoped through the constructor `headers`),
|
|
18
|
+
// so every one of them re-ran discovery. The account id a host resolves to does
|
|
19
|
+
// not change, so caching it per host is the honest scope.
|
|
20
|
+
const audience_by_host = new Map();
|
|
13
21
|
const discoverManagementAudience = (baseURL) => {
|
|
14
|
-
let cached;
|
|
15
22
|
return async () => {
|
|
23
|
+
const cached = audience_by_host.get(baseURL);
|
|
16
24
|
if (cached)
|
|
17
25
|
return cached;
|
|
18
26
|
const url = `${baseURL}/.well-known/openid-configuration`;
|
|
@@ -27,10 +35,13 @@ const discoverManagementAudience = (baseURL) => {
|
|
|
27
35
|
"auth server may be older than the management-audience support. " +
|
|
28
36
|
"Pass `auth.audience` explicitly (faable:management:<account_id>).");
|
|
29
37
|
}
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
const audience = `faable:management:${doc.account}`;
|
|
39
|
+
audience_by_host.set(baseURL, audience);
|
|
40
|
+
return audience;
|
|
32
41
|
};
|
|
33
42
|
};
|
|
43
|
+
// Testing seam: the memo outlives any single api instance.
|
|
44
|
+
export const __resetAudienceCacheForTests = () => audience_by_host.clear();
|
|
34
45
|
export class FaableAuthApi extends GeneratedFaableAuthApi {
|
|
35
46
|
constructor(params) {
|
|
36
47
|
if (!params?.domain) {
|