@intuweb3/sdk
Version:
INTU SDK - Modern blockchain interaction toolkit
195 lines • 11.9 kB
JavaScript
import { registerWasmAsset } from "./web_assembly/wasm_wrapper.native.js";
export { registerWasmAsset };
export async function createSeed() {
if (typeof global !== "undefined" &&
global.__intuWebViewWasmService &&
global.__intuWebViewWasmService.isWasmReady() &&
global.__intuWebViewWasmService.createSeed) {
try {
console.log("✅ [createSeed] Using WebView WASM");
const seed = await global.__intuWebViewWasmService.createSeed();
return { seed };
}
catch (webViewError) {
console.error("❌ [createSeed] WebView WASM call failed:", webViewError?.message);
throw new Error(`WebView WASM createSeed failed: ${webViewError?.message || String(webViewError)}`);
}
}
throw new Error("WebView WASM is not ready. Please ensure WebView WASM is initialized before calling createSeed().");
}
export async function createRandomMessage() {
try {
const array = new Uint8Array(16);
if (typeof global.crypto !== "undefined" && global.crypto.getRandomValues) {
global.crypto.getRandomValues(array);
}
else {
for (let i = 0; i < 16; i++) {
array[i] = Math.floor(Math.random() * 256);
}
}
const message = Array.from(array, (byte) => byte.toString(16).padStart(2, "0")).join("");
return { message };
}
catch (error) {
console.error("❌ JavaScript createRandomMessage failed:", error);
throw error;
}
}
export async function getUniqueHashFromSignature(signature) {
throw new Error("getUniqueHashFromSignature not implemented for React Native - use WebView WASM");
}
export async function parseTransaction(txdata) {
throw new Error("parseTransaction not implemented for React Native - use WebView WASM");
}
export async function getPolybaseKey(signature) {
if (typeof global !== "undefined" &&
global.__intuWebViewWasmService &&
global.__intuWebViewWasmService.isWasmReady() &&
global.__intuWebViewWasmService.getPolybaseKey) {
try {
console.log("✅ [getPolybaseKey] Using WebView WASM");
const result = await global.__intuWebViewWasmService.getPolybaseKey(signature);
return result;
}
catch (webViewError) {
console.error("❌ [getPolybaseKey] WebView WASM call failed:", webViewError?.message);
throw new Error(`WebView WASM getPolybaseKey failed: ${webViewError?.message || String(webViewError)}`);
}
}
throw new Error("WebView WASM is not ready. Please ensure WebView WASM is initialized before calling getPolybaseKey().");
}
export async function preRegister(signature) {
if (typeof global !== "undefined" &&
global.__intuWebViewWasmService &&
global.__intuWebViewWasmService.isWasmReady() &&
global.__intuWebViewWasmService.preRegister) {
try {
console.log("✅ [preRegister] Using WebView WASM");
const result = await global.__intuWebViewWasmService.preRegister(signature);
return result;
}
catch (webViewError) {
console.error("❌ [preRegister] WebView WASM call failed:", webViewError?.message);
throw new Error(`WebView WASM preRegister failed: ${webViewError?.message || String(webViewError)}`);
}
}
throw new Error("WebView WASM is not ready. Please ensure WebView WASM is initialized before calling preRegister().");
}
export async function encryptData(encryptionKey, dataToEncrypt) {
throw new Error("encryptData not implemented for React Native - use WebView WASM");
}
export async function decryptData(encryptionSignature, dataToDecrypt) {
throw new Error("decryptData not implemented for React Native - use WebView WASM");
}
export async function formTransaction(to, value, chainId, nonce, data, gasPrice, gas, decimal) {
throw new Error("formTransaction not implemented for React Native - use WebView WASM");
}
export async function registerStepOne(seed, threshold, index, megaPkArray) {
if (typeof global !== "undefined" &&
global.__intuWebViewWasmService &&
global.__intuWebViewWasmService.isWasmReady() &&
global.__intuWebViewWasmService.registerStepOne) {
try {
console.log("✅ [registerStepOne] Using WebView WASM");
const result = await global.__intuWebViewWasmService.registerStepOne(seed, threshold, index, megaPkArray);
return result;
}
catch (webViewError) {
console.error("❌ [registerStepOne] WebView WASM call failed:", webViewError?.message);
throw new Error(`WebView WASM registerStepOne failed: ${webViewError?.message || String(webViewError)}`);
}
}
throw new Error("WebView WASM is not ready. Please ensure WebView WASM is initialized before calling registerStepOne().");
}
export async function registerStepTwo(seed, threshold, index, megaPkArray, encryptionSignature, encryptedMegaSecret, dealingsKeyArray, dealingsKappaArray, dealingsLambdaArray) {
if (typeof global !== "undefined" &&
global.__intuWebViewWasmService &&
global.__intuWebViewWasmService.isWasmReady() &&
global.__intuWebViewWasmService.registerStepTwo) {
try {
console.log("✅ [registerStepTwo] Using WebView WASM");
const result = await global.__intuWebViewWasmService.registerStepTwo(seed, threshold, index, megaPkArray, encryptionSignature, encryptedMegaSecret, dealingsKeyArray, dealingsKappaArray, dealingsLambdaArray);
return result;
}
catch (webViewError) {
console.error("❌ [registerStepTwo] WebView WASM call failed:", webViewError?.message);
throw new Error(`WebView WASM registerStepTwo failed: ${webViewError?.message || String(webViewError)}`);
}
}
throw new Error("WebView WASM is not ready. Please ensure WebView WASM is initialized before calling registerStepTwo().");
}
export async function registerStepThree(seed, threshold, index, megaPkArray, encryptionSignature, encryptedMegaSecret, dealingsKeyArray, dealingsKappaArray, transcriptKeySingle, transcriptKappaSingle, pedersenOpeningLambda) {
if (typeof global !== "undefined" &&
global.__intuWebViewWasmService &&
global.__intuWebViewWasmService.isWasmReady() &&
global.__intuWebViewWasmService.registerStepThree) {
try {
console.log("✅ [registerStepThree] Using WebView WASM");
const result = await global.__intuWebViewWasmService.registerStepThree(seed, threshold, index, megaPkArray, encryptionSignature, encryptedMegaSecret, dealingsKeyArray, dealingsKappaArray, transcriptKeySingle, transcriptKappaSingle, pedersenOpeningLambda);
return result;
}
catch (webViewError) {
console.error("❌ [registerStepThree] WebView WASM call failed:", webViewError?.message);
throw new Error(`WebView WASM registerStepThree failed: ${webViewError?.message || String(webViewError)}`);
}
}
throw new Error("WebView WASM is not ready. Please ensure WebView WASM is initialized before calling registerStepThree().");
}
export async function getMasterPublicKey(transcript_key) {
if (typeof global !== "undefined" &&
global.__intuWebViewWasmService &&
global.__intuWebViewWasmService.isWasmReady() &&
global.__intuWebViewWasmService.getMasterPublicKey) {
try {
console.log("✅ [getMasterPublicKey] Using WebView WASM");
const result = await global.__intuWebViewWasmService.getMasterPublicKey(transcript_key);
return result;
}
catch (webViewError) {
console.error("❌ [getMasterPublicKey] WebView WASM call failed:", webViewError?.message);
throw new Error(`WebView WASM getMasterPublicKey failed: ${webViewError?.message || String(webViewError)}`);
}
}
throw new Error("WebView WASM is not ready. Please ensure WebView WASM is initialized before calling getMasterPublicKey().");
}
export async function signTransaction(seed, threshold, index, message, encryptionSignature, encryptedMegaSecret, dealingKeyXLambdaArray, dealingKappaXLambdaArray, pedersenOpeningLambda, simpleTranscriptKey, simpleTranscriptKappa, transcriptLambda) {
throw new Error("signTransaction not implemented for React Native - use WebView WASM");
}
export async function signTransactionWithoutLambda(seed, message, encryptionSignature, openingSimpleKey, openingSimpleKappa, simpleTranscriptKey, simpleTranscriptKappa) {
throw new Error("signTransactionWithoutLambda not implemented for React Native - use WebView WASM");
}
export async function combineSignedTransactions(seed, threshold, message, signatureArray, transcript_key, transcript_kappa) {
throw new Error("combineSignedTransactions not implemented for React Native - use WebView WASM");
}
export async function combineSignedTransactionsWithoutLambda(seed, threshold, message, signatureArray, transcript_key, transcript_kappa) {
throw new Error("combineSignedTransactionsWithoutLambda not implemented for React Native - use WebView WASM");
}
export async function reshareStepByOriginalGroup(seed, threshold, index, encryptionSignature, simpleOpeningKey, newMegaPkArray) {
throw new Error("reshareStepByOriginalGroup not implemented for React Native - use WebView WASM");
}
export async function reshareStepOneByNewUser(seed, threshold, index, newMegaPkArray) {
throw new Error("reshareStepOneByNewUser not implemented for React Native - use WebView WASM");
}
export async function reshareStepTwo(seed, threshold_reshare, index, megaPkArray, encryptionSignature, encryptedMegaSecret, simple_dealings_key_reshared_once_or_twice, simpleTranscriptKey, pedersenDealingsKappaReshare, pedersenDealingsLambdaReshare) {
throw new Error("reshareStepTwo not implemented for React Native - use WebView WASM");
}
export async function reshareStepThree(seed, threshold_reshare, index, megaPkArray, encryptionSignature, encryptedMegaSecret, simpleDealingsKappaReshare, pedersenOpeningLambdaReshareArray, simple_dealings_key_reshared_once_or_twice, transcript_key_simple_or_reshared_once, transcriptKappaReshare) {
throw new Error("reshareStepThree not implemented for React Native - use WebView WASM");
}
export async function reshareSignTransaction(seed, threshold_reshare, index, message, encryptionSignature, encryptedMegaSecret, pedersenDealingsLambdaReshare, dealingsKeyXlambdaReshare, dealingsKappaXlambdaReshare, pedersenOpeningLambdaReshare, transcriptKeyResharedTwice, simpleTranscriptsKappaReshare) {
throw new Error("reshareSignTransaction not implemented for React Native - use WebView WASM");
}
export async function reshareCombineSignedTransactions(simpleTranscriptKappaReshare, transcriptKeyResharedTwice, threshold, seed, message, signatureArray) {
throw new Error("reshareCombineSignedTransactions not implemented for React Native - use WebView WASM");
}
export async function signMessage(seed, threshold, index, message, encryptionSignature, encryptedMegaSecret, dealingKeyXLambdaArray, dealingKappaXLambdaArray, pedersenOpeningLambda, simpleTranscriptKey, simpleTranscriptKappa, pedersenTranscriptLambda) {
throw new Error("signMessage not implemented for React Native - use WebView WASM");
}
export async function combineSignedMessages(seed, threshold, message, signatureArray, transcript_key, transcript_kappa) {
throw new Error("combineSignedMessages not implemented for React Native - use WebView WASM");
}
export async function createMessage(message) {
throw new Error("createMessage not implemented for React Native - use WebView WASM");
}
//# sourceMappingURL=index.native.js.map