@growth-operations/ui-shared 1.6.0 → 1.6.1
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/package.json
CHANGED
|
@@ -20,13 +20,17 @@ const TokenContext = createContext(null);
|
|
|
20
20
|
let cachedTokenData = null;
|
|
21
21
|
let tokenPromise = null;
|
|
22
22
|
let appContext = null;
|
|
23
|
+
// The short-lived-token endpoint. Defaults to the /api/v1 mount (toast/sparkfly);
|
|
24
|
+
// apps mounted at /v1 (e.g. ATS) pass tokenPath="/v1/tokens/short-lived" to
|
|
25
|
+
// TokenProvider. Same per-app override pattern as makeSettingsApi / AlertsTab.
|
|
26
|
+
let tokenPath = "/api/v1/tokens/short-lived";
|
|
23
27
|
|
|
24
28
|
// Fetch the full short-lived token object (token string + expires_at) for the
|
|
25
29
|
// current portal.
|
|
26
30
|
async function fetchTokenData(context) {
|
|
27
31
|
const portalId = context?.portal?.id;
|
|
28
32
|
const query = portalId ? `?portalId=${portalId}` : "";
|
|
29
|
-
return callAppApi(context,
|
|
33
|
+
return callAppApi(context, `${tokenPath}${query}`, "GET");
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
// Return a valid access token string, fetching a fresh one if the cache is empty
|
|
@@ -76,10 +80,12 @@ export function useToken() {
|
|
|
76
80
|
return context;
|
|
77
81
|
}
|
|
78
82
|
|
|
79
|
-
export function TokenProvider({ children, context }) {
|
|
83
|
+
export function TokenProvider({ children, context, tokenPath: path }) {
|
|
80
84
|
// Stash the extension context at module level so the token functions (which
|
|
81
85
|
// live outside React) can reach it.
|
|
82
86
|
appContext = context;
|
|
87
|
+
// Per-app override for the short-lived-token endpoint (apps mounted at /v1).
|
|
88
|
+
if (path) tokenPath = path;
|
|
83
89
|
|
|
84
90
|
return (
|
|
85
91
|
<TokenContext.Provider value={stableValue}>{children}</TokenContext.Provider>
|