@volr/sdk-core 0.1.66 → 0.1.68
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.cjs +3 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1069,7 +1069,7 @@ function createPasskeyProvider(passkey, options) {
|
|
|
1069
1069
|
let sessionExpiresAt = null;
|
|
1070
1070
|
let lockTimer = null;
|
|
1071
1071
|
const isSessionExpired = () => {
|
|
1072
|
-
if (sessionTtlMs
|
|
1072
|
+
if (sessionTtlMs <= 0) return false;
|
|
1073
1073
|
if (!sessionExpiresAt) return true;
|
|
1074
1074
|
return Date.now() >= sessionExpiresAt;
|
|
1075
1075
|
};
|
|
@@ -1081,7 +1081,6 @@ function createPasskeyProvider(passkey, options) {
|
|
|
1081
1081
|
}
|
|
1082
1082
|
sessionExpiresAt = Date.now() + sessionTtlMs;
|
|
1083
1083
|
lockTimer = setTimeout(async () => {
|
|
1084
|
-
console.log("[PasskeyProvider] Session expired, auto-locking");
|
|
1085
1084
|
await lock();
|
|
1086
1085
|
}, sessionTtlMs);
|
|
1087
1086
|
};
|
|
@@ -1092,7 +1091,6 @@ function createPasskeyProvider(passkey, options) {
|
|
|
1092
1091
|
}
|
|
1093
1092
|
sessionExpiresAt = null;
|
|
1094
1093
|
if (unwrappedKeypair) {
|
|
1095
|
-
console.log("[PasskeyProvider] lock(): zeroizing sensitive data from memory");
|
|
1096
1094
|
zeroize(unwrappedKeypair.privateKey);
|
|
1097
1095
|
zeroize(unwrappedKeypair.publicKey);
|
|
1098
1096
|
unwrappedKeypair = null;
|
|
@@ -1100,7 +1098,6 @@ function createPasskeyProvider(passkey, options) {
|
|
|
1100
1098
|
};
|
|
1101
1099
|
const ensureSession = async (opts) => {
|
|
1102
1100
|
if (opts?.force && unwrappedKeypair) {
|
|
1103
|
-
console.log("[PasskeyProvider] force=true: zeroizing existing session");
|
|
1104
1101
|
await lock();
|
|
1105
1102
|
}
|
|
1106
1103
|
if (unwrappedKeypair && !isSessionExpired()) {
|
|
@@ -1108,10 +1105,8 @@ function createPasskeyProvider(passkey, options) {
|
|
|
1108
1105
|
return;
|
|
1109
1106
|
}
|
|
1110
1107
|
if (unwrappedKeypair && isSessionExpired()) {
|
|
1111
|
-
console.log("[PasskeyProvider] Session expired, re-authenticating");
|
|
1112
1108
|
await lock();
|
|
1113
1109
|
}
|
|
1114
|
-
console.log("[PasskeyProvider] Triggering WebAuthn prompt for hardware-backed authentication");
|
|
1115
1110
|
const prfSalt = deriveWrapKey(options.prfInput);
|
|
1116
1111
|
const { prfOutput } = await passkey.authenticate({
|
|
1117
1112
|
salt: prfSalt,
|
|
@@ -1147,15 +1142,11 @@ function createPasskeyProvider(passkey, options) {
|
|
|
1147
1142
|
if (hash32.length !== 32) {
|
|
1148
1143
|
throw new Error(`${ERR_INVALID_PARAM}: Message hash must be 32 bytes, got ${hash32.length}`);
|
|
1149
1144
|
}
|
|
1150
|
-
|
|
1151
|
-
await ensureSession({ force: shouldForceFresh });
|
|
1145
|
+
await ensureSession({ });
|
|
1152
1146
|
if (!unwrappedKeypair) {
|
|
1153
1147
|
throw new Error(`${ERR_INVALID_PARAM}: Session not established`);
|
|
1154
1148
|
}
|
|
1155
1149
|
const sig = evmSign(unwrappedKeypair.privateKey, hash32);
|
|
1156
|
-
if (shouldForceFresh) {
|
|
1157
|
-
await lock();
|
|
1158
|
-
}
|
|
1159
1150
|
return {
|
|
1160
1151
|
r: sig.r,
|
|
1161
1152
|
s: sig.s,
|
|
@@ -1163,27 +1154,18 @@ function createPasskeyProvider(passkey, options) {
|
|
|
1163
1154
|
};
|
|
1164
1155
|
};
|
|
1165
1156
|
const signTypedData = async (input) => {
|
|
1166
|
-
|
|
1167
|
-
await ensureSession({ force: shouldForceFresh });
|
|
1157
|
+
await ensureSession({ });
|
|
1168
1158
|
if (!unwrappedKeypair) {
|
|
1169
1159
|
throw new Error(`${ERR_INVALID_PARAM}: Session not established`);
|
|
1170
1160
|
}
|
|
1171
|
-
console.log("[PasskeyProvider] signTypedData input:", JSON.stringify(
|
|
1172
|
-
input,
|
|
1173
|
-
(_key, value) => typeof value === "bigint" ? value.toString() : value
|
|
1174
|
-
));
|
|
1175
1161
|
const hash = ethers.TypedDataEncoder.hash(input.domain, input.types, input.message);
|
|
1176
1162
|
const msgHash = hash;
|
|
1177
|
-
console.log("[PasskeyProvider] msgHash:", msgHash);
|
|
1178
1163
|
const msgHashBytes = new Uint8Array(32);
|
|
1179
1164
|
const hex = msgHash.startsWith("0x") ? msgHash.slice(2) : msgHash;
|
|
1180
1165
|
for (let i = 0; i < 32; i++) {
|
|
1181
1166
|
msgHashBytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
1182
1167
|
}
|
|
1183
1168
|
const sig = evmSign(unwrappedKeypair.privateKey, msgHashBytes);
|
|
1184
|
-
if (shouldForceFresh) {
|
|
1185
|
-
await lock();
|
|
1186
|
-
}
|
|
1187
1169
|
const v = sig.yParity + 27;
|
|
1188
1170
|
const rHex = Array.from(sig.r).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1189
1171
|
const sHex = Array.from(sig.s).map((b) => b.toString(16).padStart(2, "0")).join("");
|