mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-21 22:57:17 +01:00
feat(env-utils): add useCodeSignKey to getJWSPublicKey
This commit is contained in:
@@ -3,8 +3,8 @@ import { Dimensions, Platform } from 'react-native';
|
||||
import Constants from 'expo-constants';
|
||||
import { getLocales } from 'expo-localization';
|
||||
|
||||
import { publicKey } from './jws';
|
||||
import { EnvUtils } from './types';
|
||||
import { firmwareConfigPublicKey, publicKey } from './jws';
|
||||
import { EnvUtils, JWSPublicKeyUse } from './types';
|
||||
|
||||
const isWeb = () => false;
|
||||
|
||||
@@ -79,7 +79,15 @@ const getOsNameWeb = () => '';
|
||||
|
||||
const getOsFamily = (): 'Linux' => 'Linux';
|
||||
|
||||
export const getJWSPublicKey = () => (isCodesignBuild() ? publicKey.codesign : publicKey.dev);
|
||||
export const getJWSPublicKey = (use: JWSPublicKeyUse, useCodeSignKey = false) => {
|
||||
if (['message-system', 'token-definitions'].includes(use)) {
|
||||
return isCodesignBuild() ? publicKey.codesign : publicKey.dev;
|
||||
}
|
||||
|
||||
return isCodesignBuild() || useCodeSignKey
|
||||
? firmwareConfigPublicKey.codesign
|
||||
: firmwareConfigPublicKey.dev;
|
||||
};
|
||||
|
||||
export const envUtils: EnvUtils = {
|
||||
isWeb,
|
||||
|
||||
@@ -143,12 +143,14 @@ const getOsFamily = () => {
|
||||
|
||||
const getDeviceType = () => getUserAgentParser().getDevice().type;
|
||||
|
||||
export const getJWSPublicKey = (use: JWSPublicKeyUse) => {
|
||||
export const getJWSPublicKey = (use: JWSPublicKeyUse, useCodeSignKey = false) => {
|
||||
if (['message-system', 'token-definitions'].includes(use)) {
|
||||
return isCodesignBuild() ? publicKey.codesign : publicKey.dev;
|
||||
}
|
||||
|
||||
return isCodesignBuild() ? firmwareConfigPublicKey.codesign : firmwareConfigPublicKey.dev;
|
||||
return isCodesignBuild() || useCodeSignKey
|
||||
? firmwareConfigPublicKey.codesign
|
||||
: firmwareConfigPublicKey.dev;
|
||||
};
|
||||
|
||||
export const envUtils: EnvUtils = {
|
||||
|
||||
@@ -35,5 +35,5 @@ export interface EnvUtils {
|
||||
getOsName: () => '' | 'android' | 'linux' | 'windows' | 'macos' | 'chromeos' | 'ios';
|
||||
getOsNameWeb: () => string | undefined;
|
||||
getOsFamily: () => 'Windows' | 'MacOS' | 'Linux';
|
||||
getJWSPublicKey: (use: JWSPublicKeyUse) => string;
|
||||
getJWSPublicKey: (use: JWSPublicKeyUse, useCodeSignKey?: boolean) => string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user