@casual-simulation/aux-records 3.2.13 → 3.2.14-alpha.7890390188
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/AIController.d.ts +7 -4
- package/AIController.js +11 -0
- package/AIController.js.map +1 -1
- package/AuthController.d.ts +2 -1
- package/AuthController.js +6 -3
- package/AuthController.js.map +1 -1
- package/AuthStore.d.ts +1 -21
- package/CachingPolicyStore.d.ts +16 -5
- package/CachingPolicyStore.js +66 -39
- package/CachingPolicyStore.js.map +1 -1
- package/DataRecordsController.d.ts +67 -5
- package/DataRecordsController.js +141 -78
- package/DataRecordsController.js.map +1 -1
- package/DataRecordsStore.d.ts +35 -1
- package/DataRecordsStore.js.map +1 -1
- package/EventRecordsController.d.ts +5 -5
- package/EventRecordsController.js +54 -35
- package/EventRecordsController.js.map +1 -1
- package/FileRecordsController.d.ts +6 -6
- package/FileRecordsController.js +142 -76
- package/FileRecordsController.js.map +1 -1
- package/MemoryStore.d.ts +28 -17
- package/MemoryStore.js +457 -110
- package/MemoryStore.js.map +1 -1
- package/PolicyController.d.ts +512 -677
- package/PolicyController.js +1196 -2934
- package/PolicyController.js.map +1 -1
- package/PolicyStore.d.ts +319 -90
- package/PolicyStore.js +125 -0
- package/PolicyStore.js.map +1 -1
- package/RecordsServer.d.ts +3 -4
- package/RecordsServer.js +88 -111
- package/RecordsServer.js.map +1 -1
- package/RecordsStore.d.ts +3 -0
- package/TestUtils.d.ts +1 -1
- package/TestUtils.js.map +1 -1
- package/Utils.d.ts +21 -3
- package/Utils.js +42 -3
- package/Utils.js.map +1 -1
- package/package.json +3 -3
- package/websockets/InstRecordsStore.d.ts +21 -0
- package/websockets/InstRecordsStore.js +43 -1
- package/websockets/InstRecordsStore.js.map +1 -1
- package/websockets/WebsocketController.d.ts +7 -7
- package/websockets/WebsocketController.js +153 -82
- package/websockets/WebsocketController.js.map +1 -1
package/PolicyStore.d.ts
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
import { ServerError } from '@casual-simulation/aux-common/Errors';
|
|
2
|
-
import {
|
|
3
|
-
import { PrivacyFeatures } from './AuthStore';
|
|
2
|
+
import { ActionKinds, PermissionOptions, ResourceKinds, SubjectType, PrivacyFeatures } from '@casual-simulation/aux-common';
|
|
4
3
|
/**
|
|
5
4
|
* Defines an interface for objects that are able to store and retrieve policy documents.
|
|
6
5
|
*/
|
|
7
6
|
export interface PolicyStore {
|
|
8
|
-
/**
|
|
9
|
-
* Gets the list of policy documents that apply to the given marker and user.
|
|
10
|
-
* @param recordName The name of the record that the policies belong to.
|
|
11
|
-
* @param userId The ID of the user that is attempting to utilize the markers. Null if the user is not logged in.
|
|
12
|
-
* @param marker The marker.
|
|
13
|
-
*/
|
|
14
|
-
listPoliciesForMarkerAndUser(recordName: string, userId: string, marker: string): Promise<ListMarkerPoliciesResult>;
|
|
15
|
-
/**
|
|
16
|
-
* Lists the user-created policices for the given record.
|
|
17
|
-
* @param recordName The name of the record.
|
|
18
|
-
* @param startingMarker The marker that policies should be listed after. If null, then the list starts with the first policy.
|
|
19
|
-
*/
|
|
20
|
-
listUserPolicies(recordName: string, startingMarker: string | null): Promise<ListUserPoliciesStoreResult>;
|
|
21
7
|
/**
|
|
22
8
|
* Lists the roles that are assigned to the user.
|
|
23
9
|
* @param recordName The name of the record that the role assignments belong to.
|
|
@@ -43,18 +29,110 @@ export interface PolicyStore {
|
|
|
43
29
|
*/
|
|
44
30
|
listAssignments?(recordName: string, startingRole: string | null): Promise<ListedRoleAssignments>;
|
|
45
31
|
/**
|
|
46
|
-
* Gets the
|
|
32
|
+
* Gets the privacy features that are enabled for the given user.
|
|
33
|
+
* Returns null if the given user does not exist.
|
|
34
|
+
* @param userId The ID of the user.
|
|
35
|
+
*/
|
|
36
|
+
getUserPrivacyFeatures(userId: string): Promise<PrivacyFeatures>;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the privacy features for the owner of the given record.
|
|
39
|
+
* Returns null if the record does not exist or if the record does not have an owner.
|
|
47
40
|
* @param recordName The name of the record.
|
|
48
|
-
* @param marker The name of the marker.
|
|
49
41
|
*/
|
|
50
|
-
|
|
42
|
+
getRecordOwnerPrivacyFeatures(recordName: string): Promise<PrivacyFeatures>;
|
|
43
|
+
/**
|
|
44
|
+
* Gets the permission for the given subject, resource, and action.
|
|
45
|
+
* @param subjectType The type of the subject. Must be either a user, inst, or role.
|
|
46
|
+
* @param subjectId The ID of the subject.
|
|
47
|
+
* @param recordName The name of the record that the resource belongs to.
|
|
48
|
+
* @param resourceKind The kind of the resource.
|
|
49
|
+
* @param resourceId The ID of the resource.
|
|
50
|
+
* @param action The action that the subject is attempting to perform on the resource.
|
|
51
|
+
* @param currentTimeMs The current unix time in milliseconds.
|
|
52
|
+
*/
|
|
53
|
+
getPermissionForSubjectAndResource(subjectType: SubjectType, subjectId: string, recordName: string, resourceKind: ResourceKinds, resourceId: string, action: ActionKinds, currentTimeMs: number): Promise<GetResourcePermissionResult>;
|
|
51
54
|
/**
|
|
52
|
-
*
|
|
55
|
+
* Gets the permission for the given subject, markers, and action.
|
|
56
|
+
* @param subjectType The type of the subject. Must be either a user, inst, or role.
|
|
57
|
+
* @param subjectId The ID of the subject.
|
|
58
|
+
* @param recordName The name of the record that the resource belongs to.
|
|
59
|
+
* @param resourceKind The kind of the resource.
|
|
60
|
+
* @param markers The markers that are applied to the resource.
|
|
61
|
+
* @param action The action that the subject is attempting to perform on the resource.
|
|
62
|
+
* @param currentTimeMs The current unix time in milliseconds.
|
|
63
|
+
*/
|
|
64
|
+
getPermissionForSubjectAndMarkers(subjectType: SubjectType, subjectId: string, recordName: string, resourceKind: ResourceKinds, markers: string[], action: ActionKinds, currentTimeMs: number): Promise<GetMarkerPermissionResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Assigns the given permission to the given subject for the given resource.
|
|
67
|
+
* @param recordName The name of the record that the resource exists in.
|
|
68
|
+
* @param subjectType The type of the subject. This can be either a user, inst, or role.
|
|
69
|
+
* @param subjectId The ID of the subject.
|
|
70
|
+
* @param resourceKind The kind of the resource.
|
|
71
|
+
* @param resourceId The ID of the resource.
|
|
72
|
+
* @param action The action that the subject is allowed to perform on the resource. If null, then all actions are allowed.
|
|
73
|
+
* @param options The options for the permission.
|
|
74
|
+
* @param expireTimeMs The time that the permission expires. If null, then the permission never expires.
|
|
75
|
+
*/
|
|
76
|
+
assignPermissionToSubjectAndResource(recordName: string, subjectType: SubjectType, subjectId: string, resourceKind: ResourceKinds, resourceId: string, action: ActionKinds, options: PermissionOptions, expireTimeMs: number | null): Promise<AssignPermissionToSubjectAndResourceResult>;
|
|
77
|
+
/**
|
|
78
|
+
* Assigns the given permission to the given subject for the given resource.
|
|
79
|
+
* @param recordName The name of the record that the resource exists in.
|
|
80
|
+
* @param subjectType The type of the subject. This can be either a user, inst, or role.
|
|
81
|
+
* @param subjectId The ID of the subject.
|
|
82
|
+
* @param resourceKind The kind of the resource.
|
|
83
|
+
* @param marker The ID of the marker.
|
|
84
|
+
* @param action The action that the subject is allowed to perform on the resource. If null, then all actions are allowed.
|
|
85
|
+
* @param options The options for the permission.
|
|
86
|
+
* @param expireTimeMs The time that the permission expires. If null, then the permission never expires.
|
|
87
|
+
*/
|
|
88
|
+
assignPermissionToSubjectAndMarker(recordName: string, subjectType: SubjectType, subjectId: string, resourceKind: ResourceKinds, marker: string, action: ActionKinds, options: PermissionOptions, expireTimeMs: number | null): Promise<AssignPermissionToSubjectAndMarkerResult>;
|
|
89
|
+
/**
|
|
90
|
+
* Deletes the given resource permission assignment from the store.
|
|
91
|
+
* @param id The ID of the resource permission assignment.
|
|
92
|
+
*/
|
|
93
|
+
deleteResourcePermissionAssignmentById(id: string): Promise<DeletePermissionAssignmentResult>;
|
|
94
|
+
/**
|
|
95
|
+
* Deletes the given marker permission assignment from the store.
|
|
96
|
+
* @param id The ID of the permission assignment.
|
|
97
|
+
*/
|
|
98
|
+
deleteMarkerPermissionAssignmentById(id: string): Promise<DeletePermissionAssignmentResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Lists the resource permission assignments for the given record.
|
|
101
|
+
* @param recordName The name of the record.
|
|
102
|
+
*/
|
|
103
|
+
listPermissionsInRecord(recordName: string): Promise<ListPermissionsInRecordResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Lists the resource permission assignments for the given record and resource.
|
|
106
|
+
* @param recordName The name of the record.
|
|
107
|
+
* @param resourceKind The kind of the resource.
|
|
108
|
+
* @param resourceId The ID of the resource.
|
|
109
|
+
*/
|
|
110
|
+
listPermissionsForResource(recordName: string, resourceKind: ResourceKinds, resourceId: string): Promise<ResourcePermissionAssignment[]>;
|
|
111
|
+
/**
|
|
112
|
+
* Lists the marker permission assignments for the given record and marker.
|
|
113
|
+
* @param recordName The record that the permission assignments should be listed for.
|
|
114
|
+
* @param marker The marker that the permission assignments should be listed for.
|
|
115
|
+
*/
|
|
116
|
+
listPermissionsForMarker(recordName: string, marker: string): Promise<MarkerPermissionAssignment[]>;
|
|
117
|
+
/**
|
|
118
|
+
* Lists the resource permission assignments for the given subject in the given record.
|
|
53
119
|
* @param recordName The name of the record.
|
|
54
|
-
* @param
|
|
55
|
-
* @param
|
|
120
|
+
* @param subjectType The type of the subject.
|
|
121
|
+
* @param subjectId The ID of the subject.
|
|
122
|
+
*/
|
|
123
|
+
listPermissionsForSubject(recordName: string, subjectType: SubjectType, subjectId: string): Promise<ListPermissionsInRecordResult>;
|
|
124
|
+
/**
|
|
125
|
+
* Gets the marker permission assignment with the given ID.
|
|
126
|
+
* Returns null if no assignment was found.
|
|
127
|
+
* @param id The ID of the assignment.
|
|
128
|
+
*/
|
|
129
|
+
getMarkerPermissionAssignmentById(id: string): Promise<MarkerPermissionAssignment>;
|
|
130
|
+
/**
|
|
131
|
+
* Gets the resource permission assignment with the given ID.
|
|
132
|
+
* Returns null if no assignment was found.
|
|
133
|
+
* @param id The ID of the assignment.
|
|
56
134
|
*/
|
|
57
|
-
|
|
135
|
+
getResourcePermissionAssignmentById(id: string): Promise<ResourcePermissionAssignment>;
|
|
58
136
|
/**
|
|
59
137
|
* Assigns the given role to the given subject.
|
|
60
138
|
* If the role already is assigned, then it will be overwritten.
|
|
@@ -76,51 +154,6 @@ export interface PolicyStore {
|
|
|
76
154
|
*/
|
|
77
155
|
revokeSubjectRole(recordName: string, subjectId: string, type: 'user' | 'inst', role: string): Promise<UpdateUserRolesResult>;
|
|
78
156
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Defines an interface that represents a user-created policy.
|
|
81
|
-
*/
|
|
82
|
-
export interface UserPolicyRecord {
|
|
83
|
-
/**
|
|
84
|
-
* The policy document.
|
|
85
|
-
*/
|
|
86
|
-
document: PolicyDocument;
|
|
87
|
-
/**
|
|
88
|
-
* The list of markers that are applied to the policy.
|
|
89
|
-
*/
|
|
90
|
-
markers: string[];
|
|
91
|
-
}
|
|
92
|
-
export interface ListedUserPolicy extends UserPolicyRecord {
|
|
93
|
-
/**
|
|
94
|
-
* The marker that this policy is for.
|
|
95
|
-
*/
|
|
96
|
-
marker: string;
|
|
97
|
-
}
|
|
98
|
-
export type GetUserPolicyResult = GetUserPolicySuccess | GetUserPolicyFailure;
|
|
99
|
-
export interface GetUserPolicySuccess {
|
|
100
|
-
success: true;
|
|
101
|
-
document: PolicyDocument;
|
|
102
|
-
markers: string[];
|
|
103
|
-
}
|
|
104
|
-
export interface GetUserPolicyFailure {
|
|
105
|
-
success: false;
|
|
106
|
-
errorCode: ServerError | 'policy_not_found';
|
|
107
|
-
errorMessage: string;
|
|
108
|
-
}
|
|
109
|
-
export type UpdateUserPolicyResult = UpdateUserPolicySuccess | UpdateUserPolicyFailure;
|
|
110
|
-
export interface UpdateUserPolicySuccess {
|
|
111
|
-
success: true;
|
|
112
|
-
}
|
|
113
|
-
export interface UpdateUserPolicyFailure {
|
|
114
|
-
success: false;
|
|
115
|
-
errorCode: ServerError | 'policy_too_large';
|
|
116
|
-
errorMessage: string;
|
|
117
|
-
}
|
|
118
|
-
export interface UpdateRolesUpdate {
|
|
119
|
-
/**
|
|
120
|
-
* The roles that should be assigned.
|
|
121
|
-
*/
|
|
122
|
-
roles: AssignedRole[];
|
|
123
|
-
}
|
|
124
157
|
export interface AssignedRole {
|
|
125
158
|
/**
|
|
126
159
|
* The name of the role.
|
|
@@ -141,17 +174,6 @@ export interface UpdateUserRolesFailure {
|
|
|
141
174
|
errorCode: ServerError | 'roles_too_large';
|
|
142
175
|
errorMessage: string;
|
|
143
176
|
}
|
|
144
|
-
export type ListUserPoliciesStoreResult = ListUserPoliciesStoreSuccess | ListUserPoliciesStoreFailure;
|
|
145
|
-
export interface ListUserPoliciesStoreSuccess {
|
|
146
|
-
success: true;
|
|
147
|
-
policies: ListedUserPolicy[];
|
|
148
|
-
totalCount: number;
|
|
149
|
-
}
|
|
150
|
-
export interface ListUserPoliciesStoreFailure {
|
|
151
|
-
success: false;
|
|
152
|
-
errorCode: ServerError;
|
|
153
|
-
errorMessage: string;
|
|
154
|
-
}
|
|
155
177
|
export interface ListedRoleAssignments {
|
|
156
178
|
assignments: RoleAssignment[];
|
|
157
179
|
totalCount: number;
|
|
@@ -167,25 +189,232 @@ export interface InstRoleAssignment {
|
|
|
167
189
|
inst: string;
|
|
168
190
|
role: AssignedRole;
|
|
169
191
|
}
|
|
170
|
-
|
|
192
|
+
/**
|
|
193
|
+
* Gets the expiration time that can be used for comparision.
|
|
194
|
+
* If given null, then this function returns Infinity.
|
|
195
|
+
* Otherwise, it returns the given time.
|
|
196
|
+
* @param expireTimeMs The time that the role expires in milliseconds.
|
|
197
|
+
*/
|
|
198
|
+
export declare function getExpireTime(expireTimeMs: number | null): number;
|
|
199
|
+
export type GetResourcePermissionResult = GetResourcePermissionSuccess | GetResourcePermissionFailure;
|
|
200
|
+
export interface GetResourcePermissionSuccess {
|
|
201
|
+
success: true;
|
|
171
202
|
/**
|
|
172
|
-
* The
|
|
203
|
+
* The permission that was assigned to the subject.
|
|
204
|
+
* Null if no permission was found.
|
|
173
205
|
*/
|
|
174
|
-
|
|
206
|
+
permissionAssignment: ResourcePermissionAssignment | null;
|
|
207
|
+
}
|
|
208
|
+
export interface GetResourcePermissionFailure {
|
|
209
|
+
success: false;
|
|
175
210
|
/**
|
|
176
|
-
* The
|
|
211
|
+
* The error code.
|
|
177
212
|
*/
|
|
178
|
-
|
|
213
|
+
errorCode: ServerError;
|
|
179
214
|
/**
|
|
180
|
-
* The
|
|
215
|
+
* The error message.
|
|
181
216
|
*/
|
|
182
|
-
|
|
217
|
+
errorMessage: string;
|
|
218
|
+
}
|
|
219
|
+
export interface PermissionAssignment {
|
|
220
|
+
/**
|
|
221
|
+
* The ID of the permission assignment.
|
|
222
|
+
*/
|
|
223
|
+
id: string;
|
|
224
|
+
/**
|
|
225
|
+
* The name of the record.
|
|
226
|
+
*/
|
|
227
|
+
recordName: string;
|
|
228
|
+
/**
|
|
229
|
+
* The kind of the actions that the subject is allowed to perform.
|
|
230
|
+
* Null if the subject is allowed to perform any action.
|
|
231
|
+
*/
|
|
232
|
+
action: ActionKinds | null;
|
|
233
|
+
/**
|
|
234
|
+
* The options for the permission assignment.
|
|
235
|
+
*/
|
|
236
|
+
options: PermissionOptions;
|
|
237
|
+
/**
|
|
238
|
+
* The ID of the subject.
|
|
239
|
+
*/
|
|
240
|
+
subjectId: string;
|
|
241
|
+
/**
|
|
242
|
+
* The type of the subject.
|
|
243
|
+
*/
|
|
244
|
+
subjectType: SubjectType;
|
|
245
|
+
/**
|
|
246
|
+
* The ID of the user that the assignment grants permission to.
|
|
247
|
+
* Null if the subject type is not "user".
|
|
248
|
+
*/
|
|
249
|
+
userId: string | null;
|
|
250
|
+
/**
|
|
251
|
+
* The time that the permission expires.
|
|
252
|
+
* Null if the permission never expires.
|
|
253
|
+
*/
|
|
254
|
+
expireTimeMs: number | null;
|
|
183
255
|
}
|
|
184
256
|
/**
|
|
185
|
-
*
|
|
186
|
-
* If given null, then this function returns Infinity.
|
|
187
|
-
* Otherwise, it returns the given time.
|
|
188
|
-
* @param expireTimeMs The time that the role expires in milliseconds.
|
|
257
|
+
* Defines an interface that represents a resource permission assignment.
|
|
189
258
|
*/
|
|
190
|
-
export
|
|
259
|
+
export interface ResourcePermissionAssignment extends PermissionAssignment {
|
|
260
|
+
/**
|
|
261
|
+
* The kind of the resource.
|
|
262
|
+
*/
|
|
263
|
+
resourceKind: ResourceKinds;
|
|
264
|
+
/**
|
|
265
|
+
* The ID of the resource.
|
|
266
|
+
*/
|
|
267
|
+
resourceId: string;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Defines an interface that represents a marker permission assignment.
|
|
271
|
+
*/
|
|
272
|
+
export interface MarkerPermissionAssignment extends PermissionAssignment {
|
|
273
|
+
/**
|
|
274
|
+
* The marker that the permission applies to.
|
|
275
|
+
*/
|
|
276
|
+
marker: string;
|
|
277
|
+
/**
|
|
278
|
+
* The kind of the resource.
|
|
279
|
+
* Null if the permission applies to all resources.
|
|
280
|
+
*/
|
|
281
|
+
resourceKind: ResourceKinds | null;
|
|
282
|
+
}
|
|
283
|
+
export type GetMarkerPermissionResult = GetMarkerPermissionSuccess | GetMarkerPermissionFailure;
|
|
284
|
+
export interface GetMarkerPermissionSuccess {
|
|
285
|
+
success: true;
|
|
286
|
+
/**
|
|
287
|
+
* The permission that was assigned to the subject.
|
|
288
|
+
* Null if no permission was found.
|
|
289
|
+
*/
|
|
290
|
+
permissionAssignment: MarkerPermissionAssignment | null;
|
|
291
|
+
}
|
|
292
|
+
export interface GetMarkerPermissionFailure {
|
|
293
|
+
success: false;
|
|
294
|
+
/**
|
|
295
|
+
* The error code.
|
|
296
|
+
*/
|
|
297
|
+
errorCode: ServerError;
|
|
298
|
+
/**
|
|
299
|
+
* The error message.
|
|
300
|
+
*/
|
|
301
|
+
errorMessage: string;
|
|
302
|
+
}
|
|
303
|
+
export type AssignPermissionToSubjectAndResourceResult = AssignPermissionToSubjectAndResourceSuccess | AssignPermissionToSubjectAndResourceFailure;
|
|
304
|
+
export interface AssignPermissionToSubjectAndResourceSuccess {
|
|
305
|
+
success: true;
|
|
306
|
+
/**
|
|
307
|
+
* The assignment that was created or updated.
|
|
308
|
+
*/
|
|
309
|
+
permissionAssignment: ResourcePermissionAssignment;
|
|
310
|
+
}
|
|
311
|
+
export interface AssignPermissionToSubjectAndResourceFailure {
|
|
312
|
+
success: false;
|
|
313
|
+
errorCode: ServerError | 'permission_already_exists';
|
|
314
|
+
errorMessage: string;
|
|
315
|
+
}
|
|
316
|
+
export type AssignPermissionToSubjectAndMarkerResult = AssignPermissionToSubjectAndMarkerSuccess | AssignPermissionToSubjectAndMarkerFailure;
|
|
317
|
+
export interface AssignPermissionToSubjectAndMarkerSuccess {
|
|
318
|
+
success: true;
|
|
319
|
+
/**
|
|
320
|
+
* The assignment that was created or updated.
|
|
321
|
+
*/
|
|
322
|
+
permissionAssignment: MarkerPermissionAssignment;
|
|
323
|
+
}
|
|
324
|
+
export interface AssignPermissionToSubjectAndMarkerFailure {
|
|
325
|
+
success: false;
|
|
326
|
+
errorCode: ServerError | 'permission_already_exists';
|
|
327
|
+
errorMessage: string;
|
|
328
|
+
}
|
|
329
|
+
export type DeletePermissionAssignmentResult = DeletePermissionAssignmentSuccess | DeletePermissionAssignmentFailure;
|
|
330
|
+
export interface DeletePermissionAssignmentSuccess {
|
|
331
|
+
success: true;
|
|
332
|
+
}
|
|
333
|
+
export interface DeletePermissionAssignmentFailure {
|
|
334
|
+
success: false;
|
|
335
|
+
errorCode: ServerError;
|
|
336
|
+
errorMessage: string;
|
|
337
|
+
}
|
|
338
|
+
export type ListPermissionsInRecordResult = ListPermissionsInRecordSuccess | ListPermissionsInRecordFailure;
|
|
339
|
+
export interface ListPermissionsInRecordSuccess {
|
|
340
|
+
success: true;
|
|
341
|
+
resourceAssignments: ResourcePermissionAssignment[];
|
|
342
|
+
markerAssignments: MarkerPermissionAssignment[];
|
|
343
|
+
}
|
|
344
|
+
export interface ListPermissionsInRecordFailure {
|
|
345
|
+
success: false;
|
|
346
|
+
errorCode: ServerError;
|
|
347
|
+
errorMessage: string;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Gets the publicRead permission for the given resource kind and action.
|
|
351
|
+
* @param resourceKind The kind of the resource.
|
|
352
|
+
* @param action The kind of the action.
|
|
353
|
+
*/
|
|
354
|
+
export declare function getPublicReadPermission(resourceKind: ResourceKinds, action: ActionKinds): {
|
|
355
|
+
resourceKind: "data";
|
|
356
|
+
action: "read" | "list";
|
|
357
|
+
} | {
|
|
358
|
+
resourceKind: "inst" | "file";
|
|
359
|
+
action: "read";
|
|
360
|
+
} | {
|
|
361
|
+
resourceKind: "event";
|
|
362
|
+
action: "count";
|
|
363
|
+
};
|
|
364
|
+
/**
|
|
365
|
+
* Gets the publicWrite permission for the given resource kind and action.
|
|
366
|
+
* @param resourceKind The kind of the resource.
|
|
367
|
+
* @param action The kind of the action.
|
|
368
|
+
*/
|
|
369
|
+
export declare function getPublicWritePermission(resourceKind: ResourceKinds, action: ActionKinds): {
|
|
370
|
+
resourceKind: "data";
|
|
371
|
+
action: "create" | "read" | "update" | "delete" | "list";
|
|
372
|
+
} | {
|
|
373
|
+
resourceKind: "file";
|
|
374
|
+
action: "create" | "read" | "delete";
|
|
375
|
+
} | {
|
|
376
|
+
resourceKind: "event";
|
|
377
|
+
action: "create" | "increment" | "count";
|
|
378
|
+
} | {
|
|
379
|
+
resourceKind: "inst";
|
|
380
|
+
action: "create" | "read" | "delete" | "sendAction" | "updateData";
|
|
381
|
+
};
|
|
382
|
+
export declare function getPublicMarkerPermission(marker: string, resourceKind: ResourceKinds, action: ActionKinds): {
|
|
383
|
+
resourceKind: "inst" | "file";
|
|
384
|
+
action: "read";
|
|
385
|
+
} | {
|
|
386
|
+
resourceKind: "data";
|
|
387
|
+
action: "create" | "read" | "update" | "delete" | "list";
|
|
388
|
+
} | {
|
|
389
|
+
resourceKind: "file";
|
|
390
|
+
action: "create" | "read" | "delete";
|
|
391
|
+
} | {
|
|
392
|
+
resourceKind: "event";
|
|
393
|
+
action: "create" | "increment" | "count";
|
|
394
|
+
} | {
|
|
395
|
+
resourceKind: "inst";
|
|
396
|
+
action: "create" | "read" | "delete" | "sendAction" | "updateData";
|
|
397
|
+
};
|
|
398
|
+
export declare function getPublicMarkersPermission(markers: string[], resourceKind: ResourceKinds, action: ActionKinds): {
|
|
399
|
+
resourceKind: "inst" | "file";
|
|
400
|
+
action: "read";
|
|
401
|
+
marker: string;
|
|
402
|
+
} | {
|
|
403
|
+
resourceKind: "data";
|
|
404
|
+
action: "create" | "read" | "update" | "delete" | "list";
|
|
405
|
+
marker: string;
|
|
406
|
+
} | {
|
|
407
|
+
resourceKind: "file";
|
|
408
|
+
action: "create" | "read" | "delete";
|
|
409
|
+
marker: string;
|
|
410
|
+
} | {
|
|
411
|
+
resourceKind: "event";
|
|
412
|
+
action: "create" | "increment" | "count";
|
|
413
|
+
marker: string;
|
|
414
|
+
} | {
|
|
415
|
+
resourceKind: "inst";
|
|
416
|
+
action: "create" | "read" | "delete" | "sendAction" | "updateData";
|
|
417
|
+
marker: string;
|
|
418
|
+
};
|
|
419
|
+
export declare function getSubjectUserId(subjectType: SubjectType, subjectId: string): string | null;
|
|
191
420
|
//# sourceMappingURL=PolicyStore.d.ts.map
|
package/PolicyStore.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
import { PUBLIC_READ_MARKER, PUBLIC_WRITE_MARKER, } from '@casual-simulation/aux-common';
|
|
2
|
+
// export interface ListMarkerPoliciesResult {
|
|
3
|
+
// /**
|
|
4
|
+
// * The policies that were returned.
|
|
5
|
+
// */
|
|
6
|
+
// policies: PolicyDocument[];
|
|
7
|
+
// /**
|
|
8
|
+
// * The privacy features that are enabled for the record owner.
|
|
9
|
+
// */
|
|
10
|
+
// recordOwnerPrivacyFeatures: PrivacyFeatures;
|
|
11
|
+
// /**
|
|
12
|
+
// * The privacy features that are enabled for the user.
|
|
13
|
+
// */
|
|
14
|
+
// userPrivacyFeatures: PrivacyFeatures;
|
|
15
|
+
// }
|
|
1
16
|
/**
|
|
2
17
|
* Gets the expiration time that can be used for comparision.
|
|
3
18
|
* If given null, then this function returns Infinity.
|
|
@@ -7,4 +22,114 @@
|
|
|
7
22
|
export function getExpireTime(expireTimeMs) {
|
|
8
23
|
return expireTimeMs !== null && expireTimeMs !== void 0 ? expireTimeMs : Infinity;
|
|
9
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Gets the publicRead permission for the given resource kind and action.
|
|
27
|
+
* @param resourceKind The kind of the resource.
|
|
28
|
+
* @param action The kind of the action.
|
|
29
|
+
*/
|
|
30
|
+
export function getPublicReadPermission(resourceKind, action) {
|
|
31
|
+
if (resourceKind === 'data') {
|
|
32
|
+
// data.read and data.list
|
|
33
|
+
if (action === 'read' || action === 'list') {
|
|
34
|
+
return {
|
|
35
|
+
resourceKind,
|
|
36
|
+
action,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else if (resourceKind === 'file' || resourceKind === 'inst') {
|
|
41
|
+
// file.read, inst.read
|
|
42
|
+
if (action === 'read') {
|
|
43
|
+
return {
|
|
44
|
+
resourceKind,
|
|
45
|
+
action,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else if (resourceKind === 'event') {
|
|
50
|
+
// event.count
|
|
51
|
+
if (action === 'count') {
|
|
52
|
+
return {
|
|
53
|
+
resourceKind,
|
|
54
|
+
action,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// All other actions are not allowed.
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Gets the publicWrite permission for the given resource kind and action.
|
|
63
|
+
* @param resourceKind The kind of the resource.
|
|
64
|
+
* @param action The kind of the action.
|
|
65
|
+
*/
|
|
66
|
+
export function getPublicWritePermission(resourceKind, action) {
|
|
67
|
+
if (resourceKind === 'data') {
|
|
68
|
+
if (action === 'read' ||
|
|
69
|
+
action === 'create' ||
|
|
70
|
+
action === 'update' ||
|
|
71
|
+
action === 'delete' ||
|
|
72
|
+
action === 'list') {
|
|
73
|
+
return {
|
|
74
|
+
resourceKind,
|
|
75
|
+
action,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (resourceKind === 'file') {
|
|
80
|
+
if (action === 'read' || action === 'delete' || action === 'create') {
|
|
81
|
+
return {
|
|
82
|
+
resourceKind,
|
|
83
|
+
action,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else if (resourceKind === 'event') {
|
|
88
|
+
if (action === 'increment' ||
|
|
89
|
+
action === 'count' ||
|
|
90
|
+
action === 'create') {
|
|
91
|
+
return {
|
|
92
|
+
resourceKind,
|
|
93
|
+
action,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (resourceKind === 'inst') {
|
|
98
|
+
if (action === 'read' ||
|
|
99
|
+
action === 'updateData' ||
|
|
100
|
+
action === 'sendAction' ||
|
|
101
|
+
action === 'delete' ||
|
|
102
|
+
action === 'create') {
|
|
103
|
+
return {
|
|
104
|
+
resourceKind,
|
|
105
|
+
action,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
export function getPublicMarkerPermission(marker, resourceKind, action) {
|
|
112
|
+
if (marker === PUBLIC_READ_MARKER) {
|
|
113
|
+
return getPublicReadPermission(resourceKind, action);
|
|
114
|
+
}
|
|
115
|
+
else if (marker === PUBLIC_WRITE_MARKER) {
|
|
116
|
+
return getPublicWritePermission(resourceKind, action);
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
export function getPublicMarkersPermission(markers, resourceKind, action) {
|
|
121
|
+
for (let marker of markers) {
|
|
122
|
+
const result = getPublicMarkerPermission(marker, resourceKind, action);
|
|
123
|
+
if (result) {
|
|
124
|
+
return Object.assign({ marker }, result);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
export function getSubjectUserId(subjectType, subjectId) {
|
|
130
|
+
if (subjectType === 'user') {
|
|
131
|
+
return subjectId;
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
10
135
|
//# sourceMappingURL=PolicyStore.js.map
|
package/PolicyStore.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PolicyStore.js","sourceRoot":"","sources":["PolicyStore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PolicyStore.js","sourceRoot":"","sources":["PolicyStore.ts"],"names":[],"mappings":"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"}
|
package/RecordsServer.d.ts
CHANGED
|
@@ -60,10 +60,9 @@ export declare class RecordsServer {
|
|
|
60
60
|
private _listRecords;
|
|
61
61
|
private _createRecord;
|
|
62
62
|
private _createRecordKey;
|
|
63
|
-
private
|
|
64
|
-
private
|
|
65
|
-
private
|
|
66
|
-
private _policyList;
|
|
63
|
+
private _grantPermission;
|
|
64
|
+
private _revokePermission;
|
|
65
|
+
private _listPermissions;
|
|
67
66
|
private _roleUserList;
|
|
68
67
|
private _roleInstList;
|
|
69
68
|
private _roleAssignmentsList;
|