Skip to content

Commit

Permalink
LIT-2954 - Update ILitNodeClient interface to match implementation (#430
Browse files Browse the repository at this point in the history
)

* chore(types): LIT-2954 - Run Eslint --fix on `ILitNodeClient.ts` and update interface to match our implementation in `lit-core`

* chore(lit-node-client): LIT-2954 - Run Eslint --fix on `lit-node-client.ts`

* fix(lit-node-client-nodejs): LIT-2954 - Update LitNodeClientNodeJs to `implement` ILitNodeClient

* fix(lit-node-client): LIT-2954 - Update `LitNodeClient`'s constructor args type to no longer be a union with `any`

* fix(types): LIT-2954 - Remove dangling `type` keyword (cmon webstorm, y u do that?) and unused import
  • Loading branch information
MaximusHaximus authored Apr 18, 2024
1 parent 83a070b commit 8efcb0f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ import type {
SuccessNodePromises,
ValidateAndSignECDSA,
WebAuthnAuthenticationVerificationParams,
ILitNodeClient,
} from '@lit-protocol/types';

// TODO: move this to auth-helper for next patch
Expand All @@ -126,7 +127,7 @@ interface CapacityCreditsRes {

export class LitNodeClientNodeJs
extends LitCore
implements LitClientSessionManager
implements LitClientSessionManager, ILitNodeClient
{
defaultAuthCallback?: (authSigParams: AuthCallbackParams) => Promise<AuthSig>;

Expand Down
8 changes: 4 additions & 4 deletions packages/lit-node-client/src/lib/lit-node-client.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { LitNodeClientNodeJs } from '@lit-protocol/lit-node-client-nodejs';
import { checkAndSignAuthMessage } from '@lit-protocol/auth-browser';
import { CustomNetwork, LitNodeClientConfig } from '@lit-protocol/types';
import { EITHER_TYPE } from '@lit-protocol/constants';
import { LitNodeClientNodeJs } from '@lit-protocol/lit-node-client-nodejs';
import { isNode, log } from '@lit-protocol/misc';
import { getStorageItem } from '@lit-protocol/misc-browser';
import { EITHER_TYPE } from '@lit-protocol/constants';
import { CustomNetwork, LitNodeClientConfig } from '@lit-protocol/types';

export class LitNodeClient extends LitNodeClientNodeJs {
constructor(args: any[LitNodeClientConfig | CustomNetwork | any]) {
constructor(args: LitNodeClientConfig | CustomNetwork) {
super({
...args,
defaultAuthCallback: checkAndSignAuthMessage,
Expand Down
23 changes: 13 additions & 10 deletions packages/types/src/lib/ILitNodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import {
GetSignedTokenRequest,
HandshakeWithNode,
JsonExecutionRequest,
KV,
JsonHandshakeResponse,
LitNodeClientConfig,
MultipleAccessControlConditions,
NodeBlsSigningShare,
NodeCommandResponse,
NodeCommandServerKeysResponse,
NodeShare,
RejectedNodePromises,
SendNodeCommand,
SignConditionECDSA,
Expand All @@ -27,8 +26,8 @@ import { SupportedJsonRequests } from './types';

export interface ILitNodeClient {
config: LitNodeClientConfig;
connectedNodes: SetConstructor | Set<any> | any;
serverKeys: KV | any;
connectedNodes: Set<string>;
serverKeys: Record<string, JsonHandshakeResponse>;
ready: boolean;
subnetPubKey: string | null;
networkPubKey: string | null;
Expand All @@ -48,7 +47,7 @@ export interface ILitNodeClient {
* @returns { void }
*
*/
overrideConfigsFromLocalStorage(): void;
overrideConfigsFromLocalStorage?(): void;

/**
*
Expand Down Expand Up @@ -86,7 +85,7 @@ export interface ILitNodeClient {
* @returns { string } final JWT (convert the sig to base64 and append to the jwt)
*
*/
combineSharesAndGetJWT(signatureShares: Array<NodeBlsSigningShare>): string;
combineSharesAndGetJWT(signatureShares: NodeBlsSigningShare[]): string;

/**
*
Expand Down Expand Up @@ -125,18 +124,22 @@ export interface ILitNodeClient {
* @returns { Array<Promise<any>> }
*
*/
getNodePromises(callback: Function): Array<Promise<any>>;
getNodePromises(callback: Function): Promise<any>[];

/**
* Handle node promises
*
* @param { Array<Promise<T>> } nodePromises
*
* @param {string} requestId request Id used for logging
* @param {number} minNodeCount The minimum number of nodes we need a successful response from to continue
* @returns { Promise<SuccessNodePromises<T> | RejectedNodePromises> }
*
*/
handleNodePromises<T>(
nodePromises: Array<Promise<T>>
nodePromises: Promise<T>[],
requestId: string,
minNodeCount: number
): Promise<SuccessNodePromises<T> | RejectedNodePromises>;

/**
Expand All @@ -160,7 +163,7 @@ export interface ILitNodeClient {
* @returns { any }
*
*/
getSignatures(signedData: Array<any>, requestId: string): any;
getSignatures(signedData: any[], requestId: string): any;

/**
*
Expand All @@ -182,7 +185,7 @@ export interface ILitNodeClient {
* @returns { string } signature
*
*/
getSignature(shareData: Array<any>, requestId: string): Promise<any>;
getSignature(shareData: any[], requestId: string): Promise<any>;

// ========== API Calls to Nodes ==========
sendCommandToNode({ url, data, requestId }: SendNodeCommand): Promise<any>;
Expand Down

0 comments on commit 8efcb0f

Please sign in to comment.