@thunderid/browser 1.9.2 → 1.9.3
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/BackendClient.d.ts +4 -3
- package/dist/BackendClient.d.ts.map +1 -1
- package/dist/cjs/index.cjs +13 -10
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/BackendClient.d.ts
CHANGED
|
@@ -74,10 +74,11 @@ declare class BackendClient {
|
|
|
74
74
|
*/
|
|
75
75
|
signOut(): Promise<string>;
|
|
76
76
|
/**
|
|
77
|
-
* Maps an API URL to its backend proxy URL.
|
|
77
|
+
* Maps an API URL to its backend proxy URL. A URL already on the proxy is sent as it is, and any
|
|
78
|
+
* other path (`/users`) goes under the proxy. The backend, not the app, knows the API's address.
|
|
78
79
|
*
|
|
79
|
-
* @returns The proxy URL, or `undefined`
|
|
80
|
-
* sent with the session's credentials.
|
|
80
|
+
* @returns The proxy URL, or `undefined` for an absolute URL that isn't on the proxy and so cannot
|
|
81
|
+
* be sent with the session's credentials.
|
|
81
82
|
*/
|
|
82
83
|
toProxyUrl(url: string): string | undefined;
|
|
83
84
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackendClient.d.ts","sourceRoot":"","sources":["../src/BackendClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,cAAc,EAAE,wBAAwB,EAAE,WAAW,EAAyB,MAAM,uBAAuB,CAAC;AAEpH;;;GAGG;AACH,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AAOzD;;;GAGG;AACH,cAAM,aAAa;IAcL,OAAO,CAAC,QAAQ,CAAC,SAAS;IAbtC,OAAO,CAAC,OAAO,CAAsC;IAErD,OAAO,CAAC,UAAU,CAA+B;IAEjD,OAAO,CAAC,gBAAgB,CAAS;IAEjC,0FAA0F;IAC1F,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAA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endClient {
|
|
|
180
180
|
return (await response.json()).redirectUrl;
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
|
-
* Maps an API URL to its backend proxy URL.
|
|
183
|
+
* Maps an API URL to its backend proxy URL. A URL already on the proxy is sent as it is, and any
|
|
184
|
+
* other path (`/users`) goes under the proxy. The backend, not the app, knows the API's address.
|
|
184
185
|
*
|
|
185
|
-
* @returns The proxy URL, or `undefined`
|
|
186
|
-
* sent with the session's credentials.
|
|
186
|
+
* @returns The proxy URL, or `undefined` for an absolute URL that isn't on the proxy and so cannot
|
|
187
|
+
* be sent with the session's credentials.
|
|
187
188
|
*/
|
|
188
189
|
toProxyUrl(url) {
|
|
189
|
-
const {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
190
|
+
const { proxy } = this.endpoints;
|
|
191
|
+
const origin = typeof window !== "undefined" ? window.location.origin : "";
|
|
192
|
+
const isPath = (value) => value.startsWith("/") && !value.startsWith("//");
|
|
193
|
+
const isUnder = (base) => url === base || url.startsWith(`${base}/`) || url.startsWith(`${base}?`);
|
|
194
|
+
const absoluteProxy = isPath(proxy) ? `${origin}${proxy}` : proxy;
|
|
195
|
+
const proxyPath = absoluteProxy.startsWith(`${origin}/`) ? absoluteProxy.slice(origin.length) : void 0;
|
|
196
|
+
if (isUnder(proxy) || isUnder(absoluteProxy) || proxyPath !== void 0 && isUnder(proxyPath)) return url;
|
|
197
|
+
return isPath(url) ? `${proxy}${url}` : void 0;
|
|
195
198
|
}
|
|
196
199
|
/**
|
|
197
200
|
* Whether a request to this URL skips the proxy and goes straight from the browser.
|
|
@@ -3086,7 +3089,7 @@ var ThunderIDBrowserClient = class ThunderIDBrowserClient extends __thunderid_ja
|
|
|
3086
3089
|
await this._validateMethod();
|
|
3087
3090
|
const configData = await this.getStorageManager().getConfigData();
|
|
3088
3091
|
const profile = await (0, __thunderid_javascript.getUsersMe)({
|
|
3089
|
-
baseUrl: options?.baseUrl ?? (0, __thunderid_javascript.
|
|
3092
|
+
baseUrl: options?.baseUrl ?? (0, __thunderid_javascript.resolveRequestBaseUrl)(configData),
|
|
3090
3093
|
fetcher: createHttpClientFetcher_default(this._browserInstanceId),
|
|
3091
3094
|
url: (0, __thunderid_javascript.resolveResourceEndpoint)("usersMe", configData, options?.url)
|
|
3092
3095
|
});
|