lean-s3 0.1.6 → 0.2.1
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/README.md +14 -2
- package/dist/AmzDate.d.ts +7 -0
- package/dist/AmzDate.js +29 -0
- package/dist/KeyCache.d.ts +5 -0
- package/dist/KeyCache.js +21 -0
- package/dist/S3BucketEntry.d.ts +18 -0
- package/dist/S3BucketEntry.js +29 -0
- package/dist/S3Client.d.ts +175 -0
- package/dist/S3Client.js +610 -0
- package/dist/S3Error.d.ts +14 -0
- package/dist/S3Error.js +15 -0
- package/dist/S3File.d.ts +72 -0
- package/dist/S3File.js +195 -0
- package/dist/S3Stat.d.ts +9 -0
- package/dist/S3Stat.js +35 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +5 -0
- package/dist/index.test.d.ts +1 -0
- package/dist/sign.d.ts +16 -0
- package/dist/sign.js +77 -0
- package/dist/sign.test.d.ts +1 -0
- package/dist/test-common.d.ts +4 -0
- package/dist/test.integration.d.ts +1 -0
- package/dist/test.integration.js +19 -0
- package/dist/url.d.ts +9 -0
- package/dist/url.js +52 -0
- package/dist/url.test.d.ts +1 -0
- package/package.json +18 -14
- package/src/AmzDate.js +0 -56
- package/src/KeyCache.js +0 -36
- package/src/S3BucketEntry.js +0 -91
- package/src/S3Client.js +0 -800
- package/src/S3Error.js +0 -55
- package/src/S3File.js +0 -291
- package/src/S3Stat.js +0 -68
- package/src/index.d.ts +0 -105
- package/src/index.js +0 -4
- package/src/sign.js +0 -145
- package/src/url.js +0 -87
package/src/KeyCache.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as sign from "./sign.js";
|
|
2
|
-
|
|
3
|
-
/**@typedef {import("./AmzDate.js").AmzDate} AmzDate */
|
|
4
|
-
|
|
5
|
-
export default class KeyCache {
|
|
6
|
-
/** @type {number} */
|
|
7
|
-
#lastNumericDay = -1;
|
|
8
|
-
/** @type {Map<string, Buffer>} */
|
|
9
|
-
#keys = new Map();
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @param {AmzDate} date
|
|
13
|
-
* @param {string} region
|
|
14
|
-
* @param {string} accessKeyId
|
|
15
|
-
* @param {string} secretAccessKey
|
|
16
|
-
* @returns {Buffer}
|
|
17
|
-
*/
|
|
18
|
-
computeIfAbsent(date, region, accessKeyId, secretAccessKey) {
|
|
19
|
-
if (date.numericDayStart !== this.#lastNumericDay) {
|
|
20
|
-
this.#keys.clear();
|
|
21
|
-
this.#lastNumericDay = date.numericDayStart;
|
|
22
|
-
// TODO: Add mechanism to clear the cache after some time
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// using accessKeyId to prevent keeping the secretAccessKey somewhere
|
|
26
|
-
const cacheKey = `${date.date}:${region}:${accessKeyId}`;
|
|
27
|
-
const key = this.#keys.get(cacheKey);
|
|
28
|
-
if (key) {
|
|
29
|
-
return key;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const newKey = sign.deriveSigningKey(date.date, region, secretAccessKey);
|
|
33
|
-
this.#keys.set(cacheKey, newKey);
|
|
34
|
-
return newKey;
|
|
35
|
-
}
|
|
36
|
-
}
|
package/src/S3BucketEntry.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {import("./index.js").StorageClass} StorageClass
|
|
3
|
-
* @typedef {import("./index.js").ChecksumAlgorithm} ChecksumAlgorithm
|
|
4
|
-
* @typedef {import("./index.js").ChecksumType} ChecksumType
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @internal Normally, we'd use an interface for that, but having a class with pre-defined fields makes it easier for V8 top optimize hidden classes.
|
|
9
|
-
*/
|
|
10
|
-
export default class S3BucketEntry {
|
|
11
|
-
/**
|
|
12
|
-
* @readonly
|
|
13
|
-
* @type {string}
|
|
14
|
-
*/
|
|
15
|
-
key;
|
|
16
|
-
/**
|
|
17
|
-
* @readonly
|
|
18
|
-
* @type {number}
|
|
19
|
-
*/
|
|
20
|
-
size;
|
|
21
|
-
/**
|
|
22
|
-
* @readonly
|
|
23
|
-
* @type {Date}
|
|
24
|
-
*/
|
|
25
|
-
lastModified;
|
|
26
|
-
/**
|
|
27
|
-
* @readonly
|
|
28
|
-
* @type {string}
|
|
29
|
-
*/
|
|
30
|
-
etag;
|
|
31
|
-
/**
|
|
32
|
-
* @readonly
|
|
33
|
-
* @type {StorageClass}
|
|
34
|
-
*/
|
|
35
|
-
storageClass;
|
|
36
|
-
/**
|
|
37
|
-
* @readonly
|
|
38
|
-
* @type {ChecksumAlgorithm | undefined}
|
|
39
|
-
*/
|
|
40
|
-
checksumAlgorithm;
|
|
41
|
-
/**
|
|
42
|
-
* @readonly
|
|
43
|
-
* @type {ChecksumType | undefined}
|
|
44
|
-
*/
|
|
45
|
-
checksumType;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @param {string} key
|
|
49
|
-
* @param {number} size
|
|
50
|
-
* @param {Date} lastModified
|
|
51
|
-
* @param {string} etag
|
|
52
|
-
* @param {StorageClass} storageClass
|
|
53
|
-
* @param {ChecksumAlgorithm | undefined} checksumAlgorithm
|
|
54
|
-
* @param {ChecksumType | undefined} checksumType
|
|
55
|
-
*/
|
|
56
|
-
constructor(
|
|
57
|
-
key,
|
|
58
|
-
size,
|
|
59
|
-
lastModified,
|
|
60
|
-
etag,
|
|
61
|
-
storageClass,
|
|
62
|
-
checksumAlgorithm,
|
|
63
|
-
checksumType,
|
|
64
|
-
) {
|
|
65
|
-
this.key = key;
|
|
66
|
-
this.size = size;
|
|
67
|
-
this.lastModified = lastModified;
|
|
68
|
-
this.etag = etag;
|
|
69
|
-
this.storageClass = storageClass;
|
|
70
|
-
this.checksumAlgorithm = checksumAlgorithm;
|
|
71
|
-
this.checksumType = checksumType;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @internal
|
|
76
|
-
* @param {any} source
|
|
77
|
-
* @returns {S3BucketEntry}
|
|
78
|
-
*/
|
|
79
|
-
static parse(source) {
|
|
80
|
-
// TODO: check values and throw exceptions
|
|
81
|
-
return new S3BucketEntry(
|
|
82
|
-
source.Key,
|
|
83
|
-
source.Size,
|
|
84
|
-
new Date(source.LastModified),
|
|
85
|
-
source.ETag,
|
|
86
|
-
source.StorageClass,
|
|
87
|
-
source.ChecksumAlgorithm,
|
|
88
|
-
source.ChecksumType,
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
}
|