@lucasygu/redbook 0.3.1 → 0.3.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/package.json +1 -1
- package/scripts/postinstall.js +42 -0
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -92,10 +92,52 @@ function patchSweetCookieTimeout() {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Patch node:sqlite BigInt overflow on Node < 24.4.
|
|
97
|
+
*
|
|
98
|
+
* Chrome stores expires_utc as microseconds since 1601 — values like
|
|
99
|
+
* 13448382439000000 exceed Number.MAX_SAFE_INTEGER. Node < 24.4 lacks
|
|
100
|
+
* the `readBigInts` option, so node:sqlite throws instead of returning
|
|
101
|
+
* a BigInt. Casting to TEXT in the SQL avoids the overflow; the existing
|
|
102
|
+
* JS code already handles string values via tryParseInt/normalizeExpiration.
|
|
103
|
+
*/
|
|
104
|
+
function patchSweetCookieBigInt() {
|
|
105
|
+
const target = join(
|
|
106
|
+
PACKAGE_ROOT,
|
|
107
|
+
'node_modules',
|
|
108
|
+
'@steipete',
|
|
109
|
+
'sweet-cookie',
|
|
110
|
+
'dist',
|
|
111
|
+
'providers',
|
|
112
|
+
'chromeSqlite',
|
|
113
|
+
'shared.js'
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
if (!existsSync(target)) return;
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
const content = readFileSync(target, 'utf-8');
|
|
120
|
+
const needle = 'SELECT name, value, host_key, path, expires_utc, samesite, encrypted_value,';
|
|
121
|
+
if (!content.includes(needle)) {
|
|
122
|
+
// Already patched or upstream fixed
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const patched = content.replace(
|
|
126
|
+
needle,
|
|
127
|
+
'SELECT name, value, host_key, path, CAST(expires_utc AS TEXT) AS expires_utc, samesite, encrypted_value,'
|
|
128
|
+
);
|
|
129
|
+
writeFileSync(target, patched, 'utf-8');
|
|
130
|
+
console.log('[redbook] Patched sweet-cookie BigInt overflow (CAST expires_utc).');
|
|
131
|
+
} catch (err) {
|
|
132
|
+
console.log(`[redbook] Warning: could not patch sweet-cookie BigInt: ${err.message}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
95
136
|
function main() {
|
|
96
137
|
console.log('[redbook] Running post-install...');
|
|
97
138
|
const success = setupClaudeSkill();
|
|
98
139
|
patchSweetCookieTimeout();
|
|
140
|
+
patchSweetCookieBigInt();
|
|
99
141
|
console.log('');
|
|
100
142
|
console.log('[redbook] Installation complete!');
|
|
101
143
|
if (success) {
|