@umbraco-cms/backoffice 14.0.0--preview005-5c967edf → 14.0.0--preview005-2c00d16c
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-cms/apps/app/app.element.js +1 -0
- package/dist-cms/shared/auth/auth.context.d.ts +35 -1
- package/dist-cms/shared/auth/auth.context.js +50 -3
- package/dist-cms/shared/auth/index.d.ts +1 -0
- package/dist-cms/shared/auth/index.js +1 -0
- package/dist-cms/shared/auth/models/openApiConfiguration.d.ts +28 -0
- package/dist-cms/shared/auth/models/openApiConfiguration.js +1 -0
- package/dist-cms/tsconfig.build.tsbuildinfo +1 -1
- package/examples/sorter-with-nested-containers/sorter-dashboard.ts +1 -0
- package/examples/sorter-with-nested-containers/sorter-group.ts +3 -8
- package/examples/sorter-with-two-containers/sorter-dashboard.ts +1 -0
- package/examples/sorter-with-two-containers/sorter-group.ts +3 -0
- package/package.json +2 -2
|
@@ -138,6 +138,7 @@ async function _UmbAppElement_setAuthStatus() {
|
|
|
138
138
|
// Instruct all requests to use the auth flow to get and use the access_token for all subsequent requests
|
|
139
139
|
OpenAPI.TOKEN = () => __classPrivateFieldGet(this, _UmbAppElement_authContext, "f").getLatestToken();
|
|
140
140
|
OpenAPI.WITH_CREDENTIALS = true;
|
|
141
|
+
OpenAPI.CREDENTIALS = 'include';
|
|
141
142
|
};
|
|
142
143
|
_UmbAppElement_redirect = function _UmbAppElement_redirect() {
|
|
143
144
|
// If there is a ?code parameter in the url, then we are in the middle of the oauth flow
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UmbOpenApiConfiguration } from './models/openApiConfiguration.js';
|
|
1
2
|
import type { UmbControllerHostElement } from '../../libs/controller-api/index.js';
|
|
2
3
|
import { UmbBaseController } from '../../libs/class-api/index.js';
|
|
3
4
|
export declare class UmbAuthContext extends UmbBaseController {
|
|
@@ -28,7 +29,7 @@ export declare class UmbAuthContext extends UmbBaseController {
|
|
|
28
29
|
*
|
|
29
30
|
* NB! The user may experience being redirected to the login screen if the token is expired.
|
|
30
31
|
*
|
|
31
|
-
* @example
|
|
32
|
+
* @example <caption>Using the latest token</caption>
|
|
32
33
|
* ```js
|
|
33
34
|
* const token = await authContext.getLatestToken();
|
|
34
35
|
* const result = await fetch('https://my-api.com', { headers: { Authorization: `Bearer ${token}` } });
|
|
@@ -48,4 +49,37 @@ export declare class UmbAuthContext extends UmbBaseController {
|
|
|
48
49
|
* @memberof UmbAuthContext
|
|
49
50
|
*/
|
|
50
51
|
signOut(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the server url to the Management API.
|
|
54
|
+
* @memberof UmbAuthContext
|
|
55
|
+
* @example <caption>Using the server url</caption>
|
|
56
|
+
* ```js
|
|
57
|
+
* const serverUrl = authContext.getServerUrl();
|
|
58
|
+
* OpenAPI.BASE = serverUrl;
|
|
59
|
+
* ```
|
|
60
|
+
* @example <caption></caption>
|
|
61
|
+
* ```js
|
|
62
|
+
* const serverUrl = authContext.getServerUrl();
|
|
63
|
+
* const token = await authContext.getLatestToken();
|
|
64
|
+
* const result = await fetch(`${serverUrl}/umbraco/management/api/v1/my-resource`, { headers: { Authorization: `Bearer ${token}` } });
|
|
65
|
+
* ```
|
|
66
|
+
* @returns The server url to the Management API
|
|
67
|
+
*/
|
|
68
|
+
getServerUrl(): string;
|
|
69
|
+
/**
|
|
70
|
+
* Get the default OpenAPI configuration, which is set up to communicate with the Management API.
|
|
71
|
+
* @remark This is useful if you want to communicate with your own resources generated by the [openapi-typescript-codegen](https://github.com/ferdikoomen/openapi-typescript-codegen) library.
|
|
72
|
+
* @memberof UmbAuthContext
|
|
73
|
+
*
|
|
74
|
+
* @example <caption>Using the default OpenAPI configuration</caption>
|
|
75
|
+
* ```js
|
|
76
|
+
* const defaultOpenApi = authContext.getOpenApiConfiguration();
|
|
77
|
+
* OpenAPI.BASE = defaultOpenApi.base;
|
|
78
|
+
* OpenAPI.WITH_CREDENTIALS = defaultOpenApi.withCredentials;
|
|
79
|
+
* OpenAPI.CREDENTIALS = defaultOpenApi.credentials;
|
|
80
|
+
* OpenAPI.TOKEN = defaultOpenApi.token;
|
|
81
|
+
* ```
|
|
82
|
+
* @returns The default OpenAPI configuration
|
|
83
|
+
*/
|
|
84
|
+
getOpenApiConfiguration(): UmbOpenApiConfiguration;
|
|
51
85
|
}
|
|
@@ -9,11 +9,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _UmbAuthContext_instances, _UmbAuthContext_isAuthorized, _UmbAuthContext_isBypassed, _UmbAuthContext_backofficePath, _UmbAuthContext_authFlow, _UmbAuthContext_getRedirectUrl;
|
|
12
|
+
var _UmbAuthContext_instances, _UmbAuthContext_isAuthorized, _UmbAuthContext_isBypassed, _UmbAuthContext_serverUrl, _UmbAuthContext_backofficePath, _UmbAuthContext_authFlow, _UmbAuthContext_openApi, _UmbAuthContext_getRedirectUrl;
|
|
13
13
|
import { UmbAuthFlow } from './auth-flow.js';
|
|
14
14
|
import { UMB_AUTH_CONTEXT } from './auth.context.token.js';
|
|
15
15
|
import { UmbBaseController } from '../../libs/class-api/index.js';
|
|
16
16
|
import { UmbBooleanState } from '../../libs/observable-api/index.js';
|
|
17
|
+
import { OpenAPI } from '../../external/backend-api/index.js';
|
|
17
18
|
export class UmbAuthContext extends UmbBaseController {
|
|
18
19
|
constructor(host, serverUrl, backofficePath, isBypassed) {
|
|
19
20
|
super(host);
|
|
@@ -21,9 +22,12 @@ export class UmbAuthContext extends UmbBaseController {
|
|
|
21
22
|
_UmbAuthContext_isAuthorized.set(this, new UmbBooleanState(false));
|
|
22
23
|
this.isAuthorized = __classPrivateFieldGet(this, _UmbAuthContext_isAuthorized, "f").asObservable();
|
|
23
24
|
_UmbAuthContext_isBypassed.set(this, false);
|
|
25
|
+
_UmbAuthContext_serverUrl.set(this, void 0);
|
|
24
26
|
_UmbAuthContext_backofficePath.set(this, void 0);
|
|
25
27
|
_UmbAuthContext_authFlow.set(this, void 0);
|
|
28
|
+
_UmbAuthContext_openApi.set(this, OpenAPI);
|
|
26
29
|
__classPrivateFieldSet(this, _UmbAuthContext_isBypassed, isBypassed, "f");
|
|
30
|
+
__classPrivateFieldSet(this, _UmbAuthContext_serverUrl, serverUrl, "f");
|
|
27
31
|
__classPrivateFieldSet(this, _UmbAuthContext_backofficePath, backofficePath, "f");
|
|
28
32
|
__classPrivateFieldSet(this, _UmbAuthContext_authFlow, new UmbAuthFlow(serverUrl, __classPrivateFieldGet(this, _UmbAuthContext_instances, "m", _UmbAuthContext_getRedirectUrl).call(this)), "f");
|
|
29
33
|
this.provideContext(UMB_AUTH_CONTEXT, this);
|
|
@@ -68,7 +72,7 @@ export class UmbAuthContext extends UmbBaseController {
|
|
|
68
72
|
*
|
|
69
73
|
* NB! The user may experience being redirected to the login screen if the token is expired.
|
|
70
74
|
*
|
|
71
|
-
* @example
|
|
75
|
+
* @example <caption>Using the latest token</caption>
|
|
72
76
|
* ```js
|
|
73
77
|
* const token = await authContext.getLatestToken();
|
|
74
78
|
* const result = await fetch('https://my-api.com', { headers: { Authorization: `Bearer ${token}` } });
|
|
@@ -94,7 +98,50 @@ export class UmbAuthContext extends UmbBaseController {
|
|
|
94
98
|
signOut() {
|
|
95
99
|
return __classPrivateFieldGet(this, _UmbAuthContext_authFlow, "f").signOut();
|
|
96
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Get the server url to the Management API.
|
|
103
|
+
* @memberof UmbAuthContext
|
|
104
|
+
* @example <caption>Using the server url</caption>
|
|
105
|
+
* ```js
|
|
106
|
+
* const serverUrl = authContext.getServerUrl();
|
|
107
|
+
* OpenAPI.BASE = serverUrl;
|
|
108
|
+
* ```
|
|
109
|
+
* @example <caption></caption>
|
|
110
|
+
* ```js
|
|
111
|
+
* const serverUrl = authContext.getServerUrl();
|
|
112
|
+
* const token = await authContext.getLatestToken();
|
|
113
|
+
* const result = await fetch(`${serverUrl}/umbraco/management/api/v1/my-resource`, { headers: { Authorization: `Bearer ${token}` } });
|
|
114
|
+
* ```
|
|
115
|
+
* @returns The server url to the Management API
|
|
116
|
+
*/
|
|
117
|
+
getServerUrl() {
|
|
118
|
+
return __classPrivateFieldGet(this, _UmbAuthContext_serverUrl, "f");
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get the default OpenAPI configuration, which is set up to communicate with the Management API.
|
|
122
|
+
* @remark This is useful if you want to communicate with your own resources generated by the [openapi-typescript-codegen](https://github.com/ferdikoomen/openapi-typescript-codegen) library.
|
|
123
|
+
* @memberof UmbAuthContext
|
|
124
|
+
*
|
|
125
|
+
* @example <caption>Using the default OpenAPI configuration</caption>
|
|
126
|
+
* ```js
|
|
127
|
+
* const defaultOpenApi = authContext.getOpenApiConfiguration();
|
|
128
|
+
* OpenAPI.BASE = defaultOpenApi.base;
|
|
129
|
+
* OpenAPI.WITH_CREDENTIALS = defaultOpenApi.withCredentials;
|
|
130
|
+
* OpenAPI.CREDENTIALS = defaultOpenApi.credentials;
|
|
131
|
+
* OpenAPI.TOKEN = defaultOpenApi.token;
|
|
132
|
+
* ```
|
|
133
|
+
* @returns The default OpenAPI configuration
|
|
134
|
+
*/
|
|
135
|
+
getOpenApiConfiguration() {
|
|
136
|
+
return {
|
|
137
|
+
base: OpenAPI.BASE,
|
|
138
|
+
version: OpenAPI.VERSION,
|
|
139
|
+
withCredentials: OpenAPI.WITH_CREDENTIALS,
|
|
140
|
+
credentials: OpenAPI.CREDENTIALS,
|
|
141
|
+
token: () => this.getLatestToken(),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
97
144
|
}
|
|
98
|
-
_UmbAuthContext_isAuthorized = new WeakMap(), _UmbAuthContext_isBypassed = new WeakMap(), _UmbAuthContext_backofficePath = new WeakMap(), _UmbAuthContext_authFlow = new WeakMap(), _UmbAuthContext_instances = new WeakSet(), _UmbAuthContext_getRedirectUrl = function _UmbAuthContext_getRedirectUrl() {
|
|
145
|
+
_UmbAuthContext_isAuthorized = new WeakMap(), _UmbAuthContext_isBypassed = new WeakMap(), _UmbAuthContext_serverUrl = new WeakMap(), _UmbAuthContext_backofficePath = new WeakMap(), _UmbAuthContext_authFlow = new WeakMap(), _UmbAuthContext_openApi = new WeakMap(), _UmbAuthContext_instances = new WeakSet(), _UmbAuthContext_getRedirectUrl = function _UmbAuthContext_getRedirectUrl() {
|
|
99
146
|
return `${window.location.origin}${__classPrivateFieldGet(this, _UmbAuthContext_backofficePath, "f")}`;
|
|
100
147
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the OpenAPI (Umbraco) server. This is used to communicate with the Management API.
|
|
3
|
+
* This is useful if you want to configure your Fetch, Axios or other HTTP client to communicate with the Management API.
|
|
4
|
+
* If you use the recommended resource generator [openapi-typescript-codegen](https://github.com/ferdikoomen/openapi-typescript-codegen) this can be used to configure the `OpenAPI` object.
|
|
5
|
+
*/
|
|
6
|
+
export interface UmbOpenApiConfiguration {
|
|
7
|
+
/**
|
|
8
|
+
* The base URL of the OpenAPI (Umbraco) server.
|
|
9
|
+
*/
|
|
10
|
+
readonly base: string;
|
|
11
|
+
/**
|
|
12
|
+
* The configured version of the Management API to use.
|
|
13
|
+
*/
|
|
14
|
+
readonly version: string;
|
|
15
|
+
/**
|
|
16
|
+
* The `withCredentials` option for the Fetch API.
|
|
17
|
+
*/
|
|
18
|
+
readonly withCredentials: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The `credentials` option for the Fetch API.
|
|
21
|
+
*/
|
|
22
|
+
readonly credentials: 'include' | 'omit' | 'same-origin';
|
|
23
|
+
/**
|
|
24
|
+
* The token to use for the Authorization header.
|
|
25
|
+
* @returns A resolver for the token to use for the Authorization header.
|
|
26
|
+
*/
|
|
27
|
+
readonly token: () => Promise<string>;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|