Skip to content

Commit 2ea0dcb

Browse files
committed
feat(ILitNodeClient): sync interface
1 parent 234b283 commit 2ea0dcb

File tree

1 file changed

+44
-127
lines changed

1 file changed

+44
-127
lines changed
Lines changed: 44 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import {
2+
AuthenticationContext,
3+
CapacityCreditsReq,
4+
CapacityCreditsRes,
5+
ClaimKeyResponse,
26
DecryptRequest,
37
DecryptResponse,
48
EncryptResponse,
59
EncryptSdkParams,
610
ExecuteJsResponse,
7-
FormattedMultipleAccs,
8-
HandshakeWithNode,
911
JsonExecutionSdkParams,
1012
JsonHandshakeResponse,
13+
JsonPkpSignSdkParams,
1114
LitNodeClientConfig,
12-
MultipleAccessControlConditions,
13-
NodeCommandServerKeysResponse,
14-
RejectedNodePromises,
15-
SendNodeCommand,
16-
SuccessNodePromises,
15+
SigResponse,
1716
} from './interfaces';
18-
import { ILitResource, ISessionCapabilityObject } from './models';
19-
import { SupportedJsonRequests } from './types';
17+
18+
import { PRODUCT_IDS } from '@lit-protocol/constants';
19+
import { ClaimProcessor, ClaimRequest } from './types';
2020

2121
export interface ILitNodeClient {
2222
config: LitNodeClientConfig;
@@ -28,162 +28,79 @@ export interface ILitNodeClient {
2828
networkPubKeySet: string | null;
2929
latestBlockhash: string | null;
3030

31-
// ========== Constructor ==========
32-
// ** IMPORTANT !! You have to create your constructor when implementing this class **
33-
// constructor(customConfig: LitNodeClientConfig);
34-
35-
// ========== Scoped Class Helpers ==========
36-
31+
// ========== Core ==========
3732
/**
38-
*
39-
* Set bootstrapUrls to match the network litNetwork unless it's set to custom
40-
*
41-
* @returns { void }
42-
*
33+
* Connect to the LIT nodes
34+
* @returns { Promise } A promise that resolves when the nodes are connected.
4335
*/
44-
setCustomBootstrapUrls(): void;
36+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
37+
connect(): Promise<any>;
4538

39+
// ========== Helpers ==========
4640
/**
47-
*
48-
* Get different formats of access control conditions, eg. evm, sol, unified etc.
49-
*
50-
* @param { SupportedJsonRequests } params
51-
*
52-
* @returns { FormattedMultipleAccs }
53-
*
41+
* Set the default max price for a specific product
42+
* @param product - The product type to set the max price for
43+
* @param price - The max price to set
5444
*/
55-
getFormattedAccessControlConditions(
56-
params: SupportedJsonRequests
57-
): FormattedMultipleAccs;
45+
setDefaultMaxPrice(product: keyof typeof PRODUCT_IDS, price: bigint): void;
5846

5947
/**
60-
*
61-
* Get hash of access control conditions
62-
*
63-
* @param { MultipleAccessControlConditions } params
64-
*
65-
* @returns { Promise<ArrayBuffer | undefined> }
66-
*
48+
* Get PKP authentication context
49+
* @param params - Authentication context parameters
50+
* @returns Authentication context with PKP-specific configuration
6751
*/
68-
getHashedAccessControlConditions(
69-
params: MultipleAccessControlConditions
70-
): Promise<ArrayBuffer | undefined>;
71-
72-
// ========== Promise Handlers ==========
52+
getPkpAuthContext(params: AuthenticationContext): AuthenticationContext;
7353

7454
/**
75-
*
76-
* Get and gather node promises
77-
*
78-
* @param { string[] } nodeUrls URLs of nodes to get promises for
79-
* @param { any } callback
80-
*
81-
* @returns { Array<Promise<any>> }
82-
*
55+
* Get maximum prices for node products
56+
* @param params - Parameters including user max price and product type
8357
*/
84-
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any
85-
getNodePromises(nodeUrls: string[], callback: Function): Promise<any>[];
58+
getMaxPricesForNodeProduct(params: {
59+
userMaxPrice?: bigint;
60+
product: keyof typeof PRODUCT_IDS;
61+
}): { url: string; price: bigint }[];
8662

8763
/**
88-
* Handle node promises
89-
*
90-
* @param { Array<Promise<T>> } nodePromises
91-
*
92-
* @param {string} requestId request Id used for logging
93-
* @param {number} minNodeCount The minimum number of nodes we need a successful response from to continue
94-
* @returns { Promise<SuccessNodePromises<T> | RejectedNodePromises> }
95-
*
64+
* Create capacity delegation authentication signature
65+
* @param params - Capacity credits request parameters
9666
*/
97-
handleNodePromises<T>(
98-
nodePromises: Promise<T>[],
99-
requestId: string,
100-
minNodeCount: number
101-
): Promise<SuccessNodePromises<T> | RejectedNodePromises>;
67+
createCapacityDelegationAuthSig(
68+
params: CapacityCreditsReq
69+
): Promise<CapacityCreditsRes>;
10270

10371
/**
72+
* Encrypt data with Lit identity-based Timelock Encryption.
10473
*
105-
* Throw node error
106-
*
107-
* @param { RejectedNodePromises } res
108-
* @param { string } requestId
109-
*
110-
* @returns { void }
111-
*
74+
* @param params
11275
*/
113-
_throwNodeError(res: RejectedNodePromises, requestId: string): never;
114-
115-
// ========== API Calls to Nodes ==========
116-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
117-
sendCommandToNode({ url, data, requestId }: SendNodeCommand): Promise<any>;
76+
encrypt(params: EncryptSdkParams): Promise<EncryptResponse>;
11877

119-
/**
120-
*
121-
* Get JS Execution Shares from Nodes
122-
*
123-
* @param { JsonExecutionRequest } params
124-
*
125-
* @returns { Promise<any> }
126-
*/
78+
// ========== ENDPOINTS ==========
12779

12880
/**
129-
*
130-
* Handshake with SGX
131-
*
132-
* @param { HandshakeWithNode } params
133-
*
134-
* @returns { Promise<NodeCommandServerKeysResponse> }
135-
*
81+
* Sign using PKP
82+
* @param params - PKP signing parameters
13683
*/
137-
handshakeWithNode(
138-
params: HandshakeWithNode,
139-
requestId: string
140-
): Promise<NodeCommandServerKeysResponse>;
84+
pkpSign(params: JsonPkpSignSdkParams): Promise<SigResponse>;
14185

142-
// ========== Scoped Business Logics ==========
14386
/**
144-
*
14587
* Execute JS on the nodes and combine and return any resulting signatures
146-
*
14788
* @param { ExecuteJsRequest } params
148-
*
14989
* @returns { ExecuteJsResponse }
150-
*
15190
*/
15291
executeJs(
15392
params: JsonExecutionSdkParams
15493
): Promise<ExecuteJsResponse | undefined>;
15594

156-
/**
157-
* Encrypt data with Lit identity-based Timelock Encryption.
158-
*
159-
* @param params
160-
*/
161-
encrypt(params: EncryptSdkParams): Promise<EncryptResponse>;
162-
16395
/**
16496
* Decrypt data with Lit identity-based Timelock Encryption.
165-
*
16697
* @param params
16798
*/
16899
decrypt(params: DecryptRequest): Promise<DecryptResponse>;
169100

170101
/**
171-
*
172-
* Connect to the LIT nodes
173-
*
174-
* @returns { Promise } A promise that resolves when the nodes are connected.
175-
*
176-
*/
177-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
178-
connect(): Promise<any>;
179-
180-
/**
181-
* Generates a session capability object
182-
*
183-
* @param litResources An array of ILitResource to be processed.
184-
* @returns A Promise resolving to an ISessionCapabilityObject.
102+
* Claim a key ID using authentication method
103+
* @param params - Claim request parameters
185104
*/
186-
generateSessionCapabilityObjectWithWildcards(
187-
litResources: ILitResource[]
188-
): Promise<ISessionCapabilityObject>;
105+
claimKeyId(params: ClaimRequest<ClaimProcessor>): Promise<ClaimKeyResponse>;
189106
}

0 commit comments

Comments
 (0)