diff --git a/CHANGELOG.md b/CHANGELOG.md index a93be492443..73a85882bc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased (develop) +- added: Changelly plugin info revised - added: Logbox disable option to env.json - added: Reverse-resolve recipient addresses to ENS / Unstoppable Domains / ZNS names in the send flow, address modal, and transaction history. diff --git a/scripts/obfuscateString.ts b/scripts/obfuscateString.ts new file mode 100644 index 00000000000..962269fb50a --- /dev/null +++ b/scripts/obfuscateString.ts @@ -0,0 +1,16 @@ +// Generates the obfuscated char-code array to paste into env.json for +// fields cleaned by asObfuscatedString. +// +// Usage: +// node -r sucrase/register scripts/obfuscateString.ts + +import { wasObfuscatedString } from '../src/util/cleaners/asObfuscatedString' + +const plaintext = process.argv.slice(2).join(' ') + +if (plaintext === '') { + console.error('Usage: obfuscateString.ts ') + process.exit(1) +} + +console.log(JSON.stringify(wasObfuscatedString(plaintext))) diff --git a/src/actions/CategoriesActions.ts b/src/actions/CategoriesActions.ts index 494d875de17..2c0887af262 100644 --- a/src/actions/CategoriesActions.ts +++ b/src/actions/CategoriesActions.ts @@ -712,6 +712,7 @@ export const pluginIdIcons: Record<string, string> = { bridgeless: EDGE_CONTENT_SERVER_URI + '/bridgeless.png', changenow: EDGE_CONTENT_SERVER_URI + '/changenow.png', changehero: EDGE_CONTENT_SERVER_URI + '/changehero.png', + changelly: EDGE_CONTENT_SERVER_URI + '/changelly.png', cosmosibc: EDGE_CONTENT_SERVER_URI + '/cosmosibc.png', exolix: EDGE_CONTENT_SERVER_URI + '/exolix-logo.png', fantomsonicupgrade: EDGE_CONTENT_SERVER_URI + '/fantomsonicupgrade.png', diff --git a/src/components/modals/SwapVerifyTermsModal.tsx b/src/components/modals/SwapVerifyTermsModal.tsx index 663f5ff9ba6..0b8e0ccb763 100644 --- a/src/components/modals/SwapVerifyTermsModal.tsx +++ b/src/components/modals/SwapVerifyTermsModal.tsx @@ -31,6 +31,11 @@ const pluginData: Record<string, TermsUri> = { privacyUri: 'https://changenow.io/privacy-policy', kycUri: 'https://changenow.io/faq/kyc' }, + changelly: { + termsUri: 'https://changelly.com/terms-of-use', + privacyUri: 'https://changelly.com/privacy-policy', + kycUri: 'https://changelly.com/aml-kyc' + }, exolix: { termsUri: 'https://exolix.com/terms', privacyUri: 'https://exolix.com/privacy', diff --git a/src/envConfig.ts b/src/envConfig.ts index 149d1383f28..2d098e7b5a5 100644 --- a/src/envConfig.ts +++ b/src/envConfig.ts @@ -19,6 +19,7 @@ import { asInitOptions as asPaybisInitOptions } from './plugins/ramps/paybis/pay import { asInitOptions as asRevolutInitOptions } from './plugins/ramps/revolut/revolutRampTypes' import { asInitOptions as asSimplexInitOptions } from './plugins/ramps/simplex/simplexRampTypes' import { asBase16 } from './util/cleaners/asHex' +import { asObfuscatedString } from './util/cleaners/asObfuscatedString' function asNullable<T>(cleaner: Cleaner<T>): Cleaner<T | null> { return function asNullable(raw) { @@ -266,6 +267,13 @@ export const asEnvConfig = asObject({ apiKey: asOptional(asString, '') }).withRest ), + CHANGELLY_INIT: asCorePluginInit( + asObject({ + // Arrays of XOR-masked char codes; see asObfuscatedString. + apiKey: asOptional(asObfuscatedString, ''), + secret: asOptional(asObfuscatedString, '') + }).withRest + ), COREUM_INIT: asCorePluginInit(asBoolean), COSMOSHUB_INIT: asCorePluginInit(asBoolean), DASH_INIT: asCorePluginInit( diff --git a/src/util/cleaners/asObfuscatedString.ts b/src/util/cleaners/asObfuscatedString.ts new file mode 100644 index 00000000000..784eaab18b7 --- /dev/null +++ b/src/util/cleaners/asObfuscatedString.ts @@ -0,0 +1,19 @@ +import { asArray, asCodec, asNumber, uncleaner } from 'cleaners' + +// XOR mask applied to each char code. Not a secret. +const MASK = 0x5a + +/** + * Decodes a string stored as an array of XOR-masked char codes, + * e.g. "hi" <-> [0x32, 0x33]. Use `wasObfuscatedString` or + * scripts/obfuscateString.ts to generate the array. + */ +export const asObfuscatedString = asCodec<string>( + raw => + asArray(asNumber)(raw) + .map(code => String.fromCharCode(code ^ MASK)) + .join(''), + clean => clean.split('').map(ch => ch.charCodeAt(0) ^ MASK) +) + +export const wasObfuscatedString = uncleaner(asObfuscatedString) diff --git a/src/util/corePlugins.ts b/src/util/corePlugins.ts index 719aebe1008..fbb7d00263b 100644 --- a/src/util/corePlugins.ts +++ b/src/util/corePlugins.ts @@ -93,6 +93,7 @@ export const swapPlugins = { // Centralized Swaps changehero: ENV.CHANGEHERO_INIT, changenow: ENV.CHANGE_NOW_INIT, + changelly: ENV.CHANGELLY_INIT, exolix: ENV.EXOLIX_INIT, godex: ENV.GODEX_INIT, lifi: ENV.LIFI_INIT,