From de20e83bd4d2cd981f0599c16582643f9521c947 Mon Sep 17 00:00:00 2001 From: William Swanson Date: Wed, 23 Oct 2024 14:51:16 -0700 Subject: [PATCH 1/2] Rename ENV.AIRBITZ_API_KEY to ENV.EDGE_API_KEY --- scripts/makeNativeHeaders.ts | 2 +- src/actions/NotificationActions.ts | 6 +++--- src/components/services/EdgeCoreManager.tsx | 2 +- src/envConfig.ts | 2 +- src/util/PushClient/PushClient.ts | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/makeNativeHeaders.ts b/scripts/makeNativeHeaders.ts index cbdb35277b8..b60653f9ea0 100644 --- a/scripts/makeNativeHeaders.ts +++ b/scripts/makeNativeHeaders.ts @@ -7,7 +7,7 @@ function makeNativeHeaders() { // Grab the API key: let apiKey = 'Error: Set up env.json & re-run scripts/makeNativeHeaders.js' try { - apiKey = require('../env.json').AIRBITZ_API_KEY + apiKey = require('../env.json').EDGE_API_KEY } catch (e) { console.log(apiKey) } diff --git a/src/actions/NotificationActions.ts b/src/actions/NotificationActions.ts index 5c72ac2644c..1131a1bb692 100644 --- a/src/actions/NotificationActions.ts +++ b/src/actions/NotificationActions.ts @@ -46,7 +46,7 @@ export function registerNotificationsV2(changeFiat: boolean = false): ThunkActio .catch(() => '') const body = { - apiKey: ENV.AIRBITZ_API_KEY, + apiKey: ENV.EDGE_API_KEY, deviceId: state.core.context.clientId, deviceToken, loginId: base64.stringify(base58.parse(state.core.account.rootLoginId)) @@ -193,7 +193,7 @@ async function updateServerSettings(context: EdgeContext, data: DeviceUpdatePayl .catch(() => '') const body = { - apiKey: ENV.AIRBITZ_API_KEY, + apiKey: ENV.EDGE_API_KEY, deviceId, deviceToken, data: { ...data, loginIds } @@ -279,7 +279,7 @@ async function legacyGet(path: string) { method: 'GET', headers: { 'Content-Type': 'application/json', - 'X-Api-Key': ENV.AIRBITZ_API_KEY + 'X-Api-Key': ENV.EDGE_API_KEY } }) if (response != null && response.ok) { diff --git a/src/components/services/EdgeCoreManager.tsx b/src/components/services/EdgeCoreManager.tsx index d4669143962..0ad1cbbd136 100644 --- a/src/components/services/EdgeCoreManager.tsx +++ b/src/components/services/EdgeCoreManager.tsx @@ -29,7 +29,7 @@ const SYNC_TEST_SERVER = 'https://sync-tester-us1.edge.app' interface Props {} const contextOptions: EdgeContextOptions = { - apiKey: ENV.AIRBITZ_API_KEY, + apiKey: ENV.EDGE_API_KEY, appId: '', deviceDescription: `${getBrand()} ${getDeviceId()}`, diff --git a/src/envConfig.ts b/src/envConfig.ts index 5231e1a7fa3..1f8f6aab2fc 100644 --- a/src/envConfig.ts +++ b/src/envConfig.ts @@ -29,7 +29,7 @@ const asEvmApiKeys = asObject({ export const asEnvConfig = asObject({ // API keys: - AIRBITZ_API_KEY: asOptional(asString, ''), + EDGE_API_KEY: asOptional(asString, ''), COINGECKO_API_KEY: asOptional(asString, 'a0000000000000000000000000000000'), IP_API_KEY: asOptional(asString, ''), SENTRY_DSN_URL: asOptional(asString, 'SENTRY_DSN_URL'), diff --git a/src/util/PushClient/PushClient.ts b/src/util/PushClient/PushClient.ts index 33ba7def846..6500f8e6e4c 100644 --- a/src/util/PushClient/PushClient.ts +++ b/src/util/PushClient/PushClient.ts @@ -13,7 +13,7 @@ import { import { ENV } from '../../env' import { base58 } from '../encoding' -const { ACTION_QUEUE, AIRBITZ_API_KEY } = ENV +const { ACTION_QUEUE, EDGE_API_KEY } = ENV const { pushServerUri } = ACTION_QUEUE export interface PushClient { @@ -46,7 +46,7 @@ export const makePushClient = (account: EdgeAccount, clientId: string): PushClie getPushRequestBody(payload?: LoginUpdatePayload): PushRequestBody { const data = payload != null ? wasLoginUpdatePayload(payload) : undefined return { - apiKey: AIRBITZ_API_KEY, + apiKey: EDGE_API_KEY, deviceId: clientId, loginId: base58.parse(account.rootLoginId), data From aa63545aa51584670106f29b913e14e86052f7e6 Mon Sep 17 00:00:00 2001 From: William Swanson Date: Wed, 23 Oct 2024 14:55:16 -0700 Subject: [PATCH 2/2] Add the optional Edge API secret --- src/components/services/EdgeCoreManager.tsx | 1 + src/envConfig.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/components/services/EdgeCoreManager.tsx b/src/components/services/EdgeCoreManager.tsx index 0ad1cbbd136..294201b6cdb 100644 --- a/src/components/services/EdgeCoreManager.tsx +++ b/src/components/services/EdgeCoreManager.tsx @@ -30,6 +30,7 @@ interface Props {} const contextOptions: EdgeContextOptions = { apiKey: ENV.EDGE_API_KEY, + apiSecret: ENV.EDGE_API_SECRET, appId: '', deviceDescription: `${getBrand()} ${getDeviceId()}`, diff --git a/src/envConfig.ts b/src/envConfig.ts index 1f8f6aab2fc..4bf3d927afa 100644 --- a/src/envConfig.ts +++ b/src/envConfig.ts @@ -1,5 +1,7 @@ import { asArray, asBoolean, asEither, asNumber, asObject, asOptional, asString, asValue, Cleaner } from 'cleaners' +import { asBase16 } from './util/cleaners/asHex' + function asNullable(cleaner: Cleaner): Cleaner { return function asNullable(raw) { if (raw == null) return null @@ -30,6 +32,8 @@ const asEvmApiKeys = asObject({ export const asEnvConfig = asObject({ // API keys: EDGE_API_KEY: asOptional(asString, ''), + EDGE_API_SECRET: asOptional(asBase16), + COINGECKO_API_KEY: asOptional(asString, 'a0000000000000000000000000000000'), IP_API_KEY: asOptional(asString, ''), SENTRY_DSN_URL: asOptional(asString, 'SENTRY_DSN_URL'),