@schemavaults/app-definitions 0.6.19 → 0.6.20
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/hardcoded-app-to-api-permissions.d.ts +6 -0
- package/dist/hardcoded-app-to-api-permissions.js +38 -0
- package/dist/hardcoded-app-to-api-permissions.js.map +1 -0
- package/dist/index.cjs +42 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HardcodedAppId } from "./hardcoded-core-schemavaults-apps";
|
|
2
|
+
import type { HardcodedApiServerId } from "./hardcoded-core-schemavaults-api-servers";
|
|
3
|
+
/** Check if a hardcoded app has permission to access a specific API server */
|
|
4
|
+
export declare function hasHardcodedAppToApiPermission(client_app_id: HardcodedAppId, api_server_id: HardcodedApiServerId): boolean;
|
|
5
|
+
/** Get all hardcoded API server IDs that a hardcoded app has permission to access */
|
|
6
|
+
export declare function getHardcodedApiServerIdsForHardcodedApp(client_app_id: HardcodedAppId): HardcodedApiServerId[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SCHEMAVAULTS_AUTH_APP_DEFINITION, SCHEMAVAULTS_WEB, } from "./hardcoded-core-schemavaults-apps";
|
|
2
|
+
import { SCHEMAVAULTS_CLI } from "./hardcoded-core-schemavaults-apps";
|
|
3
|
+
import { SCHEMAVAULTS_MAIL_APP_DEFINITION } from "./hardcoded-core-schemavaults-apps";
|
|
4
|
+
import { SCHEMAVAULTS_REGISTRY_SERVER, SCHEMAVAULTS_MAIL_SERVER, isHardcodedApiServerId, } from "./hardcoded-core-schemavaults-api-servers";
|
|
5
|
+
import { isHardcodedAppId } from "./hardcoded-core-schemavaults-apps";
|
|
6
|
+
// Map of hardcoded app IDs to their permitted hardcoded API server IDs
|
|
7
|
+
const HARDCODED_APP_TO_API_PERMISSIONS = {
|
|
8
|
+
[SCHEMAVAULTS_WEB.app_id]: [
|
|
9
|
+
SCHEMAVAULTS_REGISTRY_SERVER.api_server_id,
|
|
10
|
+
SCHEMAVAULTS_MAIL_SERVER.api_server_id,
|
|
11
|
+
],
|
|
12
|
+
[SCHEMAVAULTS_CLI.app_id]: [
|
|
13
|
+
SCHEMAVAULTS_REGISTRY_SERVER.api_server_id,
|
|
14
|
+
SCHEMAVAULTS_MAIL_SERVER.api_server_id,
|
|
15
|
+
],
|
|
16
|
+
[SCHEMAVAULTS_MAIL_APP_DEFINITION.app_id]: [
|
|
17
|
+
SCHEMAVAULTS_MAIL_SERVER.api_server_id,
|
|
18
|
+
],
|
|
19
|
+
[SCHEMAVAULTS_AUTH_APP_DEFINITION.app_id]: [],
|
|
20
|
+
};
|
|
21
|
+
/** Check if a hardcoded app has permission to access a specific API server */
|
|
22
|
+
export function hasHardcodedAppToApiPermission(client_app_id, api_server_id) {
|
|
23
|
+
if (!isHardcodedAppId(client_app_id)) {
|
|
24
|
+
throw new TypeError("hasHardcodedAppToApiPermission received non-hardcoded client app ID!");
|
|
25
|
+
}
|
|
26
|
+
else if (!isHardcodedApiServerId(api_server_id)) {
|
|
27
|
+
throw new TypeError("hasHardcodedAppToApiPermission received non-hardcoded API server ID!");
|
|
28
|
+
}
|
|
29
|
+
return (HARDCODED_APP_TO_API_PERMISSIONS[client_app_id].includes(api_server_id) ?? false);
|
|
30
|
+
}
|
|
31
|
+
/** Get all hardcoded API server IDs that a hardcoded app has permission to access */
|
|
32
|
+
export function getHardcodedApiServerIdsForHardcodedApp(client_app_id) {
|
|
33
|
+
if (!isHardcodedAppId(client_app_id)) {
|
|
34
|
+
throw new TypeError("hasHardcodedAppToApiPermission received non-hardcoded client app ID!");
|
|
35
|
+
}
|
|
36
|
+
return HARDCODED_APP_TO_API_PERMISSIONS[client_app_id] ?? [];
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=hardcoded-app-to-api-permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hardcoded-app-to-api-permissions.js","sourceRoot":"","sources":["../src/hardcoded-app-to-api-permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gCAAgC,EAChC,gBAAgB,GACjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,uEAAuE;AACvE,MAAM,gCAAgC,GAGlC;IACF,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE;QACzB,4BAA4B,CAAC,aAAa;QAC1C,wBAAwB,CAAC,aAAa;KACvC;IACD,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE;QACzB,4BAA4B,CAAC,aAAa;QAC1C,wBAAwB,CAAC,aAAa;KACvC;IACD,CAAC,gCAAgC,CAAC,MAAM,CAAC,EAAE;QACzC,wBAAwB,CAAC,aAAa;KACvC;IACD,CAAC,gCAAgC,CAAC,MAAM,CAAC,EAAE,EAAE;CAC9C,CAAC;AAEF,8EAA8E;AAC9E,MAAM,UAAU,8BAA8B,CAC5C,aAA6B,EAC7B,aAAmC;IAEnC,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,SAAS,CACjB,sEAAsE,CACvE,CAAC;IACJ,CAAC;SAAM,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,SAAS,CACjB,sEAAsE,CACvE,CAAC;IACJ,CAAC;IAED,OAAO,CACL,gCAAgC,CAAC,aAAa,CAAC,CAAC,QAAQ,CACtD,aAAqC,CACtC,IAAI,KAAK,CACX,CAAC;AACJ,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,uCAAuC,CACrD,aAA6B;IAE7B,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,SAAS,CACjB,sEAAsE,CACvE,CAAC;IACJ,CAAC;IAED,OAAO,gCAAgC,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;AAC/D,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -69,10 +69,12 @@ __export(src_exports, {
|
|
|
69
69
|
getAuthServerUri: () => getAuthServerUri,
|
|
70
70
|
getHardcodedApiServer: () => getHardcodedApiServer,
|
|
71
71
|
getHardcodedApiServerDomain: () => getHardcodedApiServerDomain,
|
|
72
|
+
getHardcodedApiServerIdsForHardcodedApp: () => getHardcodedApiServerIdsForHardcodedApp,
|
|
72
73
|
getHardcodedApp: () => getHardcodedApp,
|
|
73
74
|
getHardcodedClientWebAppDomain: () => getHardcodedClientWebAppDomain,
|
|
74
75
|
hardcodedApiServerIdSchema: () => hardcodedApiServerIdSchema,
|
|
75
76
|
hardcodedAppIdSchema: () => hardcodedAppIdSchema,
|
|
77
|
+
hasHardcodedAppToApiPermission: () => hasHardcodedAppToApiPermission,
|
|
76
78
|
isHardcodedApiServerId: () => isHardcodedApiServerId,
|
|
77
79
|
isHardcodedAppId: () => isHardcodedAppId,
|
|
78
80
|
listApiServersQueryTypeSchema: () => listApiServersQueryTypeSchema,
|
|
@@ -4867,6 +4869,44 @@ function getAuthServerUri(environment = getAppEnvironment()) {
|
|
|
4867
4869
|
|
|
4868
4870
|
// src/SCHEMAVAULTS_AUTH_APP_ID.ts
|
|
4869
4871
|
var SCHEMAVAULTS_AUTH_APP_ID = SCHEMAVAULTS_AUTH_APP_DEFINITION.app_id;
|
|
4872
|
+
|
|
4873
|
+
// src/hardcoded-app-to-api-permissions.ts
|
|
4874
|
+
var HARDCODED_APP_TO_API_PERMISSIONS = {
|
|
4875
|
+
[SCHEMAVAULTS_WEB.app_id]: [
|
|
4876
|
+
SCHEMAVAULTS_REGISTRY_SERVER.api_server_id,
|
|
4877
|
+
SCHEMAVAULTS_MAIL_SERVER.api_server_id
|
|
4878
|
+
],
|
|
4879
|
+
[SCHEMAVAULTS_CLI.app_id]: [
|
|
4880
|
+
SCHEMAVAULTS_REGISTRY_SERVER.api_server_id,
|
|
4881
|
+
SCHEMAVAULTS_MAIL_SERVER.api_server_id
|
|
4882
|
+
],
|
|
4883
|
+
[SCHEMAVAULTS_MAIL_APP_DEFINITION.app_id]: [
|
|
4884
|
+
SCHEMAVAULTS_MAIL_SERVER.api_server_id
|
|
4885
|
+
],
|
|
4886
|
+
[SCHEMAVAULTS_AUTH_APP_DEFINITION.app_id]: []
|
|
4887
|
+
};
|
|
4888
|
+
function hasHardcodedAppToApiPermission(client_app_id, api_server_id) {
|
|
4889
|
+
if (!isHardcodedAppId(client_app_id)) {
|
|
4890
|
+
throw new TypeError(
|
|
4891
|
+
"hasHardcodedAppToApiPermission received non-hardcoded client app ID!"
|
|
4892
|
+
);
|
|
4893
|
+
} else if (!isHardcodedApiServerId(api_server_id)) {
|
|
4894
|
+
throw new TypeError(
|
|
4895
|
+
"hasHardcodedAppToApiPermission received non-hardcoded API server ID!"
|
|
4896
|
+
);
|
|
4897
|
+
}
|
|
4898
|
+
return HARDCODED_APP_TO_API_PERMISSIONS[client_app_id].includes(
|
|
4899
|
+
api_server_id
|
|
4900
|
+
) ?? false;
|
|
4901
|
+
}
|
|
4902
|
+
function getHardcodedApiServerIdsForHardcodedApp(client_app_id) {
|
|
4903
|
+
if (!isHardcodedAppId(client_app_id)) {
|
|
4904
|
+
throw new TypeError(
|
|
4905
|
+
"hasHardcodedAppToApiPermission received non-hardcoded client app ID!"
|
|
4906
|
+
);
|
|
4907
|
+
}
|
|
4908
|
+
return HARDCODED_APP_TO_API_PERMISSIONS[client_app_id] ?? [];
|
|
4909
|
+
}
|
|
4870
4910
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4871
4911
|
0 && (module.exports = {
|
|
4872
4912
|
HARDCODED_CORE_SCHEMAVAULTS_API_SERVERS,
|
|
@@ -4918,10 +4958,12 @@ var SCHEMAVAULTS_AUTH_APP_ID = SCHEMAVAULTS_AUTH_APP_DEFINITION.app_id;
|
|
|
4918
4958
|
getAuthServerUri,
|
|
4919
4959
|
getHardcodedApiServer,
|
|
4920
4960
|
getHardcodedApiServerDomain,
|
|
4961
|
+
getHardcodedApiServerIdsForHardcodedApp,
|
|
4921
4962
|
getHardcodedApp,
|
|
4922
4963
|
getHardcodedClientWebAppDomain,
|
|
4923
4964
|
hardcodedApiServerIdSchema,
|
|
4924
4965
|
hardcodedAppIdSchema,
|
|
4966
|
+
hasHardcodedAppToApiPermission,
|
|
4925
4967
|
isHardcodedApiServerId,
|
|
4926
4968
|
isHardcodedAppId,
|
|
4927
4969
|
listApiServersQueryTypeSchema,
|
package/dist/index.d.ts
CHANGED
|
@@ -28,3 +28,4 @@ export type { SchemaVaultsAppEnvironment } from "./app-environments";
|
|
|
28
28
|
export { getAppEnvironment } from "./get-app-environment";
|
|
29
29
|
export { getAuthServerUri } from "./get-auth-server-uri";
|
|
30
30
|
export { SCHEMAVAULTS_AUTH_APP_ID } from "./SCHEMAVAULTS_AUTH_APP_ID";
|
|
31
|
+
export { hasHardcodedAppToApiPermission, getHardcodedApiServerIdsForHardcodedApp, } from "./hardcoded-app-to-api-permissions";
|
package/dist/index.js
CHANGED
|
@@ -16,4 +16,5 @@ export { schemaVaultsAppEnvironments, schemaVaultsAppEnvironmentSchema, } from "
|
|
|
16
16
|
export { getAppEnvironment } from "./get-app-environment";
|
|
17
17
|
export { getAuthServerUri } from "./get-auth-server-uri";
|
|
18
18
|
export { SCHEMAVAULTS_AUTH_APP_ID } from "./SCHEMAVAULTS_AUTH_APP_ID";
|
|
19
|
+
export { hasHardcodedAppToApiPermission, getHardcodedApiServerIdsForHardcodedApp, } from "./hardcoded-app-to-api-permissions";
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAGzB,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,GAC/B,MAAM,yBAAyB,CAAC;AAGjC,cAAc,mCAAmC,CAAC;AAGlD,cAAc,iBAAiB,CAAC;AAGhC,OAAO,EACL,qCAAqC,EACrC,oCAAoC,GACrC,MAAM,yBAAyB,CAAC;AAGjC,cAAc,0CAA0C,CAAC;AAGzD,cAAc,6BAA6B,CAAC;AAG5C,cAAc,oCAAoC,CAAC;AAEnD,cAAc,2CAA2C,CAAC;AAE1D,OAAO,EAAE,8BAA8B,EAAE,MAAM,uCAAuC,CAAC;AAEvF,cAAc,2CAA2C,CAAC;AAE1D,cAAc,kDAAkD,CAAC;AAEjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAEhF,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EACL,2BAA2B,EAC3B,gCAAgC,GACjC,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAGzB,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,GAC/B,MAAM,yBAAyB,CAAC;AAGjC,cAAc,mCAAmC,CAAC;AAGlD,cAAc,iBAAiB,CAAC;AAGhC,OAAO,EACL,qCAAqC,EACrC,oCAAoC,GACrC,MAAM,yBAAyB,CAAC;AAGjC,cAAc,0CAA0C,CAAC;AAGzD,cAAc,6BAA6B,CAAC;AAG5C,cAAc,oCAAoC,CAAC;AAEnD,cAAc,2CAA2C,CAAC;AAE1D,OAAO,EAAE,8BAA8B,EAAE,MAAM,uCAAuC,CAAC;AAEvF,cAAc,2CAA2C,CAAC;AAE1D,cAAc,kDAAkD,CAAC;AAEjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAEhF,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EACL,2BAA2B,EAC3B,gCAAgC,GACjC,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,EACL,8BAA8B,EAC9B,uCAAuC,GACxC,MAAM,oCAAoC,CAAC"}
|