@pi-r/aws-lib 0.6.1 → 0.7.0
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/LICENSE +1 -1
- package/index.js +8 -10
- package/package.json +2 -4
- package/types/index.d.ts +1 -1
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2024 An Pham
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
exports.getBucketKey = exports.formatDefaultRetention = exports.checkBucketCannedACL = exports.setDatabaseEndpoint = exports.setEndpoint = exports.getPrivatePolicy = exports.getBucketPublicReadPolicy = exports.getPublicReadPolicy = exports.isDatabaseDefined = exports.isProviderChainDefined = exports.isSharedCredentialsDefined = exports.isEnvDefined = exports.isAccessDefined = void 0;
|
|
4
|
-
const types_1 = require("@e-mc/types");
|
|
5
3
|
function isAccessDefined(credential) {
|
|
6
4
|
return !!(credential.accessKeyId && credential.secretAccessKey);
|
|
7
5
|
}
|
|
@@ -68,30 +66,30 @@ exports.getPrivatePolicy = getPrivatePolicy;
|
|
|
68
66
|
function setEndpoint(config, instance, fallbackRegion) {
|
|
69
67
|
let { region, endpoint } = config;
|
|
70
68
|
if (!endpoint) {
|
|
71
|
-
const location =
|
|
69
|
+
const location = typeof region === 'string' && region || process.env.AWS_REGION || fallbackRegion;
|
|
72
70
|
if (location) {
|
|
73
71
|
endpoint = `https://${instance}.${location}.amazonaws.com`;
|
|
74
72
|
config.endpoint = endpoint;
|
|
75
73
|
}
|
|
76
74
|
}
|
|
77
75
|
if (!region) {
|
|
78
|
-
region = (
|
|
79
|
-
if (region && region !== "us-east-1"
|
|
76
|
+
region = (typeof endpoint === 'string' && new RegExp(`\\b${instance}\\.([^.]+)\\.`, 'i').exec(endpoint)?.[1] || process.env.AWS_REGION || fallbackRegion)?.toLowerCase();
|
|
77
|
+
if (region && region !== "us-east-1") {
|
|
80
78
|
config.region = region;
|
|
81
79
|
}
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
82
|
exports.setEndpoint = setEndpoint;
|
|
85
|
-
function setDatabaseEndpoint(config, fallbackRegion = "us-east-1"
|
|
83
|
+
function setDatabaseEndpoint(config, fallbackRegion = "us-east-1") {
|
|
86
84
|
setEndpoint(config, 'dynamodb', fallbackRegion);
|
|
87
85
|
}
|
|
88
86
|
exports.setDatabaseEndpoint = setDatabaseEndpoint;
|
|
89
87
|
function checkBucketCannedACL(value) {
|
|
90
88
|
switch (value) {
|
|
91
|
-
case "private"
|
|
92
|
-
case "public-read"
|
|
93
|
-
case "public-read-write"
|
|
94
|
-
case "authenticated-read"
|
|
89
|
+
case "private":
|
|
90
|
+
case "public-read":
|
|
91
|
+
case "public-read-write":
|
|
92
|
+
case "authenticated-read":
|
|
95
93
|
return value;
|
|
96
94
|
}
|
|
97
95
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/aws-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "AWS cloud utility functions for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -20,7 +20,5 @@
|
|
|
20
20
|
"author": "An Pham <anpham6@gmail.com>",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"@e-mc/types": "^0.8.3"
|
|
25
|
-
}
|
|
23
|
+
"dependencies": {}
|
|
26
24
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ declare namespace AWS {
|
|
|
97
97
|
function getPrivatePolicy(bucket: string): string;
|
|
98
98
|
function setDatabaseEndpoint(config: EndpointConfig, fallbackRegion?: string): void;
|
|
99
99
|
function setEndpoint(config: EndpointConfig, instance: string, fallbackRegion?: string): void;
|
|
100
|
-
function checkBucketCannedACL(value: unknown):
|
|
100
|
+
function checkBucketCannedACL(value: unknown): BucketCannedACL | undefined;
|
|
101
101
|
function formatDefaultRetention(retention: DefaultRetention): string;
|
|
102
102
|
function getBucketKey(credential: unknown, bucket: string, acl: string | undefined, service: string, sdk: string): string;
|
|
103
103
|
}
|