@riocrypto/common-server 1.0.2764 → 1.0.2765
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,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -11,13 +34,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
35
|
exports.buildGCloudStorageClient = exports.GCloudStorageClient = void 0;
|
|
13
36
|
const storage_1 = require("@google-cloud/storage");
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
14
38
|
const secret_manager_client_1 = require("./secret-manager-client");
|
|
39
|
+
const KEY_PATH = "/etc/secrets/cloud-storage/cloud-storage-service-account-key.json";
|
|
40
|
+
function buildStorage() {
|
|
41
|
+
if (fs.existsSync(KEY_PATH)) {
|
|
42
|
+
return new storage_1.Storage({ keyFilename: KEY_PATH });
|
|
43
|
+
}
|
|
44
|
+
return new storage_1.Storage();
|
|
45
|
+
}
|
|
15
46
|
class GCloudStorageClient {
|
|
16
47
|
constructor(bucket) {
|
|
17
|
-
|
|
18
|
-
keyFilename: "/etc/secrets/cloud-storage/cloud-storage-service-account-key.json",
|
|
19
|
-
});
|
|
20
|
-
this._bucket = storage.bucket(bucket);
|
|
48
|
+
this._bucket = buildStorage().bucket(bucket);
|
|
21
49
|
}
|
|
22
50
|
get bucket() {
|
|
23
51
|
return this._bucket;
|
|
@@ -26,9 +54,7 @@ class GCloudStorageClient {
|
|
|
26
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
55
|
const bucketName = gcsUri.split("/")[2];
|
|
28
56
|
const folderPath = gcsUri.split("/").slice(4).join("/"); // Extract the folder path from the URI
|
|
29
|
-
const storage =
|
|
30
|
-
keyFilename: "/etc/secrets/cloud-storage/cloud-storage-service-account-key.json",
|
|
31
|
-
});
|
|
57
|
+
const storage = buildStorage();
|
|
32
58
|
const [files] = yield storage
|
|
33
59
|
.bucket(bucketName)
|
|
34
60
|
.getFiles({ prefix: folderPath });
|