@casual-simulation/aux-records 3.8.1 → 3.10.2
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/AIChatInterface.d.ts +7 -43
- package/AIChatInterface.js +8 -6
- package/AIChatInterface.js.map +1 -1
- package/AIController.js +44 -49
- package/AIController.js.map +1 -1
- package/AIOpenAIRealtimeInterface.d.ts +1 -1
- package/AnthropicAIChatInterface.js +4 -4
- package/AnthropicAIChatInterface.js.map +1 -1
- package/AuthController.d.ts +78 -10
- package/AuthController.js +230 -166
- package/AuthController.js.map +1 -1
- package/AuthStore.d.ts +317 -4
- package/BigIntPatch.d.ts +1 -0
- package/BigIntPatch.js +24 -0
- package/BigIntPatch.js.map +1 -0
- package/BlockadeLabsGenerateSkyboxInterface.js +4 -4
- package/BlockadeLabsGenerateSkyboxInterface.js.map +1 -1
- package/CachingConfigStore.d.ts +8 -1
- package/CachingConfigStore.js +50 -0
- package/CachingConfigStore.js.map +1 -1
- package/ComIdConfig.d.ts +132 -86
- package/ComIdConfig.js +5 -5
- package/ComIdConfig.js.map +1 -1
- package/ConfigurationStore.d.ts +1393 -3
- package/ConfigurationStore.js +49 -0
- package/ConfigurationStore.js.map +1 -1
- package/DataRecordsController.js +28 -28
- package/DataRecordsController.js.map +1 -1
- package/EventRecordsController.js +9 -9
- package/EventRecordsController.js.map +1 -1
- package/FileRecordsController.js +18 -17
- package/FileRecordsController.js.map +1 -1
- package/GoogleAIChatInterface.js +4 -4
- package/GoogleAIChatInterface.js.map +1 -1
- package/HttpTestUtils.d.ts +48 -0
- package/HttpTestUtils.js +256 -0
- package/HttpTestUtils.js.map +1 -0
- package/LivekitController.js +2 -2
- package/LivekitController.js.map +1 -1
- package/LoomController.js +3 -4
- package/LoomController.js.map +1 -1
- package/MemoryStore.d.ts +60 -7
- package/MemoryStore.js +427 -59
- package/MemoryStore.js.map +1 -1
- package/MetricsStore.d.ts +11 -0
- package/ModerationConfiguration.d.ts +11 -85
- package/ModerationConfiguration.js +17 -17
- package/ModerationConfiguration.js.map +1 -1
- package/ModerationController.js +9 -11
- package/ModerationController.js.map +1 -1
- package/OpenAIChatInterface.js +8 -13
- package/OpenAIChatInterface.js.map +1 -1
- package/OpenAIImageInterface.js +4 -5
- package/OpenAIImageInterface.js.map +1 -1
- package/PolicyController.js +66 -73
- package/PolicyController.js.map +1 -1
- package/PolicyStore.d.ts +59 -33
- package/PolicyStore.js +35 -1
- package/PolicyStore.js.map +1 -1
- package/PrivoClient.d.ts +3 -1
- package/PrivoClient.js +2 -4
- package/PrivoClient.js.map +1 -1
- package/PrivoConfiguration.d.ts +6 -72
- package/PrivoConfiguration.js +30 -31
- package/PrivoConfiguration.js.map +1 -1
- package/README.md +276 -2
- package/RateLimitController.js +2 -2
- package/RateLimitController.js.map +1 -1
- package/RecordsClient.d.ts +3 -1
- package/RecordsClient.js +6 -6
- package/RecordsClient.js.map +1 -1
- package/RecordsController.d.ts +145 -3
- package/RecordsController.js +399 -61
- package/RecordsController.js.map +1 -1
- package/RecordsServer.d.ts +1932 -1109
- package/RecordsStore.d.ts +99 -14
- package/RecordsStore.js +8 -10
- package/RecordsStore.js.map +1 -1
- package/ServerConfig.d.ts +698 -9867
- package/ServerConfig.js +457 -377
- package/ServerConfig.js.map +1 -1
- package/SloydInterface.js +1 -1
- package/SloydInterface.js.map +1 -1
- package/StabilityAIImageInterface.js +6 -9
- package/StabilityAIImageInterface.js.map +1 -1
- package/StripeInterface.d.ts +431 -287
- package/StripeInterface.js +21 -1
- package/StripeInterface.js.map +1 -1
- package/SubscriptionConfigBuilder.d.ts +10 -1
- package/SubscriptionConfigBuilder.js +72 -41
- package/SubscriptionConfigBuilder.js.map +1 -1
- package/SubscriptionConfiguration.d.ts +606 -6334
- package/SubscriptionConfiguration.js +460 -277
- package/SubscriptionConfiguration.js.map +1 -1
- package/SubscriptionController.d.ts +677 -4
- package/SubscriptionController.js +2986 -186
- package/SubscriptionController.js.map +1 -1
- package/SystemNotificationMessenger.d.ts +14 -70
- package/SystemNotificationMessenger.js +17 -20
- package/SystemNotificationMessenger.js.map +1 -1
- package/TestUtils.d.ts +18 -3
- package/TestUtils.js +84 -8
- package/TestUtils.js.map +1 -1
- package/TypeUtils.d.ts +991 -0
- package/TypeUtils.js +2 -0
- package/TypeUtils.js.map +1 -0
- package/Utils.d.ts +59 -0
- package/Utils.js +507 -3
- package/Utils.js.map +1 -1
- package/Validations.d.ts +24 -108
- package/Validations.js +62 -45
- package/Validations.js.map +1 -1
- package/ViewTemplateRenderer.d.ts +39 -0
- package/ViewTemplateRenderer.js +19 -0
- package/ViewTemplateRenderer.js.map +1 -0
- package/contracts/ContractRecordsController.d.ts +58 -0
- package/contracts/ContractRecordsController.js +144 -0
- package/contracts/ContractRecordsController.js.map +1 -0
- package/contracts/ContractRecordsStore.d.ts +285 -0
- package/contracts/ContractRecordsStore.js +19 -0
- package/contracts/ContractRecordsStore.js.map +1 -0
- package/contracts/MemoryContractRecordsStore.d.ts +27 -0
- package/contracts/MemoryContractRecordsStore.js +124 -0
- package/contracts/MemoryContractRecordsStore.js.map +1 -0
- package/contracts/index.d.ts +4 -0
- package/contracts/index.js +21 -0
- package/contracts/index.js.map +1 -0
- package/crud/CrudHelpers.d.ts +25 -26
- package/crud/CrudHelpers.js +1 -1
- package/crud/CrudHelpers.js.map +1 -1
- package/crud/CrudRecordsController.js +13 -16
- package/crud/CrudRecordsController.js.map +1 -1
- package/crud/CrudRecordsControllerTests.d.ts +2 -2
- package/crud/CrudRecordsControllerTests.js +605 -580
- package/crud/CrudRecordsControllerTests.js.map +1 -1
- package/crud/MemoryCrudRecordsStore.js +1 -2
- package/crud/MemoryCrudRecordsStore.js.map +1 -1
- package/crud/sub/MemorySubCrudRecordsStore.js +4 -6
- package/crud/sub/MemorySubCrudRecordsStore.js.map +1 -1
- package/crud/sub/SubCrudRecordsController.js +8 -8
- package/crud/sub/SubCrudRecordsController.js.map +1 -1
- package/database/DatabaseRecordsController.js +1 -2
- package/database/DatabaseRecordsController.js.map +1 -1
- package/database/SqliteDatabaseInterface.js +1 -2
- package/database/SqliteDatabaseInterface.js.map +1 -1
- package/dns/DNSDomainNameValidator.d.ts +11 -0
- package/dns/DNSDomainNameValidator.js +59 -0
- package/dns/DNSDomainNameValidator.js.map +1 -0
- package/dns/DomainNameValidator.d.ts +36 -0
- package/dns/DomainNameValidator.js +19 -0
- package/dns/DomainNameValidator.js.map +1 -0
- package/dns/index.d.ts +3 -0
- package/dns/index.js +20 -0
- package/dns/index.js.map +1 -0
- package/financial/FinancialController.d.ts +272 -0
- package/financial/FinancialController.js +762 -0
- package/financial/FinancialController.js.map +1 -0
- package/financial/FinancialInterface.d.ts +352 -0
- package/financial/FinancialInterface.js +642 -0
- package/financial/FinancialInterface.js.map +1 -0
- package/financial/FinancialStore.d.ts +186 -0
- package/financial/FinancialStore.js +19 -0
- package/financial/FinancialStore.js.map +1 -0
- package/financial/MemoryFinancialInterface.d.ts +23 -0
- package/financial/MemoryFinancialInterface.js +592 -0
- package/financial/MemoryFinancialInterface.js.map +1 -0
- package/financial/TigerBeetleFinancialInterface.d.ts +46 -0
- package/financial/TigerBeetleFinancialInterface.js +109 -0
- package/financial/TigerBeetleFinancialInterface.js.map +1 -0
- package/financial/TigerBeetleTestUtils.d.ts +40 -0
- package/financial/TigerBeetleTestUtils.js +185 -0
- package/financial/TigerBeetleTestUtils.js.map +1 -0
- package/financial/Types.d.ts +1 -0
- package/financial/Types.js +801 -0
- package/financial/Types.js.map +1 -0
- package/financial/index.d.ts +6 -0
- package/financial/index.js +24 -0
- package/financial/index.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/notifications/NotificationRecordsController.js +14 -14
- package/notifications/NotificationRecordsController.js.map +1 -1
- package/notifications/WebPushInterface.d.ts +24 -155
- package/notifications/WebPushInterface.js +2 -2
- package/notifications/WebPushInterface.js.map +1 -1
- package/package.json +72 -70
- package/packages/version/MemoryPackageVersionRecordsStore.js +12 -15
- package/packages/version/MemoryPackageVersionRecordsStore.js.map +1 -1
- package/packages/version/PackageVersionRecordsController.d.ts +19 -0
- package/packages/version/PackageVersionRecordsController.js +102 -22
- package/packages/version/PackageVersionRecordsController.js.map +1 -1
- package/packages/version/PackageVersionRecordsStore.js +6 -8
- package/packages/version/PackageVersionRecordsStore.js.map +1 -1
- package/purchasable-items/MemoryPurchasableItemRecordsStore.d.ts +7 -0
- package/purchasable-items/MemoryPurchasableItemRecordsStore.js +33 -0
- package/purchasable-items/MemoryPurchasableItemRecordsStore.js.map +1 -0
- package/purchasable-items/PurchasableItemRecordsController.d.ts +16 -0
- package/purchasable-items/PurchasableItemRecordsController.js +72 -0
- package/purchasable-items/PurchasableItemRecordsController.js.map +1 -0
- package/purchasable-items/PurchasableItemRecordsStore.d.ts +66 -0
- package/purchasable-items/PurchasableItemRecordsStore.js +2 -0
- package/purchasable-items/PurchasableItemRecordsStore.js.map +1 -0
- package/purchasable-items/index.d.ts +4 -0
- package/purchasable-items/index.js +21 -0
- package/purchasable-items/index.js.map +1 -0
- package/queue/MemoryQueue.js +1 -1
- package/queue/MemoryQueue.js.map +1 -1
- package/search/MemorySearchInterface.js +1 -2
- package/search/MemorySearchInterface.js.map +1 -1
- package/search/SearchRecordsController.d.ts +66 -244
- package/search/SearchRecordsController.js +35 -36
- package/search/SearchRecordsController.js.map +1 -1
- package/search/SearchSyncProcessor.d.ts +7 -83
- package/search/TypesenseSearchInterface.js +8 -11
- package/search/TypesenseSearchInterface.js.map +1 -1
- package/tracing/TracingDecorators.js +5 -8
- package/tracing/TracingDecorators.js.map +1 -1
- package/webhooks/WebhookEnvironment.d.ts +36 -560
- package/webhooks/WebhookEnvironment.js +1 -1
- package/webhooks/WebhookEnvironment.js.map +1 -1
- package/webhooks/WebhookRecordsController.js +14 -16
- package/webhooks/WebhookRecordsController.js.map +1 -1
- package/websockets/MemoryLockStore.d.ts +18 -0
- package/websockets/MemoryLockStore.js +2 -0
- package/websockets/MemoryLockStore.js.map +1 -0
- package/websockets/MemoryTempInstRecordsStore.js +15 -27
- package/websockets/MemoryTempInstRecordsStore.js.map +1 -1
- package/websockets/MemoryWebsocketConnectionStore.js +6 -8
- package/websockets/MemoryWebsocketConnectionStore.js.map +1 -1
- package/websockets/MemoryWebsocketMessenger.js +1 -2
- package/websockets/MemoryWebsocketMessenger.js.map +1 -1
- package/websockets/SplitInstRecordsStore.js +2 -2
- package/websockets/SplitInstRecordsStore.js.map +1 -1
- package/websockets/WebsocketController.d.ts +5 -0
- package/websockets/WebsocketController.js +122 -83
- package/websockets/WebsocketController.js.map +1 -1
- package/RecordsServer.js +0 -6435
- package/RecordsServer.js.map +0 -1
package/PolicyController.js
CHANGED
|
@@ -55,6 +55,7 @@ const ALLOWED_MODERATOR_ACTIONS = new Set([
|
|
|
55
55
|
'list',
|
|
56
56
|
'listSubscriptions',
|
|
57
57
|
'count',
|
|
58
|
+
'purchase',
|
|
58
59
|
]);
|
|
59
60
|
function constructAllowedResourcesLookup(allowedResources) {
|
|
60
61
|
const lookup = new Set();
|
|
@@ -154,7 +155,6 @@ export class PolicyController {
|
|
|
154
155
|
* @returns The authorization context that will be used to evaluate whether the request is authorized.
|
|
155
156
|
*/
|
|
156
157
|
async constructAuthorizationContext(request) {
|
|
157
|
-
var _a, _b;
|
|
158
158
|
let recordKeyResult = null;
|
|
159
159
|
let recordName;
|
|
160
160
|
let recordKeyCreatorId;
|
|
@@ -223,9 +223,9 @@ export class PolicyController {
|
|
|
223
223
|
if (request.userId) {
|
|
224
224
|
userPrivacyFeatures = await this._policies.getUserPrivacyFeatures(request.userId);
|
|
225
225
|
}
|
|
226
|
-
const userRole = (
|
|
227
|
-
? userPrivacyFeatures
|
|
228
|
-
: request.userRole)
|
|
226
|
+
const userRole = (request.userId
|
|
227
|
+
? userPrivacyFeatures?.userRole
|
|
228
|
+
: request.userRole) ?? 'none';
|
|
229
229
|
if (!userPrivacyFeatures) {
|
|
230
230
|
if (this._auth.privoEnabled && userRole !== 'system') {
|
|
231
231
|
userPrivacyFeatures = {
|
|
@@ -257,7 +257,7 @@ export class PolicyController {
|
|
|
257
257
|
userId: request.userId,
|
|
258
258
|
userRole: userRole,
|
|
259
259
|
userPrivacyFeatures,
|
|
260
|
-
sendNotLoggedIn:
|
|
260
|
+
sendNotLoggedIn: request.sendNotLoggedIn ?? true,
|
|
261
261
|
};
|
|
262
262
|
return {
|
|
263
263
|
success: true,
|
|
@@ -270,7 +270,6 @@ export class PolicyController {
|
|
|
270
270
|
* @param request The request.
|
|
271
271
|
*/
|
|
272
272
|
async authorizeUserAndInstances(context, request) {
|
|
273
|
-
var _a;
|
|
274
273
|
try {
|
|
275
274
|
const authorization = await this.authorizeSubjects(context, {
|
|
276
275
|
action: request.action,
|
|
@@ -282,7 +281,7 @@ export class PolicyController {
|
|
|
282
281
|
subjectType: 'user',
|
|
283
282
|
subjectId: request.userId,
|
|
284
283
|
},
|
|
285
|
-
...(
|
|
284
|
+
...(request.instances ?? []).map((i) => ({
|
|
286
285
|
subjectType: 'inst',
|
|
287
286
|
subjectId: i,
|
|
288
287
|
})),
|
|
@@ -299,8 +298,8 @@ export class PolicyController {
|
|
|
299
298
|
}
|
|
300
299
|
catch (err) {
|
|
301
300
|
const span = trace.getActiveSpan();
|
|
302
|
-
span
|
|
303
|
-
span
|
|
301
|
+
span?.recordException(err);
|
|
302
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
304
303
|
console.error('[PolicyController] A server error occurred while authorizing user and instances.', err);
|
|
305
304
|
return {
|
|
306
305
|
success: false,
|
|
@@ -315,14 +314,13 @@ export class PolicyController {
|
|
|
315
314
|
* @param request The request.
|
|
316
315
|
*/
|
|
317
316
|
async authorizeUserAndInstancesForResources(context, request) {
|
|
318
|
-
var _a;
|
|
319
317
|
try {
|
|
320
318
|
const subjects = [
|
|
321
319
|
{
|
|
322
320
|
subjectType: 'user',
|
|
323
321
|
subjectId: request.userId,
|
|
324
322
|
},
|
|
325
|
-
...(
|
|
323
|
+
...(request.instances ?? []).map((i) => ({
|
|
326
324
|
subjectType: 'inst',
|
|
327
325
|
subjectId: i,
|
|
328
326
|
})),
|
|
@@ -432,8 +430,8 @@ export class PolicyController {
|
|
|
432
430
|
}
|
|
433
431
|
catch (err) {
|
|
434
432
|
const span = trace.getActiveSpan();
|
|
435
|
-
span
|
|
436
|
-
span
|
|
433
|
+
span?.recordException(err);
|
|
434
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
437
435
|
console.error('[PolicyController] A server error occurred while authorizing user and instances for resources.', err);
|
|
438
436
|
return {
|
|
439
437
|
success: false,
|
|
@@ -482,8 +480,8 @@ export class PolicyController {
|
|
|
482
480
|
}
|
|
483
481
|
catch (err) {
|
|
484
482
|
const span = trace.getActiveSpan();
|
|
485
|
-
span
|
|
486
|
-
span
|
|
483
|
+
span?.recordException(err);
|
|
484
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
487
485
|
console.error('[PolicyController] A server error occurred while authorizing subjects.', err);
|
|
488
486
|
return {
|
|
489
487
|
success: false,
|
|
@@ -507,8 +505,8 @@ export class PolicyController {
|
|
|
507
505
|
}
|
|
508
506
|
catch (err) {
|
|
509
507
|
const span = trace.getActiveSpan();
|
|
510
|
-
span
|
|
511
|
-
span
|
|
508
|
+
span?.recordException(err);
|
|
509
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
512
510
|
console.error('[PolicyController] A server error occurred while authorizing a subject.', err);
|
|
513
511
|
return {
|
|
514
512
|
success: false,
|
|
@@ -540,7 +538,6 @@ export class PolicyController {
|
|
|
540
538
|
* @param request The request to authorize.
|
|
541
539
|
*/
|
|
542
540
|
async _authorizeSubjectUsingContext(context, request) {
|
|
543
|
-
var _a, _b, _c;
|
|
544
541
|
try {
|
|
545
542
|
const markers = getRootMarkersOrDefault(request.markers);
|
|
546
543
|
let recommendedEntitlement = undefined;
|
|
@@ -878,10 +875,10 @@ export class PolicyController {
|
|
|
878
875
|
const entitlementFeature = getEntitlementFeatureForAction(request.resourceKind, request.action);
|
|
879
876
|
let hasPackages = false;
|
|
880
877
|
if (entitlementFeature) {
|
|
881
|
-
const loadedPackages = (
|
|
878
|
+
const loadedPackages = (await this._insts?.listLoadedPackages(instId.recordName, instId.inst)) ?? [];
|
|
882
879
|
const grantedEntitlements = await this._policies.listGrantedEntitlementsByFeatureAndUserId(loadedPackages.map((p) => p.packageId), entitlementFeature, context.userId, context.recordName, Date.now());
|
|
883
|
-
if (
|
|
884
|
-
|
|
880
|
+
if (loadedPackages?.length > 0 ||
|
|
881
|
+
grantedEntitlements?.length > 0) {
|
|
885
882
|
hasPackages = true;
|
|
886
883
|
}
|
|
887
884
|
if (grantedEntitlements && grantedEntitlements.length > 0) {
|
|
@@ -926,10 +923,9 @@ export class PolicyController {
|
|
|
926
923
|
}
|
|
927
924
|
if (hasPackages) {
|
|
928
925
|
const firstPackage = loadedPackages[0];
|
|
929
|
-
const pkg = await
|
|
930
|
-
if (pkg
|
|
926
|
+
const pkg = await this._packageVersions?.getItemById(firstPackage.packageVersionId);
|
|
927
|
+
if (pkg?.item) {
|
|
931
928
|
const canRecommendEntitlement = pkg.item.entitlements.some((e) => {
|
|
932
|
-
var _a, _b;
|
|
933
929
|
if (e.scope === 'personal' &&
|
|
934
930
|
context.userId === context.recordName) {
|
|
935
931
|
return true;
|
|
@@ -939,11 +935,11 @@ export class PolicyController {
|
|
|
939
935
|
return true;
|
|
940
936
|
}
|
|
941
937
|
else if (e.scope === 'studio' &&
|
|
942
|
-
|
|
938
|
+
context.recordStudioMembers?.some((m) => m.userId === context.userId)) {
|
|
943
939
|
return true;
|
|
944
940
|
}
|
|
945
941
|
else if (e.scope === 'designated' &&
|
|
946
|
-
|
|
942
|
+
e.designatedRecords?.includes(context.recordName)) {
|
|
947
943
|
return true;
|
|
948
944
|
}
|
|
949
945
|
else if (e.scope === 'shared') {
|
|
@@ -1187,8 +1183,8 @@ export class PolicyController {
|
|
|
1187
1183
|
}
|
|
1188
1184
|
catch (err) {
|
|
1189
1185
|
const span = trace.getActiveSpan();
|
|
1190
|
-
span
|
|
1191
|
-
span
|
|
1186
|
+
span?.recordException(err);
|
|
1187
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1192
1188
|
console.error('[PolicyController] A server error occurred while listing permissions.', err);
|
|
1193
1189
|
return {
|
|
1194
1190
|
success: false,
|
|
@@ -1244,8 +1240,8 @@ export class PolicyController {
|
|
|
1244
1240
|
}
|
|
1245
1241
|
catch (err) {
|
|
1246
1242
|
const span = trace.getActiveSpan();
|
|
1247
|
-
span
|
|
1248
|
-
span
|
|
1243
|
+
span?.recordException(err);
|
|
1244
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1249
1245
|
console.error('[PolicyController] A server error occurred while listing permissions for marker.', err);
|
|
1250
1246
|
return {
|
|
1251
1247
|
success: false,
|
|
@@ -1301,8 +1297,8 @@ export class PolicyController {
|
|
|
1301
1297
|
}
|
|
1302
1298
|
catch (err) {
|
|
1303
1299
|
const span = trace.getActiveSpan();
|
|
1304
|
-
span
|
|
1305
|
-
span
|
|
1300
|
+
span?.recordException(err);
|
|
1301
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1306
1302
|
console.error('[PolicyController] A server error occurred while listing permissions for resource.', err);
|
|
1307
1303
|
return {
|
|
1308
1304
|
success: false,
|
|
@@ -1316,7 +1312,6 @@ export class PolicyController {
|
|
|
1316
1312
|
* @param request The request for the operation.
|
|
1317
1313
|
*/
|
|
1318
1314
|
async grantMarkerPermission(request) {
|
|
1319
|
-
var _a, _b, _c;
|
|
1320
1315
|
try {
|
|
1321
1316
|
const baseRequest = {
|
|
1322
1317
|
recordKeyOrRecordName: request.recordKeyOrRecordName,
|
|
@@ -1347,15 +1342,15 @@ export class PolicyController {
|
|
|
1347
1342
|
if (assignmentResult.success === false) {
|
|
1348
1343
|
return assignmentResult;
|
|
1349
1344
|
}
|
|
1350
|
-
console.log(`[PolicyController] [grantMarkerPermission] [userId: ${request.userId}, recordName: ${recordName}, subjectType: ${request.permission.subjectType}, subjectId: ${request.permission.subjectId}, marker: ${marker}, resourceKind: ${
|
|
1345
|
+
console.log(`[PolicyController] [grantMarkerPermission] [userId: ${request.userId}, recordName: ${recordName}, subjectType: ${request.permission.subjectType}, subjectId: ${request.permission.subjectId}, marker: ${marker}, resourceKind: ${request.permission.resourceKind ?? '(null)'}, action: ${request.permission.action ?? '(null)'}, expireTimeMs: ${request.permission.expireTimeMs ?? '(null)'}, permissionId: ${assignmentResult.permissionAssignment.id}] Granted marker permission.`);
|
|
1351
1346
|
return {
|
|
1352
1347
|
success: true,
|
|
1353
1348
|
};
|
|
1354
1349
|
}
|
|
1355
1350
|
catch (err) {
|
|
1356
1351
|
const span = trace.getActiveSpan();
|
|
1357
|
-
span
|
|
1358
|
-
span
|
|
1352
|
+
span?.recordException(err);
|
|
1353
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1359
1354
|
console.error('[PolicyController] A server error occurred while granting a marker permission.', err);
|
|
1360
1355
|
return {
|
|
1361
1356
|
success: false,
|
|
@@ -1412,8 +1407,8 @@ export class PolicyController {
|
|
|
1412
1407
|
}
|
|
1413
1408
|
catch (err) {
|
|
1414
1409
|
const span = trace.getActiveSpan();
|
|
1415
|
-
span
|
|
1416
|
-
span
|
|
1410
|
+
span?.recordException(err);
|
|
1411
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1417
1412
|
console.error('[PolicyController] A server error occurred while revoking a marker permission.', err);
|
|
1418
1413
|
return {
|
|
1419
1414
|
success: false,
|
|
@@ -1427,7 +1422,6 @@ export class PolicyController {
|
|
|
1427
1422
|
* @param request The request.
|
|
1428
1423
|
*/
|
|
1429
1424
|
async grantResourcePermission(request) {
|
|
1430
|
-
var _a, _b, _c, _d;
|
|
1431
1425
|
try {
|
|
1432
1426
|
const baseRequest = {
|
|
1433
1427
|
recordKeyOrRecordName: request.recordKeyOrRecordName,
|
|
@@ -1474,15 +1468,15 @@ export class PolicyController {
|
|
|
1474
1468
|
if (assignmentResult.success === false) {
|
|
1475
1469
|
return assignmentResult;
|
|
1476
1470
|
}
|
|
1477
|
-
console.log(`[PolicyController] [grantResourcePermission] [userId: ${request.userId}, recordName: ${recordName}, subjectType: ${request.permission.subjectType}, subjectId: ${request.permission.subjectId}, resourceKind: ${
|
|
1471
|
+
console.log(`[PolicyController] [grantResourcePermission] [userId: ${request.userId}, recordName: ${recordName}, subjectType: ${request.permission.subjectType}, subjectId: ${request.permission.subjectId}, resourceKind: ${request.permission.resourceKind ?? '(null)'}, resourceId: ${request.permission.resourceId ?? '(null)'}, action: ${request.permission.action ?? '(null)'}, expireTimeMs: ${request.permission.expireTimeMs ?? '(null)'}, permissionId: ${assignmentResult.permissionAssignment.id}] Granted permission for resource.`);
|
|
1478
1472
|
return {
|
|
1479
1473
|
success: true,
|
|
1480
1474
|
};
|
|
1481
1475
|
}
|
|
1482
1476
|
catch (err) {
|
|
1483
1477
|
const span = trace.getActiveSpan();
|
|
1484
|
-
span
|
|
1485
|
-
span
|
|
1478
|
+
span?.recordException(err);
|
|
1479
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1486
1480
|
console.error('[PolicyController] A server error occurred while granting a resource permission.', err);
|
|
1487
1481
|
return {
|
|
1488
1482
|
success: false,
|
|
@@ -1539,8 +1533,8 @@ export class PolicyController {
|
|
|
1539
1533
|
}
|
|
1540
1534
|
catch (err) {
|
|
1541
1535
|
const span = trace.getActiveSpan();
|
|
1542
|
-
span
|
|
1543
|
-
span
|
|
1536
|
+
span?.recordException(err);
|
|
1537
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1544
1538
|
console.error('[PolicyController] A server error occurred while revoking a resource permission.', err);
|
|
1545
1539
|
return {
|
|
1546
1540
|
success: false,
|
|
@@ -1564,8 +1558,8 @@ export class PolicyController {
|
|
|
1564
1558
|
}
|
|
1565
1559
|
catch (err) {
|
|
1566
1560
|
const span = trace.getActiveSpan();
|
|
1567
|
-
span
|
|
1568
|
-
span
|
|
1561
|
+
span?.recordException(err);
|
|
1562
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1569
1563
|
console.error('[PolicyController] A server error occurred while revoking a permission.', err);
|
|
1570
1564
|
return {
|
|
1571
1565
|
success: false,
|
|
@@ -1615,8 +1609,8 @@ export class PolicyController {
|
|
|
1615
1609
|
}
|
|
1616
1610
|
catch (err) {
|
|
1617
1611
|
const span = trace.getActiveSpan();
|
|
1618
|
-
span
|
|
1619
|
-
span
|
|
1612
|
+
span?.recordException(err);
|
|
1613
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1620
1614
|
console.error('[PolicyController] A server error occurred.', err);
|
|
1621
1615
|
return {
|
|
1622
1616
|
success: false,
|
|
@@ -1664,8 +1658,8 @@ export class PolicyController {
|
|
|
1664
1658
|
}
|
|
1665
1659
|
catch (err) {
|
|
1666
1660
|
const span = trace.getActiveSpan();
|
|
1667
|
-
span
|
|
1668
|
-
span
|
|
1661
|
+
span?.recordException(err);
|
|
1662
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1669
1663
|
console.error('[PolicyController] A server error occurred.', err);
|
|
1670
1664
|
return {
|
|
1671
1665
|
success: false,
|
|
@@ -1713,8 +1707,8 @@ export class PolicyController {
|
|
|
1713
1707
|
}
|
|
1714
1708
|
catch (err) {
|
|
1715
1709
|
const span = trace.getActiveSpan();
|
|
1716
|
-
span
|
|
1717
|
-
span
|
|
1710
|
+
span?.recordException(err);
|
|
1711
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1718
1712
|
console.error('[PolicyController] A server error occurred.', err);
|
|
1719
1713
|
return {
|
|
1720
1714
|
success: false,
|
|
@@ -1770,8 +1764,8 @@ export class PolicyController {
|
|
|
1770
1764
|
}
|
|
1771
1765
|
catch (err) {
|
|
1772
1766
|
const span = trace.getActiveSpan();
|
|
1773
|
-
span
|
|
1774
|
-
span
|
|
1767
|
+
span?.recordException(err);
|
|
1768
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1775
1769
|
console.error('[PolicyController] A server error occurred.', err);
|
|
1776
1770
|
return {
|
|
1777
1771
|
success: false,
|
|
@@ -1848,8 +1842,8 @@ export class PolicyController {
|
|
|
1848
1842
|
}
|
|
1849
1843
|
catch (err) {
|
|
1850
1844
|
const span = trace.getActiveSpan();
|
|
1851
|
-
span
|
|
1852
|
-
span
|
|
1845
|
+
span?.recordException(err);
|
|
1846
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1853
1847
|
console.error('[PolicyController] A server error occurred.', err);
|
|
1854
1848
|
return {
|
|
1855
1849
|
success: false,
|
|
@@ -1919,8 +1913,8 @@ export class PolicyController {
|
|
|
1919
1913
|
}
|
|
1920
1914
|
catch (err) {
|
|
1921
1915
|
const span = trace.getActiveSpan();
|
|
1922
|
-
span
|
|
1923
|
-
span
|
|
1916
|
+
span?.recordException(err);
|
|
1917
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1924
1918
|
console.error('[PolicyController] A server error occurred.', err);
|
|
1925
1919
|
return {
|
|
1926
1920
|
success: false,
|
|
@@ -1934,7 +1928,6 @@ export class PolicyController {
|
|
|
1934
1928
|
* @param request
|
|
1935
1929
|
*/
|
|
1936
1930
|
async grantEntitlement(request) {
|
|
1937
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1938
1931
|
try {
|
|
1939
1932
|
if (!isSuperUserRole(request.userRole)) {
|
|
1940
1933
|
if (request.userId !== request.grantingUserId) {
|
|
@@ -1946,18 +1939,18 @@ export class PolicyController {
|
|
|
1946
1939
|
}
|
|
1947
1940
|
}
|
|
1948
1941
|
const grant = await this._policies.findGrantedPackageEntitlementByUserIdPackageIdFeatureAndScope(request.grantingUserId, request.packageId, request.feature, request.scope, request.recordName);
|
|
1949
|
-
const grantId =
|
|
1950
|
-
const feature =
|
|
1942
|
+
const grantId = grant?.id ?? uuidv7();
|
|
1943
|
+
const feature = grant?.feature ?? request.feature;
|
|
1951
1944
|
await this._policies.saveGrantedPackageEntitlement({
|
|
1952
1945
|
id: grantId,
|
|
1953
|
-
createdAtMs:
|
|
1954
|
-
expireTimeMs: Math.max(request.expireTimeMs,
|
|
1946
|
+
createdAtMs: grant?.createdAtMs ?? Date.now(),
|
|
1947
|
+
expireTimeMs: Math.max(request.expireTimeMs, grant?.expireTimeMs ?? 0),
|
|
1955
1948
|
revokeTimeMs: null,
|
|
1956
|
-
scope:
|
|
1957
|
-
packageId:
|
|
1958
|
-
userId:
|
|
1949
|
+
scope: grant?.scope ?? request.scope,
|
|
1950
|
+
packageId: grant?.packageId ?? request.packageId,
|
|
1951
|
+
userId: grant?.userId ?? request.grantingUserId,
|
|
1959
1952
|
feature: feature,
|
|
1960
|
-
recordName:
|
|
1953
|
+
recordName: grant?.recordName ?? request.recordName,
|
|
1961
1954
|
});
|
|
1962
1955
|
return {
|
|
1963
1956
|
success: true,
|
|
@@ -1967,8 +1960,8 @@ export class PolicyController {
|
|
|
1967
1960
|
}
|
|
1968
1961
|
catch (err) {
|
|
1969
1962
|
const span = trace.getActiveSpan();
|
|
1970
|
-
span
|
|
1971
|
-
span
|
|
1963
|
+
span?.recordException(err);
|
|
1964
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1972
1965
|
console.error('[PolicyController] A server error occurred.', err);
|
|
1973
1966
|
return {
|
|
1974
1967
|
success: false,
|
|
@@ -2012,8 +2005,8 @@ export class PolicyController {
|
|
|
2012
2005
|
}
|
|
2013
2006
|
catch (err) {
|
|
2014
2007
|
const span = trace.getActiveSpan();
|
|
2015
|
-
span
|
|
2016
|
-
span
|
|
2008
|
+
span?.recordException(err);
|
|
2009
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
2017
2010
|
console.error('[PolicyController] A server error occurred.', err);
|
|
2018
2011
|
return {
|
|
2019
2012
|
success: false,
|
|
@@ -2041,8 +2034,8 @@ export class PolicyController {
|
|
|
2041
2034
|
}
|
|
2042
2035
|
catch (err) {
|
|
2043
2036
|
const span = trace.getActiveSpan();
|
|
2044
|
-
span
|
|
2045
|
-
span
|
|
2037
|
+
span?.recordException(err);
|
|
2038
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
2046
2039
|
console.error('[PolicyController] A server error occurred.', err);
|
|
2047
2040
|
return {
|
|
2048
2041
|
success: false,
|