Add IDX as user identity provider

Signed-off-by: Sebastian Martinez <sebastinez@me.com>
This commit is contained in:
Sebastian Martinez
2021-06-24 12:17:45 -03:00
parent 73a213f234
commit dcdec8c8e1
9 changed files with 771 additions and 21 deletions
+27
View File
@@ -0,0 +1,27 @@
<script lang="ts">
import { onMount } from 'svelte';
import type { Config } from '@app/config';
import { Caip10Link } from '@ceramicnetwork/stream-caip10-link';
import { EthereumAuthProvider } from '@ceramicnetwork/blockchain-utils-linking';
export let did: string;
export let caip10: string;
export let config: Config;
onMount(async () => {
if (config.signer) {
const address = await config.signer.getAddress();
const ethAuthProvider = new EthereumAuthProvider(
// TODO: Using the window.ethereum provider here since the config provider is throwing error.
window.ethereum, address
);
const accountLink = await Caip10Link.fromAccount(config.ceramic.client, caip10.toLowerCase());
await accountLink.setDid(
did,
ethAuthProvider
);
}
});
</script>
+11
View File
@@ -0,0 +1,11 @@
<script lang="ts">
import { Route } from "svelte-routing";
import Link from '@app/base/idx/Link.svelte';
import type { Config } from '@app/config';
export let config: Config;
</script>
<Route path="/idx/:did/link/:caip10" let:params>
<Link {config} did={params.did} caip10={params.caip10} />
</Route>