-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathauth.js
More file actions
65 lines (63 loc) · 2.41 KB
/
auth.js
File metadata and controls
65 lines (63 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { t as getAuthRuntimeModule } from "./chunks/public-runtime-modules-D0nOC9BY.js";
//#region src/public/auth.ts
/**
* Registers an auth module that can handle authentication. An auth module is used by specifying its name as authType in the HostConfig passed in to api calls.
* @param name the name of the module
* @param authModule the implementation of the AuthModule interface
*/
function registerAuthModule(name, authModule) {
getAuthRuntimeModule().then((impl) => impl.registerAuthModule(name, authModule));
}
/**
* Logs out the user and sets `global.loggingOut` to true.
*
* **NOTE**: Does not abort pending requests.
*/
function logout() {
getAuthRuntimeModule().then((impl) => impl.logout());
}
/**
* Sets the default host config that will be used for all api calls that do not include a HostConfig
* @param hostConfig the default HostConfig to use
*/
function setDefaultHostConfig(hostConfig) {
getAuthRuntimeModule(hostConfig).then((impl) => impl.setDefaultHostConfig(hostConfig));
}
/**
* Registers a host config with the given name.
* @param name The name of the host config to be used to reference the host config later.
* @param hostConfig The host config to register.
*/
function registerHostConfig(name, hostConfig) {
getAuthRuntimeModule(hostConfig).then((impl) => impl.registerHostConfig(name, hostConfig));
}
/**
* Unregisters a host config with the given name.
* @param name The name of the host config to unregister.
*/
function unregisterHostConfig(name) {
getAuthRuntimeModule().then((impl) => impl.unregisterHostConfig(name));
}
/**
* Returns an access token using the supplied host config. Typically used on the backend to supply the access token to the frontend
*/
async function getAccessToken({ hostConfig }) {
return getAuthRuntimeModule(hostConfig).then((impl) => impl.getAccessToken({ hostConfig }));
}
/**
* Returns a record of query parameters that needs to be added to resources requests, e.g.
* image tags, etc.
*/
async function getWebResourceAuthParams({ hostConfig }) {
return getAuthRuntimeModule(hostConfig).then((impl) => impl.getWebResourceAuthParams({ hostConfig }));
}
var auth_default = {
registerAuthModule,
setDefaultHostConfig,
registerHostConfig,
unregisterHostConfig,
getAccessToken,
getWebResourceAuthParams
};
//#endregion
export { auth_default as default, getAccessToken, getWebResourceAuthParams, logout, registerAuthModule, registerHostConfig, setDefaultHostConfig, unregisterHostConfig };