@inco/js 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/cjs/advancedacl/index.d.ts +2 -0
  2. package/dist/cjs/advancedacl/index.js +19 -0
  3. package/dist/cjs/advancedacl/session-key.d.ts +28 -0
  4. package/dist/cjs/advancedacl/session-key.js +176 -0
  5. package/dist/cjs/advancedacl/types.d.ts +15 -0
  6. package/dist/cjs/advancedacl/types.js +3 -0
  7. package/dist/cjs/attestedcompute/attested-compute.d.ts +14 -16
  8. package/dist/cjs/attestedcompute/attested-compute.js +56 -71
  9. package/dist/cjs/attesteddecrypt/attested-decrypt.d.ts +18 -19
  10. package/dist/cjs/attesteddecrypt/attested-decrypt.js +50 -60
  11. package/dist/cjs/attesteddecrypt/index.d.ts +0 -1
  12. package/dist/cjs/attesteddecrypt/index.js +1 -2
  13. package/dist/cjs/generated/abis/lightning-preview.d.ts +2265 -0
  14. package/dist/cjs/generated/abis/lightning-preview.js +1429 -0
  15. package/dist/cjs/lite/attested-compute.d.ts +1 -2
  16. package/dist/cjs/lite/attested-compute.js +1 -4
  17. package/dist/cjs/lite/attested-decrypt.d.ts +1 -2
  18. package/dist/cjs/lite/attested-decrypt.js +1 -4
  19. package/dist/cjs/lite/lightning.d.ts +94 -1
  20. package/dist/cjs/lite/lightning.js +129 -2
  21. package/dist/cjs/local/local-node.d.ts +1 -1
  22. package/dist/cjs/local/local-node.js +15 -15
  23. package/dist/esm/advancedacl/index.d.ts +2 -0
  24. package/dist/esm/advancedacl/index.js +3 -0
  25. package/dist/esm/advancedacl/session-key.d.ts +28 -0
  26. package/dist/esm/advancedacl/session-key.js +170 -0
  27. package/dist/esm/advancedacl/types.d.ts +15 -0
  28. package/dist/esm/advancedacl/types.js +2 -0
  29. package/dist/esm/attestedcompute/attested-compute.d.ts +14 -16
  30. package/dist/esm/attestedcompute/attested-compute.js +55 -70
  31. package/dist/esm/attesteddecrypt/attested-decrypt.d.ts +18 -19
  32. package/dist/esm/attesteddecrypt/attested-decrypt.js +49 -59
  33. package/dist/esm/attesteddecrypt/index.d.ts +0 -1
  34. package/dist/esm/attesteddecrypt/index.js +1 -2
  35. package/dist/esm/generated/abis/lightning-preview.d.ts +2265 -0
  36. package/dist/esm/generated/abis/lightning-preview.js +1426 -0
  37. package/dist/esm/lite/attested-compute.d.ts +1 -2
  38. package/dist/esm/lite/attested-compute.js +2 -3
  39. package/dist/esm/lite/attested-decrypt.d.ts +1 -2
  40. package/dist/esm/lite/attested-decrypt.js +2 -3
  41. package/dist/esm/lite/lightning.d.ts +94 -1
  42. package/dist/esm/lite/lightning.js +129 -2
  43. package/dist/esm/local/local-node.d.ts +1 -1
  44. package/dist/esm/local/local-node.js +3 -3
  45. package/dist/types/advancedacl/index.d.ts +2 -0
  46. package/dist/types/advancedacl/session-key.d.ts +28 -0
  47. package/dist/types/advancedacl/types.d.ts +15 -0
  48. package/dist/types/attestedcompute/attested-compute.d.ts +14 -16
  49. package/dist/types/attesteddecrypt/attested-decrypt.d.ts +18 -19
  50. package/dist/types/attesteddecrypt/index.d.ts +0 -1
  51. package/dist/types/generated/abis/lightning-preview.d.ts +2265 -0
  52. package/dist/types/lite/attested-compute.d.ts +1 -2
  53. package/dist/types/lite/attested-decrypt.d.ts +1 -2
  54. package/dist/types/lite/lightning.d.ts +94 -1
  55. package/dist/types/local/local-node.d.ts +1 -1
  56. package/package.json +1 -1
@@ -1,4 +1,3 @@
1
- import { type IncoLiteAttestedComputeArgs, incoLiteAttestedCompute } from '../attestedcompute/attested-compute.js';
1
+ import { type IncoLiteAttestedComputeArgs } from '../attestedcompute/attested-compute.js';
2
2
  import { type AttestedComputeSupportedOps } from '../attestedcompute/types.js';
3
- export { incoLiteAttestedCompute };
4
3
  export type { AttestedComputeSupportedOps, IncoLiteAttestedComputeArgs };
@@ -1,3 +1,2 @@
1
- import { type IncoLiteAttestedDecryptorArgs, incoLiteAttestedDecryptor } from '../attesteddecrypt/attested-decrypt.js';
2
- export { incoLiteAttestedDecryptor };
1
+ import { type IncoLiteAttestedDecryptorArgs } from '../attesteddecrypt/attested-decrypt.js';
3
2
  export type { IncoLiteAttestedDecryptorArgs };
@@ -1,10 +1,15 @@
1
1
  import { Account, Chain, Transport, WalletClient } from 'viem';
2
+ import { AllowanceVoucherWithSig } from '../advancedacl/types.js';
3
+ import { AttestedComputeOP } from '../attestedcompute/types.js';
4
+ import { DecryptionAttestation } from '../attesteddecrypt/index.js';
2
5
  import { Address, HexString } from '../binary.js';
3
- import { EciesScheme } from '../encryption/index.js';
6
+ import { EciesScheme, PlaintextOf, SupportedFheType } from '../encryption/index.js';
4
7
  import { lightningDeployments } from '../generated/lightning.js';
5
8
  import { localNodeLightningConfig } from '../generated/local-node.js';
6
9
  import { LocalNodeEnv } from '../local/index.js';
7
10
  import type { Reencryptor } from '../reencryption/index.js';
11
+ import { BackoffConfig } from '../retry.js';
12
+ import { Secp256k1Keypair } from './ecies.js';
8
13
  type TupleToUnion<T> = T extends readonly unknown[] ? T[number] : never;
9
14
  type Deployment = TupleToUnion<typeof lightningDeployments>;
10
15
  type DistributedPick<T, K> = T extends any ? Pick<T, Extract<keyof T, K>> : never;
@@ -120,6 +125,94 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
120
125
  * @param walletClient the wallet client to use for signing the reencrypt request.
121
126
  */
122
127
  getReencryptor(walletClient: WalletClient<Transport, Chain, Account>): Promise<Reencryptor<EciesScheme>>;
128
+ /**
129
+ * Grants a session key allowance voucher for secure reencryption operations.
130
+ *
131
+ * This method creates a signed allowance voucher that authorizes a specific requester address
132
+ * to perform reencryption operations using session keys. The voucher includes an expiration time
133
+ * and can optionally specify a custom session verifier contract address.
134
+ *
135
+ * @param walletClient - The wallet client used for signing the allowance voucher
136
+ * @param granteeAddress - The address of the entity requesting the session key allowance
137
+ * @param expiresAt - The timestamp when the allowance voucher expires (as a bigint)
138
+ * @param sessionVerifierAddress - Optional custom session verifier contract address. If not provided, uses the executor address
139
+ * @returns A promise that resolves to an AllowanceVoucherWithSig containing the signed allowance voucher
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * const voucher = await lightning.grantSessionKeyAllowanceVoucher(
144
+ * walletClient,
145
+ * "0x1234...",
146
+ * BigInt(Date.now() + 3600000), // 1 hour from now
147
+ * "0x5678..." // optional custom verifier
148
+ * );
149
+ * ```
150
+ */
151
+ grantSessionKeyAllowanceVoucher(walletClient: WalletClient<Transport, Chain, Account>, granteeAddress: string, expiresAt: Date, sessionVerifierAddress: string): Promise<AllowanceVoucherWithSig>;
152
+ /**
153
+ * Creates a session key reencryptor for secure data reencryption operations.
154
+ *
155
+ * This method returns a reencryptor instance that can be used to perform reencryption
156
+ * operations using session keys. The reencryptor is configured with the provided
157
+ * allowance voucher and ephemeral keypair for secure communication.
158
+ *
159
+ * @param allowanceVoucherWithSig - The signed allowance voucher obtained from grantSessionKeyAllowanceVoucher
160
+ * @param ephemeralKeypair - The ephemeral keypair used for secure communication with the KMS make sure it has allowance to voucher
161
+ * @returns A reencryptor instance configured for session key operations
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * const reencryptor = await lightning.getSessionKeyRencryptor(voucher, ephemeralKeypair);
166
+ * const decryptedValue = await reencryptor({handle: resultHandle});
167
+ * ```
168
+ */
169
+ getSessionKeyRencryptor(allowanceVoucherWithSig: AllowanceVoucherWithSig, ephemeralKeypair: Secp256k1Keypair): Promise<(<T_1 extends SupportedFheType>({ handle }: import("../reencryption/types.js").ReencryptFnArgs<EciesScheme, T_1>) => Promise<PlaintextOf<1, 0 | 5 | 7 | 8>>)>;
170
+ /**
171
+ * Updates the active session nonce for the given wallet client.
172
+ *
173
+ * This method updates the active session nonce for the given wallet client.
174
+ * It nullifies all the previous shared addresses accessing the voucher.
175
+ *
176
+ * @param walletClient - The wallet client used for updating the session nonce
177
+ * @returns The transaction hash of the updateActiveVouchersSessionNonce transaction
178
+ */
179
+ updateActiveVouchersSessionNonce(walletClient: WalletClient<Transport, Chain, Account>): Promise<HexString>;
180
+ /**
181
+ * Get an attested decryptor for the given wallet client.
182
+ *
183
+ * @param walletClient - The wallet client used for signing the attested decrypt request
184
+ * @param handles - The handles to decrypt
185
+ * @param backoffConfig - The backoff configuration for the attested decrypt request
186
+ * @returns The decryption attestations
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * const response = await lightning.attestedDecrypt(walletClient, [handle1, handle2]);
191
+ * const { plaintext, covalidatorSignature } = response[0];
192
+ * ```
193
+ */
194
+ attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
195
+ /**
196
+ * Get an attested compute for the given wallet client.
197
+ *
198
+ * @param walletClient - The wallet client used for signing the attested compute request
199
+ * @param lhsHandle - The handle to compute
200
+ * @param op - The operation to perform
201
+ * @param rhsPlaintext - The plaintext to compute with
202
+ * @param backoffConfig - The backoff configuration for the attested compute request
203
+ * @returns The decryption attestation
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * import { AttestedComputeSupportedOps } from '../lite/attested-compute.js';
208
+ * const lhsHandle = '0x...';
209
+ * const rhsPlaintext = 1337n;
210
+ * const op = AttestedComputeSupportedOps.Eq;
211
+ * const response = await lightning.attestedCompute(walletClient, lhsHandle, op, rhsPlaintext);
212
+ * const { plaintext, covalidatorSignature, handle } = response;
213
+ * ```
214
+ */
215
+ attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
123
216
  /**
124
217
  * Get the GRPC endpoint for the covalidator that services this deployment.
125
218
  */
@@ -15,7 +15,7 @@ export declare const LocalNodeEnv: Schema.Struct<{
15
15
  COVALIDATOR_INCO_EXECUTOR_ADDR: Schema.brand<Schema.filter<Schema.TemplateLiteral<`0x${string}`>>, "Address">;
16
16
  COVALIDATOR_DECRYPTION_HANDLER_ADDR: Schema.brand<Schema.filter<Schema.TemplateLiteral<`0x${string}`>>, "Address">;
17
17
  COVALIDATOR_HOST_CHAIN_ID: Schema.optional<typeof Schema.String>;
18
- COVALIDATOR_GRPC_SERVER_ADDRESS: Schema.optional<typeof Schema.String>;
18
+ COVALIDATOR_URL: Schema.optional<typeof Schema.String>;
19
19
  COVALIDATOR_HOST_CHAIN_RPC_URL: Schema.optional<typeof Schema.String>;
20
20
  }>;
21
21
  export type LocalNodeEnv = typeof LocalNodeEnv.Type;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inco/js",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "repository": "https://github.com/Inco-fhevm/inco-monorepo",
5
5
  "sideEffects": false,
6
6
  "scripts": {