@magicnewton/newton-protocol-sdk 0.5.4 → 0.6.0
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.
- package/README.md +9 -0
- package/dist/cjs/const.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/modules/identity/index.js +1 -0
- package/dist/cjs/types/core/exception-types.js +1 -1
- package/dist/es/const.mjs +1 -1
- package/dist/es/index.mjs +1 -1
- package/dist/es/modules/identity/index.mjs +1 -0
- package/dist/es/types/core/exception-types.mjs +1 -1
- package/dist/types/const.d.mts +1 -0
- package/dist/types/const.d.ts +1 -0
- package/dist/types/index.d.mts +4 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/modules/avs/index.d.mts +82 -0
- package/dist/types/modules/identity/index.d.mts +30 -0
- package/dist/types/modules/identity/index.d.ts +30 -0
- package/dist/types/modules/policy/index.d.mts +228 -0
- package/dist/types/modules/privacy/index.d.mts +77 -0
- package/dist/types/types/core/exception-types.d.mts +5 -1
- package/dist/types/types/core/exception-types.d.ts +5 -1
- package/dist/types/types/identity.d.mts +28 -0
- package/dist/types/types/identity.d.ts +28 -0
- package/dist/types/types/index.d.mts +1 -0
- package/dist/types/types/index.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,6 +109,15 @@ The SDK includes a privacy module for client-side HPKE encryption used in privac
|
|
|
109
109
|
|
|
110
110
|
See the [SDK Reference](https://docs.newton.xyz/developers/reference/sdk-reference) for full API documentation.
|
|
111
111
|
|
|
112
|
+
## Identity Module
|
|
113
|
+
|
|
114
|
+
The SDK includes an identity module for submitting EIP-712 signed identity data to the on-chain IdentityRegistry. Key exports:
|
|
115
|
+
|
|
116
|
+
- `sendIdentityEncrypted` -- sign and submit encrypted identity data to the gateway
|
|
117
|
+
- `identityDomainHash` -- compute the bytes32 domain identifier from a name (e.g., `identityDomainHash("kyc")`)
|
|
118
|
+
|
|
119
|
+
The module uses viem's `signTypedData` with domain `{name: "IdentityRegistry", version: "1"}` and a single EIP-712 struct `EncryptedIdentityData { string data }` that works across all identity domains.
|
|
120
|
+
|
|
112
121
|
## Testing
|
|
113
122
|
|
|
114
123
|
The project uses Vitest for unit testing:
|
package/dist/cjs/const.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("viem/chains");const
|
|
1
|
+
"use strict";var e=require("viem/chains");const t={[e.sepolia.id]:"https://gateway.testnet.newton.xyz/rpc",[e.mainnet.id]:"https://gateway.newton.xyz/rpc",[e.baseSepolia.id]:"https://gateway.testnet.newton.xyz/rpc",[e.base.id]:"https://gateway.newton.xyz/rpc"},a={createTask:"newt_createTask",sendTask:"newt_sendTask",simulatePolicy:"newt_simulatePolicy",simulateTask:"newt_simulateTask",simulatePolicyData:"newt_simulatePolicyData",simulatePolicyDataWithClient:"newt_simulatePolicyDataWithClient",getPrivacyPublicKey:"newt_getPrivacyPublicKey",uploadEncryptedData:"newt_uploadEncryptedData",storeEncryptedSecrets:"newt_storeEncryptedSecrets",sendIdentityEncrypted:"newt_sendIdentityEncrypted"},i={[e.sepolia.id]:"0xecb741f4875770f9a5f060cb30f6c9eb5966ed13",[e.mainnet.id]:"0x2010dbaa5438801bdc3f08174a799fe344f544ee",[e.baseSepolia.id]:"0xc3dc89b5e5241ef53c468dfbaa371a7f1d465eb7"},c={[e.sepolia.id]:"0x26f452e4b9c9c28508cb836ba486cceaa95b429c",[e.mainnet.id]:"0x263c275c15867a4611a44c600e77144a23012a06",[e.baseSepolia.id]:"0x4e21b596944ebe8bd3773dd70c6f134bd2840a73"};exports.ATTESTATION_VALIDATOR=c,exports.GATEWAY_API_URLS=t,exports.GATEWAY_METHODS=a,exports.NEWTON_PROVER_TASK_MANAGER=i;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var s=require("viem/chains"),d=require("./modules/avs/index.js"),
|
|
1
|
+
"use strict";var s=require("viem/chains"),d=require("./modules/avs/index.js"),w=require("./modules/identity/index.js"),r=require("./modules/policy/index.js"),c=require("./modules/privacy/index.js"),I=require("./const.js"),y=require("./service/popup.js");require("./types/core/exception-types.js");var C=require("./types/core/json-rpc-types.js"),A=require("./utils/get-payload-id.js");const g=[s.mainnet.id,s.sepolia.id,s.baseSepolia.id],R=(h,l)=>e=>{const{apiKey:a,policyContractAddress:n}=h,p=()=>{if(!n)throw new Error('Newton SDK: policyContractAddress is required. Ensure you instantiate viem client actions extension with policyContractAddress parameter. Example: newtonWalletClientActions({ policyContractAddress: "0x123..." })');return n};if(!g.includes(e?.chain?.id??s.sepolia.id))throw new Error(`Newton SDK: Invalid network specified for newtonWalletClientActions. Only ${g.join(", ")} are supported`);const P=l?.taskManagerAddress??I.NEWTON_PROVER_TASK_MANAGER[e?.chain?.id??s.sepolia.id],t=l?.gatewayApiUrl??void 0,o=l?.newtonIdpUrl,m=l?.identityRegistry??void 0;return{submitEvaluationRequest:i=>d.submitEvaluationRequest(e,i,P,a,t),evaluateIntentDirect:i=>d.evaluateIntentDirect(e,i,a,t),submitIntentAndSubscribe:i=>d.submitIntentAndSubscribe(e,i,a,t),simulateTask:i=>d.simulateTask(e,i,a,t),simulatePolicy:i=>d.simulatePolicy(e,i,a,t),simulatePolicyData:i=>d.simulatePolicyData(e,i,a,t),simulatePolicyDataWithClient:i=>d.simulatePolicyDataWithClient(e,i,a,t),initialize:i=>{const u=p();return r.policyWriteFunctions.initialize({walletClient:e,policyContractAddress:u,...i})},renounceOwnership:()=>{const i=p();return r.policyWriteFunctions.renounceOwnership({walletClient:e,policyContractAddress:i})},transferOwnership:i=>{const u=p();return r.policyWriteFunctions.transferOwnership({walletClient:e,policyContractAddress:u,...i})},connectIdentityWithNewton:i=>y.popupRequest({method:C.NewtonIdpPayloadMethod.Connect,id:A.getPayloadId(),jsonrpc:"2.0",params:{apiKey:a,chainId:e.chain?.id,appWalletAddress:i.appWalletAddress,appClientAddress:i.appClientAddress}},o),registerUserData:i=>y.popupRequest({method:C.NewtonIdpPayloadMethod.RegisterUserData,id:A.getPayloadId(),jsonrpc:"2.0",params:{apiKey:a,userData:i.userData,gatewayApiUrlOverride:t,chainId:e.chain?.id,appIdentityDomain:i.appIdentityDomain,identityRegistryOverride:m}},o),linkApp:i=>y.popupRequest({method:C.NewtonIdpPayloadMethod.LinkApp,id:A.getPayloadId(),jsonrpc:"2.0",params:{apiKey:a,appWalletAddress:i.appWalletAddress,appClientAddress:i.appClientAddress,appIdentityDomain:i.appIdentityDomain,chainId:e.chain?.id,identityRegistryOverride:m}},o),unlinkApp:i=>y.popupRequest({method:C.NewtonIdpPayloadMethod.Unlink,id:A.getPayloadId(),jsonrpc:"2.0",params:{apiKey:a,appWalletAddress:i.appWalletAddress,appClientAddress:i.appClientAddress,chainId:e.chain?.id,appIdentityDomain:i.appIdentityDomain,identityRegistryOverride:m}},o),getPrivacyPublicKey:()=>c.getPrivacyPublicKey(e?.chain?.id??s.sepolia.id,a,t),createSecureEnvelope:(i,u)=>c.createSecureEnvelope(i,u),uploadEncryptedData:i=>c.uploadEncryptedData(e?.chain?.id??s.sepolia.id,a,i,t),uploadSecureEnvelope:i=>c.uploadSecureEnvelope(e?.chain?.id??s.sepolia.id,a,i,t),generateSigningKeyPair:()=>c.generateSigningKeyPair(),storeEncryptedSecrets:i=>c.storeEncryptedSecrets(e?.chain?.id??s.sepolia.id,a,i,t),signPrivacyAuthorization:i=>c.signPrivacyAuthorization(i),sendIdentityEncrypted:i=>w.sendIdentityEncrypted(e,i,a,t)}},v=(h,l)=>e=>{if(!g.includes(e?.chain?.id??s.sepolia.id))throw new Error(`Newton SDK: Invalid network specified for newtonPublicActions. Only ${g.join(", ")} are supported.`);const a=h?.policyContractAddress,n=()=>{if(!a)throw new Error('Newton SDK: policyContractAddress is required. Ensure you instantiate viem client actions extension with policyContractAddress parameter. Example: newtonPublicClientActions({ policyContractAddress: "0x123..." })');return a},p=l?.taskManagerAddress??I.NEWTON_PROVER_TASK_MANAGER[e?.chain?.id??s.sepolia.id],P=l?.attestationValidatorAddress??I.ATTESTATION_VALIDATOR[e?.chain?.id??s.sepolia.id];return{waitForTaskResponded:t=>d.waitForTaskResponded(e,t,p),getTaskResponseHash:t=>d.getTaskResponseHash(e,t,p),getTaskStatus:t=>d.getTaskStatus(e,t,p,P),clientToPolicyId:t=>{const o=n();return r.policyReadFunctions.clientToPolicyId({publicClient:e,policyContractAddress:o,...t})},entrypoint:()=>{const t=n();return r.policyReadFunctions.entrypoint({publicClient:e,policyContractAddress:t})},factory:()=>{const t=n();return r.policyReadFunctions.factory({publicClient:e,policyContractAddress:t})},getEntrypoint:()=>{const t=n();return r.policyReadFunctions.getEntrypoint({publicClient:e,policyContractAddress:t})},getMetadataCid:()=>{const t=n();return r.policyReadFunctions.getMetadataCid({publicClient:e,policyContractAddress:t})},getPolicyCid:()=>{const t=n();return r.policyReadFunctions.getPolicyCid({publicClient:e,policyContractAddress:t})},getPolicyConfig:t=>{const o=n();return r.policyReadFunctions.getPolicyConfig({publicClient:e,policyContractAddress:o,...t})},getPolicyData:()=>{const t=n();return r.policyReadFunctions.getPolicyData({publicClient:e,policyContractAddress:t})},getPolicyId:t=>{const o=n();return r.policyReadFunctions.getPolicyId({publicClient:e,policyContractAddress:o,...t})},getSchemaCid:()=>{const t=n();return r.policyReadFunctions.getSchemaCid({publicClient:e,policyContractAddress:t})},isPolicyVerified:()=>{const t=n();return r.policyReadFunctions.isPolicyVerified({publicClient:e,policyContractAddress:t})},metadataCid:()=>{const t=n();return r.policyReadFunctions.metadataCid({publicClient:e,policyContractAddress:t})},owner:()=>{const t=n();return r.policyReadFunctions.owner({publicClient:e,policyContractAddress:t})},policyCid:()=>{const t=n();return r.policyReadFunctions.policyCid({publicClient:e,policyContractAddress:t})},policyData:t=>{const o=n();return r.policyReadFunctions.policyData({publicClient:e,policyContractAddress:o,...t})},schemaCid:()=>{const t=n();return r.policyReadFunctions.schemaCid({publicClient:e,policyContractAddress:t})},supportsInterface:t=>{const o=n();return r.policyReadFunctions.supportsInterface({publicClient:e,policyContractAddress:o,...t})},precomputePolicyId:t=>{const o=n();return r.policyReadFunctions.precomputePolicyId({publicClient:e,policyContractAddress:o,...t})}}};exports.identityDomainHash=w.identityDomainHash,exports.sendIdentityEncrypted=w.sendIdentityEncrypted,exports.createSecureEnvelope=c.createSecureEnvelope,exports.generateSigningKeyPair=c.generateSigningKeyPair,exports.getPrivacyPublicKey=c.getPrivacyPublicKey,exports.signPrivacyAuthorization=c.signPrivacyAuthorization,exports.storeEncryptedSecrets=c.storeEncryptedSecrets,exports.uploadEncryptedData=c.uploadEncryptedData,exports.uploadSecureEnvelope=c.uploadSecureEnvelope,exports.newtonPublicClientActions=v,exports.newtonWalletClientActions=R;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var g=require("../../const.js"),i=require("../../sdk-exceptions.js"),n=require("../../types/core/exception-types.js"),h=require("../../utils/https.js"),t=require("viem");function o(r){return t.keccak256(t.toBytes(r))}async function E(r,e,y,c){const s=r.chain?.id;if(!s)throw new i.SDKError(n.SDKErrorCode.MissingChain,"walletClient must have a chain configured");const d=r.account;if(!d)throw new i.SDKError(n.SDKErrorCode.MissingAccount,"walletClient must have an account configured");if(!t.isAddress(e.identityOwner))throw new i.SDKError(n.SDKErrorCode.InvalidAddress,`invalid identityOwner address: ${e.identityOwner}`);if(!t.isAddress(e.identityRegistryAddress))throw new i.SDKError(n.SDKErrorCode.InvalidAddress,`invalid identityRegistryAddress: ${e.identityRegistryAddress}`);if(t.getAddress(d.address)!==t.getAddress(e.identityOwner))throw new i.SDKError(n.SDKErrorCode.IdentityOwnerMismatch,`wallet account ${d.address} does not match identityOwner ${e.identityOwner}`);const w=await r.signTypedData({account:d,domain:{name:"IdentityRegistry",version:"1",chainId:BigInt(s),verifyingContract:e.identityRegistryAddress},types:{EncryptedIdentityData:[{name:"data",type:"string"}]},primaryType:"EncryptedIdentityData",message:{data:e.identityData}}),u=o(e.identityDomain),D={identity_owner:e.identityOwner,identity_owner_sig:w,identity_data:{data:e.identityData},identity_domain:u},a=await new h.AvsHttpService(s,c).Post(g.GATEWAY_METHODS.sendIdentityEncrypted,D,y);if(a.error)throw a.error;return a.result}exports.identityDomainHash=o,exports.sendIdentityEncrypted=E;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.SDKErrorCode=void 0,(function(e){e.MissingApiKey="MISSING_API_KEY",e.PopupAlreadyExists="POPUP_ALREADY_EXISTS",e.MalformedResponse="MALFORMED_RESPONSE",e.InvalidArgument="INVALID_ARGUMENT",e.ExtensionNotInitialized="EXTENSION_NOT_INITIALIZED",e.IncompatibleExtensions="INCOMPATIBLE_EXTENSIONS",e.FailedToOpenPopup="FAILED_TO_OPEN_POPUP",e.FailedToRetrieveNativeTokenBalance="FAILED_TO_RETRIEVE_NATIVE_TOKEN_BALANCE"})(exports.SDKErrorCode||(exports.SDKErrorCode={})),exports.SDKWarningCode=void 0,(function(e){e.SyncWeb3Method="SYNC_WEB3_METHOD",e.ReactNativeEndpointConfiguration="REACT_NATIVE_ENDPOINT_CONFIGURATION",e.DeprecationNotice="DEPRECATION_NOTICE",e.ProductAnnouncement="ANNOUNCEMENT"})(exports.SDKWarningCode||(exports.SDKWarningCode={})),exports.RPCErrorCode=void 0,(function(e){e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.MagicLinkRateLimited=-10002]="MagicLinkRateLimited",e[e.UserAlreadyLoggedIn=-10003]="UserAlreadyLoggedIn",e[e.AccessDeniedToUser=-10011]="AccessDeniedToUser",e[e.UserRejectedAction=-10012]="UserRejectedAction",e[e.RequestCancelled=-10014]="RequestCancelled",e[e.RedirectLoginComplete=-10015]="RedirectLoginComplete",e[e.NewtonWalletSessionTerminated=-10016]="NewtonWalletSessionTerminated",e[e.PopupRequestOverriden=-10017]="PopupRequestOverriden"})(exports.RPCErrorCode||(exports.RPCErrorCode={}));
|
|
1
|
+
"use strict";exports.SDKErrorCode=void 0,(function(e){e.MissingApiKey="MISSING_API_KEY",e.PopupAlreadyExists="POPUP_ALREADY_EXISTS",e.MalformedResponse="MALFORMED_RESPONSE",e.InvalidArgument="INVALID_ARGUMENT",e.ExtensionNotInitialized="EXTENSION_NOT_INITIALIZED",e.IncompatibleExtensions="INCOMPATIBLE_EXTENSIONS",e.FailedToOpenPopup="FAILED_TO_OPEN_POPUP",e.FailedToRetrieveNativeTokenBalance="FAILED_TO_RETRIEVE_NATIVE_TOKEN_BALANCE",e.MissingChain="MISSING_CHAIN",e.MissingAccount="MISSING_ACCOUNT",e.InvalidAddress="INVALID_ADDRESS",e.IdentityOwnerMismatch="IDENTITY_OWNER_MISMATCH"})(exports.SDKErrorCode||(exports.SDKErrorCode={})),exports.SDKWarningCode=void 0,(function(e){e.SyncWeb3Method="SYNC_WEB3_METHOD",e.ReactNativeEndpointConfiguration="REACT_NATIVE_ENDPOINT_CONFIGURATION",e.DeprecationNotice="DEPRECATION_NOTICE",e.ProductAnnouncement="ANNOUNCEMENT"})(exports.SDKWarningCode||(exports.SDKWarningCode={})),exports.RPCErrorCode=void 0,(function(e){e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.MagicLinkRateLimited=-10002]="MagicLinkRateLimited",e[e.UserAlreadyLoggedIn=-10003]="UserAlreadyLoggedIn",e[e.AccessDeniedToUser=-10011]="AccessDeniedToUser",e[e.UserRejectedAction=-10012]="UserRejectedAction",e[e.RequestCancelled=-10014]="RequestCancelled",e[e.RedirectLoginComplete=-10015]="RedirectLoginComplete",e[e.NewtonWalletSessionTerminated=-10016]="NewtonWalletSessionTerminated",e[e.PopupRequestOverriden=-10017]="PopupRequestOverriden"})(exports.RPCErrorCode||(exports.RPCErrorCode={}));
|
package/dist/es/const.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{base as c,baseSepolia as e,mainnet as t,sepolia as a}from"viem/chains";const i={[a.id]:"https://gateway.testnet.newton.xyz/rpc",[t.id]:"https://gateway.newton.xyz/rpc",[e.id]:"https://gateway.testnet.newton.xyz/rpc",[c.id]:"https://gateway.newton.xyz/rpc"},n={createTask:"newt_createTask",sendTask:"newt_sendTask",simulatePolicy:"newt_simulatePolicy",simulateTask:"newt_simulateTask",simulatePolicyData:"newt_simulatePolicyData",simulatePolicyDataWithClient:"newt_simulatePolicyDataWithClient",getPrivacyPublicKey:"newt_getPrivacyPublicKey",uploadEncryptedData:"newt_uploadEncryptedData",storeEncryptedSecrets:"newt_storeEncryptedSecrets"},
|
|
1
|
+
import{base as c,baseSepolia as e,mainnet as t,sepolia as a}from"viem/chains";const i={[a.id]:"https://gateway.testnet.newton.xyz/rpc",[t.id]:"https://gateway.newton.xyz/rpc",[e.id]:"https://gateway.testnet.newton.xyz/rpc",[c.id]:"https://gateway.newton.xyz/rpc"},n={createTask:"newt_createTask",sendTask:"newt_sendTask",simulatePolicy:"newt_simulatePolicy",simulateTask:"newt_simulateTask",simulatePolicyData:"newt_simulatePolicyData",simulatePolicyDataWithClient:"newt_simulatePolicyDataWithClient",getPrivacyPublicKey:"newt_getPrivacyPublicKey",uploadEncryptedData:"newt_uploadEncryptedData",storeEncryptedSecrets:"newt_storeEncryptedSecrets",sendIdentityEncrypted:"newt_sendIdentityEncrypted"},d={[a.id]:"0xecb741f4875770f9a5f060cb30f6c9eb5966ed13",[t.id]:"0x2010dbaa5438801bdc3f08174a799fe344f544ee",[e.id]:"0xc3dc89b5e5241ef53c468dfbaa371a7f1d465eb7"},s={[a.id]:"0x26f452e4b9c9c28508cb836ba486cceaa95b429c",[t.id]:"0x263c275c15867a4611a44c600e77144a23012a06",[e.id]:"0x4e21b596944ebe8bd3773dd70c6f134bd2840a73"};export{s as ATTESTATION_VALIDATOR,i as GATEWAY_API_URLS,n as GATEWAY_METHODS,d as NEWTON_PROVER_TASK_MANAGER};
|
package/dist/es/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mainnet as
|
|
1
|
+
import{mainnet as R,sepolia as s,baseSepolia as T}from"viem/chains";import{getTaskStatus as k,getTaskResponseHash as K,waitForTaskResponded as W,simulatePolicyDataWithClient as O,simulatePolicyData as N,simulatePolicy as x,simulateTask as U,submitIntentAndSubscribe as j,evaluateIntentDirect as M,submitEvaluationRequest as q}from"./modules/avs/index.mjs";import{sendIdentityEncrypted as w}from"./modules/identity/index.mjs";import{identityDomainHash as it}from"./modules/identity/index.mjs";import{policyReadFunctions as a,policyWriteFunctions as g}from"./modules/policy/index.mjs";import{signPrivacyAuthorization as P,storeEncryptedSecrets as b,generateSigningKeyPair as I,uploadSecureEnvelope as f,uploadEncryptedData as D,createSecureEnvelope as E,getPrivacyPublicKey as v}from"./modules/privacy/index.mjs";import{NEWTON_PROVER_TASK_MANAGER as S,ATTESTATION_VALIDATOR as z}from"./const.mjs";import{popupRequest as p}from"./service/popup.mjs";import"./types/core/exception-types.mjs";import{NewtonIdpPayloadMethod as y}from"./types/core/json-rpc-types.mjs";import{getPayloadId as u}from"./utils/get-payload-id.mjs";const C=[R.id,s.id,T.id],F=(A,c)=>i=>{const{apiKey:r,policyContractAddress:n}=A,d=()=>{if(!n)throw new Error('Newton SDK: policyContractAddress is required. Ensure you instantiate viem client actions extension with policyContractAddress parameter. Example: newtonWalletClientActions({ policyContractAddress: "0x123..." })');return n};if(!C.includes(i?.chain?.id??s.id))throw new Error(`Newton SDK: Invalid network specified for newtonWalletClientActions. Only ${C.join(", ")} are supported`);const m=c?.taskManagerAddress??S[i?.chain?.id??s.id],t=c?.gatewayApiUrl??void 0,o=c?.newtonIdpUrl,h=c?.identityRegistry??void 0;return{submitEvaluationRequest:e=>q(i,e,m,r,t),evaluateIntentDirect:e=>M(i,e,r,t),submitIntentAndSubscribe:e=>j(i,e,r,t),simulateTask:e=>U(i,e,r,t),simulatePolicy:e=>x(i,e,r,t),simulatePolicyData:e=>N(i,e,r,t),simulatePolicyDataWithClient:e=>O(i,e,r,t),initialize:e=>{const l=d();return g.initialize({walletClient:i,policyContractAddress:l,...e})},renounceOwnership:()=>{const e=d();return g.renounceOwnership({walletClient:i,policyContractAddress:e})},transferOwnership:e=>{const l=d();return g.transferOwnership({walletClient:i,policyContractAddress:l,...e})},connectIdentityWithNewton:e=>p({method:y.Connect,id:u(),jsonrpc:"2.0",params:{apiKey:r,chainId:i.chain?.id,appWalletAddress:e.appWalletAddress,appClientAddress:e.appClientAddress}},o),registerUserData:e=>p({method:y.RegisterUserData,id:u(),jsonrpc:"2.0",params:{apiKey:r,userData:e.userData,gatewayApiUrlOverride:t,chainId:i.chain?.id,appIdentityDomain:e.appIdentityDomain,identityRegistryOverride:h}},o),linkApp:e=>p({method:y.LinkApp,id:u(),jsonrpc:"2.0",params:{apiKey:r,appWalletAddress:e.appWalletAddress,appClientAddress:e.appClientAddress,appIdentityDomain:e.appIdentityDomain,chainId:i.chain?.id,identityRegistryOverride:h}},o),unlinkApp:e=>p({method:y.Unlink,id:u(),jsonrpc:"2.0",params:{apiKey:r,appWalletAddress:e.appWalletAddress,appClientAddress:e.appClientAddress,chainId:i.chain?.id,appIdentityDomain:e.appIdentityDomain,identityRegistryOverride:h}},o),getPrivacyPublicKey:()=>v(i?.chain?.id??s.id,r,t),createSecureEnvelope:(e,l)=>E(e,l),uploadEncryptedData:e=>D(i?.chain?.id??s.id,r,e,t),uploadSecureEnvelope:e=>f(i?.chain?.id??s.id,r,e,t),generateSigningKeyPair:()=>I(),storeEncryptedSecrets:e=>b(i?.chain?.id??s.id,r,e,t),signPrivacyAuthorization:e=>P(e),sendIdentityEncrypted:e=>w(i,e,r,t)}},V=(A,c)=>i=>{if(!C.includes(i?.chain?.id??s.id))throw new Error(`Newton SDK: Invalid network specified for newtonPublicActions. Only ${C.join(", ")} are supported.`);const r=A?.policyContractAddress,n=()=>{if(!r)throw new Error('Newton SDK: policyContractAddress is required. Ensure you instantiate viem client actions extension with policyContractAddress parameter. Example: newtonPublicClientActions({ policyContractAddress: "0x123..." })');return r},d=c?.taskManagerAddress??S[i?.chain?.id??s.id],m=c?.attestationValidatorAddress??z[i?.chain?.id??s.id];return{waitForTaskResponded:t=>W(i,t,d),getTaskResponseHash:t=>K(i,t,d),getTaskStatus:t=>k(i,t,d,m),clientToPolicyId:t=>{const o=n();return a.clientToPolicyId({publicClient:i,policyContractAddress:o,...t})},entrypoint:()=>{const t=n();return a.entrypoint({publicClient:i,policyContractAddress:t})},factory:()=>{const t=n();return a.factory({publicClient:i,policyContractAddress:t})},getEntrypoint:()=>{const t=n();return a.getEntrypoint({publicClient:i,policyContractAddress:t})},getMetadataCid:()=>{const t=n();return a.getMetadataCid({publicClient:i,policyContractAddress:t})},getPolicyCid:()=>{const t=n();return a.getPolicyCid({publicClient:i,policyContractAddress:t})},getPolicyConfig:t=>{const o=n();return a.getPolicyConfig({publicClient:i,policyContractAddress:o,...t})},getPolicyData:()=>{const t=n();return a.getPolicyData({publicClient:i,policyContractAddress:t})},getPolicyId:t=>{const o=n();return a.getPolicyId({publicClient:i,policyContractAddress:o,...t})},getSchemaCid:()=>{const t=n();return a.getSchemaCid({publicClient:i,policyContractAddress:t})},isPolicyVerified:()=>{const t=n();return a.isPolicyVerified({publicClient:i,policyContractAddress:t})},metadataCid:()=>{const t=n();return a.metadataCid({publicClient:i,policyContractAddress:t})},owner:()=>{const t=n();return a.owner({publicClient:i,policyContractAddress:t})},policyCid:()=>{const t=n();return a.policyCid({publicClient:i,policyContractAddress:t})},policyData:t=>{const o=n();return a.policyData({publicClient:i,policyContractAddress:o,...t})},schemaCid:()=>{const t=n();return a.schemaCid({publicClient:i,policyContractAddress:t})},supportsInterface:t=>{const o=n();return a.supportsInterface({publicClient:i,policyContractAddress:o,...t})},precomputePolicyId:t=>{const o=n();return a.precomputePolicyId({publicClient:i,policyContractAddress:o,...t})}}};export{E as createSecureEnvelope,I as generateSigningKeyPair,v as getPrivacyPublicKey,it as identityDomainHash,V as newtonPublicClientActions,F as newtonWalletClientActions,w as sendIdentityEncrypted,P as signPrivacyAuthorization,b as storeEncryptedSecrets,D as uploadEncryptedData,f as uploadSecureEnvelope};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{GATEWAY_METHODS as h}from"../../const.mjs";import{SDKError as e}from"../../sdk-exceptions.mjs";import{SDKErrorCode as n}from"../../types/core/exception-types.mjs";import{AvsHttpService as p}from"../../utils/https.mjs";import{keccak256 as u,toBytes as l,isAddress as s,getAddress as o}from"viem";function y(i){return u(l(i))}async function A(i,t,c,w){const d=i.chain?.id;if(!d)throw new e(n.MissingChain,"walletClient must have a chain configured");const r=i.account;if(!r)throw new e(n.MissingAccount,"walletClient must have an account configured");if(!s(t.identityOwner))throw new e(n.InvalidAddress,`invalid identityOwner address: ${t.identityOwner}`);if(!s(t.identityRegistryAddress))throw new e(n.InvalidAddress,`invalid identityRegistryAddress: ${t.identityRegistryAddress}`);if(o(r.address)!==o(t.identityOwner))throw new e(n.IdentityOwnerMismatch,`wallet account ${r.address} does not match identityOwner ${t.identityOwner}`);const m=await i.signTypedData({account:r,domain:{name:"IdentityRegistry",version:"1",chainId:BigInt(d),verifyingContract:t.identityRegistryAddress},types:{EncryptedIdentityData:[{name:"data",type:"string"}]},primaryType:"EncryptedIdentityData",message:{data:t.identityData}}),g=y(t.identityDomain),f={identity_owner:t.identityOwner,identity_owner_sig:m,identity_data:{data:t.identityData},identity_domain:g},a=await new p(d,w).Post(h.sendIdentityEncrypted,f,c);if(a.error)throw a.error;return a.result}export{y as identityDomainHash,A as sendIdentityEncrypted};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var e;(function(n){n.MissingApiKey="MISSING_API_KEY",n.PopupAlreadyExists="POPUP_ALREADY_EXISTS",n.MalformedResponse="MALFORMED_RESPONSE",n.InvalidArgument="INVALID_ARGUMENT",n.ExtensionNotInitialized="EXTENSION_NOT_INITIALIZED",n.IncompatibleExtensions="INCOMPATIBLE_EXTENSIONS",n.FailedToOpenPopup="FAILED_TO_OPEN_POPUP",n.FailedToRetrieveNativeTokenBalance="FAILED_TO_RETRIEVE_NATIVE_TOKEN_BALANCE",n.MissingChain="MISSING_CHAIN",n.MissingAccount="MISSING_ACCOUNT",n.InvalidAddress="INVALID_ADDRESS",n.IdentityOwnerMismatch="IDENTITY_OWNER_MISMATCH"})(e||(e={}));var i;(function(n){n.SyncWeb3Method="SYNC_WEB3_METHOD",n.ReactNativeEndpointConfiguration="REACT_NATIVE_ENDPOINT_CONFIGURATION",n.DeprecationNotice="DEPRECATION_NOTICE",n.ProductAnnouncement="ANNOUNCEMENT"})(i||(i={}));var t;(function(n){n[n.ParseError=-32700]="ParseError",n[n.InvalidRequest=-32600]="InvalidRequest",n[n.MethodNotFound=-32601]="MethodNotFound",n[n.InvalidParams=-32602]="InvalidParams",n[n.InternalError=-32603]="InternalError",n[n.MagicLinkRateLimited=-10002]="MagicLinkRateLimited",n[n.UserAlreadyLoggedIn=-10003]="UserAlreadyLoggedIn",n[n.AccessDeniedToUser=-10011]="AccessDeniedToUser",n[n.UserRejectedAction=-10012]="UserRejectedAction",n[n.RequestCancelled=-10014]="RequestCancelled",n[n.RedirectLoginComplete=-10015]="RedirectLoginComplete",n[n.NewtonWalletSessionTerminated=-10016]="NewtonWalletSessionTerminated",n[n.PopupRequestOverriden=-10017]="PopupRequestOverriden"})(t||(t={}));export{t as RPCErrorCode,e as SDKErrorCode,i as SDKWarningCode};
|
package/dist/types/const.d.mts
CHANGED
|
@@ -10,6 +10,7 @@ export declare const GATEWAY_METHODS: {
|
|
|
10
10
|
getPrivacyPublicKey: string;
|
|
11
11
|
uploadEncryptedData: string;
|
|
12
12
|
storeEncryptedSecrets: string;
|
|
13
|
+
sendIdentityEncrypted: string;
|
|
13
14
|
};
|
|
14
15
|
export declare const NEWTON_PROVER_TASK_MANAGER: Record<number, Hex>;
|
|
15
16
|
export declare const ATTESTATION_VALIDATOR: Record<number, Hex>;
|
package/dist/types/const.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare const GATEWAY_METHODS: {
|
|
|
10
10
|
getPrivacyPublicKey: string;
|
|
11
11
|
uploadEncryptedData: string;
|
|
12
12
|
storeEncryptedSecrets: string;
|
|
13
|
+
sendIdentityEncrypted: string;
|
|
13
14
|
};
|
|
14
15
|
export declare const NEWTON_PROVER_TASK_MANAGER: Record<number, Hex>;
|
|
15
16
|
export declare const ATTESTATION_VALIDATOR: Record<number, Hex>;
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Address, Hex, PublicClient, WalletClient } from 'viem';
|
|
2
2
|
import { type PendingTaskBuilder } from './modules/avs/index.d.mts';
|
|
3
|
+
import { identityDomainHash, sendIdentityEncrypted } from './modules/identity/index.d.mts';
|
|
3
4
|
import { createSecureEnvelope, generateSigningKeyPair, getPrivacyPublicKey, signPrivacyAuthorization, storeEncryptedSecrets, uploadEncryptedData, uploadSecureEnvelope } from './modules/privacy/index.d.mts';
|
|
5
|
+
import type { SendIdentityEncryptedParams, SendIdentityEncryptedResponse } from './types/identity.d.mts';
|
|
4
6
|
import type { PolicyParamsJson } from './types/policy.d.mts';
|
|
5
7
|
import type { CreateSecureEnvelopeParams, Ed25519KeyPair, PrivacyAuthorizationResult, PrivacyPublicKeyResponse, SecureEnvelopeResult, SignPrivacyAuthorizationParams, StoreEncryptedSecretsParams, StoreEncryptedSecretsResponse, UploadEncryptedDataParams, UploadEncryptedDataResponse, UploadSecureEnvelopeParams } from './types/privacy.d.mts';
|
|
6
8
|
import type { SimulatePolicyDataParams, SimulatePolicyDataResult, SimulatePolicyDataWithClientParams, SimulatePolicyDataWithClientResult, SimulatePolicyParams, SimulatePolicyResult, SimulateTaskParams, SimulateTaskResult, SubmitEvaluationRequestParams, SubmitIntentResult, Task, TaskId, TaskResponseResult, TaskStatus } from './types/task.d.mts';
|
|
@@ -76,6 +78,7 @@ declare const newtonWalletClientActions: (config: {
|
|
|
76
78
|
generateSigningKeyPair: () => Ed25519KeyPair;
|
|
77
79
|
storeEncryptedSecrets: (args: StoreEncryptedSecretsParams) => Promise<StoreEncryptedSecretsResponse>;
|
|
78
80
|
signPrivacyAuthorization: (args: SignPrivacyAuthorizationParams) => PrivacyAuthorizationResult;
|
|
81
|
+
sendIdentityEncrypted: (args: SendIdentityEncryptedParams) => Promise<SendIdentityEncryptedResponse>;
|
|
79
82
|
};
|
|
80
83
|
declare const newtonPublicClientActions: (options?: {
|
|
81
84
|
policyContractAddress?: Address;
|
|
@@ -135,4 +138,5 @@ declare const newtonPublicClientActions: (options?: {
|
|
|
135
138
|
}) => string;
|
|
136
139
|
};
|
|
137
140
|
export { newtonPublicClientActions, newtonWalletClientActions };
|
|
141
|
+
export { identityDomainHash, sendIdentityEncrypted };
|
|
138
142
|
export { createSecureEnvelope, generateSigningKeyPair, getPrivacyPublicKey, signPrivacyAuthorization, storeEncryptedSecrets, uploadEncryptedData, uploadSecureEnvelope, };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Address, Hex, PublicClient, WalletClient } from 'viem';
|
|
2
2
|
import { type PendingTaskBuilder } from './modules/avs';
|
|
3
|
+
import { identityDomainHash, sendIdentityEncrypted } from './modules/identity';
|
|
3
4
|
import { createSecureEnvelope, generateSigningKeyPair, getPrivacyPublicKey, signPrivacyAuthorization, storeEncryptedSecrets, uploadEncryptedData, uploadSecureEnvelope } from './modules/privacy';
|
|
5
|
+
import type { SendIdentityEncryptedParams, SendIdentityEncryptedResponse } from './types/identity';
|
|
4
6
|
import type { PolicyParamsJson } from './types/policy';
|
|
5
7
|
import type { CreateSecureEnvelopeParams, Ed25519KeyPair, PrivacyAuthorizationResult, PrivacyPublicKeyResponse, SecureEnvelopeResult, SignPrivacyAuthorizationParams, StoreEncryptedSecretsParams, StoreEncryptedSecretsResponse, UploadEncryptedDataParams, UploadEncryptedDataResponse, UploadSecureEnvelopeParams } from './types/privacy';
|
|
6
8
|
import type { SimulatePolicyDataParams, SimulatePolicyDataResult, SimulatePolicyDataWithClientParams, SimulatePolicyDataWithClientResult, SimulatePolicyParams, SimulatePolicyResult, SimulateTaskParams, SimulateTaskResult, SubmitEvaluationRequestParams, SubmitIntentResult, Task, TaskId, TaskResponseResult, TaskStatus } from './types/task';
|
|
@@ -76,6 +78,7 @@ declare const newtonWalletClientActions: (config: {
|
|
|
76
78
|
generateSigningKeyPair: () => Ed25519KeyPair;
|
|
77
79
|
storeEncryptedSecrets: (args: StoreEncryptedSecretsParams) => Promise<StoreEncryptedSecretsResponse>;
|
|
78
80
|
signPrivacyAuthorization: (args: SignPrivacyAuthorizationParams) => PrivacyAuthorizationResult;
|
|
81
|
+
sendIdentityEncrypted: (args: SendIdentityEncryptedParams) => Promise<SendIdentityEncryptedResponse>;
|
|
79
82
|
};
|
|
80
83
|
declare const newtonPublicClientActions: (options?: {
|
|
81
84
|
policyContractAddress?: Address;
|
|
@@ -135,4 +138,5 @@ declare const newtonPublicClientActions: (options?: {
|
|
|
135
138
|
}) => string;
|
|
136
139
|
};
|
|
137
140
|
export { newtonPublicClientActions, newtonWalletClientActions };
|
|
141
|
+
export { identityDomainHash, sendIdentityEncrypted };
|
|
138
142
|
export { createSecureEnvelope, generateSigningKeyPair, getPrivacyPublicKey, signPrivacyAuthorization, storeEncryptedSecrets, uploadEncryptedData, uploadSecureEnvelope, };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { 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 } 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
|
+
export { submitEvaluationRequest, waitForTaskResponded, getTaskResponseHash, getTaskStatus, evaluateIntentDirect, submitIntentAndSubscribe, simulateTask, simulatePolicy, simulatePolicyData, simulatePolicyDataWithClient, };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Newton Identity Module — EIP-712 signed identity data submission to the on-chain IdentityRegistry.
|
|
3
|
+
*
|
|
4
|
+
* The gateway's `newt_sendIdentityEncrypted` RPC method accepts an EIP-712 signature over
|
|
5
|
+
* `EncryptedIdentityData { string data }` with domain `{name: "IdentityRegistry", version: "1"}`.
|
|
6
|
+
* The `identity_domain` field (bytes32 = keccak256 of the domain name) tells the gateway
|
|
7
|
+
* how to interpret the blob after decryption.
|
|
8
|
+
*/
|
|
9
|
+
import type { SendIdentityEncryptedParams, SendIdentityEncryptedResponse } from '@core/types/identity';
|
|
10
|
+
import { type Hex, type WalletClient } from 'viem';
|
|
11
|
+
/**
|
|
12
|
+
* Compute the bytes32 identity domain hash from a human-readable domain name.
|
|
13
|
+
*
|
|
14
|
+
* Matches the Rust convention: `keccak256(toBytes("kyc"))` producing a bytes32 hash.
|
|
15
|
+
*/
|
|
16
|
+
export declare function identityDomainHash(domainName: string): Hex;
|
|
17
|
+
/**
|
|
18
|
+
* Sign encrypted identity data with EIP-712 and submit to the gateway.
|
|
19
|
+
*
|
|
20
|
+
* The wallet client signs `EncryptedIdentityData { string data }` using the
|
|
21
|
+
* EIP-712 domain `{name: "IdentityRegistry", version: "1", chainId, verifyingContract}`.
|
|
22
|
+
* The gateway validates the signature, then submits the data to the on-chain IdentityRegistry.
|
|
23
|
+
*
|
|
24
|
+
* @param walletClient - viem WalletClient with a connected account
|
|
25
|
+
* @param params - Identity data and domain parameters
|
|
26
|
+
* @param apiKey - Newton API key for gateway authentication
|
|
27
|
+
* @param gatewayApiUrlOverride - Optional gateway URL override
|
|
28
|
+
* @returns Transaction hash of the on-chain inclusion
|
|
29
|
+
*/
|
|
30
|
+
export declare function sendIdentityEncrypted(walletClient: WalletClient, params: SendIdentityEncryptedParams, apiKey: string, gatewayApiUrlOverride?: string): Promise<SendIdentityEncryptedResponse>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Newton Identity Module — EIP-712 signed identity data submission to the on-chain IdentityRegistry.
|
|
3
|
+
*
|
|
4
|
+
* The gateway's `newt_sendIdentityEncrypted` RPC method accepts an EIP-712 signature over
|
|
5
|
+
* `EncryptedIdentityData { string data }` with domain `{name: "IdentityRegistry", version: "1"}`.
|
|
6
|
+
* The `identity_domain` field (bytes32 = keccak256 of the domain name) tells the gateway
|
|
7
|
+
* how to interpret the blob after decryption.
|
|
8
|
+
*/
|
|
9
|
+
import type { SendIdentityEncryptedParams, SendIdentityEncryptedResponse } from '../../types/identity';
|
|
10
|
+
import { type Hex, type WalletClient } from 'viem';
|
|
11
|
+
/**
|
|
12
|
+
* Compute the bytes32 identity domain hash from a human-readable domain name.
|
|
13
|
+
*
|
|
14
|
+
* Matches the Rust convention: `keccak256(toBytes("kyc"))` producing a bytes32 hash.
|
|
15
|
+
*/
|
|
16
|
+
export declare function identityDomainHash(domainName: string): Hex;
|
|
17
|
+
/**
|
|
18
|
+
* Sign encrypted identity data with EIP-712 and submit to the gateway.
|
|
19
|
+
*
|
|
20
|
+
* The wallet client signs `EncryptedIdentityData { string data }` using the
|
|
21
|
+
* EIP-712 domain `{name: "IdentityRegistry", version: "1", chainId, verifyingContract}`.
|
|
22
|
+
* The gateway validates the signature, then submits the data to the on-chain IdentityRegistry.
|
|
23
|
+
*
|
|
24
|
+
* @param walletClient - viem WalletClient with a connected account
|
|
25
|
+
* @param params - Identity data and domain parameters
|
|
26
|
+
* @param apiKey - Newton API key for gateway authentication
|
|
27
|
+
* @param gatewayApiUrlOverride - Optional gateway URL override
|
|
28
|
+
* @returns Transaction hash of the on-chain inclusion
|
|
29
|
+
*/
|
|
30
|
+
export declare function sendIdentityEncrypted(walletClient: WalletClient, params: SendIdentityEncryptedParams, apiKey: string, gatewayApiUrlOverride?: string): Promise<SendIdentityEncryptedResponse>;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { PolicyId, PolicyParamsJson } from '@core/types/policy';
|
|
2
|
+
import { type Address, type PublicClient, type WalletClient } from 'viem';
|
|
3
|
+
export declare const policyWriteFunctions: {
|
|
4
|
+
initialize: ({ walletClient, policyContractAddress, ...args }: {
|
|
5
|
+
walletClient: WalletClient;
|
|
6
|
+
policyContractAddress: Address;
|
|
7
|
+
factory: Address;
|
|
8
|
+
entrypoint: string;
|
|
9
|
+
policyCid: string;
|
|
10
|
+
schemaCid: string;
|
|
11
|
+
policyData: Address[];
|
|
12
|
+
metadataCid: string;
|
|
13
|
+
owner: Address;
|
|
14
|
+
}) => Promise<`0x${string}`>;
|
|
15
|
+
renounceOwnership: ({ walletClient, policyContractAddress, }: {
|
|
16
|
+
walletClient: WalletClient;
|
|
17
|
+
policyContractAddress: Address;
|
|
18
|
+
}) => Promise<`0x${string}`>;
|
|
19
|
+
transferOwnership: ({ walletClient, policyContractAddress, ...args }: {
|
|
20
|
+
walletClient: WalletClient;
|
|
21
|
+
policyContractAddress: Address;
|
|
22
|
+
newOwner: Address;
|
|
23
|
+
}) => Promise<`0x${string}`>;
|
|
24
|
+
};
|
|
25
|
+
export declare const policyReadFunctions: {
|
|
26
|
+
getPolicyId: ({ publicClient, policyContractAddress, client, }: {
|
|
27
|
+
publicClient: PublicClient;
|
|
28
|
+
policyContractAddress: Address;
|
|
29
|
+
client: Address;
|
|
30
|
+
}) => Promise<`0x${string}`>;
|
|
31
|
+
getPolicyConfig: ({ publicClient, policyContractAddress, policyId, }: {
|
|
32
|
+
publicClient: PublicClient;
|
|
33
|
+
policyContractAddress: Address;
|
|
34
|
+
policyId: `0x${string}`;
|
|
35
|
+
}) => Promise<{
|
|
36
|
+
policyParams: string | object;
|
|
37
|
+
policyParamsHex: `0x${string}`;
|
|
38
|
+
expireAfter: number;
|
|
39
|
+
}>;
|
|
40
|
+
supportsInterface: ({ publicClient, policyContractAddress, interfaceId, }: {
|
|
41
|
+
publicClient: PublicClient;
|
|
42
|
+
policyContractAddress: Address;
|
|
43
|
+
interfaceId: `0x${string}`;
|
|
44
|
+
}) => Promise<boolean>;
|
|
45
|
+
owner: ({ publicClient, policyContractAddress, }: {
|
|
46
|
+
publicClient: PublicClient;
|
|
47
|
+
policyContractAddress: Address;
|
|
48
|
+
}) => Promise<Address>;
|
|
49
|
+
factory: ({ publicClient, policyContractAddress, }: {
|
|
50
|
+
publicClient: PublicClient;
|
|
51
|
+
policyContractAddress: Address;
|
|
52
|
+
}) => Promise<Address>;
|
|
53
|
+
entrypoint: ({ publicClient, policyContractAddress, }: {
|
|
54
|
+
publicClient: PublicClient;
|
|
55
|
+
policyContractAddress: Address;
|
|
56
|
+
}) => Promise<string>;
|
|
57
|
+
clientToPolicyId: ({ publicClient, policyContractAddress, client, }: {
|
|
58
|
+
publicClient: PublicClient;
|
|
59
|
+
policyContractAddress: Address;
|
|
60
|
+
client: Address;
|
|
61
|
+
}) => Promise<`0x${string}`>;
|
|
62
|
+
policyData: ({ publicClient, policyContractAddress, index, }: {
|
|
63
|
+
publicClient: PublicClient;
|
|
64
|
+
policyContractAddress: Address;
|
|
65
|
+
index: number;
|
|
66
|
+
}) => Promise<Address>;
|
|
67
|
+
getEntrypoint: ({ publicClient, policyContractAddress, }: {
|
|
68
|
+
publicClient: PublicClient;
|
|
69
|
+
policyContractAddress: Address;
|
|
70
|
+
}) => Promise<string>;
|
|
71
|
+
getMetadataCid: ({ publicClient, policyContractAddress, }: {
|
|
72
|
+
publicClient: PublicClient;
|
|
73
|
+
policyContractAddress: Address;
|
|
74
|
+
}) => Promise<string>;
|
|
75
|
+
getPolicyCid: ({ publicClient, policyContractAddress, }: {
|
|
76
|
+
publicClient: PublicClient;
|
|
77
|
+
policyContractAddress: Address;
|
|
78
|
+
}) => Promise<string>;
|
|
79
|
+
getPolicyData: ({ publicClient, policyContractAddress, }: {
|
|
80
|
+
publicClient: PublicClient;
|
|
81
|
+
policyContractAddress: Address;
|
|
82
|
+
}) => Promise<Address[]>;
|
|
83
|
+
getSchemaCid: ({ publicClient, policyContractAddress, }: {
|
|
84
|
+
publicClient: PublicClient;
|
|
85
|
+
policyContractAddress: Address;
|
|
86
|
+
}) => Promise<string>;
|
|
87
|
+
isPolicyVerified: ({ publicClient, policyContractAddress, }: {
|
|
88
|
+
publicClient: PublicClient;
|
|
89
|
+
policyContractAddress: Address;
|
|
90
|
+
}) => Promise<boolean>;
|
|
91
|
+
metadataCid: ({ publicClient, policyContractAddress, }: {
|
|
92
|
+
publicClient: PublicClient;
|
|
93
|
+
policyContractAddress: Address;
|
|
94
|
+
}) => Promise<string>;
|
|
95
|
+
policyCid: ({ publicClient, policyContractAddress, }: {
|
|
96
|
+
publicClient: PublicClient;
|
|
97
|
+
policyContractAddress: Address;
|
|
98
|
+
}) => Promise<string>;
|
|
99
|
+
schemaCid: ({ publicClient, policyContractAddress, }: {
|
|
100
|
+
publicClient: PublicClient;
|
|
101
|
+
policyContractAddress: Address;
|
|
102
|
+
}) => Promise<string>;
|
|
103
|
+
precomputePolicyId: ({ publicClient, policyContractAddress, ...args }: {
|
|
104
|
+
publicClient: PublicClient;
|
|
105
|
+
policyContractAddress: Address;
|
|
106
|
+
policyContract: Address;
|
|
107
|
+
policyData: Address[];
|
|
108
|
+
params: PolicyParamsJson;
|
|
109
|
+
client: Address;
|
|
110
|
+
policyUri: string;
|
|
111
|
+
schemaUri: string;
|
|
112
|
+
entrypoint: string;
|
|
113
|
+
expireAfter?: number;
|
|
114
|
+
blockTimestamp?: bigint;
|
|
115
|
+
}) => PolicyId;
|
|
116
|
+
};
|
|
117
|
+
export declare const policyFunctions: {
|
|
118
|
+
initialize: ({ walletClient, policyContractAddress, ...args }: {
|
|
119
|
+
walletClient: WalletClient;
|
|
120
|
+
policyContractAddress: Address;
|
|
121
|
+
factory: Address;
|
|
122
|
+
entrypoint: string;
|
|
123
|
+
policyCid: string;
|
|
124
|
+
schemaCid: string;
|
|
125
|
+
policyData: Address[];
|
|
126
|
+
metadataCid: string;
|
|
127
|
+
owner: Address;
|
|
128
|
+
}) => Promise<`0x${string}`>;
|
|
129
|
+
renounceOwnership: ({ walletClient, policyContractAddress, }: {
|
|
130
|
+
walletClient: WalletClient;
|
|
131
|
+
policyContractAddress: Address;
|
|
132
|
+
}) => Promise<`0x${string}`>;
|
|
133
|
+
transferOwnership: ({ walletClient, policyContractAddress, ...args }: {
|
|
134
|
+
walletClient: WalletClient;
|
|
135
|
+
policyContractAddress: Address;
|
|
136
|
+
newOwner: Address;
|
|
137
|
+
}) => Promise<`0x${string}`>;
|
|
138
|
+
getPolicyId: ({ publicClient, policyContractAddress, client, }: {
|
|
139
|
+
publicClient: PublicClient;
|
|
140
|
+
policyContractAddress: Address;
|
|
141
|
+
client: Address;
|
|
142
|
+
}) => Promise<`0x${string}`>;
|
|
143
|
+
getPolicyConfig: ({ publicClient, policyContractAddress, policyId, }: {
|
|
144
|
+
publicClient: PublicClient;
|
|
145
|
+
policyContractAddress: Address;
|
|
146
|
+
policyId: `0x${string}`;
|
|
147
|
+
}) => Promise<{
|
|
148
|
+
policyParams: string | object;
|
|
149
|
+
policyParamsHex: `0x${string}`;
|
|
150
|
+
expireAfter: number;
|
|
151
|
+
}>;
|
|
152
|
+
supportsInterface: ({ publicClient, policyContractAddress, interfaceId, }: {
|
|
153
|
+
publicClient: PublicClient;
|
|
154
|
+
policyContractAddress: Address;
|
|
155
|
+
interfaceId: `0x${string}`;
|
|
156
|
+
}) => Promise<boolean>;
|
|
157
|
+
owner: ({ publicClient, policyContractAddress, }: {
|
|
158
|
+
publicClient: PublicClient;
|
|
159
|
+
policyContractAddress: Address;
|
|
160
|
+
}) => Promise<Address>;
|
|
161
|
+
factory: ({ publicClient, policyContractAddress, }: {
|
|
162
|
+
publicClient: PublicClient;
|
|
163
|
+
policyContractAddress: Address;
|
|
164
|
+
}) => Promise<Address>;
|
|
165
|
+
entrypoint: ({ publicClient, policyContractAddress, }: {
|
|
166
|
+
publicClient: PublicClient;
|
|
167
|
+
policyContractAddress: Address;
|
|
168
|
+
}) => Promise<string>;
|
|
169
|
+
clientToPolicyId: ({ publicClient, policyContractAddress, client, }: {
|
|
170
|
+
publicClient: PublicClient;
|
|
171
|
+
policyContractAddress: Address;
|
|
172
|
+
client: Address;
|
|
173
|
+
}) => Promise<`0x${string}`>;
|
|
174
|
+
policyData: ({ publicClient, policyContractAddress, index, }: {
|
|
175
|
+
publicClient: PublicClient;
|
|
176
|
+
policyContractAddress: Address;
|
|
177
|
+
index: number;
|
|
178
|
+
}) => Promise<Address>;
|
|
179
|
+
getEntrypoint: ({ publicClient, policyContractAddress, }: {
|
|
180
|
+
publicClient: PublicClient;
|
|
181
|
+
policyContractAddress: Address;
|
|
182
|
+
}) => Promise<string>;
|
|
183
|
+
getMetadataCid: ({ publicClient, policyContractAddress, }: {
|
|
184
|
+
publicClient: PublicClient;
|
|
185
|
+
policyContractAddress: Address;
|
|
186
|
+
}) => Promise<string>;
|
|
187
|
+
getPolicyCid: ({ publicClient, policyContractAddress, }: {
|
|
188
|
+
publicClient: PublicClient;
|
|
189
|
+
policyContractAddress: Address;
|
|
190
|
+
}) => Promise<string>;
|
|
191
|
+
getPolicyData: ({ publicClient, policyContractAddress, }: {
|
|
192
|
+
publicClient: PublicClient;
|
|
193
|
+
policyContractAddress: Address;
|
|
194
|
+
}) => Promise<Address[]>;
|
|
195
|
+
getSchemaCid: ({ publicClient, policyContractAddress, }: {
|
|
196
|
+
publicClient: PublicClient;
|
|
197
|
+
policyContractAddress: Address;
|
|
198
|
+
}) => Promise<string>;
|
|
199
|
+
isPolicyVerified: ({ publicClient, policyContractAddress, }: {
|
|
200
|
+
publicClient: PublicClient;
|
|
201
|
+
policyContractAddress: Address;
|
|
202
|
+
}) => Promise<boolean>;
|
|
203
|
+
metadataCid: ({ publicClient, policyContractAddress, }: {
|
|
204
|
+
publicClient: PublicClient;
|
|
205
|
+
policyContractAddress: Address;
|
|
206
|
+
}) => Promise<string>;
|
|
207
|
+
policyCid: ({ publicClient, policyContractAddress, }: {
|
|
208
|
+
publicClient: PublicClient;
|
|
209
|
+
policyContractAddress: Address;
|
|
210
|
+
}) => Promise<string>;
|
|
211
|
+
schemaCid: ({ publicClient, policyContractAddress, }: {
|
|
212
|
+
publicClient: PublicClient;
|
|
213
|
+
policyContractAddress: Address;
|
|
214
|
+
}) => Promise<string>;
|
|
215
|
+
precomputePolicyId: ({ publicClient, policyContractAddress, ...args }: {
|
|
216
|
+
publicClient: PublicClient;
|
|
217
|
+
policyContractAddress: Address;
|
|
218
|
+
policyContract: Address;
|
|
219
|
+
policyData: Address[];
|
|
220
|
+
params: PolicyParamsJson;
|
|
221
|
+
client: Address;
|
|
222
|
+
policyUri: string;
|
|
223
|
+
schemaUri: string;
|
|
224
|
+
entrypoint: string;
|
|
225
|
+
expireAfter?: number;
|
|
226
|
+
blockTimestamp?: bigint;
|
|
227
|
+
}) => PolicyId;
|
|
228
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
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, PrivacyAuthorizationResult, PrivacyPublicKeyResponse, SecureEnvelopeResult, SignPrivacyAuthorizationParams, StoreEncryptedSecretsParams, StoreEncryptedSecretsResponse, UploadEncryptedDataParams, UploadEncryptedDataResponse, UploadSecureEnvelopeParams } 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
|
+
* The caller owns the signingKey buffer lifecycle. This function creates an
|
|
20
|
+
* internal copy for signing and zeroes it immediately after use, but the
|
|
21
|
+
* caller is responsible for zeroing the original Uint8Array when done.
|
|
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
|
+
* Encrypt data and upload to the gateway in a single call.
|
|
37
|
+
*
|
|
38
|
+
* Combines createSecureEnvelope + RPC upload. If recipientPublicKey is not
|
|
39
|
+
* provided, it is fetched from the gateway first via newt_getPrivacyPublicKey.
|
|
40
|
+
*/
|
|
41
|
+
export declare function uploadEncryptedData(chainId: number, apiKey: string, params: UploadEncryptedDataParams, gatewayApiUrlOverride?: string): Promise<UploadEncryptedDataResponse>;
|
|
42
|
+
/**
|
|
43
|
+
* Upload a pre-built SecureEnvelope to the gateway.
|
|
44
|
+
*
|
|
45
|
+
* Use this when you've already created an envelope via createSecureEnvelope
|
|
46
|
+
* and want to control the upload separately — e.g., offline-first apps that
|
|
47
|
+
* encrypt now and upload later, or batching multiple envelopes.
|
|
48
|
+
*/
|
|
49
|
+
export declare function uploadSecureEnvelope(chainId: number, apiKey: string, params: UploadSecureEnvelopeParams, gatewayApiUrlOverride?: string): Promise<UploadEncryptedDataResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Generate a random Ed25519 key pair for signing envelopes and privacy authorization.
|
|
52
|
+
*
|
|
53
|
+
* This is a pure offline function. The private key is generated from 32 bytes of
|
|
54
|
+
* cryptographically secure randomness via `crypto.getRandomValues`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function generateSigningKeyPair(): Ed25519KeyPair;
|
|
57
|
+
/**
|
|
58
|
+
* Upload KMS-encrypted secrets for a policy client's PolicyData.
|
|
59
|
+
*
|
|
60
|
+
* The gateway decrypts via AWS KMS, validates against the PolicyData schema,
|
|
61
|
+
* and stores the secrets for use during policy evaluation.
|
|
62
|
+
*/
|
|
63
|
+
export declare function storeEncryptedSecrets(chainId: number, apiKey: string, params: StoreEncryptedSecretsParams, gatewayApiUrlOverride?: string): Promise<StoreEncryptedSecretsResponse>;
|
|
64
|
+
/**
|
|
65
|
+
* Compute dual Ed25519 signatures for privacy-enabled task creation.
|
|
66
|
+
*
|
|
67
|
+
* The gateway validates these signatures when `encrypted_data_refs` are present
|
|
68
|
+
* in a `newt_createTask` request. This prevents unauthorized use of encrypted
|
|
69
|
+
* data references across policy contexts.
|
|
70
|
+
*
|
|
71
|
+
* Signature scheme (must match `crates/gateway/src/processor/privacy_auth.rs`):
|
|
72
|
+
* - User signs: keccak256(abi.encodePacked(policy_client, intent_hash, ref_id_1, ref_id_2, ...))
|
|
73
|
+
* - App signs: keccak256(abi.encodePacked(policy_client, intent_hash, user_signature))
|
|
74
|
+
*
|
|
75
|
+
* This is a pure offline function — zero network calls.
|
|
76
|
+
*/
|
|
77
|
+
export declare function signPrivacyAuthorization(params: SignPrivacyAuthorizationParams): PrivacyAuthorizationResult;
|
|
@@ -6,7 +6,11 @@ export declare enum SDKErrorCode {
|
|
|
6
6
|
ExtensionNotInitialized = "EXTENSION_NOT_INITIALIZED",
|
|
7
7
|
IncompatibleExtensions = "INCOMPATIBLE_EXTENSIONS",
|
|
8
8
|
FailedToOpenPopup = "FAILED_TO_OPEN_POPUP",
|
|
9
|
-
FailedToRetrieveNativeTokenBalance = "FAILED_TO_RETRIEVE_NATIVE_TOKEN_BALANCE"
|
|
9
|
+
FailedToRetrieveNativeTokenBalance = "FAILED_TO_RETRIEVE_NATIVE_TOKEN_BALANCE",
|
|
10
|
+
MissingChain = "MISSING_CHAIN",
|
|
11
|
+
MissingAccount = "MISSING_ACCOUNT",
|
|
12
|
+
InvalidAddress = "INVALID_ADDRESS",
|
|
13
|
+
IdentityOwnerMismatch = "IDENTITY_OWNER_MISMATCH"
|
|
10
14
|
}
|
|
11
15
|
export declare enum SDKWarningCode {
|
|
12
16
|
SyncWeb3Method = "SYNC_WEB3_METHOD",
|
|
@@ -6,7 +6,11 @@ export declare enum SDKErrorCode {
|
|
|
6
6
|
ExtensionNotInitialized = "EXTENSION_NOT_INITIALIZED",
|
|
7
7
|
IncompatibleExtensions = "INCOMPATIBLE_EXTENSIONS",
|
|
8
8
|
FailedToOpenPopup = "FAILED_TO_OPEN_POPUP",
|
|
9
|
-
FailedToRetrieveNativeTokenBalance = "FAILED_TO_RETRIEVE_NATIVE_TOKEN_BALANCE"
|
|
9
|
+
FailedToRetrieveNativeTokenBalance = "FAILED_TO_RETRIEVE_NATIVE_TOKEN_BALANCE",
|
|
10
|
+
MissingChain = "MISSING_CHAIN",
|
|
11
|
+
MissingAccount = "MISSING_ACCOUNT",
|
|
12
|
+
InvalidAddress = "INVALID_ADDRESS",
|
|
13
|
+
IdentityOwnerMismatch = "IDENTITY_OWNER_MISMATCH"
|
|
10
14
|
}
|
|
11
15
|
export declare enum SDKWarningCode {
|
|
12
16
|
SyncWeb3Method = "SYNC_WEB3_METHOD",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Address, Hex } from 'viem';
|
|
1
2
|
type DateString = `${number}${number}${number}${number}-${number}${number}-${number}${number}`;
|
|
2
3
|
export interface KycUserData {
|
|
3
4
|
status: string;
|
|
@@ -9,4 +10,31 @@ export interface KycUserData {
|
|
|
9
10
|
issue_date: DateString;
|
|
10
11
|
issuing_authority: string;
|
|
11
12
|
}
|
|
13
|
+
/** Well-known identity domain name strings. */
|
|
14
|
+
export type IdentityDomainName = 'kyc';
|
|
15
|
+
/** Parameters for sending encrypted identity data to the gateway. */
|
|
16
|
+
export interface SendIdentityEncryptedParams {
|
|
17
|
+
/** The identity owner's EVM address (must match the wallet signer) */
|
|
18
|
+
identityOwner: Address;
|
|
19
|
+
/** The encrypted identity data blob (opaque string — encrypted by the caller) */
|
|
20
|
+
identityData: string;
|
|
21
|
+
/** Identity domain name (e.g., "kyc"). Hashed to bytes32 via keccak256. */
|
|
22
|
+
identityDomain: IdentityDomainName | string;
|
|
23
|
+
/** IdentityRegistry contract address for the EIP-712 domain */
|
|
24
|
+
identityRegistryAddress: Address;
|
|
25
|
+
}
|
|
26
|
+
/** Response from newt_sendIdentityEncrypted. */
|
|
27
|
+
export interface SendIdentityEncryptedResponse {
|
|
28
|
+
/** Transaction hash where the identity data was included on-chain */
|
|
29
|
+
inclusion_tx: string;
|
|
30
|
+
}
|
|
31
|
+
/** RPC request body for newt_sendIdentityEncrypted (snake_case, matches gateway). */
|
|
32
|
+
export interface SendIdentityEncryptedRpcRequest {
|
|
33
|
+
identity_owner: Address;
|
|
34
|
+
identity_owner_sig: Hex;
|
|
35
|
+
identity_data: {
|
|
36
|
+
data: string;
|
|
37
|
+
};
|
|
38
|
+
identity_domain: Hex;
|
|
39
|
+
}
|
|
12
40
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Address, Hex } from 'viem';
|
|
1
2
|
type DateString = `${number}${number}${number}${number}-${number}${number}-${number}${number}`;
|
|
2
3
|
export interface KycUserData {
|
|
3
4
|
status: string;
|
|
@@ -9,4 +10,31 @@ export interface KycUserData {
|
|
|
9
10
|
issue_date: DateString;
|
|
10
11
|
issuing_authority: string;
|
|
11
12
|
}
|
|
13
|
+
/** Well-known identity domain name strings. */
|
|
14
|
+
export type IdentityDomainName = 'kyc';
|
|
15
|
+
/** Parameters for sending encrypted identity data to the gateway. */
|
|
16
|
+
export interface SendIdentityEncryptedParams {
|
|
17
|
+
/** The identity owner's EVM address (must match the wallet signer) */
|
|
18
|
+
identityOwner: Address;
|
|
19
|
+
/** The encrypted identity data blob (opaque string — encrypted by the caller) */
|
|
20
|
+
identityData: string;
|
|
21
|
+
/** Identity domain name (e.g., "kyc"). Hashed to bytes32 via keccak256. */
|
|
22
|
+
identityDomain: IdentityDomainName | string;
|
|
23
|
+
/** IdentityRegistry contract address for the EIP-712 domain */
|
|
24
|
+
identityRegistryAddress: Address;
|
|
25
|
+
}
|
|
26
|
+
/** Response from newt_sendIdentityEncrypted. */
|
|
27
|
+
export interface SendIdentityEncryptedResponse {
|
|
28
|
+
/** Transaction hash where the identity data was included on-chain */
|
|
29
|
+
inclusion_tx: string;
|
|
30
|
+
}
|
|
31
|
+
/** RPC request body for newt_sendIdentityEncrypted (snake_case, matches gateway). */
|
|
32
|
+
export interface SendIdentityEncryptedRpcRequest {
|
|
33
|
+
identity_owner: Address;
|
|
34
|
+
identity_owner_sig: Hex;
|
|
35
|
+
identity_data: {
|
|
36
|
+
data: string;
|
|
37
|
+
};
|
|
38
|
+
identity_domain: Hex;
|
|
39
|
+
}
|
|
12
40
|
export {};
|
package/package.json
CHANGED