@hot-updater/aws 0.21.10 → 0.21.12
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/dist/index.cjs +84 -85
- package/dist/index.d.cts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +85 -86
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -1457,98 +1457,97 @@ async function invalidateCloudFront(client, distributionId, paths) {
|
|
|
1457
1457
|
}
|
|
1458
1458
|
}));
|
|
1459
1459
|
}
|
|
1460
|
-
const s3Database = (
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
});
|
|
1483
|
-
};
|
|
1460
|
+
const s3Database = (0, __hot_updater_plugin_core.createBlobDatabasePlugin)({
|
|
1461
|
+
name: "s3Database",
|
|
1462
|
+
factory: (config) => {
|
|
1463
|
+
const { bucketName, cloudfrontDistributionId, apiBasePath = "/api/check-update",...s3Config } = config;
|
|
1464
|
+
const client = new __aws_sdk_client_s3.S3Client(s3Config);
|
|
1465
|
+
const cloudfrontClient = cloudfrontDistributionId ? new __aws_sdk_client_cloudfront.CloudFrontClient({
|
|
1466
|
+
credentials: s3Config.credentials,
|
|
1467
|
+
region: s3Config.region
|
|
1468
|
+
}) : void 0;
|
|
1469
|
+
return {
|
|
1470
|
+
apiBasePath,
|
|
1471
|
+
listObjects: (prefix) => listObjectsInS3(client, bucketName, prefix),
|
|
1472
|
+
loadObject: (key) => loadJsonFromS3(client, bucketName, key),
|
|
1473
|
+
uploadObject: (key, data) => uploadJsonToS3(client, bucketName, key, data),
|
|
1474
|
+
deleteObject: (key) => deleteObjectInS3(client, bucketName, key),
|
|
1475
|
+
invalidatePaths: (pathsToInvalidate) => {
|
|
1476
|
+
if (cloudfrontClient && cloudfrontDistributionId && pathsToInvalidate.length > 0) return invalidateCloudFront(cloudfrontClient, cloudfrontDistributionId, pathsToInvalidate);
|
|
1477
|
+
return Promise.resolve();
|
|
1478
|
+
}
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
});
|
|
1484
1482
|
|
|
1485
1483
|
//#endregion
|
|
1486
1484
|
//#region src/s3Storage.ts
|
|
1487
|
-
const s3Storage = (
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
Prefix: key
|
|
1500
|
-
});
|
|
1501
|
-
const listResponse = await client.send(listCommand);
|
|
1502
|
-
if (listResponse.Contents && listResponse.Contents.length > 0) {
|
|
1503
|
-
const deleteCommand = new __aws_sdk_client_s3.DeleteObjectsCommand({
|
|
1485
|
+
const s3Storage = (0, __hot_updater_plugin_core.createStoragePlugin)({
|
|
1486
|
+
name: "s3Storage",
|
|
1487
|
+
supportedProtocol: "s3",
|
|
1488
|
+
factory: (config) => {
|
|
1489
|
+
const { bucketName,...s3Config } = config;
|
|
1490
|
+
const client = new __aws_sdk_client_s3.S3Client(s3Config);
|
|
1491
|
+
const getStorageKey = (0, __hot_updater_plugin_core.createStorageKeyBuilder)(config.basePath);
|
|
1492
|
+
return {
|
|
1493
|
+
async delete(storageUri) {
|
|
1494
|
+
const { bucket, key } = (0, __hot_updater_plugin_core.parseStorageUri)(storageUri, "s3");
|
|
1495
|
+
if (bucket !== bucketName) throw new Error(`Bucket name mismatch: expected "${bucketName}", but found "${bucket}".`);
|
|
1496
|
+
const listCommand = new __aws_sdk_client_s3.ListObjectsV2Command({
|
|
1504
1497
|
Bucket: bucketName,
|
|
1505
|
-
|
|
1506
|
-
Objects: listResponse.Contents.map((obj) => ({ Key: obj.Key })),
|
|
1507
|
-
Quiet: true
|
|
1508
|
-
}
|
|
1498
|
+
Prefix: key
|
|
1509
1499
|
});
|
|
1510
|
-
await client.send(
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1500
|
+
const listResponse = await client.send(listCommand);
|
|
1501
|
+
if (listResponse.Contents && listResponse.Contents.length > 0) {
|
|
1502
|
+
const deleteCommand = new __aws_sdk_client_s3.DeleteObjectsCommand({
|
|
1503
|
+
Bucket: bucketName,
|
|
1504
|
+
Delete: {
|
|
1505
|
+
Objects: listResponse.Contents.map((obj) => ({ Key: obj.Key })),
|
|
1506
|
+
Quiet: true
|
|
1507
|
+
}
|
|
1508
|
+
});
|
|
1509
|
+
await client.send(deleteCommand);
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1512
|
+
throw new Error("Bundle Not Found");
|
|
1513
|
+
},
|
|
1514
|
+
async upload(key, filePath) {
|
|
1515
|
+
const Body = await fs_promises.default.readFile(filePath);
|
|
1516
|
+
const ContentType = (0, __hot_updater_plugin_core.getContentType)(filePath);
|
|
1517
|
+
const Key = getStorageKey(key, path.default.basename(filePath));
|
|
1518
|
+
const response = await new __aws_sdk_lib_storage.Upload({
|
|
1519
|
+
client,
|
|
1520
|
+
params: {
|
|
1521
|
+
ContentType,
|
|
1522
|
+
Bucket: bucketName,
|
|
1523
|
+
Key,
|
|
1524
|
+
Body,
|
|
1525
|
+
CacheControl: "max-age=31536000"
|
|
1526
|
+
}
|
|
1527
|
+
}).done();
|
|
1528
|
+
if (!response.Bucket || !response.Key) throw new Error("Upload Failed");
|
|
1529
|
+
return { storageUri: `s3://${bucketName}/${Key}` };
|
|
1530
|
+
},
|
|
1531
|
+
async getDownloadUrl(storageUri) {
|
|
1532
|
+
const u = new URL(storageUri);
|
|
1533
|
+
if (u.protocol.replace(":", "") !== "s3") throw new Error("Invalid S3 storage URI protocol");
|
|
1534
|
+
const bucket = u.host;
|
|
1535
|
+
const key = u.pathname.slice(1);
|
|
1536
|
+
if (!bucket || !key) throw new Error("Invalid S3 storage URI: missing bucket or key");
|
|
1537
|
+
try {
|
|
1538
|
+
const signedUrl = await (0, __aws_sdk_s3_request_presigner.getSignedUrl)(client, new __aws_sdk_client_s3.GetObjectCommand({
|
|
1539
|
+
Bucket: bucket,
|
|
1540
|
+
Key: key
|
|
1541
|
+
}), { expiresIn: 3600 });
|
|
1542
|
+
if (!signedUrl) throw new Error("Failed to presign S3 URL");
|
|
1543
|
+
return { fileUrl: signedUrl };
|
|
1544
|
+
} catch (e) {
|
|
1545
|
+
throw new Error(e instanceof Error ? `Failed to presign S3 URL: ${e.message}` : "Failed to presign S3 URL");
|
|
1527
1546
|
}
|
|
1528
|
-
}).done();
|
|
1529
|
-
if (!response.Bucket || !response.Key) throw new Error("Upload Failed");
|
|
1530
|
-
hooks?.onStorageUploaded?.();
|
|
1531
|
-
return { storageUri: `s3://${bucketName}/${Key}` };
|
|
1532
|
-
},
|
|
1533
|
-
async getDownloadUrl(storageUri) {
|
|
1534
|
-
const u = new URL(storageUri);
|
|
1535
|
-
if (u.protocol.replace(":", "") !== "s3") throw new Error("Invalid S3 storage URI protocol");
|
|
1536
|
-
const bucket = u.host;
|
|
1537
|
-
const key = u.pathname.slice(1);
|
|
1538
|
-
if (!bucket || !key) throw new Error("Invalid S3 storage URI: missing bucket or key");
|
|
1539
|
-
try {
|
|
1540
|
-
const signedUrl = await (0, __aws_sdk_s3_request_presigner.getSignedUrl)(client, new __aws_sdk_client_s3.GetObjectCommand({
|
|
1541
|
-
Bucket: bucket,
|
|
1542
|
-
Key: key
|
|
1543
|
-
}), { expiresIn: 3600 });
|
|
1544
|
-
if (!signedUrl) throw new Error("Failed to presign S3 URL");
|
|
1545
|
-
return { fileUrl: signedUrl };
|
|
1546
|
-
} catch (e) {
|
|
1547
|
-
throw new Error(e instanceof Error ? `Failed to presign S3 URL: ${e.message}` : "Failed to presign S3 URL");
|
|
1548
1547
|
}
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
};
|
|
1548
|
+
};
|
|
1549
|
+
}
|
|
1550
|
+
});
|
|
1552
1551
|
|
|
1553
1552
|
//#endregion
|
|
1554
1553
|
exports.s3Database = s3Database;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { BasePluginArgs, DatabasePluginHooks, StoragePlugin, StoragePluginHooks } from "@hot-updater/plugin-core";
|
|
1
|
+
import * as _hot_updater_plugin_core1 from "@hot-updater/plugin-core";
|
|
3
2
|
import { S3ClientConfig } from "@aws-sdk/client-s3";
|
|
4
3
|
|
|
5
4
|
//#region src/s3Database.d.ts
|
|
6
5
|
interface S3DatabaseConfig extends S3ClientConfig {
|
|
7
6
|
bucketName: string;
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* CloudFront distribution ID used for cache invalidation.
|
|
9
|
+
*
|
|
10
|
+
* If omitted or an empty string, CloudFront invalidation is skipped.
|
|
11
|
+
* This is useful for local development environments (e.g. Localstack)
|
|
12
|
+
* where CloudFront is not available.
|
|
13
|
+
*/
|
|
14
|
+
cloudfrontDistributionId?: string;
|
|
9
15
|
apiBasePath?: string;
|
|
10
16
|
}
|
|
11
|
-
declare const s3Database: (config: S3DatabaseConfig, hooks?: DatabasePluginHooks) =>
|
|
17
|
+
declare const s3Database: (config: S3DatabaseConfig, hooks?: _hot_updater_plugin_core1.DatabasePluginHooks) => _hot_updater_plugin_core1.DatabasePlugin;
|
|
12
18
|
//#endregion
|
|
13
19
|
//#region src/s3Storage.d.ts
|
|
14
20
|
interface S3StorageConfig extends S3ClientConfig {
|
|
@@ -18,6 +24,6 @@ interface S3StorageConfig extends S3ClientConfig {
|
|
|
18
24
|
*/
|
|
19
25
|
basePath?: string;
|
|
20
26
|
}
|
|
21
|
-
declare const s3Storage: (config: S3StorageConfig, hooks?: StoragePluginHooks) => (
|
|
27
|
+
declare const s3Storage: (config: S3StorageConfig, hooks?: _hot_updater_plugin_core1.StoragePluginHooks) => () => _hot_updater_plugin_core1.StoragePlugin;
|
|
22
28
|
//#endregion
|
|
23
29
|
export { S3DatabaseConfig, S3StorageConfig, s3Database, s3Storage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { S3ClientConfig } from "@aws-sdk/client-s3";
|
|
2
|
-
import * as
|
|
3
|
-
import { BasePluginArgs, DatabasePluginHooks, StoragePlugin, StoragePluginHooks } from "@hot-updater/plugin-core";
|
|
2
|
+
import * as _hot_updater_plugin_core1 from "@hot-updater/plugin-core";
|
|
4
3
|
|
|
5
4
|
//#region src/s3Database.d.ts
|
|
6
5
|
interface S3DatabaseConfig extends S3ClientConfig {
|
|
7
6
|
bucketName: string;
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* CloudFront distribution ID used for cache invalidation.
|
|
9
|
+
*
|
|
10
|
+
* If omitted or an empty string, CloudFront invalidation is skipped.
|
|
11
|
+
* This is useful for local development environments (e.g. Localstack)
|
|
12
|
+
* where CloudFront is not available.
|
|
13
|
+
*/
|
|
14
|
+
cloudfrontDistributionId?: string;
|
|
9
15
|
apiBasePath?: string;
|
|
10
16
|
}
|
|
11
|
-
declare const s3Database: (config: S3DatabaseConfig, hooks?: DatabasePluginHooks) =>
|
|
17
|
+
declare const s3Database: (config: S3DatabaseConfig, hooks?: _hot_updater_plugin_core1.DatabasePluginHooks) => _hot_updater_plugin_core1.DatabasePlugin;
|
|
12
18
|
//#endregion
|
|
13
19
|
//#region src/s3Storage.d.ts
|
|
14
20
|
interface S3StorageConfig extends S3ClientConfig {
|
|
@@ -18,6 +24,6 @@ interface S3StorageConfig extends S3ClientConfig {
|
|
|
18
24
|
*/
|
|
19
25
|
basePath?: string;
|
|
20
26
|
}
|
|
21
|
-
declare const s3Storage: (config: S3StorageConfig, hooks?: StoragePluginHooks) => (
|
|
27
|
+
declare const s3Storage: (config: S3StorageConfig, hooks?: _hot_updater_plugin_core1.StoragePluginHooks) => () => _hot_updater_plugin_core1.StoragePlugin;
|
|
22
28
|
//#endregion
|
|
23
29
|
export { S3DatabaseConfig, S3StorageConfig, s3Database, s3Storage };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CloudFrontClient, CreateInvalidationCommand } from "@aws-sdk/client-cloudfront";
|
|
2
2
|
import { DeleteObjectCommand, DeleteObjectsCommand, GetObjectCommand, ListObjectsV2Command, NoSuchKey, S3Client } from "@aws-sdk/client-s3";
|
|
3
3
|
import { Upload } from "@aws-sdk/lib-storage";
|
|
4
|
-
import { createBlobDatabasePlugin, createStorageKeyBuilder, getContentType, parseStorageUri } from "@hot-updater/plugin-core";
|
|
4
|
+
import { createBlobDatabasePlugin, createStorageKeyBuilder, createStoragePlugin, getContentType, parseStorageUri } from "@hot-updater/plugin-core";
|
|
5
5
|
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
6
6
|
import fs from "fs/promises";
|
|
7
7
|
import path from "path";
|
|
@@ -1427,98 +1427,97 @@ async function invalidateCloudFront(client, distributionId, paths) {
|
|
|
1427
1427
|
}
|
|
1428
1428
|
}));
|
|
1429
1429
|
}
|
|
1430
|
-
const s3Database = (
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
});
|
|
1453
|
-
};
|
|
1430
|
+
const s3Database = createBlobDatabasePlugin({
|
|
1431
|
+
name: "s3Database",
|
|
1432
|
+
factory: (config) => {
|
|
1433
|
+
const { bucketName, cloudfrontDistributionId, apiBasePath = "/api/check-update",...s3Config } = config;
|
|
1434
|
+
const client = new S3Client(s3Config);
|
|
1435
|
+
const cloudfrontClient = cloudfrontDistributionId ? new CloudFrontClient({
|
|
1436
|
+
credentials: s3Config.credentials,
|
|
1437
|
+
region: s3Config.region
|
|
1438
|
+
}) : void 0;
|
|
1439
|
+
return {
|
|
1440
|
+
apiBasePath,
|
|
1441
|
+
listObjects: (prefix) => listObjectsInS3(client, bucketName, prefix),
|
|
1442
|
+
loadObject: (key) => loadJsonFromS3(client, bucketName, key),
|
|
1443
|
+
uploadObject: (key, data) => uploadJsonToS3(client, bucketName, key, data),
|
|
1444
|
+
deleteObject: (key) => deleteObjectInS3(client, bucketName, key),
|
|
1445
|
+
invalidatePaths: (pathsToInvalidate) => {
|
|
1446
|
+
if (cloudfrontClient && cloudfrontDistributionId && pathsToInvalidate.length > 0) return invalidateCloudFront(cloudfrontClient, cloudfrontDistributionId, pathsToInvalidate);
|
|
1447
|
+
return Promise.resolve();
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
}
|
|
1451
|
+
});
|
|
1454
1452
|
|
|
1455
1453
|
//#endregion
|
|
1456
1454
|
//#region src/s3Storage.ts
|
|
1457
|
-
const s3Storage = (
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
Prefix: key
|
|
1470
|
-
});
|
|
1471
|
-
const listResponse = await client.send(listCommand);
|
|
1472
|
-
if (listResponse.Contents && listResponse.Contents.length > 0) {
|
|
1473
|
-
const deleteCommand = new DeleteObjectsCommand({
|
|
1455
|
+
const s3Storage = createStoragePlugin({
|
|
1456
|
+
name: "s3Storage",
|
|
1457
|
+
supportedProtocol: "s3",
|
|
1458
|
+
factory: (config) => {
|
|
1459
|
+
const { bucketName,...s3Config } = config;
|
|
1460
|
+
const client = new S3Client(s3Config);
|
|
1461
|
+
const getStorageKey = createStorageKeyBuilder(config.basePath);
|
|
1462
|
+
return {
|
|
1463
|
+
async delete(storageUri) {
|
|
1464
|
+
const { bucket, key } = parseStorageUri(storageUri, "s3");
|
|
1465
|
+
if (bucket !== bucketName) throw new Error(`Bucket name mismatch: expected "${bucketName}", but found "${bucket}".`);
|
|
1466
|
+
const listCommand = new ListObjectsV2Command({
|
|
1474
1467
|
Bucket: bucketName,
|
|
1475
|
-
|
|
1476
|
-
Objects: listResponse.Contents.map((obj) => ({ Key: obj.Key })),
|
|
1477
|
-
Quiet: true
|
|
1478
|
-
}
|
|
1468
|
+
Prefix: key
|
|
1479
1469
|
});
|
|
1480
|
-
await client.send(
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1470
|
+
const listResponse = await client.send(listCommand);
|
|
1471
|
+
if (listResponse.Contents && listResponse.Contents.length > 0) {
|
|
1472
|
+
const deleteCommand = new DeleteObjectsCommand({
|
|
1473
|
+
Bucket: bucketName,
|
|
1474
|
+
Delete: {
|
|
1475
|
+
Objects: listResponse.Contents.map((obj) => ({ Key: obj.Key })),
|
|
1476
|
+
Quiet: true
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1479
|
+
await client.send(deleteCommand);
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1482
|
+
throw new Error("Bundle Not Found");
|
|
1483
|
+
},
|
|
1484
|
+
async upload(key, filePath) {
|
|
1485
|
+
const Body = await fs.readFile(filePath);
|
|
1486
|
+
const ContentType = getContentType(filePath);
|
|
1487
|
+
const Key = getStorageKey(key, path.basename(filePath));
|
|
1488
|
+
const response = await new Upload({
|
|
1489
|
+
client,
|
|
1490
|
+
params: {
|
|
1491
|
+
ContentType,
|
|
1492
|
+
Bucket: bucketName,
|
|
1493
|
+
Key,
|
|
1494
|
+
Body,
|
|
1495
|
+
CacheControl: "max-age=31536000"
|
|
1496
|
+
}
|
|
1497
|
+
}).done();
|
|
1498
|
+
if (!response.Bucket || !response.Key) throw new Error("Upload Failed");
|
|
1499
|
+
return { storageUri: `s3://${bucketName}/${Key}` };
|
|
1500
|
+
},
|
|
1501
|
+
async getDownloadUrl(storageUri) {
|
|
1502
|
+
const u = new URL(storageUri);
|
|
1503
|
+
if (u.protocol.replace(":", "") !== "s3") throw new Error("Invalid S3 storage URI protocol");
|
|
1504
|
+
const bucket = u.host;
|
|
1505
|
+
const key = u.pathname.slice(1);
|
|
1506
|
+
if (!bucket || !key) throw new Error("Invalid S3 storage URI: missing bucket or key");
|
|
1507
|
+
try {
|
|
1508
|
+
const signedUrl = await getSignedUrl(client, new GetObjectCommand({
|
|
1509
|
+
Bucket: bucket,
|
|
1510
|
+
Key: key
|
|
1511
|
+
}), { expiresIn: 3600 });
|
|
1512
|
+
if (!signedUrl) throw new Error("Failed to presign S3 URL");
|
|
1513
|
+
return { fileUrl: signedUrl };
|
|
1514
|
+
} catch (e) {
|
|
1515
|
+
throw new Error(e instanceof Error ? `Failed to presign S3 URL: ${e.message}` : "Failed to presign S3 URL");
|
|
1497
1516
|
}
|
|
1498
|
-
}).done();
|
|
1499
|
-
if (!response.Bucket || !response.Key) throw new Error("Upload Failed");
|
|
1500
|
-
hooks?.onStorageUploaded?.();
|
|
1501
|
-
return { storageUri: `s3://${bucketName}/${Key}` };
|
|
1502
|
-
},
|
|
1503
|
-
async getDownloadUrl(storageUri) {
|
|
1504
|
-
const u = new URL(storageUri);
|
|
1505
|
-
if (u.protocol.replace(":", "") !== "s3") throw new Error("Invalid S3 storage URI protocol");
|
|
1506
|
-
const bucket = u.host;
|
|
1507
|
-
const key = u.pathname.slice(1);
|
|
1508
|
-
if (!bucket || !key) throw new Error("Invalid S3 storage URI: missing bucket or key");
|
|
1509
|
-
try {
|
|
1510
|
-
const signedUrl = await getSignedUrl(client, new GetObjectCommand({
|
|
1511
|
-
Bucket: bucket,
|
|
1512
|
-
Key: key
|
|
1513
|
-
}), { expiresIn: 3600 });
|
|
1514
|
-
if (!signedUrl) throw new Error("Failed to presign S3 URL");
|
|
1515
|
-
return { fileUrl: signedUrl };
|
|
1516
|
-
} catch (e) {
|
|
1517
|
-
throw new Error(e instanceof Error ? `Failed to presign S3 URL: ${e.message}` : "Failed to presign S3 URL");
|
|
1518
1517
|
}
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
};
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1522
1521
|
|
|
1523
1522
|
//#endregion
|
|
1524
1523
|
export { s3Database, s3Storage };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/aws",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.21.
|
|
4
|
+
"version": "0.21.12",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"execa": "9.5.2",
|
|
45
45
|
"hono": "^4.6.3",
|
|
46
46
|
"mime": "^4.0.4",
|
|
47
|
-
"@hot-updater/core": "0.21.
|
|
48
|
-
"@hot-updater/
|
|
49
|
-
"@hot-updater/
|
|
47
|
+
"@hot-updater/core": "0.21.12",
|
|
48
|
+
"@hot-updater/js": "0.21.12",
|
|
49
|
+
"@hot-updater/test-utils": "0.21.12"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@aws-sdk/client-cloudfront": "3.772.0",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"@aws-sdk/credential-providers": "3.772.0",
|
|
60
60
|
"@aws-sdk/lib-storage": "3.772.0",
|
|
61
61
|
"aws-lambda": "1.0.7",
|
|
62
|
-
"@hot-updater/cli-tools": "0.21.
|
|
63
|
-
"@hot-updater/plugin-core": "0.21.
|
|
62
|
+
"@hot-updater/cli-tools": "0.21.12",
|
|
63
|
+
"@hot-updater/plugin-core": "0.21.12"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"build": "tsdown",
|