diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c2db27
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+/walmart_CSVs
+/.vscode
+/walmart_API_Debug_Tools/walmart_API_Taxonomy/taxonomy_categories.csv
+/walmart_API_Debug_Tools/walmart_API_Taxonomy/taxonomy.json
+RecipesDataset.csv
+.DS_Store
\ No newline at end of file
diff --git a/SWFrontUI/ShopwiseFrontEndUI/Assets.xcassets/AccentColor.colorset/Contents.json b/SWFrontUI/ShopwiseFrontEndUI/Assets.xcassets/AccentColor.colorset/Contents.json
index eb87897..0afb3cf 100644
--- a/SWFrontUI/ShopwiseFrontEndUI/Assets.xcassets/AccentColor.colorset/Contents.json
+++ b/SWFrontUI/ShopwiseFrontEndUI/Assets.xcassets/AccentColor.colorset/Contents.json
@@ -1,11 +1,11 @@
{
- "colors" : [
+ "colors": [
{
- "idiom" : "universal"
+ "idiom": "universal"
}
],
- "info" : {
- "author" : "xcode",
- "version" : 1
+ "info": {
+ "author": "xcode",
+ "version": 1
}
}
diff --git a/SWFrontUI/ShopwiseFrontEndUI/Assets.xcassets/AppIcon.appiconset/Contents.json b/SWFrontUI/ShopwiseFrontEndUI/Assets.xcassets/AppIcon.appiconset/Contents.json
index 2305880..c70a5bf 100644
--- a/SWFrontUI/ShopwiseFrontEndUI/Assets.xcassets/AppIcon.appiconset/Contents.json
+++ b/SWFrontUI/ShopwiseFrontEndUI/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -1,35 +1,35 @@
{
- "images" : [
+ "images": [
{
- "idiom" : "universal",
- "platform" : "ios",
- "size" : "1024x1024"
+ "idiom": "universal",
+ "platform": "ios",
+ "size": "1024x1024"
},
{
- "appearances" : [
+ "appearances": [
{
- "appearance" : "luminosity",
- "value" : "dark"
+ "appearance": "luminosity",
+ "value": "dark"
}
],
- "idiom" : "universal",
- "platform" : "ios",
- "size" : "1024x1024"
+ "idiom": "universal",
+ "platform": "ios",
+ "size": "1024x1024"
},
{
- "appearances" : [
+ "appearances": [
{
- "appearance" : "luminosity",
- "value" : "tinted"
+ "appearance": "luminosity",
+ "value": "tinted"
}
],
- "idiom" : "universal",
- "platform" : "ios",
- "size" : "1024x1024"
+ "idiom": "universal",
+ "platform": "ios",
+ "size": "1024x1024"
}
],
- "info" : {
- "author" : "xcode",
- "version" : 1
+ "info": {
+ "author": "xcode",
+ "version": 1
}
}
diff --git a/SWFrontUI/ShopwiseFrontEndUI/Assets.xcassets/Contents.json b/SWFrontUI/ShopwiseFrontEndUI/Assets.xcassets/Contents.json
index 73c0059..74d6a72 100644
--- a/SWFrontUI/ShopwiseFrontEndUI/Assets.xcassets/Contents.json
+++ b/SWFrontUI/ShopwiseFrontEndUI/Assets.xcassets/Contents.json
@@ -1,6 +1,6 @@
{
- "info" : {
- "author" : "xcode",
- "version" : 1
+ "info": {
+ "author": "xcode",
+ "version": 1
}
}
diff --git a/deleteEmptyCSVs.js b/deleteEmptyCSVs.js
new file mode 100644
index 0000000..fc44beb
--- /dev/null
+++ b/deleteEmptyCSVs.js
@@ -0,0 +1,64 @@
+import fs from 'fs';
+import path from 'path';
+
+const TARGET_DIR = 'walmart_CSVs';
+
+/* -------------------- helpers -------------------- */
+
+function isEmptyCSV(filePath) {
+ const stat = fs.statSync(filePath);
+
+ // Truly empty file
+ if (stat.size === 0) {
+ return true;
+ }
+
+ const content = fs.readFileSync(filePath, 'utf8').trim();
+ if (!content) {
+ return true;
+ }
+
+ // Header-only CSV (1 line)
+ const lines = content.split(/\r?\n/);
+ return lines.length <= 1;
+}
+
+/* -------------------- main -------------------- */
+
+function main() {
+ const dirPath = path.resolve(process.cwd(), TARGET_DIR);
+
+ if (!fs.existsSync(dirPath)) {
+ console.error(`Folder not found: ${dirPath}`);
+ process.exit(1);
+ }
+
+ const files = fs.readdirSync(dirPath);
+
+ let deleted = 0;
+ let checked = 0;
+
+ for (const file of files) {
+ if (!file.toLowerCase().endsWith('.csv')) {
+ continue;
+ }
+
+ const filePath = path.join(dirPath, file);
+ checked++;
+
+ try {
+ if (isEmptyCSV(filePath)) {
+ fs.unlinkSync(filePath);
+ deleted++;
+ console.log(`Deleted empty CSV: ${file}`);
+ }
+ } catch (e) {
+ console.warn(`Failed to process ${file}: ${e.message}`);
+ }
+ }
+
+ console.log(`\nChecked ${checked} CSV files`);
+ console.log(`Deleted ${deleted} empty CSV files`);
+}
+
+main();
diff --git a/fetchProducts.js b/fetchProducts.js
new file mode 100644
index 0000000..2f9bd11
--- /dev/null
+++ b/fetchProducts.js
@@ -0,0 +1,672 @@
+import crypto from 'crypto';
+import fs from 'fs';
+import path from 'path';
+
+const CATEGORIES_DIR = 'Categories';
+const OUT_DIR = 'walmart_CSVs';
+
+// Walmart endpoint
+const BASE = 'https://developer.api.walmart.com';
+const PAGINATED_PATH = '/api-proxy/service/affil/product/v2/paginated/items';
+
+// Page and Category Ping Delay
+const COUNT_PER_PAGE = 500;
+const REQUEST_DELAY_MS = 200; // between pages
+const CATEGORY_DELAY_MS = 150; // between categories
+
+// Retry Attempt Tuning
+const FETCH_ATTEMPTS = 5;
+const RETRY_BASE_DELAY_MS = 500;
+
+// Output behavior
+const EXPORT_PARENT_ROWS_TOO = false; // false = leaf-ish only
+const DEDUPE_WITHIN_EACH_CATEGORY_CSV = true; // dedupe itemId inside each category CSV
+const DEDUPE_WITHIN_SUBTREE_AGG = true; // dedupe within subtree aggregate
+const DEDUPE_MASTER = false; // dedupe in global master
+
+// Logging
+const MAX_ERROR_BODY_CHARS = 1200;
+
+/* -------------------- AUTH / HEADERS -------------------- */
+
+const keyData = {
+ consumerId: '39d025f8-e575-48cf-aa4e-22f89da4c16f',
+ keyVer: '5', // keep as STRING; must match walmart.io key version exactly
+ privateKeyPem: `-----BEGIN RSA PRIVATE KEY-----
+MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC1hpiZMh1pyN6k
+oDO95qK3L+/uY3M+sUpcnQkuNdFPBChh3jxEjn3zQLm88rdBTKQVqDD8E7g2KBHX
+wYaSiKqqXcBkMkPfEEyTE/I//BjDF5dS+sgR6uIJmfsNVIVkY7laxo0STFCO3G+V
+gkHTp8u/lJ5Aa8NSxu4BYlR0wBpze40aHYBeQw/+QuPvZzNeUf5YNC3rs5eId2f5
+N0rA2mZfY1myzE6UarW+5+WrWbkR0Bwrvs+8B/S8Jh4QFmh2EDaucisx96MXSH5S
+3BuzBxqE9Txo4TKGu0y/aDmRU1Ij5WP88VnURU3vna1UF5n/pPw6InzvcQkeGS1o
+thpyvCvtAgMBAAECggEABFOmXm5twvqOQpRa0/Gxo9YX/0iJoZPPdcPhLdF5N/lU
+bqdUGeyojxoD41rkHviDXpXH9x9YxwevQp7QcrygjsU6Xv2YuekC3j69ycjcHKqf
+UlygHdc3O2r/tHOr1G2RFhITIIbHEqSpqqY9ke7paxtaOQKojqpL/F1jdr8WduM9
+WQqbpgk+Hc6PIYVdUeALMX+IGNWbZiX6zqm85IKUdAA4/V0RCMl/j9ySBP6TsT06
+5IXK63urXl+AOJh1tHV79GP/waETEc6rQ8Ntn9p3HsUtsx6qiLSky7E2m2L3rdVd
+LOzM2vVQDKr0SMGfx4/ZA79OJbLvJnwon9l4WdxmeQKBgQDb4L7sI4FnnD7uAaV5
+NTxt6ELJIpgxalTXbGiD6BoGN7LPbRfLJmKP4pGbNkfxtLZKsrTXOE1z5bTurRzY
+dsH9pEmhBf7SdYtNrnPZCfOwpZaK/PyVdIggnaAiVYD6Q5urNcTltOA9SLdxGJyE
+Ny8GpdB/ItmRCUkru4uk8L3KFQKBgQDTWOaBQRPvrL7sl4nVrTlfaxDTYulFgqSx
+j3ag+RBhCwvFVNxb710moIEtThpDnaLNJCc6JQ+QebrsDP7Q49eOxqKbbbLOHGrt
+akkeMROg6+MaL7HMAMsjCj7hBnpSjCg94ldHuJ0d8/PB60amIES/TTOyTsssxIlD
+HcoX4JsIeQKBgDVHF/wP/mMksPrq2zWreKEJDmW+RDJ1GWm5kvmjW+r1xBYO0R0g
+h/FlbPK3DGe86g7fjoI32kyi9FyBBeRNomPbUxv5X+2PHdoM03Vbu/ippvi2pF1y
+hymgCBVJsp7xkt7BgJxIX6152TlGRWakGHj75LFpuF40ac52+zdUPiihAoGASmQU
+XpKljctkOKruXUPn2eo5te4u5cSia81vmCGS3lWhAwhnuAR86Ue9sFC5detajpKX
+LCQ3Ykc2wDeiyawpB5xrSAJI2buu93pd2j60BgSBn4oCLyhoWCEXGOXK0Jt83qt4
+xUn6I7zmo+9Iotjg2eU2uSB663sSRYmKxPTOHSECgYEAr9GDqLgORkKWwXhMAe3h
+R0tYdGzWqpOiVNi1hcNMGfNwQekfIAM9NVarIib5JYPkSQQQWJZVXcTlR2YZbf9/
+P5VgNbNkV23Nq7j926cpbSlgb+UsZOCC5zTaJ0L6oePnK5R38v54y2XC9ccqW6FP
+sVP5T4Vx30thw2cpbOY227Q=
+-----END RSA PRIVATE KEY-----`,
+};
+
+function canonicalizeForSignature({ consumerId, ts, keyVer }) {
+ const map = {
+ 'WM_CONSUMER.ID': String(consumerId).trim(),
+ 'WM_CONSUMER.INTIMESTAMP': String(ts).trim(),
+ 'WM_SEC.KEY_VERSION': String(keyVer).trim(),
+ };
+
+ const sortedKeys = Object.keys(map).sort();
+ return sortedKeys.map((k) => map[k]).join('\n') + '\n';
+}
+
+function buildAuthHeaders() {
+ const id = String(keyData.consumerId).trim();
+ const kv = String(keyData.keyVer).trim();
+ const ts = String(Date.now()).trim();
+
+ const toSign = canonicalizeForSignature({
+ consumerId: id,
+ ts,
+ keyVer: kv,
+ });
+
+ const signature = crypto
+ .sign('RSA-SHA256', Buffer.from(toSign, 'utf8'), {
+ key: keyData.privateKeyPem,
+ padding: crypto.constants.RSA_PKCS1_PADDING,
+ })
+ .toString('base64');
+
+ return {
+ 'WM_CONSUMER.ID': id,
+ 'WM_CONSUMER.INTIMESTAMP': ts,
+ 'WM_SEC.TIMESTAMP': ts,
+ 'WM_SEC.KEY_VERSION': kv,
+ 'WM_SEC.AUTH_SIGNATURE': signature,
+ Accept: 'application/json',
+ };
+}
+
+/* -------------------- helpers -------------------- */
+
+function sleep(ms) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+}
+
+function escapeCSV(value) {
+ const s = String(value ?? '');
+ return `"${s.replaceAll('"', '""')}"`;
+}
+
+function sanitizeFilename(value) {
+ return (
+ String(value ?? 'export')
+ .trim()
+ .replaceAll(/[^\w\-]+/g, '_')
+ .replaceAll(/_+/g, '_')
+ .replaceAll(/^_+|_+$/g, '')
+ .slice(0, 160) || 'export'
+ );
+}
+
+function formatISO(d) {
+ return d.toISOString();
+}
+
+function msToHMS(ms) {
+ const totalSeconds = Math.floor(ms / 1000);
+ const hours = Math.floor(totalSeconds / 3600);
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
+ const seconds = totalSeconds % 60;
+ return `${hours}h ${minutes}m ${seconds}s (${ms} ms)`;
+}
+
+function safeTruncate(s, n) {
+ const str = String(s ?? '');
+ if (str.length <= n) return str;
+ return str.slice(0, n) + `... [truncated ${str.length - n} chars]`;
+}
+
+/* -------------------- CSV parsing -------------------- */
+
+function parseCSV(text) {
+ const rows = [];
+ let i = 0;
+ let field = '';
+ let row = [];
+ let inQuotes = false;
+
+ while (i < text.length) {
+ const c = text[i];
+
+ if (inQuotes) {
+ if (c === '"') {
+ if (text[i + 1] === '"') {
+ field += '"';
+ i += 2;
+ continue;
+ }
+ inQuotes = false;
+ i++;
+ continue;
+ }
+ field += c;
+ i++;
+ continue;
+ }
+
+ if (c === '"') {
+ inQuotes = true;
+ i++;
+ continue;
+ }
+
+ if (c === ',') {
+ row.push(field);
+ field = '';
+ i++;
+ continue;
+ }
+
+ if (c === '\n') {
+ row.push(field);
+ field = '';
+ rows.push(row);
+ row = [];
+ i++;
+ continue;
+ }
+
+ if (c === '\r') {
+ i++;
+ continue;
+ }
+
+ field += c;
+ i++;
+ }
+
+ if (field.length > 0 || row.length > 0) {
+ row.push(field);
+ rows.push(row);
+ }
+
+ return rows;
+}
+
+function rowsToObjects(rows) {
+ if (!rows.length) return [];
+
+ const header = rows[0].map((h) => h.trim());
+ const output = [];
+
+ for (let r = 1; r < rows.length; r++) {
+ const obj = {};
+ for (let c = 0; c < header.length; c++) {
+ obj[header[c]] = rows[r][c] ?? '';
+ }
+ output.push(obj);
+ }
+
+ return output;
+}
+
+/* -------------------- subtree helpers -------------------- */
+
+function getDepth(pathValue) {
+ const s = String(pathValue ?? '').trim();
+ if (!s) return Number.POSITIVE_INFINITY;
+ return s.split('/').length;
+}
+
+function pickSubtreeRoot(objs) {
+ const candidates = objs.filter(
+ (o) => String(o.id ?? '').trim() && String(o.name ?? '').trim(),
+ );
+
+ if (!candidates.length) return null;
+
+ candidates.sort((a, b) => {
+ const da = getDepth(a.path);
+ const db = getDepth(b.path);
+ if (da !== db) return da - db;
+ return String(a.path ?? '').length - String(b.path ?? '').length;
+ });
+
+ return candidates[0];
+}
+
+function isParentRow(allRows, row) {
+ const p = String(row.path ?? '').trim();
+ if (!p) return false;
+
+ const prefix = p.endsWith('/') ? p : p + '/';
+ return allRows.some((o) => String(o.path ?? '').startsWith(prefix));
+}
+
+/* -------------------- row conversion -------------------- */
+
+function itemToRow(item, extra) {
+ return {
+ subtree_id: extra.subtree_id,
+ subtree_name: extra.subtree_name,
+
+ category_id: extra.category_id,
+ category_name: extra.category_name,
+ category_path: extra.category_path,
+
+ item_id: item?.itemId ?? '',
+ name: item?.name ?? '',
+ msrp: item?.msrp ?? '',
+ retail_price: item?.salePrice ?? '',
+ upc: item?.upc ?? '',
+ shortDescription: item?.shortDescription ?? '',
+ longDescription: item?.longDescription ?? '',
+ brandName: item?.brandName ?? '',
+ thumbnailImage: item?.thumbnailImage ?? '',
+ mediumImage: item?.mediumImage ?? '',
+ largeImage: item?.largeImage ?? '',
+ color: item?.color ?? '',
+ customerRating: item?.customerRating ?? '',
+ stock: item?.stock ?? '',
+ productTrackingUrl: item?.productTrackingUrl ?? '',
+ categoryNode: item?.categoryNode ?? '',
+ };
+}
+
+function csvHeader(columns) {
+ return columns.join(',') + '\n';
+}
+
+function rowToCSVLine(row, columns) {
+ return columns.map((k) => escapeCSV(row[k])).join(',') + '\n';
+}
+
+/* -------------------- Walmart fetching -------------------- */
+
+async function fetchPage(url, attempts = FETCH_ATTEMPTS) {
+ for (let i = 0; i < attempts; i++) {
+ const headers = buildAuthHeaders();
+ const res = await fetch(url, { headers });
+
+ if (res.ok) {
+ return await res.json();
+ }
+
+ const status = res.status;
+ const statusText = res.statusText;
+ const body = await res.text().catch(() => '');
+
+ if (status === 429 || (status >= 500 && status <= 599)) {
+ const backoff = RETRY_BASE_DELAY_MS * Math.pow(2, i);
+ await sleep(backoff);
+ continue;
+ }
+
+ const err = new Error(`HTTP ${status} ${statusText}`);
+ err.httpStatus = status;
+ err.httpStatusText = statusText;
+ err.url = url;
+ err.responseBody = safeTruncate(body, MAX_ERROR_BODY_CHARS);
+ throw err;
+ }
+
+ const err = new Error(`Failed after ${attempts} attempts`);
+ err.url = url;
+ throw err;
+}
+
+async function fetchAllItemsForCategory(categoryId) {
+ let url = new URL(BASE + PAGINATED_PATH);
+ url.searchParams.set('category', categoryId);
+ url.searchParams.set('count', String(COUNT_PER_PAGE));
+
+ const allItems = [];
+
+ while (true) {
+ const data = await fetchPage(url.toString());
+ const items = Array.isArray(data?.items) ? data.items : [];
+
+ allItems.push(...items);
+
+ if (!data?.nextPageExist || !data?.nextPage) {
+ break;
+ }
+
+ url = new URL(
+ data.nextPage.startsWith('http') ? data.nextPage : BASE + data.nextPage,
+ );
+
+ await sleep(REQUEST_DELAY_MS);
+ }
+
+ return allItems;
+}
+
+/* -------------------- Logging / finalization -------------------- */
+
+const runState = {
+ startedAt: new Date(),
+ endedAt: null,
+ exitReason: 'completed',
+ subtreeFilesProcessed: 0,
+ categoryRowsAttempted: 0,
+ categoryRowsSucceeded: 0,
+ categoryRowsFailed: 0,
+ failures: [],
+};
+
+let finalized = false;
+let masterStreamRef = null;
+
+function writeRunLogFile(outPath) {
+ const endedAt = runState.endedAt ?? new Date();
+ const elapsedMs = endedAt.getTime() - runState.startedAt.getTime();
+
+ const logFolder = path.resolve(outPath);
+ if (!fs.existsSync(logFolder)) {
+ fs.mkdirSync(logFolder, { recursive: true });
+ }
+
+ const logName = `run_log_${sanitizeFilename(formatISO(runState.startedAt))}.json`;
+ const logPath = path.join(logFolder, logName);
+
+ const payload = {
+ startedAt: formatISO(runState.startedAt),
+ endedAt: formatISO(endedAt),
+ elapsed: msToHMS(elapsedMs),
+ exitReason: runState.exitReason,
+ counts: {
+ subtreeFilesProcessed: runState.subtreeFilesProcessed,
+ categoryRowsAttempted: runState.categoryRowsAttempted,
+ categoryRowsSucceeded: runState.categoryRowsSucceeded,
+ categoryRowsFailed: runState.categoryRowsFailed,
+ },
+ failures: runState.failures,
+ };
+
+ fs.writeFileSync(logPath, JSON.stringify(payload, null, 4), 'utf8');
+ console.log(`Log written: ${OUT_DIR}/${path.basename(logPath)}`);
+}
+
+function finalizeAndExit(outPath, reason, code = 0) {
+ if (finalized) {
+ process.exit(code);
+ return;
+ }
+
+ finalized = true;
+ runState.exitReason = reason ?? runState.exitReason;
+ runState.endedAt = new Date();
+
+ try {
+ if (masterStreamRef && !masterStreamRef.closed) {
+ masterStreamRef.end();
+ }
+ } catch (_) {}
+
+ try {
+ writeRunLogFile(outPath);
+ } catch (e) {
+ console.error('Failed to write log file:', e);
+ }
+
+ process.exit(code);
+}
+
+function registerExitHandlers(outPath) {
+ process.on('SIGINT', () => finalizeAndExit(outPath, 'SIGINT (Ctrl+C)', 130));
+ process.on('SIGTERM', () => finalizeAndExit(outPath, 'SIGTERM', 143));
+
+ process.on('uncaughtException', (err) => {
+ runState.failures.push({
+ type: 'uncaughtException',
+ message: String(err?.message ?? err),
+ stack: String(err?.stack ?? ''),
+ when: formatISO(new Date()),
+ });
+ finalizeAndExit(outPath, 'uncaughtException', 1);
+ });
+
+ process.on('unhandledRejection', (reason) => {
+ runState.failures.push({
+ type: 'unhandledRejection',
+ message: String(reason?.message ?? reason),
+ stack: String(reason?.stack ?? ''),
+ when: formatISO(new Date()),
+ });
+ finalizeAndExit(outPath, 'unhandledRejection', 1);
+ });
+}
+
+/* -------------------- main -------------------- */
+
+async function main() {
+ const categoriesPath = path.resolve(process.cwd(), CATEGORIES_DIR);
+ const outPath = path.resolve(process.cwd(), OUT_DIR);
+
+ registerExitHandlers(outPath);
+
+ if (!fs.existsSync(categoriesPath)) {
+ throw new Error(`Missing folder: ${categoriesPath}`);
+ }
+
+ if (!fs.existsSync(outPath)) {
+ fs.mkdirSync(outPath, { recursive: true });
+ }
+
+ const subtreeFiles = fs
+ .readdirSync(categoriesPath)
+ .filter((f) => f.toLowerCase().endsWith('.csv'));
+
+ if (!subtreeFiles.length) {
+ throw new Error(`No .csv files found in ${categoriesPath}`);
+ }
+
+ const columns = [
+ 'subtree_id',
+ 'subtree_name',
+ 'category_id',
+ 'category_name',
+ 'category_path',
+ 'item_id',
+ 'name',
+ 'msrp',
+ 'retail_price',
+ 'upc',
+ 'shortDescription',
+ 'longDescription',
+ 'brandName',
+ 'thumbnailImage',
+ 'mediumImage',
+ 'largeImage',
+ 'color',
+ 'customerRating',
+ 'stock',
+ 'productTrackingUrl',
+ 'categoryNode',
+ ];
+
+ const masterFile = path.join(outPath, 'ALL_SUBTREES_PRODUCTS.csv');
+ const masterStream = fs.createWriteStream(masterFile, { encoding: 'utf8' });
+ masterStreamRef = masterStream;
+ masterStream.write(csvHeader(columns));
+
+ const seenMaster = DEDUPE_MASTER ? new Set() : null;
+ let masterCount = 0;
+
+ for (const file of subtreeFiles) {
+ const subtreeCsvPath = path.join(categoriesPath, file);
+ const text = fs.readFileSync(subtreeCsvPath, 'utf8');
+
+ const parsed = parseCSV(text);
+ const objsRaw = rowsToObjects(parsed);
+
+ if (!objsRaw.length) {
+ continue;
+ }
+
+ const root = pickSubtreeRoot(objsRaw);
+ const subtree_name = root?.name ?? path.basename(file, '.csv');
+ const subtree_id = root?.id ?? '';
+
+ const subtreeLabel = sanitizeFilename(
+ `${subtree_name}_${subtree_id || 'unknown'}`,
+ );
+
+ // Subtree aggregate CSV
+ const subtreeAggFile = path.join(outPath, `${subtreeLabel}__ALL.csv`);
+ const subtreeAggStream = fs.createWriteStream(subtreeAggFile, {
+ encoding: 'utf8',
+ });
+ subtreeAggStream.write(csvHeader(columns));
+
+ const seenSubtreeAgg = DEDUPE_WITHIN_SUBTREE_AGG ? new Set() : null;
+ let subtreeAggCount = 0;
+
+ const rows = objsRaw
+ .map((o) => ({
+ id: String(o.id ?? '').trim(),
+ name: String(o.name ?? '').trim(),
+ path: String(o.path ?? '').trim(),
+ }))
+ .filter((o) => o.id && o.name);
+
+ for (const row of rows) {
+ const parent = isParentRow(rows, row);
+
+ if (!EXPORT_PARENT_ROWS_TOO && parent) {
+ continue;
+ }
+
+ runState.categoryRowsAttempted++;
+
+ await sleep(CATEGORY_DELAY_MS);
+
+ let items;
+ try {
+ items = await fetchAllItemsForCategory(row.id);
+ runState.categoryRowsSucceeded++;
+ } catch (e) {
+ runState.categoryRowsFailed++;
+
+ runState.failures.push({
+ type: 'categoryFetchFailed',
+ subtreeFile: file,
+ subtreeName: subtree_name,
+ subtreeId: subtree_id,
+ categoryId: row.id,
+ categoryName: row.name,
+ categoryPath: row.path,
+ message: String(e?.message ?? e),
+ httpStatus: e?.httpStatus ?? null,
+ url: e?.url ?? null,
+ responseBody: e?.responseBody ?? null,
+ stack: String(e?.stack ?? ''),
+ when: formatISO(new Date()),
+ });
+
+ console.error(`Failed category ${row.id} (${row.name}): ${e.message}`);
+ continue;
+ }
+
+ const categoryLabel = sanitizeFilename(
+ `${subtree_name}_${subtree_id}__${row.name}_${row.id}`,
+ );
+ const categoryFile = path.join(outPath, `${categoryLabel}.csv`);
+ const categoryStream = fs.createWriteStream(categoryFile, {
+ encoding: 'utf8',
+ });
+ categoryStream.write(csvHeader(columns));
+
+ const seenCategory = DEDUPE_WITHIN_EACH_CATEGORY_CSV ? new Set() : null;
+ let categoryCount = 0;
+
+ for (const item of items) {
+ const itemId = String(item?.itemId ?? '');
+ if (!itemId) continue;
+
+ if (seenCategory) {
+ if (seenCategory.has(itemId)) continue;
+ seenCategory.add(itemId);
+ }
+
+ const outRow = itemToRow(item, {
+ subtree_id,
+ subtree_name,
+ category_id: row.id,
+ category_name: row.name,
+ category_path: row.path,
+ });
+
+ // Per-category CSV
+ categoryStream.write(rowToCSVLine(outRow, columns));
+ categoryCount++;
+
+ // Subtree aggregate (dedup optional)
+ if (seenSubtreeAgg) {
+ if (!seenSubtreeAgg.has(itemId)) {
+ seenSubtreeAgg.add(itemId);
+ subtreeAggStream.write(rowToCSVLine(outRow, columns));
+ subtreeAggCount++;
+ }
+ } else {
+ subtreeAggStream.write(rowToCSVLine(outRow, columns));
+ subtreeAggCount++;
+ }
+
+ // Master (dedup optional)
+ if (seenMaster) {
+ if (!seenMaster.has(itemId)) {
+ seenMaster.add(itemId);
+ masterStream.write(rowToCSVLine(outRow, columns));
+ masterCount++;
+ }
+ } else {
+ masterStream.write(rowToCSVLine(outRow, columns));
+ masterCount++;
+ }
+ }
+
+ await new Promise((resolve) => categoryStream.end(resolve));
+
+ console.log(
+ `Wrote category CSV: ${path.basename(categoryFile)} (${categoryCount} rows)`,
+ );
+ }
+
+ await new Promise((resolve) => subtreeAggStream.end(resolve));
+
+ runState.subtreeFilesProcessed++;
+
+ console.log(
+ `Wrote subtree aggregate CSV: ${path.basename(subtreeAggFile)} (${subtreeAggCount} rows)`,
+ );
+ }
+
+ await new Promise((resolve) => masterStream.end(resolve));
+ console.log(
+ `Wrote master CSV: ${path.basename(masterFile)} (${masterCount} rows)`,
+ );
+
+ finalizeAndExit(outPath, 'completed', 0);
+}
+
+main().catch((err) => {
+ console.error(err);
+ finalizeAndExit(path.resolve(process.cwd(), OUT_DIR), 'main() catch', 1);
+});
diff --git a/node_modules/.DS_Store b/node_modules/.DS_Store
deleted file mode 100644
index f8cb8af..0000000
Binary files a/node_modules/.DS_Store and /dev/null differ
diff --git a/node_modules/.bin/acorn b/node_modules/.bin/acorn
deleted file mode 100644
index 679bd16..0000000
--- a/node_modules/.bin/acorn
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
-
-case `uname` in
- *CYGWIN*|*MINGW*|*MSYS*)
- if command -v cygpath > /dev/null 2>&1; then
- basedir=`cygpath -w "$basedir"`
- fi
- ;;
-esac
-
-if [ -x "$basedir/node" ]; then
- exec "$basedir/node" "$basedir/../acorn/bin/acorn" "$@"
-else
- exec node "$basedir/../acorn/bin/acorn" "$@"
-fi
diff --git a/node_modules/.bin/acorn b/node_modules/.bin/acorn
new file mode 120000
index 0000000..cf76760
--- /dev/null
+++ b/node_modules/.bin/acorn
@@ -0,0 +1 @@
+../acorn/bin/acorn
\ No newline at end of file
diff --git a/node_modules/.bin/acorn.cmd b/node_modules/.bin/acorn.cmd
deleted file mode 100644
index a9324df..0000000
--- a/node_modules/.bin/acorn.cmd
+++ /dev/null
@@ -1,17 +0,0 @@
-@ECHO off
-GOTO start
-:find_dp0
-SET dp0=%~dp0
-EXIT /b
-:start
-SETLOCAL
-CALL :find_dp0
-
-IF EXIST "%dp0%\node.exe" (
- SET "_prog=%dp0%\node.exe"
-) ELSE (
- SET "_prog=node"
- SET PATHEXT=%PATHEXT:;.JS;=;%
-)
-
-endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\acorn\bin\acorn" %*
diff --git a/node_modules/.bin/acorn.ps1 b/node_modules/.bin/acorn.ps1
deleted file mode 100644
index 6f6dcdd..0000000
--- a/node_modules/.bin/acorn.ps1
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env pwsh
-$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
-
-$exe=""
-if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
- # Fix case when both the Windows and Linux builds of Node
- # are installed in the same directory
- $exe=".exe"
-}
-$ret=0
-if (Test-Path "$basedir/node$exe") {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "$basedir/node$exe" "$basedir/../acorn/bin/acorn" $args
- } else {
- & "$basedir/node$exe" "$basedir/../acorn/bin/acorn" $args
- }
- $ret=$LASTEXITCODE
-} else {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "node$exe" "$basedir/../acorn/bin/acorn" $args
- } else {
- & "node$exe" "$basedir/../acorn/bin/acorn" $args
- }
- $ret=$LASTEXITCODE
-}
-exit $ret
diff --git a/node_modules/.bin/eslint b/node_modules/.bin/eslint
deleted file mode 100644
index d450ee1..0000000
--- a/node_modules/.bin/eslint
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
-
-case `uname` in
- *CYGWIN*|*MINGW*|*MSYS*)
- if command -v cygpath > /dev/null 2>&1; then
- basedir=`cygpath -w "$basedir"`
- fi
- ;;
-esac
-
-if [ -x "$basedir/node" ]; then
- exec "$basedir/node" "$basedir/../eslint/bin/eslint.js" "$@"
-else
- exec node "$basedir/../eslint/bin/eslint.js" "$@"
-fi
diff --git a/node_modules/.bin/eslint b/node_modules/.bin/eslint
new file mode 120000
index 0000000..810e4bc
--- /dev/null
+++ b/node_modules/.bin/eslint
@@ -0,0 +1 @@
+../eslint/bin/eslint.js
\ No newline at end of file
diff --git a/node_modules/.bin/eslint-config-prettier b/node_modules/.bin/eslint-config-prettier
deleted file mode 100644
index 478b3ef..0000000
--- a/node_modules/.bin/eslint-config-prettier
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
-
-case `uname` in
- *CYGWIN*|*MINGW*|*MSYS*)
- if command -v cygpath > /dev/null 2>&1; then
- basedir=`cygpath -w "$basedir"`
- fi
- ;;
-esac
-
-if [ -x "$basedir/node" ]; then
- exec "$basedir/node" "$basedir/../eslint-config-prettier/bin/cli.js" "$@"
-else
- exec node "$basedir/../eslint-config-prettier/bin/cli.js" "$@"
-fi
diff --git a/node_modules/.bin/eslint-config-prettier b/node_modules/.bin/eslint-config-prettier
new file mode 120000
index 0000000..7d29baa
--- /dev/null
+++ b/node_modules/.bin/eslint-config-prettier
@@ -0,0 +1 @@
+../eslint-config-prettier/bin/cli.js
\ No newline at end of file
diff --git a/node_modules/.bin/eslint-config-prettier.cmd b/node_modules/.bin/eslint-config-prettier.cmd
deleted file mode 100644
index 13a820d..0000000
--- a/node_modules/.bin/eslint-config-prettier.cmd
+++ /dev/null
@@ -1,17 +0,0 @@
-@ECHO off
-GOTO start
-:find_dp0
-SET dp0=%~dp0
-EXIT /b
-:start
-SETLOCAL
-CALL :find_dp0
-
-IF EXIST "%dp0%\node.exe" (
- SET "_prog=%dp0%\node.exe"
-) ELSE (
- SET "_prog=node"
- SET PATHEXT=%PATHEXT:;.JS;=;%
-)
-
-endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\eslint-config-prettier\bin\cli.js" %*
diff --git a/node_modules/.bin/eslint-config-prettier.ps1 b/node_modules/.bin/eslint-config-prettier.ps1
deleted file mode 100644
index 342c61f..0000000
--- a/node_modules/.bin/eslint-config-prettier.ps1
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env pwsh
-$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
-
-$exe=""
-if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
- # Fix case when both the Windows and Linux builds of Node
- # are installed in the same directory
- $exe=".exe"
-}
-$ret=0
-if (Test-Path "$basedir/node$exe") {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "$basedir/node$exe" "$basedir/../eslint-config-prettier/bin/cli.js" $args
- } else {
- & "$basedir/node$exe" "$basedir/../eslint-config-prettier/bin/cli.js" $args
- }
- $ret=$LASTEXITCODE
-} else {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "node$exe" "$basedir/../eslint-config-prettier/bin/cli.js" $args
- } else {
- & "node$exe" "$basedir/../eslint-config-prettier/bin/cli.js" $args
- }
- $ret=$LASTEXITCODE
-}
-exit $ret
diff --git a/node_modules/.bin/eslint.cmd b/node_modules/.bin/eslint.cmd
deleted file mode 100644
index 032901a..0000000
--- a/node_modules/.bin/eslint.cmd
+++ /dev/null
@@ -1,17 +0,0 @@
-@ECHO off
-GOTO start
-:find_dp0
-SET dp0=%~dp0
-EXIT /b
-:start
-SETLOCAL
-CALL :find_dp0
-
-IF EXIST "%dp0%\node.exe" (
- SET "_prog=%dp0%\node.exe"
-) ELSE (
- SET "_prog=node"
- SET PATHEXT=%PATHEXT:;.JS;=;%
-)
-
-endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\eslint\bin\eslint.js" %*
diff --git a/node_modules/.bin/eslint.ps1 b/node_modules/.bin/eslint.ps1
deleted file mode 100644
index 155bec4..0000000
--- a/node_modules/.bin/eslint.ps1
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env pwsh
-$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
-
-$exe=""
-if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
- # Fix case when both the Windows and Linux builds of Node
- # are installed in the same directory
- $exe=".exe"
-}
-$ret=0
-if (Test-Path "$basedir/node$exe") {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "$basedir/node$exe" "$basedir/../eslint/bin/eslint.js" $args
- } else {
- & "$basedir/node$exe" "$basedir/../eslint/bin/eslint.js" $args
- }
- $ret=$LASTEXITCODE
-} else {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "node$exe" "$basedir/../eslint/bin/eslint.js" $args
- } else {
- & "node$exe" "$basedir/../eslint/bin/eslint.js" $args
- }
- $ret=$LASTEXITCODE
-}
-exit $ret
diff --git a/node_modules/.bin/husky b/node_modules/.bin/husky
deleted file mode 100644
index d1e0e88..0000000
--- a/node_modules/.bin/husky
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
-
-case `uname` in
- *CYGWIN*|*MINGW*|*MSYS*)
- if command -v cygpath > /dev/null 2>&1; then
- basedir=`cygpath -w "$basedir"`
- fi
- ;;
-esac
-
-if [ -x "$basedir/node" ]; then
- exec "$basedir/node" "$basedir/../husky/bin.js" "$@"
-else
- exec node "$basedir/../husky/bin.js" "$@"
-fi
diff --git a/node_modules/.bin/husky b/node_modules/.bin/husky
new file mode 120000
index 0000000..d5c33f5
--- /dev/null
+++ b/node_modules/.bin/husky
@@ -0,0 +1 @@
+../husky/bin.js
\ No newline at end of file
diff --git a/node_modules/.bin/husky.cmd b/node_modules/.bin/husky.cmd
deleted file mode 100644
index a104740..0000000
--- a/node_modules/.bin/husky.cmd
+++ /dev/null
@@ -1,17 +0,0 @@
-@ECHO off
-GOTO start
-:find_dp0
-SET dp0=%~dp0
-EXIT /b
-:start
-SETLOCAL
-CALL :find_dp0
-
-IF EXIST "%dp0%\node.exe" (
- SET "_prog=%dp0%\node.exe"
-) ELSE (
- SET "_prog=node"
- SET PATHEXT=%PATHEXT:;.JS;=;%
-)
-
-endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\husky\bin.js" %*
diff --git a/node_modules/.bin/husky.ps1 b/node_modules/.bin/husky.ps1
deleted file mode 100644
index 2203952..0000000
--- a/node_modules/.bin/husky.ps1
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env pwsh
-$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
-
-$exe=""
-if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
- # Fix case when both the Windows and Linux builds of Node
- # are installed in the same directory
- $exe=".exe"
-}
-$ret=0
-if (Test-Path "$basedir/node$exe") {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "$basedir/node$exe" "$basedir/../husky/bin.js" $args
- } else {
- & "$basedir/node$exe" "$basedir/../husky/bin.js" $args
- }
- $ret=$LASTEXITCODE
-} else {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "node$exe" "$basedir/../husky/bin.js" $args
- } else {
- & "node$exe" "$basedir/../husky/bin.js" $args
- }
- $ret=$LASTEXITCODE
-}
-exit $ret
diff --git a/node_modules/.bin/js-yaml b/node_modules/.bin/js-yaml
deleted file mode 100644
index 82416ef..0000000
--- a/node_modules/.bin/js-yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
-
-case `uname` in
- *CYGWIN*|*MINGW*|*MSYS*)
- if command -v cygpath > /dev/null 2>&1; then
- basedir=`cygpath -w "$basedir"`
- fi
- ;;
-esac
-
-if [ -x "$basedir/node" ]; then
- exec "$basedir/node" "$basedir/../js-yaml/bin/js-yaml.js" "$@"
-else
- exec node "$basedir/../js-yaml/bin/js-yaml.js" "$@"
-fi
diff --git a/node_modules/.bin/js-yaml b/node_modules/.bin/js-yaml
new file mode 120000
index 0000000..9dbd010
--- /dev/null
+++ b/node_modules/.bin/js-yaml
@@ -0,0 +1 @@
+../js-yaml/bin/js-yaml.js
\ No newline at end of file
diff --git a/node_modules/.bin/js-yaml.cmd b/node_modules/.bin/js-yaml.cmd
deleted file mode 100644
index 453312b..0000000
--- a/node_modules/.bin/js-yaml.cmd
+++ /dev/null
@@ -1,17 +0,0 @@
-@ECHO off
-GOTO start
-:find_dp0
-SET dp0=%~dp0
-EXIT /b
-:start
-SETLOCAL
-CALL :find_dp0
-
-IF EXIST "%dp0%\node.exe" (
- SET "_prog=%dp0%\node.exe"
-) ELSE (
- SET "_prog=node"
- SET PATHEXT=%PATHEXT:;.JS;=;%
-)
-
-endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\js-yaml\bin\js-yaml.js" %*
diff --git a/node_modules/.bin/js-yaml.ps1 b/node_modules/.bin/js-yaml.ps1
deleted file mode 100644
index 2acfc61..0000000
--- a/node_modules/.bin/js-yaml.ps1
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env pwsh
-$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
-
-$exe=""
-if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
- # Fix case when both the Windows and Linux builds of Node
- # are installed in the same directory
- $exe=".exe"
-}
-$ret=0
-if (Test-Path "$basedir/node$exe") {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "$basedir/node$exe" "$basedir/../js-yaml/bin/js-yaml.js" $args
- } else {
- & "$basedir/node$exe" "$basedir/../js-yaml/bin/js-yaml.js" $args
- }
- $ret=$LASTEXITCODE
-} else {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "node$exe" "$basedir/../js-yaml/bin/js-yaml.js" $args
- } else {
- & "node$exe" "$basedir/../js-yaml/bin/js-yaml.js" $args
- }
- $ret=$LASTEXITCODE
-}
-exit $ret
diff --git a/node_modules/.bin/node-which b/node_modules/.bin/node-which
deleted file mode 100644
index b49b03f..0000000
--- a/node_modules/.bin/node-which
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
-
-case `uname` in
- *CYGWIN*|*MINGW*|*MSYS*)
- if command -v cygpath > /dev/null 2>&1; then
- basedir=`cygpath -w "$basedir"`
- fi
- ;;
-esac
-
-if [ -x "$basedir/node" ]; then
- exec "$basedir/node" "$basedir/../which/bin/node-which" "$@"
-else
- exec node "$basedir/../which/bin/node-which" "$@"
-fi
diff --git a/node_modules/.bin/node-which b/node_modules/.bin/node-which
new file mode 120000
index 0000000..6f8415e
--- /dev/null
+++ b/node_modules/.bin/node-which
@@ -0,0 +1 @@
+../which/bin/node-which
\ No newline at end of file
diff --git a/node_modules/.bin/node-which.cmd b/node_modules/.bin/node-which.cmd
deleted file mode 100644
index 8738aed..0000000
--- a/node_modules/.bin/node-which.cmd
+++ /dev/null
@@ -1,17 +0,0 @@
-@ECHO off
-GOTO start
-:find_dp0
-SET dp0=%~dp0
-EXIT /b
-:start
-SETLOCAL
-CALL :find_dp0
-
-IF EXIST "%dp0%\node.exe" (
- SET "_prog=%dp0%\node.exe"
-) ELSE (
- SET "_prog=node"
- SET PATHEXT=%PATHEXT:;.JS;=;%
-)
-
-endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\which\bin\node-which" %*
diff --git a/node_modules/.bin/node-which.ps1 b/node_modules/.bin/node-which.ps1
deleted file mode 100644
index cfb09e8..0000000
--- a/node_modules/.bin/node-which.ps1
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env pwsh
-$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
-
-$exe=""
-if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
- # Fix case when both the Windows and Linux builds of Node
- # are installed in the same directory
- $exe=".exe"
-}
-$ret=0
-if (Test-Path "$basedir/node$exe") {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "$basedir/node$exe" "$basedir/../which/bin/node-which" $args
- } else {
- & "$basedir/node$exe" "$basedir/../which/bin/node-which" $args
- }
- $ret=$LASTEXITCODE
-} else {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "node$exe" "$basedir/../which/bin/node-which" $args
- } else {
- & "node$exe" "$basedir/../which/bin/node-which" $args
- }
- $ret=$LASTEXITCODE
-}
-exit $ret
diff --git a/node_modules/.bin/prettier b/node_modules/.bin/prettier
deleted file mode 100644
index 5944261..0000000
--- a/node_modules/.bin/prettier
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
-
-case `uname` in
- *CYGWIN*|*MINGW*|*MSYS*)
- if command -v cygpath > /dev/null 2>&1; then
- basedir=`cygpath -w "$basedir"`
- fi
- ;;
-esac
-
-if [ -x "$basedir/node" ]; then
- exec "$basedir/node" "$basedir/../prettier/bin/prettier.cjs" "$@"
-else
- exec node "$basedir/../prettier/bin/prettier.cjs" "$@"
-fi
diff --git a/node_modules/.bin/prettier b/node_modules/.bin/prettier
new file mode 120000
index 0000000..92267ed
--- /dev/null
+++ b/node_modules/.bin/prettier
@@ -0,0 +1 @@
+../prettier/bin/prettier.cjs
\ No newline at end of file
diff --git a/node_modules/.bin/prettier.cmd b/node_modules/.bin/prettier.cmd
deleted file mode 100644
index e0fa0f7..0000000
--- a/node_modules/.bin/prettier.cmd
+++ /dev/null
@@ -1,17 +0,0 @@
-@ECHO off
-GOTO start
-:find_dp0
-SET dp0=%~dp0
-EXIT /b
-:start
-SETLOCAL
-CALL :find_dp0
-
-IF EXIST "%dp0%\node.exe" (
- SET "_prog=%dp0%\node.exe"
-) ELSE (
- SET "_prog=node"
- SET PATHEXT=%PATHEXT:;.JS;=;%
-)
-
-endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\prettier\bin\prettier.cjs" %*
diff --git a/node_modules/.bin/prettier.ps1 b/node_modules/.bin/prettier.ps1
deleted file mode 100644
index 8359dd9..0000000
--- a/node_modules/.bin/prettier.ps1
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env pwsh
-$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
-
-$exe=""
-if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
- # Fix case when both the Windows and Linux builds of Node
- # are installed in the same directory
- $exe=".exe"
-}
-$ret=0
-if (Test-Path "$basedir/node$exe") {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "$basedir/node$exe" "$basedir/../prettier/bin/prettier.cjs" $args
- } else {
- & "$basedir/node$exe" "$basedir/../prettier/bin/prettier.cjs" $args
- }
- $ret=$LASTEXITCODE
-} else {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "node$exe" "$basedir/../prettier/bin/prettier.cjs" $args
- } else {
- & "node$exe" "$basedir/../prettier/bin/prettier.cjs" $args
- }
- $ret=$LASTEXITCODE
-}
-exit $ret
diff --git a/node_modules/.bin/uuid b/node_modules/.bin/uuid
deleted file mode 100644
index 26eb018..0000000
--- a/node_modules/.bin/uuid
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
-
-case `uname` in
- *CYGWIN*|*MINGW*|*MSYS*)
- if command -v cygpath > /dev/null 2>&1; then
- basedir=`cygpath -w "$basedir"`
- fi
- ;;
-esac
-
-if [ -x "$basedir/node" ]; then
- exec "$basedir/node" "$basedir/../uuid/dist-node/bin/uuid" "$@"
-else
- exec node "$basedir/../uuid/dist-node/bin/uuid" "$@"
-fi
diff --git a/node_modules/.bin/uuid b/node_modules/.bin/uuid
new file mode 120000
index 0000000..a0e681c
--- /dev/null
+++ b/node_modules/.bin/uuid
@@ -0,0 +1 @@
+../uuid/dist-node/bin/uuid
\ No newline at end of file
diff --git a/node_modules/.bin/uuid.cmd b/node_modules/.bin/uuid.cmd
deleted file mode 100644
index 91d932f..0000000
--- a/node_modules/.bin/uuid.cmd
+++ /dev/null
@@ -1,17 +0,0 @@
-@ECHO off
-GOTO start
-:find_dp0
-SET dp0=%~dp0
-EXIT /b
-:start
-SETLOCAL
-CALL :find_dp0
-
-IF EXIST "%dp0%\node.exe" (
- SET "_prog=%dp0%\node.exe"
-) ELSE (
- SET "_prog=node"
- SET PATHEXT=%PATHEXT:;.JS;=;%
-)
-
-endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\uuid\dist-node\bin\uuid" %*
diff --git a/node_modules/.bin/uuid.ps1 b/node_modules/.bin/uuid.ps1
deleted file mode 100644
index 42eab25..0000000
--- a/node_modules/.bin/uuid.ps1
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env pwsh
-$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
-
-$exe=""
-if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
- # Fix case when both the Windows and Linux builds of Node
- # are installed in the same directory
- $exe=".exe"
-}
-$ret=0
-if (Test-Path "$basedir/node$exe") {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "$basedir/node$exe" "$basedir/../uuid/dist-node/bin/uuid" $args
- } else {
- & "$basedir/node$exe" "$basedir/../uuid/dist-node/bin/uuid" $args
- }
- $ret=$LASTEXITCODE
-} else {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & "node$exe" "$basedir/../uuid/dist-node/bin/uuid" $args
- } else {
- & "node$exe" "$basedir/../uuid/dist-node/bin/uuid" $args
- }
- $ret=$LASTEXITCODE
-}
-exit $ret
diff --git a/node_modules/@eslint/.DS_Store b/node_modules/@eslint/.DS_Store
deleted file mode 100644
index fd4a0c5..0000000
Binary files a/node_modules/@eslint/.DS_Store and /dev/null differ
diff --git a/node_modules/@humanfs/.DS_Store b/node_modules/@humanfs/.DS_Store
deleted file mode 100644
index 1fa4f7d..0000000
Binary files a/node_modules/@humanfs/.DS_Store and /dev/null differ
diff --git a/node_modules/@humanwhocodes/.DS_Store b/node_modules/@humanwhocodes/.DS_Store
deleted file mode 100644
index 5ef4dac..0000000
Binary files a/node_modules/@humanwhocodes/.DS_Store and /dev/null differ
diff --git a/node_modules/@types/.DS_Store b/node_modules/@types/.DS_Store
deleted file mode 100644
index 9f5c09a..0000000
Binary files a/node_modules/@types/.DS_Store and /dev/null differ
diff --git a/node_modules/@types/estree/README.md b/node_modules/@types/estree/README.md
index 3a8c041..2af760b 100644
--- a/node_modules/@types/estree/README.md
+++ b/node_modules/@types/estree/README.md
@@ -1,15 +1,15 @@
-# Installation
-> `npm install --save @types/estree`
-
-# Summary
-This package contains type definitions for estree (https://github.com/estree/estree).
-
-# Details
-Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree.
-
-### Additional Details
- * Last updated: Fri, 06 Jun 2025 00:04:33 GMT
- * Dependencies: none
-
-# Credits
-These definitions were written by [RReverser](https://github.com/RReverser).
+# Installation
+> `npm install --save @types/estree`
+
+# Summary
+This package contains type definitions for estree (https://github.com/estree/estree).
+
+# Details
+Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree.
+
+### Additional Details
+ * Last updated: Fri, 06 Jun 2025 00:04:33 GMT
+ * Dependencies: none
+
+# Credits
+These definitions were written by [RReverser](https://github.com/RReverser).
diff --git a/node_modules/@types/json-schema/README.md b/node_modules/@types/json-schema/README.md
index 42d55d3..78c610f 100644
--- a/node_modules/@types/json-schema/README.md
+++ b/node_modules/@types/json-schema/README.md
@@ -1,15 +1,15 @@
-# Installation
-> `npm install --save @types/json-schema`
-
-# Summary
-This package contains type definitions for json-schema (https://github.com/kriszyp/json-schema).
-
-# Details
-Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/json-schema.
-
-### Additional Details
- * Last updated: Tue, 07 Nov 2023 03:09:37 GMT
- * Dependencies: none
-
-# Credits
-These definitions were written by [Boris Cherny](https://github.com/bcherny), [Lucian Buzzo](https://github.com/lucianbuzzo), [Roland Groza](https://github.com/rolandjitsu), and [Jason Kwok](https://github.com/JasonHK).
+# Installation
+> `npm install --save @types/json-schema`
+
+# Summary
+This package contains type definitions for json-schema (https://github.com/kriszyp/json-schema).
+
+# Details
+Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/json-schema.
+
+### Additional Details
+ * Last updated: Tue, 07 Nov 2023 03:09:37 GMT
+ * Dependencies: none
+
+# Credits
+These definitions were written by [Boris Cherny](https://github.com/bcherny), [Lucian Buzzo](https://github.com/lucianbuzzo), [Roland Groza](https://github.com/rolandjitsu), and [Jason Kwok](https://github.com/JasonHK).
diff --git a/node_modules/acorn/.DS_Store b/node_modules/acorn/.DS_Store
deleted file mode 100644
index bf3af43..0000000
Binary files a/node_modules/acorn/.DS_Store and /dev/null differ
diff --git a/node_modules/acorn/bin/acorn b/node_modules/acorn/bin/acorn
old mode 100644
new mode 100755
diff --git a/node_modules/ajv/.DS_Store b/node_modules/ajv/.DS_Store
deleted file mode 100644
index b775c14..0000000
Binary files a/node_modules/ajv/.DS_Store and /dev/null differ
diff --git a/node_modules/color-name/LICENSE b/node_modules/color-name/LICENSE
index 4d9802a..c6b1001 100644
--- a/node_modules/color-name/LICENSE
+++ b/node_modules/color-name/LICENSE
@@ -1,8 +1,8 @@
-The MIT License (MIT)
-Copyright (c) 2015 Dmitry Ivanov
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
+The MIT License (MIT)
+Copyright (c) 2015 Dmitry Ivanov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/node_modules/color-name/README.md b/node_modules/color-name/README.md
index 3611a6b..932b979 100644
--- a/node_modules/color-name/README.md
+++ b/node_modules/color-name/README.md
@@ -1,11 +1,11 @@
-A JSON with color names and its values. Based on http://dev.w3.org/csswg/css-color/#named-colors.
-
-[](https://nodei.co/npm/color-name/)
-
-
-```js
-var colors = require('color-name');
-colors.red //[255,0,0]
-```
-
-
+A JSON with color names and its values. Based on http://dev.w3.org/csswg/css-color/#named-colors.
+
+[](https://nodei.co/npm/color-name/)
+
+
+```js
+var colors = require('color-name');
+colors.red //[255,0,0]
+```
+
+
diff --git a/node_modules/color-name/index.js b/node_modules/color-name/index.js
index e42aa68..b7c198a 100644
--- a/node_modules/color-name/index.js
+++ b/node_modules/color-name/index.js
@@ -1,152 +1,152 @@
-'use strict'
-
-module.exports = {
- "aliceblue": [240, 248, 255],
- "antiquewhite": [250, 235, 215],
- "aqua": [0, 255, 255],
- "aquamarine": [127, 255, 212],
- "azure": [240, 255, 255],
- "beige": [245, 245, 220],
- "bisque": [255, 228, 196],
- "black": [0, 0, 0],
- "blanchedalmond": [255, 235, 205],
- "blue": [0, 0, 255],
- "blueviolet": [138, 43, 226],
- "brown": [165, 42, 42],
- "burlywood": [222, 184, 135],
- "cadetblue": [95, 158, 160],
- "chartreuse": [127, 255, 0],
- "chocolate": [210, 105, 30],
- "coral": [255, 127, 80],
- "cornflowerblue": [100, 149, 237],
- "cornsilk": [255, 248, 220],
- "crimson": [220, 20, 60],
- "cyan": [0, 255, 255],
- "darkblue": [0, 0, 139],
- "darkcyan": [0, 139, 139],
- "darkgoldenrod": [184, 134, 11],
- "darkgray": [169, 169, 169],
- "darkgreen": [0, 100, 0],
- "darkgrey": [169, 169, 169],
- "darkkhaki": [189, 183, 107],
- "darkmagenta": [139, 0, 139],
- "darkolivegreen": [85, 107, 47],
- "darkorange": [255, 140, 0],
- "darkorchid": [153, 50, 204],
- "darkred": [139, 0, 0],
- "darksalmon": [233, 150, 122],
- "darkseagreen": [143, 188, 143],
- "darkslateblue": [72, 61, 139],
- "darkslategray": [47, 79, 79],
- "darkslategrey": [47, 79, 79],
- "darkturquoise": [0, 206, 209],
- "darkviolet": [148, 0, 211],
- "deeppink": [255, 20, 147],
- "deepskyblue": [0, 191, 255],
- "dimgray": [105, 105, 105],
- "dimgrey": [105, 105, 105],
- "dodgerblue": [30, 144, 255],
- "firebrick": [178, 34, 34],
- "floralwhite": [255, 250, 240],
- "forestgreen": [34, 139, 34],
- "fuchsia": [255, 0, 255],
- "gainsboro": [220, 220, 220],
- "ghostwhite": [248, 248, 255],
- "gold": [255, 215, 0],
- "goldenrod": [218, 165, 32],
- "gray": [128, 128, 128],
- "green": [0, 128, 0],
- "greenyellow": [173, 255, 47],
- "grey": [128, 128, 128],
- "honeydew": [240, 255, 240],
- "hotpink": [255, 105, 180],
- "indianred": [205, 92, 92],
- "indigo": [75, 0, 130],
- "ivory": [255, 255, 240],
- "khaki": [240, 230, 140],
- "lavender": [230, 230, 250],
- "lavenderblush": [255, 240, 245],
- "lawngreen": [124, 252, 0],
- "lemonchiffon": [255, 250, 205],
- "lightblue": [173, 216, 230],
- "lightcoral": [240, 128, 128],
- "lightcyan": [224, 255, 255],
- "lightgoldenrodyellow": [250, 250, 210],
- "lightgray": [211, 211, 211],
- "lightgreen": [144, 238, 144],
- "lightgrey": [211, 211, 211],
- "lightpink": [255, 182, 193],
- "lightsalmon": [255, 160, 122],
- "lightseagreen": [32, 178, 170],
- "lightskyblue": [135, 206, 250],
- "lightslategray": [119, 136, 153],
- "lightslategrey": [119, 136, 153],
- "lightsteelblue": [176, 196, 222],
- "lightyellow": [255, 255, 224],
- "lime": [0, 255, 0],
- "limegreen": [50, 205, 50],
- "linen": [250, 240, 230],
- "magenta": [255, 0, 255],
- "maroon": [128, 0, 0],
- "mediumaquamarine": [102, 205, 170],
- "mediumblue": [0, 0, 205],
- "mediumorchid": [186, 85, 211],
- "mediumpurple": [147, 112, 219],
- "mediumseagreen": [60, 179, 113],
- "mediumslateblue": [123, 104, 238],
- "mediumspringgreen": [0, 250, 154],
- "mediumturquoise": [72, 209, 204],
- "mediumvioletred": [199, 21, 133],
- "midnightblue": [25, 25, 112],
- "mintcream": [245, 255, 250],
- "mistyrose": [255, 228, 225],
- "moccasin": [255, 228, 181],
- "navajowhite": [255, 222, 173],
- "navy": [0, 0, 128],
- "oldlace": [253, 245, 230],
- "olive": [128, 128, 0],
- "olivedrab": [107, 142, 35],
- "orange": [255, 165, 0],
- "orangered": [255, 69, 0],
- "orchid": [218, 112, 214],
- "palegoldenrod": [238, 232, 170],
- "palegreen": [152, 251, 152],
- "paleturquoise": [175, 238, 238],
- "palevioletred": [219, 112, 147],
- "papayawhip": [255, 239, 213],
- "peachpuff": [255, 218, 185],
- "peru": [205, 133, 63],
- "pink": [255, 192, 203],
- "plum": [221, 160, 221],
- "powderblue": [176, 224, 230],
- "purple": [128, 0, 128],
- "rebeccapurple": [102, 51, 153],
- "red": [255, 0, 0],
- "rosybrown": [188, 143, 143],
- "royalblue": [65, 105, 225],
- "saddlebrown": [139, 69, 19],
- "salmon": [250, 128, 114],
- "sandybrown": [244, 164, 96],
- "seagreen": [46, 139, 87],
- "seashell": [255, 245, 238],
- "sienna": [160, 82, 45],
- "silver": [192, 192, 192],
- "skyblue": [135, 206, 235],
- "slateblue": [106, 90, 205],
- "slategray": [112, 128, 144],
- "slategrey": [112, 128, 144],
- "snow": [255, 250, 250],
- "springgreen": [0, 255, 127],
- "steelblue": [70, 130, 180],
- "tan": [210, 180, 140],
- "teal": [0, 128, 128],
- "thistle": [216, 191, 216],
- "tomato": [255, 99, 71],
- "turquoise": [64, 224, 208],
- "violet": [238, 130, 238],
- "wheat": [245, 222, 179],
- "white": [255, 255, 255],
- "whitesmoke": [245, 245, 245],
- "yellow": [255, 255, 0],
- "yellowgreen": [154, 205, 50]
-};
+'use strict'
+
+module.exports = {
+ "aliceblue": [240, 248, 255],
+ "antiquewhite": [250, 235, 215],
+ "aqua": [0, 255, 255],
+ "aquamarine": [127, 255, 212],
+ "azure": [240, 255, 255],
+ "beige": [245, 245, 220],
+ "bisque": [255, 228, 196],
+ "black": [0, 0, 0],
+ "blanchedalmond": [255, 235, 205],
+ "blue": [0, 0, 255],
+ "blueviolet": [138, 43, 226],
+ "brown": [165, 42, 42],
+ "burlywood": [222, 184, 135],
+ "cadetblue": [95, 158, 160],
+ "chartreuse": [127, 255, 0],
+ "chocolate": [210, 105, 30],
+ "coral": [255, 127, 80],
+ "cornflowerblue": [100, 149, 237],
+ "cornsilk": [255, 248, 220],
+ "crimson": [220, 20, 60],
+ "cyan": [0, 255, 255],
+ "darkblue": [0, 0, 139],
+ "darkcyan": [0, 139, 139],
+ "darkgoldenrod": [184, 134, 11],
+ "darkgray": [169, 169, 169],
+ "darkgreen": [0, 100, 0],
+ "darkgrey": [169, 169, 169],
+ "darkkhaki": [189, 183, 107],
+ "darkmagenta": [139, 0, 139],
+ "darkolivegreen": [85, 107, 47],
+ "darkorange": [255, 140, 0],
+ "darkorchid": [153, 50, 204],
+ "darkred": [139, 0, 0],
+ "darksalmon": [233, 150, 122],
+ "darkseagreen": [143, 188, 143],
+ "darkslateblue": [72, 61, 139],
+ "darkslategray": [47, 79, 79],
+ "darkslategrey": [47, 79, 79],
+ "darkturquoise": [0, 206, 209],
+ "darkviolet": [148, 0, 211],
+ "deeppink": [255, 20, 147],
+ "deepskyblue": [0, 191, 255],
+ "dimgray": [105, 105, 105],
+ "dimgrey": [105, 105, 105],
+ "dodgerblue": [30, 144, 255],
+ "firebrick": [178, 34, 34],
+ "floralwhite": [255, 250, 240],
+ "forestgreen": [34, 139, 34],
+ "fuchsia": [255, 0, 255],
+ "gainsboro": [220, 220, 220],
+ "ghostwhite": [248, 248, 255],
+ "gold": [255, 215, 0],
+ "goldenrod": [218, 165, 32],
+ "gray": [128, 128, 128],
+ "green": [0, 128, 0],
+ "greenyellow": [173, 255, 47],
+ "grey": [128, 128, 128],
+ "honeydew": [240, 255, 240],
+ "hotpink": [255, 105, 180],
+ "indianred": [205, 92, 92],
+ "indigo": [75, 0, 130],
+ "ivory": [255, 255, 240],
+ "khaki": [240, 230, 140],
+ "lavender": [230, 230, 250],
+ "lavenderblush": [255, 240, 245],
+ "lawngreen": [124, 252, 0],
+ "lemonchiffon": [255, 250, 205],
+ "lightblue": [173, 216, 230],
+ "lightcoral": [240, 128, 128],
+ "lightcyan": [224, 255, 255],
+ "lightgoldenrodyellow": [250, 250, 210],
+ "lightgray": [211, 211, 211],
+ "lightgreen": [144, 238, 144],
+ "lightgrey": [211, 211, 211],
+ "lightpink": [255, 182, 193],
+ "lightsalmon": [255, 160, 122],
+ "lightseagreen": [32, 178, 170],
+ "lightskyblue": [135, 206, 250],
+ "lightslategray": [119, 136, 153],
+ "lightslategrey": [119, 136, 153],
+ "lightsteelblue": [176, 196, 222],
+ "lightyellow": [255, 255, 224],
+ "lime": [0, 255, 0],
+ "limegreen": [50, 205, 50],
+ "linen": [250, 240, 230],
+ "magenta": [255, 0, 255],
+ "maroon": [128, 0, 0],
+ "mediumaquamarine": [102, 205, 170],
+ "mediumblue": [0, 0, 205],
+ "mediumorchid": [186, 85, 211],
+ "mediumpurple": [147, 112, 219],
+ "mediumseagreen": [60, 179, 113],
+ "mediumslateblue": [123, 104, 238],
+ "mediumspringgreen": [0, 250, 154],
+ "mediumturquoise": [72, 209, 204],
+ "mediumvioletred": [199, 21, 133],
+ "midnightblue": [25, 25, 112],
+ "mintcream": [245, 255, 250],
+ "mistyrose": [255, 228, 225],
+ "moccasin": [255, 228, 181],
+ "navajowhite": [255, 222, 173],
+ "navy": [0, 0, 128],
+ "oldlace": [253, 245, 230],
+ "olive": [128, 128, 0],
+ "olivedrab": [107, 142, 35],
+ "orange": [255, 165, 0],
+ "orangered": [255, 69, 0],
+ "orchid": [218, 112, 214],
+ "palegoldenrod": [238, 232, 170],
+ "palegreen": [152, 251, 152],
+ "paleturquoise": [175, 238, 238],
+ "palevioletred": [219, 112, 147],
+ "papayawhip": [255, 239, 213],
+ "peachpuff": [255, 218, 185],
+ "peru": [205, 133, 63],
+ "pink": [255, 192, 203],
+ "plum": [221, 160, 221],
+ "powderblue": [176, 224, 230],
+ "purple": [128, 0, 128],
+ "rebeccapurple": [102, 51, 153],
+ "red": [255, 0, 0],
+ "rosybrown": [188, 143, 143],
+ "royalblue": [65, 105, 225],
+ "saddlebrown": [139, 69, 19],
+ "salmon": [250, 128, 114],
+ "sandybrown": [244, 164, 96],
+ "seagreen": [46, 139, 87],
+ "seashell": [255, 245, 238],
+ "sienna": [160, 82, 45],
+ "silver": [192, 192, 192],
+ "skyblue": [135, 206, 235],
+ "slateblue": [106, 90, 205],
+ "slategray": [112, 128, 144],
+ "slategrey": [112, 128, 144],
+ "snow": [255, 250, 250],
+ "springgreen": [0, 255, 127],
+ "steelblue": [70, 130, 180],
+ "tan": [210, 180, 140],
+ "teal": [0, 128, 128],
+ "thistle": [216, 191, 216],
+ "tomato": [255, 99, 71],
+ "turquoise": [64, 224, 208],
+ "violet": [238, 130, 238],
+ "wheat": [245, 222, 179],
+ "white": [255, 255, 255],
+ "whitesmoke": [245, 245, 245],
+ "yellow": [255, 255, 0],
+ "yellowgreen": [154, 205, 50]
+};
diff --git a/node_modules/color-name/package.json b/node_modules/color-name/package.json
index 7acc902..782dd82 100644
--- a/node_modules/color-name/package.json
+++ b/node_modules/color-name/package.json
@@ -1,28 +1,28 @@
-{
- "name": "color-name",
- "version": "1.1.4",
- "description": "A list of color names and its values",
- "main": "index.js",
- "files": [
- "index.js"
- ],
- "scripts": {
- "test": "node test.js"
- },
- "repository": {
- "type": "git",
- "url": "git@github.com:colorjs/color-name.git"
- },
- "keywords": [
- "color-name",
- "color",
- "color-keyword",
- "keyword"
- ],
- "author": "DY ",
- "license": "MIT",
- "bugs": {
- "url": "https://github.com/colorjs/color-name/issues"
- },
- "homepage": "https://github.com/colorjs/color-name"
-}
+{
+ "name": "color-name",
+ "version": "1.1.4",
+ "description": "A list of color names and its values",
+ "main": "index.js",
+ "files": [
+ "index.js"
+ ],
+ "scripts": {
+ "test": "node test.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:colorjs/color-name.git"
+ },
+ "keywords": [
+ "color-name",
+ "color",
+ "color-keyword",
+ "keyword"
+ ],
+ "author": "DY ",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/colorjs/color-name/issues"
+ },
+ "homepage": "https://github.com/colorjs/color-name"
+}
diff --git a/node_modules/concat-map/.DS_Store b/node_modules/concat-map/.DS_Store
deleted file mode 100644
index 3a1eb59..0000000
Binary files a/node_modules/concat-map/.DS_Store and /dev/null differ
diff --git a/node_modules/deep-is/.DS_Store b/node_modules/deep-is/.DS_Store
deleted file mode 100644
index e7cc572..0000000
Binary files a/node_modules/deep-is/.DS_Store and /dev/null differ
diff --git a/node_modules/eslint-config-prettier/bin/cli.js b/node_modules/eslint-config-prettier/bin/cli.js
old mode 100644
new mode 100755
diff --git a/node_modules/eslint-scope/.DS_Store b/node_modules/eslint-scope/.DS_Store
deleted file mode 100644
index bca129d..0000000
Binary files a/node_modules/eslint-scope/.DS_Store and /dev/null differ
diff --git a/node_modules/eslint-visitor-keys/.DS_Store b/node_modules/eslint-visitor-keys/.DS_Store
deleted file mode 100644
index 9eff057..0000000
Binary files a/node_modules/eslint-visitor-keys/.DS_Store and /dev/null differ
diff --git a/node_modules/eslint/.DS_Store b/node_modules/eslint/.DS_Store
deleted file mode 100644
index c6b1569..0000000
Binary files a/node_modules/eslint/.DS_Store and /dev/null differ
diff --git a/node_modules/eslint/bin/eslint.js b/node_modules/eslint/bin/eslint.js
old mode 100644
new mode 100755
diff --git a/node_modules/espree/.DS_Store b/node_modules/espree/.DS_Store
deleted file mode 100644
index 1aa3e34..0000000
Binary files a/node_modules/espree/.DS_Store and /dev/null differ
diff --git a/node_modules/esrecurse/package.json b/node_modules/esrecurse/package.json
old mode 100644
new mode 100755
diff --git a/node_modules/fast-json-stable-stringify/.DS_Store b/node_modules/fast-json-stable-stringify/.DS_Store
deleted file mode 100644
index 4dcb898..0000000
Binary files a/node_modules/fast-json-stable-stringify/.DS_Store and /dev/null differ
diff --git a/node_modules/flatted/.DS_Store b/node_modules/flatted/.DS_Store
deleted file mode 100644
index b8a8744..0000000
Binary files a/node_modules/flatted/.DS_Store and /dev/null differ
diff --git a/node_modules/husky/bin.js b/node_modules/husky/bin.js
old mode 100644
new mode 100755
diff --git a/node_modules/js-yaml/.DS_Store b/node_modules/js-yaml/.DS_Store
deleted file mode 100644
index d4ba7a0..0000000
Binary files a/node_modules/js-yaml/.DS_Store and /dev/null differ
diff --git a/node_modules/js-yaml/bin/js-yaml.js b/node_modules/js-yaml/bin/js-yaml.js
old mode 100644
new mode 100755
diff --git a/node_modules/node-rsa/gruntfile.js b/node_modules/node-rsa/gruntfile.js
index ecdb7f1..4d00789 100644
--- a/node_modules/node-rsa/gruntfile.js
+++ b/node_modules/node-rsa/gruntfile.js
@@ -1,33 +1,33 @@
-module.exports = function (grunt) {
- grunt.initConfig({
- jshint: {
- options: {},
- default: {
- files: {
- src: ['gruntfile.js', 'src/**/*.js', '!src/libs/jsbn.js']
- }
- },
- libs: {
- files: {
- src: ['src/libs/**/*']
- }
- }
- },
-
- simplemocha: {
- options: {
- reporter: 'list'
- },
- all: {src: ['test/**/*.js']}
- }
- });
-
- require('jit-grunt')(grunt, {
- 'simplemocha': 'grunt-simple-mocha'
- });
-
- grunt.registerTask('lint', ['jshint:default']);
- grunt.registerTask('test', ['simplemocha']);
-
- grunt.registerTask('default', ['lint', 'test']);
+module.exports = function (grunt) {
+ grunt.initConfig({
+ jshint: {
+ options: {},
+ default: {
+ files: {
+ src: ['gruntfile.js', 'src/**/*.js', '!src/libs/jsbn.js']
+ }
+ },
+ libs: {
+ files: {
+ src: ['src/libs/**/*']
+ }
+ }
+ },
+
+ simplemocha: {
+ options: {
+ reporter: 'list'
+ },
+ all: {src: ['test/**/*.js']}
+ }
+ });
+
+ require('jit-grunt')(grunt, {
+ 'simplemocha': 'grunt-simple-mocha'
+ });
+
+ grunt.registerTask('lint', ['jshint:default']);
+ grunt.registerTask('test', ['simplemocha']);
+
+ grunt.registerTask('default', ['lint', 'test']);
};
\ No newline at end of file
diff --git a/node_modules/node-rsa/src/encryptEngines/encryptEngines.js b/node_modules/node-rsa/src/encryptEngines/encryptEngines.js
index d359452..2d7421b 100644
--- a/node_modules/node-rsa/src/encryptEngines/encryptEngines.js
+++ b/node_modules/node-rsa/src/encryptEngines/encryptEngines.js
@@ -1,17 +1,17 @@
-var crypt = require('crypto');
-
-module.exports = {
- getEngine: function (keyPair, options) {
- var engine = require('./js.js');
- if (options.environment === 'node') {
- if (typeof crypt.publicEncrypt === 'function' && typeof crypt.privateDecrypt === 'function') {
- if (typeof crypt.privateEncrypt === 'function' && typeof crypt.publicDecrypt === 'function') {
- engine = require('./io.js');
- } else {
- engine = require('./node12.js');
- }
- }
- }
- return engine(keyPair, options);
- }
+var crypt = require('crypto');
+
+module.exports = {
+ getEngine: function (keyPair, options) {
+ var engine = require('./js.js');
+ if (options.environment === 'node') {
+ if (typeof crypt.publicEncrypt === 'function' && typeof crypt.privateDecrypt === 'function') {
+ if (typeof crypt.privateEncrypt === 'function' && typeof crypt.publicDecrypt === 'function') {
+ engine = require('./io.js');
+ } else {
+ engine = require('./node12.js');
+ }
+ }
+ }
+ return engine(keyPair, options);
+ }
};
\ No newline at end of file
diff --git a/node_modules/node-rsa/src/encryptEngines/js.js b/node_modules/node-rsa/src/encryptEngines/js.js
index f148441..4df3531 100644
--- a/node_modules/node-rsa/src/encryptEngines/js.js
+++ b/node_modules/node-rsa/src/encryptEngines/js.js
@@ -1,34 +1,34 @@
-var BigInteger = require('../libs/jsbn.js');
-var schemes = require('../schemes/schemes.js');
-
-module.exports = function (keyPair, options) {
- var pkcs1Scheme = schemes.pkcs1.makeScheme(keyPair, options);
-
- return {
- encrypt: function (buffer, usePrivate) {
- var m, c;
- if (usePrivate) {
- /* Type 1: zeros padding for private key encrypt */
- m = new BigInteger(pkcs1Scheme.encPad(buffer, {type: 1}));
- c = keyPair.$doPrivate(m);
- } else {
- m = new BigInteger(keyPair.encryptionScheme.encPad(buffer));
- c = keyPair.$doPublic(m);
- }
- return c.toBuffer(keyPair.encryptedDataLength);
- },
-
- decrypt: function (buffer, usePublic) {
- var m, c = new BigInteger(buffer);
-
- if (usePublic) {
- m = keyPair.$doPublic(c);
- /* Type 1: zeros padding for private key decrypt */
- return pkcs1Scheme.encUnPad(m.toBuffer(keyPair.encryptedDataLength), {type: 1});
- } else {
- m = keyPair.$doPrivate(c);
- return keyPair.encryptionScheme.encUnPad(m.toBuffer(keyPair.encryptedDataLength));
- }
- }
- };
+var BigInteger = require('../libs/jsbn.js');
+var schemes = require('../schemes/schemes.js');
+
+module.exports = function (keyPair, options) {
+ var pkcs1Scheme = schemes.pkcs1.makeScheme(keyPair, options);
+
+ return {
+ encrypt: function (buffer, usePrivate) {
+ var m, c;
+ if (usePrivate) {
+ /* Type 1: zeros padding for private key encrypt */
+ m = new BigInteger(pkcs1Scheme.encPad(buffer, {type: 1}));
+ c = keyPair.$doPrivate(m);
+ } else {
+ m = new BigInteger(keyPair.encryptionScheme.encPad(buffer));
+ c = keyPair.$doPublic(m);
+ }
+ return c.toBuffer(keyPair.encryptedDataLength);
+ },
+
+ decrypt: function (buffer, usePublic) {
+ var m, c = new BigInteger(buffer);
+
+ if (usePublic) {
+ m = keyPair.$doPublic(c);
+ /* Type 1: zeros padding for private key decrypt */
+ return pkcs1Scheme.encUnPad(m.toBuffer(keyPair.encryptedDataLength), {type: 1});
+ } else {
+ m = keyPair.$doPrivate(c);
+ return keyPair.encryptionScheme.encUnPad(m.toBuffer(keyPair.encryptedDataLength));
+ }
+ }
+ };
};
\ No newline at end of file
diff --git a/node_modules/node-rsa/src/formats/components.js b/node_modules/node-rsa/src/formats/components.js
index a275314..56af95c 100644
--- a/node_modules/node-rsa/src/formats/components.js
+++ b/node_modules/node-rsa/src/formats/components.js
@@ -1,71 +1,71 @@
-var _ = require('../utils')._;
-var utils = require('../utils');
-
-module.exports = {
- privateExport: function (key, options) {
- return {
- n: key.n.toBuffer(),
- e: key.e,
- d: key.d.toBuffer(),
- p: key.p.toBuffer(),
- q: key.q.toBuffer(),
- dmp1: key.dmp1.toBuffer(),
- dmq1: key.dmq1.toBuffer(),
- coeff: key.coeff.toBuffer()
- };
- },
-
- privateImport: function (key, data, options) {
- if (data.n && data.e && data.d && data.p && data.q && data.dmp1 && data.dmq1 && data.coeff) {
- key.setPrivate(
- data.n,
- data.e,
- data.d,
- data.p,
- data.q,
- data.dmp1,
- data.dmq1,
- data.coeff
- );
- } else {
- throw Error("Invalid key data");
- }
- },
-
- publicExport: function (key, options) {
- return {
- n: key.n.toBuffer(),
- e: key.e
- };
- },
-
- publicImport: function (key, data, options) {
- if (data.n && data.e) {
- key.setPublic(
- data.n,
- data.e
- );
- } else {
- throw Error("Invalid key data");
- }
- },
-
- /**
- * Trying autodetect and import key
- * @param key
- * @param data
- */
- autoImport: function (key, data) {
- if (data.n && data.e) {
- if (data.d && data.p && data.q && data.dmp1 && data.dmq1 && data.coeff) {
- module.exports.privateImport(key, data);
- return true;
- } else {
- module.exports.publicImport(key, data);
- return true;
- }
- }
-
- return false;
- }
-};
+var _ = require('../utils')._;
+var utils = require('../utils');
+
+module.exports = {
+ privateExport: function (key, options) {
+ return {
+ n: key.n.toBuffer(),
+ e: key.e,
+ d: key.d.toBuffer(),
+ p: key.p.toBuffer(),
+ q: key.q.toBuffer(),
+ dmp1: key.dmp1.toBuffer(),
+ dmq1: key.dmq1.toBuffer(),
+ coeff: key.coeff.toBuffer()
+ };
+ },
+
+ privateImport: function (key, data, options) {
+ if (data.n && data.e && data.d && data.p && data.q && data.dmp1 && data.dmq1 && data.coeff) {
+ key.setPrivate(
+ data.n,
+ data.e,
+ data.d,
+ data.p,
+ data.q,
+ data.dmp1,
+ data.dmq1,
+ data.coeff
+ );
+ } else {
+ throw Error("Invalid key data");
+ }
+ },
+
+ publicExport: function (key, options) {
+ return {
+ n: key.n.toBuffer(),
+ e: key.e
+ };
+ },
+
+ publicImport: function (key, data, options) {
+ if (data.n && data.e) {
+ key.setPublic(
+ data.n,
+ data.e
+ );
+ } else {
+ throw Error("Invalid key data");
+ }
+ },
+
+ /**
+ * Trying autodetect and import key
+ * @param key
+ * @param data
+ */
+ autoImport: function (key, data) {
+ if (data.n && data.e) {
+ if (data.d && data.p && data.q && data.dmp1 && data.dmq1 && data.coeff) {
+ module.exports.privateImport(key, data);
+ return true;
+ } else {
+ module.exports.publicImport(key, data);
+ return true;
+ }
+ }
+
+ return false;
+ }
+};
diff --git a/node_modules/node-rsa/src/libs/jsbn.js b/node_modules/node-rsa/src/libs/jsbn.js
index 6eb3cd4..5464d7c 100644
--- a/node_modules/node-rsa/src/libs/jsbn.js
+++ b/node_modules/node-rsa/src/libs/jsbn.js
@@ -1,1540 +1,1540 @@
-/*
- * Basic JavaScript BN library - subset useful for RSA encryption.
- *
- * Copyright (c) 2003-2005 Tom Wu
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
- * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * In addition, the following condition applies:
- *
- * All redistributions must retain an intact copy of this copyright notice
- * and disclaimer.
- */
-
-/*
- * Added Node.js Buffers support
- * 2014 rzcoder
- */
-
-var crypt = require('crypto');
-var _ = require('../utils')._;
-
-// Bits per digit
-var dbits;
-
-// JavaScript engine analysis
-var canary = 0xdeadbeefcafe;
-var j_lm = ((canary & 0xffffff) == 0xefcafe);
-
-// (public) Constructor
-function BigInteger(a, b) {
- if (a != null) {
- if ("number" == typeof a) {
- this.fromNumber(a, b);
- } else if (Buffer.isBuffer(a)) {
- this.fromBuffer(a);
- } else if (b == null && "string" != typeof a) {
- this.fromByteArray(a);
- } else {
- this.fromString(a, b);
- }
- }
-}
-
-// return new, unset BigInteger
-function nbi() {
- return new BigInteger(null);
-}
-
-// am: Compute w_j += (x*this_i), propagate carries,
-// c is initial carry, returns final carry.
-// c < 3*dvalue, x < 2*dvalue, this_i < dvalue
-// We need to select the fastest one that works in this environment.
-
-// am1: use a single mult and divide to get the high bits,
-// max digit bits should be 26 because
-// max internal value = 2*dvalue^2-2*dvalue (< 2^53)
-function am1(i, x, w, j, c, n) {
- while (--n >= 0) {
- var v = x * this[i++] + w[j] + c;
- c = Math.floor(v / 0x4000000);
- w[j++] = v & 0x3ffffff;
- }
- return c;
-}
-// am2 avoids a big mult-and-extract completely.
-// Max digit bits should be <= 30 because we do bitwise ops
-// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
-function am2(i, x, w, j, c, n) {
- var xl = x & 0x7fff, xh = x >> 15;
- while (--n >= 0) {
- var l = this[i] & 0x7fff;
- var h = this[i++] >> 15;
- var m = xh * l + h * xl;
- l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff);
- c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
- w[j++] = l & 0x3fffffff;
- }
- return c;
-}
-// Alternately, set max digit bits to 28 since some
-// browsers slow down when dealing with 32-bit numbers.
-function am3(i, x, w, j, c, n) {
- var xl = x & 0x3fff, xh = x >> 14;
- while (--n >= 0) {
- var l = this[i] & 0x3fff;
- var h = this[i++] >> 14;
- var m = xh * l + h * xl;
- l = xl * l + ((m & 0x3fff) << 14) + w[j] + c;
- c = (l >> 28) + (m >> 14) + xh * h;
- w[j++] = l & 0xfffffff;
- }
- return c;
-}
-
-// We need to select the fastest one that works in this environment.
-//if (j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
-// BigInteger.prototype.am = am2;
-// dbits = 30;
-//} else if (j_lm && (navigator.appName != "Netscape")) {
-// BigInteger.prototype.am = am1;
-// dbits = 26;
-//} else { // Mozilla/Netscape seems to prefer am3
-// BigInteger.prototype.am = am3;
-// dbits = 28;
-//}
-
-// For node.js, we pick am3 with max dbits to 28.
-BigInteger.prototype.am = am3;
-dbits = 28;
-
-BigInteger.prototype.DB = dbits;
-BigInteger.prototype.DM = ((1 << dbits) - 1);
-BigInteger.prototype.DV = (1 << dbits);
-
-var BI_FP = 52;
-BigInteger.prototype.FV = Math.pow(2, BI_FP);
-BigInteger.prototype.F1 = BI_FP - dbits;
-BigInteger.prototype.F2 = 2 * dbits - BI_FP;
-
-// Digit conversions
-var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
-var BI_RC = new Array();
-var rr, vv;
-rr = "0".charCodeAt(0);
-for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
-rr = "a".charCodeAt(0);
-for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
-rr = "A".charCodeAt(0);
-for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
-
-function int2char(n) {
- return BI_RM.charAt(n);
-}
-function intAt(s, i) {
- var c = BI_RC[s.charCodeAt(i)];
- return (c == null) ? -1 : c;
-}
-
-// (protected) copy this to r
-function bnpCopyTo(r) {
- for (var i = this.t - 1; i >= 0; --i) r[i] = this[i];
- r.t = this.t;
- r.s = this.s;
-}
-
-// (protected) set from integer value x, -DV <= x < DV
-function bnpFromInt(x) {
- this.t = 1;
- this.s = (x < 0) ? -1 : 0;
- if (x > 0) this[0] = x;
- else if (x < -1) this[0] = x + DV;
- else this.t = 0;
-}
-
-// return bigint initialized to value
-function nbv(i) {
- var r = nbi();
- r.fromInt(i);
- return r;
-}
-
-// (protected) set from string and radix
-function bnpFromString(data, radix, unsigned) {
- var k;
- switch (radix) {
- case 2:
- k = 1;
- break;
- case 4:
- k = 2;
- break;
- case 8:
- k = 3;
- break;
- case 16:
- k = 4;
- break;
- case 32:
- k = 5;
- break;
- case 256:
- k = 8;
- break;
- default:
- this.fromRadix(data, radix);
- return;
- }
-
- this.t = 0;
- this.s = 0;
-
- var i = data.length;
- var mi = false;
- var sh = 0;
-
- while (--i >= 0) {
- var x = (k == 8) ? data[i] & 0xff : intAt(data, i);
- if (x < 0) {
- if (data.charAt(i) == "-") mi = true;
- continue;
- }
- mi = false;
- if (sh === 0)
- this[this.t++] = x;
- else if (sh + k > this.DB) {
- this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;
- this[this.t++] = (x >> (this.DB - sh));
- }
- else
- this[this.t - 1] |= x << sh;
- sh += k;
- if (sh >= this.DB) sh -= this.DB;
- }
- if ((!unsigned) && k == 8 && (data[0] & 0x80) != 0) {
- this.s = -1;
- if (sh > 0) this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh;
- }
- this.clamp();
- if (mi) BigInteger.ZERO.subTo(this, this);
-}
-
-function bnpFromByteArray(a, unsigned) {
- this.fromString(a, 256, unsigned)
-}
-
-function bnpFromBuffer(a) {
- this.fromString(a, 256, true)
-}
-
-// (protected) clamp off excess high words
-function bnpClamp() {
- var c = this.s & this.DM;
- while (this.t > 0 && this[this.t - 1] == c) --this.t;
-}
-
-// (public) return string representation in given radix
-function bnToString(b) {
- if (this.s < 0) return "-" + this.negate().toString(b);
- var k;
- if (b == 16) k = 4;
- else if (b == 8) k = 3;
- else if (b == 2) k = 1;
- else if (b == 32) k = 5;
- else if (b == 4) k = 2;
- else return this.toRadix(b);
- var km = (1 << k) - 1, d, m = false, r = "", i = this.t;
- var p = this.DB - (i * this.DB) % k;
- if (i-- > 0) {
- if (p < this.DB && (d = this[i] >> p) > 0) {
- m = true;
- r = int2char(d);
- }
- while (i >= 0) {
- if (p < k) {
- d = (this[i] & ((1 << p) - 1)) << (k - p);
- d |= this[--i] >> (p += this.DB - k);
- }
- else {
- d = (this[i] >> (p -= k)) & km;
- if (p <= 0) {
- p += this.DB;
- --i;
- }
- }
- if (d > 0) m = true;
- if (m) r += int2char(d);
- }
- }
- return m ? r : "0";
-}
-
-// (public) -this
-function bnNegate() {
- var r = nbi();
- BigInteger.ZERO.subTo(this, r);
- return r;
-}
-
-// (public) |this|
-function bnAbs() {
- return (this.s < 0) ? this.negate() : this;
-}
-
-// (public) return + if this > a, - if this < a, 0 if equal
-function bnCompareTo(a) {
- var r = this.s - a.s;
- if (r != 0) return r;
- var i = this.t;
- r = i - a.t;
- if (r != 0) return (this.s < 0) ? -r : r;
- while (--i >= 0) if ((r = this[i] - a[i]) != 0) return r;
- return 0;
-}
-
-// returns bit length of the integer x
-function nbits(x) {
- var r = 1, t;
- if ((t = x >>> 16) != 0) {
- x = t;
- r += 16;
- }
- if ((t = x >> 8) != 0) {
- x = t;
- r += 8;
- }
- if ((t = x >> 4) != 0) {
- x = t;
- r += 4;
- }
- if ((t = x >> 2) != 0) {
- x = t;
- r += 2;
- }
- if ((t = x >> 1) != 0) {
- x = t;
- r += 1;
- }
- return r;
-}
-
-// (public) return the number of bits in "this"
-function bnBitLength() {
- if (this.t <= 0) return 0;
- return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM));
-}
-
-// (protected) r = this << n*DB
-function bnpDLShiftTo(n, r) {
- var i;
- for (i = this.t - 1; i >= 0; --i) r[i + n] = this[i];
- for (i = n - 1; i >= 0; --i) r[i] = 0;
- r.t = this.t + n;
- r.s = this.s;
-}
-
-// (protected) r = this >> n*DB
-function bnpDRShiftTo(n, r) {
- for (var i = n; i < this.t; ++i) r[i - n] = this[i];
- r.t = Math.max(this.t - n, 0);
- r.s = this.s;
-}
-
-// (protected) r = this << n
-function bnpLShiftTo(n, r) {
- var bs = n % this.DB;
- var cbs = this.DB - bs;
- var bm = (1 << cbs) - 1;
- var ds = Math.floor(n / this.DB), c = (this.s << bs) & this.DM, i;
- for (i = this.t - 1; i >= 0; --i) {
- r[i + ds + 1] = (this[i] >> cbs) | c;
- c = (this[i] & bm) << bs;
- }
- for (i = ds - 1; i >= 0; --i) r[i] = 0;
- r[ds] = c;
- r.t = this.t + ds + 1;
- r.s = this.s;
- r.clamp();
-}
-
-// (protected) r = this >> n
-function bnpRShiftTo(n, r) {
- r.s = this.s;
- var ds = Math.floor(n / this.DB);
- if (ds >= this.t) {
- r.t = 0;
- return;
- }
- var bs = n % this.DB;
- var cbs = this.DB - bs;
- var bm = (1 << bs) - 1;
- r[0] = this[ds] >> bs;
- for (var i = ds + 1; i < this.t; ++i) {
- r[i - ds - 1] |= (this[i] & bm) << cbs;
- r[i - ds] = this[i] >> bs;
- }
- if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs;
- r.t = this.t - ds;
- r.clamp();
-}
-
-// (protected) r = this - a
-function bnpSubTo(a, r) {
- var i = 0, c = 0, m = Math.min(a.t, this.t);
- while (i < m) {
- c += this[i] - a[i];
- r[i++] = c & this.DM;
- c >>= this.DB;
- }
- if (a.t < this.t) {
- c -= a.s;
- while (i < this.t) {
- c += this[i];
- r[i++] = c & this.DM;
- c >>= this.DB;
- }
- c += this.s;
- }
- else {
- c += this.s;
- while (i < a.t) {
- c -= a[i];
- r[i++] = c & this.DM;
- c >>= this.DB;
- }
- c -= a.s;
- }
- r.s = (c < 0) ? -1 : 0;
- if (c < -1) r[i++] = this.DV + c;
- else if (c > 0) r[i++] = c;
- r.t = i;
- r.clamp();
-}
-
-// (protected) r = this * a, r != this,a (HAC 14.12)
-// "this" should be the larger one if appropriate.
-function bnpMultiplyTo(a, r) {
- var x = this.abs(), y = a.abs();
- var i = x.t;
- r.t = i + y.t;
- while (--i >= 0) r[i] = 0;
- for (i = 0; i < y.t; ++i) r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);
- r.s = 0;
- r.clamp();
- if (this.s != a.s) BigInteger.ZERO.subTo(r, r);
-}
-
-// (protected) r = this^2, r != this (HAC 14.16)
-function bnpSquareTo(r) {
- var x = this.abs();
- var i = r.t = 2 * x.t;
- while (--i >= 0) r[i] = 0;
- for (i = 0; i < x.t - 1; ++i) {
- var c = x.am(i, x[i], r, 2 * i, 0, 1);
- if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
- r[i + x.t] -= x.DV;
- r[i + x.t + 1] = 1;
- }
- }
- if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);
- r.s = 0;
- r.clamp();
-}
-
-// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
-// r != q, this != m. q or r may be null.
-function bnpDivRemTo(m, q, r) {
- var pm = m.abs();
- if (pm.t <= 0) return;
- var pt = this.abs();
- if (pt.t < pm.t) {
- if (q != null) q.fromInt(0);
- if (r != null) this.copyTo(r);
- return;
- }
- if (r == null) r = nbi();
- var y = nbi(), ts = this.s, ms = m.s;
- var nsh = this.DB - nbits(pm[pm.t - 1]); // normalize modulus
- if (nsh > 0) {
- pm.lShiftTo(nsh, y);
- pt.lShiftTo(nsh, r);
- }
- else {
- pm.copyTo(y);
- pt.copyTo(r);
- }
- var ys = y.t;
- var y0 = y[ys - 1];
- if (y0 === 0) return;
- var yt = y0 * (1 << this.F1) + ((ys > 1) ? y[ys - 2] >> this.F2 : 0);
- var d1 = this.FV / yt, d2 = (1 << this.F1) / yt, e = 1 << this.F2;
- var i = r.t, j = i - ys, t = (q == null) ? nbi() : q;
- y.dlShiftTo(j, t);
- if (r.compareTo(t) >= 0) {
- r[r.t++] = 1;
- r.subTo(t, r);
- }
- BigInteger.ONE.dlShiftTo(ys, t);
- t.subTo(y, y); // "negative" y so we can replace sub with am later
- while (y.t < ys) y[y.t++] = 0;
- while (--j >= 0) {
- // Estimate quotient digit
- var qd = (r[--i] == y0) ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);
- if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) { // Try it out
- y.dlShiftTo(j, t);
- r.subTo(t, r);
- while (r[i] < --qd) r.subTo(t, r);
- }
- }
- if (q != null) {
- r.drShiftTo(ys, q);
- if (ts != ms) BigInteger.ZERO.subTo(q, q);
- }
- r.t = ys;
- r.clamp();
- if (nsh > 0) r.rShiftTo(nsh, r); // Denormalize remainder
- if (ts < 0) BigInteger.ZERO.subTo(r, r);
-}
-
-// (public) this mod a
-function bnMod(a) {
- var r = nbi();
- this.abs().divRemTo(a, null, r);
- if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r);
- return r;
-}
-
-// Modular reduction using "classic" algorithm
-function Classic(m) {
- this.m = m;
-}
-function cConvert(x) {
- if (x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
- else return x;
-}
-function cRevert(x) {
- return x;
-}
-function cReduce(x) {
- x.divRemTo(this.m, null, x);
-}
-function cMulTo(x, y, r) {
- x.multiplyTo(y, r);
- this.reduce(r);
-}
-function cSqrTo(x, r) {
- x.squareTo(r);
- this.reduce(r);
-}
-
-Classic.prototype.convert = cConvert;
-Classic.prototype.revert = cRevert;
-Classic.prototype.reduce = cReduce;
-Classic.prototype.mulTo = cMulTo;
-Classic.prototype.sqrTo = cSqrTo;
-
-// (protected) return "-1/this % 2^DB"; useful for Mont. reduction
-// justification:
-// xy == 1 (mod m)
-// xy = 1+km
-// xy(2-xy) = (1+km)(1-km)
-// x[y(2-xy)] = 1-k^2m^2
-// x[y(2-xy)] == 1 (mod m^2)
-// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
-// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
-// JS multiply "overflows" differently from C/C++, so care is needed here.
-function bnpInvDigit() {
- if (this.t < 1) return 0;
- var x = this[0];
- if ((x & 1) === 0) return 0;
- var y = x & 3; // y == 1/x mod 2^2
- y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
- y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
- y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
- // last step - calculate inverse mod DV directly;
- // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
- y = (y * (2 - x * y % this.DV)) % this.DV; // y == 1/x mod 2^dbits
- // we really want the negative inverse, and -DV < y < DV
- return (y > 0) ? this.DV - y : -y;
-}
-
-// Montgomery reduction
-function Montgomery(m) {
- this.m = m;
- this.mp = m.invDigit();
- this.mpl = this.mp & 0x7fff;
- this.mph = this.mp >> 15;
- this.um = (1 << (m.DB - 15)) - 1;
- this.mt2 = 2 * m.t;
-}
-
-// xR mod m
-function montConvert(x) {
- var r = nbi();
- x.abs().dlShiftTo(this.m.t, r);
- r.divRemTo(this.m, null, r);
- if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r);
- return r;
-}
-
-// x/R mod m
-function montRevert(x) {
- var r = nbi();
- x.copyTo(r);
- this.reduce(r);
- return r;
-}
-
-// x = x/R mod m (HAC 14.32)
-function montReduce(x) {
- while (x.t <= this.mt2) // pad x so am has enough room later
- x[x.t++] = 0;
- for (var i = 0; i < this.m.t; ++i) {
- // faster way of calculating u0 = x[i]*mp mod DV
- var j = x[i] & 0x7fff;
- var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM;
- // use am to combine the multiply-shift-add into one call
- j = i + this.m.t;
- x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
- // propagate carry
- while (x[j] >= x.DV) {
- x[j] -= x.DV;
- x[++j]++;
- }
- }
- x.clamp();
- x.drShiftTo(this.m.t, x);
- if (x.compareTo(this.m) >= 0) x.subTo(this.m, x);
-}
-
-// r = "x^2/R mod m"; x != r
-function montSqrTo(x, r) {
- x.squareTo(r);
- this.reduce(r);
-}
-
-// r = "xy/R mod m"; x,y != r
-function montMulTo(x, y, r) {
- x.multiplyTo(y, r);
- this.reduce(r);
-}
-
-Montgomery.prototype.convert = montConvert;
-Montgomery.prototype.revert = montRevert;
-Montgomery.prototype.reduce = montReduce;
-Montgomery.prototype.mulTo = montMulTo;
-Montgomery.prototype.sqrTo = montSqrTo;
-
-// (protected) true iff this is even
-function bnpIsEven() {
- return ((this.t > 0) ? (this[0] & 1) : this.s) === 0;
-}
-
-// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
-function bnpExp(e, z) {
- if (e > 0xffffffff || e < 1) return BigInteger.ONE;
- var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e) - 1;
- g.copyTo(r);
- while (--i >= 0) {
- z.sqrTo(r, r2);
- if ((e & (1 << i)) > 0) z.mulTo(r2, g, r);
- else {
- var t = r;
- r = r2;
- r2 = t;
- }
- }
- return z.revert(r);
-}
-
-// (public) this^e % m, 0 <= e < 2^32
-function bnModPowInt(e, m) {
- var z;
- if (e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
- return this.exp(e, z);
-}
-
-// Copyright (c) 2005-2009 Tom Wu
-// All Rights Reserved.
-// See "LICENSE" for details.
-
-// Extended JavaScript BN functions, required for RSA private ops.
-
-// Version 1.1: new BigInteger("0", 10) returns "proper" zero
-// Version 1.2: square() API, isProbablePrime fix
-
-//(public)
-function bnClone() {
- var r = nbi();
- this.copyTo(r);
- return r;
-}
-
-//(public) return value as integer
-function bnIntValue() {
- if (this.s < 0) {
- if (this.t == 1) return this[0] - this.DV;
- else if (this.t === 0) return -1;
- }
- else if (this.t == 1) return this[0];
- else if (this.t === 0) return 0;
-// assumes 16 < DB < 32
- return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0];
-}
-
-//(public) return value as byte
-function bnByteValue() {
- return (this.t == 0) ? this.s : (this[0] << 24) >> 24;
-}
-
-//(public) return value as short (assumes DB>=16)
-function bnShortValue() {
- return (this.t == 0) ? this.s : (this[0] << 16) >> 16;
-}
-
-//(protected) return x s.t. r^x < DV
-function bnpChunkSize(r) {
- return Math.floor(Math.LN2 * this.DB / Math.log(r));
-}
-
-//(public) 0 if this === 0, 1 if this > 0
-function bnSigNum() {
- if (this.s < 0) return -1;
- else if (this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
- else return 1;
-}
-
-//(protected) convert to radix string
-function bnpToRadix(b) {
- if (b == null) b = 10;
- if (this.signum() === 0 || b < 2 || b > 36) return "0";
- var cs = this.chunkSize(b);
- var a = Math.pow(b, cs);
- var d = nbv(a), y = nbi(), z = nbi(), r = "";
- this.divRemTo(d, y, z);
- while (y.signum() > 0) {
- r = (a + z.intValue()).toString(b).substr(1) + r;
- y.divRemTo(d, y, z);
- }
- return z.intValue().toString(b) + r;
-}
-
-//(protected) convert from radix string
-function bnpFromRadix(s, b) {
- this.fromInt(0);
- if (b == null) b = 10;
- var cs = this.chunkSize(b);
- var d = Math.pow(b, cs), mi = false, j = 0, w = 0;
- for (var i = 0; i < s.length; ++i) {
- var x = intAt(s, i);
- if (x < 0) {
- if (s.charAt(i) == "-" && this.signum() === 0) mi = true;
- continue;
- }
- w = b * w + x;
- if (++j >= cs) {
- this.dMultiply(d);
- this.dAddOffset(w, 0);
- j = 0;
- w = 0;
- }
- }
- if (j > 0) {
- this.dMultiply(Math.pow(b, j));
- this.dAddOffset(w, 0);
- }
- if (mi) BigInteger.ZERO.subTo(this, this);
-}
-
-//(protected) alternate constructor
-function bnpFromNumber(a, b) {
- if ("number" == typeof b) {
- // new BigInteger(int,int,RNG)
- if (a < 2) this.fromInt(1);
- else {
- this.fromNumber(a);
- if (!this.testBit(a - 1)) // force MSB set
- this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);
- if (this.isEven()) this.dAddOffset(1, 0); // force odd
- while (!this.isProbablePrime(b)) {
- this.dAddOffset(2, 0);
- if (this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a - 1), this);
- }
- }
- } else {
- // new BigInteger(int,RNG)
- var x = crypt.randomBytes((a >> 3) + 1)
- var t = a & 7;
-
- if (t > 0)
- x[0] &= ((1 << t) - 1);
- else
- x[0] = 0;
-
- this.fromByteArray(x);
- }
-}
-
-//(public) convert to bigendian byte array
-function bnToByteArray() {
- var i = this.t, r = new Array();
- r[0] = this.s;
- var p = this.DB - (i * this.DB) % 8, d, k = 0;
- if (i-- > 0) {
- if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p)
- r[k++] = d | (this.s << (this.DB - p));
- while (i >= 0) {
- if (p < 8) {
- d = (this[i] & ((1 << p) - 1)) << (8 - p);
- d |= this[--i] >> (p += this.DB - 8);
- }
- else {
- d = (this[i] >> (p -= 8)) & 0xff;
- if (p <= 0) {
- p += this.DB;
- --i;
- }
- }
- if ((d & 0x80) != 0) d |= -256;
- if (k === 0 && (this.s & 0x80) != (d & 0x80)) ++k;
- if (k > 0 || d != this.s) r[k++] = d;
- }
- }
- return r;
-}
-
-/**
- * return Buffer object
- * @param trim {boolean} slice buffer if first element == 0
- * @returns {Buffer}
- */
-function bnToBuffer(trimOrSize) {
- var res = Buffer.from(this.toByteArray());
- if (trimOrSize === true && res[0] === 0) {
- res = res.slice(1);
- } else if (_.isNumber(trimOrSize)) {
- if (res.length > trimOrSize) {
- for (var i = 0; i < res.length - trimOrSize; i++) {
- if (res[i] !== 0) {
- return null;
- }
- }
- return res.slice(res.length - trimOrSize);
- } else if (res.length < trimOrSize) {
- var padded = Buffer.alloc(trimOrSize);
- padded.fill(0, 0, trimOrSize - res.length);
- res.copy(padded, trimOrSize - res.length);
- return padded;
- }
- }
- return res;
-}
-
-function bnEquals(a) {
- return (this.compareTo(a) == 0);
-}
-function bnMin(a) {
- return (this.compareTo(a) < 0) ? this : a;
-}
-function bnMax(a) {
- return (this.compareTo(a) > 0) ? this : a;
-}
-
-//(protected) r = this op a (bitwise)
-function bnpBitwiseTo(a, op, r) {
- var i, f, m = Math.min(a.t, this.t);
- for (i = 0; i < m; ++i) r[i] = op(this[i], a[i]);
- if (a.t < this.t) {
- f = a.s & this.DM;
- for (i = m; i < this.t; ++i) r[i] = op(this[i], f);
- r.t = this.t;
- }
- else {
- f = this.s & this.DM;
- for (i = m; i < a.t; ++i) r[i] = op(f, a[i]);
- r.t = a.t;
- }
- r.s = op(this.s, a.s);
- r.clamp();
-}
-
-//(public) this & a
-function op_and(x, y) {
- return x & y;
-}
-function bnAnd(a) {
- var r = nbi();
- this.bitwiseTo(a, op_and, r);
- return r;
-}
-
-//(public) this | a
-function op_or(x, y) {
- return x | y;
-}
-function bnOr(a) {
- var r = nbi();
- this.bitwiseTo(a, op_or, r);
- return r;
-}
-
-//(public) this ^ a
-function op_xor(x, y) {
- return x ^ y;
-}
-function bnXor(a) {
- var r = nbi();
- this.bitwiseTo(a, op_xor, r);
- return r;
-}
-
-//(public) this & ~a
-function op_andnot(x, y) {
- return x & ~y;
-}
-function bnAndNot(a) {
- var r = nbi();
- this.bitwiseTo(a, op_andnot, r);
- return r;
-}
-
-//(public) ~this
-function bnNot() {
- var r = nbi();
- for (var i = 0; i < this.t; ++i) r[i] = this.DM & ~this[i];
- r.t = this.t;
- r.s = ~this.s;
- return r;
-}
-
-//(public) this << n
-function bnShiftLeft(n) {
- var r = nbi();
- if (n < 0) this.rShiftTo(-n, r); else this.lShiftTo(n, r);
- return r;
-}
-
-//(public) this >> n
-function bnShiftRight(n) {
- var r = nbi();
- if (n < 0) this.lShiftTo(-n, r); else this.rShiftTo(n, r);
- return r;
-}
-
-//return index of lowest 1-bit in x, x < 2^31
-function lbit(x) {
- if (x === 0) return -1;
- var r = 0;
- if ((x & 0xffff) === 0) {
- x >>= 16;
- r += 16;
- }
- if ((x & 0xff) === 0) {
- x >>= 8;
- r += 8;
- }
- if ((x & 0xf) === 0) {
- x >>= 4;
- r += 4;
- }
- if ((x & 3) === 0) {
- x >>= 2;
- r += 2;
- }
- if ((x & 1) === 0) ++r;
- return r;
-}
-
-//(public) returns index of lowest 1-bit (or -1 if none)
-function bnGetLowestSetBit() {
- for (var i = 0; i < this.t; ++i)
- if (this[i] != 0) return i * this.DB + lbit(this[i]);
- if (this.s < 0) return this.t * this.DB;
- return -1;
-}
-
-//return number of 1 bits in x
-function cbit(x) {
- var r = 0;
- while (x != 0) {
- x &= x - 1;
- ++r;
- }
- return r;
-}
-
-//(public) return number of set bits
-function bnBitCount() {
- var r = 0, x = this.s & this.DM;
- for (var i = 0; i < this.t; ++i) r += cbit(this[i] ^ x);
- return r;
-}
-
-//(public) true iff nth bit is set
-function bnTestBit(n) {
- var j = Math.floor(n / this.DB);
- if (j >= this.t) return (this.s != 0);
- return ((this[j] & (1 << (n % this.DB))) != 0);
-}
-
-//(protected) this op (1<>= this.DB;
- }
- if (a.t < this.t) {
- c += a.s;
- while (i < this.t) {
- c += this[i];
- r[i++] = c & this.DM;
- c >>= this.DB;
- }
- c += this.s;
- }
- else {
- c += this.s;
- while (i < a.t) {
- c += a[i];
- r[i++] = c & this.DM;
- c >>= this.DB;
- }
- c += a.s;
- }
- r.s = (c < 0) ? -1 : 0;
- if (c > 0) r[i++] = c;
- else if (c < -1) r[i++] = this.DV + c;
- r.t = i;
- r.clamp();
-}
-
-//(public) this + a
-function bnAdd(a) {
- var r = nbi();
- this.addTo(a, r);
- return r;
-}
-
-//(public) this - a
-function bnSubtract(a) {
- var r = nbi();
- this.subTo(a, r);
- return r;
-}
-
-//(public) this * a
-function bnMultiply(a) {
- var r = nbi();
- this.multiplyTo(a, r);
- return r;
-}
-
-// (public) this^2
-function bnSquare() {
- var r = nbi();
- this.squareTo(r);
- return r;
-}
-
-//(public) this / a
-function bnDivide(a) {
- var r = nbi();
- this.divRemTo(a, r, null);
- return r;
-}
-
-//(public) this % a
-function bnRemainder(a) {
- var r = nbi();
- this.divRemTo(a, null, r);
- return r;
-}
-
-//(public) [this/a,this%a]
-function bnDivideAndRemainder(a) {
- var q = nbi(), r = nbi();
- this.divRemTo(a, q, r);
- return new Array(q, r);
-}
-
-//(protected) this *= n, this >= 0, 1 < n < DV
-function bnpDMultiply(n) {
- this[this.t] = this.am(0, n - 1, this, 0, 0, this.t);
- ++this.t;
- this.clamp();
-}
-
-//(protected) this += n << w words, this >= 0
-function bnpDAddOffset(n, w) {
- if (n === 0) return;
- while (this.t <= w) this[this.t++] = 0;
- this[w] += n;
- while (this[w] >= this.DV) {
- this[w] -= this.DV;
- if (++w >= this.t) this[this.t++] = 0;
- ++this[w];
- }
-}
-
-//A "null" reducer
-function NullExp() {
-}
-function nNop(x) {
- return x;
-}
-function nMulTo(x, y, r) {
- x.multiplyTo(y, r);
-}
-function nSqrTo(x, r) {
- x.squareTo(r);
-}
-
-NullExp.prototype.convert = nNop;
-NullExp.prototype.revert = nNop;
-NullExp.prototype.mulTo = nMulTo;
-NullExp.prototype.sqrTo = nSqrTo;
-
-//(public) this^e
-function bnPow(e) {
- return this.exp(e, new NullExp());
-}
-
-//(protected) r = lower n words of "this * a", a.t <= n
-//"this" should be the larger one if appropriate.
-function bnpMultiplyLowerTo(a, n, r) {
- var i = Math.min(this.t + a.t, n);
- r.s = 0; // assumes a,this >= 0
- r.t = i;
- while (i > 0) r[--i] = 0;
- var j;
- for (j = r.t - this.t; i < j; ++i) r[i + this.t] = this.am(0, a[i], r, i, 0, this.t);
- for (j = Math.min(a.t, n); i < j; ++i) this.am(0, a[i], r, i, 0, n - i);
- r.clamp();
-}
-
-//(protected) r = "this * a" without lower n words, n > 0
-//"this" should be the larger one if appropriate.
-function bnpMultiplyUpperTo(a, n, r) {
- --n;
- var i = r.t = this.t + a.t - n;
- r.s = 0; // assumes a,this >= 0
- while (--i >= 0) r[i] = 0;
- for (i = Math.max(n - this.t, 0); i < a.t; ++i)
- r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n);
- r.clamp();
- r.drShiftTo(1, r);
-}
-
-//Barrett modular reduction
-function Barrett(m) {
-// setup Barrett
- this.r2 = nbi();
- this.q3 = nbi();
- BigInteger.ONE.dlShiftTo(2 * m.t, this.r2);
- this.mu = this.r2.divide(m);
- this.m = m;
-}
-
-function barrettConvert(x) {
- if (x.s < 0 || x.t > 2 * this.m.t) return x.mod(this.m);
- else if (x.compareTo(this.m) < 0) return x;
- else {
- var r = nbi();
- x.copyTo(r);
- this.reduce(r);
- return r;
- }
-}
-
-function barrettRevert(x) {
- return x;
-}
-
-//x = x mod m (HAC 14.42)
-function barrettReduce(x) {
- x.drShiftTo(this.m.t - 1, this.r2);
- if (x.t > this.m.t + 1) {
- x.t = this.m.t + 1;
- x.clamp();
- }
- this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
- this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2);
- while (x.compareTo(this.r2) < 0) x.dAddOffset(1, this.m.t + 1);
- x.subTo(this.r2, x);
- while (x.compareTo(this.m) >= 0) x.subTo(this.m, x);
-}
-
-//r = x^2 mod m; x != r
-function barrettSqrTo(x, r) {
- x.squareTo(r);
- this.reduce(r);
-}
-
-//r = x*y mod m; x,y != r
-function barrettMulTo(x, y, r) {
- x.multiplyTo(y, r);
- this.reduce(r);
-}
-
-Barrett.prototype.convert = barrettConvert;
-Barrett.prototype.revert = barrettRevert;
-Barrett.prototype.reduce = barrettReduce;
-Barrett.prototype.mulTo = barrettMulTo;
-Barrett.prototype.sqrTo = barrettSqrTo;
-
-//(public) this^e % m (HAC 14.85)
-function bnModPow(e, m) {
- var i = e.bitLength(), k, r = nbv(1), z;
- if (i <= 0) return r;
- else if (i < 18) k = 1;
- else if (i < 48) k = 3;
- else if (i < 144) k = 4;
- else if (i < 768) k = 5;
- else k = 6;
- if (i < 8)
- z = new Classic(m);
- else if (m.isEven())
- z = new Barrett(m);
- else
- z = new Montgomery(m);
-
-// precomputation
- var g = new Array(), n = 3, k1 = k - 1, km = (1 << k) - 1;
- g[1] = z.convert(this);
- if (k > 1) {
- var g2 = nbi();
- z.sqrTo(g[1], g2);
- while (n <= km) {
- g[n] = nbi();
- z.mulTo(g2, g[n - 2], g[n]);
- n += 2;
- }
- }
-
- var j = e.t - 1, w, is1 = true, r2 = nbi(), t;
- i = nbits(e[j]) - 1;
- while (j >= 0) {
- if (i >= k1) w = (e[j] >> (i - k1)) & km;
- else {
- w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i);
- if (j > 0) w |= e[j - 1] >> (this.DB + i - k1);
- }
-
- n = k;
- while ((w & 1) === 0) {
- w >>= 1;
- --n;
- }
- if ((i -= n) < 0) {
- i += this.DB;
- --j;
- }
- if (is1) { // ret == 1, don't bother squaring or multiplying it
- g[w].copyTo(r);
- is1 = false;
- }
- else {
- while (n > 1) {
- z.sqrTo(r, r2);
- z.sqrTo(r2, r);
- n -= 2;
- }
- if (n > 0) z.sqrTo(r, r2); else {
- t = r;
- r = r2;
- r2 = t;
- }
- z.mulTo(r2, g[w], r);
- }
-
- while (j >= 0 && (e[j] & (1 << i)) === 0) {
- z.sqrTo(r, r2);
- t = r;
- r = r2;
- r2 = t;
- if (--i < 0) {
- i = this.DB - 1;
- --j;
- }
- }
- }
- return z.revert(r);
-}
-
-//(public) gcd(this,a) (HAC 14.54)
-function bnGCD(a) {
- var x = (this.s < 0) ? this.negate() : this.clone();
- var y = (a.s < 0) ? a.negate() : a.clone();
- if (x.compareTo(y) < 0) {
- var t = x;
- x = y;
- y = t;
- }
- var i = x.getLowestSetBit(), g = y.getLowestSetBit();
- if (g < 0) return x;
- if (i < g) g = i;
- if (g > 0) {
- x.rShiftTo(g, x);
- y.rShiftTo(g, y);
- }
- while (x.signum() > 0) {
- if ((i = x.getLowestSetBit()) > 0) x.rShiftTo(i, x);
- if ((i = y.getLowestSetBit()) > 0) y.rShiftTo(i, y);
- if (x.compareTo(y) >= 0) {
- x.subTo(y, x);
- x.rShiftTo(1, x);
- }
- else {
- y.subTo(x, y);
- y.rShiftTo(1, y);
- }
- }
- if (g > 0) y.lShiftTo(g, y);
- return y;
-}
-
-//(protected) this % n, n < 2^26
-function bnpModInt(n) {
- if (n <= 0) return 0;
- var d = this.DV % n, r = (this.s < 0) ? n - 1 : 0;
- if (this.t > 0)
- if (d === 0) r = this[0] % n;
- else for (var i = this.t - 1; i >= 0; --i) r = (d * r + this[i]) % n;
- return r;
-}
-
-//(public) 1/this % m (HAC 14.61)
-function bnModInverse(m) {
- var ac = m.isEven();
- if ((this.isEven() && ac) || m.signum() === 0) return BigInteger.ZERO;
- var u = m.clone(), v = this.clone();
- var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
- while (u.signum() != 0) {
- while (u.isEven()) {
- u.rShiftTo(1, u);
- if (ac) {
- if (!a.isEven() || !b.isEven()) {
- a.addTo(this, a);
- b.subTo(m, b);
- }
- a.rShiftTo(1, a);
- }
- else if (!b.isEven()) b.subTo(m, b);
- b.rShiftTo(1, b);
- }
- while (v.isEven()) {
- v.rShiftTo(1, v);
- if (ac) {
- if (!c.isEven() || !d.isEven()) {
- c.addTo(this, c);
- d.subTo(m, d);
- }
- c.rShiftTo(1, c);
- }
- else if (!d.isEven()) d.subTo(m, d);
- d.rShiftTo(1, d);
- }
- if (u.compareTo(v) >= 0) {
- u.subTo(v, u);
- if (ac) a.subTo(c, a);
- b.subTo(d, b);
- }
- else {
- v.subTo(u, v);
- if (ac) c.subTo(a, c);
- d.subTo(b, d);
- }
- }
- if (v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
- if (d.compareTo(m) >= 0) return d.subtract(m);
- if (d.signum() < 0) d.addTo(m, d); else return d;
- if (d.signum() < 0) return d.add(m); else return d;
-}
-
-var lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997];
-var lplim = (1 << 26) / lowprimes[lowprimes.length - 1];
-
-//(public) test primality with certainty >= 1-.5^t
-function bnIsProbablePrime(t) {
- var i, x = this.abs();
- if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
- for (i = 0; i < lowprimes.length; ++i)
- if (x[0] == lowprimes[i]) return true;
- return false;
- }
- if (x.isEven()) return false;
- i = 1;
- while (i < lowprimes.length) {
- var m = lowprimes[i], j = i + 1;
- while (j < lowprimes.length && m < lplim) m *= lowprimes[j++];
- m = x.modInt(m);
- while (i < j) if (m % lowprimes[i++] === 0) return false;
- }
- return x.millerRabin(t);
-}
-
-//(protected) true if probably prime (HAC 4.24, Miller-Rabin)
-function bnpMillerRabin(t) {
- var n1 = this.subtract(BigInteger.ONE);
- var k = n1.getLowestSetBit();
- if (k <= 0) return false;
- var r = n1.shiftRight(k);
- t = (t + 1) >> 1;
- if (t > lowprimes.length) t = lowprimes.length;
- var a = nbi();
- for (var i = 0; i < t; ++i) {
- //Pick bases at random, instead of starting at 2
- a.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);
- var y = a.modPow(r, this);
- if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
- var j = 1;
- while (j++ < k && y.compareTo(n1) != 0) {
- y = y.modPowInt(2, this);
- if (y.compareTo(BigInteger.ONE) === 0) return false;
- }
- if (y.compareTo(n1) != 0) return false;
- }
- }
- return true;
-}
-
-// protected
-BigInteger.prototype.copyTo = bnpCopyTo;
-BigInteger.prototype.fromInt = bnpFromInt;
-BigInteger.prototype.fromString = bnpFromString;
-BigInteger.prototype.fromByteArray = bnpFromByteArray;
-BigInteger.prototype.fromBuffer = bnpFromBuffer;
-BigInteger.prototype.clamp = bnpClamp;
-BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
-BigInteger.prototype.drShiftTo = bnpDRShiftTo;
-BigInteger.prototype.lShiftTo = bnpLShiftTo;
-BigInteger.prototype.rShiftTo = bnpRShiftTo;
-BigInteger.prototype.subTo = bnpSubTo;
-BigInteger.prototype.multiplyTo = bnpMultiplyTo;
-BigInteger.prototype.squareTo = bnpSquareTo;
-BigInteger.prototype.divRemTo = bnpDivRemTo;
-BigInteger.prototype.invDigit = bnpInvDigit;
-BigInteger.prototype.isEven = bnpIsEven;
-BigInteger.prototype.exp = bnpExp;
-
-BigInteger.prototype.chunkSize = bnpChunkSize;
-BigInteger.prototype.toRadix = bnpToRadix;
-BigInteger.prototype.fromRadix = bnpFromRadix;
-BigInteger.prototype.fromNumber = bnpFromNumber;
-BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
-BigInteger.prototype.changeBit = bnpChangeBit;
-BigInteger.prototype.addTo = bnpAddTo;
-BigInteger.prototype.dMultiply = bnpDMultiply;
-BigInteger.prototype.dAddOffset = bnpDAddOffset;
-BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
-BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
-BigInteger.prototype.modInt = bnpModInt;
-BigInteger.prototype.millerRabin = bnpMillerRabin;
-
-
-// public
-BigInteger.prototype.toString = bnToString;
-BigInteger.prototype.negate = bnNegate;
-BigInteger.prototype.abs = bnAbs;
-BigInteger.prototype.compareTo = bnCompareTo;
-BigInteger.prototype.bitLength = bnBitLength;
-BigInteger.prototype.mod = bnMod;
-BigInteger.prototype.modPowInt = bnModPowInt;
-
-BigInteger.prototype.clone = bnClone;
-BigInteger.prototype.intValue = bnIntValue;
-BigInteger.prototype.byteValue = bnByteValue;
-BigInteger.prototype.shortValue = bnShortValue;
-BigInteger.prototype.signum = bnSigNum;
-BigInteger.prototype.toByteArray = bnToByteArray;
-BigInteger.prototype.toBuffer = bnToBuffer;
-BigInteger.prototype.equals = bnEquals;
-BigInteger.prototype.min = bnMin;
-BigInteger.prototype.max = bnMax;
-BigInteger.prototype.and = bnAnd;
-BigInteger.prototype.or = bnOr;
-BigInteger.prototype.xor = bnXor;
-BigInteger.prototype.andNot = bnAndNot;
-BigInteger.prototype.not = bnNot;
-BigInteger.prototype.shiftLeft = bnShiftLeft;
-BigInteger.prototype.shiftRight = bnShiftRight;
-BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
-BigInteger.prototype.bitCount = bnBitCount;
-BigInteger.prototype.testBit = bnTestBit;
-BigInteger.prototype.setBit = bnSetBit;
-BigInteger.prototype.clearBit = bnClearBit;
-BigInteger.prototype.flipBit = bnFlipBit;
-BigInteger.prototype.add = bnAdd;
-BigInteger.prototype.subtract = bnSubtract;
-BigInteger.prototype.multiply = bnMultiply;
-BigInteger.prototype.divide = bnDivide;
-BigInteger.prototype.remainder = bnRemainder;
-BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
-BigInteger.prototype.modPow = bnModPow;
-BigInteger.prototype.modInverse = bnModInverse;
-BigInteger.prototype.pow = bnPow;
-BigInteger.prototype.gcd = bnGCD;
-BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
-BigInteger.int2char = int2char;
-
-// "constants"
-BigInteger.ZERO = nbv(0);
-BigInteger.ONE = nbv(1);
-
-// JSBN-specific extension
-BigInteger.prototype.square = bnSquare;
-
-//BigInteger interfaces not implemented in jsbn:
-
-//BigInteger(int signum, byte[] magnitude)
-//double doubleValue()
-//float floatValue()
-//int hashCode()
-//long longValue()
-//static BigInteger valueOf(long val)
-
+/*
+ * Basic JavaScript BN library - subset useful for RSA encryption.
+ *
+ * Copyright (c) 2003-2005 Tom Wu
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following condition applies:
+ *
+ * All redistributions must retain an intact copy of this copyright notice
+ * and disclaimer.
+ */
+
+/*
+ * Added Node.js Buffers support
+ * 2014 rzcoder
+ */
+
+var crypt = require('crypto');
+var _ = require('../utils')._;
+
+// Bits per digit
+var dbits;
+
+// JavaScript engine analysis
+var canary = 0xdeadbeefcafe;
+var j_lm = ((canary & 0xffffff) == 0xefcafe);
+
+// (public) Constructor
+function BigInteger(a, b) {
+ if (a != null) {
+ if ("number" == typeof a) {
+ this.fromNumber(a, b);
+ } else if (Buffer.isBuffer(a)) {
+ this.fromBuffer(a);
+ } else if (b == null && "string" != typeof a) {
+ this.fromByteArray(a);
+ } else {
+ this.fromString(a, b);
+ }
+ }
+}
+
+// return new, unset BigInteger
+function nbi() {
+ return new BigInteger(null);
+}
+
+// am: Compute w_j += (x*this_i), propagate carries,
+// c is initial carry, returns final carry.
+// c < 3*dvalue, x < 2*dvalue, this_i < dvalue
+// We need to select the fastest one that works in this environment.
+
+// am1: use a single mult and divide to get the high bits,
+// max digit bits should be 26 because
+// max internal value = 2*dvalue^2-2*dvalue (< 2^53)
+function am1(i, x, w, j, c, n) {
+ while (--n >= 0) {
+ var v = x * this[i++] + w[j] + c;
+ c = Math.floor(v / 0x4000000);
+ w[j++] = v & 0x3ffffff;
+ }
+ return c;
+}
+// am2 avoids a big mult-and-extract completely.
+// Max digit bits should be <= 30 because we do bitwise ops
+// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
+function am2(i, x, w, j, c, n) {
+ var xl = x & 0x7fff, xh = x >> 15;
+ while (--n >= 0) {
+ var l = this[i] & 0x7fff;
+ var h = this[i++] >> 15;
+ var m = xh * l + h * xl;
+ l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff);
+ c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
+ w[j++] = l & 0x3fffffff;
+ }
+ return c;
+}
+// Alternately, set max digit bits to 28 since some
+// browsers slow down when dealing with 32-bit numbers.
+function am3(i, x, w, j, c, n) {
+ var xl = x & 0x3fff, xh = x >> 14;
+ while (--n >= 0) {
+ var l = this[i] & 0x3fff;
+ var h = this[i++] >> 14;
+ var m = xh * l + h * xl;
+ l = xl * l + ((m & 0x3fff) << 14) + w[j] + c;
+ c = (l >> 28) + (m >> 14) + xh * h;
+ w[j++] = l & 0xfffffff;
+ }
+ return c;
+}
+
+// We need to select the fastest one that works in this environment.
+//if (j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
+// BigInteger.prototype.am = am2;
+// dbits = 30;
+//} else if (j_lm && (navigator.appName != "Netscape")) {
+// BigInteger.prototype.am = am1;
+// dbits = 26;
+//} else { // Mozilla/Netscape seems to prefer am3
+// BigInteger.prototype.am = am3;
+// dbits = 28;
+//}
+
+// For node.js, we pick am3 with max dbits to 28.
+BigInteger.prototype.am = am3;
+dbits = 28;
+
+BigInteger.prototype.DB = dbits;
+BigInteger.prototype.DM = ((1 << dbits) - 1);
+BigInteger.prototype.DV = (1 << dbits);
+
+var BI_FP = 52;
+BigInteger.prototype.FV = Math.pow(2, BI_FP);
+BigInteger.prototype.F1 = BI_FP - dbits;
+BigInteger.prototype.F2 = 2 * dbits - BI_FP;
+
+// Digit conversions
+var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
+var BI_RC = new Array();
+var rr, vv;
+rr = "0".charCodeAt(0);
+for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
+rr = "a".charCodeAt(0);
+for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
+rr = "A".charCodeAt(0);
+for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
+
+function int2char(n) {
+ return BI_RM.charAt(n);
+}
+function intAt(s, i) {
+ var c = BI_RC[s.charCodeAt(i)];
+ return (c == null) ? -1 : c;
+}
+
+// (protected) copy this to r
+function bnpCopyTo(r) {
+ for (var i = this.t - 1; i >= 0; --i) r[i] = this[i];
+ r.t = this.t;
+ r.s = this.s;
+}
+
+// (protected) set from integer value x, -DV <= x < DV
+function bnpFromInt(x) {
+ this.t = 1;
+ this.s = (x < 0) ? -1 : 0;
+ if (x > 0) this[0] = x;
+ else if (x < -1) this[0] = x + DV;
+ else this.t = 0;
+}
+
+// return bigint initialized to value
+function nbv(i) {
+ var r = nbi();
+ r.fromInt(i);
+ return r;
+}
+
+// (protected) set from string and radix
+function bnpFromString(data, radix, unsigned) {
+ var k;
+ switch (radix) {
+ case 2:
+ k = 1;
+ break;
+ case 4:
+ k = 2;
+ break;
+ case 8:
+ k = 3;
+ break;
+ case 16:
+ k = 4;
+ break;
+ case 32:
+ k = 5;
+ break;
+ case 256:
+ k = 8;
+ break;
+ default:
+ this.fromRadix(data, radix);
+ return;
+ }
+
+ this.t = 0;
+ this.s = 0;
+
+ var i = data.length;
+ var mi = false;
+ var sh = 0;
+
+ while (--i >= 0) {
+ var x = (k == 8) ? data[i] & 0xff : intAt(data, i);
+ if (x < 0) {
+ if (data.charAt(i) == "-") mi = true;
+ continue;
+ }
+ mi = false;
+ if (sh === 0)
+ this[this.t++] = x;
+ else if (sh + k > this.DB) {
+ this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;
+ this[this.t++] = (x >> (this.DB - sh));
+ }
+ else
+ this[this.t - 1] |= x << sh;
+ sh += k;
+ if (sh >= this.DB) sh -= this.DB;
+ }
+ if ((!unsigned) && k == 8 && (data[0] & 0x80) != 0) {
+ this.s = -1;
+ if (sh > 0) this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh;
+ }
+ this.clamp();
+ if (mi) BigInteger.ZERO.subTo(this, this);
+}
+
+function bnpFromByteArray(a, unsigned) {
+ this.fromString(a, 256, unsigned)
+}
+
+function bnpFromBuffer(a) {
+ this.fromString(a, 256, true)
+}
+
+// (protected) clamp off excess high words
+function bnpClamp() {
+ var c = this.s & this.DM;
+ while (this.t > 0 && this[this.t - 1] == c) --this.t;
+}
+
+// (public) return string representation in given radix
+function bnToString(b) {
+ if (this.s < 0) return "-" + this.negate().toString(b);
+ var k;
+ if (b == 16) k = 4;
+ else if (b == 8) k = 3;
+ else if (b == 2) k = 1;
+ else if (b == 32) k = 5;
+ else if (b == 4) k = 2;
+ else return this.toRadix(b);
+ var km = (1 << k) - 1, d, m = false, r = "", i = this.t;
+ var p = this.DB - (i * this.DB) % k;
+ if (i-- > 0) {
+ if (p < this.DB && (d = this[i] >> p) > 0) {
+ m = true;
+ r = int2char(d);
+ }
+ while (i >= 0) {
+ if (p < k) {
+ d = (this[i] & ((1 << p) - 1)) << (k - p);
+ d |= this[--i] >> (p += this.DB - k);
+ }
+ else {
+ d = (this[i] >> (p -= k)) & km;
+ if (p <= 0) {
+ p += this.DB;
+ --i;
+ }
+ }
+ if (d > 0) m = true;
+ if (m) r += int2char(d);
+ }
+ }
+ return m ? r : "0";
+}
+
+// (public) -this
+function bnNegate() {
+ var r = nbi();
+ BigInteger.ZERO.subTo(this, r);
+ return r;
+}
+
+// (public) |this|
+function bnAbs() {
+ return (this.s < 0) ? this.negate() : this;
+}
+
+// (public) return + if this > a, - if this < a, 0 if equal
+function bnCompareTo(a) {
+ var r = this.s - a.s;
+ if (r != 0) return r;
+ var i = this.t;
+ r = i - a.t;
+ if (r != 0) return (this.s < 0) ? -r : r;
+ while (--i >= 0) if ((r = this[i] - a[i]) != 0) return r;
+ return 0;
+}
+
+// returns bit length of the integer x
+function nbits(x) {
+ var r = 1, t;
+ if ((t = x >>> 16) != 0) {
+ x = t;
+ r += 16;
+ }
+ if ((t = x >> 8) != 0) {
+ x = t;
+ r += 8;
+ }
+ if ((t = x >> 4) != 0) {
+ x = t;
+ r += 4;
+ }
+ if ((t = x >> 2) != 0) {
+ x = t;
+ r += 2;
+ }
+ if ((t = x >> 1) != 0) {
+ x = t;
+ r += 1;
+ }
+ return r;
+}
+
+// (public) return the number of bits in "this"
+function bnBitLength() {
+ if (this.t <= 0) return 0;
+ return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM));
+}
+
+// (protected) r = this << n*DB
+function bnpDLShiftTo(n, r) {
+ var i;
+ for (i = this.t - 1; i >= 0; --i) r[i + n] = this[i];
+ for (i = n - 1; i >= 0; --i) r[i] = 0;
+ r.t = this.t + n;
+ r.s = this.s;
+}
+
+// (protected) r = this >> n*DB
+function bnpDRShiftTo(n, r) {
+ for (var i = n; i < this.t; ++i) r[i - n] = this[i];
+ r.t = Math.max(this.t - n, 0);
+ r.s = this.s;
+}
+
+// (protected) r = this << n
+function bnpLShiftTo(n, r) {
+ var bs = n % this.DB;
+ var cbs = this.DB - bs;
+ var bm = (1 << cbs) - 1;
+ var ds = Math.floor(n / this.DB), c = (this.s << bs) & this.DM, i;
+ for (i = this.t - 1; i >= 0; --i) {
+ r[i + ds + 1] = (this[i] >> cbs) | c;
+ c = (this[i] & bm) << bs;
+ }
+ for (i = ds - 1; i >= 0; --i) r[i] = 0;
+ r[ds] = c;
+ r.t = this.t + ds + 1;
+ r.s = this.s;
+ r.clamp();
+}
+
+// (protected) r = this >> n
+function bnpRShiftTo(n, r) {
+ r.s = this.s;
+ var ds = Math.floor(n / this.DB);
+ if (ds >= this.t) {
+ r.t = 0;
+ return;
+ }
+ var bs = n % this.DB;
+ var cbs = this.DB - bs;
+ var bm = (1 << bs) - 1;
+ r[0] = this[ds] >> bs;
+ for (var i = ds + 1; i < this.t; ++i) {
+ r[i - ds - 1] |= (this[i] & bm) << cbs;
+ r[i - ds] = this[i] >> bs;
+ }
+ if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs;
+ r.t = this.t - ds;
+ r.clamp();
+}
+
+// (protected) r = this - a
+function bnpSubTo(a, r) {
+ var i = 0, c = 0, m = Math.min(a.t, this.t);
+ while (i < m) {
+ c += this[i] - a[i];
+ r[i++] = c & this.DM;
+ c >>= this.DB;
+ }
+ if (a.t < this.t) {
+ c -= a.s;
+ while (i < this.t) {
+ c += this[i];
+ r[i++] = c & this.DM;
+ c >>= this.DB;
+ }
+ c += this.s;
+ }
+ else {
+ c += this.s;
+ while (i < a.t) {
+ c -= a[i];
+ r[i++] = c & this.DM;
+ c >>= this.DB;
+ }
+ c -= a.s;
+ }
+ r.s = (c < 0) ? -1 : 0;
+ if (c < -1) r[i++] = this.DV + c;
+ else if (c > 0) r[i++] = c;
+ r.t = i;
+ r.clamp();
+}
+
+// (protected) r = this * a, r != this,a (HAC 14.12)
+// "this" should be the larger one if appropriate.
+function bnpMultiplyTo(a, r) {
+ var x = this.abs(), y = a.abs();
+ var i = x.t;
+ r.t = i + y.t;
+ while (--i >= 0) r[i] = 0;
+ for (i = 0; i < y.t; ++i) r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);
+ r.s = 0;
+ r.clamp();
+ if (this.s != a.s) BigInteger.ZERO.subTo(r, r);
+}
+
+// (protected) r = this^2, r != this (HAC 14.16)
+function bnpSquareTo(r) {
+ var x = this.abs();
+ var i = r.t = 2 * x.t;
+ while (--i >= 0) r[i] = 0;
+ for (i = 0; i < x.t - 1; ++i) {
+ var c = x.am(i, x[i], r, 2 * i, 0, 1);
+ if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
+ r[i + x.t] -= x.DV;
+ r[i + x.t + 1] = 1;
+ }
+ }
+ if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);
+ r.s = 0;
+ r.clamp();
+}
+
+// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
+// r != q, this != m. q or r may be null.
+function bnpDivRemTo(m, q, r) {
+ var pm = m.abs();
+ if (pm.t <= 0) return;
+ var pt = this.abs();
+ if (pt.t < pm.t) {
+ if (q != null) q.fromInt(0);
+ if (r != null) this.copyTo(r);
+ return;
+ }
+ if (r == null) r = nbi();
+ var y = nbi(), ts = this.s, ms = m.s;
+ var nsh = this.DB - nbits(pm[pm.t - 1]); // normalize modulus
+ if (nsh > 0) {
+ pm.lShiftTo(nsh, y);
+ pt.lShiftTo(nsh, r);
+ }
+ else {
+ pm.copyTo(y);
+ pt.copyTo(r);
+ }
+ var ys = y.t;
+ var y0 = y[ys - 1];
+ if (y0 === 0) return;
+ var yt = y0 * (1 << this.F1) + ((ys > 1) ? y[ys - 2] >> this.F2 : 0);
+ var d1 = this.FV / yt, d2 = (1 << this.F1) / yt, e = 1 << this.F2;
+ var i = r.t, j = i - ys, t = (q == null) ? nbi() : q;
+ y.dlShiftTo(j, t);
+ if (r.compareTo(t) >= 0) {
+ r[r.t++] = 1;
+ r.subTo(t, r);
+ }
+ BigInteger.ONE.dlShiftTo(ys, t);
+ t.subTo(y, y); // "negative" y so we can replace sub with am later
+ while (y.t < ys) y[y.t++] = 0;
+ while (--j >= 0) {
+ // Estimate quotient digit
+ var qd = (r[--i] == y0) ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);
+ if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) { // Try it out
+ y.dlShiftTo(j, t);
+ r.subTo(t, r);
+ while (r[i] < --qd) r.subTo(t, r);
+ }
+ }
+ if (q != null) {
+ r.drShiftTo(ys, q);
+ if (ts != ms) BigInteger.ZERO.subTo(q, q);
+ }
+ r.t = ys;
+ r.clamp();
+ if (nsh > 0) r.rShiftTo(nsh, r); // Denormalize remainder
+ if (ts < 0) BigInteger.ZERO.subTo(r, r);
+}
+
+// (public) this mod a
+function bnMod(a) {
+ var r = nbi();
+ this.abs().divRemTo(a, null, r);
+ if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r);
+ return r;
+}
+
+// Modular reduction using "classic" algorithm
+function Classic(m) {
+ this.m = m;
+}
+function cConvert(x) {
+ if (x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
+ else return x;
+}
+function cRevert(x) {
+ return x;
+}
+function cReduce(x) {
+ x.divRemTo(this.m, null, x);
+}
+function cMulTo(x, y, r) {
+ x.multiplyTo(y, r);
+ this.reduce(r);
+}
+function cSqrTo(x, r) {
+ x.squareTo(r);
+ this.reduce(r);
+}
+
+Classic.prototype.convert = cConvert;
+Classic.prototype.revert = cRevert;
+Classic.prototype.reduce = cReduce;
+Classic.prototype.mulTo = cMulTo;
+Classic.prototype.sqrTo = cSqrTo;
+
+// (protected) return "-1/this % 2^DB"; useful for Mont. reduction
+// justification:
+// xy == 1 (mod m)
+// xy = 1+km
+// xy(2-xy) = (1+km)(1-km)
+// x[y(2-xy)] = 1-k^2m^2
+// x[y(2-xy)] == 1 (mod m^2)
+// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
+// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
+// JS multiply "overflows" differently from C/C++, so care is needed here.
+function bnpInvDigit() {
+ if (this.t < 1) return 0;
+ var x = this[0];
+ if ((x & 1) === 0) return 0;
+ var y = x & 3; // y == 1/x mod 2^2
+ y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
+ y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
+ y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
+ // last step - calculate inverse mod DV directly;
+ // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
+ y = (y * (2 - x * y % this.DV)) % this.DV; // y == 1/x mod 2^dbits
+ // we really want the negative inverse, and -DV < y < DV
+ return (y > 0) ? this.DV - y : -y;
+}
+
+// Montgomery reduction
+function Montgomery(m) {
+ this.m = m;
+ this.mp = m.invDigit();
+ this.mpl = this.mp & 0x7fff;
+ this.mph = this.mp >> 15;
+ this.um = (1 << (m.DB - 15)) - 1;
+ this.mt2 = 2 * m.t;
+}
+
+// xR mod m
+function montConvert(x) {
+ var r = nbi();
+ x.abs().dlShiftTo(this.m.t, r);
+ r.divRemTo(this.m, null, r);
+ if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r);
+ return r;
+}
+
+// x/R mod m
+function montRevert(x) {
+ var r = nbi();
+ x.copyTo(r);
+ this.reduce(r);
+ return r;
+}
+
+// x = x/R mod m (HAC 14.32)
+function montReduce(x) {
+ while (x.t <= this.mt2) // pad x so am has enough room later
+ x[x.t++] = 0;
+ for (var i = 0; i < this.m.t; ++i) {
+ // faster way of calculating u0 = x[i]*mp mod DV
+ var j = x[i] & 0x7fff;
+ var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM;
+ // use am to combine the multiply-shift-add into one call
+ j = i + this.m.t;
+ x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
+ // propagate carry
+ while (x[j] >= x.DV) {
+ x[j] -= x.DV;
+ x[++j]++;
+ }
+ }
+ x.clamp();
+ x.drShiftTo(this.m.t, x);
+ if (x.compareTo(this.m) >= 0) x.subTo(this.m, x);
+}
+
+// r = "x^2/R mod m"; x != r
+function montSqrTo(x, r) {
+ x.squareTo(r);
+ this.reduce(r);
+}
+
+// r = "xy/R mod m"; x,y != r
+function montMulTo(x, y, r) {
+ x.multiplyTo(y, r);
+ this.reduce(r);
+}
+
+Montgomery.prototype.convert = montConvert;
+Montgomery.prototype.revert = montRevert;
+Montgomery.prototype.reduce = montReduce;
+Montgomery.prototype.mulTo = montMulTo;
+Montgomery.prototype.sqrTo = montSqrTo;
+
+// (protected) true iff this is even
+function bnpIsEven() {
+ return ((this.t > 0) ? (this[0] & 1) : this.s) === 0;
+}
+
+// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
+function bnpExp(e, z) {
+ if (e > 0xffffffff || e < 1) return BigInteger.ONE;
+ var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e) - 1;
+ g.copyTo(r);
+ while (--i >= 0) {
+ z.sqrTo(r, r2);
+ if ((e & (1 << i)) > 0) z.mulTo(r2, g, r);
+ else {
+ var t = r;
+ r = r2;
+ r2 = t;
+ }
+ }
+ return z.revert(r);
+}
+
+// (public) this^e % m, 0 <= e < 2^32
+function bnModPowInt(e, m) {
+ var z;
+ if (e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
+ return this.exp(e, z);
+}
+
+// Copyright (c) 2005-2009 Tom Wu
+// All Rights Reserved.
+// See "LICENSE" for details.
+
+// Extended JavaScript BN functions, required for RSA private ops.
+
+// Version 1.1: new BigInteger("0", 10) returns "proper" zero
+// Version 1.2: square() API, isProbablePrime fix
+
+//(public)
+function bnClone() {
+ var r = nbi();
+ this.copyTo(r);
+ return r;
+}
+
+//(public) return value as integer
+function bnIntValue() {
+ if (this.s < 0) {
+ if (this.t == 1) return this[0] - this.DV;
+ else if (this.t === 0) return -1;
+ }
+ else if (this.t == 1) return this[0];
+ else if (this.t === 0) return 0;
+// assumes 16 < DB < 32
+ return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0];
+}
+
+//(public) return value as byte
+function bnByteValue() {
+ return (this.t == 0) ? this.s : (this[0] << 24) >> 24;
+}
+
+//(public) return value as short (assumes DB>=16)
+function bnShortValue() {
+ return (this.t == 0) ? this.s : (this[0] << 16) >> 16;
+}
+
+//(protected) return x s.t. r^x < DV
+function bnpChunkSize(r) {
+ return Math.floor(Math.LN2 * this.DB / Math.log(r));
+}
+
+//(public) 0 if this === 0, 1 if this > 0
+function bnSigNum() {
+ if (this.s < 0) return -1;
+ else if (this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
+ else return 1;
+}
+
+//(protected) convert to radix string
+function bnpToRadix(b) {
+ if (b == null) b = 10;
+ if (this.signum() === 0 || b < 2 || b > 36) return "0";
+ var cs = this.chunkSize(b);
+ var a = Math.pow(b, cs);
+ var d = nbv(a), y = nbi(), z = nbi(), r = "";
+ this.divRemTo(d, y, z);
+ while (y.signum() > 0) {
+ r = (a + z.intValue()).toString(b).substr(1) + r;
+ y.divRemTo(d, y, z);
+ }
+ return z.intValue().toString(b) + r;
+}
+
+//(protected) convert from radix string
+function bnpFromRadix(s, b) {
+ this.fromInt(0);
+ if (b == null) b = 10;
+ var cs = this.chunkSize(b);
+ var d = Math.pow(b, cs), mi = false, j = 0, w = 0;
+ for (var i = 0; i < s.length; ++i) {
+ var x = intAt(s, i);
+ if (x < 0) {
+ if (s.charAt(i) == "-" && this.signum() === 0) mi = true;
+ continue;
+ }
+ w = b * w + x;
+ if (++j >= cs) {
+ this.dMultiply(d);
+ this.dAddOffset(w, 0);
+ j = 0;
+ w = 0;
+ }
+ }
+ if (j > 0) {
+ this.dMultiply(Math.pow(b, j));
+ this.dAddOffset(w, 0);
+ }
+ if (mi) BigInteger.ZERO.subTo(this, this);
+}
+
+//(protected) alternate constructor
+function bnpFromNumber(a, b) {
+ if ("number" == typeof b) {
+ // new BigInteger(int,int,RNG)
+ if (a < 2) this.fromInt(1);
+ else {
+ this.fromNumber(a);
+ if (!this.testBit(a - 1)) // force MSB set
+ this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);
+ if (this.isEven()) this.dAddOffset(1, 0); // force odd
+ while (!this.isProbablePrime(b)) {
+ this.dAddOffset(2, 0);
+ if (this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a - 1), this);
+ }
+ }
+ } else {
+ // new BigInteger(int,RNG)
+ var x = crypt.randomBytes((a >> 3) + 1)
+ var t = a & 7;
+
+ if (t > 0)
+ x[0] &= ((1 << t) - 1);
+ else
+ x[0] = 0;
+
+ this.fromByteArray(x);
+ }
+}
+
+//(public) convert to bigendian byte array
+function bnToByteArray() {
+ var i = this.t, r = new Array();
+ r[0] = this.s;
+ var p = this.DB - (i * this.DB) % 8, d, k = 0;
+ if (i-- > 0) {
+ if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p)
+ r[k++] = d | (this.s << (this.DB - p));
+ while (i >= 0) {
+ if (p < 8) {
+ d = (this[i] & ((1 << p) - 1)) << (8 - p);
+ d |= this[--i] >> (p += this.DB - 8);
+ }
+ else {
+ d = (this[i] >> (p -= 8)) & 0xff;
+ if (p <= 0) {
+ p += this.DB;
+ --i;
+ }
+ }
+ if ((d & 0x80) != 0) d |= -256;
+ if (k === 0 && (this.s & 0x80) != (d & 0x80)) ++k;
+ if (k > 0 || d != this.s) r[k++] = d;
+ }
+ }
+ return r;
+}
+
+/**
+ * return Buffer object
+ * @param trim {boolean} slice buffer if first element == 0
+ * @returns {Buffer}
+ */
+function bnToBuffer(trimOrSize) {
+ var res = Buffer.from(this.toByteArray());
+ if (trimOrSize === true && res[0] === 0) {
+ res = res.slice(1);
+ } else if (_.isNumber(trimOrSize)) {
+ if (res.length > trimOrSize) {
+ for (var i = 0; i < res.length - trimOrSize; i++) {
+ if (res[i] !== 0) {
+ return null;
+ }
+ }
+ return res.slice(res.length - trimOrSize);
+ } else if (res.length < trimOrSize) {
+ var padded = Buffer.alloc(trimOrSize);
+ padded.fill(0, 0, trimOrSize - res.length);
+ res.copy(padded, trimOrSize - res.length);
+ return padded;
+ }
+ }
+ return res;
+}
+
+function bnEquals(a) {
+ return (this.compareTo(a) == 0);
+}
+function bnMin(a) {
+ return (this.compareTo(a) < 0) ? this : a;
+}
+function bnMax(a) {
+ return (this.compareTo(a) > 0) ? this : a;
+}
+
+//(protected) r = this op a (bitwise)
+function bnpBitwiseTo(a, op, r) {
+ var i, f, m = Math.min(a.t, this.t);
+ for (i = 0; i < m; ++i) r[i] = op(this[i], a[i]);
+ if (a.t < this.t) {
+ f = a.s & this.DM;
+ for (i = m; i < this.t; ++i) r[i] = op(this[i], f);
+ r.t = this.t;
+ }
+ else {
+ f = this.s & this.DM;
+ for (i = m; i < a.t; ++i) r[i] = op(f, a[i]);
+ r.t = a.t;
+ }
+ r.s = op(this.s, a.s);
+ r.clamp();
+}
+
+//(public) this & a
+function op_and(x, y) {
+ return x & y;
+}
+function bnAnd(a) {
+ var r = nbi();
+ this.bitwiseTo(a, op_and, r);
+ return r;
+}
+
+//(public) this | a
+function op_or(x, y) {
+ return x | y;
+}
+function bnOr(a) {
+ var r = nbi();
+ this.bitwiseTo(a, op_or, r);
+ return r;
+}
+
+//(public) this ^ a
+function op_xor(x, y) {
+ return x ^ y;
+}
+function bnXor(a) {
+ var r = nbi();
+ this.bitwiseTo(a, op_xor, r);
+ return r;
+}
+
+//(public) this & ~a
+function op_andnot(x, y) {
+ return x & ~y;
+}
+function bnAndNot(a) {
+ var r = nbi();
+ this.bitwiseTo(a, op_andnot, r);
+ return r;
+}
+
+//(public) ~this
+function bnNot() {
+ var r = nbi();
+ for (var i = 0; i < this.t; ++i) r[i] = this.DM & ~this[i];
+ r.t = this.t;
+ r.s = ~this.s;
+ return r;
+}
+
+//(public) this << n
+function bnShiftLeft(n) {
+ var r = nbi();
+ if (n < 0) this.rShiftTo(-n, r); else this.lShiftTo(n, r);
+ return r;
+}
+
+//(public) this >> n
+function bnShiftRight(n) {
+ var r = nbi();
+ if (n < 0) this.lShiftTo(-n, r); else this.rShiftTo(n, r);
+ return r;
+}
+
+//return index of lowest 1-bit in x, x < 2^31
+function lbit(x) {
+ if (x === 0) return -1;
+ var r = 0;
+ if ((x & 0xffff) === 0) {
+ x >>= 16;
+ r += 16;
+ }
+ if ((x & 0xff) === 0) {
+ x >>= 8;
+ r += 8;
+ }
+ if ((x & 0xf) === 0) {
+ x >>= 4;
+ r += 4;
+ }
+ if ((x & 3) === 0) {
+ x >>= 2;
+ r += 2;
+ }
+ if ((x & 1) === 0) ++r;
+ return r;
+}
+
+//(public) returns index of lowest 1-bit (or -1 if none)
+function bnGetLowestSetBit() {
+ for (var i = 0; i < this.t; ++i)
+ if (this[i] != 0) return i * this.DB + lbit(this[i]);
+ if (this.s < 0) return this.t * this.DB;
+ return -1;
+}
+
+//return number of 1 bits in x
+function cbit(x) {
+ var r = 0;
+ while (x != 0) {
+ x &= x - 1;
+ ++r;
+ }
+ return r;
+}
+
+//(public) return number of set bits
+function bnBitCount() {
+ var r = 0, x = this.s & this.DM;
+ for (var i = 0; i < this.t; ++i) r += cbit(this[i] ^ x);
+ return r;
+}
+
+//(public) true iff nth bit is set
+function bnTestBit(n) {
+ var j = Math.floor(n / this.DB);
+ if (j >= this.t) return (this.s != 0);
+ return ((this[j] & (1 << (n % this.DB))) != 0);
+}
+
+//(protected) this op (1<>= this.DB;
+ }
+ if (a.t < this.t) {
+ c += a.s;
+ while (i < this.t) {
+ c += this[i];
+ r[i++] = c & this.DM;
+ c >>= this.DB;
+ }
+ c += this.s;
+ }
+ else {
+ c += this.s;
+ while (i < a.t) {
+ c += a[i];
+ r[i++] = c & this.DM;
+ c >>= this.DB;
+ }
+ c += a.s;
+ }
+ r.s = (c < 0) ? -1 : 0;
+ if (c > 0) r[i++] = c;
+ else if (c < -1) r[i++] = this.DV + c;
+ r.t = i;
+ r.clamp();
+}
+
+//(public) this + a
+function bnAdd(a) {
+ var r = nbi();
+ this.addTo(a, r);
+ return r;
+}
+
+//(public) this - a
+function bnSubtract(a) {
+ var r = nbi();
+ this.subTo(a, r);
+ return r;
+}
+
+//(public) this * a
+function bnMultiply(a) {
+ var r = nbi();
+ this.multiplyTo(a, r);
+ return r;
+}
+
+// (public) this^2
+function bnSquare() {
+ var r = nbi();
+ this.squareTo(r);
+ return r;
+}
+
+//(public) this / a
+function bnDivide(a) {
+ var r = nbi();
+ this.divRemTo(a, r, null);
+ return r;
+}
+
+//(public) this % a
+function bnRemainder(a) {
+ var r = nbi();
+ this.divRemTo(a, null, r);
+ return r;
+}
+
+//(public) [this/a,this%a]
+function bnDivideAndRemainder(a) {
+ var q = nbi(), r = nbi();
+ this.divRemTo(a, q, r);
+ return new Array(q, r);
+}
+
+//(protected) this *= n, this >= 0, 1 < n < DV
+function bnpDMultiply(n) {
+ this[this.t] = this.am(0, n - 1, this, 0, 0, this.t);
+ ++this.t;
+ this.clamp();
+}
+
+//(protected) this += n << w words, this >= 0
+function bnpDAddOffset(n, w) {
+ if (n === 0) return;
+ while (this.t <= w) this[this.t++] = 0;
+ this[w] += n;
+ while (this[w] >= this.DV) {
+ this[w] -= this.DV;
+ if (++w >= this.t) this[this.t++] = 0;
+ ++this[w];
+ }
+}
+
+//A "null" reducer
+function NullExp() {
+}
+function nNop(x) {
+ return x;
+}
+function nMulTo(x, y, r) {
+ x.multiplyTo(y, r);
+}
+function nSqrTo(x, r) {
+ x.squareTo(r);
+}
+
+NullExp.prototype.convert = nNop;
+NullExp.prototype.revert = nNop;
+NullExp.prototype.mulTo = nMulTo;
+NullExp.prototype.sqrTo = nSqrTo;
+
+//(public) this^e
+function bnPow(e) {
+ return this.exp(e, new NullExp());
+}
+
+//(protected) r = lower n words of "this * a", a.t <= n
+//"this" should be the larger one if appropriate.
+function bnpMultiplyLowerTo(a, n, r) {
+ var i = Math.min(this.t + a.t, n);
+ r.s = 0; // assumes a,this >= 0
+ r.t = i;
+ while (i > 0) r[--i] = 0;
+ var j;
+ for (j = r.t - this.t; i < j; ++i) r[i + this.t] = this.am(0, a[i], r, i, 0, this.t);
+ for (j = Math.min(a.t, n); i < j; ++i) this.am(0, a[i], r, i, 0, n - i);
+ r.clamp();
+}
+
+//(protected) r = "this * a" without lower n words, n > 0
+//"this" should be the larger one if appropriate.
+function bnpMultiplyUpperTo(a, n, r) {
+ --n;
+ var i = r.t = this.t + a.t - n;
+ r.s = 0; // assumes a,this >= 0
+ while (--i >= 0) r[i] = 0;
+ for (i = Math.max(n - this.t, 0); i < a.t; ++i)
+ r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n);
+ r.clamp();
+ r.drShiftTo(1, r);
+}
+
+//Barrett modular reduction
+function Barrett(m) {
+// setup Barrett
+ this.r2 = nbi();
+ this.q3 = nbi();
+ BigInteger.ONE.dlShiftTo(2 * m.t, this.r2);
+ this.mu = this.r2.divide(m);
+ this.m = m;
+}
+
+function barrettConvert(x) {
+ if (x.s < 0 || x.t > 2 * this.m.t) return x.mod(this.m);
+ else if (x.compareTo(this.m) < 0) return x;
+ else {
+ var r = nbi();
+ x.copyTo(r);
+ this.reduce(r);
+ return r;
+ }
+}
+
+function barrettRevert(x) {
+ return x;
+}
+
+//x = x mod m (HAC 14.42)
+function barrettReduce(x) {
+ x.drShiftTo(this.m.t - 1, this.r2);
+ if (x.t > this.m.t + 1) {
+ x.t = this.m.t + 1;
+ x.clamp();
+ }
+ this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
+ this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2);
+ while (x.compareTo(this.r2) < 0) x.dAddOffset(1, this.m.t + 1);
+ x.subTo(this.r2, x);
+ while (x.compareTo(this.m) >= 0) x.subTo(this.m, x);
+}
+
+//r = x^2 mod m; x != r
+function barrettSqrTo(x, r) {
+ x.squareTo(r);
+ this.reduce(r);
+}
+
+//r = x*y mod m; x,y != r
+function barrettMulTo(x, y, r) {
+ x.multiplyTo(y, r);
+ this.reduce(r);
+}
+
+Barrett.prototype.convert = barrettConvert;
+Barrett.prototype.revert = barrettRevert;
+Barrett.prototype.reduce = barrettReduce;
+Barrett.prototype.mulTo = barrettMulTo;
+Barrett.prototype.sqrTo = barrettSqrTo;
+
+//(public) this^e % m (HAC 14.85)
+function bnModPow(e, m) {
+ var i = e.bitLength(), k, r = nbv(1), z;
+ if (i <= 0) return r;
+ else if (i < 18) k = 1;
+ else if (i < 48) k = 3;
+ else if (i < 144) k = 4;
+ else if (i < 768) k = 5;
+ else k = 6;
+ if (i < 8)
+ z = new Classic(m);
+ else if (m.isEven())
+ z = new Barrett(m);
+ else
+ z = new Montgomery(m);
+
+// precomputation
+ var g = new Array(), n = 3, k1 = k - 1, km = (1 << k) - 1;
+ g[1] = z.convert(this);
+ if (k > 1) {
+ var g2 = nbi();
+ z.sqrTo(g[1], g2);
+ while (n <= km) {
+ g[n] = nbi();
+ z.mulTo(g2, g[n - 2], g[n]);
+ n += 2;
+ }
+ }
+
+ var j = e.t - 1, w, is1 = true, r2 = nbi(), t;
+ i = nbits(e[j]) - 1;
+ while (j >= 0) {
+ if (i >= k1) w = (e[j] >> (i - k1)) & km;
+ else {
+ w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i);
+ if (j > 0) w |= e[j - 1] >> (this.DB + i - k1);
+ }
+
+ n = k;
+ while ((w & 1) === 0) {
+ w >>= 1;
+ --n;
+ }
+ if ((i -= n) < 0) {
+ i += this.DB;
+ --j;
+ }
+ if (is1) { // ret == 1, don't bother squaring or multiplying it
+ g[w].copyTo(r);
+ is1 = false;
+ }
+ else {
+ while (n > 1) {
+ z.sqrTo(r, r2);
+ z.sqrTo(r2, r);
+ n -= 2;
+ }
+ if (n > 0) z.sqrTo(r, r2); else {
+ t = r;
+ r = r2;
+ r2 = t;
+ }
+ z.mulTo(r2, g[w], r);
+ }
+
+ while (j >= 0 && (e[j] & (1 << i)) === 0) {
+ z.sqrTo(r, r2);
+ t = r;
+ r = r2;
+ r2 = t;
+ if (--i < 0) {
+ i = this.DB - 1;
+ --j;
+ }
+ }
+ }
+ return z.revert(r);
+}
+
+//(public) gcd(this,a) (HAC 14.54)
+function bnGCD(a) {
+ var x = (this.s < 0) ? this.negate() : this.clone();
+ var y = (a.s < 0) ? a.negate() : a.clone();
+ if (x.compareTo(y) < 0) {
+ var t = x;
+ x = y;
+ y = t;
+ }
+ var i = x.getLowestSetBit(), g = y.getLowestSetBit();
+ if (g < 0) return x;
+ if (i < g) g = i;
+ if (g > 0) {
+ x.rShiftTo(g, x);
+ y.rShiftTo(g, y);
+ }
+ while (x.signum() > 0) {
+ if ((i = x.getLowestSetBit()) > 0) x.rShiftTo(i, x);
+ if ((i = y.getLowestSetBit()) > 0) y.rShiftTo(i, y);
+ if (x.compareTo(y) >= 0) {
+ x.subTo(y, x);
+ x.rShiftTo(1, x);
+ }
+ else {
+ y.subTo(x, y);
+ y.rShiftTo(1, y);
+ }
+ }
+ if (g > 0) y.lShiftTo(g, y);
+ return y;
+}
+
+//(protected) this % n, n < 2^26
+function bnpModInt(n) {
+ if (n <= 0) return 0;
+ var d = this.DV % n, r = (this.s < 0) ? n - 1 : 0;
+ if (this.t > 0)
+ if (d === 0) r = this[0] % n;
+ else for (var i = this.t - 1; i >= 0; --i) r = (d * r + this[i]) % n;
+ return r;
+}
+
+//(public) 1/this % m (HAC 14.61)
+function bnModInverse(m) {
+ var ac = m.isEven();
+ if ((this.isEven() && ac) || m.signum() === 0) return BigInteger.ZERO;
+ var u = m.clone(), v = this.clone();
+ var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
+ while (u.signum() != 0) {
+ while (u.isEven()) {
+ u.rShiftTo(1, u);
+ if (ac) {
+ if (!a.isEven() || !b.isEven()) {
+ a.addTo(this, a);
+ b.subTo(m, b);
+ }
+ a.rShiftTo(1, a);
+ }
+ else if (!b.isEven()) b.subTo(m, b);
+ b.rShiftTo(1, b);
+ }
+ while (v.isEven()) {
+ v.rShiftTo(1, v);
+ if (ac) {
+ if (!c.isEven() || !d.isEven()) {
+ c.addTo(this, c);
+ d.subTo(m, d);
+ }
+ c.rShiftTo(1, c);
+ }
+ else if (!d.isEven()) d.subTo(m, d);
+ d.rShiftTo(1, d);
+ }
+ if (u.compareTo(v) >= 0) {
+ u.subTo(v, u);
+ if (ac) a.subTo(c, a);
+ b.subTo(d, b);
+ }
+ else {
+ v.subTo(u, v);
+ if (ac) c.subTo(a, c);
+ d.subTo(b, d);
+ }
+ }
+ if (v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
+ if (d.compareTo(m) >= 0) return d.subtract(m);
+ if (d.signum() < 0) d.addTo(m, d); else return d;
+ if (d.signum() < 0) return d.add(m); else return d;
+}
+
+var lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997];
+var lplim = (1 << 26) / lowprimes[lowprimes.length - 1];
+
+//(public) test primality with certainty >= 1-.5^t
+function bnIsProbablePrime(t) {
+ var i, x = this.abs();
+ if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
+ for (i = 0; i < lowprimes.length; ++i)
+ if (x[0] == lowprimes[i]) return true;
+ return false;
+ }
+ if (x.isEven()) return false;
+ i = 1;
+ while (i < lowprimes.length) {
+ var m = lowprimes[i], j = i + 1;
+ while (j < lowprimes.length && m < lplim) m *= lowprimes[j++];
+ m = x.modInt(m);
+ while (i < j) if (m % lowprimes[i++] === 0) return false;
+ }
+ return x.millerRabin(t);
+}
+
+//(protected) true if probably prime (HAC 4.24, Miller-Rabin)
+function bnpMillerRabin(t) {
+ var n1 = this.subtract(BigInteger.ONE);
+ var k = n1.getLowestSetBit();
+ if (k <= 0) return false;
+ var r = n1.shiftRight(k);
+ t = (t + 1) >> 1;
+ if (t > lowprimes.length) t = lowprimes.length;
+ var a = nbi();
+ for (var i = 0; i < t; ++i) {
+ //Pick bases at random, instead of starting at 2
+ a.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);
+ var y = a.modPow(r, this);
+ if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
+ var j = 1;
+ while (j++ < k && y.compareTo(n1) != 0) {
+ y = y.modPowInt(2, this);
+ if (y.compareTo(BigInteger.ONE) === 0) return false;
+ }
+ if (y.compareTo(n1) != 0) return false;
+ }
+ }
+ return true;
+}
+
+// protected
+BigInteger.prototype.copyTo = bnpCopyTo;
+BigInteger.prototype.fromInt = bnpFromInt;
+BigInteger.prototype.fromString = bnpFromString;
+BigInteger.prototype.fromByteArray = bnpFromByteArray;
+BigInteger.prototype.fromBuffer = bnpFromBuffer;
+BigInteger.prototype.clamp = bnpClamp;
+BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
+BigInteger.prototype.drShiftTo = bnpDRShiftTo;
+BigInteger.prototype.lShiftTo = bnpLShiftTo;
+BigInteger.prototype.rShiftTo = bnpRShiftTo;
+BigInteger.prototype.subTo = bnpSubTo;
+BigInteger.prototype.multiplyTo = bnpMultiplyTo;
+BigInteger.prototype.squareTo = bnpSquareTo;
+BigInteger.prototype.divRemTo = bnpDivRemTo;
+BigInteger.prototype.invDigit = bnpInvDigit;
+BigInteger.prototype.isEven = bnpIsEven;
+BigInteger.prototype.exp = bnpExp;
+
+BigInteger.prototype.chunkSize = bnpChunkSize;
+BigInteger.prototype.toRadix = bnpToRadix;
+BigInteger.prototype.fromRadix = bnpFromRadix;
+BigInteger.prototype.fromNumber = bnpFromNumber;
+BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
+BigInteger.prototype.changeBit = bnpChangeBit;
+BigInteger.prototype.addTo = bnpAddTo;
+BigInteger.prototype.dMultiply = bnpDMultiply;
+BigInteger.prototype.dAddOffset = bnpDAddOffset;
+BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
+BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
+BigInteger.prototype.modInt = bnpModInt;
+BigInteger.prototype.millerRabin = bnpMillerRabin;
+
+
+// public
+BigInteger.prototype.toString = bnToString;
+BigInteger.prototype.negate = bnNegate;
+BigInteger.prototype.abs = bnAbs;
+BigInteger.prototype.compareTo = bnCompareTo;
+BigInteger.prototype.bitLength = bnBitLength;
+BigInteger.prototype.mod = bnMod;
+BigInteger.prototype.modPowInt = bnModPowInt;
+
+BigInteger.prototype.clone = bnClone;
+BigInteger.prototype.intValue = bnIntValue;
+BigInteger.prototype.byteValue = bnByteValue;
+BigInteger.prototype.shortValue = bnShortValue;
+BigInteger.prototype.signum = bnSigNum;
+BigInteger.prototype.toByteArray = bnToByteArray;
+BigInteger.prototype.toBuffer = bnToBuffer;
+BigInteger.prototype.equals = bnEquals;
+BigInteger.prototype.min = bnMin;
+BigInteger.prototype.max = bnMax;
+BigInteger.prototype.and = bnAnd;
+BigInteger.prototype.or = bnOr;
+BigInteger.prototype.xor = bnXor;
+BigInteger.prototype.andNot = bnAndNot;
+BigInteger.prototype.not = bnNot;
+BigInteger.prototype.shiftLeft = bnShiftLeft;
+BigInteger.prototype.shiftRight = bnShiftRight;
+BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
+BigInteger.prototype.bitCount = bnBitCount;
+BigInteger.prototype.testBit = bnTestBit;
+BigInteger.prototype.setBit = bnSetBit;
+BigInteger.prototype.clearBit = bnClearBit;
+BigInteger.prototype.flipBit = bnFlipBit;
+BigInteger.prototype.add = bnAdd;
+BigInteger.prototype.subtract = bnSubtract;
+BigInteger.prototype.multiply = bnMultiply;
+BigInteger.prototype.divide = bnDivide;
+BigInteger.prototype.remainder = bnRemainder;
+BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
+BigInteger.prototype.modPow = bnModPow;
+BigInteger.prototype.modInverse = bnModInverse;
+BigInteger.prototype.pow = bnPow;
+BigInteger.prototype.gcd = bnGCD;
+BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
+BigInteger.int2char = int2char;
+
+// "constants"
+BigInteger.ZERO = nbv(0);
+BigInteger.ONE = nbv(1);
+
+// JSBN-specific extension
+BigInteger.prototype.square = bnSquare;
+
+//BigInteger interfaces not implemented in jsbn:
+
+//BigInteger(int signum, byte[] magnitude)
+//double doubleValue()
+//float floatValue()
+//int hashCode()
+//long longValue()
+//static BigInteger valueOf(long val)
+
module.exports = BigInteger;
\ No newline at end of file
diff --git a/node_modules/node-rsa/src/schemes/pss.js b/node_modules/node-rsa/src/schemes/pss.js
index c6e037f..d7f3b58 100644
--- a/node_modules/node-rsa/src/schemes/pss.js
+++ b/node_modules/node-rsa/src/schemes/pss.js
@@ -1,183 +1,183 @@
-/**
- * PSS signature scheme
- */
-
-var BigInteger = require('../libs/jsbn');
-var crypt = require('crypto');
-
-module.exports = {
- isEncryption: false,
- isSignature: true
-};
-
-var DEFAULT_HASH_FUNCTION = 'sha1';
-var DEFAULT_SALT_LENGTH = 20;
-
-module.exports.makeScheme = function (key, options) {
- var OAEP = require('./schemes').pkcs1_oaep;
-
- /**
- * @param key
- * @param options
- * options [Object] An object that contains the following keys that specify certain options for encoding.
- * └>signingSchemeOptions
- * ├>hash [String] Hash function to use when encoding and generating masks. Must be a string accepted by node's crypto.createHash function. (default = "sha1")
- * ├>mgf [function] The mask generation function to use when encoding. (default = mgf1SHA1)
- * └>sLen [uint] The length of the salt to generate. (default = 20)
- * @constructor
- */
- function Scheme(key, options) {
- this.key = key;
- this.options = options;
- }
-
- Scheme.prototype.sign = function (buffer) {
- var mHash = crypt.createHash(this.options.signingSchemeOptions.hash || DEFAULT_HASH_FUNCTION);
- mHash.update(buffer);
-
- var encoded = this.emsa_pss_encode(mHash.digest(), this.key.keySize - 1);
- return this.key.$doPrivate(new BigInteger(encoded)).toBuffer(this.key.encryptedDataLength);
- };
-
- Scheme.prototype.verify = function (buffer, signature, signature_encoding) {
- if (signature_encoding) {
- signature = Buffer.from(signature, signature_encoding);
- }
- signature = new BigInteger(signature);
-
- var emLen = Math.ceil((this.key.keySize - 1) / 8);
- var m = this.key.$doPublic(signature).toBuffer(emLen);
-
- var mHash = crypt.createHash(this.options.signingSchemeOptions.hash || DEFAULT_HASH_FUNCTION);
- mHash.update(buffer);
-
- return this.emsa_pss_verify(mHash.digest(), m, this.key.keySize - 1);
- };
-
- /*
- * https://tools.ietf.org/html/rfc3447#section-9.1.1
- *
- * mHash [Buffer] Hashed message to encode
- * emBits [uint] Maximum length of output in bits. Must be at least 8hLen + 8sLen + 9 (hLen = Hash digest length in bytes | sLen = length of salt in bytes)
- * @returns {Buffer} The encoded message
- */
- Scheme.prototype.emsa_pss_encode = function (mHash, emBits) {
- var hash = this.options.signingSchemeOptions.hash || DEFAULT_HASH_FUNCTION;
- var mgf = this.options.signingSchemeOptions.mgf || OAEP.eme_oaep_mgf1;
- var sLen = this.options.signingSchemeOptions.saltLength || DEFAULT_SALT_LENGTH;
-
- var hLen = OAEP.digestLength[hash];
- var emLen = Math.ceil(emBits / 8);
-
- if (emLen < hLen + sLen + 2) {
- throw new Error("Output length passed to emBits(" + emBits + ") is too small for the options " +
- "specified(" + hash + ", " + sLen + "). To fix this issue increase the value of emBits. (minimum size: " +
- (8 * hLen + 8 * sLen + 9) + ")"
- );
- }
-
- var salt = crypt.randomBytes(sLen);
-
- var Mapostrophe = Buffer.alloc(8 + hLen + sLen);
- Mapostrophe.fill(0, 0, 8);
- mHash.copy(Mapostrophe, 8);
- salt.copy(Mapostrophe, 8 + mHash.length);
-
- var H = crypt.createHash(hash);
- H.update(Mapostrophe);
- H = H.digest();
-
- var PS = Buffer.alloc(emLen - salt.length - hLen - 2);
- PS.fill(0);
-
- var DB = Buffer.alloc(PS.length + 1 + salt.length);
- PS.copy(DB);
- DB[PS.length] = 0x01;
- salt.copy(DB, PS.length + 1);
-
- var dbMask = mgf(H, DB.length, hash);
-
- // XOR DB and dbMask together
- var maskedDB = Buffer.alloc(DB.length);
- for (var i = 0; i < dbMask.length; i++) {
- maskedDB[i] = DB[i] ^ dbMask[i];
- }
-
- var bits = 8 * emLen - emBits;
- var mask = 255 ^ (255 >> 8 - bits << 8 - bits);
- maskedDB[0] = maskedDB[0] & mask;
-
- var EM = Buffer.alloc(maskedDB.length + H.length + 1);
- maskedDB.copy(EM, 0);
- H.copy(EM, maskedDB.length);
- EM[EM.length - 1] = 0xbc;
-
- return EM;
- };
-
- /*
- * https://tools.ietf.org/html/rfc3447#section-9.1.2
- *
- * mHash [Buffer] Hashed message
- * EM [Buffer] Signature
- * emBits [uint] Length of EM in bits. Must be at least 8hLen + 8sLen + 9 to be a valid signature. (hLen = Hash digest length in bytes | sLen = length of salt in bytes)
- * @returns {Boolean} True if signature(EM) matches message(M)
- */
- Scheme.prototype.emsa_pss_verify = function (mHash, EM, emBits) {
- var hash = this.options.signingSchemeOptions.hash || DEFAULT_HASH_FUNCTION;
- var mgf = this.options.signingSchemeOptions.mgf || OAEP.eme_oaep_mgf1;
- var sLen = this.options.signingSchemeOptions.saltLength || DEFAULT_SALT_LENGTH;
-
- var hLen = OAEP.digestLength[hash];
- var emLen = Math.ceil(emBits / 8);
-
- if (emLen < hLen + sLen + 2 || EM[EM.length - 1] != 0xbc) {
- return false;
- }
-
- var DB = Buffer.alloc(emLen - hLen - 1);
- EM.copy(DB, 0, 0, emLen - hLen - 1);
-
- var mask = 0;
- for (var i = 0, bits = 8 * emLen - emBits; i < bits; i++) {
- mask |= 1 << (7 - i);
- }
-
- if ((DB[0] & mask) !== 0) {
- return false;
- }
-
- var H = EM.slice(emLen - hLen - 1, emLen - 1);
- var dbMask = mgf(H, DB.length, hash);
-
- // Unmask DB
- for (i = 0; i < DB.length; i++) {
- DB[i] ^= dbMask[i];
- }
-
- bits = 8 * emLen - emBits;
- mask = 255 ^ (255 >> 8 - bits << 8 - bits);
- DB[0] = DB[0] & mask;
-
- // Filter out padding
- for (i = 0; DB[i] === 0 && i < DB.length; i++);
- if (DB[i] != 1) {
- return false;
- }
-
- var salt = DB.slice(DB.length - sLen);
-
- var Mapostrophe = Buffer.alloc(8 + hLen + sLen);
- Mapostrophe.fill(0, 0, 8);
- mHash.copy(Mapostrophe, 8);
- salt.copy(Mapostrophe, 8 + mHash.length);
-
- var Hapostrophe = crypt.createHash(hash);
- Hapostrophe.update(Mapostrophe);
- Hapostrophe = Hapostrophe.digest();
-
- return H.toString("hex") === Hapostrophe.toString("hex");
- };
-
- return new Scheme(key, options);
-};
+/**
+ * PSS signature scheme
+ */
+
+var BigInteger = require('../libs/jsbn');
+var crypt = require('crypto');
+
+module.exports = {
+ isEncryption: false,
+ isSignature: true
+};
+
+var DEFAULT_HASH_FUNCTION = 'sha1';
+var DEFAULT_SALT_LENGTH = 20;
+
+module.exports.makeScheme = function (key, options) {
+ var OAEP = require('./schemes').pkcs1_oaep;
+
+ /**
+ * @param key
+ * @param options
+ * options [Object] An object that contains the following keys that specify certain options for encoding.
+ * └>signingSchemeOptions
+ * ├>hash [String] Hash function to use when encoding and generating masks. Must be a string accepted by node's crypto.createHash function. (default = "sha1")
+ * ├>mgf [function] The mask generation function to use when encoding. (default = mgf1SHA1)
+ * └>sLen [uint] The length of the salt to generate. (default = 20)
+ * @constructor
+ */
+ function Scheme(key, options) {
+ this.key = key;
+ this.options = options;
+ }
+
+ Scheme.prototype.sign = function (buffer) {
+ var mHash = crypt.createHash(this.options.signingSchemeOptions.hash || DEFAULT_HASH_FUNCTION);
+ mHash.update(buffer);
+
+ var encoded = this.emsa_pss_encode(mHash.digest(), this.key.keySize - 1);
+ return this.key.$doPrivate(new BigInteger(encoded)).toBuffer(this.key.encryptedDataLength);
+ };
+
+ Scheme.prototype.verify = function (buffer, signature, signature_encoding) {
+ if (signature_encoding) {
+ signature = Buffer.from(signature, signature_encoding);
+ }
+ signature = new BigInteger(signature);
+
+ var emLen = Math.ceil((this.key.keySize - 1) / 8);
+ var m = this.key.$doPublic(signature).toBuffer(emLen);
+
+ var mHash = crypt.createHash(this.options.signingSchemeOptions.hash || DEFAULT_HASH_FUNCTION);
+ mHash.update(buffer);
+
+ return this.emsa_pss_verify(mHash.digest(), m, this.key.keySize - 1);
+ };
+
+ /*
+ * https://tools.ietf.org/html/rfc3447#section-9.1.1
+ *
+ * mHash [Buffer] Hashed message to encode
+ * emBits [uint] Maximum length of output in bits. Must be at least 8hLen + 8sLen + 9 (hLen = Hash digest length in bytes | sLen = length of salt in bytes)
+ * @returns {Buffer} The encoded message
+ */
+ Scheme.prototype.emsa_pss_encode = function (mHash, emBits) {
+ var hash = this.options.signingSchemeOptions.hash || DEFAULT_HASH_FUNCTION;
+ var mgf = this.options.signingSchemeOptions.mgf || OAEP.eme_oaep_mgf1;
+ var sLen = this.options.signingSchemeOptions.saltLength || DEFAULT_SALT_LENGTH;
+
+ var hLen = OAEP.digestLength[hash];
+ var emLen = Math.ceil(emBits / 8);
+
+ if (emLen < hLen + sLen + 2) {
+ throw new Error("Output length passed to emBits(" + emBits + ") is too small for the options " +
+ "specified(" + hash + ", " + sLen + "). To fix this issue increase the value of emBits. (minimum size: " +
+ (8 * hLen + 8 * sLen + 9) + ")"
+ );
+ }
+
+ var salt = crypt.randomBytes(sLen);
+
+ var Mapostrophe = Buffer.alloc(8 + hLen + sLen);
+ Mapostrophe.fill(0, 0, 8);
+ mHash.copy(Mapostrophe, 8);
+ salt.copy(Mapostrophe, 8 + mHash.length);
+
+ var H = crypt.createHash(hash);
+ H.update(Mapostrophe);
+ H = H.digest();
+
+ var PS = Buffer.alloc(emLen - salt.length - hLen - 2);
+ PS.fill(0);
+
+ var DB = Buffer.alloc(PS.length + 1 + salt.length);
+ PS.copy(DB);
+ DB[PS.length] = 0x01;
+ salt.copy(DB, PS.length + 1);
+
+ var dbMask = mgf(H, DB.length, hash);
+
+ // XOR DB and dbMask together
+ var maskedDB = Buffer.alloc(DB.length);
+ for (var i = 0; i < dbMask.length; i++) {
+ maskedDB[i] = DB[i] ^ dbMask[i];
+ }
+
+ var bits = 8 * emLen - emBits;
+ var mask = 255 ^ (255 >> 8 - bits << 8 - bits);
+ maskedDB[0] = maskedDB[0] & mask;
+
+ var EM = Buffer.alloc(maskedDB.length + H.length + 1);
+ maskedDB.copy(EM, 0);
+ H.copy(EM, maskedDB.length);
+ EM[EM.length - 1] = 0xbc;
+
+ return EM;
+ };
+
+ /*
+ * https://tools.ietf.org/html/rfc3447#section-9.1.2
+ *
+ * mHash [Buffer] Hashed message
+ * EM [Buffer] Signature
+ * emBits [uint] Length of EM in bits. Must be at least 8hLen + 8sLen + 9 to be a valid signature. (hLen = Hash digest length in bytes | sLen = length of salt in bytes)
+ * @returns {Boolean} True if signature(EM) matches message(M)
+ */
+ Scheme.prototype.emsa_pss_verify = function (mHash, EM, emBits) {
+ var hash = this.options.signingSchemeOptions.hash || DEFAULT_HASH_FUNCTION;
+ var mgf = this.options.signingSchemeOptions.mgf || OAEP.eme_oaep_mgf1;
+ var sLen = this.options.signingSchemeOptions.saltLength || DEFAULT_SALT_LENGTH;
+
+ var hLen = OAEP.digestLength[hash];
+ var emLen = Math.ceil(emBits / 8);
+
+ if (emLen < hLen + sLen + 2 || EM[EM.length - 1] != 0xbc) {
+ return false;
+ }
+
+ var DB = Buffer.alloc(emLen - hLen - 1);
+ EM.copy(DB, 0, 0, emLen - hLen - 1);
+
+ var mask = 0;
+ for (var i = 0, bits = 8 * emLen - emBits; i < bits; i++) {
+ mask |= 1 << (7 - i);
+ }
+
+ if ((DB[0] & mask) !== 0) {
+ return false;
+ }
+
+ var H = EM.slice(emLen - hLen - 1, emLen - 1);
+ var dbMask = mgf(H, DB.length, hash);
+
+ // Unmask DB
+ for (i = 0; i < DB.length; i++) {
+ DB[i] ^= dbMask[i];
+ }
+
+ bits = 8 * emLen - emBits;
+ mask = 255 ^ (255 >> 8 - bits << 8 - bits);
+ DB[0] = DB[0] & mask;
+
+ // Filter out padding
+ for (i = 0; DB[i] === 0 && i < DB.length; i++);
+ if (DB[i] != 1) {
+ return false;
+ }
+
+ var salt = DB.slice(DB.length - sLen);
+
+ var Mapostrophe = Buffer.alloc(8 + hLen + sLen);
+ Mapostrophe.fill(0, 0, 8);
+ mHash.copy(Mapostrophe, 8);
+ salt.copy(Mapostrophe, 8 + mHash.length);
+
+ var Hapostrophe = crypt.createHash(hash);
+ Hapostrophe.update(Mapostrophe);
+ Hapostrophe = Hapostrophe.digest();
+
+ return H.toString("hex") === Hapostrophe.toString("hex");
+ };
+
+ return new Scheme(key, options);
+};
diff --git a/node_modules/node-rsa/src/schemes/schemes.js b/node_modules/node-rsa/src/schemes/schemes.js
index 3eb8261..141827a 100644
--- a/node_modules/node-rsa/src/schemes/schemes.js
+++ b/node_modules/node-rsa/src/schemes/schemes.js
@@ -1,23 +1,23 @@
-module.exports = {
- pkcs1: require('./pkcs1'),
- pkcs1_oaep: require('./oaep'),
- pss: require('./pss'),
-
- /**
- * Check if scheme has padding methods
- * @param scheme {string}
- * @returns {Boolean}
- */
- isEncryption: function (scheme) {
- return module.exports[scheme] && module.exports[scheme].isEncryption;
- },
-
- /**
- * Check if scheme has sign/verify methods
- * @param scheme {string}
- * @returns {Boolean}
- */
- isSignature: function (scheme) {
- return module.exports[scheme] && module.exports[scheme].isSignature;
- }
+module.exports = {
+ pkcs1: require('./pkcs1'),
+ pkcs1_oaep: require('./oaep'),
+ pss: require('./pss'),
+
+ /**
+ * Check if scheme has padding methods
+ * @param scheme {string}
+ * @returns {Boolean}
+ */
+ isEncryption: function (scheme) {
+ return module.exports[scheme] && module.exports[scheme].isEncryption;
+ },
+
+ /**
+ * Check if scheme has sign/verify methods
+ * @param scheme {string}
+ * @returns {Boolean}
+ */
+ isSignature: function (scheme) {
+ return module.exports[scheme] && module.exports[scheme].isSignature;
+ }
};
\ No newline at end of file
diff --git a/node_modules/prettier/THIRD-PARTY-NOTICES.md b/node_modules/prettier/THIRD-PARTY-NOTICES.md
index b61bf0b..f2af3ea 100644
--- a/node_modules/prettier/THIRD-PARTY-NOTICES.md
+++ b/node_modules/prettier/THIRD-PARTY-NOTICES.md
@@ -565,26 +565,26 @@ License: MIT
Homepage:
Author: Ika (https://github.com/ikatyang)
-> MIT License
->
-> Copyright (c) Ika (https://github.com/ikatyang)
->
-> Permission is hereby granted, free of charge, to any person obtaining a copy
-> of this software and associated documentation files (the "Software"), to deal
-> in the Software without restriction, including without limitation the rights
-> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-> copies of the Software, and to permit persons to whom the Software is
-> furnished to do so, subject to the following conditions:
->
-> The above copyright notice and this permission notice shall be included in all
-> copies or substantial portions of the Software.
->
-> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+> MIT License
+>
+> Copyright (c) Ika (https://github.com/ikatyang)
+>
+> Permission is hereby granted, free of charge, to any person obtaining a copy
+> of this software and associated documentation files (the "Software"), to deal
+> in the Software without restriction, including without limitation the rights
+> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+> copies of the Software, and to permit persons to whom the Software is
+> furnished to do so, subject to the following conditions:
+>
+> The above copyright notice and this permission notice shall be included in all
+> copies or substantial portions of the Software.
+>
+> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
----------------------------------------
@@ -4939,60 +4939,60 @@ Homepage:
Repository:
Author: Microsoft Corp.
-> Apache License
->
-> Version 2.0, January 2004
->
-> http://www.apache.org/licenses/
->
-> TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
->
-> 1. Definitions.
->
-> "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
->
-> "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
->
-> "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
->
-> "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
->
-> "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
->
-> "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
->
-> "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
->
-> "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
->
-> "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
->
-> "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
->
-> 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
->
-> 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
->
-> 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
->
-> You must give any other recipients of the Work or Derivative Works a copy of this License; and
->
-> You must cause any modified files to carry prominent notices stating that You changed the files; and
->
-> You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
->
-> If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
->
-> 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
->
-> 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
->
-> 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
->
-> 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
->
-> 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
->
+> Apache License
+>
+> Version 2.0, January 2004
+>
+> http://www.apache.org/licenses/
+>
+> TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+>
+> 1. Definitions.
+>
+> "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+>
+> "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+>
+> "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+>
+> "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+>
+> "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+>
+> "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+>
+> "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+>
+> "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+>
+> "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
+>
+> "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+>
+> 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+>
+> 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+>
+> 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+>
+> You must give any other recipients of the Work or Derivative Works a copy of this License; and
+>
+> You must cause any modified files to carry prominent notices stating that You changed the files; and
+>
+> You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+>
+> If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+>
+> 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+>
+> 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+>
+> 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+>
+> 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+>
+> 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+>
> END OF TERMS AND CONDITIONS
----------------------------------------
diff --git a/node_modules/prettier/bin/prettier.cjs b/node_modules/prettier/bin/prettier.cjs
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/LICENSE b/node_modules/uri-js/LICENSE
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/README.md b/node_modules/uri-js/README.md
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/es5/uri.all.d.ts b/node_modules/uri-js/dist/es5/uri.all.d.ts
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/es5/uri.all.js b/node_modules/uri-js/dist/es5/uri.all.js
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/es5/uri.all.js.map b/node_modules/uri-js/dist/es5/uri.all.js.map
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/es5/uri.all.min.d.ts b/node_modules/uri-js/dist/es5/uri.all.min.d.ts
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/es5/uri.all.min.js b/node_modules/uri-js/dist/es5/uri.all.min.js
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/es5/uri.all.min.js.map b/node_modules/uri-js/dist/es5/uri.all.min.js.map
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/index.d.ts b/node_modules/uri-js/dist/esnext/index.d.ts
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/index.js b/node_modules/uri-js/dist/esnext/index.js
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/index.js.map b/node_modules/uri-js/dist/esnext/index.js.map
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/regexps-iri.d.ts b/node_modules/uri-js/dist/esnext/regexps-iri.d.ts
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/regexps-iri.js b/node_modules/uri-js/dist/esnext/regexps-iri.js
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/regexps-iri.js.map b/node_modules/uri-js/dist/esnext/regexps-iri.js.map
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/regexps-uri.d.ts b/node_modules/uri-js/dist/esnext/regexps-uri.d.ts
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/regexps-uri.js b/node_modules/uri-js/dist/esnext/regexps-uri.js
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/regexps-uri.js.map b/node_modules/uri-js/dist/esnext/regexps-uri.js.map
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/http.d.ts b/node_modules/uri-js/dist/esnext/schemes/http.d.ts
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/http.js b/node_modules/uri-js/dist/esnext/schemes/http.js
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/http.js.map b/node_modules/uri-js/dist/esnext/schemes/http.js.map
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/https.d.ts b/node_modules/uri-js/dist/esnext/schemes/https.d.ts
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/https.js b/node_modules/uri-js/dist/esnext/schemes/https.js
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/https.js.map b/node_modules/uri-js/dist/esnext/schemes/https.js.map
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/mailto.d.ts b/node_modules/uri-js/dist/esnext/schemes/mailto.d.ts
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/mailto.js b/node_modules/uri-js/dist/esnext/schemes/mailto.js
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/mailto.js.map b/node_modules/uri-js/dist/esnext/schemes/mailto.js.map
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/urn-uuid.d.ts b/node_modules/uri-js/dist/esnext/schemes/urn-uuid.d.ts
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/urn-uuid.js b/node_modules/uri-js/dist/esnext/schemes/urn-uuid.js
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/urn-uuid.js.map b/node_modules/uri-js/dist/esnext/schemes/urn-uuid.js.map
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/urn.d.ts b/node_modules/uri-js/dist/esnext/schemes/urn.d.ts
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/urn.js b/node_modules/uri-js/dist/esnext/schemes/urn.js
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/urn.js.map b/node_modules/uri-js/dist/esnext/schemes/urn.js.map
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/ws.d.ts b/node_modules/uri-js/dist/esnext/schemes/ws.d.ts
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/ws.js b/node_modules/uri-js/dist/esnext/schemes/ws.js
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/ws.js.map b/node_modules/uri-js/dist/esnext/schemes/ws.js.map
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/wss.d.ts b/node_modules/uri-js/dist/esnext/schemes/wss.d.ts
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/wss.js b/node_modules/uri-js/dist/esnext/schemes/wss.js
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/schemes/wss.js.map b/node_modules/uri-js/dist/esnext/schemes/wss.js.map
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/uri.d.ts b/node_modules/uri-js/dist/esnext/uri.d.ts
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/uri.js b/node_modules/uri-js/dist/esnext/uri.js
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/uri.js.map b/node_modules/uri-js/dist/esnext/uri.js.map
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/util.d.ts b/node_modules/uri-js/dist/esnext/util.d.ts
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/util.js b/node_modules/uri-js/dist/esnext/util.js
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/dist/esnext/util.js.map b/node_modules/uri-js/dist/esnext/util.js.map
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/package.json b/node_modules/uri-js/package.json
old mode 100644
new mode 100755
diff --git a/node_modules/uri-js/yarn.lock b/node_modules/uri-js/yarn.lock
old mode 100644
new mode 100755
diff --git a/node_modules/uuid/dist-node/bin/uuid b/node_modules/uuid/dist-node/bin/uuid
old mode 100644
new mode 100755
diff --git a/node_modules/which/bin/node-which b/node_modules/which/bin/node-which
old mode 100644
new mode 100755
diff --git a/run.js b/run.js
deleted file mode 100644
index 5ebb440..0000000
--- a/run.js
+++ /dev/null
@@ -1,18 +0,0 @@
-// run.js — tiny CLI to print results
-import { getStoresByZip, getStoresByCoord } from './walmartClient.js';
-
-const [, , cmd, arg1, arg2] = process.argv;
-
-try {
- if (cmd === 'stores') {
- const zip = arg1 || '92507';
- const data = await getStoresByZip(zip);
-
- console.table(data);
- } else {
- console.log(`Usage:
- node run.js stores `);
- }
-} catch (e) {
- console.error('Request failed:', e.message);
-}
diff --git a/sanityCheckerCrap/key-check.mjs b/sanityCheckerCrap/key-check.mjs
deleted file mode 100644
index 9634889..0000000
--- a/sanityCheckerCrap/key-check.mjs
+++ /dev/null
@@ -1,16 +0,0 @@
-import fs from 'fs';
-import crypto from 'crypto';
-
-const pem = fs.readFileSync('./private_key.pem', 'utf8'); // or your inline string
-try {
- const ts = String(Date.now());
- const toSign = `your-consumer-id\n${ts}\nyour-key-version`;
- crypto.sign('RSA-SHA256', Buffer.from(toSign), {
- key: pem,
- padding: crypto.constants.RSA_PKCS1_PADDING,
- // passphrase: "if-you-set-one",
- });
- console.log('✅ Key parsed and signature generated.');
-} catch (e) {
- console.error('❌ Still failing:', e.message);
-}
diff --git a/sanityCheckerCrap/verify.mjs b/sanityCheckerCrap/verify.mjs
deleted file mode 100644
index 775be64..0000000
--- a/sanityCheckerCrap/verify.mjs
+++ /dev/null
@@ -1,29 +0,0 @@
-import crypto from 'crypto';
-import fs from 'fs';
-
-const consumerId = '39d025f8-e575-48cf-aa4e-22f89da4c16f';
-const keyVer = '5';
-const ts = String(Date.now());
-
-const payload = `${consumerId}\n${ts}\n${keyVer}`;
-const privatePem = fs.readFileSync('./private_key.pem', 'utf8'); // OR your inline string
-const publicPem = fs.readFileSync('./public_key.pem', 'utf8');
-
-// sign (exactly like your client)
-const sigB64 = crypto
- .sign('RSA-SHA256', Buffer.from(payload), {
- key: privatePem,
- padding: crypto.constants.RSA_PKCS1_PADDING,
- })
- .toString('base64');
-
-// verify with the public key from the portal
-const ok = crypto.verify(
- 'RSA-SHA256',
- Buffer.from(payload),
- { key: publicPem, padding: crypto.constants.RSA_PKCS1_PADDING },
- Buffer.from(sigB64, 'base64'),
-);
-
-console.log('verify:', ok ? 'OK ✅' : 'FAIL ❌');
-console.log({ toSign: payload, sigLen: sigB64.length });
diff --git a/test.js b/test.js
deleted file mode 100644
index 849f141..0000000
--- a/test.js
+++ /dev/null
@@ -1,3 +0,0 @@
-//poopoo
-//hello testing git push
-//testing push from xcode again
diff --git a/walmartClient.js b/walmartClient.js
deleted file mode 100644
index 69fad32..0000000
--- a/walmartClient.js
+++ /dev/null
@@ -1,119 +0,0 @@
-// walmartClient.mjs — Affiliates v2 with inline private key (temporary)
-import crypto from 'crypto';
-
-// WARNING: Inline key is OK for a quick test, but move it to a .pem asap.
-const keyData = {
- consumerId: '39d025f8-e575-48cf-aa4e-22f89da4c16f',
- keyVer: '5', // keep as STRING; must match walmart.io key version exactly
- privateKeyPem: `-----BEGIN RSA PRIVATE KEY-----
-MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC1hpiZMh1pyN6k
-oDO95qK3L+/uY3M+sUpcnQkuNdFPBChh3jxEjn3zQLm88rdBTKQVqDD8E7g2KBHX
-wYaSiKqqXcBkMkPfEEyTE/I//BjDF5dS+sgR6uIJmfsNVIVkY7laxo0STFCO3G+V
-gkHTp8u/lJ5Aa8NSxu4BYlR0wBpze40aHYBeQw/+QuPvZzNeUf5YNC3rs5eId2f5
-N0rA2mZfY1myzE6UarW+5+WrWbkR0Bwrvs+8B/S8Jh4QFmh2EDaucisx96MXSH5S
-3BuzBxqE9Txo4TKGu0y/aDmRU1Ij5WP88VnURU3vna1UF5n/pPw6InzvcQkeGS1o
-thpyvCvtAgMBAAECggEABFOmXm5twvqOQpRa0/Gxo9YX/0iJoZPPdcPhLdF5N/lU
-bqdUGeyojxoD41rkHviDXpXH9x9YxwevQp7QcrygjsU6Xv2YuekC3j69ycjcHKqf
-UlygHdc3O2r/tHOr1G2RFhITIIbHEqSpqqY9ke7paxtaOQKojqpL/F1jdr8WduM9
-WQqbpgk+Hc6PIYVdUeALMX+IGNWbZiX6zqm85IKUdAA4/V0RCMl/j9ySBP6TsT06
-5IXK63urXl+AOJh1tHV79GP/waETEc6rQ8Ntn9p3HsUtsx6qiLSky7E2m2L3rdVd
-LOzM2vVQDKr0SMGfx4/ZA79OJbLvJnwon9l4WdxmeQKBgQDb4L7sI4FnnD7uAaV5
-NTxt6ELJIpgxalTXbGiD6BoGN7LPbRfLJmKP4pGbNkfxtLZKsrTXOE1z5bTurRzY
-dsH9pEmhBf7SdYtNrnPZCfOwpZaK/PyVdIggnaAiVYD6Q5urNcTltOA9SLdxGJyE
-Ny8GpdB/ItmRCUkru4uk8L3KFQKBgQDTWOaBQRPvrL7sl4nVrTlfaxDTYulFgqSx
-j3ag+RBhCwvFVNxb710moIEtThpDnaLNJCc6JQ+QebrsDP7Q49eOxqKbbbLOHGrt
-akkeMROg6+MaL7HMAMsjCj7hBnpSjCg94ldHuJ0d8/PB60amIES/TTOyTsssxIlD
-HcoX4JsIeQKBgDVHF/wP/mMksPrq2zWreKEJDmW+RDJ1GWm5kvmjW+r1xBYO0R0g
-h/FlbPK3DGe86g7fjoI32kyi9FyBBeRNomPbUxv5X+2PHdoM03Vbu/ippvi2pF1y
-hymgCBVJsp7xkt7BgJxIX6152TlGRWakGHj75LFpuF40ac52+zdUPiihAoGASmQU
-XpKljctkOKruXUPn2eo5te4u5cSia81vmCGS3lWhAwhnuAR86Ue9sFC5detajpKX
-LCQ3Ykc2wDeiyawpB5xrSAJI2buu93pd2j60BgSBn4oCLyhoWCEXGOXK0Jt83qt4
-xUn6I7zmo+9Iotjg2eU2uSB663sSRYmKxPTOHSECgYEAr9GDqLgORkKWwXhMAe3h
-R0tYdGzWqpOiVNi1hcNMGfNwQekfIAM9NVarIib5JYPkSQQQWJZVXcTlR2YZbf9/
-P5VgNbNkV23Nq7j926cpbSlgb+UsZOCC5zTaJ0L6oePnK5R38v54y2XC9ccqW6FP
-sVP5T4Vx30thw2cpbOY227Q=
------END RSA PRIVATE KEY-----`,
-};
-
-// EXACTLY mirror the Java canonicalization
-function canonicalizeForSignature({ consumerId, ts, keyVer }) {
- const map = {
- 'WM_CONSUMER.ID': String(consumerId).trim(),
- 'WM_CONSUMER.INTIMESTAMP': String(ts).trim(),
- 'WM_SEC.KEY_VERSION': String(keyVer).trim(),
- };
- const sortedKeys = Object.keys(map).sort(); // lexicographic
- // join values with '\n' and ADD a trailing '\n' (Java example does this)
- return sortedKeys.map((k) => map[k]).join('\n') + '\n';
-}
-
-// Build Walmart security headers (no trailing newline in the payload)
-export function generateWalmartHeaders() {
- const id = String(keyData.consumerId).trim();
- const kv = String(keyData.keyVer).trim(); // keep as STRING (e.g., "5")
- const ts = String(Date.now()).trim(); // epoch ms
-
- const toSign = canonicalizeForSignature({ consumerId: id, ts, keyVer: kv });
-
- // (Optional) log to verify there's a trailing newline at the end:
- // console.log("toSign (JSON):", JSON.stringify(toSign));
-
- const signature = crypto
- .sign('RSA-SHA256', Buffer.from(toSign, 'utf8'), {
- key: keyData.privateKeyPem, // your PEM private key
- padding: crypto.constants.RSA_PKCS1_PADDING, // PKCS#1 v1.5
- // passphrase: "...", // if your PEM is encrypted
- })
- .toString('base64');
-
- return {
- 'WM_CONSUMER.ID': id,
- 'WM_CONSUMER.INTIMESTAMP': ts, // Java example uses this one
- 'WM_SEC.TIMESTAMP': ts, // include too (v2 pages show this)
- 'WM_SEC.KEY_VERSION': kv,
- 'WM_SEC.AUTH_SIGNATURE': signature,
- Accept: 'application/json',
- };
-}
-
-export async function getStoresByZip(zipCode) {
- const url = new URL(
- 'https://developer.api.walmart.com/api-proxy/service/affil/product/v2/stores',
- );
- url.searchParams.set('zip', zipCode);
-
- const res = await fetch(url, {
- method: 'GET',
- headers: generateWalmartHeaders(),
- });
- const text = await res.text();
- if (!res.ok) throw new Error(`Stores HTTP ${res.status}: ${text}`);
- return JSON.parse(text); // { stores: [...] }
-}
-
-// // v2: Product lookup by UPC + ZIP (price & availability)
-// export async function getProductByUpcAtZip(upc, zipCode) {
-// const url = new URL("https://developer.api.walmart.com/api-proxy/service/affil/product/v2/items");
-// url.searchParams.set("upc", upc);
-// url.searchParams.set("zipCode", zipCode);
-
-// const res = await fetch(url, { method: "GET", headers: generateWalmartHeaders() });
-// const text = await res.text();
-// if (!res.ok) throw new Error(`Items HTTP ${res.status}: ${text}`);
-// return JSON.parse(text);
-// }
-
-// // v2: Product lookup by itemId (optional zipCode)
-// export async function getProductByItemId(itemId, zipCode) {
-// const url = new URL("https://developer.api.walmart.com/api-proxy/service/affil/product/v2/items");
-// url.searchParams.set("itemId", itemId);
-// if (zipCode) url.searchParams.set("zipCode", zipCode);
-
-// const res = await fetch(url, { method: "GET", headers: generateWalmartHeaders() });
-// const text = await res.text();
-// if (!res.ok) throw new Error(`Items HTTP ${res.status}: ${text}`);
-// return JSON.parse(text);
-// }
-
-// // Back-compat alias
-// export const getProductById = getProductByItemId;