Add encrypted storage support for embedded webview in android #42
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "web-wallet",
|
||||
"version": "0.1.7-nym-0.1.2",
|
||||
"version": "0.1.7-nym-0.1.3",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@cerc-io/registry-sdk": "^0.2.5",
|
||||
|
||||
9
src/global.d.ts
vendored
9
src/global.d.ts
vendored
@ -3,6 +3,15 @@ declare global {
|
||||
interface Window {
|
||||
// Android bridge callbacks for signature and accounts related events
|
||||
Android?: {
|
||||
// Store a key-value pair securely in encrypted storage
|
||||
setItem(key: string, value: string): boolean;
|
||||
|
||||
// Retrieve a value by key from encrypted storage
|
||||
getItem(key: string): string | null;
|
||||
|
||||
// Remove a key-value pair from encrypted storage
|
||||
removeItem(key: string): boolean;
|
||||
|
||||
// Called when signature is successfully generated
|
||||
onSignatureComplete?: (signature: string) => void;
|
||||
|
||||
|
||||
@ -40,12 +40,12 @@ export const useWebViewHandler = () => {
|
||||
try {
|
||||
// Get available networks data
|
||||
const networksData = await retrieveNetworksData();
|
||||
|
||||
|
||||
if (!networksData || networksData.length === 0) {
|
||||
window.Android?.onAccountError?.('No networks configured');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Create wallet using the provided mnemonic if it doesn't exist
|
||||
const walletExists = await isWalletCreated();
|
||||
if (!walletExists) {
|
||||
|
||||
@ -1,13 +1,28 @@
|
||||
const setInternetCredentials = (name:string, username:string, password:string) => {
|
||||
localStorage.setItem(name, password);
|
||||
if (window.Android?.setItem) {
|
||||
window.Android.setItem(name, password);
|
||||
} else {
|
||||
localStorage.setItem(name, password);
|
||||
}
|
||||
};
|
||||
|
||||
const getInternetCredentials = (name:string) : string | null => {
|
||||
return localStorage.getItem(name);
|
||||
if (window.Android?.getItem) {
|
||||
const result = window.Android.getItem(name);
|
||||
|
||||
// Normalize undefined to null to match localStorage behavior
|
||||
return result === undefined ? null : result;
|
||||
} else {
|
||||
return localStorage.getItem(name);
|
||||
}
|
||||
};
|
||||
|
||||
const resetInternetCredentials = (name:string) => {
|
||||
localStorage.removeItem(name);
|
||||
if (window.Android?.removeItem) {
|
||||
window.Android.removeItem(name);
|
||||
} else {
|
||||
localStorage.removeItem(name);
|
||||
}
|
||||
};
|
||||
|
||||
export {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user