Add branta (#845)
* adding translations * adding branta * implemtn branta with pollyfill * improve pollyfill * change function name
This commit is contained in:
+24
-1
@@ -5,10 +5,33 @@ import 'react-native-gesture-handler';
|
||||
import '@azure/core-asynciterator-polyfill';
|
||||
//neeed for encription + spark
|
||||
import 'react-native-quick-base64';
|
||||
|
||||
import { Buffer } from '@craftzdog/react-native-buffer';
|
||||
import { pbkdf2Sync, createHash } from 'react-native-quick-crypto';
|
||||
import QuickCrypto, {
|
||||
pbkdf2Sync,
|
||||
createHash,
|
||||
subtle,
|
||||
} from 'react-native-quick-crypto';
|
||||
global.Buffer = Buffer;
|
||||
|
||||
// Polyfill Web Crypto API for packages that rely on crypto.subtle (e.g. @branta-ops/branta)
|
||||
// react-native-get-random-values (imported above) already provides crypto.getRandomValues
|
||||
// need for @branta-ops/branta
|
||||
global.crypto = QuickCrypto;
|
||||
global.crypto.subtle = subtle;
|
||||
global.crypto.randomUUID =
|
||||
global.crypto.randomUUID ||
|
||||
function () {
|
||||
const bytes = new Uint8Array(16);
|
||||
global.crypto.getRandomValues(bytes);
|
||||
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
||||
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
||||
const hex = Array.from(bytes, b => b.toString(16).padStart(2, '0'));
|
||||
return `${hex.slice(0, 4).join('')}-${hex.slice(4, 6).join('')}-${hex
|
||||
.slice(6, 8)
|
||||
.join('')}-${hex.slice(8, 10).join('')}-${hex.slice(10).join('')}`;
|
||||
};
|
||||
|
||||
// import 'text-encoding-polyfill';
|
||||
import 'text-encoding'; // needed for spark
|
||||
|
||||
|
||||
Reference in New Issue
Block a user