@openstax/ts-utils 1.6.0 → 1.6.2
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/cjs/services/apiGateway/index.js +1 -1
- package/dist/cjs/services/authProvider/browser.d.ts +4 -0
- package/dist/cjs/services/authProvider/browser.js +7 -0
- package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -1
- package/dist/esm/services/apiGateway/index.js +1 -1
- package/dist/esm/services/authProvider/browser.d.ts +4 -0
- package/dist/esm/services/authProvider/browser.js +7 -0
- package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -45,7 +45,7 @@ const makeRouteClient = (initializer, config, route, authProvider) => {
|
|
|
45
45
|
status: response.status,
|
|
46
46
|
acceptStatus: (...status) => {
|
|
47
47
|
if (!status.includes(response.status)) {
|
|
48
|
-
throw new Error(
|
|
48
|
+
throw new Error(`unexpected HTTP ${response.status} response from api`);
|
|
49
49
|
}
|
|
50
50
|
return { status: response.status, headers: response.headers, load: loadResponse(response) };
|
|
51
51
|
},
|
|
@@ -29,6 +29,10 @@ export interface Window {
|
|
|
29
29
|
export declare const browserAuthProvider: <C extends string = "auth">({ window, configSpace }: Initializer<C>) => (configProvider: { [key in C]: {
|
|
30
30
|
accountsBase: import("../../config").ConfigValueProvider<string>;
|
|
31
31
|
}; }) => {
|
|
32
|
+
/**
|
|
33
|
+
* gets the authentication token
|
|
34
|
+
*/
|
|
35
|
+
getAuthToken: () => Promise<string | null>;
|
|
32
36
|
/**
|
|
33
37
|
* adds auth parameters to the url. this is only safe to use when using javascript to navigate
|
|
34
38
|
* within the current window, eg `window.location = 'https://my.otherservice.com';` anchors
|
|
@@ -17,6 +17,9 @@ export const browserAuthProvider = ({ window, configSpace }) => (configProvider)
|
|
|
17
17
|
let userData = {
|
|
18
18
|
token: [null, embeddedQueryValue].includes(authQuery) ? null : authQuery
|
|
19
19
|
};
|
|
20
|
+
const getAuthToken = async () => {
|
|
21
|
+
return (await getUserData()).token;
|
|
22
|
+
};
|
|
20
23
|
const getAuthorizedLinkUrl = (urlString) => {
|
|
21
24
|
const url = new URL(urlString);
|
|
22
25
|
if (userData.token) {
|
|
@@ -89,6 +92,10 @@ export const browserAuthProvider = ({ window, configSpace }) => (configProvider)
|
|
|
89
92
|
return (await getUserData()).user;
|
|
90
93
|
};
|
|
91
94
|
return {
|
|
95
|
+
/**
|
|
96
|
+
* gets the authentication token
|
|
97
|
+
*/
|
|
98
|
+
getAuthToken,
|
|
92
99
|
/**
|
|
93
100
|
* adds auth parameters to the url. this is only safe to use when using javascript to navigate
|
|
94
101
|
* within the current window, eg `window.location = 'https://my.otherservice.com';` anchors
|