@webiny/wcp 5.44.1-beta.0 → 5.45.0-beta.0
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/License.d.ts +5 -3
- package/License.js +16 -16
- package/License.js.map +1 -1
- package/NullLicense.d.ts +4 -2
- package/NullLicense.js +7 -8
- package/NullLicense.js.map +1 -1
- package/README.md +7 -111
- package/encryption.js +2 -10
- package/encryption.js.map +1 -1
- package/getWcpProjectEnvironment.d.ts +1 -1
- package/getWcpProjectEnvironment.js +3 -9
- package/getWcpProjectEnvironment.js.map +1 -1
- package/index.d.ts +5 -5
- package/index.js +7 -82
- package/index.js.map +1 -1
- package/licenses.d.ts +1 -1
- package/licenses.js +6 -15
- package/licenses.js.map +1 -1
- package/package.json +6 -12
- package/testing/createTestWcpLicense.d.ts +7 -2
- package/testing/createTestWcpLicense.js +13 -20
- package/testing/createTestWcpLicense.js.map +1 -1
- package/types.d.ts +6 -1
- package/types.js +9 -8
- package/types.js.map +1 -1
- package/urls.js +3 -12
- package/urls.js.map +1 -1
package/License.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { DecryptedWcpProjectLicense, ILicense, WcpProject } from "./types";
|
|
2
|
-
import { NullLicense } from "./NullLicense";
|
|
3
|
-
import { WCP_FEATURE_LABEL } from "./index";
|
|
1
|
+
import type { DecryptedWcpProjectLicense, ILicense, WcpProject } from "./types.js";
|
|
2
|
+
import { NullLicense } from "./NullLicense.js";
|
|
3
|
+
import type { WCP_FEATURE_LABEL } from "./index.js";
|
|
4
4
|
export declare class License implements ILicense {
|
|
5
5
|
private readonly license;
|
|
6
6
|
static fromLicenseDto(license: DecryptedWcpProjectLicense | null): NullLicense | License;
|
|
7
7
|
static fromEnvironment(): Promise<NullLicense | License>;
|
|
8
8
|
private constructor();
|
|
9
9
|
getRawLicense(): DecryptedWcpProjectLicense;
|
|
10
|
+
toDto(): DecryptedWcpProjectLicense;
|
|
10
11
|
getProject(): WcpProject | null;
|
|
11
12
|
canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): boolean;
|
|
12
13
|
canUseAacl(): boolean;
|
|
@@ -16,4 +17,5 @@ export declare class License implements ILicense {
|
|
|
16
17
|
canUseAuditLogs(): boolean;
|
|
17
18
|
canUseRecordLocking(): boolean;
|
|
18
19
|
canUseFileManagerThreatDetection(): boolean;
|
|
20
|
+
canUseWorkflows(): boolean;
|
|
19
21
|
}
|
package/License.js
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.License = void 0;
|
|
7
|
-
var _getWcpProjectEnvironment = require("./getWcpProjectEnvironment");
|
|
8
|
-
var _licenses = require("./licenses");
|
|
9
|
-
var _NullLicense = require("./NullLicense");
|
|
10
|
-
class License {
|
|
1
|
+
import { getWcpProjectEnvironment } from "./getWcpProjectEnvironment.js";
|
|
2
|
+
import { getWcpProjectLicense } from "./licenses.js";
|
|
3
|
+
import { NullLicense } from "./NullLicense.js";
|
|
4
|
+
export class License {
|
|
11
5
|
static fromLicenseDto(license) {
|
|
12
6
|
if (!license) {
|
|
13
|
-
return new
|
|
7
|
+
return new NullLicense();
|
|
14
8
|
}
|
|
15
9
|
return new License(license);
|
|
16
10
|
}
|
|
17
11
|
static async fromEnvironment() {
|
|
18
|
-
const wcpProjectEnvironment =
|
|
12
|
+
const wcpProjectEnvironment = getWcpProjectEnvironment();
|
|
19
13
|
if (!wcpProjectEnvironment) {
|
|
20
|
-
return new
|
|
14
|
+
return new NullLicense();
|
|
21
15
|
}
|
|
22
|
-
const license = await
|
|
16
|
+
const license = await getWcpProjectLicense({
|
|
23
17
|
orgId: wcpProjectEnvironment.org.id,
|
|
24
18
|
projectId: wcpProjectEnvironment.project.id,
|
|
25
19
|
projectEnvironmentApiKey: wcpProjectEnvironment.apiKey
|
|
@@ -32,10 +26,14 @@ class License {
|
|
|
32
26
|
getRawLicense() {
|
|
33
27
|
return this.license;
|
|
34
28
|
}
|
|
29
|
+
toDto() {
|
|
30
|
+
return this.license;
|
|
31
|
+
}
|
|
35
32
|
getProject() {
|
|
36
33
|
return {
|
|
37
34
|
orgId: this.license.orgId,
|
|
38
|
-
projectId: this.license.projectId
|
|
35
|
+
projectId: this.license.projectId,
|
|
36
|
+
package: this.license.package
|
|
39
37
|
};
|
|
40
38
|
}
|
|
41
39
|
canUseFeature(wcpFeatureId) {
|
|
@@ -71,7 +69,9 @@ class License {
|
|
|
71
69
|
canUseFileManagerThreatDetection() {
|
|
72
70
|
return this.license.package.features.fileManager?.options.threatDetection ?? false;
|
|
73
71
|
}
|
|
72
|
+
canUseWorkflows() {
|
|
73
|
+
return this.canUseFeature("advancedPublishingWorkflow");
|
|
74
|
+
}
|
|
74
75
|
}
|
|
75
|
-
exports.License = License;
|
|
76
76
|
|
|
77
77
|
//# sourceMappingURL=License.js.map
|
package/License.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getWcpProjectEnvironment","getWcpProjectLicense","NullLicense","License","fromLicenseDto","license","fromEnvironment","wcpProjectEnvironment","orgId","org","id","projectId","project","projectEnvironmentApiKey","apiKey","constructor","getRawLicense","toDto","getProject","package","canUseFeature","wcpFeatureId","features","enabled","canUseAacl","canUseTeams","advancedAccessControlLayer","options","teams","canUseFolderLevelPermissions","folderLevelPermissions","canUsePrivateFiles","privateFiles","canUseAuditLogs","canUseRecordLocking","canUseFileManagerThreatDetection","fileManager","threatDetection","canUseWorkflows"],"sources":["License.ts"],"sourcesContent":["import { getWcpProjectEnvironment } from \"./getWcpProjectEnvironment.js\";\nimport type { DecryptedWcpProjectLicense, ILicense, WcpProject } from \"./types.js\";\nimport { getWcpProjectLicense } from \"./licenses.js\";\nimport { NullLicense } from \"./NullLicense.js\";\nimport type { WCP_FEATURE_LABEL } from \"./index.js\";\n\nexport class License implements ILicense {\n private readonly license: DecryptedWcpProjectLicense;\n\n static fromLicenseDto(license: DecryptedWcpProjectLicense | null) {\n if (!license) {\n return new NullLicense();\n }\n\n return new License(license);\n }\n\n static async fromEnvironment() {\n const wcpProjectEnvironment = getWcpProjectEnvironment();\n\n if (!wcpProjectEnvironment) {\n return new NullLicense();\n }\n\n const license = await getWcpProjectLicense({\n orgId: wcpProjectEnvironment.org.id,\n projectId: wcpProjectEnvironment.project.id,\n projectEnvironmentApiKey: wcpProjectEnvironment.apiKey\n });\n\n return License.fromLicenseDto(license);\n }\n\n private constructor(license: DecryptedWcpProjectLicense) {\n this.license = license;\n }\n\n getRawLicense(): DecryptedWcpProjectLicense {\n return this.license;\n }\n\n toDto(): DecryptedWcpProjectLicense {\n return this.license;\n }\n\n getProject(): WcpProject | null {\n return {\n orgId: this.license.orgId,\n projectId: this.license.projectId,\n package: this.license.package\n };\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL) {\n return this.license.package?.features?.[wcpFeatureId]?.enabled === true;\n }\n\n canUseAacl() {\n return this.canUseFeature(\"advancedAccessControlLayer\");\n }\n\n canUseTeams() {\n if (!this.canUseAacl()) {\n return false;\n }\n\n return this.license.package.features.advancedAccessControlLayer.options.teams;\n }\n\n canUseFolderLevelPermissions() {\n if (!this.canUseAacl()) {\n return false;\n }\n\n return this.license.package.features.advancedAccessControlLayer.options\n .folderLevelPermissions;\n }\n\n canUsePrivateFiles() {\n if (!this.canUseAacl()) {\n return false;\n }\n\n return this.license.package.features.advancedAccessControlLayer.options.privateFiles;\n }\n\n canUseAuditLogs() {\n return this.canUseFeature(\"auditLogs\");\n }\n\n canUseRecordLocking() {\n return this.canUseFeature(\"recordLocking\");\n }\n\n canUseFileManagerThreatDetection() {\n return this.license.package.features.fileManager?.options.threatDetection ?? false;\n }\n\n public canUseWorkflows(): boolean {\n return this.canUseFeature(\"advancedPublishingWorkflow\");\n }\n}\n"],"mappings":"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","ignoreList":[]}
|
package/NullLicense.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { WCP_FEATURE_LABEL } from "./index";
|
|
2
|
-
import type { ILicense, WcpProject } from "./types";
|
|
1
|
+
import type { WCP_FEATURE_LABEL } from "./index.js";
|
|
2
|
+
import type { ILicense, WcpProject } from "./types.js";
|
|
3
3
|
export declare class NullLicense implements ILicense {
|
|
4
4
|
getRawLicense(): null;
|
|
5
|
+
toDto(): null;
|
|
5
6
|
getProject(): WcpProject | null;
|
|
6
7
|
canUseAacl(): boolean;
|
|
7
8
|
canUseAuditLogs(): boolean;
|
|
@@ -11,4 +12,5 @@ export declare class NullLicense implements ILicense {
|
|
|
11
12
|
canUsePrivateFiles(): boolean;
|
|
12
13
|
canUseRecordLocking(): boolean;
|
|
13
14
|
canUseTeams(): boolean;
|
|
15
|
+
canUseWorkflows(): boolean;
|
|
14
16
|
}
|
package/NullLicense.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.NullLicense = void 0;
|
|
7
|
-
class NullLicense {
|
|
1
|
+
export class NullLicense {
|
|
8
2
|
getRawLicense() {
|
|
9
3
|
return null;
|
|
10
4
|
}
|
|
5
|
+
toDto() {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
11
8
|
getProject() {
|
|
12
9
|
return null;
|
|
13
10
|
}
|
|
@@ -39,7 +36,9 @@ class NullLicense {
|
|
|
39
36
|
canUseTeams() {
|
|
40
37
|
return false;
|
|
41
38
|
}
|
|
39
|
+
canUseWorkflows() {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
42
|
}
|
|
43
|
-
exports.NullLicense = NullLicense;
|
|
44
43
|
|
|
45
44
|
//# sourceMappingURL=NullLicense.js.map
|
package/NullLicense.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NullLicense","getRawLicense","getProject","canUseAacl","canUseAuditLogs","canUseFeature","featureId","process","env","WEBINY_MULTI_TENANCY","canUseFileManagerThreatDetection","canUseFolderLevelPermissions","canUsePrivateFiles","canUseRecordLocking","canUseTeams","
|
|
1
|
+
{"version":3,"names":["NullLicense","getRawLicense","toDto","getProject","canUseAacl","canUseAuditLogs","canUseFeature","featureId","process","env","WEBINY_MULTI_TENANCY","canUseFileManagerThreatDetection","canUseFolderLevelPermissions","canUsePrivateFiles","canUseRecordLocking","canUseTeams","canUseWorkflows"],"sources":["NullLicense.ts"],"sourcesContent":["import type { WCP_FEATURE_LABEL } from \"./index.js\";\nimport type { ILicense, WcpProject } from \"./types.js\";\n\nexport class NullLicense implements ILicense {\n getRawLicense() {\n return null;\n }\n\n toDto(): null {\n return null;\n }\n\n getProject(): WcpProject | null {\n return null;\n }\n\n canUseAacl() {\n return false;\n }\n\n canUseAuditLogs() {\n return false;\n }\n\n canUseFeature(featureId: keyof typeof WCP_FEATURE_LABEL): boolean {\n // For backwards compatibility, we need to check the legacy ENV variable `WEBINY_MULTI_TENANCY`.\n if (featureId === \"multiTenancy\") {\n return process.env.WEBINY_MULTI_TENANCY === \"true\";\n }\n\n return false;\n }\n\n canUseFileManagerThreatDetection() {\n return false;\n }\n\n canUseFolderLevelPermissions() {\n return false;\n }\n\n canUsePrivateFiles() {\n return false;\n }\n\n canUseRecordLocking() {\n return false;\n }\n\n canUseTeams() {\n return false;\n }\n\n public canUseWorkflows(): boolean {\n return false;\n }\n}\n"],"mappings":"AAGA,OAAO,MAAMA,WAAW,CAAqB;EACzCC,aAAaA,CAAA,EAAG;IACZ,OAAO,IAAI;EACf;EAEAC,KAAKA,CAAA,EAAS;IACV,OAAO,IAAI;EACf;EAEAC,UAAUA,CAAA,EAAsB;IAC5B,OAAO,IAAI;EACf;EAEAC,UAAUA,CAAA,EAAG;IACT,OAAO,KAAK;EAChB;EAEAC,eAAeA,CAAA,EAAG;IACd,OAAO,KAAK;EAChB;EAEAC,aAAaA,CAACC,SAAyC,EAAW;IAC9D;IACA,IAAIA,SAAS,KAAK,cAAc,EAAE;MAC9B,OAAOC,OAAO,CAACC,GAAG,CAACC,oBAAoB,KAAK,MAAM;IACtD;IAEA,OAAO,KAAK;EAChB;EAEAC,gCAAgCA,CAAA,EAAG;IAC/B,OAAO,KAAK;EAChB;EAEAC,4BAA4BA,CAAA,EAAG;IAC3B,OAAO,KAAK;EAChB;EAEAC,kBAAkBA,CAAA,EAAG;IACjB,OAAO,KAAK;EAChB;EAEAC,mBAAmBA,CAAA,EAAG;IAClB,OAAO,KAAK;EAChB;EAEAC,WAAWA,CAAA,EAAG;IACV,OAAO,KAAK;EAChB;EAEOC,eAAeA,CAAA,EAAY;IAC9B,OAAO,KAAK;EAChB;AACJ","ignoreList":[]}
|
package/README.md
CHANGED
|
@@ -1,115 +1,11 @@
|
|
|
1
|
-
#
|
|
2
|
-
[](https://www.npmjs.com/package/@webiny/wcp)
|
|
3
|
-
[](https://www.npmjs.com/package/@webiny/wcp)
|
|
4
|
-
[](https://github.com/prettier/prettier)
|
|
5
|
-
[](http://makeapullrequest.com)
|
|
1
|
+
# @webiny/wcp
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
- [Overview](#overview)
|
|
13
|
-
- [Examples](#examples)
|
|
14
|
-
- [Reference](#reference)
|
|
15
|
-
- [Functions](#functions)
|
|
16
|
-
- [`getWcpAppUrl`](#getWcpAppUrl)
|
|
17
|
-
- [`getWcpApiUrl`](#getWcpApiUrl)
|
|
18
|
-
- [`getWcpGqlApiUrl`](#getWcpGqlApiUrl)
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
npm install --save @webiny/wcp
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Or if you prefer yarn:
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
yarn add @webiny/wcp
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
## Overview
|
|
34
|
-
|
|
35
|
-
The `@webiny/wcp` package contains essential Webiny Control Panel (WCP)-related utilities.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
## Examples
|
|
40
|
-
|
|
41
|
-
| Example | Description |
|
|
42
|
-
| ------- | ----------- |
|
|
43
|
-
| [Retrieve WCP URLs](./docs/examples/retrievingWcpUrls.md) | Shows how to retrieve WCP API and app URLs. |
|
|
44
|
-
|
|
45
|
-
## Reference
|
|
46
|
-
|
|
47
|
-
### Functions
|
|
48
|
-
|
|
49
|
-
#### `getWcpAppUrl`
|
|
50
|
-
|
|
51
|
-
<details>
|
|
52
|
-
<summary>Type Declaration</summary>
|
|
53
|
-
<p>
|
|
54
|
-
|
|
55
|
-
```ts
|
|
56
|
-
export declare const getWcpAppUrl: (path?: string | undefined) => string;
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
</p>
|
|
60
|
-
</details>
|
|
61
|
-
|
|
62
|
-
Returns WCP app URL. The default URL can be overridden via the `WCP_APP_URL` environment variable.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
```ts
|
|
66
|
-
import { getWcpAppUrl } from "@webiny/wcp";
|
|
67
|
-
|
|
68
|
-
console.log(getWcpAppUrl()); // Returns "https://d3mudimnmgk2a9.cloudfront.net".
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
#### `getWcpApiUrl`
|
|
73
|
-
|
|
74
|
-
<details>
|
|
75
|
-
<summary>Type Declaration</summary>
|
|
76
|
-
<p>
|
|
77
|
-
|
|
78
|
-
```ts
|
|
79
|
-
export declare const getWcpApiUrl: (path?: string | undefined) => string;
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
</p>
|
|
83
|
-
</details>
|
|
84
|
-
|
|
85
|
-
Returns WCP API URL. The default URL can be overridden via the `WCP_API_URL` environment variable.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
```ts
|
|
89
|
-
import { getWcpApiUrl } from "@webiny/wcp";
|
|
90
|
-
|
|
91
|
-
console.log(getWcpApiUrl()); // Returns "https://d3mudimnmgk2a9.cloudfront.net".
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
#### `getWcpGqlApiUrl`
|
|
95
|
-
|
|
96
|
-
<details>
|
|
97
|
-
<summary>Type Declaration</summary>
|
|
98
|
-
<p>
|
|
99
|
-
|
|
100
|
-
```ts
|
|
101
|
-
export declare const getWcpGqlApiUrl: (path?: string | undefined) => string;
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
</p>
|
|
105
|
-
</details>
|
|
106
|
-
|
|
107
|
-
Returns WCP GraphQL API URL.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
```ts
|
|
111
|
-
import { getWcpGqlApiUrl } from "@webiny/wcp";
|
|
112
|
-
|
|
113
|
-
console.log(getWcpGqlApiUrl()); // Returns "https://d3mudimnmgk2a9.cloudfront.net/graphql".
|
|
114
|
-
```
|
|
9
|
+
---
|
|
115
10
|
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/encryption.js
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.encrypt = exports.decrypt = void 0;
|
|
7
1
|
/**
|
|
8
2
|
* For now, we're not doing actual encryption, just simple base64 encoding/decoding.
|
|
9
3
|
* Potentially, we'll revisit this in the future and implement actual encryption.
|
|
10
4
|
*/
|
|
11
5
|
|
|
12
|
-
const encrypt = rawObject => {
|
|
6
|
+
export const encrypt = rawObject => {
|
|
13
7
|
try {
|
|
14
8
|
return Buffer.from(JSON.stringify(rawObject), "utf-8").toString("base64");
|
|
15
9
|
} catch {
|
|
16
10
|
throw new Error("Could not encrypt given data.");
|
|
17
11
|
}
|
|
18
12
|
};
|
|
19
|
-
|
|
20
|
-
const decrypt = encryptedString => {
|
|
13
|
+
export const decrypt = encryptedString => {
|
|
21
14
|
try {
|
|
22
15
|
const decryptedString = Buffer.from(encryptedString, "base64").toString("utf-8");
|
|
23
16
|
return JSON.parse(decryptedString);
|
|
@@ -25,6 +18,5 @@ const decrypt = encryptedString => {
|
|
|
25
18
|
throw new Error(`Could not decrypt the given string (${encryptedString}).`);
|
|
26
19
|
}
|
|
27
20
|
};
|
|
28
|
-
exports.decrypt = decrypt;
|
|
29
21
|
|
|
30
22
|
//# sourceMappingURL=encryption.js.map
|
package/encryption.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["encrypt","rawObject","Buffer","from","JSON","stringify","toString","Error","
|
|
1
|
+
{"version":3,"names":["encrypt","rawObject","Buffer","from","JSON","stringify","toString","Error","decrypt","encryptedString","decryptedString","parse"],"sources":["encryption.ts"],"sourcesContent":["/**\n * For now, we're not doing actual encryption, just simple base64 encoding/decoding.\n * Potentially, we'll revisit this in the future and implement actual encryption.\n */\n\nexport const encrypt = <T = Record<string, any>>(rawObject: T): string => {\n try {\n return Buffer.from(JSON.stringify(rawObject), \"utf-8\").toString(\"base64\");\n } catch {\n throw new Error(\"Could not encrypt given data.\");\n }\n};\n\nexport const decrypt = <T = Record<string, any>>(encryptedString: string): T => {\n try {\n const decryptedString = Buffer.from(encryptedString, \"base64\").toString(\"utf-8\");\n return JSON.parse(decryptedString) as T;\n } catch {\n throw new Error(`Could not decrypt the given string (${encryptedString}).`);\n }\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,OAAO,GAA6BC,SAAY,IAAa;EACtE,IAAI;IACA,OAAOC,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACJ,SAAS,CAAC,EAAE,OAAO,CAAC,CAACK,QAAQ,CAAC,QAAQ,CAAC;EAC7E,CAAC,CAAC,MAAM;IACJ,MAAM,IAAIC,KAAK,CAAC,+BAA+B,CAAC;EACpD;AACJ,CAAC;AAED,OAAO,MAAMC,OAAO,GAA6BC,eAAuB,IAAQ;EAC5E,IAAI;IACA,MAAMC,eAAe,GAAGR,MAAM,CAACC,IAAI,CAACM,eAAe,EAAE,QAAQ,CAAC,CAACH,QAAQ,CAAC,OAAO,CAAC;IAChF,OAAOF,IAAI,CAACO,KAAK,CAACD,eAAe,CAAC;EACtC,CAAC,CAAC,MAAM;IACJ,MAAM,IAAIH,KAAK,CAAC,uCAAuCE,eAAe,IAAI,CAAC;EAC/E;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { WcpProjectEnvironment } from "./types";
|
|
1
|
+
import type { WcpProjectEnvironment } from "./types.js";
|
|
2
2
|
export declare function getWcpProjectEnvironment(): WcpProjectEnvironment | null;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getWcpProjectEnvironment = getWcpProjectEnvironment;
|
|
7
|
-
var _encryption = require("./encryption");
|
|
8
|
-
function getWcpProjectEnvironment() {
|
|
1
|
+
import { decrypt } from "./encryption.js";
|
|
2
|
+
export function getWcpProjectEnvironment() {
|
|
9
3
|
if (process.env.WCP_PROJECT_ENVIRONMENT) {
|
|
10
4
|
try {
|
|
11
|
-
return
|
|
5
|
+
return decrypt(process.env.WCP_PROJECT_ENVIRONMENT);
|
|
12
6
|
} catch {
|
|
13
7
|
throw new Error("Could not decrypt WCP_PROJECT_ENVIRONMENT environment variable data.");
|
|
14
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["decrypt","getWcpProjectEnvironment","process","env","WCP_PROJECT_ENVIRONMENT","Error"],"sources":["getWcpProjectEnvironment.ts"],"sourcesContent":["import type { WcpProjectEnvironment } from \"./types.js\";\nimport { decrypt } from \"./encryption.js\";\n\nexport function getWcpProjectEnvironment(): WcpProjectEnvironment | null {\n if (process.env.WCP_PROJECT_ENVIRONMENT) {\n try {\n return decrypt<WcpProjectEnvironment>(process.env.WCP_PROJECT_ENVIRONMENT);\n } catch {\n throw new Error(\"Could not decrypt WCP_PROJECT_ENVIRONMENT environment variable data.\");\n }\n }\n return null;\n}\n"],"mappings":"AACA,SAASA,OAAO;AAEhB,OAAO,SAASC,wBAAwBA,CAAA,EAAiC;EACrE,IAAIC,OAAO,CAACC,GAAG,CAACC,uBAAuB,EAAE;IACrC,IAAI;MACA,OAAOJ,OAAO,CAAwBE,OAAO,CAACC,GAAG,CAACC,uBAAuB,CAAC;IAC9E,CAAC,CAAC,MAAM;MACJ,MAAM,IAAIC,KAAK,CAAC,sEAAsE,CAAC;IAC3F;EACJ;EACA,OAAO,IAAI;AACf","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from "./encryption";
|
|
2
|
-
export * from "./licenses";
|
|
3
|
-
export * from "./urls";
|
|
1
|
+
export * from "./encryption.js";
|
|
2
|
+
export * from "./licenses.js";
|
|
3
|
+
export * from "./urls.js";
|
|
4
4
|
export * from "./License.js";
|
|
5
|
-
export * from "./NullLicense";
|
|
6
|
-
export * from "./getWcpProjectEnvironment";
|
|
5
|
+
export * from "./NullLicense.js";
|
|
6
|
+
export * from "./getWcpProjectEnvironment.js";
|
|
7
7
|
export declare const WCP_FEATURE_LABEL: {
|
|
8
8
|
seats: string;
|
|
9
9
|
multiTenancy: string;
|
package/index.js
CHANGED
|
@@ -1,85 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
exports.WCP_FEATURE_LABEL = void 0;
|
|
10
|
-
var _encryption = require("./encryption");
|
|
11
|
-
Object.keys(_encryption).forEach(function (key) {
|
|
12
|
-
if (key === "default" || key === "__esModule") return;
|
|
13
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
14
|
-
if (key in exports && exports[key] === _encryption[key]) return;
|
|
15
|
-
Object.defineProperty(exports, key, {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () {
|
|
18
|
-
return _encryption[key];
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
var _licenses = require("./licenses");
|
|
23
|
-
Object.keys(_licenses).forEach(function (key) {
|
|
24
|
-
if (key === "default" || key === "__esModule") return;
|
|
25
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
26
|
-
if (key in exports && exports[key] === _licenses[key]) return;
|
|
27
|
-
Object.defineProperty(exports, key, {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function () {
|
|
30
|
-
return _licenses[key];
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
var _urls = require("./urls");
|
|
35
|
-
Object.keys(_urls).forEach(function (key) {
|
|
36
|
-
if (key === "default" || key === "__esModule") return;
|
|
37
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
38
|
-
if (key in exports && exports[key] === _urls[key]) return;
|
|
39
|
-
Object.defineProperty(exports, key, {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
get: function () {
|
|
42
|
-
return _urls[key];
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
var _License = require("./License.js");
|
|
47
|
-
Object.keys(_License).forEach(function (key) {
|
|
48
|
-
if (key === "default" || key === "__esModule") return;
|
|
49
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
50
|
-
if (key in exports && exports[key] === _License[key]) return;
|
|
51
|
-
Object.defineProperty(exports, key, {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: function () {
|
|
54
|
-
return _License[key];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
var _NullLicense = require("./NullLicense");
|
|
59
|
-
Object.keys(_NullLicense).forEach(function (key) {
|
|
60
|
-
if (key === "default" || key === "__esModule") return;
|
|
61
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
62
|
-
if (key in exports && exports[key] === _NullLicense[key]) return;
|
|
63
|
-
Object.defineProperty(exports, key, {
|
|
64
|
-
enumerable: true,
|
|
65
|
-
get: function () {
|
|
66
|
-
return _NullLicense[key];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
var _getWcpProjectEnvironment = require("./getWcpProjectEnvironment");
|
|
71
|
-
Object.keys(_getWcpProjectEnvironment).forEach(function (key) {
|
|
72
|
-
if (key === "default" || key === "__esModule") return;
|
|
73
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
74
|
-
if (key in exports && exports[key] === _getWcpProjectEnvironment[key]) return;
|
|
75
|
-
Object.defineProperty(exports, key, {
|
|
76
|
-
enumerable: true,
|
|
77
|
-
get: function () {
|
|
78
|
-
return _getWcpProjectEnvironment[key];
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
const WCP_FEATURE_LABEL = exports.WCP_FEATURE_LABEL = {
|
|
1
|
+
export * from "./encryption.js";
|
|
2
|
+
export * from "./licenses.js";
|
|
3
|
+
export * from "./urls.js";
|
|
4
|
+
export * from "./License.js";
|
|
5
|
+
export * from "./NullLicense.js";
|
|
6
|
+
export * from "./getWcpProjectEnvironment.js";
|
|
7
|
+
export const WCP_FEATURE_LABEL = {
|
|
83
8
|
seats: "User Seats",
|
|
84
9
|
multiTenancy: "Multi-tenancy",
|
|
85
10
|
advancedPublishingWorkflow: "Advanced Publishing Workflow (APW)",
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WCP_FEATURE_LABEL","seats","multiTenancy","advancedPublishingWorkflow","advancedAccessControlLayer","auditLogs","recordLocking","fileManager"],"sources":["index.ts"],"sourcesContent":["export * from \"./encryption.js\";\nexport * from \"./licenses.js\";\nexport * from \"./urls.js\";\nexport * from \"./License.js\";\nexport * from \"./NullLicense.js\";\nexport * from \"./getWcpProjectEnvironment.js\";\n\nexport const WCP_FEATURE_LABEL = {\n seats: \"User Seats\",\n multiTenancy: \"Multi-tenancy\",\n advancedPublishingWorkflow: \"Advanced Publishing Workflow (APW)\",\n advancedAccessControlLayer: \"Advanced Access Control Layer (ACL)\",\n auditLogs: \"Audit Logs\",\n recordLocking: \"Record Locking\",\n fileManager: \"File Manager\"\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,iBAAiB,GAAG;EAC7BC,KAAK,EAAE,YAAY;EACnBC,YAAY,EAAE,eAAe;EAC7BC,0BAA0B,EAAE,oCAAoC;EAChEC,0BAA0B,EAAE,qCAAqC;EACjEC,SAAS,EAAE,YAAY;EACvBC,aAAa,EAAE,gBAAgB;EAC/BC,WAAW,EAAE;AACjB,CAAC","ignoreList":[]}
|
package/licenses.d.ts
CHANGED
package/licenses.js
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getWcpProjectLicense = void 0;
|
|
8
|
-
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
9
|
-
var _encryption = require("./encryption");
|
|
10
|
-
var _urls = require("./urls");
|
|
1
|
+
import { decrypt } from "./encryption.js";
|
|
2
|
+
import { getWcpApiUrl } from "./urls.js";
|
|
11
3
|
const fetchWcpProjectLicense = async ({
|
|
12
4
|
orgId,
|
|
13
5
|
projectId,
|
|
14
6
|
projectEnvironmentApiKey
|
|
15
7
|
}) => {
|
|
16
8
|
// Fetch and decrypt the license.
|
|
17
|
-
const getLicenseEndpoint =
|
|
18
|
-
const encryptedLicense = await (
|
|
9
|
+
const getLicenseEndpoint = getWcpApiUrl(`/orgs/${orgId}/projects/${projectId}/license`);
|
|
10
|
+
const encryptedLicense = await fetch(getLicenseEndpoint, {
|
|
19
11
|
headers: {
|
|
20
12
|
authorization: projectEnvironmentApiKey
|
|
21
13
|
}
|
|
@@ -31,7 +23,7 @@ const fetchWcpProjectLicense = async ({
|
|
|
31
23
|
});
|
|
32
24
|
return encryptedLicense;
|
|
33
25
|
};
|
|
34
|
-
const getWcpProjectLicense = async params => {
|
|
26
|
+
export const getWcpProjectLicense = async params => {
|
|
35
27
|
let encryptedLicense = process.env.WCP_PROJECT_LICENSE;
|
|
36
28
|
if (!encryptedLicense) {
|
|
37
29
|
const fetchedLicense = await fetchWcpProjectLicense(params);
|
|
@@ -43,13 +35,12 @@ const getWcpProjectLicense = async params => {
|
|
|
43
35
|
return null;
|
|
44
36
|
}
|
|
45
37
|
try {
|
|
46
|
-
return
|
|
38
|
+
return decrypt(encryptedLicense);
|
|
47
39
|
} catch (e) {
|
|
48
40
|
const projectId = `${params.orgId}/${params.projectId}`;
|
|
49
41
|
console.warn(`An error occurred while trying to decrypt the retrieved license for project "${projectId}": ${e.message}`);
|
|
50
42
|
return null;
|
|
51
43
|
}
|
|
52
44
|
};
|
|
53
|
-
exports.getWcpProjectLicense = getWcpProjectLicense;
|
|
54
45
|
|
|
55
46
|
//# sourceMappingURL=licenses.js.map
|
package/licenses.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["decrypt","getWcpApiUrl","fetchWcpProjectLicense","orgId","projectId","projectEnvironmentApiKey","getLicenseEndpoint","encryptedLicense","fetch","headers","authorization","then","response","ok","json","console","warn","status","statusText","catch","e","message","getWcpProjectLicense","params","process","env","WCP_PROJECT_LICENSE","fetchedLicense","license"],"sources":["licenses.ts"],"sourcesContent":["import type { DecryptedWcpProjectLicense, EncryptedWcpProjectLicense } from \"./types.js\";\nimport { decrypt } from \"./encryption.js\";\nimport { getWcpApiUrl } from \"./urls.js\";\n\ninterface GetWcpProjectLicenseParams {\n orgId: string;\n projectId: string;\n projectEnvironmentApiKey: string;\n}\n\nconst fetchWcpProjectLicense = async ({\n orgId,\n projectId,\n projectEnvironmentApiKey\n}: GetWcpProjectLicenseParams) => {\n // Fetch and decrypt the license.\n const getLicenseEndpoint = getWcpApiUrl(`/orgs/${orgId}/projects/${projectId}/license`);\n\n const encryptedLicense: { license: EncryptedWcpProjectLicense } | null = await fetch(\n getLicenseEndpoint,\n {\n headers: { authorization: projectEnvironmentApiKey }\n }\n )\n .then(response => {\n if (response.ok) {\n return response.json();\n }\n\n console.warn(\n `An error occurred while trying to retrieve the license for project \"${orgId}/${projectId}\": invalid response status (${response.status}, ${response.statusText})`,\n response\n );\n\n return null;\n })\n .catch(e => {\n console.warn(\n `An error occurred while trying to retrieve the license for project \"${orgId}/${projectId}\": ${e.message}`,\n e\n );\n return null;\n });\n\n return encryptedLicense;\n};\n\nexport const getWcpProjectLicense = async (params: GetWcpProjectLicenseParams) => {\n let encryptedLicense = process.env.WCP_PROJECT_LICENSE;\n if (!encryptedLicense) {\n const fetchedLicense = await fetchWcpProjectLicense(params);\n if (fetchedLicense) {\n encryptedLicense = fetchedLicense.license;\n }\n }\n\n if (!encryptedLicense) {\n return null;\n }\n\n try {\n return decrypt<DecryptedWcpProjectLicense>(encryptedLicense);\n } catch (e) {\n const projectId = `${params.orgId}/${params.projectId}`;\n console.warn(\n `An error occurred while trying to decrypt the retrieved license for project \"${projectId}\": ${e.message}`\n );\n return null;\n }\n};\n"],"mappings":"AACA,SAASA,OAAO;AAChB,SAASC,YAAY;AAQrB,MAAMC,sBAAsB,GAAG,MAAAA,CAAO;EAClCC,KAAK;EACLC,SAAS;EACTC;AACwB,CAAC,KAAK;EAC9B;EACA,MAAMC,kBAAkB,GAAGL,YAAY,CAAC,SAASE,KAAK,aAAaC,SAAS,UAAU,CAAC;EAEvF,MAAMG,gBAAgE,GAAG,MAAMC,KAAK,CAChFF,kBAAkB,EAClB;IACIG,OAAO,EAAE;MAAEC,aAAa,EAAEL;IAAyB;EACvD,CACJ,CAAC,CACIM,IAAI,CAACC,QAAQ,IAAI;IACd,IAAIA,QAAQ,CAACC,EAAE,EAAE;MACb,OAAOD,QAAQ,CAACE,IAAI,CAAC,CAAC;IAC1B;IAEAC,OAAO,CAACC,IAAI,CACR,uEAAuEb,KAAK,IAAIC,SAAS,+BAA+BQ,QAAQ,CAACK,MAAM,KAAKL,QAAQ,CAACM,UAAU,GAAG,EAClKN,QACJ,CAAC;IAED,OAAO,IAAI;EACf,CAAC,CAAC,CACDO,KAAK,CAACC,CAAC,IAAI;IACRL,OAAO,CAACC,IAAI,CACR,uEAAuEb,KAAK,IAAIC,SAAS,MAAMgB,CAAC,CAACC,OAAO,EAAE,EAC1GD,CACJ,CAAC;IACD,OAAO,IAAI;EACf,CAAC,CAAC;EAEN,OAAOb,gBAAgB;AAC3B,CAAC;AAED,OAAO,MAAMe,oBAAoB,GAAG,MAAOC,MAAkC,IAAK;EAC9E,IAAIhB,gBAAgB,GAAGiB,OAAO,CAACC,GAAG,CAACC,mBAAmB;EACtD,IAAI,CAACnB,gBAAgB,EAAE;IACnB,MAAMoB,cAAc,GAAG,MAAMzB,sBAAsB,CAACqB,MAAM,CAAC;IAC3D,IAAII,cAAc,EAAE;MAChBpB,gBAAgB,GAAGoB,cAAc,CAACC,OAAO;IAC7C;EACJ;EAEA,IAAI,CAACrB,gBAAgB,EAAE;IACnB,OAAO,IAAI;EACf;EAEA,IAAI;IACA,OAAOP,OAAO,CAA6BO,gBAAgB,CAAC;EAChE,CAAC,CAAC,OAAOa,CAAC,EAAE;IACR,MAAMhB,SAAS,GAAG,GAAGmB,MAAM,CAACpB,KAAK,IAAIoB,MAAM,CAACnB,SAAS,EAAE;IACvDW,OAAO,CAACC,IAAI,CACR,gFAAgFZ,SAAS,MAAMgB,CAAC,CAACC,OAAO,EAC5G,CAAC;IACD,OAAO,IAAI;EACf;AACJ,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/wcp",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.45.0-beta.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "index.js",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
@@ -10,26 +11,19 @@
|
|
|
10
11
|
"description": "A set of Webiny Control Panel (WCP)-related utilities.",
|
|
11
12
|
"author": "Webiny Ltd.",
|
|
12
13
|
"license": "MIT",
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"node-fetch": "2.6.7"
|
|
15
|
-
},
|
|
16
14
|
"devDependencies": {
|
|
17
|
-
"@webiny/
|
|
18
|
-
"rimraf": "6.
|
|
19
|
-
"typescript": "5.
|
|
15
|
+
"@webiny/build-tools": "5.45.0-beta.0",
|
|
16
|
+
"rimraf": "6.1.3",
|
|
17
|
+
"typescript": "5.9.3"
|
|
20
18
|
},
|
|
21
19
|
"publishConfig": {
|
|
22
20
|
"access": "public",
|
|
23
21
|
"directory": "dist"
|
|
24
22
|
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"watch": "node ../cli/bin.js run watch",
|
|
27
|
-
"build": "node ../cli/bin.js run build"
|
|
28
|
-
},
|
|
29
23
|
"adio": {
|
|
30
24
|
"ignoreDirs": [
|
|
31
25
|
"__tests__"
|
|
32
26
|
]
|
|
33
27
|
},
|
|
34
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "b85c33cfbe7c02c130445c918d913ef4b2c09cb2"
|
|
35
29
|
}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import { DecryptedWcpProjectLicense } from "../types";
|
|
2
|
-
|
|
1
|
+
import type { DecryptedWcpProjectLicense } from "../types.js";
|
|
2
|
+
interface LicenseOptions {
|
|
3
|
+
recordLocking?: boolean;
|
|
4
|
+
folderLevelPermissions?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const createTestWcpLicense: (options?: LicenseOptions) => DecryptedWcpProjectLicense;
|
|
7
|
+
export {};
|
|
@@ -1,48 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createTestWcpLicense = void 0;
|
|
7
|
-
var _types = require("../types");
|
|
8
|
-
const createTestWcpLicense = () => {
|
|
1
|
+
import { MT_OPTIONS_MAX_COUNT_TYPE, PROJECT_PACKAGE_FEATURE_NAME } from "../types.js";
|
|
2
|
+
export const createTestWcpLicense = options => {
|
|
9
3
|
return {
|
|
10
4
|
orgId: "org-id",
|
|
11
5
|
projectId: "project-id",
|
|
12
6
|
package: {
|
|
13
7
|
features: {
|
|
14
|
-
[
|
|
8
|
+
[PROJECT_PACKAGE_FEATURE_NAME.AACL]: {
|
|
15
9
|
enabled: true,
|
|
16
10
|
options: {
|
|
17
11
|
teams: true,
|
|
18
|
-
folderLevelPermissions: true,
|
|
12
|
+
folderLevelPermissions: options?.folderLevelPermissions ?? true,
|
|
19
13
|
privateFiles: true
|
|
20
14
|
}
|
|
21
15
|
},
|
|
22
|
-
[
|
|
16
|
+
[PROJECT_PACKAGE_FEATURE_NAME.MT]: {
|
|
23
17
|
enabled: true,
|
|
24
18
|
options: {
|
|
25
19
|
maxCount: {
|
|
26
|
-
type:
|
|
20
|
+
type: MT_OPTIONS_MAX_COUNT_TYPE.SEAT_BASED
|
|
27
21
|
}
|
|
28
22
|
}
|
|
29
23
|
},
|
|
30
|
-
[
|
|
31
|
-
enabled:
|
|
24
|
+
[PROJECT_PACKAGE_FEATURE_NAME.APW]: {
|
|
25
|
+
enabled: true
|
|
32
26
|
},
|
|
33
|
-
[
|
|
27
|
+
[PROJECT_PACKAGE_FEATURE_NAME.AUDIT_LOGS]: {
|
|
34
28
|
enabled: false
|
|
35
29
|
},
|
|
36
|
-
[
|
|
37
|
-
enabled: false
|
|
30
|
+
[PROJECT_PACKAGE_FEATURE_NAME.RECORD_LOCKING]: {
|
|
31
|
+
enabled: options?.recordLocking ?? false
|
|
38
32
|
},
|
|
39
|
-
[
|
|
33
|
+
[PROJECT_PACKAGE_FEATURE_NAME.SEATS]: {
|
|
40
34
|
enabled: true,
|
|
41
35
|
options: {
|
|
42
36
|
maxCount: 100
|
|
43
37
|
}
|
|
44
38
|
},
|
|
45
|
-
[
|
|
39
|
+
[PROJECT_PACKAGE_FEATURE_NAME.FILE_MANAGER]: {
|
|
46
40
|
enabled: false,
|
|
47
41
|
options: {
|
|
48
42
|
threatDetection: false
|
|
@@ -52,6 +46,5 @@ const createTestWcpLicense = () => {
|
|
|
52
46
|
}
|
|
53
47
|
};
|
|
54
48
|
};
|
|
55
|
-
exports.createTestWcpLicense = createTestWcpLicense;
|
|
56
49
|
|
|
57
50
|
//# sourceMappingURL=createTestWcpLicense.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["MT_OPTIONS_MAX_COUNT_TYPE","PROJECT_PACKAGE_FEATURE_NAME","createTestWcpLicense","options","orgId","projectId","package","features","AACL","enabled","teams","folderLevelPermissions","privateFiles","MT","maxCount","type","SEAT_BASED","APW","AUDIT_LOGS","RECORD_LOCKING","recordLocking","SEATS","FILE_MANAGER","threatDetection"],"sources":["createTestWcpLicense.ts"],"sourcesContent":["import type { DecryptedWcpProjectLicense } from \"~/types.js\";\nimport { MT_OPTIONS_MAX_COUNT_TYPE, PROJECT_PACKAGE_FEATURE_NAME } from \"~/types.js\";\n\ninterface LicenseOptions {\n recordLocking?: boolean;\n folderLevelPermissions?: boolean;\n}\n\nexport const createTestWcpLicense = (options?: LicenseOptions): DecryptedWcpProjectLicense => {\n return {\n orgId: \"org-id\",\n projectId: \"project-id\",\n package: {\n features: {\n [PROJECT_PACKAGE_FEATURE_NAME.AACL]: {\n enabled: true,\n options: {\n teams: true,\n folderLevelPermissions: options?.folderLevelPermissions ?? true,\n privateFiles: true\n }\n },\n [PROJECT_PACKAGE_FEATURE_NAME.MT]: {\n enabled: true,\n options: {\n maxCount: {\n type: MT_OPTIONS_MAX_COUNT_TYPE.SEAT_BASED\n }\n }\n },\n [PROJECT_PACKAGE_FEATURE_NAME.APW]: {\n enabled: true\n },\n [PROJECT_PACKAGE_FEATURE_NAME.AUDIT_LOGS]: {\n enabled: false\n },\n [PROJECT_PACKAGE_FEATURE_NAME.RECORD_LOCKING]: {\n enabled: options?.recordLocking ?? false\n },\n [PROJECT_PACKAGE_FEATURE_NAME.SEATS]: {\n enabled: true,\n options: {\n maxCount: 100\n }\n },\n [PROJECT_PACKAGE_FEATURE_NAME.FILE_MANAGER]: {\n enabled: false,\n options: {\n threatDetection: false\n }\n }\n }\n }\n };\n};\n"],"mappings":"AACA,SAASA,yBAAyB,EAAEC,4BAA4B;AAOhE,OAAO,MAAMC,oBAAoB,GAAIC,OAAwB,IAAiC;EAC1F,OAAO;IACHC,KAAK,EAAE,QAAQ;IACfC,SAAS,EAAE,YAAY;IACvBC,OAAO,EAAE;MACLC,QAAQ,EAAE;QACN,CAACN,4BAA4B,CAACO,IAAI,GAAG;UACjCC,OAAO,EAAE,IAAI;UACbN,OAAO,EAAE;YACLO,KAAK,EAAE,IAAI;YACXC,sBAAsB,EAAER,OAAO,EAAEQ,sBAAsB,IAAI,IAAI;YAC/DC,YAAY,EAAE;UAClB;QACJ,CAAC;QACD,CAACX,4BAA4B,CAACY,EAAE,GAAG;UAC/BJ,OAAO,EAAE,IAAI;UACbN,OAAO,EAAE;YACLW,QAAQ,EAAE;cACNC,IAAI,EAAEf,yBAAyB,CAACgB;YACpC;UACJ;QACJ,CAAC;QACD,CAACf,4BAA4B,CAACgB,GAAG,GAAG;UAChCR,OAAO,EAAE;QACb,CAAC;QACD,CAACR,4BAA4B,CAACiB,UAAU,GAAG;UACvCT,OAAO,EAAE;QACb,CAAC;QACD,CAACR,4BAA4B,CAACkB,cAAc,GAAG;UAC3CV,OAAO,EAAEN,OAAO,EAAEiB,aAAa,IAAI;QACvC,CAAC;QACD,CAACnB,4BAA4B,CAACoB,KAAK,GAAG;UAClCZ,OAAO,EAAE,IAAI;UACbN,OAAO,EAAE;YACLW,QAAQ,EAAE;UACd;QACJ,CAAC;QACD,CAACb,4BAA4B,CAACqB,YAAY,GAAG;UACzCb,OAAO,EAAE,KAAK;UACdN,OAAO,EAAE;YACLoB,eAAe,EAAE;UACrB;QACJ;MACJ;IACJ;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
package/types.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { WCP_FEATURE_LABEL } from "./index";
|
|
1
|
+
import type { WCP_FEATURE_LABEL } from "./index.js";
|
|
2
2
|
export interface WcpProject {
|
|
3
3
|
orgId: string;
|
|
4
4
|
projectId: string;
|
|
5
|
+
package: {
|
|
6
|
+
features: ProjectPackageFeatures;
|
|
7
|
+
};
|
|
5
8
|
}
|
|
6
9
|
export interface ILicense {
|
|
7
10
|
getRawLicense: () => DecryptedWcpProjectLicense | null;
|
|
8
11
|
getProject(): WcpProject | null;
|
|
12
|
+
toDto(): DecryptedWcpProjectLicense | null;
|
|
9
13
|
canUseFeature: (featureId: keyof typeof WCP_FEATURE_LABEL) => boolean;
|
|
10
14
|
canUseAacl: () => boolean;
|
|
11
15
|
canUseTeams: () => boolean;
|
|
@@ -14,6 +18,7 @@ export interface ILicense {
|
|
|
14
18
|
canUseFileManagerThreatDetection: () => boolean;
|
|
15
19
|
canUseFolderLevelPermissions: () => boolean;
|
|
16
20
|
canUseRecordLocking: () => boolean;
|
|
21
|
+
canUseWorkflows: () => boolean;
|
|
17
22
|
}
|
|
18
23
|
export declare type WcpProjectEnvironment = {
|
|
19
24
|
id: string;
|
package/types.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.PROJECT_PACKAGE_FEATURE_NAME = exports.MT_OPTIONS_MAX_COUNT_TYPE = void 0;
|
|
7
|
-
let PROJECT_PACKAGE_FEATURE_NAME = exports.PROJECT_PACKAGE_FEATURE_NAME = /*#__PURE__*/function (PROJECT_PACKAGE_FEATURE_NAME) {
|
|
1
|
+
export let PROJECT_PACKAGE_FEATURE_NAME = /*#__PURE__*/function (PROJECT_PACKAGE_FEATURE_NAME) {
|
|
8
2
|
PROJECT_PACKAGE_FEATURE_NAME["SEATS"] = "seats";
|
|
9
3
|
PROJECT_PACKAGE_FEATURE_NAME["MT"] = "multiTenancy";
|
|
10
4
|
PROJECT_PACKAGE_FEATURE_NAME["APW"] = "advancedPublishingWorkflow";
|
|
11
5
|
PROJECT_PACKAGE_FEATURE_NAME["AACL"] = "advancedAccessControlLayer";
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `AUDIT_LOGS` instead.
|
|
8
|
+
*/
|
|
12
9
|
PROJECT_PACKAGE_FEATURE_NAME["AL"] = "auditLogs";
|
|
10
|
+
/**
|
|
11
|
+
* TODO: remove eslint disable when removing AL enum value.
|
|
12
|
+
*/
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
13
14
|
PROJECT_PACKAGE_FEATURE_NAME["AUDIT_LOGS"] = "auditLogs";
|
|
14
15
|
PROJECT_PACKAGE_FEATURE_NAME["RECORD_LOCKING"] = "recordLocking";
|
|
15
16
|
PROJECT_PACKAGE_FEATURE_NAME["FILE_MANAGER"] = "fileManager";
|
|
16
17
|
return PROJECT_PACKAGE_FEATURE_NAME;
|
|
17
18
|
}({});
|
|
18
|
-
let MT_OPTIONS_MAX_COUNT_TYPE =
|
|
19
|
+
export let MT_OPTIONS_MAX_COUNT_TYPE = /*#__PURE__*/function (MT_OPTIONS_MAX_COUNT_TYPE) {
|
|
19
20
|
MT_OPTIONS_MAX_COUNT_TYPE["SEAT_BASED"] = "seatBased";
|
|
20
21
|
MT_OPTIONS_MAX_COUNT_TYPE["FIXED"] = "fixed";
|
|
21
22
|
return MT_OPTIONS_MAX_COUNT_TYPE;
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PROJECT_PACKAGE_FEATURE_NAME","
|
|
1
|
+
{"version":3,"names":["PROJECT_PACKAGE_FEATURE_NAME","MT_OPTIONS_MAX_COUNT_TYPE"],"sources":["types.ts"],"sourcesContent":["import type { WCP_FEATURE_LABEL } from \"./index.js\";\n\nexport interface WcpProject {\n orgId: string;\n projectId: string;\n package: {\n features: ProjectPackageFeatures;\n };\n}\n\nexport interface ILicense {\n // TODO: identify all places where raw license data is being used and refactor.\n getRawLicense: () => DecryptedWcpProjectLicense | null;\n getProject(): WcpProject | null;\n toDto(): DecryptedWcpProjectLicense | null;\n canUseFeature: (featureId: keyof typeof WCP_FEATURE_LABEL) => boolean;\n canUseAacl: () => boolean;\n canUseTeams: () => boolean;\n canUseAuditLogs: () => boolean;\n canUsePrivateFiles: () => boolean;\n canUseFileManagerThreatDetection: () => boolean;\n canUseFolderLevelPermissions: () => boolean;\n canUseRecordLocking: () => boolean;\n canUseWorkflows: () => boolean;\n}\n\nexport declare type WcpProjectEnvironment = {\n id: string;\n apiKey: string;\n org: {\n id: string;\n };\n project: {\n id: string;\n };\n};\n\nexport declare type EncryptedWcpProjectLicense = string;\n\nexport enum PROJECT_PACKAGE_FEATURE_NAME {\n SEATS = \"seats\",\n MT = \"multiTenancy\",\n APW = \"advancedPublishingWorkflow\",\n AACL = \"advancedAccessControlLayer\",\n /**\n * @deprecated Use `AUDIT_LOGS` instead.\n */\n AL = \"auditLogs\",\n /**\n * TODO: remove eslint disable when removing AL enum value.\n */\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n AUDIT_LOGS = \"auditLogs\",\n RECORD_LOCKING = \"recordLocking\",\n FILE_MANAGER = \"fileManager\"\n}\n\nexport enum MT_OPTIONS_MAX_COUNT_TYPE {\n SEAT_BASED = \"seatBased\",\n FIXED = \"fixed\"\n}\n\nexport interface ProjectPackageFeatures {\n [PROJECT_PACKAGE_FEATURE_NAME.SEATS]: {\n // This is always true because WCP projects immediately get access to seats (by default 1 seat).\n enabled: true;\n options: {\n maxCount: number;\n };\n };\n [PROJECT_PACKAGE_FEATURE_NAME.MT]: {\n // This is always true because WCP projects immediately get access to multi-tenancy.\n enabled: true;\n options: {\n maxCount: {\n type: MT_OPTIONS_MAX_COUNT_TYPE;\n count?: number;\n };\n };\n };\n [PROJECT_PACKAGE_FEATURE_NAME.APW]: {\n enabled: boolean;\n };\n [PROJECT_PACKAGE_FEATURE_NAME.AUDIT_LOGS]: {\n enabled: boolean;\n };\n [PROJECT_PACKAGE_FEATURE_NAME.RECORD_LOCKING]: {\n enabled: boolean;\n };\n [PROJECT_PACKAGE_FEATURE_NAME.AACL]: {\n enabled: boolean;\n options: { teams: boolean; privateFiles: boolean; folderLevelPermissions: boolean };\n };\n [PROJECT_PACKAGE_FEATURE_NAME.AL]: {\n enabled: boolean;\n };\n [PROJECT_PACKAGE_FEATURE_NAME.FILE_MANAGER]: {\n enabled: boolean;\n options: { threatDetection: boolean };\n };\n}\n\nexport interface DecryptedWcpProjectLicense {\n orgId: string;\n projectId: string;\n package: {\n features: ProjectPackageFeatures;\n };\n}\n"],"mappings":"AAuCA,WAAYA,4BAA4B,0BAA5BA,4BAA4B;EAA5BA,4BAA4B;EAA5BA,4BAA4B;EAA5BA,4BAA4B;EAA5BA,4BAA4B;EAKpC;AACJ;AACA;EAPYA,4BAA4B;EASpC;AACJ;AACA;EACI;EAZQA,4BAA4B;EAA5BA,4BAA4B;EAA5BA,4BAA4B;EAAA,OAA5BA,4BAA4B;AAAA;AAkBxC,WAAYC,yBAAyB,0BAAzBA,yBAAyB;EAAzBA,yBAAyB;EAAzBA,yBAAyB;EAAA,OAAzBA,yBAAyB;AAAA","ignoreList":[]}
|
package/urls.js
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getWcpGqlApiUrl = exports.getWcpAppUrl = exports.getWcpApiUrl = void 0;
|
|
7
1
|
const DEFAULT_WCP_API_URL = "https://api.webiny.com";
|
|
8
2
|
const DEFAULT_WCP_APP_URL = "https://app.webiny.com";
|
|
9
|
-
const getWcpApiUrl = path => {
|
|
3
|
+
export const getWcpApiUrl = path => {
|
|
10
4
|
const apiUrl = process.env.WCP_API_URL || DEFAULT_WCP_API_URL;
|
|
11
5
|
return path ? apiUrl + path : apiUrl;
|
|
12
6
|
};
|
|
13
|
-
|
|
14
|
-
const getWcpGqlApiUrl = path => {
|
|
7
|
+
export const getWcpGqlApiUrl = path => {
|
|
15
8
|
const graphqlApi = getWcpApiUrl("/graphql");
|
|
16
9
|
return path ? graphqlApi + path : graphqlApi;
|
|
17
10
|
};
|
|
18
|
-
|
|
19
|
-
const getWcpAppUrl = path => {
|
|
11
|
+
export const getWcpAppUrl = path => {
|
|
20
12
|
const appUrl = process.env.WCP_APP_URL || DEFAULT_WCP_APP_URL;
|
|
21
13
|
return path ? appUrl + path : appUrl;
|
|
22
14
|
};
|
|
23
|
-
exports.getWcpAppUrl = getWcpAppUrl;
|
|
24
15
|
|
|
25
16
|
//# sourceMappingURL=urls.js.map
|
package/urls.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_WCP_API_URL","DEFAULT_WCP_APP_URL","getWcpApiUrl","path","apiUrl","process","env","WCP_API_URL","
|
|
1
|
+
{"version":3,"names":["DEFAULT_WCP_API_URL","DEFAULT_WCP_APP_URL","getWcpApiUrl","path","apiUrl","process","env","WCP_API_URL","getWcpGqlApiUrl","graphqlApi","getWcpAppUrl","appUrl","WCP_APP_URL"],"sources":["urls.ts"],"sourcesContent":["const DEFAULT_WCP_API_URL = \"https://api.webiny.com\";\nconst DEFAULT_WCP_APP_URL = \"https://app.webiny.com\";\n\nexport const getWcpApiUrl = (path?: string) => {\n const apiUrl = process.env.WCP_API_URL || DEFAULT_WCP_API_URL;\n return path ? apiUrl + path : apiUrl;\n};\n\nexport const getWcpGqlApiUrl = (path?: string) => {\n const graphqlApi = getWcpApiUrl(\"/graphql\");\n return path ? graphqlApi + path : graphqlApi;\n};\n\nexport const getWcpAppUrl = (path?: string) => {\n const appUrl = process.env.WCP_APP_URL || DEFAULT_WCP_APP_URL;\n return path ? appUrl + path : appUrl;\n};\n"],"mappings":"AAAA,MAAMA,mBAAmB,GAAG,wBAAwB;AACpD,MAAMC,mBAAmB,GAAG,wBAAwB;AAEpD,OAAO,MAAMC,YAAY,GAAIC,IAAa,IAAK;EAC3C,MAAMC,MAAM,GAAGC,OAAO,CAACC,GAAG,CAACC,WAAW,IAAIP,mBAAmB;EAC7D,OAAOG,IAAI,GAAGC,MAAM,GAAGD,IAAI,GAAGC,MAAM;AACxC,CAAC;AAED,OAAO,MAAMI,eAAe,GAAIL,IAAa,IAAK;EAC9C,MAAMM,UAAU,GAAGP,YAAY,CAAC,UAAU,CAAC;EAC3C,OAAOC,IAAI,GAAGM,UAAU,GAAGN,IAAI,GAAGM,UAAU;AAChD,CAAC;AAED,OAAO,MAAMC,YAAY,GAAIP,IAAa,IAAK;EAC3C,MAAMQ,MAAM,GAAGN,OAAO,CAACC,GAAG,CAACM,WAAW,IAAIX,mBAAmB;EAC7D,OAAOE,IAAI,GAAGQ,MAAM,GAAGR,IAAI,GAAGQ,MAAM;AACxC,CAAC","ignoreList":[]}
|