-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsecrets.ts
More file actions
305 lines (261 loc) · 8.66 KB
/
secrets.ts
File metadata and controls
305 lines (261 loc) · 8.66 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
import 'dotenv/config';
import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
// Instantiate the client
const client = new SecretManagerServiceClient();
/**
* Retrieves a secret from Google Secret Manager.
* @param {string} secretName - The name of the secret to retrieve.
* @returns {Promise<string|null>} - The retrieved secret value or null in case of an error.
*/
async function getSecretVersion(secretName: string): Promise<string | null> {
try {
const [version] = await client.accessSecretVersion({
name: secretName,
});
// Extract the secret's content
const secretValue = version.payload.data.toString();
return secretValue;
} catch (err) {
console.error(`Error retrieving the secret: ${err}`);
return null; // Returns null in case of an error
}
}
/**
* Retrieves a secret from Google Secret Manager based on the provided secret name.
* @param {string} secretName - The name of the secret to retrieve.
* @returns {Promise<string>} - The retrieved secret value or an empty string if not found.
*/
async function getSecret(secretName: string): Promise<string | null> {
if (process.env.NOT_GOOGLE_SECRET) return null;
return await getSecretVersion(secretName);
}
/**
* The port number used for the application.
* Fallback: an empty string if not defined in the environment.
*/
export const PORT = process.env.PORT || '';
/**
* The ANKR key.
* Fallback: an empty string if not defined in the environment.
*/
export const ANKR_KEY = process.env.ANKR_KEY || '';
/**
* The ALCHEMY API key.
* Fallback: an empty string if not defined in the environment.
*/
export const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY || '';
/**
* The GETBLOCK API key.
* Fallback: an empty string if not defined in the environment.
*/
export const GETBLOCK_API_KEY = process.env.GETBLOCK_API_KEY || '';
/**
* The LAVANET API key.
* Fallback: an empty string if not defined in the environment.
*/
export const LAVANET_API_KEY = process.env.LAVANET_API_KEY || '';
/**
* The CHAINSTACK API key.
* Fallback: an empty string if not defined in the environment.
*/
export const CHAINSTACK_API_KEY = process.env.CHAINSTACK_API_KEY || '';
/**
* The second CHAINSTACK API key.
* Fallback: an empty string if not defined in the environment.
*/
export const CHAINSTACK_API_KEY_2 = process.env.CHAINSTACK_API_KEY_2 || '';
/**
* Retrieves the bot token.
*/
export async function getBotToken(): Promise<string> {
return (
(await getSecret(process.env.BOT_TOKEN_NAME)) || process.env.BOT_TOKEN || ''
);
}
/**
* Retrieves the client ID.
*/
export async function getClientId(): Promise<string> {
return (
(await getSecret(process.env.CLIENT_ID_NAME)) || process.env.CLIENT_ID || ''
);
}
/**
* Retrieves the client secret.
*/
export async function getClientSecret(): Promise<string> {
return (
(await getSecret(process.env.CLIENT_SECRET_NAME)) ||
process.env.CLIENT_SECRET ||
''
);
}
/**
* Retrieves the API key.
*/
export async function getApiKey(): Promise<string> {
return (
(await getSecret(process.env.API_KEY_NAME)) || process.env.API_KEY || ''
);
}
/**
* Retrieves the API key for Linea.
*/
export const API_KEY_LINEA = process.env.API_KEY_LINEA || '';
/**
* Retrieves the Atlas URI.
*/
export async function getAtlasUri(): Promise<string> {
return (
(await getSecret(process.env.ATLAS_URI_NAME)) || process.env.ATLAS_URI || ''
);
}
/**
* The G1 Polygon address used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const G1_POLYGON_ADDRESS = process.env.G1_POLYGON_ADDRESS || '';
/**
* The source Telegram ID used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const SOURCE_TG_ID = process.env.SOURCE_TG_ID || '';
/**
* The source wallet address used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const SOURCE_WALLET_ADDRESS = process.env.SOURCE_WALLET_ADDRESS || '';
/**
* The Pub/Sub subscription name used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const PUBSUB_SUBSCRIPTION_NAME =
process.env.PUBSUB_SUBSCRIPTION_NAME || '';
/**
* The Pub/Sub topic name used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const PUBSUB_TOPIC_NAME = process.env.PUBSUB_TOPIC_NAME || '';
/**
* The project ID used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const PROJECT_ID = process.env.PROJECT_ID || '';
/**
* The FlowXO new user webhook.
* Fallback: an empty string if not defined in the environment.
*/
export const FLOWXO_NEW_USER_WEBHOOK =
process.env.FLOWXO_NEW_USER_WEBHOOK || '';
/**
* The FlowXO new signup reward webhook.
* Fallback: an empty string if not defined in the environment.
*/
export const FLOWXO_NEW_SIGNUP_REWARD_WEBHOOK =
process.env.FLOWXO_NEW_SIGNUP_REWARD_WEBHOOK || '';
/**
* The FlowXO new referral reward webhook.
* Fallback: an empty string if not defined in the environment.
*/
export const FLOWXO_NEW_REFERRAL_REWARD_WEBHOOK =
process.env.FLOWXO_NEW_REFERRAL_REWARD_WEBHOOK || '';
/**
* The FlowXO new transaction webhook.
* Fallback: an empty string if not defined in the environment.
*/
export const FLOWXO_NEW_TRANSACTION_WEBHOOK =
process.env.FLOWXO_NEW_TRANSACTION_WEBHOOK || '';
/**
* The FlowXO new link reward webhook.
* Fallback: an empty string if not defined in the environment.
*/
export const FLOWXO_NEW_LINK_REWARD_WEBHOOK =
process.env.FLOWXO_NEW_LINK_REWARD_WEBHOOK || '';
/**
* The FlowXO new isolated reward webhook.
* Fallback: an empty string if not defined in the environment.
*/
export const FLOWXO_NEW_ISOLATED_REWARD_WEBHOOK =
process.env.FLOWXO_NEW_ISOLATED_REWARD_WEBHOOK || '';
/**
* The FlowXO new swap webhook.
* Fallback: an empty string if not defined in the environment.
*/
export const FLOWXO_NEW_SWAP_WEBHOOK =
process.env.FLOWXO_NEW_SWAP_WEBHOOK || '';
/**
* The Airtable base ID used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const AIRTABLE_BASE_ID = process.env.AIRTABLE_BASE_ID || '';
/**
* The Airtable API key used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const AIRTABLE_API_KEY = process.env.AIRTABLE_API_KEY || '';
/**
* The Segment write key used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const SEGMENT_WRITE_KEY = process.env.SEGMENT_WRITE_KEY || '';
/**
* The Segment key used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const SEGMENT_KEY = process.env.SEGMENT_KEY || '';
/**
* The Grindery account refresh token used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const GRINDERY_ACCOUNT_REFRESH_TOKEN =
process.env.GRINDERY_ACCOUNT_REFRESH_TOKEN || '';
/**
* The Grindery account workspace key used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const GRINDERY_ACCOUNT_WORKSPACE_KEY =
process.env.GRINDERY_ACCOUNT_WORKSPACE_KEY || '';
/**
* The wallet notification webhook URL used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const WALLET_NOTIFICATION_WEBHOOK_URL =
process.env.WALLET_NOTIFICATION_WEBHOOK_URL || '';
/**
* The Pub/Sub minimum acknowledgment deadline used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const PUBSUB_MIN_ACK_DEADLINE =
process.env.PUBSUB_MIN_ACK_DEADLINE || '';
/**
* The Pub/Sub maximum acknowledgment deadline used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const PUBSUB_MAX_ACK_DEADLINE =
process.env.PUBSUB_MAX_ACK_DEADLINE || '';
/**
* The Pub/Sub concurrency value used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const PUBSUB_CONCURRENCY = process.env.PUBSUB_CONCURRENCY || '';
/**
* The Telegram API ID used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const TELEGRAM_API_ID = process.env.TELEGRAM_API_ID || '';
/**
* The Telegram API hash used for something.
* Fallback: an empty string if not defined in the environment.
*/
export const TELEGRAM_API_HASH = process.env.TELEGRAM_API_HASH || '';
/**
* The production environement.
* Fallback: an empty string if not defined in the environment.
*/
export const PRODUCTION_ENV = process.env.PRODUCTION_ENV || '';
/**
* Grindery Nexus refresh token.
* Fallback: an empty string if not defined in the environment.
*/
export const GRINDERY_NEXUS_REFRESH_TOKEN =
process.env.GRINDERY_NEXUS_REFRESH_TOKEN || '';