@zendfi/sdk 0.8.0 → 0.8.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.
- package/dist/index.js +15 -23
- package/dist/index.mjs +15 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2279,9 +2279,6 @@ var DeviceBoundSessionKey = class _DeviceBoundSessionKey {
|
|
|
2279
2279
|
let keypair;
|
|
2280
2280
|
if (this.isCached()) {
|
|
2281
2281
|
keypair = this.cachedKeypair;
|
|
2282
|
-
if (typeof console !== "undefined") {
|
|
2283
|
-
console.log("\u{1F680} Using cached keypair - instant signing (no PIN required)");
|
|
2284
|
-
}
|
|
2285
2282
|
} else {
|
|
2286
2283
|
if (!pin) {
|
|
2287
2284
|
throw new Error("PIN required: no cached keypair available");
|
|
@@ -2294,9 +2291,6 @@ var DeviceBoundSessionKey = class _DeviceBoundSessionKey {
|
|
|
2294
2291
|
if (cacheKeypair) {
|
|
2295
2292
|
const ttl = cacheTTL || this.DEFAULT_CACHE_TTL_MS;
|
|
2296
2293
|
this.cacheKeypair(keypair, ttl);
|
|
2297
|
-
if (typeof console !== "undefined") {
|
|
2298
|
-
console.log(`\u2705 Keypair decrypted and cached for ${ttl / 1e3 / 60} minutes`);
|
|
2299
|
-
}
|
|
2300
2294
|
}
|
|
2301
2295
|
}
|
|
2302
2296
|
transaction.partialSign(keypair);
|
|
@@ -2342,9 +2336,6 @@ var DeviceBoundSessionKey = class _DeviceBoundSessionKey {
|
|
|
2342
2336
|
clearCache() {
|
|
2343
2337
|
this.cachedKeypair = null;
|
|
2344
2338
|
this.cacheExpiry = null;
|
|
2345
|
-
if (typeof console !== "undefined") {
|
|
2346
|
-
console.log("\u{1F9F9} Keypair cache cleared");
|
|
2347
|
-
}
|
|
2348
2339
|
}
|
|
2349
2340
|
/**
|
|
2350
2341
|
* Decrypt and cache keypair without signing a transaction
|
|
@@ -2371,9 +2362,6 @@ var DeviceBoundSessionKey = class _DeviceBoundSessionKey {
|
|
|
2371
2362
|
);
|
|
2372
2363
|
const ttl = cacheTTL || this.DEFAULT_CACHE_TTL_MS;
|
|
2373
2364
|
this.cacheKeypair(keypair, ttl);
|
|
2374
|
-
if (typeof console !== "undefined") {
|
|
2375
|
-
console.log(`\u{1F513} Session key unlocked and cached for ${ttl / 1e3 / 60} minutes`);
|
|
2376
|
-
}
|
|
2377
2365
|
}
|
|
2378
2366
|
/**
|
|
2379
2367
|
* Get time remaining until cache expires (in milliseconds)
|
|
@@ -2402,10 +2390,6 @@ var DeviceBoundSessionKey = class _DeviceBoundSessionKey {
|
|
|
2402
2390
|
throw new Error("Cannot extend cache: no cached keypair");
|
|
2403
2391
|
}
|
|
2404
2392
|
this.cacheExpiry += additionalTTL;
|
|
2405
|
-
if (typeof console !== "undefined") {
|
|
2406
|
-
const remainingMinutes = this.getCacheTimeRemaining() / 1e3 / 60;
|
|
2407
|
-
console.log(`\u23F0 Cache extended - ${remainingMinutes.toFixed(1)} minutes remaining`);
|
|
2408
|
-
}
|
|
2409
2393
|
}
|
|
2410
2394
|
/**
|
|
2411
2395
|
* Set session key ID after backend creation
|
|
@@ -2440,26 +2424,34 @@ async function encryptKeypairWithLit(keypair, options) {
|
|
|
2440
2424
|
console.log(`[Lit] Connected to ${network}`);
|
|
2441
2425
|
}
|
|
2442
2426
|
try {
|
|
2443
|
-
const
|
|
2427
|
+
const evmContractConditions = [
|
|
2444
2428
|
{
|
|
2445
2429
|
contractAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
2446
2430
|
// USDC on Ethereum
|
|
2447
|
-
|
|
2431
|
+
functionName: "balanceOf",
|
|
2432
|
+
functionParams: [":userAddress"],
|
|
2433
|
+
functionAbi: {
|
|
2434
|
+
constant: true,
|
|
2435
|
+
inputs: [{ name: "account", type: "address" }],
|
|
2436
|
+
name: "balanceOf",
|
|
2437
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
2438
|
+
stateMutability: "view",
|
|
2439
|
+
type: "function"
|
|
2440
|
+
},
|
|
2448
2441
|
chain: "ethereum",
|
|
2449
|
-
method: "totalSupply",
|
|
2450
|
-
parameters: [],
|
|
2451
2442
|
returnValueTest: {
|
|
2452
|
-
|
|
2443
|
+
key: "",
|
|
2444
|
+
comparator: ">=",
|
|
2453
2445
|
value: "0"
|
|
2454
2446
|
}
|
|
2455
2447
|
}
|
|
2456
2448
|
];
|
|
2457
2449
|
const dataToEncrypt = keypair.secretKey;
|
|
2458
2450
|
if (debug) {
|
|
2459
|
-
console.log("[Lit] Encrypting keypair bytes...");
|
|
2451
|
+
console.log("[Lit] Encrypting keypair bytes with evmContractConditions...");
|
|
2460
2452
|
}
|
|
2461
2453
|
const encryptResult = await litClient.encrypt({
|
|
2462
|
-
|
|
2454
|
+
evmContractConditions,
|
|
2463
2455
|
dataToEncrypt
|
|
2464
2456
|
});
|
|
2465
2457
|
if (debug) {
|
package/dist/index.mjs
CHANGED
|
@@ -1812,9 +1812,6 @@ var DeviceBoundSessionKey = class _DeviceBoundSessionKey {
|
|
|
1812
1812
|
let keypair;
|
|
1813
1813
|
if (this.isCached()) {
|
|
1814
1814
|
keypair = this.cachedKeypair;
|
|
1815
|
-
if (typeof console !== "undefined") {
|
|
1816
|
-
console.log("\u{1F680} Using cached keypair - instant signing (no PIN required)");
|
|
1817
|
-
}
|
|
1818
1815
|
} else {
|
|
1819
1816
|
if (!pin) {
|
|
1820
1817
|
throw new Error("PIN required: no cached keypair available");
|
|
@@ -1827,9 +1824,6 @@ var DeviceBoundSessionKey = class _DeviceBoundSessionKey {
|
|
|
1827
1824
|
if (cacheKeypair) {
|
|
1828
1825
|
const ttl = cacheTTL || this.DEFAULT_CACHE_TTL_MS;
|
|
1829
1826
|
this.cacheKeypair(keypair, ttl);
|
|
1830
|
-
if (typeof console !== "undefined") {
|
|
1831
|
-
console.log(`\u2705 Keypair decrypted and cached for ${ttl / 1e3 / 60} minutes`);
|
|
1832
|
-
}
|
|
1833
1827
|
}
|
|
1834
1828
|
}
|
|
1835
1829
|
transaction.partialSign(keypair);
|
|
@@ -1875,9 +1869,6 @@ var DeviceBoundSessionKey = class _DeviceBoundSessionKey {
|
|
|
1875
1869
|
clearCache() {
|
|
1876
1870
|
this.cachedKeypair = null;
|
|
1877
1871
|
this.cacheExpiry = null;
|
|
1878
|
-
if (typeof console !== "undefined") {
|
|
1879
|
-
console.log("\u{1F9F9} Keypair cache cleared");
|
|
1880
|
-
}
|
|
1881
1872
|
}
|
|
1882
1873
|
/**
|
|
1883
1874
|
* Decrypt and cache keypair without signing a transaction
|
|
@@ -1904,9 +1895,6 @@ var DeviceBoundSessionKey = class _DeviceBoundSessionKey {
|
|
|
1904
1895
|
);
|
|
1905
1896
|
const ttl = cacheTTL || this.DEFAULT_CACHE_TTL_MS;
|
|
1906
1897
|
this.cacheKeypair(keypair, ttl);
|
|
1907
|
-
if (typeof console !== "undefined") {
|
|
1908
|
-
console.log(`\u{1F513} Session key unlocked and cached for ${ttl / 1e3 / 60} minutes`);
|
|
1909
|
-
}
|
|
1910
1898
|
}
|
|
1911
1899
|
/**
|
|
1912
1900
|
* Get time remaining until cache expires (in milliseconds)
|
|
@@ -1935,10 +1923,6 @@ var DeviceBoundSessionKey = class _DeviceBoundSessionKey {
|
|
|
1935
1923
|
throw new Error("Cannot extend cache: no cached keypair");
|
|
1936
1924
|
}
|
|
1937
1925
|
this.cacheExpiry += additionalTTL;
|
|
1938
|
-
if (typeof console !== "undefined") {
|
|
1939
|
-
const remainingMinutes = this.getCacheTimeRemaining() / 1e3 / 60;
|
|
1940
|
-
console.log(`\u23F0 Cache extended - ${remainingMinutes.toFixed(1)} minutes remaining`);
|
|
1941
|
-
}
|
|
1942
1926
|
}
|
|
1943
1927
|
/**
|
|
1944
1928
|
* Set session key ID after backend creation
|
|
@@ -1973,26 +1957,34 @@ async function encryptKeypairWithLit(keypair, options) {
|
|
|
1973
1957
|
console.log(`[Lit] Connected to ${network}`);
|
|
1974
1958
|
}
|
|
1975
1959
|
try {
|
|
1976
|
-
const
|
|
1960
|
+
const evmContractConditions = [
|
|
1977
1961
|
{
|
|
1978
1962
|
contractAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
1979
1963
|
// USDC on Ethereum
|
|
1980
|
-
|
|
1964
|
+
functionName: "balanceOf",
|
|
1965
|
+
functionParams: [":userAddress"],
|
|
1966
|
+
functionAbi: {
|
|
1967
|
+
constant: true,
|
|
1968
|
+
inputs: [{ name: "account", type: "address" }],
|
|
1969
|
+
name: "balanceOf",
|
|
1970
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
1971
|
+
stateMutability: "view",
|
|
1972
|
+
type: "function"
|
|
1973
|
+
},
|
|
1981
1974
|
chain: "ethereum",
|
|
1982
|
-
method: "totalSupply",
|
|
1983
|
-
parameters: [],
|
|
1984
1975
|
returnValueTest: {
|
|
1985
|
-
|
|
1976
|
+
key: "",
|
|
1977
|
+
comparator: ">=",
|
|
1986
1978
|
value: "0"
|
|
1987
1979
|
}
|
|
1988
1980
|
}
|
|
1989
1981
|
];
|
|
1990
1982
|
const dataToEncrypt = keypair.secretKey;
|
|
1991
1983
|
if (debug) {
|
|
1992
|
-
console.log("[Lit] Encrypting keypair bytes...");
|
|
1984
|
+
console.log("[Lit] Encrypting keypair bytes with evmContractConditions...");
|
|
1993
1985
|
}
|
|
1994
1986
|
const encryptResult = await litClient.encrypt({
|
|
1995
|
-
|
|
1987
|
+
evmContractConditions,
|
|
1996
1988
|
dataToEncrypt
|
|
1997
1989
|
});
|
|
1998
1990
|
if (debug) {
|