non working LIT jwt
This commit is contained in:
parent
95566d6f36
commit
042f9209ed
@ -40,6 +40,7 @@
|
||||
"@lit-protocol/pkp-client": "^2.2.50",
|
||||
"@lit-protocol/types": "^2.2.50",
|
||||
"@tanstack/svelte-query": "^4.29.1",
|
||||
"@wagmi/core": "^1.3.9",
|
||||
"@wundergraph/sdk": "^0.174.5",
|
||||
"@wundergraph/svelte-query": "^0.3.10",
|
||||
"axios": "^1.4.0",
|
||||
@ -52,6 +53,7 @@
|
||||
"jwks-rsa": "^3.0.1",
|
||||
"node-jose": "^2.2.0",
|
||||
"path": "^0.12.7",
|
||||
"svelte-kit-cookie-session": "^4.0.0",
|
||||
"url": "^0.11.1"
|
||||
},
|
||||
"type": "module"
|
||||
|
752
pnpm-lock.yaml
752
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -159,7 +159,7 @@
|
||||
<div class="mt-4 text-center">
|
||||
<p>{status}</p>
|
||||
</div>
|
||||
{#if activeSession}
|
||||
<!-- {#if activeSession}
|
||||
<div>
|
||||
<h3>Active Session:</h3>
|
||||
<p>Node: {activeSession.node}</p>
|
||||
@ -174,6 +174,6 @@
|
||||
</p>
|
||||
{/each}
|
||||
{/if}
|
||||
{/if}
|
||||
{/if} -->
|
||||
</div>
|
||||
</div>
|
||||
|
@ -2,6 +2,7 @@
|
||||
<script lang="ts">
|
||||
import { ethers } from "ethers";
|
||||
import { onMount } from "svelte";
|
||||
// import { fetchBalance, serialize } from "@wagmi/core";
|
||||
|
||||
export let messageToSign = {};
|
||||
|
||||
@ -23,7 +24,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
export async function signMessageWithPKP() {
|
||||
async function signMessageWithPKP() {
|
||||
const userConfirmed = window.confirm(
|
||||
"Do you want to sign the following message?\n\n" +
|
||||
JSON.stringify(messageToSign, null, 2)
|
||||
@ -86,9 +87,45 @@
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
async function getJWT() {
|
||||
var unifiedAccessControlConditions = [
|
||||
{
|
||||
conditionType: "evmBasic",
|
||||
contractAddress: "",
|
||||
standardContractType: "",
|
||||
chain: "xdai",
|
||||
method: "eth_getBalance",
|
||||
parameters: [":userAddress", "latest"],
|
||||
returnValueTest: {
|
||||
comparator: ">=",
|
||||
value: "10000000000000",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// Saving signing condition
|
||||
await litNodeClient.saveSigningCondition({
|
||||
unifiedAccessControlConditions,
|
||||
sessionSigs,
|
||||
resourceId: { test: "hello" },
|
||||
chain: "litSessionSign",
|
||||
});
|
||||
|
||||
// Retrieving a signature
|
||||
let jwt = await litNodeClient.getSignedToken({
|
||||
unifiedAccessControlConditions,
|
||||
sessionSigs,
|
||||
resourceId: { test: "hello" },
|
||||
});
|
||||
|
||||
alert("JWT: " + jwt);
|
||||
}
|
||||
</script>
|
||||
|
||||
<button on:click={signMessageWithPKP}>Sign Message</button>
|
||||
<button on:click={getJWT}>Get JWT</button>
|
||||
|
||||
{#if messageToSign}
|
||||
<pre>{JSON.stringify(messageToSign)}</pre>
|
||||
{/if}
|
||||
|
58
src/lib/setupChainProvider.ts
Normal file
58
src/lib/setupChainProvider.ts
Normal file
@ -0,0 +1,58 @@
|
||||
import { configureChains, createConfig } from '@wagmi/core';
|
||||
import { gnosis } from '@wagmi/core/chains';
|
||||
import { publicProvider } from '@wagmi/core/providers/public';
|
||||
import { InjectedConnector } from '@wagmi/core/connectors/injected';
|
||||
import { jsonRpcProvider } from '@wagmi/core/providers/jsonRpc';
|
||||
|
||||
// const chronicleChain = {
|
||||
// id: 175177,
|
||||
// name: 'Chronicle',
|
||||
// network: 'chronicle',
|
||||
|
||||
// nativeCurrency: {
|
||||
// decimals: 18,
|
||||
// name: 'Chronicle - Lit Protocol Testnet',
|
||||
// symbol: 'LIT'
|
||||
// },
|
||||
// rpcUrls: {
|
||||
// default: {
|
||||
// http: ['https://chain-rpc.litprotocol.com/http']
|
||||
// },
|
||||
// public: {
|
||||
// http: ['https://chain-rpc.litprotocol.com/http']
|
||||
// }
|
||||
// },
|
||||
// blockExplorers: {
|
||||
// default: {
|
||||
// name: 'Chronicle - Lit Protocol Testnet',
|
||||
// url: 'https://chain.litprotocol.com'
|
||||
// }
|
||||
// },
|
||||
// testnet: true
|
||||
// };
|
||||
|
||||
export function initChainProvider() {
|
||||
const { chains, publicClient } = configureChains(
|
||||
[gnosis],
|
||||
[
|
||||
jsonRpcProvider({
|
||||
rpc: (chain) => ({ http: chain.rpcUrls.default.http[0] })
|
||||
}),
|
||||
jsonRpcProvider({
|
||||
rpc: () => ({
|
||||
http: `https://rpc.ankr.com/gnosis`,
|
||||
wss: `wss://rpc.gnosischain.com/wss`
|
||||
})
|
||||
}),
|
||||
publicProvider()
|
||||
]
|
||||
);
|
||||
createConfig({
|
||||
autoConnect: true,
|
||||
connectors: [
|
||||
new InjectedConnector({ chains }),
|
||||
],
|
||||
publicClient
|
||||
});
|
||||
}
|
||||
|
@ -3,11 +3,17 @@
|
||||
import type { LayoutData } from "./$types";
|
||||
import { client } from "$lib/wundergraph";
|
||||
import Cookies from "js-cookie";
|
||||
import { onMount } from "svelte";
|
||||
import { initChainProvider } from "$lib/setupChainProvider";
|
||||
|
||||
export let data: LayoutData;
|
||||
|
||||
const token = Cookies.get("token");
|
||||
|
||||
onMount(() => {
|
||||
initChainProvider();
|
||||
});
|
||||
|
||||
if (token) {
|
||||
client.setAuthorizationToken(token);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user