@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.js
CHANGED
|
@@ -1063,7 +1063,7 @@ function createPasskeyProvider(passkey, options) {
|
|
|
1063
1063
|
let sessionExpiresAt = null;
|
|
1064
1064
|
let lockTimer = null;
|
|
1065
1065
|
const isSessionExpired = () => {
|
|
1066
|
-
if (sessionTtlMs
|
|
1066
|
+
if (sessionTtlMs <= 0) return false;
|
|
1067
1067
|
if (!sessionExpiresAt) return true;
|
|
1068
1068
|
return Date.now() >= sessionExpiresAt;
|
|
1069
1069
|
};
|
|
@@ -1075,7 +1075,6 @@ function createPasskeyProvider(passkey, options) {
|
|
|
1075
1075
|
}
|
|
1076
1076
|
sessionExpiresAt = Date.now() + sessionTtlMs;
|
|
1077
1077
|
lockTimer = setTimeout(async () => {
|
|
1078
|
-
console.log("[PasskeyProvider] Session expired, auto-locking");
|
|
1079
1078
|
await lock();
|
|
1080
1079
|
}, sessionTtlMs);
|
|
1081
1080
|
};
|
|
@@ -1086,7 +1085,6 @@ function createPasskeyProvider(passkey, options) {
|
|
|
1086
1085
|
}
|
|
1087
1086
|
sessionExpiresAt = null;
|
|
1088
1087
|
if (unwrappedKeypair) {
|
|
1089
|
-
console.log("[PasskeyProvider] lock(): zeroizing sensitive data from memory");
|
|
1090
1088
|
zeroize(unwrappedKeypair.privateKey);
|
|
1091
1089
|
zeroize(unwrappedKeypair.publicKey);
|
|
1092
1090
|
unwrappedKeypair = null;
|
|
@@ -1094,7 +1092,6 @@ function createPasskeyProvider(passkey, options) {
|
|
|
1094
1092
|
};
|
|
1095
1093
|
const ensureSession = async (opts) => {
|
|
1096
1094
|
if (opts?.force && unwrappedKeypair) {
|
|
1097
|
-
console.log("[PasskeyProvider] force=true: zeroizing existing session");
|
|
1098
1095
|
await lock();
|
|
1099
1096
|
}
|
|
1100
1097
|
if (unwrappedKeypair && !isSessionExpired()) {
|
|
@@ -1102,10 +1099,8 @@ function createPasskeyProvider(passkey, options) {
|
|
|
1102
1099
|
return;
|
|
1103
1100
|
}
|
|
1104
1101
|
if (unwrappedKeypair && isSessionExpired()) {
|
|
1105
|
-
console.log("[PasskeyProvider] Session expired, re-authenticating");
|
|
1106
1102
|
await lock();
|
|
1107
1103
|
}
|
|
1108
|
-
console.log("[PasskeyProvider] Triggering WebAuthn prompt for hardware-backed authentication");
|
|
1109
1104
|
const prfSalt = deriveWrapKey(options.prfInput);
|
|
1110
1105
|
const { prfOutput } = await passkey.authenticate({
|
|
1111
1106
|
salt: prfSalt,
|
|
@@ -1141,15 +1136,11 @@ function createPasskeyProvider(passkey, options) {
|
|
|
1141
1136
|
if (hash32.length !== 32) {
|
|
1142
1137
|
throw new Error(`${ERR_INVALID_PARAM}: Message hash must be 32 bytes, got ${hash32.length}`);
|
|
1143
1138
|
}
|
|
1144
|
-
|
|
1145
|
-
await ensureSession({ force: shouldForceFresh });
|
|
1139
|
+
await ensureSession({ });
|
|
1146
1140
|
if (!unwrappedKeypair) {
|
|
1147
1141
|
throw new Error(`${ERR_INVALID_PARAM}: Session not established`);
|
|
1148
1142
|
}
|
|
1149
1143
|
const sig = evmSign(unwrappedKeypair.privateKey, hash32);
|
|
1150
|
-
if (shouldForceFresh) {
|
|
1151
|
-
await lock();
|
|
1152
|
-
}
|
|
1153
1144
|
return {
|
|
1154
1145
|
r: sig.r,
|
|
1155
1146
|
s: sig.s,
|
|
@@ -1157,27 +1148,18 @@ function createPasskeyProvider(passkey, options) {
|
|
|
1157
1148
|
};
|
|
1158
1149
|
};
|
|
1159
1150
|
const signTypedData = async (input) => {
|
|
1160
|
-
|
|
1161
|
-
await ensureSession({ force: shouldForceFresh });
|
|
1151
|
+
await ensureSession({ });
|
|
1162
1152
|
if (!unwrappedKeypair) {
|
|
1163
1153
|
throw new Error(`${ERR_INVALID_PARAM}: Session not established`);
|
|
1164
1154
|
}
|
|
1165
|
-
console.log("[PasskeyProvider] signTypedData input:", JSON.stringify(
|
|
1166
|
-
input,
|
|
1167
|
-
(_key, value) => typeof value === "bigint" ? value.toString() : value
|
|
1168
|
-
));
|
|
1169
1155
|
const hash = TypedDataEncoder.hash(input.domain, input.types, input.message);
|
|
1170
1156
|
const msgHash = hash;
|
|
1171
|
-
console.log("[PasskeyProvider] msgHash:", msgHash);
|
|
1172
1157
|
const msgHashBytes = new Uint8Array(32);
|
|
1173
1158
|
const hex = msgHash.startsWith("0x") ? msgHash.slice(2) : msgHash;
|
|
1174
1159
|
for (let i = 0; i < 32; i++) {
|
|
1175
1160
|
msgHashBytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
1176
1161
|
}
|
|
1177
1162
|
const sig = evmSign(unwrappedKeypair.privateKey, msgHashBytes);
|
|
1178
|
-
if (shouldForceFresh) {
|
|
1179
|
-
await lock();
|
|
1180
|
-
}
|
|
1181
1163
|
const v = sig.yParity + 27;
|
|
1182
1164
|
const rHex = Array.from(sig.r).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1183
1165
|
const sHex = Array.from(sig.s).map((b) => b.toString(16).padStart(2, "0")).join("");
|