Skip to content

Commit

Permalink
fix: update crypto lib
Browse files Browse the repository at this point in the history
  • Loading branch information
ieow committed Aug 29, 2024
1 parent f92c00c commit cde2a83
Show file tree
Hide file tree
Showing 5 changed files with 726 additions and 346 deletions.
17 changes: 7 additions & 10 deletions mpc-core-kit-react-native/mpc-core-kit-rn-auth0/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ import '@ethersproject/shims';
import {useAuth0, Auth0Provider} from 'react-native-auth0';
// IMP END - Auth Provider Login
import EncryptedStorage from 'react-native-encrypted-storage';
import * as tssLib from '@toruslabs/react-native-tss-lib-bridge';
import {tssLib} from '@toruslabs/react-native-tss-lib-bridge';
import {Bridge} from '@toruslabs/react-native-tss-lib-bridge';
import {EthereumSigningProvider} from '@web3auth/ethereum-mpc-provider';

// IMP START - Quick Start
import {
Web3AuthMPCCoreKit,
WEB3AUTH_NETWORK,
IdTokenLoginParams,
TssShareType,
parseToken,
generateFactorKey,
Expand All @@ -31,6 +30,7 @@ import {
mnemonicToKey,
makeEthereumSigner,
TssLib,
JWTLoginParams,
} from '@web3auth/mpc-core-kit';
// import { Web3AuthMPCCoreKit, WEB3AUTH_NETWORK, Point, SubVerifierDetailsParams,
// TssShareType, keyToMnemonic, getWebBrowserFactor, COREKIT_STATUS, TssSecurityQuestion,
Expand Down Expand Up @@ -61,10 +61,7 @@ const chainConfig = {
tickerName: 'Ethereum',
};

const tsslibInstance: TssLib = {
keyType: 'secp256k1',
lib: tssLib,
};
const tsslibInstance = tssLib;
// setup async storage for react native
const asyncStorageKey = {
getItem: async (key: string) => {
Expand Down Expand Up @@ -156,11 +153,11 @@ function Home() {
uiConsole('idToken', idToken);
const parsedToken = parseToken(idToken!);

const idTokenLoginParams = {
const idTokenLoginParams: JWTLoginParams = {
verifier,
verifierId: parsedToken.email,
idToken,
} as IdTokenLoginParams;
verifierId: parsedToken.sub,
idToken: idToken!,
};

await coreKitInstance.loginWithJWT(idTokenLoginParams);
if (coreKitInstance.status === COREKIT_STATUS.LOGGED_IN) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
global.Buffer = require('buffer').Buffer;
// import './shim.js';
import {install} from 'react-native-quick-crypto';

install();

console.log(Buffer.from( 'Hello World!', "utf-8" ).toString('base64'))
// Needed so that 'stream-http' chooses the right default protocol.
// @ts-ignore
global.location = {
protocol: 'file:',
};

// @ts-ignore
global.process.version = 'v16.0.0';
if (!global.process.version) {
global.process = require('process');
console.log({process: global.process});
}

// @ts-ignore
process.browser = true;

global.Buffer = require('buffer').Buffer;

const TextEncodingPolyfill = require('text-encoding');
// const WebAssembly = require('react-native-webassembly');
Expand All @@ -25,4 +27,4 @@ Object.assign(global, {
TextDecoder: TextEncodingPolyfill.TextDecoder,
// WebAssembly: WebAssembly,
// BigInt: BigInt,
});
});
10 changes: 10 additions & 0 deletions mpc-core-kit-react-native/mpc-core-kit-rn-auth0/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,12 @@ PODS:
- React-Core
- react-native-get-random-values (1.11.0):
- React-Core
- react-native-quick-crypto (0.7.3):
- glog
- OpenSSL-Universal
- RCT-Folly (= 2022.05.16.00)
- React
- React-Core
- react-native-webview (13.8.6):
- glog
- RCT-Folly (= 2022.05.16.00)
Expand Down Expand Up @@ -1188,6 +1194,7 @@ DEPENDENCIES:
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
- react-native-encrypted-storage (from `../node_modules/react-native-encrypted-storage`)
- react-native-get-random-values (from `../node_modules/react-native-get-random-values`)
- react-native-quick-crypto (from `../node_modules/react-native-quick-crypto`)
- react-native-webview (from `../node_modules/react-native-webview`)
- React-nativeconfig (from `../node_modules/react-native/ReactCommon`)
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
Expand Down Expand Up @@ -1292,6 +1299,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-encrypted-storage"
react-native-get-random-values:
:path: "../node_modules/react-native-get-random-values"
react-native-quick-crypto:
:path: "../node_modules/react-native-quick-crypto"
react-native-webview:
:path: "../node_modules/react-native-webview"
React-nativeconfig:
Expand Down Expand Up @@ -1382,6 +1391,7 @@ SPEC CHECKSUMS:
React-Mapbuffer: 84ea43c6c6232049135b1550b8c60b2faac19fab
react-native-encrypted-storage: db300a3f2f0aba1e818417c1c0a6be549038deb7
react-native-get-random-values: 21325b2244dfa6b58878f51f9aa42821e7ba3d06
react-native-quick-crypto: baf477ca99eb2d142ebc8fd10c82eba98f4ebfa6
react-native-webview: d6607cbbe7bad689cc08d6d5e35cbf9938093223
React-nativeconfig: b4d4e9901d4cabb57be63053fd2aa6086eb3c85f
React-NativeModulesApple: cd26e56d56350e123da0c1e3e4c76cb58a05e1ee
Expand Down
Loading

0 comments on commit cde2a83

Please sign in to comment.