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/pkp-client": "^2.2.50",
|
||||||
"@lit-protocol/types": "^2.2.50",
|
"@lit-protocol/types": "^2.2.50",
|
||||||
"@tanstack/svelte-query": "^4.29.1",
|
"@tanstack/svelte-query": "^4.29.1",
|
||||||
|
"@wagmi/core": "^1.3.9",
|
||||||
"@wundergraph/sdk": "^0.174.5",
|
"@wundergraph/sdk": "^0.174.5",
|
||||||
"@wundergraph/svelte-query": "^0.3.10",
|
"@wundergraph/svelte-query": "^0.3.10",
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
@ -52,6 +53,7 @@
|
|||||||
"jwks-rsa": "^3.0.1",
|
"jwks-rsa": "^3.0.1",
|
||||||
"node-jose": "^2.2.0",
|
"node-jose": "^2.2.0",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
|
"svelte-kit-cookie-session": "^4.0.0",
|
||||||
"url": "^0.11.1"
|
"url": "^0.11.1"
|
||||||
},
|
},
|
||||||
"type": "module"
|
"type": "module"
|
||||||
|
752
pnpm-lock.yaml
generated
752
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -159,7 +159,7 @@
|
|||||||
<div class="mt-4 text-center">
|
<div class="mt-4 text-center">
|
||||||
<p>{status}</p>
|
<p>{status}</p>
|
||||||
</div>
|
</div>
|
||||||
{#if activeSession}
|
<!-- {#if activeSession}
|
||||||
<div>
|
<div>
|
||||||
<h3>Active Session:</h3>
|
<h3>Active Session:</h3>
|
||||||
<p>Node: {activeSession.node}</p>
|
<p>Node: {activeSession.node}</p>
|
||||||
@ -174,6 +174,6 @@
|
|||||||
</p>
|
</p>
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if} -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ethers } from "ethers";
|
import { ethers } from "ethers";
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
|
// import { fetchBalance, serialize } from "@wagmi/core";
|
||||||
|
|
||||||
export let messageToSign = {};
|
export let messageToSign = {};
|
||||||
|
|
||||||
@ -23,7 +24,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export async function signMessageWithPKP() {
|
async function signMessageWithPKP() {
|
||||||
const userConfirmed = window.confirm(
|
const userConfirmed = window.confirm(
|
||||||
"Do you want to sign the following message?\n\n" +
|
"Do you want to sign the following message?\n\n" +
|
||||||
JSON.stringify(messageToSign, null, 2)
|
JSON.stringify(messageToSign, null, 2)
|
||||||
@ -86,9 +87,45 @@
|
|||||||
console.error(err);
|
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>
|
</script>
|
||||||
|
|
||||||
<button on:click={signMessageWithPKP}>Sign Message</button>
|
<button on:click={signMessageWithPKP}>Sign Message</button>
|
||||||
|
<button on:click={getJWT}>Get JWT</button>
|
||||||
|
|
||||||
{#if messageToSign}
|
{#if messageToSign}
|
||||||
<pre>{JSON.stringify(messageToSign)}</pre>
|
<pre>{JSON.stringify(messageToSign)}</pre>
|
||||||
{/if}
|
{/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 type { LayoutData } from "./$types";
|
||||||
import { client } from "$lib/wundergraph";
|
import { client } from "$lib/wundergraph";
|
||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import { initChainProvider } from "$lib/setupChainProvider";
|
||||||
|
|
||||||
export let data: LayoutData;
|
export let data: LayoutData;
|
||||||
|
|
||||||
const token = Cookies.get("token");
|
const token = Cookies.get("token");
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
initChainProvider();
|
||||||
|
});
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
client.setAuthorizationToken(token);
|
client.setAuthorizationToken(token);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user