@riocrypto/common 1.0.545 → 1.0.547
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.
|
@@ -259,14 +259,6 @@ class RioClient {
|
|
|
259
259
|
return data;
|
|
260
260
|
});
|
|
261
261
|
}
|
|
262
|
-
createBankPayment(orderId) {
|
|
263
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
264
|
-
const { data } = yield this.axios.post(`/api/payments/bank/init`, {
|
|
265
|
-
orderId,
|
|
266
|
-
});
|
|
267
|
-
return data;
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
262
|
updateAuth(update, id) {
|
|
271
263
|
return __awaiter(this, void 0, void 0, function* () {
|
|
272
264
|
const { data } = yield this.axios.patch(`/api/auth/${id || ""}`, update);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SecretManagerServiceClient } from "@google-cloud/secret-manager";
|
|
2
|
+
import { RioEnv } from "../types/rio-env";
|
|
3
|
+
declare class SecretManagerClient {
|
|
4
|
+
private env;
|
|
5
|
+
client: SecretManagerServiceClient;
|
|
6
|
+
constructor(env: RioEnv);
|
|
7
|
+
getSecretValue(secretId: string): Promise<string | null>;
|
|
8
|
+
}
|
|
9
|
+
export declare const secretManagerClient: SecretManagerClient;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.secretManagerClient = void 0;
|
|
13
|
+
const secret_manager_1 = require("@google-cloud/secret-manager");
|
|
14
|
+
const rio_env_1 = require("../types/rio-env");
|
|
15
|
+
class SecretManagerClient {
|
|
16
|
+
constructor(env) {
|
|
17
|
+
this.env = env;
|
|
18
|
+
this.client = new secret_manager_1.SecretManagerServiceClient({});
|
|
19
|
+
}
|
|
20
|
+
getSecretValue(secretId) {
|
|
21
|
+
var _a, _b, _c, _d;
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
let file;
|
|
24
|
+
if (this.env === rio_env_1.RioEnv.Development) {
|
|
25
|
+
file = "dev-secrets";
|
|
26
|
+
}
|
|
27
|
+
else if (this.env === rio_env_1.RioEnv.Sandbox) {
|
|
28
|
+
file = "sandbox-secrets";
|
|
29
|
+
}
|
|
30
|
+
else if (this.env === rio_env_1.RioEnv.Staging) {
|
|
31
|
+
file = "staging-secrets";
|
|
32
|
+
}
|
|
33
|
+
else if (this.env === rio_env_1.RioEnv.Production) {
|
|
34
|
+
file = "production-secrets";
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
// Access the secret version
|
|
38
|
+
const [version] = yield this.client.accessSecretVersion({
|
|
39
|
+
name: `projects/riocrypto/secrets/${file}/versions/latest`,
|
|
40
|
+
});
|
|
41
|
+
if (!((_b = (_a = version.payload) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.toString())) {
|
|
42
|
+
throw new Error();
|
|
43
|
+
}
|
|
44
|
+
const secrets = JSON.parse((_d = (_c = version.payload) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.toString());
|
|
45
|
+
return secrets[secretId];
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
console.error(`Failed to access secret ${secretId}: ${err}`);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.secretManagerClient = new SecretManagerClient(process.env.RIO_ENV);
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -159,3 +159,4 @@ __exportStar(require("./classes/USStateAsset"), exports);
|
|
|
159
159
|
__exportStar(require("./classes/WyrePaymentMethodAsset"), exports);
|
|
160
160
|
__exportStar(require("./helpers/get-user-from-client-helper"), exports);
|
|
161
161
|
__exportStar(require("./clients/rio-client"), exports);
|
|
162
|
+
__exportStar(require("./clients/secret-manager-client"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.547",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"typescript": "^4.7.4"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
+
"@google-cloud/secret-manager": "^4.2.1",
|
|
24
25
|
"@types/express": "^4.17.13",
|
|
25
26
|
"axios": "^0.27.2",
|
|
26
27
|
"express-validator": "^6.15.0",
|