read client cert/key from file
This commit is contained in:
16
index.js
16
index.js
@@ -1,19 +1,23 @@
|
||||
const { PrimusNetwork } = require("@primuslabs/network-core-sdk");
|
||||
const { ethers } = require("ethers");
|
||||
require("dotenv/config");
|
||||
const fs = require("fs");
|
||||
|
||||
async function primusProofTest() {
|
||||
const PRIVATEKEY = process.env.PRIVATE_KEY;
|
||||
const PRIVATE_KEY = process.env.PRIVATE_KEY?.trim() ?? (() => { throw new Error("Missing PRIVATE_KEY in .env"); })();
|
||||
const CLIENT_CRT = process.env.CLIENT_CRT?.trim() ?? (() => { throw new Error("Missing CLIENT_CRT in .env"); })();
|
||||
const CLIENT_KEY = process.env.CLIENT_KEY?.trim() ?? (() => { throw new Error("Missing CLIENT_KEY in .env"); })();
|
||||
|
||||
const address = "0x8F0D4188307496926d785fB00E08Ed772f3be890"; // change to your address
|
||||
const chainId = 84532; // Base Sepolia (or 8453 for Base mainnet)
|
||||
const baseSepoliaRpcUrl = "https://sepolia.base.org"; // (or 'https://mainnet.base.org' for Base mainnet)
|
||||
// The request and response can be customized as needed.
|
||||
|
||||
|
||||
// change to your request params
|
||||
const requests = [
|
||||
{
|
||||
url: "https://checkout.mtls.api.hm.bb.com.br/",
|
||||
method: "GET",
|
||||
method: "GET",
|
||||
header: {},
|
||||
body: "",
|
||||
}
|
||||
@@ -29,7 +33,7 @@ async function primusProofTest() {
|
||||
];
|
||||
|
||||
const provider = new ethers.providers.JsonRpcProvider(baseSepoliaRpcUrl);
|
||||
const wallet = new ethers.Wallet(PRIVATEKEY, provider);
|
||||
const wallet = new ethers.Wallet(PRIVATE_KEY, provider);
|
||||
|
||||
try {
|
||||
const primusNetwork = new PrimusNetwork();
|
||||
@@ -46,8 +50,8 @@ async function primusProofTest() {
|
||||
|
||||
// Compose params for attest
|
||||
const mTLS = {
|
||||
clientCrt: "YourClientCrtString", // Please replace with your ownner client crt string
|
||||
clientKey: "YourClientKeyString", // Please replace with your ownner client key string
|
||||
clientKey: fs.readFileSync(CLIENT_KEY).toString(),
|
||||
clientCrt: fs.readFileSync(CLIENT_CRT).toString(),
|
||||
}
|
||||
const attestParams = {
|
||||
...submitTaskParams,
|
||||
|
||||
Reference in New Issue
Block a user