Skip to content

use eth blockhash as webauthn challenge #507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
"jszip": "^3.10.1",
"micromodal": "^0.4.10",
"multiformats": "^9.7.1",
"nanoid": "3.3.4",
"next": "13.3.0",
"react": "18.0.0",
"react-dom": "18.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/lit-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class LitCore {
lastUpdateTime: null,
};
private _blockHashUrl =
'http://block-indexer.litgateway.com/get_most_recent_valid_block';
'https://block-indexer.litgateway.com/get_most_recent_valid_block';

// ========== Constructor ==========
constructor(config: LitNodeClientConfig | CustomNetwork) {
Expand Down
2 changes: 1 addition & 1 deletion packages/lit-auth-client/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export default {
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/packages/lit-auth-client',
transformIgnorePatterns: ['/node_modules/(?!(@simplewebauthn|nanoid)/)'],
transformIgnorePatterns: ['/node_modules/(?!(@simplewebauthn)/)'],
setupFilesAfterEnv: ['../../jest.setup.js'],
};
3 changes: 1 addition & 2 deletions packages/lit-auth-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
],
"peerDependencies": {
"@simplewebauthn/browser": "^7.2.0",
"@simplewebauthn/typescript-types": "^7.0.0",
"nanoid": "3.3.4"
"@simplewebauthn/typescript-types": "^7.0.0"
},
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts"
Expand Down
5 changes: 0 additions & 5 deletions packages/lit-auth-client/src/lib/providers/BaseProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ import { ethers } from 'ethers';
import { validateMintRequestBody } from '../validators';

export abstract class BaseProvider {
/**
* Endpoint to interact with a blockchain network. Defaults to the Lit Chronicle.
*/
public rpcUrl: string;
/**
* Relay server to subsidize minting of PKPs
*/
Expand All @@ -37,7 +33,6 @@ export abstract class BaseProvider {
public litNodeClient: LitNodeClient;

constructor(options: BaseProviderOptions) {
this.rpcUrl = options.rpcUrl;
this.relay = options.relay;
this.litNodeClient = options.litNodeClient;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ export default class WebAuthnProvider extends BaseProvider {
* @returns {Promise<AuthMethod>} - Auth method object containing WebAuthn authentication data
*/
public async authenticate(): Promise<AuthMethod> {
const provider = new ethers.providers.JsonRpcProvider(this.rpcUrl);

const block = await provider.getBlock('latest');
const blockHash = block.hash;

const blockHash = await this.litNodeClient.getLatestBlockhash();
// Turn into byte array
const blockHashBytes = ethers.utils.arrayify(blockHash);

Expand Down
3 changes: 1 addition & 2 deletions packages/lit-auth-client/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ export function getProviderFromUrl(): string | null {
* @returns {Promise<string>} - State param
*/
export async function setStateParam(): Promise<string> {
const { nanoid } = await import('nanoid');
const state = nanoid(15);
const state = Math.random().toString(36).substring(2, 17);
sessionStorage.setItem(STATE_PARAM_KEY, state);
return state;
}
Expand Down
4 changes: 0 additions & 4 deletions packages/types/src/lib/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1480,10 +1480,6 @@ export interface IRelayPKP {
}

export interface BaseProviderOptions {
/**
* Endpoint to interact with a blockchain network. Defaults to the Lit Chronicle.
*/
rpcUrl: string;
/**
* Relay server to use
*/
Expand Down
Loading
Loading