@casual-simulation/aux-records-aws 3.2.2 → 3.2.4-alpha.5857788915

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.
@@ -1,401 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { signRequest, } from '@casual-simulation/aux-records';
11
- import { PUBLIC_READ_MARKER } from '@casual-simulation/aux-records/PolicyPermissions';
12
- import AWS from 'aws-sdk';
13
- export const EMPTY_STRING_SHA256_HASH_HEX = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';
14
- /**
15
- * Defines a class that can manage file records in DynamoDB and S3.
16
- */
17
- export class DynamoDBFileStore {
18
- constructor(region, bucket, documentClient, tableName, storageClass = 'STANDARD', aws = AWS, s3Host = null, s3Options = {}) {
19
- this._region = region;
20
- this._bucket = bucket;
21
- this._dynamo = documentClient;
22
- this._tableName = tableName;
23
- this._storageClass = storageClass;
24
- this._aws = aws;
25
- this._s3Host = s3Host;
26
- this._s3Options = s3Options;
27
- }
28
- getAllowedUploadHeaders() {
29
- return [
30
- 'content-type',
31
- 'content-length',
32
- 'cache-control',
33
- 'x-amz-acl',
34
- 'x-amz-storage-class',
35
- 'x-amz-security-token',
36
- ];
37
- }
38
- getFileNameFromUrl(fileUrl) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const host = this._fileHost();
41
- if (fileUrl.startsWith(host)) {
42
- let recordNameAndFileName = fileUrl.slice(host.length + 1);
43
- let firstSlash = recordNameAndFileName.indexOf('/');
44
- if (firstSlash < 0) {
45
- return {
46
- success: false,
47
- errorCode: 'unacceptable_url',
48
- errorMessage: 'The URL does not match an expected format.',
49
- };
50
- }
51
- let recordName = recordNameAndFileName.slice(0, firstSlash);
52
- let fileName = recordNameAndFileName.slice(firstSlash + 1);
53
- if (recordName && fileName) {
54
- return {
55
- success: true,
56
- recordName,
57
- fileName,
58
- };
59
- }
60
- return {
61
- success: false,
62
- errorCode: 'unacceptable_url',
63
- errorMessage: 'The URL does not match an expected format.',
64
- };
65
- }
66
- return {
67
- success: false,
68
- errorCode: 'unacceptable_url',
69
- errorMessage: 'The URL does not match an expected format.',
70
- };
71
- });
72
- }
73
- presignFileUpload(request) {
74
- var _a;
75
- return __awaiter(this, void 0, void 0, function* () {
76
- const credentials = yield this._getCredentials();
77
- const secretAccessKey = credentials
78
- ? credentials.secretAccessKey
79
- : null;
80
- const accessKeyId = credentials ? credentials.accessKeyId : null;
81
- const now = (_a = request.date) !== null && _a !== void 0 ? _a : new Date();
82
- const fileUrl = this._fileUrl(request.recordName, request.fileName);
83
- const requiredHeaders = {
84
- 'content-type': request.fileMimeType,
85
- 'content-length': request.fileByteLength.toString(),
86
- 'cache-control': 'max-age=31536000',
87
- 'x-amz-acl': s3AclForMarkers(request.markers),
88
- 'x-amz-storage-class': this._storageClass,
89
- host: fileUrl.host,
90
- };
91
- if (credentials && credentials.sessionToken) {
92
- requiredHeaders['x-amz-security-token'] =
93
- credentials.sessionToken;
94
- }
95
- const result = signRequest({
96
- method: 'PUT',
97
- payloadSha256Hex: request.fileSha256Hex,
98
- headers: Object.assign(Object.assign({}, request.headers), requiredHeaders),
99
- queryString: {},
100
- path: fileUrl.pathname,
101
- }, secretAccessKey, accessKeyId, now, this._region, 's3');
102
- return {
103
- success: true,
104
- uploadUrl: fileUrl.href,
105
- uploadHeaders: result.headers,
106
- uploadMethod: result.method,
107
- };
108
- });
109
- }
110
- presignFileRead(request) {
111
- var _a;
112
- return __awaiter(this, void 0, void 0, function* () {
113
- const credentials = yield this._getCredentials();
114
- const secretAccessKey = credentials
115
- ? credentials.secretAccessKey
116
- : null;
117
- const accessKeyId = credentials ? credentials.accessKeyId : null;
118
- const now = (_a = request.date) !== null && _a !== void 0 ? _a : new Date();
119
- const fileUrl = this._fileUrl(request.recordName, request.fileName);
120
- const requiredHeaders = {
121
- host: fileUrl.host,
122
- };
123
- if (credentials && credentials.sessionToken) {
124
- requiredHeaders['x-amz-security-token'] =
125
- credentials.sessionToken;
126
- }
127
- const result = signRequest({
128
- method: 'GET',
129
- payloadSha256Hex: EMPTY_STRING_SHA256_HASH_HEX,
130
- headers: Object.assign(Object.assign({}, request.headers), requiredHeaders),
131
- queryString: {
132
- 'response-cache-control': 'max-age=31536000',
133
- },
134
- path: fileUrl.pathname,
135
- }, secretAccessKey, accessKeyId, now, this._region, 's3');
136
- const url = new URL(fileUrl.href);
137
- for (let key in result.queryString) {
138
- url.searchParams.set(key, result.queryString[key]);
139
- }
140
- return {
141
- success: true,
142
- requestUrl: url.href,
143
- requestHeaders: result.headers,
144
- requestMethod: result.method,
145
- };
146
- });
147
- }
148
- getFileRecord(recordName, fileName) {
149
- return __awaiter(this, void 0, void 0, function* () {
150
- try {
151
- const result = yield this._dynamo
152
- .get({
153
- TableName: this._tableName,
154
- Key: {
155
- recordName: recordName,
156
- fileName: fileName,
157
- },
158
- })
159
- .promise();
160
- if (result.Item) {
161
- const file = result.Item;
162
- let url = this._fileUrl(file.recordName, file.fileName);
163
- return {
164
- success: true,
165
- recordName: file.recordName,
166
- fileName: file.fileName,
167
- description: file.description,
168
- publisherId: file.publisherId,
169
- subjectId: file.subjectId,
170
- sizeInBytes: file.sizeInBytes,
171
- uploaded: file.uploadTime !== null,
172
- url: url.href,
173
- markers: file.markers,
174
- };
175
- }
176
- else {
177
- return {
178
- success: false,
179
- errorCode: 'file_not_found',
180
- errorMessage: 'The file was not found.',
181
- };
182
- }
183
- }
184
- catch (err) {
185
- console.error(err);
186
- return {
187
- success: false,
188
- errorCode: 'server_error',
189
- errorMessage: 'An unexpected error occurred.',
190
- };
191
- }
192
- });
193
- }
194
- addFileRecord(recordName, fileName, publisherId, subjectId, sizeInBytes, description, markers) {
195
- return __awaiter(this, void 0, void 0, function* () {
196
- try {
197
- const publishTime = Date.now();
198
- const file = {
199
- recordName,
200
- fileName,
201
- publisherId,
202
- subjectId,
203
- sizeInBytes,
204
- description,
205
- publishTime,
206
- uploadTime: null,
207
- markers,
208
- };
209
- yield this._dynamo
210
- .put({
211
- TableName: this._tableName,
212
- Item: file,
213
- ConditionExpression: 'attribute_not_exists(recordName) AND attribute_not_exists(fileName)',
214
- })
215
- .promise();
216
- return {
217
- success: true,
218
- };
219
- }
220
- catch (err) {
221
- if (err instanceof Error &&
222
- err.name === 'ConditionalCheckFailedException') {
223
- return {
224
- success: false,
225
- errorCode: 'file_already_exists',
226
- errorMessage: 'The file already exists.',
227
- };
228
- }
229
- else {
230
- console.error(err);
231
- return {
232
- success: false,
233
- errorCode: 'server_error',
234
- errorMessage: 'An unexpected error occurred.',
235
- };
236
- }
237
- }
238
- });
239
- }
240
- updateFileRecord(recordName, fileName, markers) {
241
- return __awaiter(this, void 0, void 0, function* () {
242
- try {
243
- yield this._dynamo
244
- .update({
245
- TableName: this._tableName,
246
- Key: {
247
- recordName: recordName,
248
- fileName: fileName,
249
- },
250
- ConditionExpression: 'attribute_exists(recordName) AND attribute_exists(fileName)',
251
- UpdateExpression: 'SET markers = :markers',
252
- ExpressionAttributeValues: {
253
- ':markers': markers,
254
- },
255
- })
256
- .promise();
257
- return {
258
- success: true,
259
- };
260
- }
261
- catch (err) {
262
- if (err instanceof Error &&
263
- err.name === 'ConditionalCheckFailedException') {
264
- return {
265
- success: false,
266
- errorCode: 'file_not_found',
267
- errorMessage: 'The file was not found.',
268
- };
269
- }
270
- else {
271
- console.error(err);
272
- return {
273
- success: false,
274
- errorCode: 'server_error',
275
- errorMessage: 'An unexpected error occurred.',
276
- };
277
- }
278
- }
279
- });
280
- }
281
- setFileRecordAsUploaded(recordName, fileName) {
282
- return __awaiter(this, void 0, void 0, function* () {
283
- try {
284
- yield this._dynamo
285
- .update({
286
- TableName: this._tableName,
287
- Key: {
288
- recordName: recordName,
289
- fileName: fileName,
290
- },
291
- ConditionExpression: 'attribute_exists(recordName) AND attribute_exists(fileName)',
292
- UpdateExpression: 'SET uploadTime = :uploadTime',
293
- ExpressionAttributeValues: {
294
- ':uploadTime': Date.now(),
295
- },
296
- })
297
- .promise();
298
- return {
299
- success: true,
300
- };
301
- }
302
- catch (err) {
303
- if (err instanceof Error &&
304
- err.name === 'ConditionalCheckFailedException') {
305
- return {
306
- success: false,
307
- errorCode: 'file_not_found',
308
- errorMessage: 'The file was not found.',
309
- };
310
- }
311
- else {
312
- console.error(err);
313
- return {
314
- success: false,
315
- errorCode: 'server_error',
316
- errorMessage: 'An unexpected error occurred.',
317
- };
318
- }
319
- }
320
- });
321
- }
322
- eraseFileRecord(recordName, fileName) {
323
- return __awaiter(this, void 0, void 0, function* () {
324
- try {
325
- yield this._dynamo
326
- .delete({
327
- TableName: this._tableName,
328
- Key: {
329
- recordName: recordName,
330
- fileName: fileName,
331
- },
332
- })
333
- .promise();
334
- const s3 = this._getS3();
335
- const key = this._fileKey(recordName, fileName);
336
- yield s3
337
- .deleteObject({
338
- Bucket: this._bucket,
339
- Key: key,
340
- })
341
- .promise();
342
- return {
343
- success: true,
344
- };
345
- }
346
- catch (err) {
347
- console.error(err);
348
- return {
349
- success: false,
350
- errorCode: 'server_error',
351
- errorMessage: 'An unexpected error occurred.',
352
- };
353
- }
354
- });
355
- }
356
- _getCredentials() {
357
- return new Promise((resolve, reject) => {
358
- this._aws.config.getCredentials(function (err, credentials) {
359
- if (err) {
360
- reject(err);
361
- }
362
- else {
363
- resolve(credentials);
364
- }
365
- });
366
- });
367
- }
368
- _getS3() {
369
- if (!this._s3) {
370
- this._s3 = new this._aws.S3(this._s3Options);
371
- }
372
- return this._s3;
373
- }
374
- _fileUrl(recordName, fileName) {
375
- let filePath = this._fileKey(recordName, fileName);
376
- if (this._s3Host) {
377
- filePath = `${this._s3Host}/${this._bucket}/${filePath}`;
378
- }
379
- return new URL(filePath, `https://${this._bucket}.s3.amazonaws.com`);
380
- }
381
- _fileHost() {
382
- if (this._s3Host) {
383
- return this._s3Host;
384
- }
385
- return `https://${this._bucket}.s3.amazonaws.com`;
386
- }
387
- _fileKey(recordName, fileName) {
388
- return `${recordName}/${fileName}`;
389
- }
390
- }
391
- /**
392
- * Gets the Access Control List (ACL) that should be used for files uploaded with the given markers.
393
- * @param markers The markers that are applied to the file.
394
- */
395
- export function s3AclForMarkers(markers) {
396
- if (markers.some((m) => m === PUBLIC_READ_MARKER)) {
397
- return 'public-read';
398
- }
399
- return 'private';
400
- }
401
- //# sourceMappingURL=DynamoDBFileStore.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DynamoDBFileStore.js","sourceRoot":"","sources":["DynamoDBFileStore.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAKH,WAAW,GACd,MAAM,gCAAgC,CAAC;AAUxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AACtF,OAAO,GAAG,MAAM,SAAS,CAAC;AAG1B,MAAM,CAAC,MAAM,4BAA4B,GACrC,kEAAkE,CAAC;AAEvE;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAW1B,YACI,MAAc,EACd,MAAc,EACd,cAAuC,EACvC,SAAiB,EACjB,eAAuB,UAAU,EACjC,MAAkB,GAAG,EACrB,SAAiB,IAAI,EACrB,YAAwC,EAAE;QAE1C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,IAAI,GA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,EAAE;QAC/C,OAAO,aAAa,CAAC;KACxB;IAED,OAAO,SAAS,CAAC;AACrB,CAAC"}
@@ -1,27 +0,0 @@
1
- import { AssignedRole, GetUserPolicyResult, ListedRoleAssignments, PolicyDocument, PolicyStore, UpdateRolesUpdate, UpdateUserPolicyResult, UpdateUserRolesResult, UserPolicyRecord } from '@casual-simulation/aux-records';
2
- import { ListUserPoliciesStoreResult } from '@casual-simulation/aux-records/PolicyStore';
3
- import dynamodb from 'aws-sdk/clients/dynamodb';
4
- /**
5
- * Defines a PolicyStore that can store data items in DynamoDB.
6
- */
7
- export declare class DynamoDBPolicyStore implements PolicyStore {
8
- private _dynamo;
9
- private _policiesTableName;
10
- private _subjectRolesTableName;
11
- private _roleSubjectsTableName;
12
- private _rolesTableName;
13
- constructor(client: dynamodb.DocumentClient, policiesTableName: string, subjectRolesTableName: string, roleSubjectsTableName: string, rolesTableName: string);
14
- listPoliciesForMarker(recordName: string, marker: string): Promise<PolicyDocument[]>;
15
- listUserPolicies(recordName: string, startingMarker: string | null): Promise<ListUserPoliciesStoreResult>;
16
- listRolesForUser(recordName: string, userId: string): Promise<AssignedRole[]>;
17
- listRolesForInst(recordName: string, inst: string): Promise<AssignedRole[]>;
18
- listAssignmentsForRole(recordName: string, role: string): Promise<ListedRoleAssignments>;
19
- getUserPolicy(recordName: string, marker: string): Promise<GetUserPolicyResult>;
20
- updateUserPolicy(recordName: string, marker: string, policy: UserPolicyRecord): Promise<UpdateUserPolicyResult>;
21
- assignSubjectRole(recordName: string, subjectId: string, type: 'user' | 'inst', role: AssignedRole): Promise<UpdateUserRolesResult>;
22
- revokeSubjectRole(recordName: string, subjectId: string, type: 'user' | 'inst', role: string): Promise<UpdateUserRolesResult>;
23
- updateUserRoles(recordName: string, userId: string, update: UpdateRolesUpdate): Promise<UpdateUserRolesResult>;
24
- updateInstRoles(recordName: string, inst: string, update: UpdateRolesUpdate): Promise<UpdateUserRolesResult>;
25
- private _updateRoles;
26
- }
27
- //# sourceMappingURL=DynamoDBPolicyStore.d.ts.map