Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oddsdk/odd-walletauth
Use your blockchain wallet as an ODD SDK authentication strategy.
https://github.com/oddsdk/odd-walletauth
blockchain ethereum fission odd oddjs
Last synced: 11 days ago
JSON representation
Use your blockchain wallet as an ODD SDK authentication strategy.
- Host: GitHub
- URL: https://github.com/oddsdk/odd-walletauth
- Owner: oddsdk
- License: apache-2.0
- Created: 2022-04-19T15:20:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-11T17:45:03.000Z (over 1 year ago)
- Last Synced: 2024-04-28T07:19:02.912Z (7 months ago)
- Topics: blockchain, ethereum, fission, odd, oddjs
- Language: TypeScript
- Homepage: https://fission.codes/walletauth/
- Size: 1.05 MB
- Stars: 6
- Watchers: 5
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Use the [ODD SDK](https://github.com/oddsdk/ts-odd#readme) 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.
```ts
import * as walletauth from "odd-walletauth";
import { AppScenario } from "@oddjs/odd";// Initialise
const program = await walletauth.program({
// optional event handlers
onAccountChange: (newProgram) => handleProgram(newProgram),
onDisconnect: () => {
/* eg. logout() */
},
});handleProgram(program);
function handleProgram(program) {
if (program.session) {
// ✅ Authenticated
} else {
// Failed to authenticate with wallet
}
}
```Use a custom Ethereum provider:
```ts
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](https://github.com/fission-codes/fission), 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.
```ts
import { Implementation } from "odd-walletauth/wallet/implementation"const impl: Implementation = {
decrypt: (encryptedMessage: Uint8Array) => Promise,
encrypt: (storage: Storage.Implementation, data: Uint8Array) => Promise,
init: (storage: Storage.Implementation, args: InitArgs) => Promise,
publicSignature: {
type: string
magicBytes: Uint8Array
key: (storage: Storage.Implementation) => Promise
},
sign: (data: Uint8Array) => Promise,
ucanAlgorithm: string,
username: () => Promise,
verifySignedMessage: (storage: Storage.Implementation, args: VerifyArgs) => Promise,
}// When creating a Program indicate that you want to use your custom wallet implementation.
walletauth.program({
wallet: impl
})
```