forked from NanoAdblocker/NanoBuild
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfind-credentials.js
56 lines (48 loc) · 1.11 KB
/
find-credentials.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* Find credentials for publishing extensions.
*/
"use strict";
/**
* Load modules.
* @const {Module}
*/
const assert = require("assert");
/**
* Local credentials.
* @const {Object}
*/
const local = (() => {
try {
return require("../../Prototype/NanoBuild/credentials.js");
} catch (err) {
return {};
}
})();
/**
* All expected credentials.
* @const {Array.<string>}
*/
const expected = [
"WebStoreClient", // Google API app client
"WebStoreSecret", // Google API app secret
"WebStoreAccount", // Google account refresh token
"AddonsServerIssuer", // Firefox extension store API issuer
"AddonsServerSecret", // Firefox extension store API secret
// "DefenderVersionKey", // Not used for now
];
/**
* Find one credential.
* @function
* @param {string} name - The name of the credential.
*/
const findOne = (name) => {
if (typeof local[name] === "string") {
exports[name] = local[name];
} else {
exports[name] = process.env[name]
}
assert(typeof exports[name] === "string");
};
for (const name of expected) {
findOne(name);
}