Use the ODD SDK with a blockchain wallet. Access your personal encrypted file system with your wallet keys.
Usage
Uses Ethereum by default with window.ethereum
as the provider. Currently only works with MetaMask because it's the only wallet with encryption and decryption.
import * as walletauth from "odd-walletauth";
import { AppScenario } from "odd";
const program = await walletauth.program({
onAccountChange: (newProgram) => handleProgram(newProgram),
onDisconnect: () => {
},
});
handleProgram(program);
function handleProgram(program) {
if (program.session) {
} else {
}
}
Use a custom Ethereum provider:
import * as ethereum from "odd-walletauth/wallet/ethereum";
ethereum.setProvider(window.ethereum);
You can also write an implementation for other wallets. Note that the DID method has to be supported by the Fission server, unless you're using other services with the ODD SDK. At the moment of writing, you can only use the key
method for DIDs with the Fission servers. It supports ED25519, RSA and SECP256K1 keys, same for the UCAN algorithms.
import { Implementation } from "odd-walletauth/wallet/implementation"
const impl: Implementation = {
decrypt: (encryptedMessage: Uint8Array) => Promise<Uint8Array>,
encrypt: (storage: Storage.Implementation, data: Uint8Array) => Promise<Uint8Array>,
init: (storage: Storage.Implementation, args: InitArgs) => Promise<void>,
publicSignature: {
type: string
magicBytes: Uint8Array
key: (storage: Storage.Implementation) => Promise<Uint8Array>
},
sign: (data: Uint8Array) => Promise<Uint8Array>,
ucanAlgorithm: string,
username: () => Promise<string>,
verifySignedMessage: (storage: Storage.Implementation, args: VerifyArgs) => Promise<boolean>,
}
walletauth.program({
wallet: impl
})