@newton-xyz/sdk 1.0.5 → 1.0.6

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.
@@ -0,0 +1,90 @@
1
+ import { type RegisterWebhookParams, type RegisterWebhookResult, type SimulatePolicyDataParams, type SimulatePolicyDataResult, type SimulatePolicyDataWithClientParams, type SimulatePolicyDataWithClientResult, type SimulatePolicyParams, type SimulatePolicyResult, type SimulateTaskParams, type SimulateTaskResult, type SubmitEvaluationRequestParams, type SubmitIntentResult, type Task, type TaskId, type TaskResponseResult, TaskStatus, type UnregisterWebhookResult } from '@core/types/task';
2
+ import { type Address, type PublicClient as Client, type Hex, type WalletClient } from 'viem';
3
+ export interface CreateTaskResult {
4
+ task_id: Hex;
5
+ task_request: unknown;
6
+ status: 'Completed' | 'Failed';
7
+ aggregation_response: unknown;
8
+ timestamp: number;
9
+ error?: unknown;
10
+ }
11
+ export interface PendingTaskBuilder {
12
+ readonly taskId?: TaskId;
13
+ waitForTaskResponded: ({ timeoutMs, }: {
14
+ timeoutMs?: number;
15
+ }) => Promise<TaskResponseResult>;
16
+ }
17
+ declare const waitForTaskResponded: (publicClient: Client, args: {
18
+ taskId?: Hex;
19
+ timeoutMs?: number;
20
+ abortSignal?: AbortSignal;
21
+ }, taskManagerAddress: Address, taskRequestedAtBlock?: bigint) => Promise<TaskResponseResult>;
22
+ declare const getTaskResponseHash: (publicClient: Client, args: {
23
+ taskId: TaskId;
24
+ }, taskManagerAddress: Address) => Promise<Hex | null>;
25
+ declare const getTaskStatus: (publicClient: Client, args: {
26
+ taskId: TaskId;
27
+ }, taskManagerAddress: Address, attestationValidatorAddress: Address) => Promise<TaskStatus>;
28
+ declare function submitEvaluationRequest(walletClient: WalletClient, args: SubmitEvaluationRequestParams, taskManagerAddress: Address, apiKey: string, gatewayApiUrlOverride?: string): Promise<{
29
+ result: {
30
+ taskId: Hex;
31
+ txHash: Hex;
32
+ };
33
+ } & PendingTaskBuilder>;
34
+ /**
35
+ * Evaluate intent directly without waiting for task response confirmation on source chain.
36
+ * Results are to be used with `validateAttestationDirect` on NewtonPolicyClient (NewtonProverTaskManagerShared)
37
+ *
38
+ * @param walletClient - Wallet client
39
+ * @param args - Evaluation request parameters
40
+ * @param apiKey - API key
41
+ * @param gatewayApiUrlOverride - Gateway API URL override
42
+ * @returns Evaluation result
43
+ */
44
+ declare function evaluateIntentDirect(walletClient: WalletClient, args: SubmitEvaluationRequestParams, apiKey: string, gatewayApiUrlOverride?: string): Promise<{
45
+ result: {
46
+ evaluationResult: boolean;
47
+ task: Task;
48
+ taskResponse: unknown;
49
+ blsSignature: unknown;
50
+ };
51
+ }>;
52
+ /**
53
+ * Submit intent and subscribe to task response on source chain (this will be slower but can be used to challenge the task evaluation)
54
+ * Results are to be used with `validateAttestation` on NewtonPolicyClient (NewtonProverTaskManager)
55
+ *
56
+ * @param walletClient - Wallet client
57
+ * @param args
58
+ * @param apiKey
59
+ * @param gatewayApiUrlOverride
60
+ * @returns
61
+ */
62
+ declare function submitIntentAndSubscribe(walletClient: WalletClient, args: SubmitEvaluationRequestParams, apiKey: string, gatewayApiUrlOverride?: string): Promise<{
63
+ result: SubmitIntentResult;
64
+ ws: WebSocket;
65
+ }>;
66
+ /**
67
+ * Simulates task evaluation (newt_simulateTask). Forwards to an operator and returns allow/deny without executing on-chain.
68
+ */
69
+ declare function simulateTask(walletClient: WalletClient, args: SimulateTaskParams, apiKey: string, gatewayApiUrlOverride?: string): Promise<SimulateTaskResult>;
70
+ /**
71
+ * Simulates full Rego policy evaluation (newt_simulatePolicy). Tests policy with sample intent and policy data; may require ownership if PolicyData uses stored secrets.
72
+ */
73
+ declare function simulatePolicy(walletClient: WalletClient, args: SimulatePolicyParams, apiKey: string, gatewayApiUrlOverride?: string): Promise<SimulatePolicyResult>;
74
+ /**
75
+ * Simulates PolicyData WASM execution with caller-provided secrets (newt_simulatePolicyData). No ownership verification.
76
+ */
77
+ declare function simulatePolicyData(walletClient: WalletClient, args: SimulatePolicyDataParams, apiKey: string, gatewayApiUrlOverride?: string): Promise<SimulatePolicyDataResult>;
78
+ /**
79
+ * Simulates PolicyData WASM execution with stored secrets for a policy client (newt_simulatePolicyDataWithClient). Requires ownership.
80
+ */
81
+ declare function simulatePolicyDataWithClient(walletClient: WalletClient, args: SimulatePolicyDataWithClientParams, apiKey: string, gatewayApiUrlOverride?: string): Promise<SimulatePolicyDataWithClientResult>;
82
+ /**
83
+ * Register a webhook for task failure notifications (newt_registerWebhook).
84
+ */
85
+ declare function registerWebhook(chainId: number, apiKey: string, params: RegisterWebhookParams, gatewayApiUrlOverride?: string): Promise<RegisterWebhookResult>;
86
+ /**
87
+ * Unregister the webhook for the API key (newt_unregisterWebhook).
88
+ */
89
+ declare function unregisterWebhook(chainId: number, apiKey: string, gatewayApiUrlOverride?: string): Promise<UnregisterWebhookResult>;
90
+ export { submitEvaluationRequest, waitForTaskResponded, getTaskResponseHash, getTaskStatus, evaluateIntentDirect, submitIntentAndSubscribe, simulateTask, simulatePolicy, simulatePolicyData, simulatePolicyDataWithClient, registerWebhook, unregisterWebhook, };
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Newton Identity Module
3
+ *
4
+ * - `registerIdentityData` — store identity data reference on-chain with gateway co-signature
5
+ * - `identityDomainHash` — compute keccak256 domain identifier
6
+ * - `linkIdentity*` / `unlinkIdentity*` — direct contract calls to IdentityRegistry
7
+ */
8
+ import type { LinkIdentityAsSignerAndUserParams, LinkIdentityAsSignerParams, LinkIdentityAsUserParams, LinkIdentityParams, RegisterIdentityDataParams, UnlinkIdentityAsSignerParams, UnlinkIdentityAsUserParams } from '@core/types/identity';
9
+ import { type Hex, type WalletClient } from 'viem';
10
+ /**
11
+ * Compute the bytes32 identity domain hash from a human-readable domain name.
12
+ *
13
+ * Matches the Rust convention: `keccak256(toBytes("kyc"))` producing a bytes32 hash.
14
+ */
15
+ export declare function identityDomainHash(domainName: string): Hex;
16
+ /**
17
+ * Register an identity data reference on-chain.
18
+ *
19
+ * The identity owner (msg.sender) calls this after uploading encrypted data
20
+ * to the gateway via `newt_uploadIdentityEncrypted`. The gateway returns a
21
+ * `data_ref_id`, `gateway_signature`, and `deadline` which are passed here.
22
+ *
23
+ * The contract verifies the gateway signature against `REGISTER_IDENTITY_TYPEHASH`
24
+ * and checks that the signer is a registered task generator.
25
+ */
26
+ export declare function registerIdentityData(walletClient: WalletClient, params: RegisterIdentityDataParams): Promise<Hex>;
27
+ /**
28
+ * Link identity data when the caller is both identity owner and client user.
29
+ * msg.sender must have submitted identity data for the given domains.
30
+ */
31
+ export declare function linkIdentityAsSignerAndUser(walletClient: WalletClient, params: LinkIdentityAsSignerAndUserParams): Promise<Hex>;
32
+ /**
33
+ * Link identity data as the identity owner (signer).
34
+ * Requires a counterparty signature from the client user.
35
+ */
36
+ export declare function linkIdentityAsSigner(walletClient: WalletClient, params: LinkIdentityAsSignerParams): Promise<Hex>;
37
+ /**
38
+ * Link identity data as the client user.
39
+ * Requires a counterparty signature from the identity owner.
40
+ */
41
+ export declare function linkIdentityAsUser(walletClient: WalletClient, params: LinkIdentityAsUserParams): Promise<Hex>;
42
+ /**
43
+ * Link identity data as a 3rd party with signatures from both identity owner and client user.
44
+ */
45
+ export declare function linkIdentity(walletClient: WalletClient, params: LinkIdentityParams): Promise<Hex>;
46
+ /**
47
+ * Unlink identity data as the identity owner (signer).
48
+ * Only the identity owner who created the link can call this.
49
+ */
50
+ export declare function unlinkIdentityAsSigner(walletClient: WalletClient, params: UnlinkIdentityAsSignerParams): Promise<Hex>;
51
+ /**
52
+ * Unlink identity data as the client user.
53
+ * Allows users to revoke links to their own account.
54
+ */
55
+ export declare function unlinkIdentityAsUser(walletClient: WalletClient, params: UnlinkIdentityAsUserParams): Promise<Hex>;
@@ -0,0 +1,239 @@
1
+ import type { PolicyId, PolicyParamsJson } from '@core/types/policy';
2
+ import { type Address, type Hex, type PublicClient, type WalletClient } from 'viem';
3
+ type InitializeContractArgs = {
4
+ factory: Address;
5
+ entrypoint: string;
6
+ policyCid: string;
7
+ schemaCid: string;
8
+ policyData: Address[];
9
+ metadataCid: string;
10
+ owner: Address;
11
+ };
12
+ /**
13
+ * Args for `initialize`. Callers must supply the policy code hash one of two ways:
14
+ *
15
+ * - `policyCodeHash`: pre-computed `keccak256` of the Rego policy bytes (e.g. read from
16
+ * `policy_cids.json` or another out-of-band source). Takes precedence when both are set.
17
+ * - `policyBytes`: the raw Rego policy bytes — the SDK computes `keccak256` for you. Use
18
+ * this when fetching from IPFS via `policyCid`, reading a local file, or any other
19
+ * transport. Bringing the bytes lets the SDK stay browser/edge friendly without taking
20
+ * an opinion on an IPFS gateway.
21
+ *
22
+ * Mirrors the resolution strategy in `newton-cli` (`commands/policy.rs`).
23
+ */
24
+ export type InitializePolicyArgs = InitializeContractArgs & ({
25
+ policyCodeHash: Hex;
26
+ } | {
27
+ policyBytes: Uint8Array;
28
+ });
29
+ type InitializeArgs = InitializePolicyArgs & {
30
+ walletClient: WalletClient;
31
+ policyContractAddress: Address;
32
+ };
33
+ export declare const policyWriteFunctions: {
34
+ initialize: ({ walletClient, policyContractAddress, ...args }: InitializeArgs) => Promise<`0x${string}`>;
35
+ renounceOwnership: ({ walletClient, policyContractAddress, }: {
36
+ walletClient: WalletClient;
37
+ policyContractAddress: Address;
38
+ }) => Promise<`0x${string}`>;
39
+ transferOwnership: ({ walletClient, policyContractAddress, ...args }: {
40
+ walletClient: WalletClient;
41
+ policyContractAddress: Address;
42
+ newOwner: Address;
43
+ }) => Promise<`0x${string}`>;
44
+ };
45
+ export declare const policyReadFunctions: {
46
+ getPolicyId: ({ publicClient, policyContractAddress, client, }: {
47
+ publicClient: PublicClient;
48
+ policyContractAddress: Address;
49
+ client: Address;
50
+ }) => Promise<`0x${string}`>;
51
+ getPolicyConfig: ({ publicClient, policyContractAddress, policyId, }: {
52
+ publicClient: PublicClient;
53
+ policyContractAddress: Address;
54
+ policyId: `0x${string}`;
55
+ }) => Promise<{
56
+ policyParams: string | object;
57
+ policyParamsHex: `0x${string}`;
58
+ expireAfter: number;
59
+ }>;
60
+ supportsInterface: ({ publicClient, policyContractAddress, interfaceId, }: {
61
+ publicClient: PublicClient;
62
+ policyContractAddress: Address;
63
+ interfaceId: `0x${string}`;
64
+ }) => Promise<boolean>;
65
+ owner: ({ publicClient, policyContractAddress, }: {
66
+ publicClient: PublicClient;
67
+ policyContractAddress: Address;
68
+ }) => Promise<Address>;
69
+ factory: ({ publicClient, policyContractAddress, }: {
70
+ publicClient: PublicClient;
71
+ policyContractAddress: Address;
72
+ }) => Promise<Address>;
73
+ entrypoint: ({ publicClient, policyContractAddress, }: {
74
+ publicClient: PublicClient;
75
+ policyContractAddress: Address;
76
+ }) => Promise<string>;
77
+ clientToPolicyId: ({ publicClient, policyContractAddress, client, }: {
78
+ publicClient: PublicClient;
79
+ policyContractAddress: Address;
80
+ client: Address;
81
+ }) => Promise<`0x${string}`>;
82
+ policyData: ({ publicClient, policyContractAddress, index, }: {
83
+ publicClient: PublicClient;
84
+ policyContractAddress: Address;
85
+ index: number;
86
+ }) => Promise<Address>;
87
+ getEntrypoint: ({ publicClient, policyContractAddress, }: {
88
+ publicClient: PublicClient;
89
+ policyContractAddress: Address;
90
+ }) => Promise<string>;
91
+ getMetadataCid: ({ publicClient, policyContractAddress, }: {
92
+ publicClient: PublicClient;
93
+ policyContractAddress: Address;
94
+ }) => Promise<string>;
95
+ getPolicyCid: ({ publicClient, policyContractAddress, }: {
96
+ publicClient: PublicClient;
97
+ policyContractAddress: Address;
98
+ }) => Promise<string>;
99
+ getPolicyData: ({ publicClient, policyContractAddress, }: {
100
+ publicClient: PublicClient;
101
+ policyContractAddress: Address;
102
+ }) => Promise<Address[]>;
103
+ getSchemaCid: ({ publicClient, policyContractAddress, }: {
104
+ publicClient: PublicClient;
105
+ policyContractAddress: Address;
106
+ }) => Promise<string>;
107
+ isPolicyVerified: ({ publicClient, policyContractAddress, }: {
108
+ publicClient: PublicClient;
109
+ policyContractAddress: Address;
110
+ }) => Promise<boolean>;
111
+ metadataCid: ({ publicClient, policyContractAddress, }: {
112
+ publicClient: PublicClient;
113
+ policyContractAddress: Address;
114
+ }) => Promise<string>;
115
+ policyCid: ({ publicClient, policyContractAddress, }: {
116
+ publicClient: PublicClient;
117
+ policyContractAddress: Address;
118
+ }) => Promise<string>;
119
+ schemaCid: ({ publicClient, policyContractAddress, }: {
120
+ publicClient: PublicClient;
121
+ policyContractAddress: Address;
122
+ }) => Promise<string>;
123
+ precomputePolicyId: ({ publicClient, policyContractAddress, ...args }: {
124
+ publicClient: PublicClient;
125
+ policyContractAddress: Address;
126
+ policyContract: Address;
127
+ policyData: Address[];
128
+ params: PolicyParamsJson;
129
+ client: Address;
130
+ policyUri: string;
131
+ schemaUri: string;
132
+ entrypoint: string;
133
+ expireAfter?: number;
134
+ blockTimestamp?: bigint;
135
+ }) => PolicyId;
136
+ };
137
+ export declare const policyFunctions: {
138
+ initialize: ({ walletClient, policyContractAddress, ...args }: InitializeArgs) => Promise<`0x${string}`>;
139
+ renounceOwnership: ({ walletClient, policyContractAddress, }: {
140
+ walletClient: WalletClient;
141
+ policyContractAddress: Address;
142
+ }) => Promise<`0x${string}`>;
143
+ transferOwnership: ({ walletClient, policyContractAddress, ...args }: {
144
+ walletClient: WalletClient;
145
+ policyContractAddress: Address;
146
+ newOwner: Address;
147
+ }) => Promise<`0x${string}`>;
148
+ getPolicyId: ({ publicClient, policyContractAddress, client, }: {
149
+ publicClient: PublicClient;
150
+ policyContractAddress: Address;
151
+ client: Address;
152
+ }) => Promise<`0x${string}`>;
153
+ getPolicyConfig: ({ publicClient, policyContractAddress, policyId, }: {
154
+ publicClient: PublicClient;
155
+ policyContractAddress: Address;
156
+ policyId: `0x${string}`;
157
+ }) => Promise<{
158
+ policyParams: string | object;
159
+ policyParamsHex: `0x${string}`;
160
+ expireAfter: number;
161
+ }>;
162
+ supportsInterface: ({ publicClient, policyContractAddress, interfaceId, }: {
163
+ publicClient: PublicClient;
164
+ policyContractAddress: Address;
165
+ interfaceId: `0x${string}`;
166
+ }) => Promise<boolean>;
167
+ owner: ({ publicClient, policyContractAddress, }: {
168
+ publicClient: PublicClient;
169
+ policyContractAddress: Address;
170
+ }) => Promise<Address>;
171
+ factory: ({ publicClient, policyContractAddress, }: {
172
+ publicClient: PublicClient;
173
+ policyContractAddress: Address;
174
+ }) => Promise<Address>;
175
+ entrypoint: ({ publicClient, policyContractAddress, }: {
176
+ publicClient: PublicClient;
177
+ policyContractAddress: Address;
178
+ }) => Promise<string>;
179
+ clientToPolicyId: ({ publicClient, policyContractAddress, client, }: {
180
+ publicClient: PublicClient;
181
+ policyContractAddress: Address;
182
+ client: Address;
183
+ }) => Promise<`0x${string}`>;
184
+ policyData: ({ publicClient, policyContractAddress, index, }: {
185
+ publicClient: PublicClient;
186
+ policyContractAddress: Address;
187
+ index: number;
188
+ }) => Promise<Address>;
189
+ getEntrypoint: ({ publicClient, policyContractAddress, }: {
190
+ publicClient: PublicClient;
191
+ policyContractAddress: Address;
192
+ }) => Promise<string>;
193
+ getMetadataCid: ({ publicClient, policyContractAddress, }: {
194
+ publicClient: PublicClient;
195
+ policyContractAddress: Address;
196
+ }) => Promise<string>;
197
+ getPolicyCid: ({ publicClient, policyContractAddress, }: {
198
+ publicClient: PublicClient;
199
+ policyContractAddress: Address;
200
+ }) => Promise<string>;
201
+ getPolicyData: ({ publicClient, policyContractAddress, }: {
202
+ publicClient: PublicClient;
203
+ policyContractAddress: Address;
204
+ }) => Promise<Address[]>;
205
+ getSchemaCid: ({ publicClient, policyContractAddress, }: {
206
+ publicClient: PublicClient;
207
+ policyContractAddress: Address;
208
+ }) => Promise<string>;
209
+ isPolicyVerified: ({ publicClient, policyContractAddress, }: {
210
+ publicClient: PublicClient;
211
+ policyContractAddress: Address;
212
+ }) => Promise<boolean>;
213
+ metadataCid: ({ publicClient, policyContractAddress, }: {
214
+ publicClient: PublicClient;
215
+ policyContractAddress: Address;
216
+ }) => Promise<string>;
217
+ policyCid: ({ publicClient, policyContractAddress, }: {
218
+ publicClient: PublicClient;
219
+ policyContractAddress: Address;
220
+ }) => Promise<string>;
221
+ schemaCid: ({ publicClient, policyContractAddress, }: {
222
+ publicClient: PublicClient;
223
+ policyContractAddress: Address;
224
+ }) => Promise<string>;
225
+ precomputePolicyId: ({ publicClient, policyContractAddress, ...args }: {
226
+ publicClient: PublicClient;
227
+ policyContractAddress: Address;
228
+ policyContract: Address;
229
+ policyData: Address[];
230
+ params: PolicyParamsJson;
231
+ client: Address;
232
+ policyUri: string;
233
+ schemaUri: string;
234
+ entrypoint: string;
235
+ expireAfter?: number;
236
+ blockTimestamp?: bigint;
237
+ }) => PolicyId;
238
+ };
239
+ export {};
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Newton Privacy Module — Client-side HPKE encryption for privacy-preserving policy evaluation.
3
+ *
4
+ * Encryption suite: X25519 KEM + HKDF-SHA256 + ChaCha20-Poly1305 (RFC 9180, Base mode).
5
+ * Compatible with the Rust gateway's `crates/core/src/crypto/hpke.rs`.
6
+ *
7
+ * Key design constraints:
8
+ * - Zero network calls during encrypt/createSecureEnvelope
9
+ * - Offline capable once the gateway public key is known
10
+ * - Ephemeral keys zeroed after encryption
11
+ */
12
+ import type { CreateSecureEnvelopeParams, Ed25519KeyPair, GetConfidentialDataResult, GetIdentityEncryptedResult, PrivacyAuthorizationResult, PrivacyPublicKeyResponse, SecretsPublicKeyResponse, SecureEnvelopeResult, SignPrivacyAuthorizationParams, StoreEncryptedSecretsParams, StoreEncryptedSecretsResponse, UploadConfidentialDataParams, UploadConfidentialDataResult, UploadIdentityEncryptedParams, UploadIdentityEncryptedResponse } from '@core/types/privacy';
13
+ /**
14
+ * Create a SecureEnvelope by encrypting plaintext with HPKE.
15
+ *
16
+ * This is a pure, offline function — zero network calls.
17
+ * The ephemeral HPKE key is generated internally and zeroed after use.
18
+ *
19
+ * SECURITY: The caller owns the signingKey buffer lifecycle and must zeroize it when done.
20
+ * This function copies the key internally and zeroes the copy after signing, but the
21
+ * original Uint8Array remains in the caller's control.
22
+ *
23
+ * @param params - Encryption parameters
24
+ * @param signingKey - Ed25519 private key seed (32 bytes as Uint8Array)
25
+ * @returns Envelope + Ed25519 signature over the serialized envelope
26
+ */
27
+ export declare function createSecureEnvelope(params: CreateSecureEnvelopeParams, signingKey: Uint8Array): Promise<SecureEnvelopeResult>;
28
+ /**
29
+ * Fetch the gateway's X25519 HPKE public key.
30
+ *
31
+ * Clients call this once to discover which key to encrypt SecureEnvelopes to.
32
+ * The result can be cached — the key only changes on gateway restart or key rotation.
33
+ */
34
+ export declare function getPrivacyPublicKey(chainId: number, apiKey: string, gatewayApiUrlOverride?: string): Promise<PrivacyPublicKeyResponse>;
35
+ /**
36
+ * Upload encrypted identity data to the gateway.
37
+ *
38
+ * The caller must provide a pre-built SecureEnvelope (via createSecureEnvelope)
39
+ * and an EIP-712 signature of the envelope JSON from the identity owner.
40
+ * The gateway stores the envelope and returns a data_ref_id + gateway signature
41
+ * for the on-chain registerIdentityData call.
42
+ */
43
+ export declare function uploadIdentityEncrypted(chainId: number, apiKey: string, params: UploadIdentityEncryptedParams, gatewayApiUrlOverride?: string): Promise<UploadIdentityEncryptedResponse>;
44
+ /**
45
+ * Fetch encrypted identity data by its content-hash reference ID.
46
+ *
47
+ * Used to resolve a data_ref_id (stored on-chain in IdentityRegistry) back to
48
+ * the actual encrypted data blob (stored off-chain in the gateway).
49
+ */
50
+ export declare function getIdentityEncrypted(chainId: number, apiKey: string, dataRefId: string, gatewayApiUrlOverride?: string): Promise<GetIdentityEncryptedResult>;
51
+ /**
52
+ * Fetch the gateway's X25519 HPKE public key for WASM secrets encryption.
53
+ *
54
+ * In threshold DKG mode, this returns a different key than getPrivacyPublicKey.
55
+ * Use this key when encrypting secrets via storeEncryptedSecrets.
56
+ */
57
+ export declare function getSecretsPublicKey(chainId: number, apiKey: string, gatewayApiUrlOverride?: string): Promise<SecretsPublicKeyResponse>;
58
+ /**
59
+ * Generate a random Ed25519 key pair for signing envelopes and privacy authorization.
60
+ *
61
+ * This is a pure offline function. The private key is generated from 32 bytes of
62
+ * cryptographically secure randomness via `crypto.getRandomValues`.
63
+ */
64
+ export declare function generateSigningKeyPair(): Ed25519KeyPair;
65
+ /**
66
+ * Upload HPKE-encrypted secrets for a policy client's PolicyData.
67
+ *
68
+ * The gateway decrypts the HPKE envelope, validates the plaintext against
69
+ * the PolicyData schema, and stores the envelope for operator-side decryption
70
+ * during policy evaluation.
71
+ */
72
+ export declare function storeEncryptedSecrets(chainId: number, apiKey: string, params: StoreEncryptedSecretsParams, gatewayApiUrlOverride?: string): Promise<StoreEncryptedSecretsResponse>;
73
+ /**
74
+ * Compute dual Ed25519 signatures for privacy-enabled task creation.
75
+ *
76
+ * Dual signatures prevent the app from forging user authorization, and ensure
77
+ * the app explicitly acknowledges which encrypted data refs are being used.
78
+ * The gateway validates both when `encrypted_data_refs` are present in `newt_createTask`.
79
+ *
80
+ * Signature scheme (must match `crates/gateway/src/processor/privacy_auth.rs`):
81
+ * - User signs: keccak256(abi.encodePacked(policy_client, intent_hash, ref_id_1, ref_id_2, ...))
82
+ * - App signs: keccak256(abi.encodePacked(policy_client, intent_hash, user_signature))
83
+ *
84
+ * This is a pure offline function — zero network calls.
85
+ */
86
+ export declare function signPrivacyAuthorization(params: SignPrivacyAuthorizationParams): PrivacyAuthorizationResult;
87
+ /**
88
+ * Upload HPKE-encrypted confidential data (blacklists, allowlists, sanctions lists, etc.)
89
+ * to the gateway.
90
+ *
91
+ * The provider encrypts data client-side using HPKE and uploads the envelope.
92
+ * The gateway stores it and returns a content-hash data_ref_id. The provider
93
+ * then calls ConfidentialDataRegistry.publishData(domain, dataRefId) on-chain.
94
+ *
95
+ * If recipientPublicKey is not provided, it is fetched from the gateway first
96
+ * via newt_getPrivacyPublicKey.
97
+ */
98
+ export declare function uploadConfidentialData(chainId: number, apiKey: string, params: UploadConfidentialDataParams, gatewayApiUrlOverride?: string): Promise<UploadConfidentialDataResult>;
99
+ /**
100
+ * Retrieve encrypted confidential data by its data reference ID.
101
+ *
102
+ * Returns the HPKE-encrypted envelope along with the domain and provider address.
103
+ * The caller is responsible for decryption using their HPKE private key.
104
+ */
105
+ export declare function getConfidentialData(chainId: number, apiKey: string, dataRefId: string, gatewayApiUrlOverride?: string): Promise<GetConfidentialDataResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newton-xyz/sdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Official SDK for the Newton Protocol.",
5
5
  "author": "Newton Protocol <https://x.com/newton_xyz> (https://newton.xyz)",
6
6
  "private": false,