@prosopo/user-access-policy 3.5.32 → 3.7.11
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/.turbo/turbo-build$colon$cjs.log +23 -21
- package/.turbo/turbo-build$colon$tsc.log +41 -0
- package/.turbo/turbo-build.log +28 -22
- package/CHANGELOG.md +393 -0
- package/dist/.export.d.ts +6 -0
- package/dist/.export.d.ts.map +1 -0
- package/dist/.export.js.map +1 -0
- package/dist/api/.export.d.ts +7 -0
- package/dist/api/.export.d.ts.map +1 -0
- package/dist/api/.export.js.map +1 -0
- package/dist/api/accessRulesApiClient.d.ts +2 -0
- package/dist/api/accessRulesApiClient.d.ts.map +1 -0
- package/dist/api/accessRulesApiClient.js +2 -0
- package/dist/api/accessRulesApiClient.js.map +1 -0
- package/dist/api/delete/.export.d.ts +2 -0
- package/dist/api/delete/.export.d.ts.map +1 -0
- package/dist/api/delete/.export.js.map +1 -0
- package/dist/api/delete/deleteAllRules.d.ts +11 -0
- package/dist/api/delete/deleteAllRules.d.ts.map +1 -0
- package/dist/api/delete/deleteAllRules.js +3 -2
- package/dist/api/delete/deleteAllRules.js.map +1 -0
- package/dist/api/delete/deleteRuleGroups.d.ts +19 -0
- package/dist/api/delete/deleteRuleGroups.d.ts.map +1 -0
- package/dist/api/delete/deleteRuleGroups.js +3 -2
- package/dist/api/delete/deleteRuleGroups.js.map +1 -0
- package/dist/api/delete/deleteRules.d.ts +15 -0
- package/dist/api/delete/deleteRules.d.ts.map +1 -0
- package/dist/api/delete/deleteRules.js +3 -2
- package/dist/api/delete/deleteRules.js.map +1 -0
- package/dist/api/read/.export.d.ts +4 -0
- package/dist/api/read/.export.d.ts.map +1 -0
- package/dist/api/read/.export.js.map +1 -0
- package/dist/api/read/fetchRules.d.ts +53 -0
- package/dist/api/read/fetchRules.d.ts.map +1 -0
- package/dist/api/read/fetchRules.js +4 -3
- package/dist/api/read/fetchRules.js.map +1 -0
- package/dist/api/read/findRuleIds.d.ts +28 -0
- package/dist/api/read/findRuleIds.d.ts.map +1 -0
- package/dist/api/read/findRuleIds.js +3 -2
- package/dist/api/read/findRuleIds.js.map +1 -0
- package/dist/api/read/getMissingIds.d.ts +28 -0
- package/dist/api/read/getMissingIds.d.ts.map +1 -0
- package/dist/api/read/getMissingIds.js +4 -3
- package/dist/api/read/getMissingIds.js.map +1 -0
- package/dist/api/ruleApiRoutes.d.ts +43 -0
- package/dist/api/ruleApiRoutes.d.ts.map +1 -0
- package/dist/api/ruleApiRoutes.js.map +1 -0
- package/dist/api/rulesApiClient.d.ts +20 -0
- package/dist/api/rulesApiClient.d.ts.map +1 -0
- package/dist/api/rulesApiClient.js +18 -19
- package/dist/api/rulesApiClient.js.map +1 -0
- package/dist/api/write/.export.d.ts +2 -0
- package/dist/api/write/.export.d.ts.map +1 -0
- package/dist/api/write/.export.js.map +1 -0
- package/dist/api/write/insertRules.d.ts +29 -0
- package/dist/api/write/insertRules.d.ts.map +1 -0
- package/dist/api/write/insertRules.js +12 -9
- package/dist/api/write/insertRules.js.map +1 -0
- package/dist/api/write/rehashRules.d.ts +11 -0
- package/dist/api/write/rehashRules.d.ts.map +1 -0
- package/dist/api/write/rehashRules.js +7 -6
- package/dist/api/write/rehashRules.js.map +1 -0
- package/dist/cjs/api/delete/deleteAllRules.cjs +3 -2
- package/dist/cjs/api/delete/deleteRuleGroups.cjs +3 -2
- package/dist/cjs/api/delete/deleteRules.cjs +3 -2
- package/dist/cjs/api/read/fetchRules.cjs +4 -3
- package/dist/cjs/api/read/findRuleIds.cjs +3 -2
- package/dist/cjs/api/read/getMissingIds.cjs +4 -3
- package/dist/cjs/api/rulesApiClient.cjs +18 -19
- package/dist/cjs/api/write/insertRules.cjs +13 -10
- package/dist/cjs/api/write/rehashRules.cjs +7 -6
- package/dist/cjs/mongoose/mongooseRuleSchema.cjs +4 -1
- package/dist/cjs/redis/reader/redisRulesQuery.cjs +18 -1
- package/dist/cjs/redis/reader/redisRulesReader.cjs +13 -4
- package/dist/cjs/redis/redisRuleIndex.cjs +5 -1
- package/dist/cjs/redis/redisRulesWriter.cjs +6 -0
- package/dist/cjs/ruleInput/policyInput.cjs +8 -0
- package/dist/cjs/ruleInput/userScopeInput.cjs +4 -1
- package/dist/cjs/ruleRecord.cjs +4 -1
- package/dist/mongoose/.export.d.ts +2 -0
- package/dist/mongoose/.export.d.ts.map +1 -0
- package/dist/mongoose/.export.js.map +1 -0
- package/dist/mongoose/mongooseRuleSchema.d.ts +4 -0
- package/dist/mongoose/mongooseRuleSchema.d.ts.map +1 -0
- package/dist/mongoose/mongooseRuleSchema.js +4 -1
- package/dist/mongoose/mongooseRuleSchema.js.map +1 -0
- package/dist/redis/.export.d.ts +3 -0
- package/dist/redis/.export.d.ts.map +1 -0
- package/dist/redis/.export.js.map +1 -0
- package/dist/redis/reader/redisAggregate.d.ts +4 -0
- package/dist/redis/reader/redisAggregate.d.ts.map +1 -0
- package/dist/redis/reader/redisAggregate.js.map +1 -0
- package/dist/redis/reader/redisRulesQuery.d.ts +4 -0
- package/dist/redis/reader/redisRulesQuery.d.ts.map +1 -0
- package/dist/redis/reader/redisRulesQuery.js +18 -1
- package/dist/redis/reader/redisRulesQuery.js.map +1 -0
- package/dist/redis/reader/redisRulesReader.d.ts +26 -0
- package/dist/redis/reader/redisRulesReader.d.ts.map +1 -0
- package/dist/redis/reader/redisRulesReader.js +14 -5
- package/dist/redis/reader/redisRulesReader.js.map +1 -0
- package/dist/redis/redisClient.d.ts +11 -0
- package/dist/redis/redisClient.d.ts.map +1 -0
- package/dist/redis/redisClient.js.map +1 -0
- package/dist/redis/redisRuleIndex.d.ts +13 -0
- package/dist/redis/redisRuleIndex.d.ts.map +1 -0
- package/dist/redis/redisRuleIndex.js +5 -1
- package/dist/redis/redisRuleIndex.js.map +1 -0
- package/dist/redis/redisRulesStorage.d.ts +5 -0
- package/dist/redis/redisRulesStorage.d.ts.map +1 -0
- package/dist/redis/redisRulesStorage.js.map +1 -0
- package/dist/redis/redisRulesWriter.d.ts +22 -0
- package/dist/redis/redisRulesWriter.d.ts.map +1 -0
- package/dist/redis/redisRulesWriter.js +6 -0
- package/dist/redis/redisRulesWriter.js.map +1 -0
- package/dist/rule.d.ts +37 -0
- package/dist/rule.d.ts.map +1 -0
- package/dist/rule.js.map +1 -0
- package/dist/ruleInput/.export.d.ts +4 -0
- package/dist/ruleInput/.export.d.ts.map +1 -0
- package/dist/ruleInput/.export.js.map +1 -0
- package/dist/ruleInput/policyInput.d.ts +39 -0
- package/dist/ruleInput/policyInput.d.ts.map +1 -0
- package/dist/ruleInput/policyInput.js +9 -1
- package/dist/ruleInput/policyInput.js.map +1 -0
- package/dist/ruleInput/ruleInput.d.ts +163 -0
- package/dist/ruleInput/ruleInput.d.ts.map +1 -0
- package/dist/ruleInput/ruleInput.js.map +1 -0
- package/dist/ruleInput/userScopeInput.d.ts +117 -0
- package/dist/ruleInput/userScopeInput.d.ts.map +1 -0
- package/dist/ruleInput/userScopeInput.js +4 -1
- package/dist/ruleInput/userScopeInput.js.map +1 -0
- package/dist/ruleRecord.d.ts +18 -0
- package/dist/ruleRecord.d.ts.map +1 -0
- package/dist/ruleRecord.js +4 -1
- package/dist/ruleRecord.js.map +1 -0
- package/dist/rulesStorage.d.ts +30 -0
- package/dist/rulesStorage.d.ts.map +1 -0
- package/dist/rulesStorage.js.map +1 -0
- package/dist/tests/insertRulesEndpoint.unit.test.d.ts +2 -0
- package/dist/tests/insertRulesEndpoint.unit.test.d.ts.map +1 -0
- package/dist/tests/insertRulesEndpoint.unit.test.js +57 -0
- package/dist/tests/insertRulesEndpoint.unit.test.js.map +1 -0
- package/dist/tests/policyInput.unit.test.d.ts +2 -0
- package/dist/tests/policyInput.unit.test.d.ts.map +1 -0
- package/dist/tests/policyInput.unit.test.js +116 -0
- package/dist/tests/policyInput.unit.test.js.map +1 -0
- package/dist/tests/redis/reader/redisRulesQuery.unit.test.d.ts +2 -0
- package/dist/tests/redis/reader/redisRulesQuery.unit.test.d.ts.map +1 -0
- package/dist/tests/redis/reader/redisRulesQuery.unit.test.js +199 -0
- package/dist/tests/redis/reader/redisRulesQuery.unit.test.js.map +1 -0
- package/dist/tests/redis/redisRulesStorage.integration.test.d.ts +2 -0
- package/dist/tests/redis/redisRulesStorage.integration.test.d.ts.map +1 -0
- package/dist/tests/redis/redisRulesStorage.integration.test.js +831 -0
- package/dist/tests/redis/redisRulesStorage.integration.test.js.map +1 -0
- package/dist/tests/testLogger.d.ts +4 -0
- package/dist/tests/testLogger.d.ts.map +1 -0
- package/dist/tests/testLogger.js +22 -0
- package/dist/tests/testLogger.js.map +1 -0
- package/dist/tests/transformRule.unit.test.d.ts +2 -0
- package/dist/tests/transformRule.unit.test.d.ts.map +1 -0
- package/dist/tests/transformRule.unit.test.js +191 -0
- package/dist/tests/transformRule.unit.test.js.map +1 -0
- package/dist/transformRule.d.ts +7 -0
- package/dist/transformRule.d.ts.map +1 -0
- package/dist/transformRule.js.map +1 -0
- package/entries.ts +1 -1
- package/package.json +18 -12
- package/src/.export.ts +44 -0
- package/src/api/.export.ts +25 -0
- package/src/api/accessRulesApiClient.ts +13 -0
- package/src/api/delete/.export.ts +18 -0
- package/src/api/delete/deleteAllRules.ts +47 -0
- package/src/api/delete/deleteRuleGroups.ts +96 -0
- package/src/api/delete/deleteRules.ts +81 -0
- package/src/api/read/.export.ts +25 -0
- package/src/api/read/fetchRules.ts +88 -0
- package/src/api/read/findRuleIds.ts +95 -0
- package/src/api/read/getMissingIds.ts +81 -0
- package/src/api/ruleApiRoutes.ts +146 -0
- package/src/api/rulesApiClient.ts +154 -0
- package/src/api/write/.export.ts +15 -0
- package/src/api/write/insertRules.ts +183 -0
- package/src/api/write/rehashRules.ts +85 -0
- package/src/mongoose/.export.ts +15 -0
- package/src/mongoose/mongooseRuleSchema.ts +65 -0
- package/src/redis/.export.ts +17 -0
- package/src/redis/reader/redisAggregate.ts +103 -0
- package/src/redis/reader/redisRulesQuery.ts +217 -0
- package/src/redis/reader/redisRulesReader.ts +318 -0
- package/src/redis/redisClient.ts +120 -0
- package/src/redis/redisRuleIndex.ts +85 -0
- package/src/redis/redisRulesStorage.ts +68 -0
- package/src/redis/redisRulesWriter.ts +158 -0
- package/src/rule.ts +59 -0
- package/src/ruleInput/.export.ts +19 -0
- package/src/ruleInput/policyInput.ts +51 -0
- package/src/ruleInput/ruleInput.ts +103 -0
- package/src/ruleInput/userScopeInput.ts +108 -0
- package/src/ruleRecord.ts +69 -0
- package/src/rulesStorage.ts +72 -0
- package/src/tests/insertRulesEndpoint.unit.test.ts +89 -0
- package/src/tests/policyInput.unit.test.ts +150 -0
- package/src/tests/redis/reader/redisRulesQuery.unit.test.ts +284 -0
- package/src/tests/redis/redisRulesStorage.integration.test.ts +1156 -0
- package/src/tests/testLogger.ts +38 -0
- package/src/tests/transformRule.unit.test.ts +255 -0
- package/src/transformRule.ts +128 -0
- package/tsconfig.cjs.json +41 -0
- package/tsconfig.json +47 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsconfig.types.json +9 -0
- package/vite.cjs.config.ts +1 -1
- package/vite.esm.config.ts +1 -1
- package/vite.test.config.ts +1 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
type ApiEndpoint,
|
|
17
|
+
type ApiEndpointResponse,
|
|
18
|
+
ApiEndpointResponseStatus,
|
|
19
|
+
} from "@prosopo/api-route";
|
|
20
|
+
import { executeBatchesSequentially } from "@prosopo/common";
|
|
21
|
+
import type { Logger } from "@prosopo/logger";
|
|
22
|
+
import { type ZodType, z } from "zod";
|
|
23
|
+
import {
|
|
24
|
+
type AccessRulesFilterInput,
|
|
25
|
+
accessRulesFilterInput,
|
|
26
|
+
getAccessRuleFiltersFromInput,
|
|
27
|
+
} from "#policy/ruleInput/ruleInput.js";
|
|
28
|
+
import type { AccessRulesStorage } from "#policy/rulesStorage.js";
|
|
29
|
+
|
|
30
|
+
type DeleteRulesSchema = ZodType<AccessRulesFilterInput[]>;
|
|
31
|
+
|
|
32
|
+
export class DeleteRulesEndpoint implements ApiEndpoint<DeleteRulesSchema> {
|
|
33
|
+
public constructor(
|
|
34
|
+
private readonly accessRulesStorage: AccessRulesStorage,
|
|
35
|
+
private readonly logger: Logger,
|
|
36
|
+
) {}
|
|
37
|
+
|
|
38
|
+
public getRequestArgsSchema(): DeleteRulesSchema {
|
|
39
|
+
return z.array(accessRulesFilterInput);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async processRequest(
|
|
43
|
+
args: AccessRulesFilterInput[],
|
|
44
|
+
logger?: Logger,
|
|
45
|
+
): Promise<ApiEndpointResponse> {
|
|
46
|
+
const log = logger ?? this.logger;
|
|
47
|
+
let deletedCount = 0;
|
|
48
|
+
|
|
49
|
+
for (const rulesFilterInput of args) {
|
|
50
|
+
const ruleFilters = getAccessRuleFiltersFromInput(rulesFilterInput);
|
|
51
|
+
|
|
52
|
+
await executeBatchesSequentially(ruleFilters, async (ruleFilter) => {
|
|
53
|
+
const ruleIds = await this.accessRulesStorage.findRuleIds(ruleFilter);
|
|
54
|
+
|
|
55
|
+
// Set() automatically removes duplicates
|
|
56
|
+
const uniqueRuleIds = [...new Set(ruleIds)];
|
|
57
|
+
|
|
58
|
+
if (uniqueRuleIds.length > 0) {
|
|
59
|
+
await this.accessRulesStorage.deleteRules(uniqueRuleIds);
|
|
60
|
+
|
|
61
|
+
deletedCount += uniqueRuleIds.length;
|
|
62
|
+
|
|
63
|
+
log.info(() => ({
|
|
64
|
+
msg: "Endpoint deleted rules",
|
|
65
|
+
data: {
|
|
66
|
+
rulesFilterInput,
|
|
67
|
+
uniqueRuleIds,
|
|
68
|
+
},
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
status: ApiEndpointResponseStatus.SUCCESS,
|
|
76
|
+
data: {
|
|
77
|
+
deleted_count: deletedCount,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
export type {
|
|
16
|
+
RuleIdsResponse,
|
|
17
|
+
RuleIdsEndpointResponse,
|
|
18
|
+
} from "./findRuleIds.js";
|
|
19
|
+
|
|
20
|
+
export type {
|
|
21
|
+
FetchRulesOptions,
|
|
22
|
+
FetchRulesResponse,
|
|
23
|
+
} from "./fetchRules.js";
|
|
24
|
+
|
|
25
|
+
export type { MissingIds } from "./getMissingIds.js";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
type ApiEndpoint,
|
|
17
|
+
type ApiEndpointResponse,
|
|
18
|
+
ApiEndpointResponseStatus,
|
|
19
|
+
} from "@prosopo/api-route";
|
|
20
|
+
import type { AllKeys } from "@prosopo/common";
|
|
21
|
+
import type { Logger } from "@prosopo/logger";
|
|
22
|
+
import { type ZodType, z } from "zod";
|
|
23
|
+
import { ruleEntryInput } from "#policy/ruleInput/ruleInput.js";
|
|
24
|
+
import type {
|
|
25
|
+
AccessRuleEntry,
|
|
26
|
+
AccessRulesStorage,
|
|
27
|
+
} from "#policy/rulesStorage.js";
|
|
28
|
+
|
|
29
|
+
export type FetchRulesOptions = {
|
|
30
|
+
ids: string[];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type FetchRulesSchema = ZodType<FetchRulesOptions>;
|
|
34
|
+
|
|
35
|
+
export type FetchRulesResponse = {
|
|
36
|
+
ruleEntries: AccessRuleEntry[];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const fetchRulesResponse = z.object({
|
|
40
|
+
ruleEntries: ruleEntryInput.array(),
|
|
41
|
+
} satisfies AllKeys<FetchRulesResponse>) satisfies ZodType<FetchRulesResponse>;
|
|
42
|
+
|
|
43
|
+
export type FetchRulesEndpointResponse = ApiEndpointResponse & {
|
|
44
|
+
data?: FetchRulesResponse;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export class FetchRulesEndpoint implements ApiEndpoint<FetchRulesSchema> {
|
|
48
|
+
public constructor(
|
|
49
|
+
private readonly accessRulesStorage: AccessRulesStorage,
|
|
50
|
+
private readonly logger: Logger,
|
|
51
|
+
) {}
|
|
52
|
+
|
|
53
|
+
public getRequestArgsSchema(): FetchRulesSchema {
|
|
54
|
+
return z.object({
|
|
55
|
+
ids: z.string().array(),
|
|
56
|
+
} satisfies AllKeys<FetchRulesOptions>);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async processRequest(
|
|
60
|
+
args: FetchRulesOptions,
|
|
61
|
+
logger?: Logger,
|
|
62
|
+
): Promise<FetchRulesEndpointResponse> {
|
|
63
|
+
const log = logger ?? this.logger;
|
|
64
|
+
const ruleEntries = await this.accessRulesStorage.fetchRules(args.ids);
|
|
65
|
+
|
|
66
|
+
log.info(() => ({
|
|
67
|
+
msg: "Endpoint fetched rules",
|
|
68
|
+
data: {
|
|
69
|
+
requestedCount: args.ids.length,
|
|
70
|
+
foundCount: ruleEntries.length,
|
|
71
|
+
},
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
log.debug(() => ({
|
|
75
|
+
msg: "Fetched rule details",
|
|
76
|
+
data: {
|
|
77
|
+
ruleEntries: ruleEntries,
|
|
78
|
+
},
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
status: ApiEndpointResponseStatus.SUCCESS,
|
|
83
|
+
data: {
|
|
84
|
+
ruleEntries: ruleEntries,
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
type ApiEndpoint,
|
|
17
|
+
type ApiEndpointResponse,
|
|
18
|
+
ApiEndpointResponseStatus,
|
|
19
|
+
} from "@prosopo/api-route";
|
|
20
|
+
import { type AllKeys, executeBatchesSequentially } from "@prosopo/common";
|
|
21
|
+
import type { Logger } from "@prosopo/logger";
|
|
22
|
+
import { type ZodType, z } from "zod";
|
|
23
|
+
import {
|
|
24
|
+
type AccessRulesFilterInput,
|
|
25
|
+
accessRulesFilterInput,
|
|
26
|
+
getAccessRuleFiltersFromInput,
|
|
27
|
+
} from "#policy/ruleInput/ruleInput.js";
|
|
28
|
+
import type { AccessRulesStorage } from "#policy/rulesStorage.js";
|
|
29
|
+
|
|
30
|
+
type FindRulesSchema = ZodType<AccessRulesFilterInput[]>;
|
|
31
|
+
|
|
32
|
+
export type RuleIdsResponse = {
|
|
33
|
+
ruleIds: string[];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const ruleIdsResponse = z.object({
|
|
37
|
+
ruleIds: z.string().array(),
|
|
38
|
+
} satisfies AllKeys<RuleIdsResponse>) satisfies ZodType<RuleIdsResponse>;
|
|
39
|
+
|
|
40
|
+
export type RuleIdsEndpointResponse = ApiEndpointResponse & {
|
|
41
|
+
data?: RuleIdsResponse;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export class FindRuleIdsEndpoint implements ApiEndpoint<FindRulesSchema> {
|
|
45
|
+
public constructor(
|
|
46
|
+
private readonly accessRulesStorage: AccessRulesStorage,
|
|
47
|
+
private readonly logger: Logger,
|
|
48
|
+
) {}
|
|
49
|
+
|
|
50
|
+
public getRequestArgsSchema(): FindRulesSchema {
|
|
51
|
+
return z.array(accessRulesFilterInput);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async processRequest(
|
|
55
|
+
args: AccessRulesFilterInput[],
|
|
56
|
+
logger?: Logger,
|
|
57
|
+
): Promise<RuleIdsEndpointResponse> {
|
|
58
|
+
const log = logger ?? this.logger;
|
|
59
|
+
const ruleIdBatches = await executeBatchesSequentially(
|
|
60
|
+
args,
|
|
61
|
+
async (rulesFilterInput) => {
|
|
62
|
+
const ruleFilters = getAccessRuleFiltersFromInput(rulesFilterInput);
|
|
63
|
+
|
|
64
|
+
const ruleIds = await executeBatchesSequentially(
|
|
65
|
+
ruleFilters,
|
|
66
|
+
(ruleFilter) => this.accessRulesStorage.findRuleIds(ruleFilter),
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return ruleIds.flat();
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const ruleIds = ruleIdBatches.flat();
|
|
74
|
+
|
|
75
|
+
// Set() automatically removes duplicates
|
|
76
|
+
const uniqueRuleIds = [...new Set(ruleIds)];
|
|
77
|
+
|
|
78
|
+
log.info(() => ({
|
|
79
|
+
msg: "Endpoint found rules",
|
|
80
|
+
data: {
|
|
81
|
+
totalFoundCount: ruleIds.length,
|
|
82
|
+
uniqueFoundCount: uniqueRuleIds.length,
|
|
83
|
+
searchFilters: args,
|
|
84
|
+
foundIds: uniqueRuleIds,
|
|
85
|
+
},
|
|
86
|
+
}));
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
status: ApiEndpointResponseStatus.SUCCESS,
|
|
90
|
+
data: {
|
|
91
|
+
ruleIds: uniqueRuleIds,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
type ApiEndpoint,
|
|
17
|
+
type ApiEndpointResponse,
|
|
18
|
+
ApiEndpointResponseStatus,
|
|
19
|
+
} from "@prosopo/api-route";
|
|
20
|
+
import type { AllKeys } from "@prosopo/common";
|
|
21
|
+
import type { Logger } from "@prosopo/logger";
|
|
22
|
+
import { type ZodType, z } from "zod";
|
|
23
|
+
import type { AccessRulesStorage } from "#policy/rulesStorage.js";
|
|
24
|
+
|
|
25
|
+
export type MissingIds = string[];
|
|
26
|
+
|
|
27
|
+
type MissingIdsSchema = ZodType<MissingIds>;
|
|
28
|
+
|
|
29
|
+
export type MissingIdsResponse = {
|
|
30
|
+
ids: string[];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const missingIdsResponse = z.object({
|
|
34
|
+
ids: z.string().array(),
|
|
35
|
+
} satisfies AllKeys<MissingIdsResponse>) satisfies ZodType<MissingIdsResponse>;
|
|
36
|
+
|
|
37
|
+
export type MissingIdsEndpointResponse = ApiEndpointResponse & {
|
|
38
|
+
data?: MissingIdsResponse;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export class GetMissingIdsEndpoint implements ApiEndpoint<MissingIdsSchema> {
|
|
42
|
+
public constructor(
|
|
43
|
+
private readonly accessRulesStorage: AccessRulesStorage,
|
|
44
|
+
private readonly logger: Logger,
|
|
45
|
+
) {}
|
|
46
|
+
|
|
47
|
+
public getRequestArgsSchema(): MissingIdsSchema {
|
|
48
|
+
return z.string().array();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async processRequest(
|
|
52
|
+
args: MissingIds,
|
|
53
|
+
logger?: Logger,
|
|
54
|
+
): Promise<MissingIdsEndpointResponse> {
|
|
55
|
+
const log = logger ?? this.logger;
|
|
56
|
+
const missingIds = await this.accessRulesStorage.getMissingRuleIds(args);
|
|
57
|
+
|
|
58
|
+
log.info(() => ({
|
|
59
|
+
msg: "Endpoint checked missing ids",
|
|
60
|
+
data: {
|
|
61
|
+
idsToCheck: args.length,
|
|
62
|
+
missingIds: missingIds.length,
|
|
63
|
+
},
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
log.debug(() => ({
|
|
67
|
+
msg: "Missing id details",
|
|
68
|
+
data: {
|
|
69
|
+
idsToCheck: args,
|
|
70
|
+
missingIds: missingIds,
|
|
71
|
+
},
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
status: ApiEndpointResponseStatus.SUCCESS,
|
|
76
|
+
data: {
|
|
77
|
+
ids: missingIds,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
import type {
|
|
16
|
+
ApiRouteLimits,
|
|
17
|
+
ApiRoutes,
|
|
18
|
+
ApiRoutesProvider,
|
|
19
|
+
} from "@prosopo/api-route";
|
|
20
|
+
import type { AllEnumValues } from "@prosopo/common";
|
|
21
|
+
import type { Logger } from "@prosopo/logger";
|
|
22
|
+
import { FetchRulesEndpoint } from "#policy/api/read/fetchRules.js";
|
|
23
|
+
import { FindRuleIdsEndpoint } from "#policy/api/read/findRuleIds.js";
|
|
24
|
+
import { GetMissingIdsEndpoint } from "#policy/api/read/getMissingIds.js";
|
|
25
|
+
import { RehashRulesEndpoint } from "#policy/api/write/rehashRules.js";
|
|
26
|
+
import type { AccessRulesStorage } from "#policy/rulesStorage.js";
|
|
27
|
+
import { DeleteAllRulesEndpoint } from "./delete/deleteAllRules.js";
|
|
28
|
+
import { DeleteRuleGroupsEndpoint } from "./delete/deleteRuleGroups.js";
|
|
29
|
+
import { DeleteRulesEndpoint } from "./delete/deleteRules.js";
|
|
30
|
+
import { InsertRulesEndpoint } from "./write/insertRules.js";
|
|
31
|
+
|
|
32
|
+
export enum accessRuleApiPaths {
|
|
33
|
+
// delete
|
|
34
|
+
DELETE_ALL = "/v1/prosopo/user-access-policy/rules/delete-all",
|
|
35
|
+
DELETE_GROUPS = "/v1/prosopo/user-access-policy/rules/delete-groups",
|
|
36
|
+
DELETE_MANY = "/v1/prosopo/user-access-policy/rules/delete-many",
|
|
37
|
+
// read
|
|
38
|
+
FETCH_MANY = "/v1/prosopo/user-access-policy/rules/fetch-many",
|
|
39
|
+
FIND_IDS = "/v1/prosopo/user-access-policy/rules/find-ids",
|
|
40
|
+
GET_MISSING_IDS = "/v1/prosopo/user-access-policy/rules/get-missing-ids",
|
|
41
|
+
// write
|
|
42
|
+
INSERT_MANY = "/v1/prosopo/user-access-policy/rules/insert-many",
|
|
43
|
+
REHASH_ALL = "/v1/prosopo/user-access-policy/rules/rehash-all",
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class AccessRuleApiRoutes implements ApiRoutesProvider {
|
|
47
|
+
public constructor(
|
|
48
|
+
private readonly accessRulesStorage: AccessRulesStorage,
|
|
49
|
+
private readonly logger: Logger,
|
|
50
|
+
) {}
|
|
51
|
+
|
|
52
|
+
public getRoutes(): ApiRoutes {
|
|
53
|
+
return {
|
|
54
|
+
...this.makeDeleteEndpoints(),
|
|
55
|
+
...this.makeReadEndpoints(),
|
|
56
|
+
...this.makeWriteEndpoints(),
|
|
57
|
+
} satisfies AllEnumValues<accessRuleApiPaths>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
protected makeDeleteEndpoints() {
|
|
61
|
+
return {
|
|
62
|
+
[accessRuleApiPaths.DELETE_ALL]: new DeleteAllRulesEndpoint(
|
|
63
|
+
this.accessRulesStorage,
|
|
64
|
+
this.logger,
|
|
65
|
+
),
|
|
66
|
+
[accessRuleApiPaths.DELETE_GROUPS]: new DeleteRuleGroupsEndpoint(
|
|
67
|
+
this.accessRulesStorage,
|
|
68
|
+
this.logger,
|
|
69
|
+
),
|
|
70
|
+
[accessRuleApiPaths.DELETE_MANY]: new DeleteRulesEndpoint(
|
|
71
|
+
this.accessRulesStorage,
|
|
72
|
+
this.logger,
|
|
73
|
+
),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
protected makeReadEndpoints() {
|
|
78
|
+
return {
|
|
79
|
+
[accessRuleApiPaths.FETCH_MANY]: new FetchRulesEndpoint(
|
|
80
|
+
this.accessRulesStorage,
|
|
81
|
+
this.logger,
|
|
82
|
+
),
|
|
83
|
+
[accessRuleApiPaths.FIND_IDS]: new FindRuleIdsEndpoint(
|
|
84
|
+
this.accessRulesStorage,
|
|
85
|
+
this.logger,
|
|
86
|
+
),
|
|
87
|
+
[accessRuleApiPaths.GET_MISSING_IDS]: new GetMissingIdsEndpoint(
|
|
88
|
+
this.accessRulesStorage,
|
|
89
|
+
this.logger,
|
|
90
|
+
),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
protected makeWriteEndpoints() {
|
|
95
|
+
return {
|
|
96
|
+
[accessRuleApiPaths.INSERT_MANY]: new InsertRulesEndpoint(
|
|
97
|
+
this.accessRulesStorage,
|
|
98
|
+
this.logger,
|
|
99
|
+
),
|
|
100
|
+
[accessRuleApiPaths.REHASH_ALL]: new RehashRulesEndpoint(
|
|
101
|
+
this.accessRulesStorage,
|
|
102
|
+
this.logger,
|
|
103
|
+
),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const getExpressApiRuleRateLimits =
|
|
109
|
+
(): ApiRouteLimits<accessRuleApiPaths> => {
|
|
110
|
+
const defaults = {
|
|
111
|
+
limit: 5,
|
|
112
|
+
windowSeconds: 10,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const defaultWindowMs = defaults.windowSeconds * 1_000;
|
|
116
|
+
|
|
117
|
+
const rateLimitEntries = Object.entries(accessRuleApiPaths).map(
|
|
118
|
+
([endpointName, endpointPath]) => [
|
|
119
|
+
endpointPath,
|
|
120
|
+
{
|
|
121
|
+
windowMs:
|
|
122
|
+
getIntEnvironmentVariable(
|
|
123
|
+
`PROSOPO_USER_ACCESS_POLICY_RULE_${endpointName}_WINDOW`,
|
|
124
|
+
) || defaultWindowMs,
|
|
125
|
+
limit:
|
|
126
|
+
getIntEnvironmentVariable(
|
|
127
|
+
`PROSOPO_USER_ACCESS_POLICY_RULE_${endpointName}_LIMIT`,
|
|
128
|
+
) || defaults.limit,
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
return Object.fromEntries(rateLimitEntries);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const getIntEnvironmentVariable = (
|
|
137
|
+
variableName: string,
|
|
138
|
+
): number | undefined => {
|
|
139
|
+
const variableValue = process.env[variableName];
|
|
140
|
+
|
|
141
|
+
const numericValue = variableValue
|
|
142
|
+
? Number.parseInt(variableValue)
|
|
143
|
+
: Number.NaN;
|
|
144
|
+
|
|
145
|
+
return Number.isInteger(numericValue) ? numericValue : undefined;
|
|
146
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
import { ApiClient } from "@prosopo/api";
|
|
16
|
+
import type { ApiEndpointResponse } from "@prosopo/api-route";
|
|
17
|
+
import {
|
|
18
|
+
type FetchRulesEndpointResponse,
|
|
19
|
+
type FetchRulesOptions,
|
|
20
|
+
fetchRulesResponse,
|
|
21
|
+
} from "#policy/api/read/fetchRules.js";
|
|
22
|
+
import {
|
|
23
|
+
type RuleIdsEndpointResponse,
|
|
24
|
+
ruleIdsResponse,
|
|
25
|
+
} from "#policy/api/read/findRuleIds.js";
|
|
26
|
+
import {
|
|
27
|
+
type MissingIds,
|
|
28
|
+
type MissingIdsEndpointResponse,
|
|
29
|
+
missingIdsResponse,
|
|
30
|
+
} from "#policy/api/read/getMissingIds.js";
|
|
31
|
+
import type { AccessRulesFilterInput } from "#policy/ruleInput/ruleInput.js";
|
|
32
|
+
import type { DeleteSiteGroups } from "./delete/deleteRuleGroups.js";
|
|
33
|
+
import { accessRuleApiPaths } from "./ruleApiRoutes.js";
|
|
34
|
+
import type { InsertRulesGroup } from "./write/insertRules.js";
|
|
35
|
+
|
|
36
|
+
export class AccessRulesApiClient extends ApiClient {
|
|
37
|
+
//// delete
|
|
38
|
+
|
|
39
|
+
public deleteMany(
|
|
40
|
+
filters: AccessRulesFilterInput[],
|
|
41
|
+
jwt: string,
|
|
42
|
+
): Promise<ApiEndpointResponse> {
|
|
43
|
+
return this.post(
|
|
44
|
+
accessRuleApiPaths.DELETE_MANY,
|
|
45
|
+
filters,
|
|
46
|
+
this.getAuthHeaders(jwt),
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public deleteGroups(
|
|
51
|
+
siteGroups: DeleteSiteGroups,
|
|
52
|
+
jwt: string,
|
|
53
|
+
): Promise<ApiEndpointResponse> {
|
|
54
|
+
return this.post(
|
|
55
|
+
accessRuleApiPaths.DELETE_GROUPS,
|
|
56
|
+
siteGroups,
|
|
57
|
+
this.getAuthHeaders(jwt),
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public deleteAll(jwt: string): Promise<ApiEndpointResponse> {
|
|
62
|
+
return this.post(
|
|
63
|
+
accessRuleApiPaths.DELETE_ALL,
|
|
64
|
+
{},
|
|
65
|
+
this.getAuthHeaders(jwt),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//// read
|
|
70
|
+
|
|
71
|
+
public async getMissingIds(
|
|
72
|
+
idsToCheck: MissingIds,
|
|
73
|
+
jwt: string,
|
|
74
|
+
): Promise<MissingIdsEndpointResponse> {
|
|
75
|
+
const endpointResponse: ApiEndpointResponse = await this.post(
|
|
76
|
+
accessRuleApiPaths.GET_MISSING_IDS,
|
|
77
|
+
idsToCheck,
|
|
78
|
+
this.getAuthHeaders(jwt),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const parsedData = missingIdsResponse.safeParse(endpointResponse.data);
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
...endpointResponse,
|
|
85
|
+
data: parsedData.success ? parsedData.data : undefined,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public async fetchMany(
|
|
90
|
+
fetchOptions: FetchRulesOptions,
|
|
91
|
+
jwt: string,
|
|
92
|
+
): Promise<FetchRulesEndpointResponse> {
|
|
93
|
+
const endpointResponse: ApiEndpointResponse = await this.post(
|
|
94
|
+
accessRuleApiPaths.FETCH_MANY,
|
|
95
|
+
fetchOptions,
|
|
96
|
+
this.getAuthHeaders(jwt),
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const parsedData = fetchRulesResponse.safeParse(endpointResponse.data);
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
...endpointResponse,
|
|
103
|
+
data: parsedData.success ? parsedData.data : undefined,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public async findIds(
|
|
108
|
+
filters: AccessRulesFilterInput[],
|
|
109
|
+
jwt: string,
|
|
110
|
+
): Promise<RuleIdsEndpointResponse> {
|
|
111
|
+
const endpointResponse: ApiEndpointResponse = await this.post(
|
|
112
|
+
accessRuleApiPaths.FIND_IDS,
|
|
113
|
+
filters,
|
|
114
|
+
this.getAuthHeaders(jwt),
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const parsedData = ruleIdsResponse.safeParse(endpointResponse.data);
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
...endpointResponse,
|
|
121
|
+
data: parsedData.success ? parsedData.data : undefined,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
//// write
|
|
126
|
+
|
|
127
|
+
public async rehashAll(jwt: string): Promise<ApiEndpointResponse> {
|
|
128
|
+
return this.post(
|
|
129
|
+
accessRuleApiPaths.REHASH_ALL,
|
|
130
|
+
{},
|
|
131
|
+
this.getAuthHeaders(jwt),
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public insertMany(
|
|
136
|
+
ruleGroups: InsertRulesGroup[],
|
|
137
|
+
jwt: string,
|
|
138
|
+
): Promise<ApiEndpointResponse> {
|
|
139
|
+
return this.post(
|
|
140
|
+
accessRuleApiPaths.INSERT_MANY,
|
|
141
|
+
ruleGroups,
|
|
142
|
+
this.getAuthHeaders(jwt),
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
protected getAuthHeaders(jwt: string): RequestInit {
|
|
147
|
+
return {
|
|
148
|
+
headers: {
|
|
149
|
+
"Prosopo-Site-Key": this.account,
|
|
150
|
+
Authorization: `Bearer ${jwt}`,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
export type { InsertRulesGroup } from "./insertRules.js";
|