autho 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin.js +2286 -2181
- package/package.json +14 -14
package/build/bin.js
CHANGED
|
@@ -57229,2370 +57229,2412 @@ var inquirer = {
|
|
|
57229
57229
|
};
|
|
57230
57230
|
var inquirer_default = inquirer;
|
|
57231
57231
|
|
|
57232
|
-
//
|
|
57233
|
-
var
|
|
57234
|
-
var
|
|
57235
|
-
const
|
|
57236
|
-
|
|
57237
|
-
|
|
57238
|
-
|
|
57239
|
-
|
|
57232
|
+
// node_modules/.pnpm/otpauth@9.2.3/node_modules/otpauth/dist/otpauth.node.mjs
|
|
57233
|
+
var crypto = __toESM(require("node:crypto"), 1);
|
|
57234
|
+
var uintToBuf = (num) => {
|
|
57235
|
+
const buf = new ArrayBuffer(8);
|
|
57236
|
+
const arr = new Uint8Array(buf);
|
|
57237
|
+
let acc = num;
|
|
57238
|
+
for (let i = 7; i >= 0; i--) {
|
|
57239
|
+
if (acc === 0)
|
|
57240
|
+
break;
|
|
57241
|
+
arr[i] = acc & 255;
|
|
57242
|
+
acc -= arr[i];
|
|
57243
|
+
acc /= 256;
|
|
57244
|
+
}
|
|
57245
|
+
return buf;
|
|
57246
|
+
};
|
|
57247
|
+
var jsSHA = void 0;
|
|
57248
|
+
var globalScope = (() => {
|
|
57249
|
+
if (typeof globalThis === "object")
|
|
57250
|
+
return globalThis;
|
|
57251
|
+
else {
|
|
57252
|
+
Object.defineProperty(Object.prototype, "__GLOBALTHIS__", {
|
|
57253
|
+
get() {
|
|
57254
|
+
return this;
|
|
57255
|
+
},
|
|
57256
|
+
configurable: true
|
|
57257
|
+
});
|
|
57258
|
+
try {
|
|
57259
|
+
if (typeof __GLOBALTHIS__ !== "undefined")
|
|
57260
|
+
return __GLOBALTHIS__;
|
|
57261
|
+
} finally {
|
|
57262
|
+
delete Object.prototype.__GLOBALTHIS__;
|
|
57240
57263
|
}
|
|
57241
|
-
|
|
57242
|
-
|
|
57264
|
+
}
|
|
57265
|
+
if (typeof self !== "undefined")
|
|
57266
|
+
return self;
|
|
57267
|
+
else if (typeof window !== "undefined")
|
|
57268
|
+
return window;
|
|
57269
|
+
else if (typeof global !== "undefined")
|
|
57270
|
+
return global;
|
|
57271
|
+
return void 0;
|
|
57272
|
+
})();
|
|
57273
|
+
var OPENSSL_JSSHA_ALGO_MAP = {
|
|
57274
|
+
SHA1: "SHA-1",
|
|
57275
|
+
SHA224: "SHA-224",
|
|
57276
|
+
SHA256: "SHA-256",
|
|
57277
|
+
SHA384: "SHA-384",
|
|
57278
|
+
SHA512: "SHA-512",
|
|
57279
|
+
"SHA3-224": "SHA3-224",
|
|
57280
|
+
"SHA3-256": "SHA3-256",
|
|
57281
|
+
"SHA3-384": "SHA3-384",
|
|
57282
|
+
"SHA3-512": "SHA3-512"
|
|
57243
57283
|
};
|
|
57244
|
-
|
|
57245
|
-
|
|
57246
|
-
|
|
57247
|
-
|
|
57248
|
-
|
|
57249
|
-
|
|
57250
|
-
|
|
57251
|
-
|
|
57252
|
-
|
|
57253
|
-
|
|
57254
|
-
|
|
57255
|
-
|
|
57256
|
-
|
|
57257
|
-
|
|
57258
|
-
|
|
57259
|
-
var import_crypto = __toESM(require("crypto"), 1);
|
|
57260
|
-
var import_fs = __toESM(require("fs"), 1);
|
|
57261
|
-
var import_path = __toESM(require("path"), 1);
|
|
57262
|
-
var import_zlib = __toESM(require("zlib"), 1);
|
|
57263
|
-
|
|
57264
|
-
// packages/shared/config.js
|
|
57265
|
-
var import_dotenv = __toESM(require_main2(), 1);
|
|
57266
|
-
import_dotenv.default.config();
|
|
57267
|
-
var config_default = {
|
|
57268
|
-
masterPasswordHash: process.env.AUTHO_MASTER_PASSWORD_HASH,
|
|
57269
|
-
masterPassword: process.env.AUTHO_MASTER_PASSWORD,
|
|
57270
|
-
randomSize: process.env.AUTHO_RANDOM_SIZE || 16,
|
|
57271
|
-
encryptionALgo: process.env.AUTHO_ENCRYPTION_ALGO || "aes-256-gcm",
|
|
57272
|
-
hashAlgo: process.env.AUTHO_HASH_ALGO || "sha256",
|
|
57273
|
-
dataFolder: process.env.AUTHO_DATA_FOLDER,
|
|
57274
|
-
name: process.env.AUTHO_COLLECTION_NAME || "default"
|
|
57284
|
+
var hmacDigest = (algorithm, key, message) => {
|
|
57285
|
+
if (crypto?.createHmac) {
|
|
57286
|
+
const hmac = crypto.createHmac(algorithm, globalScope.Buffer.from(key));
|
|
57287
|
+
hmac.update(globalScope.Buffer.from(message));
|
|
57288
|
+
return hmac.digest().buffer;
|
|
57289
|
+
} else {
|
|
57290
|
+
const variant = OPENSSL_JSSHA_ALGO_MAP[algorithm.toUpperCase()];
|
|
57291
|
+
if (typeof variant === "undefined") {
|
|
57292
|
+
throw new TypeError("Unknown hash function");
|
|
57293
|
+
}
|
|
57294
|
+
const hmac = new jsSHA(variant, "ARRAYBUFFER");
|
|
57295
|
+
hmac.setHMACKey(key, "ARRAYBUFFER");
|
|
57296
|
+
hmac.update(message);
|
|
57297
|
+
return hmac.getHMAC("ARRAYBUFFER");
|
|
57298
|
+
}
|
|
57275
57299
|
};
|
|
57276
|
-
|
|
57277
|
-
|
|
57278
|
-
|
|
57279
|
-
|
|
57280
|
-
|
|
57281
|
-
|
|
57282
|
-
|
|
57300
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
57301
|
+
var base32ToBuf = (str) => {
|
|
57302
|
+
let end = str.length;
|
|
57303
|
+
while (str[end - 1] === "=")
|
|
57304
|
+
--end;
|
|
57305
|
+
const cstr = (end < str.length ? str.substring(0, end) : str).toUpperCase();
|
|
57306
|
+
const buf = new ArrayBuffer(cstr.length * 5 / 8 | 0);
|
|
57307
|
+
const arr = new Uint8Array(buf);
|
|
57308
|
+
let bits = 0;
|
|
57309
|
+
let value = 0;
|
|
57310
|
+
let index = 0;
|
|
57311
|
+
for (let i = 0; i < cstr.length; i++) {
|
|
57312
|
+
const idx = ALPHABET.indexOf(cstr[i]);
|
|
57313
|
+
if (idx === -1)
|
|
57314
|
+
throw new TypeError(`Invalid character found: ${cstr[i]}`);
|
|
57315
|
+
value = value << 5 | idx;
|
|
57316
|
+
bits += 5;
|
|
57317
|
+
if (bits >= 8) {
|
|
57318
|
+
bits -= 8;
|
|
57319
|
+
arr[index++] = value >>> bits;
|
|
57320
|
+
}
|
|
57283
57321
|
}
|
|
57284
|
-
|
|
57285
|
-
|
|
57286
|
-
|
|
57322
|
+
return buf;
|
|
57323
|
+
};
|
|
57324
|
+
var base32FromBuf = (buf) => {
|
|
57325
|
+
const arr = new Uint8Array(buf);
|
|
57326
|
+
let bits = 0;
|
|
57327
|
+
let value = 0;
|
|
57328
|
+
let str = "";
|
|
57329
|
+
for (let i = 0; i < arr.length; i++) {
|
|
57330
|
+
value = value << 8 | arr[i];
|
|
57331
|
+
bits += 8;
|
|
57332
|
+
while (bits >= 5) {
|
|
57333
|
+
str += ALPHABET[value >>> bits - 5 & 31];
|
|
57334
|
+
bits -= 5;
|
|
57335
|
+
}
|
|
57287
57336
|
}
|
|
57288
|
-
|
|
57289
|
-
|
|
57290
|
-
return rnd;
|
|
57337
|
+
if (bits > 0) {
|
|
57338
|
+
str += ALPHABET[value << 5 - bits & 31];
|
|
57291
57339
|
}
|
|
57292
|
-
|
|
57293
|
-
|
|
57294
|
-
|
|
57295
|
-
|
|
57340
|
+
return str;
|
|
57341
|
+
};
|
|
57342
|
+
var hexToBuf = (str) => {
|
|
57343
|
+
const buf = new ArrayBuffer(str.length / 2);
|
|
57344
|
+
const arr = new Uint8Array(buf);
|
|
57345
|
+
for (let i = 0; i < str.length; i += 2) {
|
|
57346
|
+
arr[i / 2] = parseInt(str.substring(i, i + 2), 16);
|
|
57296
57347
|
}
|
|
57297
|
-
|
|
57298
|
-
|
|
57299
|
-
|
|
57348
|
+
return buf;
|
|
57349
|
+
};
|
|
57350
|
+
var hexFromBuf = (buf) => {
|
|
57351
|
+
const arr = new Uint8Array(buf);
|
|
57352
|
+
let str = "";
|
|
57353
|
+
for (let i = 0; i < arr.length; i++) {
|
|
57354
|
+
const hex = arr[i].toString(16);
|
|
57355
|
+
if (hex.length === 1)
|
|
57356
|
+
str += "0";
|
|
57357
|
+
str += hex;
|
|
57300
57358
|
}
|
|
57301
|
-
|
|
57302
|
-
|
|
57303
|
-
|
|
57304
|
-
|
|
57305
|
-
|
|
57306
|
-
|
|
57307
|
-
|
|
57308
|
-
let cipher = import_crypto.default.createCipheriv(
|
|
57309
|
-
algorithm,
|
|
57310
|
-
Buffer.from(encryptionKey, encoding),
|
|
57311
|
-
Buffer.from(publicKey, encoding),
|
|
57312
|
-
{ authTagLength: 16 }
|
|
57313
|
-
);
|
|
57314
|
-
let encrypted = cipher.update(value);
|
|
57315
|
-
encrypted = Buffer.concat([encrypted, cipher.final()]);
|
|
57316
|
-
encrypted = encrypted.toString(encoding);
|
|
57317
|
-
const authTag = cipher.getAuthTag().toString(encoding);
|
|
57318
|
-
return {
|
|
57319
|
-
publicKey,
|
|
57320
|
-
encrypted,
|
|
57321
|
-
algorithm,
|
|
57322
|
-
signature: _Cipher.sign(value),
|
|
57323
|
-
encoding,
|
|
57324
|
-
authTag,
|
|
57325
|
-
provider: "crypto",
|
|
57326
|
-
platform: "autho"
|
|
57327
|
-
};
|
|
57359
|
+
return str.toUpperCase();
|
|
57360
|
+
};
|
|
57361
|
+
var latin1ToBuf = (str) => {
|
|
57362
|
+
const buf = new ArrayBuffer(str.length);
|
|
57363
|
+
const arr = new Uint8Array(buf);
|
|
57364
|
+
for (let i = 0; i < str.length; i++) {
|
|
57365
|
+
arr[i] = str.charCodeAt(i) & 255;
|
|
57328
57366
|
}
|
|
57329
|
-
|
|
57330
|
-
|
|
57331
|
-
|
|
57332
|
-
|
|
57333
|
-
|
|
57334
|
-
|
|
57335
|
-
|
|
57336
|
-
encoding = "hex"
|
|
57337
|
-
}) {
|
|
57338
|
-
value = Buffer.from(value, encoding);
|
|
57339
|
-
let decipher = import_crypto.default.createDecipheriv(
|
|
57340
|
-
algorithm,
|
|
57341
|
-
Buffer.from(encryptionKey, encoding),
|
|
57342
|
-
Buffer.from(publicKey, encoding),
|
|
57343
|
-
{ authTagLength: 16 }
|
|
57344
|
-
);
|
|
57345
|
-
if (authTag) {
|
|
57346
|
-
decipher.setAuthTag(Buffer.from(authTag, encoding));
|
|
57347
|
-
}
|
|
57348
|
-
let decrypted = decipher.update(value);
|
|
57349
|
-
decrypted = Buffer.concat([decrypted, decipher.final()]);
|
|
57350
|
-
decrypted = decrypted.toString();
|
|
57351
|
-
if (signature && !_Cipher.verify(decrypted, signature)) {
|
|
57352
|
-
throw new Error("Invalid signature");
|
|
57353
|
-
}
|
|
57354
|
-
return decrypted;
|
|
57367
|
+
return buf;
|
|
57368
|
+
};
|
|
57369
|
+
var latin1FromBuf = (buf) => {
|
|
57370
|
+
const arr = new Uint8Array(buf);
|
|
57371
|
+
let str = "";
|
|
57372
|
+
for (let i = 0; i < arr.length; i++) {
|
|
57373
|
+
str += String.fromCharCode(arr[i]);
|
|
57355
57374
|
}
|
|
57356
|
-
|
|
57357
|
-
|
|
57375
|
+
return str;
|
|
57376
|
+
};
|
|
57377
|
+
var ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder("utf-8") : null;
|
|
57378
|
+
var DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder("utf-8") : null;
|
|
57379
|
+
var utf8ToBuf = (str) => {
|
|
57380
|
+
if (!ENCODER) {
|
|
57381
|
+
throw new Error("Encoding API not available");
|
|
57358
57382
|
}
|
|
57359
|
-
|
|
57360
|
-
|
|
57361
|
-
|
|
57362
|
-
|
|
57363
|
-
|
|
57364
|
-
};
|
|
57365
|
-
const encryptedData = _Cipher.encrypt(params);
|
|
57366
|
-
import_fs.default.writeFileSync(
|
|
57367
|
-
outputFilePath,
|
|
57368
|
-
Buffer.from(JSON.stringify(encryptedData)).toString("base64")
|
|
57369
|
-
);
|
|
57383
|
+
return ENCODER.encode(str).buffer;
|
|
57384
|
+
};
|
|
57385
|
+
var utf8FromBuf = (buf) => {
|
|
57386
|
+
if (!DECODER) {
|
|
57387
|
+
throw new Error("Encoding API not available");
|
|
57370
57388
|
}
|
|
57371
|
-
|
|
57372
|
-
|
|
57373
|
-
|
|
57374
|
-
|
|
57375
|
-
|
|
57376
|
-
|
|
57377
|
-
|
|
57378
|
-
|
|
57379
|
-
throw new Error("Invalid file");
|
|
57389
|
+
return DECODER.decode(buf);
|
|
57390
|
+
};
|
|
57391
|
+
var randomBytes2 = (size) => {
|
|
57392
|
+
if (crypto?.randomBytes) {
|
|
57393
|
+
return crypto.randomBytes(size).buffer;
|
|
57394
|
+
} else {
|
|
57395
|
+
if (!globalScope.crypto?.getRandomValues) {
|
|
57396
|
+
throw new Error("Cryptography API not available");
|
|
57380
57397
|
}
|
|
57381
|
-
|
|
57382
|
-
...encryptedData,
|
|
57383
|
-
value: encryptedData.encrypted,
|
|
57384
|
-
encryptionKey
|
|
57385
|
-
};
|
|
57386
|
-
const decryptedData = _Cipher.decrypt(params);
|
|
57387
|
-
import_fs.default.writeFileSync(outputFilePath, decryptedData);
|
|
57398
|
+
return globalScope.crypto.getRandomValues(new Uint8Array(size)).buffer;
|
|
57388
57399
|
}
|
|
57389
|
-
|
|
57390
|
-
|
|
57391
|
-
|
|
57392
|
-
|
|
57393
|
-
|
|
57394
|
-
|
|
57395
|
-
|
|
57396
|
-
|
|
57397
|
-
|
|
57398
|
-
|
|
57399
|
-
|
|
57400
|
-
|
|
57401
|
-
|
|
57402
|
-
const params = {
|
|
57403
|
-
value: fileContent,
|
|
57404
|
-
encryptionKey,
|
|
57405
|
-
algorithm,
|
|
57406
|
-
encoding
|
|
57407
|
-
};
|
|
57408
|
-
const encryptedData = _Cipher.encrypt(params);
|
|
57409
|
-
const encrypted = encryptedData.encrypted;
|
|
57410
|
-
delete encryptedData.encrypted;
|
|
57411
|
-
const encryptionMeta = Buffer.from(JSON.stringify(encryptedData)).toString("base64");
|
|
57412
|
-
gzip.write(`${itemPath}
|
|
57413
|
-
---
|
|
57414
|
-
${encrypted}
|
|
57415
|
-
---
|
|
57416
|
-
${encryptionMeta}
|
|
57417
|
-
:::
|
|
57418
|
-
`);
|
|
57419
|
-
}
|
|
57420
|
-
}
|
|
57421
|
-
}
|
|
57422
|
-
traverseFolder(inputFolderPath);
|
|
57423
|
-
gzip.end();
|
|
57424
|
-
return new Promise((resolve, reject) => {
|
|
57425
|
-
outputStream.on("finish", resolve);
|
|
57426
|
-
outputStream.on("error", reject);
|
|
57427
|
-
});
|
|
57400
|
+
};
|
|
57401
|
+
var Secret = class _Secret {
|
|
57402
|
+
/**
|
|
57403
|
+
* Creates a secret key object.
|
|
57404
|
+
* @param {Object} [config] Configuration options.
|
|
57405
|
+
* @param {ArrayBuffer} [config.buffer=randomBytes] Secret key.
|
|
57406
|
+
* @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.
|
|
57407
|
+
*/
|
|
57408
|
+
constructor({
|
|
57409
|
+
buffer,
|
|
57410
|
+
size = 20
|
|
57411
|
+
} = {}) {
|
|
57412
|
+
this.buffer = typeof buffer === "undefined" ? randomBytes2(size) : buffer;
|
|
57428
57413
|
}
|
|
57429
|
-
|
|
57430
|
-
|
|
57431
|
-
|
|
57432
|
-
|
|
57433
|
-
|
|
57434
|
-
|
|
57435
|
-
|
|
57436
|
-
|
|
57437
|
-
const [file, next] = buff.split("\n:::\n");
|
|
57438
|
-
let [filePath, encrypted, encryptionMeta] = file.split("\n---\n");
|
|
57439
|
-
filePath = import_path.default.join(outputFolderPath, filePath);
|
|
57440
|
-
try {
|
|
57441
|
-
import_fs.default.mkdirSync(import_path.default.dirname(filePath), { recursive: true });
|
|
57442
|
-
} catch (error) {
|
|
57443
|
-
}
|
|
57444
|
-
const decoded = Buffer.from(
|
|
57445
|
-
encryptionMeta,
|
|
57446
|
-
"base64"
|
|
57447
|
-
).toString("utf-8");
|
|
57448
|
-
const metaData = JSON.parse(decoded);
|
|
57449
|
-
const params = {
|
|
57450
|
-
...metaData,
|
|
57451
|
-
value: encrypted,
|
|
57452
|
-
encryptionKey
|
|
57453
|
-
};
|
|
57454
|
-
const decryptedData = _Cipher.decrypt(params);
|
|
57455
|
-
import_fs.default.writeFileSync(filePath, decryptedData);
|
|
57456
|
-
buff = next;
|
|
57457
|
-
}
|
|
57458
|
-
};
|
|
57459
|
-
gunzip.on("data", (data) => {
|
|
57460
|
-
compileFile(data.toString("utf8"));
|
|
57461
|
-
});
|
|
57462
|
-
return new Promise((resolve, reject) => {
|
|
57463
|
-
gunzip.on("end", resolve);
|
|
57464
|
-
gunzip.on("error", reject);
|
|
57414
|
+
/**
|
|
57415
|
+
* Converts a Latin-1 string to a Secret object.
|
|
57416
|
+
* @param {string} str Latin-1 string.
|
|
57417
|
+
* @returns {Secret} Secret object.
|
|
57418
|
+
*/
|
|
57419
|
+
static fromLatin1(str) {
|
|
57420
|
+
return new _Secret({
|
|
57421
|
+
buffer: latin1ToBuf(str)
|
|
57465
57422
|
});
|
|
57466
57423
|
}
|
|
57467
|
-
|
|
57468
|
-
|
|
57469
|
-
|
|
57470
|
-
|
|
57471
|
-
|
|
57472
|
-
|
|
57424
|
+
/**
|
|
57425
|
+
* Converts an UTF-8 string to a Secret object.
|
|
57426
|
+
* @param {string} str UTF-8 string.
|
|
57427
|
+
* @returns {Secret} Secret object.
|
|
57428
|
+
*/
|
|
57429
|
+
static fromUTF8(str) {
|
|
57430
|
+
return new _Secret({
|
|
57431
|
+
buffer: utf8ToBuf(str)
|
|
57432
|
+
});
|
|
57473
57433
|
}
|
|
57474
|
-
|
|
57475
|
-
|
|
57434
|
+
/**
|
|
57435
|
+
* Converts a base32 string to a Secret object.
|
|
57436
|
+
* @param {string} str Base32 string.
|
|
57437
|
+
* @returns {Secret} Secret object.
|
|
57438
|
+
*/
|
|
57439
|
+
static fromBase32(str) {
|
|
57440
|
+
return new _Secret({
|
|
57441
|
+
buffer: base32ToBuf(str)
|
|
57442
|
+
});
|
|
57476
57443
|
}
|
|
57477
|
-
|
|
57478
|
-
|
|
57444
|
+
/**
|
|
57445
|
+
* Converts a hexadecimal string to a Secret object.
|
|
57446
|
+
* @param {string} str Hexadecimal string.
|
|
57447
|
+
* @returns {Secret} Secret object.
|
|
57448
|
+
*/
|
|
57449
|
+
static fromHex(str) {
|
|
57450
|
+
return new _Secret({
|
|
57451
|
+
buffer: hexToBuf(str)
|
|
57452
|
+
});
|
|
57479
57453
|
}
|
|
57480
|
-
|
|
57481
|
-
|
|
57454
|
+
/**
|
|
57455
|
+
* Latin-1 string representation of secret key.
|
|
57456
|
+
* @type {string}
|
|
57457
|
+
*/
|
|
57458
|
+
get latin1() {
|
|
57459
|
+
Object.defineProperty(this, "latin1", {
|
|
57460
|
+
enumerable: true,
|
|
57461
|
+
value: latin1FromBuf(this.buffer)
|
|
57462
|
+
});
|
|
57463
|
+
return this.latin1;
|
|
57482
57464
|
}
|
|
57483
|
-
|
|
57484
|
-
|
|
57485
|
-
|
|
57486
|
-
|
|
57487
|
-
|
|
57488
|
-
|
|
57489
|
-
|
|
57490
|
-
|
|
57465
|
+
/**
|
|
57466
|
+
* UTF-8 string representation of secret key.
|
|
57467
|
+
* @type {string}
|
|
57468
|
+
*/
|
|
57469
|
+
get utf8() {
|
|
57470
|
+
Object.defineProperty(this, "utf8", {
|
|
57471
|
+
enumerable: true,
|
|
57472
|
+
value: utf8FromBuf(this.buffer)
|
|
57491
57473
|
});
|
|
57492
|
-
this.
|
|
57493
|
-
...this.secrets,
|
|
57494
|
-
{ ...value, ...encryption, value: encrypted }
|
|
57495
|
-
];
|
|
57474
|
+
return this.utf8;
|
|
57496
57475
|
}
|
|
57497
|
-
|
|
57498
|
-
|
|
57476
|
+
/**
|
|
57477
|
+
* Base32 string representation of secret key.
|
|
57478
|
+
* @type {string}
|
|
57479
|
+
*/
|
|
57480
|
+
get base32() {
|
|
57481
|
+
Object.defineProperty(this, "base32", {
|
|
57482
|
+
enumerable: true,
|
|
57483
|
+
value: base32FromBuf(this.buffer)
|
|
57484
|
+
});
|
|
57485
|
+
return this.base32;
|
|
57499
57486
|
}
|
|
57500
|
-
|
|
57501
|
-
|
|
57487
|
+
/**
|
|
57488
|
+
* Hexadecimal string representation of secret key.
|
|
57489
|
+
* @type {string}
|
|
57490
|
+
*/
|
|
57491
|
+
get hex() {
|
|
57492
|
+
Object.defineProperty(this, "hex", {
|
|
57493
|
+
enumerable: true,
|
|
57494
|
+
value: hexFromBuf(this.buffer)
|
|
57495
|
+
});
|
|
57496
|
+
return this.hex;
|
|
57502
57497
|
}
|
|
57503
57498
|
};
|
|
57504
|
-
|
|
57505
|
-
|
|
57506
|
-
|
|
57507
|
-
|
|
57508
|
-
|
|
57509
|
-
|
|
57510
|
-
|
|
57511
|
-
|
|
57512
|
-
|
|
57513
|
-
|
|
57514
|
-
|
|
57515
|
-
|
|
57516
|
-
|
|
57499
|
+
var timingSafeEqual2 = (a, b) => {
|
|
57500
|
+
if (crypto?.timingSafeEqual) {
|
|
57501
|
+
return crypto.timingSafeEqual(globalScope.Buffer.from(a), globalScope.Buffer.from(b));
|
|
57502
|
+
} else {
|
|
57503
|
+
if (a.length !== b.length) {
|
|
57504
|
+
throw new TypeError("Input strings must have the same length");
|
|
57505
|
+
}
|
|
57506
|
+
let i = -1;
|
|
57507
|
+
let out = 0;
|
|
57508
|
+
while (++i < a.length) {
|
|
57509
|
+
out |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
57510
|
+
}
|
|
57511
|
+
return out === 0;
|
|
57512
|
+
}
|
|
57517
57513
|
};
|
|
57518
|
-
var
|
|
57519
|
-
|
|
57520
|
-
|
|
57521
|
-
|
|
57522
|
-
|
|
57523
|
-
|
|
57524
|
-
|
|
57525
|
-
|
|
57526
|
-
|
|
57527
|
-
|
|
57528
|
-
|
|
57529
|
-
|
|
57530
|
-
|
|
57531
|
-
|
|
57532
|
-
|
|
57533
|
-
|
|
57534
|
-
|
|
57535
|
-
|
|
57536
|
-
|
|
57537
|
-
|
|
57538
|
-
|
|
57539
|
-
|
|
57540
|
-
|
|
57541
|
-
currentPart = "property";
|
|
57542
|
-
isIgnoring = !isIgnoring;
|
|
57543
|
-
break;
|
|
57544
|
-
}
|
|
57545
|
-
case ".": {
|
|
57546
|
-
if (currentPart === "index") {
|
|
57547
|
-
throw new Error("Invalid character in an index");
|
|
57548
|
-
}
|
|
57549
|
-
if (currentPart === "indexEnd") {
|
|
57550
|
-
currentPart = "property";
|
|
57551
|
-
break;
|
|
57552
|
-
}
|
|
57553
|
-
if (isIgnoring) {
|
|
57554
|
-
isIgnoring = false;
|
|
57555
|
-
currentSegment += character;
|
|
57556
|
-
break;
|
|
57557
|
-
}
|
|
57558
|
-
if (disallowedKeys.has(currentSegment)) {
|
|
57559
|
-
return [];
|
|
57560
|
-
}
|
|
57561
|
-
parts.push(currentSegment);
|
|
57562
|
-
currentSegment = "";
|
|
57563
|
-
currentPart = "property";
|
|
57564
|
-
break;
|
|
57565
|
-
}
|
|
57566
|
-
case "[": {
|
|
57567
|
-
if (currentPart === "index") {
|
|
57568
|
-
throw new Error("Invalid character in an index");
|
|
57569
|
-
}
|
|
57570
|
-
if (currentPart === "indexEnd") {
|
|
57571
|
-
currentPart = "index";
|
|
57572
|
-
break;
|
|
57573
|
-
}
|
|
57574
|
-
if (isIgnoring) {
|
|
57575
|
-
isIgnoring = false;
|
|
57576
|
-
currentSegment += character;
|
|
57577
|
-
break;
|
|
57578
|
-
}
|
|
57579
|
-
if (currentPart === "property") {
|
|
57580
|
-
if (disallowedKeys.has(currentSegment)) {
|
|
57581
|
-
return [];
|
|
57582
|
-
}
|
|
57583
|
-
parts.push(currentSegment);
|
|
57584
|
-
currentSegment = "";
|
|
57585
|
-
}
|
|
57586
|
-
currentPart = "index";
|
|
57587
|
-
break;
|
|
57588
|
-
}
|
|
57589
|
-
case "]": {
|
|
57590
|
-
if (currentPart === "index") {
|
|
57591
|
-
parts.push(Number.parseInt(currentSegment, 10));
|
|
57592
|
-
currentSegment = "";
|
|
57593
|
-
currentPart = "indexEnd";
|
|
57594
|
-
break;
|
|
57595
|
-
}
|
|
57596
|
-
if (currentPart === "indexEnd") {
|
|
57597
|
-
throw new Error("Invalid character after an index");
|
|
57598
|
-
}
|
|
57599
|
-
}
|
|
57600
|
-
default: {
|
|
57601
|
-
if (currentPart === "index" && !digits.has(character)) {
|
|
57602
|
-
throw new Error("Invalid character in an index");
|
|
57603
|
-
}
|
|
57604
|
-
if (currentPart === "indexEnd") {
|
|
57605
|
-
throw new Error("Invalid character after an index");
|
|
57606
|
-
}
|
|
57607
|
-
if (currentPart === "start") {
|
|
57608
|
-
currentPart = "property";
|
|
57609
|
-
}
|
|
57610
|
-
if (isIgnoring) {
|
|
57611
|
-
isIgnoring = false;
|
|
57612
|
-
currentSegment += "\\";
|
|
57613
|
-
}
|
|
57614
|
-
currentSegment += character;
|
|
57615
|
-
}
|
|
57616
|
-
}
|
|
57514
|
+
var HOTP = class _HOTP {
|
|
57515
|
+
/**
|
|
57516
|
+
* Default configuration.
|
|
57517
|
+
* @type {{
|
|
57518
|
+
* issuer: string,
|
|
57519
|
+
* label: string,
|
|
57520
|
+
* issuerInLabel: boolean,
|
|
57521
|
+
* algorithm: string,
|
|
57522
|
+
* digits: number,
|
|
57523
|
+
* counter: number
|
|
57524
|
+
* window: number
|
|
57525
|
+
* }}
|
|
57526
|
+
*/
|
|
57527
|
+
static get defaults() {
|
|
57528
|
+
return {
|
|
57529
|
+
issuer: "",
|
|
57530
|
+
label: "OTPAuth",
|
|
57531
|
+
issuerInLabel: true,
|
|
57532
|
+
algorithm: "SHA1",
|
|
57533
|
+
digits: 6,
|
|
57534
|
+
counter: 0,
|
|
57535
|
+
window: 1
|
|
57536
|
+
};
|
|
57617
57537
|
}
|
|
57618
|
-
|
|
57619
|
-
|
|
57538
|
+
/**
|
|
57539
|
+
* Creates an HOTP object.
|
|
57540
|
+
* @param {Object} [config] Configuration options.
|
|
57541
|
+
* @param {string} [config.issuer=''] Account provider.
|
|
57542
|
+
* @param {string} [config.label='OTPAuth'] Account label.
|
|
57543
|
+
* @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.
|
|
57544
|
+
* @param {Secret|string} [config.secret=Secret] Secret key.
|
|
57545
|
+
* @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.
|
|
57546
|
+
* @param {number} [config.digits=6] Token length.
|
|
57547
|
+
* @param {number} [config.counter=0] Initial counter value.
|
|
57548
|
+
*/
|
|
57549
|
+
constructor({
|
|
57550
|
+
issuer = _HOTP.defaults.issuer,
|
|
57551
|
+
label = _HOTP.defaults.label,
|
|
57552
|
+
issuerInLabel = _HOTP.defaults.issuerInLabel,
|
|
57553
|
+
secret = new Secret(),
|
|
57554
|
+
algorithm = _HOTP.defaults.algorithm,
|
|
57555
|
+
digits: digits2 = _HOTP.defaults.digits,
|
|
57556
|
+
counter = _HOTP.defaults.counter
|
|
57557
|
+
} = {}) {
|
|
57558
|
+
this.issuer = issuer;
|
|
57559
|
+
this.label = label;
|
|
57560
|
+
this.issuerInLabel = issuerInLabel;
|
|
57561
|
+
this.secret = typeof secret === "string" ? Secret.fromBase32(secret) : secret;
|
|
57562
|
+
this.algorithm = algorithm.toUpperCase();
|
|
57563
|
+
this.digits = digits2;
|
|
57564
|
+
this.counter = counter;
|
|
57620
57565
|
}
|
|
57621
|
-
|
|
57622
|
-
|
|
57623
|
-
|
|
57624
|
-
|
|
57566
|
+
/**
|
|
57567
|
+
* Generates an HOTP token.
|
|
57568
|
+
* @param {Object} config Configuration options.
|
|
57569
|
+
* @param {Secret} config.secret Secret key.
|
|
57570
|
+
* @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.
|
|
57571
|
+
* @param {number} [config.digits=6] Token length.
|
|
57572
|
+
* @param {number} [config.counter=0] Counter value.
|
|
57573
|
+
* @returns {string} Token.
|
|
57574
|
+
*/
|
|
57575
|
+
static generate({
|
|
57576
|
+
secret,
|
|
57577
|
+
algorithm = _HOTP.defaults.algorithm,
|
|
57578
|
+
digits: digits2 = _HOTP.defaults.digits,
|
|
57579
|
+
counter = _HOTP.defaults.counter
|
|
57580
|
+
}) {
|
|
57581
|
+
const digest = new Uint8Array(hmacDigest(algorithm, secret.buffer, uintToBuf(counter)));
|
|
57582
|
+
const offset = digest[digest.byteLength - 1] & 15;
|
|
57583
|
+
const otp = ((digest[offset] & 127) << 24 | (digest[offset + 1] & 255) << 16 | (digest[offset + 2] & 255) << 8 | digest[offset + 3] & 255) % 10 ** digits2;
|
|
57584
|
+
return otp.toString().padStart(digits2, "0");
|
|
57585
|
+
}
|
|
57586
|
+
/**
|
|
57587
|
+
* Generates an HOTP token.
|
|
57588
|
+
* @param {Object} [config] Configuration options.
|
|
57589
|
+
* @param {number} [config.counter=this.counter++] Counter value.
|
|
57590
|
+
* @returns {string} Token.
|
|
57591
|
+
*/
|
|
57592
|
+
generate({
|
|
57593
|
+
counter = this.counter++
|
|
57594
|
+
} = {}) {
|
|
57595
|
+
return _HOTP.generate({
|
|
57596
|
+
secret: this.secret,
|
|
57597
|
+
algorithm: this.algorithm,
|
|
57598
|
+
digits: this.digits,
|
|
57599
|
+
counter
|
|
57600
|
+
});
|
|
57601
|
+
}
|
|
57602
|
+
/**
|
|
57603
|
+
* Validates an HOTP token.
|
|
57604
|
+
* @param {Object} config Configuration options.
|
|
57605
|
+
* @param {string} config.token Token value.
|
|
57606
|
+
* @param {Secret} config.secret Secret key.
|
|
57607
|
+
* @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.
|
|
57608
|
+
* @param {number} config.digits Token length.
|
|
57609
|
+
* @param {number} [config.counter=0] Counter value.
|
|
57610
|
+
* @param {number} [config.window=1] Window of counter values to test.
|
|
57611
|
+
* @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.
|
|
57612
|
+
*/
|
|
57613
|
+
static validate({
|
|
57614
|
+
token,
|
|
57615
|
+
secret,
|
|
57616
|
+
algorithm,
|
|
57617
|
+
digits: digits2,
|
|
57618
|
+
counter = _HOTP.defaults.counter,
|
|
57619
|
+
window: window2 = _HOTP.defaults.window
|
|
57620
|
+
}) {
|
|
57621
|
+
if (token.length !== digits2)
|
|
57622
|
+
return null;
|
|
57623
|
+
let delta = null;
|
|
57624
|
+
for (let i = counter - window2; i <= counter + window2; ++i) {
|
|
57625
|
+
const generatedToken = _HOTP.generate({
|
|
57626
|
+
secret,
|
|
57627
|
+
algorithm,
|
|
57628
|
+
digits: digits2,
|
|
57629
|
+
counter: i
|
|
57630
|
+
});
|
|
57631
|
+
if (timingSafeEqual2(token, generatedToken)) {
|
|
57632
|
+
delta = i - counter;
|
|
57625
57633
|
}
|
|
57626
|
-
parts.push(currentSegment);
|
|
57627
|
-
break;
|
|
57628
|
-
}
|
|
57629
|
-
case "index": {
|
|
57630
|
-
throw new Error("Index was not closed");
|
|
57631
|
-
}
|
|
57632
|
-
case "start": {
|
|
57633
|
-
parts.push("");
|
|
57634
|
-
break;
|
|
57635
57634
|
}
|
|
57635
|
+
return delta;
|
|
57636
57636
|
}
|
|
57637
|
-
|
|
57638
|
-
|
|
57639
|
-
|
|
57640
|
-
|
|
57641
|
-
|
|
57642
|
-
|
|
57637
|
+
/**
|
|
57638
|
+
* Validates an HOTP token.
|
|
57639
|
+
* @param {Object} config Configuration options.
|
|
57640
|
+
* @param {string} config.token Token value.
|
|
57641
|
+
* @param {number} [config.counter=this.counter] Counter value.
|
|
57642
|
+
* @param {number} [config.window=1] Window of counter values to test.
|
|
57643
|
+
* @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.
|
|
57644
|
+
*/
|
|
57645
|
+
validate({
|
|
57646
|
+
token,
|
|
57647
|
+
counter = this.counter,
|
|
57648
|
+
window: window2
|
|
57649
|
+
}) {
|
|
57650
|
+
return _HOTP.validate({
|
|
57651
|
+
token,
|
|
57652
|
+
secret: this.secret,
|
|
57653
|
+
algorithm: this.algorithm,
|
|
57654
|
+
digits: this.digits,
|
|
57655
|
+
counter,
|
|
57656
|
+
window: window2
|
|
57657
|
+
});
|
|
57643
57658
|
}
|
|
57644
|
-
|
|
57645
|
-
|
|
57646
|
-
|
|
57647
|
-
|
|
57648
|
-
|
|
57659
|
+
/**
|
|
57660
|
+
* Returns a Google Authenticator key URI.
|
|
57661
|
+
* @returns {string} URI.
|
|
57662
|
+
*/
|
|
57663
|
+
toString() {
|
|
57664
|
+
const e = encodeURIComponent;
|
|
57665
|
+
return `otpauth://hotp/${this.issuer.length > 0 ? this.issuerInLabel ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&` : `${e(this.label)}?issuer=${e(this.issuer)}&` : `${e(this.label)}?`}secret=${e(this.secret.base32)}&algorithm=${e(this.algorithm)}&digits=${e(this.digits)}&counter=${e(this.counter)}`;
|
|
57649
57666
|
}
|
|
57650
|
-
}
|
|
57651
|
-
|
|
57652
|
-
|
|
57653
|
-
|
|
57667
|
+
};
|
|
57668
|
+
var TOTP = class _TOTP {
|
|
57669
|
+
/**
|
|
57670
|
+
* Default configuration.
|
|
57671
|
+
* @type {{
|
|
57672
|
+
* issuer: string,
|
|
57673
|
+
* label: string,
|
|
57674
|
+
* issuerInLabel: boolean,
|
|
57675
|
+
* algorithm: string,
|
|
57676
|
+
* digits: number,
|
|
57677
|
+
* period: number
|
|
57678
|
+
* window: number
|
|
57679
|
+
* }}
|
|
57680
|
+
*/
|
|
57681
|
+
static get defaults() {
|
|
57682
|
+
return {
|
|
57683
|
+
issuer: "",
|
|
57684
|
+
label: "OTPAuth",
|
|
57685
|
+
issuerInLabel: true,
|
|
57686
|
+
algorithm: "SHA1",
|
|
57687
|
+
digits: 6,
|
|
57688
|
+
period: 30,
|
|
57689
|
+
window: 1
|
|
57690
|
+
};
|
|
57654
57691
|
}
|
|
57655
|
-
|
|
57656
|
-
|
|
57657
|
-
|
|
57692
|
+
/**
|
|
57693
|
+
* Creates a TOTP object.
|
|
57694
|
+
* @param {Object} [config] Configuration options.
|
|
57695
|
+
* @param {string} [config.issuer=''] Account provider.
|
|
57696
|
+
* @param {string} [config.label='OTPAuth'] Account label.
|
|
57697
|
+
* @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.
|
|
57698
|
+
* @param {Secret|string} [config.secret=Secret] Secret key.
|
|
57699
|
+
* @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.
|
|
57700
|
+
* @param {number} [config.digits=6] Token length.
|
|
57701
|
+
* @param {number} [config.period=30] Token time-step duration.
|
|
57702
|
+
*/
|
|
57703
|
+
constructor({
|
|
57704
|
+
issuer = _TOTP.defaults.issuer,
|
|
57705
|
+
label = _TOTP.defaults.label,
|
|
57706
|
+
issuerInLabel = _TOTP.defaults.issuerInLabel,
|
|
57707
|
+
secret = new Secret(),
|
|
57708
|
+
algorithm = _TOTP.defaults.algorithm,
|
|
57709
|
+
digits: digits2 = _TOTP.defaults.digits,
|
|
57710
|
+
period = _TOTP.defaults.period
|
|
57711
|
+
} = {}) {
|
|
57712
|
+
this.issuer = issuer;
|
|
57713
|
+
this.label = label;
|
|
57714
|
+
this.issuerInLabel = issuerInLabel;
|
|
57715
|
+
this.secret = typeof secret === "string" ? Secret.fromBase32(secret) : secret;
|
|
57716
|
+
this.algorithm = algorithm.toUpperCase();
|
|
57717
|
+
this.digits = digits2;
|
|
57718
|
+
this.period = period;
|
|
57658
57719
|
}
|
|
57659
|
-
|
|
57660
|
-
|
|
57661
|
-
|
|
57662
|
-
|
|
57663
|
-
|
|
57664
|
-
|
|
57665
|
-
|
|
57666
|
-
|
|
57667
|
-
|
|
57668
|
-
|
|
57669
|
-
|
|
57670
|
-
|
|
57671
|
-
|
|
57720
|
+
/**
|
|
57721
|
+
* Generates a TOTP token.
|
|
57722
|
+
* @param {Object} config Configuration options.
|
|
57723
|
+
* @param {Secret} config.secret Secret key.
|
|
57724
|
+
* @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.
|
|
57725
|
+
* @param {number} [config.digits=6] Token length.
|
|
57726
|
+
* @param {number} [config.period=30] Token time-step duration.
|
|
57727
|
+
* @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.
|
|
57728
|
+
* @returns {string} Token.
|
|
57729
|
+
*/
|
|
57730
|
+
static generate({
|
|
57731
|
+
secret,
|
|
57732
|
+
algorithm,
|
|
57733
|
+
digits: digits2,
|
|
57734
|
+
period = _TOTP.defaults.period,
|
|
57735
|
+
timestamp = Date.now()
|
|
57736
|
+
}) {
|
|
57737
|
+
return HOTP.generate({
|
|
57738
|
+
secret,
|
|
57739
|
+
algorithm,
|
|
57740
|
+
digits: digits2,
|
|
57741
|
+
counter: Math.floor(timestamp / 1e3 / period)
|
|
57742
|
+
});
|
|
57672
57743
|
}
|
|
57673
|
-
|
|
57674
|
-
|
|
57675
|
-
|
|
57676
|
-
|
|
57677
|
-
|
|
57744
|
+
/**
|
|
57745
|
+
* Generates a TOTP token.
|
|
57746
|
+
* @param {Object} [config] Configuration options.
|
|
57747
|
+
* @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.
|
|
57748
|
+
* @returns {string} Token.
|
|
57749
|
+
*/
|
|
57750
|
+
generate({
|
|
57751
|
+
timestamp = Date.now()
|
|
57752
|
+
} = {}) {
|
|
57753
|
+
return _TOTP.generate({
|
|
57754
|
+
secret: this.secret,
|
|
57755
|
+
algorithm: this.algorithm,
|
|
57756
|
+
digits: this.digits,
|
|
57757
|
+
period: this.period,
|
|
57758
|
+
timestamp
|
|
57759
|
+
});
|
|
57678
57760
|
}
|
|
57679
|
-
|
|
57680
|
-
|
|
57681
|
-
|
|
57682
|
-
|
|
57683
|
-
|
|
57684
|
-
|
|
57685
|
-
|
|
57686
|
-
|
|
57687
|
-
|
|
57688
|
-
|
|
57689
|
-
|
|
57761
|
+
/**
|
|
57762
|
+
* Validates a TOTP token.
|
|
57763
|
+
* @param {Object} config Configuration options.
|
|
57764
|
+
* @param {string} config.token Token value.
|
|
57765
|
+
* @param {Secret} config.secret Secret key.
|
|
57766
|
+
* @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.
|
|
57767
|
+
* @param {number} config.digits Token length.
|
|
57768
|
+
* @param {number} [config.period=30] Token time-step duration.
|
|
57769
|
+
* @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.
|
|
57770
|
+
* @param {number} [config.window=1] Window of counter values to test.
|
|
57771
|
+
* @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.
|
|
57772
|
+
*/
|
|
57773
|
+
static validate({
|
|
57774
|
+
token,
|
|
57775
|
+
secret,
|
|
57776
|
+
algorithm,
|
|
57777
|
+
digits: digits2,
|
|
57778
|
+
period = _TOTP.defaults.period,
|
|
57779
|
+
timestamp = Date.now(),
|
|
57780
|
+
window: window2
|
|
57781
|
+
}) {
|
|
57782
|
+
return HOTP.validate({
|
|
57783
|
+
token,
|
|
57784
|
+
secret,
|
|
57785
|
+
algorithm,
|
|
57786
|
+
digits: digits2,
|
|
57787
|
+
counter: Math.floor(timestamp / 1e3 / period),
|
|
57788
|
+
window: window2
|
|
57789
|
+
});
|
|
57690
57790
|
}
|
|
57691
|
-
|
|
57692
|
-
|
|
57693
|
-
|
|
57694
|
-
|
|
57695
|
-
|
|
57791
|
+
/**
|
|
57792
|
+
* Validates a TOTP token.
|
|
57793
|
+
* @param {Object} config Configuration options.
|
|
57794
|
+
* @param {string} config.token Token value.
|
|
57795
|
+
* @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.
|
|
57796
|
+
* @param {number} [config.window=1] Window of counter values to test.
|
|
57797
|
+
* @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.
|
|
57798
|
+
*/
|
|
57799
|
+
validate({
|
|
57800
|
+
token,
|
|
57801
|
+
timestamp,
|
|
57802
|
+
window: window2
|
|
57803
|
+
}) {
|
|
57804
|
+
return _TOTP.validate({
|
|
57805
|
+
token,
|
|
57806
|
+
secret: this.secret,
|
|
57807
|
+
algorithm: this.algorithm,
|
|
57808
|
+
digits: this.digits,
|
|
57809
|
+
period: this.period,
|
|
57810
|
+
timestamp,
|
|
57811
|
+
window: window2
|
|
57812
|
+
});
|
|
57696
57813
|
}
|
|
57697
|
-
|
|
57698
|
-
|
|
57699
|
-
|
|
57700
|
-
|
|
57701
|
-
|
|
57702
|
-
|
|
57703
|
-
|
|
57704
|
-
}
|
|
57705
|
-
object = object[key];
|
|
57706
|
-
if (!isObject(object)) {
|
|
57707
|
-
return false;
|
|
57708
|
-
}
|
|
57814
|
+
/**
|
|
57815
|
+
* Returns a Google Authenticator key URI.
|
|
57816
|
+
* @returns {string} URI.
|
|
57817
|
+
*/
|
|
57818
|
+
toString() {
|
|
57819
|
+
const e = encodeURIComponent;
|
|
57820
|
+
return `otpauth://totp/${this.issuer.length > 0 ? this.issuerInLabel ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&` : `${e(this.label)}?issuer=${e(this.issuer)}&` : `${e(this.label)}?`}secret=${e(this.secret.base32)}&algorithm=${e(this.algorithm)}&digits=${e(this.digits)}&period=${e(this.period)}`;
|
|
57709
57821
|
}
|
|
57710
|
-
}
|
|
57711
|
-
|
|
57712
|
-
|
|
57713
|
-
|
|
57822
|
+
};
|
|
57823
|
+
|
|
57824
|
+
// packages/sdk/otp.js
|
|
57825
|
+
var OTP = class {
|
|
57826
|
+
constructor(secret) {
|
|
57827
|
+
const options = {
|
|
57828
|
+
issuer: "Autho",
|
|
57829
|
+
label: secret.name,
|
|
57830
|
+
algorithm: "SHA1",
|
|
57831
|
+
digits: 6,
|
|
57832
|
+
period: 30,
|
|
57833
|
+
secret: secret.value
|
|
57834
|
+
};
|
|
57835
|
+
this.totp = new TOTP(options);
|
|
57714
57836
|
}
|
|
57715
|
-
|
|
57716
|
-
|
|
57717
|
-
return false;
|
|
57837
|
+
generate() {
|
|
57838
|
+
return this.totp.generate();
|
|
57718
57839
|
}
|
|
57719
|
-
|
|
57720
|
-
|
|
57721
|
-
return false;
|
|
57722
|
-
}
|
|
57723
|
-
object = object[key];
|
|
57840
|
+
validate(token, window2 = 1) {
|
|
57841
|
+
return this.totp.validate({ token, window: window2 });
|
|
57724
57842
|
}
|
|
57725
|
-
|
|
57726
|
-
}
|
|
57843
|
+
};
|
|
57727
57844
|
|
|
57728
|
-
//
|
|
57729
|
-
var
|
|
57730
|
-
var
|
|
57731
|
-
|
|
57732
|
-
|
|
57733
|
-
|
|
57734
|
-
|
|
57735
|
-
|
|
57736
|
-
|
|
57737
|
-
|
|
57738
|
-
|
|
57739
|
-
config: import_node_path.default.join(library, "Preferences", name),
|
|
57740
|
-
cache: import_node_path.default.join(library, "Caches", name),
|
|
57741
|
-
log: import_node_path.default.join(library, "Logs", name),
|
|
57742
|
-
temp: import_node_path.default.join(tmpdir, name)
|
|
57743
|
-
};
|
|
57744
|
-
};
|
|
57745
|
-
var windows = (name) => {
|
|
57746
|
-
const appData = env2.APPDATA || import_node_path.default.join(homedir, "AppData", "Roaming");
|
|
57747
|
-
const localAppData = env2.LOCALAPPDATA || import_node_path.default.join(homedir, "AppData", "Local");
|
|
57748
|
-
return {
|
|
57749
|
-
// Data/config/cache/log are invented by me as Windows isn't opinionated about this
|
|
57750
|
-
data: import_node_path.default.join(localAppData, name, "Data"),
|
|
57751
|
-
config: import_node_path.default.join(appData, name, "Config"),
|
|
57752
|
-
cache: import_node_path.default.join(localAppData, name, "Cache"),
|
|
57753
|
-
log: import_node_path.default.join(localAppData, name, "Log"),
|
|
57754
|
-
temp: import_node_path.default.join(tmpdir, name)
|
|
57755
|
-
};
|
|
57845
|
+
// packages/cli/utils.js
|
|
57846
|
+
var prompt2 = inquirer_default.prompt;
|
|
57847
|
+
var ask = async ({ name = "", message = "", type = "input" }) => {
|
|
57848
|
+
const answers = await inquirer_default.prompt([
|
|
57849
|
+
{
|
|
57850
|
+
name,
|
|
57851
|
+
message,
|
|
57852
|
+
type
|
|
57853
|
+
}
|
|
57854
|
+
]);
|
|
57855
|
+
return answers[name];
|
|
57756
57856
|
};
|
|
57757
|
-
var
|
|
57758
|
-
const
|
|
57759
|
-
|
|
57760
|
-
data: import_node_path.default.join(env2.XDG_DATA_HOME || import_node_path.default.join(homedir, ".local", "share"), name),
|
|
57761
|
-
config: import_node_path.default.join(env2.XDG_CONFIG_HOME || import_node_path.default.join(homedir, ".config"), name),
|
|
57762
|
-
cache: import_node_path.default.join(env2.XDG_CACHE_HOME || import_node_path.default.join(homedir, ".cache"), name),
|
|
57763
|
-
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
57764
|
-
log: import_node_path.default.join(env2.XDG_STATE_HOME || import_node_path.default.join(homedir, ".local", "state"), name),
|
|
57765
|
-
temp: import_node_path.default.join(tmpdir, username, name)
|
|
57766
|
-
};
|
|
57857
|
+
var generateOTP = (secret) => {
|
|
57858
|
+
const otp = new OTP(secret);
|
|
57859
|
+
console.log("OTP code:", otp.generate());
|
|
57767
57860
|
};
|
|
57768
|
-
function envPaths(name, { suffix = "nodejs" } = {}) {
|
|
57769
|
-
if (typeof name !== "string") {
|
|
57770
|
-
throw new TypeError(`Expected a string, got ${typeof name}`);
|
|
57771
|
-
}
|
|
57772
|
-
if (suffix) {
|
|
57773
|
-
name += `-${suffix}`;
|
|
57774
|
-
}
|
|
57775
|
-
if (import_node_process2.default.platform === "darwin") {
|
|
57776
|
-
return macos(name);
|
|
57777
|
-
}
|
|
57778
|
-
if (import_node_process2.default.platform === "win32") {
|
|
57779
|
-
return windows(name);
|
|
57780
|
-
}
|
|
57781
|
-
return linux(name);
|
|
57782
|
-
}
|
|
57783
57861
|
|
|
57784
|
-
//
|
|
57785
|
-
var
|
|
57862
|
+
// packages/models/Secret.js
|
|
57863
|
+
var import_joi = __toESM(require_lib6(), 1);
|
|
57864
|
+
var import_node_crypto = require("node:crypto");
|
|
57865
|
+
var createSecretSchema = import_joi.default.object({
|
|
57866
|
+
id: import_joi.default.string().default((0, import_node_crypto.randomUUID)()),
|
|
57867
|
+
protected: import_joi.default.boolean().default(false),
|
|
57868
|
+
name: import_joi.default.string().required(),
|
|
57869
|
+
type: import_joi.default.string().required().valid("otp", "password", "note"),
|
|
57870
|
+
value: import_joi.default.string().required(),
|
|
57871
|
+
typeOptions: import_joi.default.object().default({}),
|
|
57872
|
+
createdAt: import_joi.default.date().default(/* @__PURE__ */ new Date())
|
|
57873
|
+
});
|
|
57786
57874
|
|
|
57787
|
-
//
|
|
57788
|
-
var
|
|
57789
|
-
var
|
|
57875
|
+
// packages/sdk/cipher.js
|
|
57876
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
57877
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
57878
|
+
var import_path = __toESM(require("path"), 1);
|
|
57879
|
+
var import_zlib = __toESM(require("zlib"), 1);
|
|
57790
57880
|
|
|
57791
|
-
//
|
|
57792
|
-
var
|
|
57793
|
-
|
|
57794
|
-
|
|
57795
|
-
|
|
57796
|
-
|
|
57797
|
-
|
|
57798
|
-
|
|
57799
|
-
|
|
57800
|
-
|
|
57801
|
-
|
|
57802
|
-
return onError(error);
|
|
57803
|
-
}
|
|
57804
|
-
};
|
|
57881
|
+
// packages/shared/config.js
|
|
57882
|
+
var import_dotenv = __toESM(require_main2(), 1);
|
|
57883
|
+
import_dotenv.default.config();
|
|
57884
|
+
var config_default = {
|
|
57885
|
+
masterPasswordHash: process.env.AUTHO_MASTER_PASSWORD_HASH,
|
|
57886
|
+
masterPassword: process.env.AUTHO_MASTER_PASSWORD,
|
|
57887
|
+
randomSize: process.env.AUTHO_RANDOM_SIZE || 16,
|
|
57888
|
+
encryptionALgo: process.env.AUTHO_ENCRYPTION_ALGO || "aes-256-gcm",
|
|
57889
|
+
hashAlgo: process.env.AUTHO_HASH_ALGO || "sha256",
|
|
57890
|
+
dataFolder: process.env.AUTHO_DATA_FOLDER,
|
|
57891
|
+
name: process.env.AUTHO_COLLECTION_NAME || "default"
|
|
57805
57892
|
};
|
|
57806
57893
|
|
|
57807
|
-
//
|
|
57808
|
-
var
|
|
57809
|
-
|
|
57810
|
-
|
|
57811
|
-
|
|
57812
|
-
|
|
57813
|
-
// node_modules/.pnpm/stubborn-fs@1.2.5/node_modules/stubborn-fs/dist/handlers.js
|
|
57814
|
-
var Handlers = {
|
|
57815
|
-
/* API */
|
|
57816
|
-
isChangeErrorOk: (error) => {
|
|
57817
|
-
if (!Handlers.isNodeError(error))
|
|
57818
|
-
return false;
|
|
57819
|
-
const { code } = error;
|
|
57820
|
-
if (code === "ENOSYS")
|
|
57821
|
-
return true;
|
|
57822
|
-
if (!IS_USER_ROOT && (code === "EINVAL" || code === "EPERM"))
|
|
57823
|
-
return true;
|
|
57824
|
-
return false;
|
|
57825
|
-
},
|
|
57826
|
-
isNodeError: (error) => {
|
|
57827
|
-
return error instanceof Error;
|
|
57828
|
-
},
|
|
57829
|
-
isRetriableError: (error) => {
|
|
57830
|
-
if (!Handlers.isNodeError(error))
|
|
57831
|
-
return false;
|
|
57832
|
-
const { code } = error;
|
|
57833
|
-
if (code === "EMFILE" || code === "ENFILE" || code === "EAGAIN" || code === "EBUSY" || code === "EACCESS" || code === "EACCES" || code === "EACCS" || code === "EPERM")
|
|
57834
|
-
return true;
|
|
57835
|
-
return false;
|
|
57836
|
-
},
|
|
57837
|
-
onChangeError: (error) => {
|
|
57838
|
-
if (!Handlers.isNodeError(error))
|
|
57839
|
-
throw error;
|
|
57840
|
-
if (Handlers.isChangeErrorOk(error))
|
|
57841
|
-
return;
|
|
57842
|
-
throw error;
|
|
57894
|
+
// packages/sdk/cipher.js
|
|
57895
|
+
var Cipher = class _Cipher {
|
|
57896
|
+
static hash(text, algorithm = config_default.hashAlgo, encoding = "hex") {
|
|
57897
|
+
const hash = import_crypto.default.createHash(algorithm);
|
|
57898
|
+
hash.update(text);
|
|
57899
|
+
return hash.digest(encoding);
|
|
57843
57900
|
}
|
|
57844
|
-
|
|
57845
|
-
|
|
57846
|
-
|
|
57847
|
-
|
|
57848
|
-
|
|
57849
|
-
|
|
57850
|
-
|
|
57851
|
-
|
|
57852
|
-
|
|
57853
|
-
|
|
57854
|
-
|
|
57855
|
-
|
|
57856
|
-
|
|
57857
|
-
|
|
57858
|
-
|
|
57859
|
-
|
|
57860
|
-
|
|
57861
|
-
|
|
57862
|
-
|
|
57863
|
-
|
|
57864
|
-
|
|
57865
|
-
|
|
57866
|
-
|
|
57867
|
-
|
|
57868
|
-
|
|
57869
|
-
|
|
57870
|
-
|
|
57871
|
-
|
|
57872
|
-
}
|
|
57873
|
-
|
|
57874
|
-
|
|
57875
|
-
|
|
57876
|
-
|
|
57877
|
-
|
|
57878
|
-
|
|
57879
|
-
|
|
57880
|
-
|
|
57881
|
-
|
|
57882
|
-
|
|
57883
|
-
|
|
57884
|
-
|
|
57885
|
-
|
|
57886
|
-
|
|
57887
|
-
return;
|
|
57888
|
-
if (!this.queueWaiting.size)
|
|
57889
|
-
return this.reset();
|
|
57890
|
-
for (const fn of this.queueWaiting) {
|
|
57891
|
-
if (this.queueActive.size >= this.limit)
|
|
57892
|
-
break;
|
|
57893
|
-
this.queueWaiting.delete(fn);
|
|
57894
|
-
this.queueActive.add(fn);
|
|
57895
|
-
fn();
|
|
57896
|
-
}
|
|
57901
|
+
static random(size = config_default.randomSize) {
|
|
57902
|
+
const rnd = import_crypto.default.randomBytes(size);
|
|
57903
|
+
return rnd;
|
|
57904
|
+
}
|
|
57905
|
+
static randomString(encoding = "hex") {
|
|
57906
|
+
const rnd = _Cipher.random().toString(encoding);
|
|
57907
|
+
return rnd;
|
|
57908
|
+
}
|
|
57909
|
+
static sign(text) {
|
|
57910
|
+
const hash = _Cipher.hash(text);
|
|
57911
|
+
const signature = `${hash.substring(0, 10)}:${hash.substring(hash.length - 10)}`;
|
|
57912
|
+
return signature;
|
|
57913
|
+
}
|
|
57914
|
+
static verify(text, signature) {
|
|
57915
|
+
const expectedSignature = _Cipher.sign(text);
|
|
57916
|
+
return expectedSignature === signature;
|
|
57917
|
+
}
|
|
57918
|
+
static encrypt({
|
|
57919
|
+
value,
|
|
57920
|
+
encryptionKey,
|
|
57921
|
+
algorithm = config_default.encryptionALgo,
|
|
57922
|
+
encoding = "hex"
|
|
57923
|
+
}) {
|
|
57924
|
+
const publicKey = _Cipher.randomString();
|
|
57925
|
+
let cipher = import_crypto.default.createCipheriv(
|
|
57926
|
+
algorithm,
|
|
57927
|
+
Buffer.from(encryptionKey, encoding),
|
|
57928
|
+
Buffer.from(publicKey, encoding),
|
|
57929
|
+
{ authTagLength: 16 }
|
|
57930
|
+
);
|
|
57931
|
+
let encrypted = cipher.update(value);
|
|
57932
|
+
encrypted = Buffer.concat([encrypted, cipher.final()]);
|
|
57933
|
+
encrypted = encrypted.toString(encoding);
|
|
57934
|
+
const authTag = cipher.getAuthTag().toString(encoding);
|
|
57935
|
+
return {
|
|
57936
|
+
publicKey,
|
|
57937
|
+
encrypted,
|
|
57938
|
+
algorithm,
|
|
57939
|
+
signature: _Cipher.sign(value),
|
|
57940
|
+
encoding,
|
|
57941
|
+
authTag,
|
|
57942
|
+
provider: "crypto",
|
|
57943
|
+
platform: "autho"
|
|
57897
57944
|
};
|
|
57898
57945
|
}
|
|
57899
|
-
|
|
57900
|
-
|
|
57901
|
-
|
|
57902
|
-
|
|
57903
|
-
|
|
57904
|
-
|
|
57905
|
-
|
|
57906
|
-
|
|
57907
|
-
|
|
57908
|
-
|
|
57909
|
-
|
|
57910
|
-
|
|
57911
|
-
|
|
57912
|
-
|
|
57913
|
-
|
|
57914
|
-
|
|
57915
|
-
|
|
57916
|
-
|
|
57917
|
-
|
|
57918
|
-
|
|
57919
|
-
|
|
57920
|
-
|
|
57921
|
-
|
|
57922
|
-
|
|
57923
|
-
|
|
57946
|
+
static decrypt({
|
|
57947
|
+
value,
|
|
57948
|
+
publicKey,
|
|
57949
|
+
encryptionKey,
|
|
57950
|
+
signature = false,
|
|
57951
|
+
algorithm = config_default.encryptionALgo,
|
|
57952
|
+
authTag,
|
|
57953
|
+
encoding = "hex"
|
|
57954
|
+
}) {
|
|
57955
|
+
value = Buffer.from(value, encoding);
|
|
57956
|
+
let decipher = import_crypto.default.createDecipheriv(
|
|
57957
|
+
algorithm,
|
|
57958
|
+
Buffer.from(encryptionKey, encoding),
|
|
57959
|
+
Buffer.from(publicKey, encoding),
|
|
57960
|
+
{ authTagLength: 16 }
|
|
57961
|
+
);
|
|
57962
|
+
if (authTag) {
|
|
57963
|
+
decipher.setAuthTag(Buffer.from(authTag, encoding));
|
|
57964
|
+
}
|
|
57965
|
+
let decrypted = decipher.update(value);
|
|
57966
|
+
decrypted = Buffer.concat([decrypted, decipher.final()]);
|
|
57967
|
+
decrypted = decrypted.toString();
|
|
57968
|
+
if (signature && !_Cipher.verify(decrypted, signature)) {
|
|
57969
|
+
throw new Error("Invalid signature");
|
|
57970
|
+
}
|
|
57971
|
+
return decrypted;
|
|
57972
|
+
}
|
|
57973
|
+
static canDecrypt(options) {
|
|
57974
|
+
return options.platform === "autho";
|
|
57975
|
+
}
|
|
57976
|
+
static encryptFile(inputFilePath, outputFilePath, encryptionKey) {
|
|
57977
|
+
const inputBuffer = import_fs.default.readFileSync(inputFilePath);
|
|
57978
|
+
const params = {
|
|
57979
|
+
value: inputBuffer,
|
|
57980
|
+
encryptionKey
|
|
57924
57981
|
};
|
|
57925
|
-
|
|
57926
|
-
|
|
57927
|
-
|
|
57928
|
-
|
|
57929
|
-
|
|
57930
|
-
|
|
57931
|
-
|
|
57932
|
-
|
|
57933
|
-
|
|
57934
|
-
|
|
57935
|
-
|
|
57936
|
-
|
|
57937
|
-
|
|
57982
|
+
const encryptedData = _Cipher.encrypt(params);
|
|
57983
|
+
import_fs.default.writeFileSync(
|
|
57984
|
+
outputFilePath,
|
|
57985
|
+
Buffer.from(JSON.stringify(encryptedData)).toString("base64")
|
|
57986
|
+
);
|
|
57987
|
+
}
|
|
57988
|
+
static decryptFile(inputFilePath, outputFilePath, encryptionKey) {
|
|
57989
|
+
const inputFileContent = import_fs.default.readFileSync(inputFilePath);
|
|
57990
|
+
const decoded = Buffer.from(
|
|
57991
|
+
inputFileContent.toString("utf-8"),
|
|
57992
|
+
"base64"
|
|
57993
|
+
).toString("utf-8");
|
|
57994
|
+
const encryptedData = JSON.parse(decoded);
|
|
57995
|
+
if (!_Cipher.canDecrypt(encryptedData)) {
|
|
57996
|
+
throw new Error("Invalid file");
|
|
57997
|
+
}
|
|
57998
|
+
const params = {
|
|
57999
|
+
...encryptedData,
|
|
58000
|
+
value: encryptedData.encrypted,
|
|
58001
|
+
encryptionKey
|
|
58002
|
+
};
|
|
58003
|
+
const decryptedData = _Cipher.decrypt(params);
|
|
58004
|
+
import_fs.default.writeFileSync(outputFilePath, decryptedData);
|
|
58005
|
+
}
|
|
58006
|
+
static encryptFolder({ inputFolderPath, outputFilePath, encryptionKey, algorithm = config_default.encryptionALgo, encoding = "hex" }) {
|
|
58007
|
+
const outputStream = import_fs.default.createWriteStream(outputFilePath);
|
|
58008
|
+
const gzip = import_zlib.default.createGzip();
|
|
58009
|
+
gzip.pipe(outputStream);
|
|
58010
|
+
const baseFolder = import_path.default.basename(inputFolderPath);
|
|
58011
|
+
function traverseFolder(folderPath) {
|
|
58012
|
+
const items = import_fs.default.readdirSync(folderPath);
|
|
58013
|
+
for (const item of items) {
|
|
58014
|
+
const itemPath = import_path.default.join(baseFolder, import_path.default.relative(inputFolderPath, import_path.default.join(folderPath, item)));
|
|
58015
|
+
if (import_fs.default.statSync(itemPath).isDirectory()) {
|
|
58016
|
+
traverseFolder(itemPath);
|
|
58017
|
+
} else {
|
|
58018
|
+
const fileContent = import_fs.default.readFileSync(itemPath);
|
|
58019
|
+
const params = {
|
|
58020
|
+
value: fileContent,
|
|
58021
|
+
encryptionKey,
|
|
58022
|
+
algorithm,
|
|
58023
|
+
encoding
|
|
58024
|
+
};
|
|
58025
|
+
const encryptedData = _Cipher.encrypt(params);
|
|
58026
|
+
const encrypted = encryptedData.encrypted;
|
|
58027
|
+
delete encryptedData.encrypted;
|
|
58028
|
+
const encryptionMeta = Buffer.from(JSON.stringify(encryptedData)).toString("base64");
|
|
58029
|
+
gzip.write(`${itemPath}
|
|
58030
|
+
---
|
|
58031
|
+
${encrypted}
|
|
58032
|
+
---
|
|
58033
|
+
${encryptionMeta}
|
|
58034
|
+
:::
|
|
58035
|
+
`);
|
|
58036
|
+
}
|
|
58037
|
+
}
|
|
58038
|
+
}
|
|
58039
|
+
traverseFolder(inputFolderPath);
|
|
58040
|
+
gzip.end();
|
|
58041
|
+
return new Promise((resolve, reject) => {
|
|
58042
|
+
outputStream.on("finish", resolve);
|
|
58043
|
+
outputStream.on("error", reject);
|
|
58044
|
+
});
|
|
58045
|
+
}
|
|
58046
|
+
static decryptFolder({ inputFilePath, outputFolderPath, encryptionKey }) {
|
|
58047
|
+
const inputStream = import_fs.default.createReadStream(inputFilePath);
|
|
58048
|
+
const gunzip = import_zlib.default.createGunzip();
|
|
58049
|
+
inputStream.pipe(gunzip);
|
|
58050
|
+
let buff = "";
|
|
58051
|
+
const compileFile = (data) => {
|
|
58052
|
+
buff += data;
|
|
58053
|
+
if (buff.includes(":::")) {
|
|
58054
|
+
const [file, next] = buff.split("\n:::\n");
|
|
58055
|
+
let [filePath, encrypted, encryptionMeta] = file.split("\n---\n");
|
|
58056
|
+
filePath = import_path.default.join(outputFolderPath, filePath);
|
|
58057
|
+
try {
|
|
58058
|
+
import_fs.default.mkdirSync(import_path.default.dirname(filePath), { recursive: true });
|
|
58059
|
+
} catch (error) {
|
|
58060
|
+
}
|
|
58061
|
+
const decoded = Buffer.from(
|
|
58062
|
+
encryptionMeta,
|
|
58063
|
+
"base64"
|
|
58064
|
+
).toString("utf-8");
|
|
58065
|
+
const metaData = JSON.parse(decoded);
|
|
58066
|
+
const params = {
|
|
58067
|
+
...metaData,
|
|
58068
|
+
value: encrypted,
|
|
58069
|
+
encryptionKey
|
|
58070
|
+
};
|
|
58071
|
+
const decryptedData = _Cipher.decrypt(params);
|
|
58072
|
+
import_fs.default.writeFileSync(filePath, decryptedData);
|
|
58073
|
+
buff = next;
|
|
57938
58074
|
}
|
|
57939
58075
|
};
|
|
57940
|
-
|
|
58076
|
+
gunzip.on("data", (data) => {
|
|
58077
|
+
compileFile(data.toString("utf8"));
|
|
58078
|
+
});
|
|
58079
|
+
return new Promise((resolve, reject) => {
|
|
58080
|
+
gunzip.on("end", resolve);
|
|
58081
|
+
gunzip.on("error", reject);
|
|
58082
|
+
});
|
|
58083
|
+
}
|
|
57941
58084
|
};
|
|
57942
58085
|
|
|
57943
|
-
//
|
|
57944
|
-
var
|
|
57945
|
-
|
|
57946
|
-
|
|
57947
|
-
|
|
57948
|
-
|
|
57949
|
-
|
|
57950
|
-
|
|
57951
|
-
|
|
57952
|
-
|
|
57953
|
-
|
|
57954
|
-
|
|
57955
|
-
|
|
57956
|
-
|
|
57957
|
-
|
|
57958
|
-
|
|
57959
|
-
|
|
57960
|
-
|
|
57961
|
-
|
|
57962
|
-
|
|
57963
|
-
|
|
57964
|
-
|
|
57965
|
-
|
|
57966
|
-
|
|
57967
|
-
|
|
57968
|
-
|
|
57969
|
-
|
|
57970
|
-
|
|
57971
|
-
|
|
57972
|
-
|
|
57973
|
-
|
|
57974
|
-
|
|
57975
|
-
|
|
57976
|
-
|
|
57977
|
-
|
|
57978
|
-
fsyncSync: retryifySync(import_node_fs.default.fsyncSync, handlers_default.isRetriableError),
|
|
57979
|
-
openSync: retryifySync(import_node_fs.default.openSync, handlers_default.isRetriableError),
|
|
57980
|
-
readFileSync: retryifySync(import_node_fs.default.readFileSync, handlers_default.isRetriableError),
|
|
57981
|
-
renameSync: retryifySync(import_node_fs.default.renameSync, handlers_default.isRetriableError),
|
|
57982
|
-
statSync: retryifySync(import_node_fs.default.statSync, handlers_default.isRetriableError),
|
|
57983
|
-
writeSync: retryifySync(import_node_fs.default.writeSync, handlers_default.isRetriableError),
|
|
57984
|
-
writeFileSync: retryifySync(import_node_fs.default.writeFileSync, handlers_default.isRetriableError)
|
|
58086
|
+
// packages/sdk/secrets.js
|
|
58087
|
+
var Secrets = class {
|
|
58088
|
+
constructor(db) {
|
|
58089
|
+
this.db = db;
|
|
58090
|
+
}
|
|
58091
|
+
get secrets() {
|
|
58092
|
+
return this.db.get("secrets", []);
|
|
58093
|
+
}
|
|
58094
|
+
set secrets(value) {
|
|
58095
|
+
this.db.set("secrets", value);
|
|
58096
|
+
}
|
|
58097
|
+
async get(id) {
|
|
58098
|
+
return this.secrets.find((secret) => secret.id == id);
|
|
58099
|
+
}
|
|
58100
|
+
async add(secret, encryptionKey) {
|
|
58101
|
+
const { value, error } = createSecretSchema.validate(secret);
|
|
58102
|
+
if (error) {
|
|
58103
|
+
throw new Error(error);
|
|
58104
|
+
}
|
|
58105
|
+
const { encrypted, ...encryption } = Cipher.encrypt({
|
|
58106
|
+
...value,
|
|
58107
|
+
encryptionKey
|
|
58108
|
+
});
|
|
58109
|
+
const newSecret = { ...value, ...encryption, value: encrypted };
|
|
58110
|
+
this.secrets = [
|
|
58111
|
+
...this.secrets,
|
|
58112
|
+
newSecret
|
|
58113
|
+
];
|
|
58114
|
+
return newSecret;
|
|
58115
|
+
}
|
|
58116
|
+
async remove(id) {
|
|
58117
|
+
this.secrets = this.secrets.filter((secret) => secret.id != id);
|
|
58118
|
+
}
|
|
58119
|
+
async clear() {
|
|
58120
|
+
this.secrets = [];
|
|
57985
58121
|
}
|
|
57986
58122
|
};
|
|
57987
|
-
var dist_default = FS;
|
|
57988
58123
|
|
|
57989
|
-
// node_modules/.pnpm/
|
|
57990
|
-
var
|
|
57991
|
-
var
|
|
57992
|
-
var
|
|
57993
|
-
var
|
|
57994
|
-
var
|
|
57995
|
-
var
|
|
57996
|
-
var DEFAULT_USER_UID = import_node_os3.default.userInfo().uid;
|
|
57997
|
-
var DEFAULT_USER_GID = import_node_os3.default.userInfo().gid;
|
|
57998
|
-
var DEFAULT_TIMEOUT_SYNC = 1e3;
|
|
57999
|
-
var IS_POSIX = !!import_node_process4.default.getuid;
|
|
58000
|
-
var IS_USER_ROOT2 = import_node_process4.default.getuid ? !import_node_process4.default.getuid() : false;
|
|
58001
|
-
var LIMIT_BASENAME_LENGTH = 128;
|
|
58124
|
+
// node_modules/.pnpm/conf@12.0.0/node_modules/conf/dist/source/index.js
|
|
58125
|
+
var import_node_util2 = require("node:util");
|
|
58126
|
+
var import_node_process7 = __toESM(require("node:process"), 1);
|
|
58127
|
+
var import_node_fs2 = __toESM(require("node:fs"), 1);
|
|
58128
|
+
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
58129
|
+
var import_node_crypto2 = __toESM(require("node:crypto"), 1);
|
|
58130
|
+
var import_node_assert2 = __toESM(require("node:assert"), 1);
|
|
58002
58131
|
|
|
58003
|
-
// node_modules/.pnpm/
|
|
58004
|
-
var
|
|
58005
|
-
|
|
58132
|
+
// node_modules/.pnpm/dot-prop@8.0.2/node_modules/dot-prop/index.js
|
|
58133
|
+
var isObject = (value) => {
|
|
58134
|
+
const type = typeof value;
|
|
58135
|
+
return value !== null && (type === "object" || type === "function");
|
|
58006
58136
|
};
|
|
58007
|
-
var
|
|
58008
|
-
|
|
58009
|
-
|
|
58010
|
-
|
|
58011
|
-
|
|
58012
|
-
|
|
58013
|
-
|
|
58014
|
-
|
|
58015
|
-
|
|
58016
|
-
|
|
58017
|
-
|
|
58018
|
-
|
|
58019
|
-
|
|
58020
|
-
|
|
58021
|
-
|
|
58022
|
-
|
|
58023
|
-
|
|
58024
|
-
|
|
58025
|
-
|
|
58026
|
-
|
|
58027
|
-
if (
|
|
58028
|
-
|
|
58029
|
-
}
|
|
58030
|
-
|
|
58031
|
-
|
|
58032
|
-
|
|
58033
|
-
var signals_default = Signals;
|
|
58034
|
-
|
|
58035
|
-
// node_modules/.pnpm/when-exit@2.1.2/node_modules/when-exit/dist/node/interceptor.js
|
|
58036
|
-
var Interceptor = class {
|
|
58037
|
-
/* CONSTRUCTOR */
|
|
58038
|
-
constructor() {
|
|
58039
|
-
this.callbacks = /* @__PURE__ */ new Set();
|
|
58040
|
-
this.exited = false;
|
|
58041
|
-
this.exit = (signal) => {
|
|
58042
|
-
if (this.exited)
|
|
58043
|
-
return;
|
|
58044
|
-
this.exited = true;
|
|
58045
|
-
for (const callback of this.callbacks) {
|
|
58046
|
-
callback();
|
|
58137
|
+
var disallowedKeys = /* @__PURE__ */ new Set([
|
|
58138
|
+
"__proto__",
|
|
58139
|
+
"prototype",
|
|
58140
|
+
"constructor"
|
|
58141
|
+
]);
|
|
58142
|
+
var digits = new Set("0123456789");
|
|
58143
|
+
function getPathSegments(path5) {
|
|
58144
|
+
const parts = [];
|
|
58145
|
+
let currentSegment = "";
|
|
58146
|
+
let currentPart = "start";
|
|
58147
|
+
let isIgnoring = false;
|
|
58148
|
+
for (const character of path5) {
|
|
58149
|
+
switch (character) {
|
|
58150
|
+
case "\\": {
|
|
58151
|
+
if (currentPart === "index") {
|
|
58152
|
+
throw new Error("Invalid character in an index");
|
|
58153
|
+
}
|
|
58154
|
+
if (currentPart === "indexEnd") {
|
|
58155
|
+
throw new Error("Invalid character after an index");
|
|
58156
|
+
}
|
|
58157
|
+
if (isIgnoring) {
|
|
58158
|
+
currentSegment += character;
|
|
58159
|
+
}
|
|
58160
|
+
currentPart = "property";
|
|
58161
|
+
isIgnoring = !isIgnoring;
|
|
58162
|
+
break;
|
|
58047
58163
|
}
|
|
58048
|
-
|
|
58049
|
-
if (
|
|
58050
|
-
|
|
58051
|
-
}
|
|
58052
|
-
|
|
58164
|
+
case ".": {
|
|
58165
|
+
if (currentPart === "index") {
|
|
58166
|
+
throw new Error("Invalid character in an index");
|
|
58167
|
+
}
|
|
58168
|
+
if (currentPart === "indexEnd") {
|
|
58169
|
+
currentPart = "property";
|
|
58170
|
+
break;
|
|
58171
|
+
}
|
|
58172
|
+
if (isIgnoring) {
|
|
58173
|
+
isIgnoring = false;
|
|
58174
|
+
currentSegment += character;
|
|
58175
|
+
break;
|
|
58176
|
+
}
|
|
58177
|
+
if (disallowedKeys.has(currentSegment)) {
|
|
58178
|
+
return [];
|
|
58053
58179
|
}
|
|
58180
|
+
parts.push(currentSegment);
|
|
58181
|
+
currentSegment = "";
|
|
58182
|
+
currentPart = "property";
|
|
58183
|
+
break;
|
|
58054
58184
|
}
|
|
58055
|
-
|
|
58056
|
-
|
|
58057
|
-
|
|
58058
|
-
|
|
58059
|
-
|
|
58185
|
+
case "[": {
|
|
58186
|
+
if (currentPart === "index") {
|
|
58187
|
+
throw new Error("Invalid character in an index");
|
|
58188
|
+
}
|
|
58189
|
+
if (currentPart === "indexEnd") {
|
|
58190
|
+
currentPart = "index";
|
|
58191
|
+
break;
|
|
58192
|
+
}
|
|
58193
|
+
if (isIgnoring) {
|
|
58194
|
+
isIgnoring = false;
|
|
58195
|
+
currentSegment += character;
|
|
58196
|
+
break;
|
|
58197
|
+
}
|
|
58198
|
+
if (currentPart === "property") {
|
|
58199
|
+
if (disallowedKeys.has(currentSegment)) {
|
|
58200
|
+
return [];
|
|
58201
|
+
}
|
|
58202
|
+
parts.push(currentSegment);
|
|
58203
|
+
currentSegment = "";
|
|
58204
|
+
}
|
|
58205
|
+
currentPart = "index";
|
|
58206
|
+
break;
|
|
58060
58207
|
}
|
|
58061
|
-
|
|
58062
|
-
|
|
58063
|
-
|
|
58064
|
-
|
|
58065
|
-
|
|
58066
|
-
|
|
58067
|
-
};
|
|
58068
|
-
this.hook();
|
|
58069
|
-
}
|
|
58070
|
-
};
|
|
58071
|
-
var interceptor_default = new Interceptor();
|
|
58072
|
-
|
|
58073
|
-
// node_modules/.pnpm/when-exit@2.1.2/node_modules/when-exit/dist/node/index.js
|
|
58074
|
-
var whenExit = interceptor_default.register;
|
|
58075
|
-
var node_default = whenExit;
|
|
58076
|
-
|
|
58077
|
-
// node_modules/.pnpm/atomically@2.0.3/node_modules/atomically/dist/utils/temp.js
|
|
58078
|
-
var Temp = {
|
|
58079
|
-
/* VARIABLES */
|
|
58080
|
-
store: {},
|
|
58081
|
-
/* API */
|
|
58082
|
-
create: (filePath) => {
|
|
58083
|
-
const randomness = `000000${Math.floor(Math.random() * 16777215).toString(16)}`.slice(-6);
|
|
58084
|
-
const timestamp = Date.now().toString().slice(-10);
|
|
58085
|
-
const prefix = "tmp-";
|
|
58086
|
-
const suffix = `.${prefix}${timestamp}${randomness}`;
|
|
58087
|
-
const tempPath = `${filePath}${suffix}`;
|
|
58088
|
-
return tempPath;
|
|
58089
|
-
},
|
|
58090
|
-
get: (filePath, creator, purge = true) => {
|
|
58091
|
-
const tempPath = Temp.truncate(creator(filePath));
|
|
58092
|
-
if (tempPath in Temp.store)
|
|
58093
|
-
return Temp.get(filePath, creator, purge);
|
|
58094
|
-
Temp.store[tempPath] = purge;
|
|
58095
|
-
const disposer = () => delete Temp.store[tempPath];
|
|
58096
|
-
return [tempPath, disposer];
|
|
58097
|
-
},
|
|
58098
|
-
purge: (filePath) => {
|
|
58099
|
-
if (!Temp.store[filePath])
|
|
58100
|
-
return;
|
|
58101
|
-
delete Temp.store[filePath];
|
|
58102
|
-
dist_default.attempt.unlink(filePath);
|
|
58103
|
-
},
|
|
58104
|
-
purgeSync: (filePath) => {
|
|
58105
|
-
if (!Temp.store[filePath])
|
|
58106
|
-
return;
|
|
58107
|
-
delete Temp.store[filePath];
|
|
58108
|
-
dist_default.attempt.unlinkSync(filePath);
|
|
58109
|
-
},
|
|
58110
|
-
purgeSyncAll: () => {
|
|
58111
|
-
for (const filePath in Temp.store) {
|
|
58112
|
-
Temp.purgeSync(filePath);
|
|
58113
|
-
}
|
|
58114
|
-
},
|
|
58115
|
-
truncate: (filePath) => {
|
|
58116
|
-
const basename2 = import_node_path2.default.basename(filePath);
|
|
58117
|
-
if (basename2.length <= LIMIT_BASENAME_LENGTH)
|
|
58118
|
-
return filePath;
|
|
58119
|
-
const truncable = /^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(basename2);
|
|
58120
|
-
if (!truncable)
|
|
58121
|
-
return filePath;
|
|
58122
|
-
const truncationLength = basename2.length - LIMIT_BASENAME_LENGTH;
|
|
58123
|
-
return `${filePath.slice(0, -basename2.length)}${truncable[1]}${truncable[2].slice(0, -truncationLength)}${truncable[3]}`;
|
|
58124
|
-
}
|
|
58125
|
-
};
|
|
58126
|
-
node_default(Temp.purgeSyncAll);
|
|
58127
|
-
var temp_default = Temp;
|
|
58128
|
-
|
|
58129
|
-
// node_modules/.pnpm/atomically@2.0.3/node_modules/atomically/dist/index.js
|
|
58130
|
-
function writeFileSync(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
|
|
58131
|
-
if (isString(options))
|
|
58132
|
-
return writeFileSync(filePath, data, { encoding: options });
|
|
58133
|
-
const timeout = Date.now() + ((options.timeout ?? DEFAULT_TIMEOUT_SYNC) || -1);
|
|
58134
|
-
let tempDisposer = null;
|
|
58135
|
-
let tempPath = null;
|
|
58136
|
-
let fd = null;
|
|
58137
|
-
try {
|
|
58138
|
-
const filePathReal = dist_default.attempt.realpathSync(filePath);
|
|
58139
|
-
const filePathExists = !!filePathReal;
|
|
58140
|
-
filePath = filePathReal || filePath;
|
|
58141
|
-
[tempPath, tempDisposer] = temp_default.get(filePath, options.tmpCreate || temp_default.create, !(options.tmpPurge === false));
|
|
58142
|
-
const useStatChown = IS_POSIX && isUndefined(options.chown);
|
|
58143
|
-
const useStatMode = isUndefined(options.mode);
|
|
58144
|
-
if (filePathExists && (useStatChown || useStatMode)) {
|
|
58145
|
-
const stats = dist_default.attempt.statSync(filePath);
|
|
58146
|
-
if (stats) {
|
|
58147
|
-
options = { ...options };
|
|
58148
|
-
if (useStatChown) {
|
|
58149
|
-
options.chown = { uid: stats.uid, gid: stats.gid };
|
|
58208
|
+
case "]": {
|
|
58209
|
+
if (currentPart === "index") {
|
|
58210
|
+
parts.push(Number.parseInt(currentSegment, 10));
|
|
58211
|
+
currentSegment = "";
|
|
58212
|
+
currentPart = "indexEnd";
|
|
58213
|
+
break;
|
|
58150
58214
|
}
|
|
58151
|
-
if (
|
|
58152
|
-
|
|
58215
|
+
if (currentPart === "indexEnd") {
|
|
58216
|
+
throw new Error("Invalid character after an index");
|
|
58217
|
+
}
|
|
58218
|
+
}
|
|
58219
|
+
default: {
|
|
58220
|
+
if (currentPart === "index" && !digits.has(character)) {
|
|
58221
|
+
throw new Error("Invalid character in an index");
|
|
58222
|
+
}
|
|
58223
|
+
if (currentPart === "indexEnd") {
|
|
58224
|
+
throw new Error("Invalid character after an index");
|
|
58153
58225
|
}
|
|
58226
|
+
if (currentPart === "start") {
|
|
58227
|
+
currentPart = "property";
|
|
58228
|
+
}
|
|
58229
|
+
if (isIgnoring) {
|
|
58230
|
+
isIgnoring = false;
|
|
58231
|
+
currentSegment += "\\";
|
|
58232
|
+
}
|
|
58233
|
+
currentSegment += character;
|
|
58154
58234
|
}
|
|
58155
58235
|
}
|
|
58156
|
-
|
|
58157
|
-
|
|
58158
|
-
|
|
58159
|
-
|
|
58160
|
-
|
|
58161
|
-
|
|
58236
|
+
}
|
|
58237
|
+
if (isIgnoring) {
|
|
58238
|
+
currentSegment += "\\";
|
|
58239
|
+
}
|
|
58240
|
+
switch (currentPart) {
|
|
58241
|
+
case "property": {
|
|
58242
|
+
if (disallowedKeys.has(currentSegment)) {
|
|
58243
|
+
return [];
|
|
58244
|
+
}
|
|
58245
|
+
parts.push(currentSegment);
|
|
58246
|
+
break;
|
|
58162
58247
|
}
|
|
58163
|
-
|
|
58164
|
-
|
|
58165
|
-
options.tmpCreated(tempPath);
|
|
58248
|
+
case "index": {
|
|
58249
|
+
throw new Error("Index was not closed");
|
|
58166
58250
|
}
|
|
58167
|
-
|
|
58168
|
-
|
|
58169
|
-
|
|
58170
|
-
dist_default.retry.writeSync(timeout)(fd, data, 0, data.length, 0);
|
|
58171
|
-
}
|
|
58172
|
-
if (options.fsync !== false) {
|
|
58173
|
-
if (options.fsyncWait !== false) {
|
|
58174
|
-
dist_default.retry.fsyncSync(timeout)(fd);
|
|
58175
|
-
} else {
|
|
58176
|
-
dist_default.attempt.fsync(fd);
|
|
58177
|
-
}
|
|
58178
|
-
}
|
|
58179
|
-
dist_default.retry.closeSync(timeout)(fd);
|
|
58180
|
-
fd = null;
|
|
58181
|
-
if (options.chown && (options.chown.uid !== DEFAULT_USER_UID || options.chown.gid !== DEFAULT_USER_GID)) {
|
|
58182
|
-
dist_default.attempt.chownSync(tempPath, options.chown.uid, options.chown.gid);
|
|
58183
|
-
}
|
|
58184
|
-
if (options.mode && options.mode !== DEFAULT_FILE_MODE) {
|
|
58185
|
-
dist_default.attempt.chmodSync(tempPath, options.mode);
|
|
58186
|
-
}
|
|
58187
|
-
try {
|
|
58188
|
-
dist_default.retry.renameSync(timeout)(tempPath, filePath);
|
|
58189
|
-
} catch (error) {
|
|
58190
|
-
if (!isException(error))
|
|
58191
|
-
throw error;
|
|
58192
|
-
if (error.code !== "ENAMETOOLONG")
|
|
58193
|
-
throw error;
|
|
58194
|
-
dist_default.retry.renameSync(timeout)(tempPath, temp_default.truncate(filePath));
|
|
58251
|
+
case "start": {
|
|
58252
|
+
parts.push("");
|
|
58253
|
+
break;
|
|
58195
58254
|
}
|
|
58196
|
-
tempDisposer();
|
|
58197
|
-
tempPath = null;
|
|
58198
|
-
} finally {
|
|
58199
|
-
if (fd)
|
|
58200
|
-
dist_default.attempt.closeSync(fd);
|
|
58201
|
-
if (tempPath)
|
|
58202
|
-
temp_default.purge(tempPath);
|
|
58203
58255
|
}
|
|
58256
|
+
return parts;
|
|
58204
58257
|
}
|
|
58205
|
-
|
|
58206
|
-
|
|
58207
|
-
|
|
58208
|
-
|
|
58209
|
-
|
|
58210
|
-
// node_modules/.pnpm/mimic-fn@4.0.0/node_modules/mimic-fn/index.js
|
|
58211
|
-
var copyProperty = (to, from3, property, ignoreNonConfigurable) => {
|
|
58212
|
-
if (property === "length" || property === "prototype") {
|
|
58213
|
-
return;
|
|
58214
|
-
}
|
|
58215
|
-
if (property === "arguments" || property === "caller") {
|
|
58216
|
-
return;
|
|
58217
|
-
}
|
|
58218
|
-
const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
|
|
58219
|
-
const fromDescriptor = Object.getOwnPropertyDescriptor(from3, property);
|
|
58220
|
-
if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
|
|
58221
|
-
return;
|
|
58222
|
-
}
|
|
58223
|
-
Object.defineProperty(to, property, fromDescriptor);
|
|
58224
|
-
};
|
|
58225
|
-
var canCopyProperty = function(toDescriptor, fromDescriptor) {
|
|
58226
|
-
return toDescriptor === void 0 || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
|
|
58227
|
-
};
|
|
58228
|
-
var changePrototype = (to, from3) => {
|
|
58229
|
-
const fromPrototype = Object.getPrototypeOf(from3);
|
|
58230
|
-
if (fromPrototype === Object.getPrototypeOf(to)) {
|
|
58231
|
-
return;
|
|
58258
|
+
function isStringIndex(object, key) {
|
|
58259
|
+
if (typeof key !== "number" && Array.isArray(object)) {
|
|
58260
|
+
const index = Number.parseInt(key, 10);
|
|
58261
|
+
return Number.isInteger(index) && object[index] === object[key];
|
|
58232
58262
|
}
|
|
58233
|
-
|
|
58234
|
-
}
|
|
58235
|
-
|
|
58236
|
-
|
|
58237
|
-
|
|
58238
|
-
var toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name");
|
|
58239
|
-
var changeToString = (to, from3, name) => {
|
|
58240
|
-
const withName = name === "" ? "" : `with ${name.trim()}() `;
|
|
58241
|
-
const newToString = wrappedToString.bind(null, withName, from3.toString());
|
|
58242
|
-
Object.defineProperty(newToString, "name", toStringName);
|
|
58243
|
-
Object.defineProperty(to, "toString", { ...toStringDescriptor, value: newToString });
|
|
58244
|
-
};
|
|
58245
|
-
function mimicFunction(to, from3, { ignoreNonConfigurable = false } = {}) {
|
|
58246
|
-
const { name } = to;
|
|
58247
|
-
for (const property of Reflect.ownKeys(from3)) {
|
|
58248
|
-
copyProperty(to, from3, property, ignoreNonConfigurable);
|
|
58263
|
+
return false;
|
|
58264
|
+
}
|
|
58265
|
+
function assertNotStringIndex(object, key) {
|
|
58266
|
+
if (isStringIndex(object, key)) {
|
|
58267
|
+
throw new Error("Cannot use string index");
|
|
58249
58268
|
}
|
|
58250
|
-
changePrototype(to, from3);
|
|
58251
|
-
changeToString(to, from3, name);
|
|
58252
|
-
return to;
|
|
58253
58269
|
}
|
|
58254
|
-
|
|
58255
|
-
|
|
58256
|
-
|
|
58257
|
-
if (typeof inputFunction !== "function") {
|
|
58258
|
-
throw new TypeError(`Expected the first argument to be a function, got \`${typeof inputFunction}\``);
|
|
58270
|
+
function getProperty(object, path5, value) {
|
|
58271
|
+
if (!isObject(object) || typeof path5 !== "string") {
|
|
58272
|
+
return value === void 0 ? object : value;
|
|
58259
58273
|
}
|
|
58260
|
-
const
|
|
58261
|
-
|
|
58262
|
-
|
|
58263
|
-
before = false,
|
|
58264
|
-
after = true
|
|
58265
|
-
} = options;
|
|
58266
|
-
if (!before && !after) {
|
|
58267
|
-
throw new Error("Both `before` and `after` are false, function wouldn't be called.");
|
|
58274
|
+
const pathArray = getPathSegments(path5);
|
|
58275
|
+
if (pathArray.length === 0) {
|
|
58276
|
+
return value;
|
|
58268
58277
|
}
|
|
58269
|
-
let
|
|
58270
|
-
|
|
58271
|
-
|
|
58272
|
-
|
|
58273
|
-
|
|
58274
|
-
|
|
58275
|
-
|
|
58276
|
-
|
|
58277
|
-
|
|
58278
|
-
|
|
58279
|
-
}
|
|
58280
|
-
if (after) {
|
|
58281
|
-
result = inputFunction.apply(context, arguments_);
|
|
58282
|
-
}
|
|
58283
|
-
};
|
|
58284
|
-
const maxLater = () => {
|
|
58285
|
-
maxTimeout = void 0;
|
|
58286
|
-
if (timeout) {
|
|
58287
|
-
clearTimeout(timeout);
|
|
58288
|
-
timeout = void 0;
|
|
58289
|
-
}
|
|
58290
|
-
if (after) {
|
|
58291
|
-
result = inputFunction.apply(context, arguments_);
|
|
58278
|
+
for (let index = 0; index < pathArray.length; index++) {
|
|
58279
|
+
const key = pathArray[index];
|
|
58280
|
+
if (isStringIndex(object, key)) {
|
|
58281
|
+
object = index === pathArray.length - 1 ? void 0 : null;
|
|
58282
|
+
} else {
|
|
58283
|
+
object = object[key];
|
|
58284
|
+
}
|
|
58285
|
+
if (object === void 0 || object === null) {
|
|
58286
|
+
if (index !== pathArray.length - 1) {
|
|
58287
|
+
return value;
|
|
58292
58288
|
}
|
|
58293
|
-
|
|
58294
|
-
const shouldCallNow = before && !timeout;
|
|
58295
|
-
clearTimeout(timeout);
|
|
58296
|
-
timeout = setTimeout(later, wait);
|
|
58297
|
-
if (maxWait > 0 && maxWait !== Number.POSITIVE_INFINITY && !maxTimeout) {
|
|
58298
|
-
maxTimeout = setTimeout(maxLater, maxWait);
|
|
58289
|
+
break;
|
|
58299
58290
|
}
|
|
58300
|
-
|
|
58301
|
-
|
|
58291
|
+
}
|
|
58292
|
+
return object === void 0 ? value : object;
|
|
58293
|
+
}
|
|
58294
|
+
function setProperty(object, path5, value) {
|
|
58295
|
+
if (!isObject(object) || typeof path5 !== "string") {
|
|
58296
|
+
return object;
|
|
58297
|
+
}
|
|
58298
|
+
const root = object;
|
|
58299
|
+
const pathArray = getPathSegments(path5);
|
|
58300
|
+
for (let index = 0; index < pathArray.length; index++) {
|
|
58301
|
+
const key = pathArray[index];
|
|
58302
|
+
assertNotStringIndex(object, key);
|
|
58303
|
+
if (index === pathArray.length - 1) {
|
|
58304
|
+
object[key] = value;
|
|
58305
|
+
} else if (!isObject(object[key])) {
|
|
58306
|
+
object[key] = typeof pathArray[index + 1] === "number" ? [] : {};
|
|
58302
58307
|
}
|
|
58303
|
-
|
|
58304
|
-
}
|
|
58305
|
-
|
|
58306
|
-
|
|
58307
|
-
|
|
58308
|
-
|
|
58309
|
-
|
|
58308
|
+
object = object[key];
|
|
58309
|
+
}
|
|
58310
|
+
return root;
|
|
58311
|
+
}
|
|
58312
|
+
function deleteProperty(object, path5) {
|
|
58313
|
+
if (!isObject(object) || typeof path5 !== "string") {
|
|
58314
|
+
return false;
|
|
58315
|
+
}
|
|
58316
|
+
const pathArray = getPathSegments(path5);
|
|
58317
|
+
for (let index = 0; index < pathArray.length; index++) {
|
|
58318
|
+
const key = pathArray[index];
|
|
58319
|
+
assertNotStringIndex(object, key);
|
|
58320
|
+
if (index === pathArray.length - 1) {
|
|
58321
|
+
delete object[key];
|
|
58322
|
+
return true;
|
|
58310
58323
|
}
|
|
58311
|
-
|
|
58312
|
-
|
|
58313
|
-
|
|
58324
|
+
object = object[key];
|
|
58325
|
+
if (!isObject(object)) {
|
|
58326
|
+
return false;
|
|
58314
58327
|
}
|
|
58315
|
-
};
|
|
58316
|
-
return debouncedFunction;
|
|
58317
|
-
};
|
|
58318
|
-
var debounce_fn_default = debounceFn;
|
|
58319
|
-
|
|
58320
|
-
// node_modules/.pnpm/conf@12.0.0/node_modules/conf/dist/source/index.js
|
|
58321
|
-
var import_semver = __toESM(require_semver2(), 1);
|
|
58322
|
-
|
|
58323
|
-
// node_modules/.pnpm/uint8array-extras@0.3.0/node_modules/uint8array-extras/index.js
|
|
58324
|
-
var objectToString = Object.prototype.toString;
|
|
58325
|
-
function isUint8Array(value) {
|
|
58326
|
-
return value && objectToString.call(value) === "[object Uint8Array]";
|
|
58327
|
-
}
|
|
58328
|
-
function assertUint8Array(value) {
|
|
58329
|
-
if (!isUint8Array(value)) {
|
|
58330
|
-
throw new TypeError(`Expected \`Uint8Array\`, got \`${typeof value}\``);
|
|
58331
58328
|
}
|
|
58332
58329
|
}
|
|
58333
|
-
function
|
|
58334
|
-
if (
|
|
58335
|
-
return
|
|
58330
|
+
function hasProperty(object, path5) {
|
|
58331
|
+
if (!isObject(object) || typeof path5 !== "string") {
|
|
58332
|
+
return false;
|
|
58336
58333
|
}
|
|
58337
|
-
|
|
58338
|
-
|
|
58339
|
-
|
|
58340
|
-
for (const array of arrays) {
|
|
58341
|
-
assertUint8Array(array);
|
|
58342
|
-
returnValue.set(array, offset);
|
|
58343
|
-
offset += array.length;
|
|
58334
|
+
const pathArray = getPathSegments(path5);
|
|
58335
|
+
if (pathArray.length === 0) {
|
|
58336
|
+
return false;
|
|
58344
58337
|
}
|
|
58345
|
-
|
|
58346
|
-
|
|
58347
|
-
|
|
58348
|
-
|
|
58349
|
-
|
|
58350
|
-
}
|
|
58351
|
-
function assertString(value) {
|
|
58352
|
-
if (typeof value !== "string") {
|
|
58353
|
-
throw new TypeError(`Expected \`string\`, got \`${typeof value}\``);
|
|
58338
|
+
for (const key of pathArray) {
|
|
58339
|
+
if (!isObject(object) || !(key in object) || isStringIndex(object, key)) {
|
|
58340
|
+
return false;
|
|
58341
|
+
}
|
|
58342
|
+
object = object[key];
|
|
58354
58343
|
}
|
|
58344
|
+
return true;
|
|
58355
58345
|
}
|
|
58356
|
-
function stringToUint8Array(string) {
|
|
58357
|
-
assertString(string);
|
|
58358
|
-
return new globalThis.TextEncoder().encode(string);
|
|
58359
|
-
}
|
|
58360
|
-
var byteToHexLookupTable = Array.from({ length: 256 }, (_3, index) => index.toString(16).padStart(2, "0"));
|
|
58361
58346
|
|
|
58362
|
-
// node_modules/.pnpm/
|
|
58363
|
-
var
|
|
58364
|
-
var
|
|
58365
|
-
var
|
|
58366
|
-
var
|
|
58367
|
-
var
|
|
58368
|
-
var
|
|
58369
|
-
|
|
58370
|
-
|
|
58371
|
-
|
|
58372
|
-
"
|
|
58373
|
-
|
|
58374
|
-
|
|
58375
|
-
|
|
58376
|
-
|
|
58347
|
+
// node_modules/.pnpm/env-paths@3.0.0/node_modules/env-paths/index.js
|
|
58348
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
58349
|
+
var import_node_os2 = __toESM(require("node:os"), 1);
|
|
58350
|
+
var import_node_process2 = __toESM(require("node:process"), 1);
|
|
58351
|
+
var homedir = import_node_os2.default.homedir();
|
|
58352
|
+
var tmpdir = import_node_os2.default.tmpdir();
|
|
58353
|
+
var { env: env2 } = import_node_process2.default;
|
|
58354
|
+
var macos = (name) => {
|
|
58355
|
+
const library = import_node_path.default.join(homedir, "Library");
|
|
58356
|
+
return {
|
|
58357
|
+
data: import_node_path.default.join(library, "Application Support", name),
|
|
58358
|
+
config: import_node_path.default.join(library, "Preferences", name),
|
|
58359
|
+
cache: import_node_path.default.join(library, "Caches", name),
|
|
58360
|
+
log: import_node_path.default.join(library, "Logs", name),
|
|
58361
|
+
temp: import_node_path.default.join(tmpdir, name)
|
|
58362
|
+
};
|
|
58363
|
+
};
|
|
58364
|
+
var windows = (name) => {
|
|
58365
|
+
const appData = env2.APPDATA || import_node_path.default.join(homedir, "AppData", "Roaming");
|
|
58366
|
+
const localAppData = env2.LOCALAPPDATA || import_node_path.default.join(homedir, "AppData", "Local");
|
|
58367
|
+
return {
|
|
58368
|
+
// Data/config/cache/log are invented by me as Windows isn't opinionated about this
|
|
58369
|
+
data: import_node_path.default.join(localAppData, name, "Data"),
|
|
58370
|
+
config: import_node_path.default.join(appData, name, "Config"),
|
|
58371
|
+
cache: import_node_path.default.join(localAppData, name, "Cache"),
|
|
58372
|
+
log: import_node_path.default.join(localAppData, name, "Log"),
|
|
58373
|
+
temp: import_node_path.default.join(tmpdir, name)
|
|
58374
|
+
};
|
|
58375
|
+
};
|
|
58376
|
+
var linux = (name) => {
|
|
58377
|
+
const username = import_node_path.default.basename(homedir);
|
|
58378
|
+
return {
|
|
58379
|
+
data: import_node_path.default.join(env2.XDG_DATA_HOME || import_node_path.default.join(homedir, ".local", "share"), name),
|
|
58380
|
+
config: import_node_path.default.join(env2.XDG_CONFIG_HOME || import_node_path.default.join(homedir, ".config"), name),
|
|
58381
|
+
cache: import_node_path.default.join(env2.XDG_CACHE_HOME || import_node_path.default.join(homedir, ".cache"), name),
|
|
58382
|
+
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
58383
|
+
log: import_node_path.default.join(env2.XDG_STATE_HOME || import_node_path.default.join(homedir, ".local", "state"), name),
|
|
58384
|
+
temp: import_node_path.default.join(tmpdir, username, name)
|
|
58385
|
+
};
|
|
58386
|
+
};
|
|
58387
|
+
function envPaths(name, { suffix = "nodejs" } = {}) {
|
|
58388
|
+
if (typeof name !== "string") {
|
|
58389
|
+
throw new TypeError(`Expected a string, got ${typeof name}`);
|
|
58390
|
+
}
|
|
58391
|
+
if (suffix) {
|
|
58392
|
+
name += `-${suffix}`;
|
|
58393
|
+
}
|
|
58394
|
+
if (import_node_process2.default.platform === "darwin") {
|
|
58395
|
+
return macos(name);
|
|
58396
|
+
}
|
|
58397
|
+
if (import_node_process2.default.platform === "win32") {
|
|
58398
|
+
return windows(name);
|
|
58377
58399
|
}
|
|
58400
|
+
return linux(name);
|
|
58401
|
+
}
|
|
58402
|
+
|
|
58403
|
+
// node_modules/.pnpm/atomically@2.0.3/node_modules/atomically/dist/index.js
|
|
58404
|
+
var import_node_path3 = __toESM(require("node:path"), 1);
|
|
58405
|
+
|
|
58406
|
+
// node_modules/.pnpm/stubborn-fs@1.2.5/node_modules/stubborn-fs/dist/index.js
|
|
58407
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
58408
|
+
var import_node_util = require("node:util");
|
|
58409
|
+
|
|
58410
|
+
// node_modules/.pnpm/stubborn-fs@1.2.5/node_modules/stubborn-fs/dist/attemptify.js
|
|
58411
|
+
var attemptifyAsync = (fn, onError) => {
|
|
58412
|
+
return function attemptified(...args) {
|
|
58413
|
+
return fn.apply(void 0, args).catch(onError);
|
|
58414
|
+
};
|
|
58378
58415
|
};
|
|
58379
|
-
var
|
|
58380
|
-
|
|
58381
|
-
var Conf = class {
|
|
58382
|
-
path;
|
|
58383
|
-
events;
|
|
58384
|
-
#validator;
|
|
58385
|
-
#encryptionKey;
|
|
58386
|
-
#options;
|
|
58387
|
-
#defaultValues = {};
|
|
58388
|
-
constructor(partialOptions = {}) {
|
|
58389
|
-
const options = {
|
|
58390
|
-
configName: "config",
|
|
58391
|
-
fileExtension: "json",
|
|
58392
|
-
projectSuffix: "nodejs",
|
|
58393
|
-
clearInvalidConfig: false,
|
|
58394
|
-
accessPropertiesByDotNotation: true,
|
|
58395
|
-
configFileMode: 438,
|
|
58396
|
-
...partialOptions
|
|
58397
|
-
};
|
|
58398
|
-
if (!options.cwd) {
|
|
58399
|
-
if (!options.projectName) {
|
|
58400
|
-
throw new Error("Please specify the `projectName` option.");
|
|
58401
|
-
}
|
|
58402
|
-
options.cwd = envPaths(options.projectName, { suffix: options.projectSuffix }).config;
|
|
58403
|
-
}
|
|
58404
|
-
this.#options = options;
|
|
58405
|
-
if (options.schema) {
|
|
58406
|
-
if (typeof options.schema !== "object") {
|
|
58407
|
-
throw new TypeError("The `schema` option must be an object.");
|
|
58408
|
-
}
|
|
58409
|
-
const ajv = new Ajv({
|
|
58410
|
-
allErrors: true,
|
|
58411
|
-
useDefaults: true
|
|
58412
|
-
});
|
|
58413
|
-
ajvFormats(ajv);
|
|
58414
|
-
const schema = {
|
|
58415
|
-
type: "object",
|
|
58416
|
-
properties: options.schema
|
|
58417
|
-
};
|
|
58418
|
-
this.#validator = ajv.compile(schema);
|
|
58419
|
-
for (const [key, value] of Object.entries(options.schema)) {
|
|
58420
|
-
if (value?.default) {
|
|
58421
|
-
this.#defaultValues[key] = value.default;
|
|
58422
|
-
}
|
|
58423
|
-
}
|
|
58424
|
-
}
|
|
58425
|
-
if (options.defaults) {
|
|
58426
|
-
this.#defaultValues = {
|
|
58427
|
-
...this.#defaultValues,
|
|
58428
|
-
...options.defaults
|
|
58429
|
-
};
|
|
58430
|
-
}
|
|
58431
|
-
if (options.serialize) {
|
|
58432
|
-
this._serialize = options.serialize;
|
|
58433
|
-
}
|
|
58434
|
-
if (options.deserialize) {
|
|
58435
|
-
this._deserialize = options.deserialize;
|
|
58436
|
-
}
|
|
58437
|
-
this.events = new EventTarget();
|
|
58438
|
-
this.#encryptionKey = options.encryptionKey;
|
|
58439
|
-
const fileExtension = options.fileExtension ? `.${options.fileExtension}` : "";
|
|
58440
|
-
this.path = import_node_path4.default.resolve(options.cwd, `${options.configName ?? "config"}${fileExtension}`);
|
|
58441
|
-
const fileStore = this.store;
|
|
58442
|
-
const store = Object.assign(createPlainObject(), options.defaults, fileStore);
|
|
58443
|
-
this._validate(store);
|
|
58416
|
+
var attemptifySync = (fn, onError) => {
|
|
58417
|
+
return function attemptified(...args) {
|
|
58444
58418
|
try {
|
|
58445
|
-
|
|
58446
|
-
} catch {
|
|
58447
|
-
|
|
58448
|
-
}
|
|
58449
|
-
if (options.watch) {
|
|
58450
|
-
this._watch();
|
|
58451
|
-
}
|
|
58452
|
-
if (options.migrations) {
|
|
58453
|
-
if (!options.projectVersion) {
|
|
58454
|
-
throw new Error("Please specify the `projectVersion` option.");
|
|
58455
|
-
}
|
|
58456
|
-
this._migrate(options.migrations, options.projectVersion, options.beforeEachMigration);
|
|
58457
|
-
}
|
|
58458
|
-
}
|
|
58459
|
-
get(key, defaultValue) {
|
|
58460
|
-
if (this.#options.accessPropertiesByDotNotation) {
|
|
58461
|
-
return this._get(key, defaultValue);
|
|
58419
|
+
return fn.apply(void 0, args);
|
|
58420
|
+
} catch (error) {
|
|
58421
|
+
return onError(error);
|
|
58462
58422
|
}
|
|
58463
|
-
|
|
58464
|
-
|
|
58423
|
+
};
|
|
58424
|
+
};
|
|
58425
|
+
|
|
58426
|
+
// node_modules/.pnpm/stubborn-fs@1.2.5/node_modules/stubborn-fs/dist/constants.js
|
|
58427
|
+
var import_node_process3 = __toESM(require("node:process"), 1);
|
|
58428
|
+
var IS_USER_ROOT = import_node_process3.default.getuid ? !import_node_process3.default.getuid() : false;
|
|
58429
|
+
var LIMIT_FILES_DESCRIPTORS = 1e4;
|
|
58430
|
+
var NOOP = () => void 0;
|
|
58431
|
+
|
|
58432
|
+
// node_modules/.pnpm/stubborn-fs@1.2.5/node_modules/stubborn-fs/dist/handlers.js
|
|
58433
|
+
var Handlers = {
|
|
58434
|
+
/* API */
|
|
58435
|
+
isChangeErrorOk: (error) => {
|
|
58436
|
+
if (!Handlers.isNodeError(error))
|
|
58437
|
+
return false;
|
|
58438
|
+
const { code } = error;
|
|
58439
|
+
if (code === "ENOSYS")
|
|
58440
|
+
return true;
|
|
58441
|
+
if (!IS_USER_ROOT && (code === "EINVAL" || code === "EPERM"))
|
|
58442
|
+
return true;
|
|
58443
|
+
return false;
|
|
58444
|
+
},
|
|
58445
|
+
isNodeError: (error) => {
|
|
58446
|
+
return error instanceof Error;
|
|
58447
|
+
},
|
|
58448
|
+
isRetriableError: (error) => {
|
|
58449
|
+
if (!Handlers.isNodeError(error))
|
|
58450
|
+
return false;
|
|
58451
|
+
const { code } = error;
|
|
58452
|
+
if (code === "EMFILE" || code === "ENFILE" || code === "EAGAIN" || code === "EBUSY" || code === "EACCESS" || code === "EACCES" || code === "EACCS" || code === "EPERM")
|
|
58453
|
+
return true;
|
|
58454
|
+
return false;
|
|
58455
|
+
},
|
|
58456
|
+
onChangeError: (error) => {
|
|
58457
|
+
if (!Handlers.isNodeError(error))
|
|
58458
|
+
throw error;
|
|
58459
|
+
if (Handlers.isChangeErrorOk(error))
|
|
58460
|
+
return;
|
|
58461
|
+
throw error;
|
|
58465
58462
|
}
|
|
58466
|
-
|
|
58467
|
-
|
|
58468
|
-
|
|
58469
|
-
|
|
58470
|
-
|
|
58471
|
-
|
|
58472
|
-
|
|
58473
|
-
|
|
58474
|
-
|
|
58475
|
-
|
|
58476
|
-
|
|
58477
|
-
|
|
58478
|
-
|
|
58479
|
-
|
|
58480
|
-
|
|
58463
|
+
};
|
|
58464
|
+
var handlers_default = Handlers;
|
|
58465
|
+
|
|
58466
|
+
// node_modules/.pnpm/stubborn-fs@1.2.5/node_modules/stubborn-fs/dist/retryify_queue.js
|
|
58467
|
+
var RetryfyQueue = class {
|
|
58468
|
+
constructor() {
|
|
58469
|
+
this.interval = 25;
|
|
58470
|
+
this.intervalId = void 0;
|
|
58471
|
+
this.limit = LIMIT_FILES_DESCRIPTORS;
|
|
58472
|
+
this.queueActive = /* @__PURE__ */ new Set();
|
|
58473
|
+
this.queueWaiting = /* @__PURE__ */ new Set();
|
|
58474
|
+
this.init = () => {
|
|
58475
|
+
if (this.intervalId)
|
|
58476
|
+
return;
|
|
58477
|
+
this.intervalId = setInterval(this.tick, this.interval);
|
|
58478
|
+
};
|
|
58479
|
+
this.reset = () => {
|
|
58480
|
+
if (!this.intervalId)
|
|
58481
|
+
return;
|
|
58482
|
+
clearInterval(this.intervalId);
|
|
58483
|
+
delete this.intervalId;
|
|
58484
|
+
};
|
|
58485
|
+
this.add = (fn) => {
|
|
58486
|
+
this.queueWaiting.add(fn);
|
|
58487
|
+
if (this.queueActive.size < this.limit / 2) {
|
|
58488
|
+
this.tick();
|
|
58481
58489
|
} else {
|
|
58482
|
-
|
|
58490
|
+
this.init();
|
|
58483
58491
|
}
|
|
58484
58492
|
};
|
|
58485
|
-
|
|
58486
|
-
|
|
58487
|
-
|
|
58488
|
-
|
|
58493
|
+
this.remove = (fn) => {
|
|
58494
|
+
this.queueWaiting.delete(fn);
|
|
58495
|
+
this.queueActive.delete(fn);
|
|
58496
|
+
};
|
|
58497
|
+
this.schedule = () => {
|
|
58498
|
+
return new Promise((resolve) => {
|
|
58499
|
+
const cleanup = () => this.remove(resolver);
|
|
58500
|
+
const resolver = () => resolve(cleanup);
|
|
58501
|
+
this.add(resolver);
|
|
58502
|
+
});
|
|
58503
|
+
};
|
|
58504
|
+
this.tick = () => {
|
|
58505
|
+
if (this.queueActive.size >= this.limit)
|
|
58506
|
+
return;
|
|
58507
|
+
if (!this.queueWaiting.size)
|
|
58508
|
+
return this.reset();
|
|
58509
|
+
for (const fn of this.queueWaiting) {
|
|
58510
|
+
if (this.queueActive.size >= this.limit)
|
|
58511
|
+
break;
|
|
58512
|
+
this.queueWaiting.delete(fn);
|
|
58513
|
+
this.queueActive.add(fn);
|
|
58514
|
+
fn();
|
|
58489
58515
|
}
|
|
58490
|
-
}
|
|
58491
|
-
set2(key, value);
|
|
58492
|
-
}
|
|
58493
|
-
this.store = store;
|
|
58494
|
-
}
|
|
58495
|
-
/**
|
|
58496
|
-
Check if an item exists.
|
|
58497
|
-
|
|
58498
|
-
@param key - The key of the item to check.
|
|
58499
|
-
*/
|
|
58500
|
-
has(key) {
|
|
58501
|
-
if (this.#options.accessPropertiesByDotNotation) {
|
|
58502
|
-
return hasProperty(this.store, key);
|
|
58503
|
-
}
|
|
58504
|
-
return key in this.store;
|
|
58516
|
+
};
|
|
58505
58517
|
}
|
|
58506
|
-
|
|
58507
|
-
|
|
58508
|
-
|
|
58509
|
-
|
|
58510
|
-
|
|
58511
|
-
|
|
58512
|
-
|
|
58513
|
-
|
|
58514
|
-
|
|
58515
|
-
|
|
58516
|
-
|
|
58518
|
+
};
|
|
58519
|
+
var retryify_queue_default = new RetryfyQueue();
|
|
58520
|
+
|
|
58521
|
+
// node_modules/.pnpm/stubborn-fs@1.2.5/node_modules/stubborn-fs/dist/retryify.js
|
|
58522
|
+
var retryifyAsync = (fn, isRetriableError) => {
|
|
58523
|
+
return function retrified(timestamp) {
|
|
58524
|
+
return function attempt(...args) {
|
|
58525
|
+
return retryify_queue_default.schedule().then((cleanup) => {
|
|
58526
|
+
const onResolve = (result) => {
|
|
58527
|
+
cleanup();
|
|
58528
|
+
return result;
|
|
58529
|
+
};
|
|
58530
|
+
const onReject = (error) => {
|
|
58531
|
+
cleanup();
|
|
58532
|
+
if (Date.now() >= timestamp)
|
|
58533
|
+
throw error;
|
|
58534
|
+
if (isRetriableError(error)) {
|
|
58535
|
+
const delay = Math.round(100 * Math.random());
|
|
58536
|
+
const delayPromise = new Promise((resolve) => setTimeout(resolve, delay));
|
|
58537
|
+
return delayPromise.then(() => attempt.apply(void 0, args));
|
|
58538
|
+
}
|
|
58539
|
+
throw error;
|
|
58540
|
+
};
|
|
58541
|
+
return fn.apply(void 0, args).then(onResolve, onReject);
|
|
58542
|
+
});
|
|
58543
|
+
};
|
|
58544
|
+
};
|
|
58545
|
+
};
|
|
58546
|
+
var retryifySync = (fn, isRetriableError) => {
|
|
58547
|
+
return function retrified(timestamp) {
|
|
58548
|
+
return function attempt(...args) {
|
|
58549
|
+
try {
|
|
58550
|
+
return fn.apply(void 0, args);
|
|
58551
|
+
} catch (error) {
|
|
58552
|
+
if (Date.now() > timestamp)
|
|
58553
|
+
throw error;
|
|
58554
|
+
if (isRetriableError(error))
|
|
58555
|
+
return attempt.apply(void 0, args);
|
|
58556
|
+
throw error;
|
|
58517
58557
|
}
|
|
58518
|
-
}
|
|
58519
|
-
}
|
|
58520
|
-
|
|
58521
|
-
|
|
58522
|
-
|
|
58523
|
-
|
|
58524
|
-
|
|
58525
|
-
|
|
58526
|
-
|
|
58527
|
-
|
|
58528
|
-
|
|
58529
|
-
|
|
58530
|
-
|
|
58531
|
-
|
|
58532
|
-
|
|
58533
|
-
|
|
58534
|
-
|
|
58535
|
-
|
|
58536
|
-
|
|
58537
|
-
|
|
58538
|
-
|
|
58539
|
-
|
|
58540
|
-
|
|
58541
|
-
|
|
58542
|
-
|
|
58543
|
-
|
|
58544
|
-
|
|
58545
|
-
|
|
58546
|
-
|
|
58547
|
-
|
|
58548
|
-
|
|
58549
|
-
|
|
58550
|
-
|
|
58551
|
-
|
|
58552
|
-
|
|
58553
|
-
|
|
58554
|
-
|
|
58555
|
-
|
|
58556
|
-
|
|
58557
|
-
|
|
58558
|
-
|
|
58559
|
-
|
|
58560
|
-
|
|
58561
|
-
|
|
58562
|
-
|
|
58563
|
-
|
|
58564
|
-
throw new TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof callback}`);
|
|
58565
|
-
}
|
|
58566
|
-
return this._handleChange(() => this.store, callback);
|
|
58567
|
-
}
|
|
58568
|
-
get size() {
|
|
58569
|
-
return Object.keys(this.store).length;
|
|
58558
|
+
};
|
|
58559
|
+
};
|
|
58560
|
+
};
|
|
58561
|
+
|
|
58562
|
+
// node_modules/.pnpm/stubborn-fs@1.2.5/node_modules/stubborn-fs/dist/index.js
|
|
58563
|
+
var FS = {
|
|
58564
|
+
attempt: {
|
|
58565
|
+
/* ASYNC */
|
|
58566
|
+
chmod: attemptifyAsync((0, import_node_util.promisify)(import_node_fs.default.chmod), handlers_default.onChangeError),
|
|
58567
|
+
chown: attemptifyAsync((0, import_node_util.promisify)(import_node_fs.default.chown), handlers_default.onChangeError),
|
|
58568
|
+
close: attemptifyAsync((0, import_node_util.promisify)(import_node_fs.default.close), NOOP),
|
|
58569
|
+
fsync: attemptifyAsync((0, import_node_util.promisify)(import_node_fs.default.fsync), NOOP),
|
|
58570
|
+
mkdir: attemptifyAsync((0, import_node_util.promisify)(import_node_fs.default.mkdir), NOOP),
|
|
58571
|
+
realpath: attemptifyAsync((0, import_node_util.promisify)(import_node_fs.default.realpath), NOOP),
|
|
58572
|
+
stat: attemptifyAsync((0, import_node_util.promisify)(import_node_fs.default.stat), NOOP),
|
|
58573
|
+
unlink: attemptifyAsync((0, import_node_util.promisify)(import_node_fs.default.unlink), NOOP),
|
|
58574
|
+
/* SYNC */
|
|
58575
|
+
chmodSync: attemptifySync(import_node_fs.default.chmodSync, handlers_default.onChangeError),
|
|
58576
|
+
chownSync: attemptifySync(import_node_fs.default.chownSync, handlers_default.onChangeError),
|
|
58577
|
+
closeSync: attemptifySync(import_node_fs.default.closeSync, NOOP),
|
|
58578
|
+
existsSync: attemptifySync(import_node_fs.default.existsSync, NOOP),
|
|
58579
|
+
fsyncSync: attemptifySync(import_node_fs.default.fsync, NOOP),
|
|
58580
|
+
mkdirSync: attemptifySync(import_node_fs.default.mkdirSync, NOOP),
|
|
58581
|
+
realpathSync: attemptifySync(import_node_fs.default.realpathSync, NOOP),
|
|
58582
|
+
statSync: attemptifySync(import_node_fs.default.statSync, NOOP),
|
|
58583
|
+
unlinkSync: attemptifySync(import_node_fs.default.unlinkSync, NOOP)
|
|
58584
|
+
},
|
|
58585
|
+
retry: {
|
|
58586
|
+
/* ASYNC */
|
|
58587
|
+
close: retryifyAsync((0, import_node_util.promisify)(import_node_fs.default.close), handlers_default.isRetriableError),
|
|
58588
|
+
fsync: retryifyAsync((0, import_node_util.promisify)(import_node_fs.default.fsync), handlers_default.isRetriableError),
|
|
58589
|
+
open: retryifyAsync((0, import_node_util.promisify)(import_node_fs.default.open), handlers_default.isRetriableError),
|
|
58590
|
+
readFile: retryifyAsync((0, import_node_util.promisify)(import_node_fs.default.readFile), handlers_default.isRetriableError),
|
|
58591
|
+
rename: retryifyAsync((0, import_node_util.promisify)(import_node_fs.default.rename), handlers_default.isRetriableError),
|
|
58592
|
+
stat: retryifyAsync((0, import_node_util.promisify)(import_node_fs.default.stat), handlers_default.isRetriableError),
|
|
58593
|
+
write: retryifyAsync((0, import_node_util.promisify)(import_node_fs.default.write), handlers_default.isRetriableError),
|
|
58594
|
+
writeFile: retryifyAsync((0, import_node_util.promisify)(import_node_fs.default.writeFile), handlers_default.isRetriableError),
|
|
58595
|
+
/* SYNC */
|
|
58596
|
+
closeSync: retryifySync(import_node_fs.default.closeSync, handlers_default.isRetriableError),
|
|
58597
|
+
fsyncSync: retryifySync(import_node_fs.default.fsyncSync, handlers_default.isRetriableError),
|
|
58598
|
+
openSync: retryifySync(import_node_fs.default.openSync, handlers_default.isRetriableError),
|
|
58599
|
+
readFileSync: retryifySync(import_node_fs.default.readFileSync, handlers_default.isRetriableError),
|
|
58600
|
+
renameSync: retryifySync(import_node_fs.default.renameSync, handlers_default.isRetriableError),
|
|
58601
|
+
statSync: retryifySync(import_node_fs.default.statSync, handlers_default.isRetriableError),
|
|
58602
|
+
writeSync: retryifySync(import_node_fs.default.writeSync, handlers_default.isRetriableError),
|
|
58603
|
+
writeFileSync: retryifySync(import_node_fs.default.writeFileSync, handlers_default.isRetriableError)
|
|
58570
58604
|
}
|
|
58571
|
-
|
|
58572
|
-
|
|
58573
|
-
|
|
58574
|
-
|
|
58575
|
-
|
|
58576
|
-
|
|
58577
|
-
|
|
58578
|
-
|
|
58579
|
-
|
|
58580
|
-
|
|
58581
|
-
|
|
58605
|
+
};
|
|
58606
|
+
var dist_default = FS;
|
|
58607
|
+
|
|
58608
|
+
// node_modules/.pnpm/atomically@2.0.3/node_modules/atomically/dist/constants.js
|
|
58609
|
+
var import_node_os3 = __toESM(require("node:os"), 1);
|
|
58610
|
+
var import_node_process4 = __toESM(require("node:process"), 1);
|
|
58611
|
+
var DEFAULT_ENCODING = "utf8";
|
|
58612
|
+
var DEFAULT_FILE_MODE = 438;
|
|
58613
|
+
var DEFAULT_FOLDER_MODE = 511;
|
|
58614
|
+
var DEFAULT_WRITE_OPTIONS = {};
|
|
58615
|
+
var DEFAULT_USER_UID = import_node_os3.default.userInfo().uid;
|
|
58616
|
+
var DEFAULT_USER_GID = import_node_os3.default.userInfo().gid;
|
|
58617
|
+
var DEFAULT_TIMEOUT_SYNC = 1e3;
|
|
58618
|
+
var IS_POSIX = !!import_node_process4.default.getuid;
|
|
58619
|
+
var IS_USER_ROOT2 = import_node_process4.default.getuid ? !import_node_process4.default.getuid() : false;
|
|
58620
|
+
var LIMIT_BASENAME_LENGTH = 128;
|
|
58621
|
+
|
|
58622
|
+
// node_modules/.pnpm/atomically@2.0.3/node_modules/atomically/dist/utils/lang.js
|
|
58623
|
+
var isException = (value) => {
|
|
58624
|
+
return value instanceof Error && "code" in value;
|
|
58625
|
+
};
|
|
58626
|
+
var isString = (value) => {
|
|
58627
|
+
return typeof value === "string";
|
|
58628
|
+
};
|
|
58629
|
+
var isUndefined = (value) => {
|
|
58630
|
+
return value === void 0;
|
|
58631
|
+
};
|
|
58632
|
+
|
|
58633
|
+
// node_modules/.pnpm/atomically@2.0.3/node_modules/atomically/dist/utils/temp.js
|
|
58634
|
+
var import_node_path2 = __toESM(require("node:path"), 1);
|
|
58635
|
+
|
|
58636
|
+
// node_modules/.pnpm/when-exit@2.1.2/node_modules/when-exit/dist/node/interceptor.js
|
|
58637
|
+
var import_node_process6 = __toESM(require("node:process"), 1);
|
|
58638
|
+
|
|
58639
|
+
// node_modules/.pnpm/when-exit@2.1.2/node_modules/when-exit/dist/node/constants.js
|
|
58640
|
+
var import_node_process5 = __toESM(require("node:process"), 1);
|
|
58641
|
+
var IS_LINUX = import_node_process5.default.platform === "linux";
|
|
58642
|
+
var IS_WINDOWS = import_node_process5.default.platform === "win32";
|
|
58643
|
+
|
|
58644
|
+
// node_modules/.pnpm/when-exit@2.1.2/node_modules/when-exit/dist/node/signals.js
|
|
58645
|
+
var Signals = ["SIGABRT", "SIGALRM", "SIGHUP", "SIGINT", "SIGTERM"];
|
|
58646
|
+
if (!IS_WINDOWS) {
|
|
58647
|
+
Signals.push("SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
|
|
58648
|
+
}
|
|
58649
|
+
if (IS_LINUX) {
|
|
58650
|
+
Signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT", "SIGUNUSED");
|
|
58651
|
+
}
|
|
58652
|
+
var signals_default = Signals;
|
|
58653
|
+
|
|
58654
|
+
// node_modules/.pnpm/when-exit@2.1.2/node_modules/when-exit/dist/node/interceptor.js
|
|
58655
|
+
var Interceptor = class {
|
|
58656
|
+
/* CONSTRUCTOR */
|
|
58657
|
+
constructor() {
|
|
58658
|
+
this.callbacks = /* @__PURE__ */ new Set();
|
|
58659
|
+
this.exited = false;
|
|
58660
|
+
this.exit = (signal) => {
|
|
58661
|
+
if (this.exited)
|
|
58662
|
+
return;
|
|
58663
|
+
this.exited = true;
|
|
58664
|
+
for (const callback of this.callbacks) {
|
|
58665
|
+
callback();
|
|
58582
58666
|
}
|
|
58583
|
-
if (
|
|
58584
|
-
|
|
58667
|
+
if (signal) {
|
|
58668
|
+
if (IS_WINDOWS && (signal !== "SIGINT" && signal !== "SIGTERM" && signal !== "SIGKILL")) {
|
|
58669
|
+
import_node_process6.default.kill(import_node_process6.default.pid, "SIGTERM");
|
|
58670
|
+
} else {
|
|
58671
|
+
import_node_process6.default.kill(import_node_process6.default.pid, signal);
|
|
58672
|
+
}
|
|
58585
58673
|
}
|
|
58586
|
-
|
|
58587
|
-
|
|
58588
|
-
|
|
58589
|
-
|
|
58590
|
-
|
|
58591
|
-
this._validate(value);
|
|
58592
|
-
this._write(value);
|
|
58593
|
-
this.events.dispatchEvent(new Event("change"));
|
|
58594
|
-
}
|
|
58595
|
-
*[Symbol.iterator]() {
|
|
58596
|
-
for (const [key, value] of Object.entries(this.store)) {
|
|
58597
|
-
yield [key, value];
|
|
58598
|
-
}
|
|
58599
|
-
}
|
|
58600
|
-
_encryptData(data) {
|
|
58601
|
-
if (!this.#encryptionKey) {
|
|
58602
|
-
return typeof data === "string" ? data : uint8ArrayToString(data);
|
|
58603
|
-
}
|
|
58604
|
-
try {
|
|
58605
|
-
const initializationVector = data.slice(0, 16);
|
|
58606
|
-
const password = import_node_crypto2.default.pbkdf2Sync(this.#encryptionKey, initializationVector.toString(), 1e4, 32, "sha512");
|
|
58607
|
-
const decipher = import_node_crypto2.default.createDecipheriv(encryptionAlgorithm, password, initializationVector);
|
|
58608
|
-
const slice = data.slice(17);
|
|
58609
|
-
const dataUpdate = typeof slice === "string" ? stringToUint8Array(slice) : slice;
|
|
58610
|
-
return uint8ArrayToString(concatUint8Arrays([decipher.update(dataUpdate), decipher.final()]));
|
|
58611
|
-
} catch {
|
|
58612
|
-
}
|
|
58613
|
-
return data.toString();
|
|
58614
|
-
}
|
|
58615
|
-
_handleChange(getter, callback) {
|
|
58616
|
-
let currentValue = getter();
|
|
58617
|
-
const onChange = () => {
|
|
58618
|
-
const oldValue = currentValue;
|
|
58619
|
-
const newValue = getter();
|
|
58620
|
-
if ((0, import_node_util2.isDeepStrictEqual)(newValue, oldValue)) {
|
|
58621
|
-
return;
|
|
58674
|
+
};
|
|
58675
|
+
this.hook = () => {
|
|
58676
|
+
import_node_process6.default.once("exit", () => this.exit());
|
|
58677
|
+
for (const signal of signals_default) {
|
|
58678
|
+
import_node_process6.default.once(signal, () => this.exit(signal));
|
|
58622
58679
|
}
|
|
58623
|
-
currentValue = newValue;
|
|
58624
|
-
callback.call(this, newValue, oldValue);
|
|
58625
58680
|
};
|
|
58626
|
-
this.
|
|
58627
|
-
|
|
58628
|
-
|
|
58681
|
+
this.register = (callback) => {
|
|
58682
|
+
this.callbacks.add(callback);
|
|
58683
|
+
return () => {
|
|
58684
|
+
this.callbacks.delete(callback);
|
|
58685
|
+
};
|
|
58629
58686
|
};
|
|
58687
|
+
this.hook();
|
|
58630
58688
|
}
|
|
58631
|
-
|
|
58632
|
-
|
|
58633
|
-
|
|
58634
|
-
|
|
58689
|
+
};
|
|
58690
|
+
var interceptor_default = new Interceptor();
|
|
58691
|
+
|
|
58692
|
+
// node_modules/.pnpm/when-exit@2.1.2/node_modules/when-exit/dist/node/index.js
|
|
58693
|
+
var whenExit = interceptor_default.register;
|
|
58694
|
+
var node_default = whenExit;
|
|
58695
|
+
|
|
58696
|
+
// node_modules/.pnpm/atomically@2.0.3/node_modules/atomically/dist/utils/temp.js
|
|
58697
|
+
var Temp = {
|
|
58698
|
+
/* VARIABLES */
|
|
58699
|
+
store: {},
|
|
58700
|
+
/* API */
|
|
58701
|
+
create: (filePath) => {
|
|
58702
|
+
const randomness = `000000${Math.floor(Math.random() * 16777215).toString(16)}`.slice(-6);
|
|
58703
|
+
const timestamp = Date.now().toString().slice(-10);
|
|
58704
|
+
const prefix = "tmp-";
|
|
58705
|
+
const suffix = `.${prefix}${timestamp}${randomness}`;
|
|
58706
|
+
const tempPath = `${filePath}${suffix}`;
|
|
58707
|
+
return tempPath;
|
|
58708
|
+
},
|
|
58709
|
+
get: (filePath, creator, purge = true) => {
|
|
58710
|
+
const tempPath = Temp.truncate(creator(filePath));
|
|
58711
|
+
if (tempPath in Temp.store)
|
|
58712
|
+
return Temp.get(filePath, creator, purge);
|
|
58713
|
+
Temp.store[tempPath] = purge;
|
|
58714
|
+
const disposer = () => delete Temp.store[tempPath];
|
|
58715
|
+
return [tempPath, disposer];
|
|
58716
|
+
},
|
|
58717
|
+
purge: (filePath) => {
|
|
58718
|
+
if (!Temp.store[filePath])
|
|
58635
58719
|
return;
|
|
58636
|
-
|
|
58637
|
-
|
|
58638
|
-
|
|
58720
|
+
delete Temp.store[filePath];
|
|
58721
|
+
dist_default.attempt.unlink(filePath);
|
|
58722
|
+
},
|
|
58723
|
+
purgeSync: (filePath) => {
|
|
58724
|
+
if (!Temp.store[filePath])
|
|
58639
58725
|
return;
|
|
58726
|
+
delete Temp.store[filePath];
|
|
58727
|
+
dist_default.attempt.unlinkSync(filePath);
|
|
58728
|
+
},
|
|
58729
|
+
purgeSyncAll: () => {
|
|
58730
|
+
for (const filePath in Temp.store) {
|
|
58731
|
+
Temp.purgeSync(filePath);
|
|
58640
58732
|
}
|
|
58641
|
-
|
|
58642
|
-
|
|
58643
|
-
|
|
58644
|
-
|
|
58645
|
-
|
|
58733
|
+
},
|
|
58734
|
+
truncate: (filePath) => {
|
|
58735
|
+
const basename2 = import_node_path2.default.basename(filePath);
|
|
58736
|
+
if (basename2.length <= LIMIT_BASENAME_LENGTH)
|
|
58737
|
+
return filePath;
|
|
58738
|
+
const truncable = /^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(basename2);
|
|
58739
|
+
if (!truncable)
|
|
58740
|
+
return filePath;
|
|
58741
|
+
const truncationLength = basename2.length - LIMIT_BASENAME_LENGTH;
|
|
58742
|
+
return `${filePath.slice(0, -basename2.length)}${truncable[1]}${truncable[2].slice(0, -truncationLength)}${truncable[3]}`;
|
|
58646
58743
|
}
|
|
58647
|
-
|
|
58648
|
-
|
|
58649
|
-
|
|
58650
|
-
|
|
58651
|
-
|
|
58652
|
-
|
|
58653
|
-
|
|
58654
|
-
}
|
|
58655
|
-
|
|
58656
|
-
|
|
58657
|
-
|
|
58658
|
-
|
|
58659
|
-
|
|
58660
|
-
|
|
58661
|
-
|
|
58662
|
-
|
|
58663
|
-
|
|
58744
|
+
};
|
|
58745
|
+
node_default(Temp.purgeSyncAll);
|
|
58746
|
+
var temp_default = Temp;
|
|
58747
|
+
|
|
58748
|
+
// node_modules/.pnpm/atomically@2.0.3/node_modules/atomically/dist/index.js
|
|
58749
|
+
function writeFileSync(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
|
|
58750
|
+
if (isString(options))
|
|
58751
|
+
return writeFileSync(filePath, data, { encoding: options });
|
|
58752
|
+
const timeout = Date.now() + ((options.timeout ?? DEFAULT_TIMEOUT_SYNC) || -1);
|
|
58753
|
+
let tempDisposer = null;
|
|
58754
|
+
let tempPath = null;
|
|
58755
|
+
let fd = null;
|
|
58756
|
+
try {
|
|
58757
|
+
const filePathReal = dist_default.attempt.realpathSync(filePath);
|
|
58758
|
+
const filePathExists = !!filePathReal;
|
|
58759
|
+
filePath = filePathReal || filePath;
|
|
58760
|
+
[tempPath, tempDisposer] = temp_default.get(filePath, options.tmpCreate || temp_default.create, !(options.tmpPurge === false));
|
|
58761
|
+
const useStatChown = IS_POSIX && isUndefined(options.chown);
|
|
58762
|
+
const useStatMode = isUndefined(options.mode);
|
|
58763
|
+
if (filePathExists && (useStatChown || useStatMode)) {
|
|
58764
|
+
const stats = dist_default.attempt.statSync(filePath);
|
|
58765
|
+
if (stats) {
|
|
58766
|
+
options = { ...options };
|
|
58767
|
+
if (useStatChown) {
|
|
58768
|
+
options.chown = { uid: stats.uid, gid: stats.gid };
|
|
58664
58769
|
}
|
|
58665
|
-
|
|
58666
|
-
|
|
58667
|
-
}
|
|
58668
|
-
}
|
|
58669
|
-
_watch() {
|
|
58670
|
-
this._ensureDirectory();
|
|
58671
|
-
if (!import_node_fs2.default.existsSync(this.path)) {
|
|
58672
|
-
this._write(createPlainObject());
|
|
58673
|
-
}
|
|
58674
|
-
if (import_node_process7.default.platform === "win32") {
|
|
58675
|
-
import_node_fs2.default.watch(this.path, { persistent: false }, debounce_fn_default(() => {
|
|
58676
|
-
this.events.dispatchEvent(new Event("change"));
|
|
58677
|
-
}, { wait: 100 }));
|
|
58678
|
-
} else {
|
|
58679
|
-
import_node_fs2.default.watchFile(this.path, { persistent: false }, debounce_fn_default(() => {
|
|
58680
|
-
this.events.dispatchEvent(new Event("change"));
|
|
58681
|
-
}, { wait: 5e3 }));
|
|
58682
|
-
}
|
|
58683
|
-
}
|
|
58684
|
-
_migrate(migrations, versionToMigrate, beforeEachMigration) {
|
|
58685
|
-
let previousMigratedVersion = this._get(MIGRATION_KEY, "0.0.0");
|
|
58686
|
-
const newerVersions = Object.keys(migrations).filter((candidateVersion) => this._shouldPerformMigration(candidateVersion, previousMigratedVersion, versionToMigrate));
|
|
58687
|
-
let storeBackup = { ...this.store };
|
|
58688
|
-
for (const version of newerVersions) {
|
|
58689
|
-
try {
|
|
58690
|
-
if (beforeEachMigration) {
|
|
58691
|
-
beforeEachMigration(this, {
|
|
58692
|
-
fromVersion: previousMigratedVersion,
|
|
58693
|
-
toVersion: version,
|
|
58694
|
-
finalVersion: versionToMigrate,
|
|
58695
|
-
versions: newerVersions
|
|
58696
|
-
});
|
|
58770
|
+
if (useStatMode) {
|
|
58771
|
+
options.mode = stats.mode;
|
|
58697
58772
|
}
|
|
58698
|
-
const migration = migrations[version];
|
|
58699
|
-
migration?.(this);
|
|
58700
|
-
this._set(MIGRATION_KEY, version);
|
|
58701
|
-
previousMigratedVersion = version;
|
|
58702
|
-
storeBackup = { ...this.store };
|
|
58703
|
-
} catch (error) {
|
|
58704
|
-
this.store = storeBackup;
|
|
58705
|
-
throw new Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${error}`);
|
|
58706
58773
|
}
|
|
58707
58774
|
}
|
|
58708
|
-
if (
|
|
58709
|
-
|
|
58775
|
+
if (!filePathExists) {
|
|
58776
|
+
const parentPath = import_node_path3.default.dirname(filePath);
|
|
58777
|
+
dist_default.attempt.mkdirSync(parentPath, {
|
|
58778
|
+
mode: DEFAULT_FOLDER_MODE,
|
|
58779
|
+
recursive: true
|
|
58780
|
+
});
|
|
58710
58781
|
}
|
|
58711
|
-
|
|
58712
|
-
|
|
58713
|
-
|
|
58714
|
-
const firsKey = Object.keys(key)[0];
|
|
58715
|
-
if (firsKey === INTERNAL_KEY) {
|
|
58716
|
-
return true;
|
|
58717
|
-
}
|
|
58782
|
+
fd = dist_default.retry.openSync(timeout)(tempPath, "w", options.mode || DEFAULT_FILE_MODE);
|
|
58783
|
+
if (options.tmpCreated) {
|
|
58784
|
+
options.tmpCreated(tempPath);
|
|
58718
58785
|
}
|
|
58719
|
-
if (
|
|
58720
|
-
|
|
58786
|
+
if (isString(data)) {
|
|
58787
|
+
dist_default.retry.writeSync(timeout)(fd, data, 0, options.encoding || DEFAULT_ENCODING);
|
|
58788
|
+
} else if (!isUndefined(data)) {
|
|
58789
|
+
dist_default.retry.writeSync(timeout)(fd, data, 0, data.length, 0);
|
|
58721
58790
|
}
|
|
58722
|
-
if (
|
|
58723
|
-
if (
|
|
58724
|
-
|
|
58791
|
+
if (options.fsync !== false) {
|
|
58792
|
+
if (options.fsyncWait !== false) {
|
|
58793
|
+
dist_default.retry.fsyncSync(timeout)(fd);
|
|
58794
|
+
} else {
|
|
58795
|
+
dist_default.attempt.fsync(fd);
|
|
58725
58796
|
}
|
|
58726
|
-
return false;
|
|
58727
58797
|
}
|
|
58728
|
-
|
|
58729
|
-
|
|
58730
|
-
|
|
58731
|
-
|
|
58732
|
-
}
|
|
58733
|
-
_shouldPerformMigration(candidateVersion, previousMigratedVersion, versionToMigrate) {
|
|
58734
|
-
if (this._isVersionInRangeFormat(candidateVersion)) {
|
|
58735
|
-
if (previousMigratedVersion !== "0.0.0" && import_semver.default.satisfies(previousMigratedVersion, candidateVersion)) {
|
|
58736
|
-
return false;
|
|
58737
|
-
}
|
|
58738
|
-
return import_semver.default.satisfies(versionToMigrate, candidateVersion);
|
|
58798
|
+
dist_default.retry.closeSync(timeout)(fd);
|
|
58799
|
+
fd = null;
|
|
58800
|
+
if (options.chown && (options.chown.uid !== DEFAULT_USER_UID || options.chown.gid !== DEFAULT_USER_GID)) {
|
|
58801
|
+
dist_default.attempt.chownSync(tempPath, options.chown.uid, options.chown.gid);
|
|
58739
58802
|
}
|
|
58740
|
-
if (
|
|
58741
|
-
|
|
58803
|
+
if (options.mode && options.mode !== DEFAULT_FILE_MODE) {
|
|
58804
|
+
dist_default.attempt.chmodSync(tempPath, options.mode);
|
|
58742
58805
|
}
|
|
58743
|
-
|
|
58744
|
-
|
|
58806
|
+
try {
|
|
58807
|
+
dist_default.retry.renameSync(timeout)(tempPath, filePath);
|
|
58808
|
+
} catch (error) {
|
|
58809
|
+
if (!isException(error))
|
|
58810
|
+
throw error;
|
|
58811
|
+
if (error.code !== "ENAMETOOLONG")
|
|
58812
|
+
throw error;
|
|
58813
|
+
dist_default.retry.renameSync(timeout)(tempPath, temp_default.truncate(filePath));
|
|
58745
58814
|
}
|
|
58746
|
-
|
|
58747
|
-
|
|
58748
|
-
|
|
58749
|
-
|
|
58750
|
-
|
|
58751
|
-
|
|
58752
|
-
|
|
58753
|
-
setProperty(store, key, value);
|
|
58754
|
-
this.store = store;
|
|
58815
|
+
tempDisposer();
|
|
58816
|
+
tempPath = null;
|
|
58817
|
+
} finally {
|
|
58818
|
+
if (fd)
|
|
58819
|
+
dist_default.attempt.closeSync(fd);
|
|
58820
|
+
if (tempPath)
|
|
58821
|
+
temp_default.purge(tempPath);
|
|
58755
58822
|
}
|
|
58756
|
-
}
|
|
58823
|
+
}
|
|
58757
58824
|
|
|
58758
|
-
//
|
|
58759
|
-
var
|
|
58760
|
-
var
|
|
58761
|
-
|
|
58762
|
-
|
|
58763
|
-
|
|
58764
|
-
|
|
58765
|
-
|
|
58766
|
-
configName: name,
|
|
58767
|
-
cwd: dataFolder,
|
|
58768
|
-
projectSuffix: ""
|
|
58769
|
-
});
|
|
58770
|
-
}
|
|
58771
|
-
get(key, defaultValue) {
|
|
58772
|
-
return this.client.get(key, defaultValue);
|
|
58773
|
-
}
|
|
58774
|
-
set(key, value) {
|
|
58775
|
-
this.client.set(key, value);
|
|
58776
|
-
}
|
|
58777
|
-
clear() {
|
|
58778
|
-
this.client.clear();
|
|
58825
|
+
// node_modules/.pnpm/conf@12.0.0/node_modules/conf/dist/source/index.js
|
|
58826
|
+
var import_ajv = __toESM(require_ajv(), 1);
|
|
58827
|
+
var import_ajv_formats = __toESM(require_dist(), 1);
|
|
58828
|
+
|
|
58829
|
+
// node_modules/.pnpm/mimic-fn@4.0.0/node_modules/mimic-fn/index.js
|
|
58830
|
+
var copyProperty = (to, from3, property, ignoreNonConfigurable) => {
|
|
58831
|
+
if (property === "length" || property === "prototype") {
|
|
58832
|
+
return;
|
|
58779
58833
|
}
|
|
58780
|
-
|
|
58781
|
-
return
|
|
58834
|
+
if (property === "arguments" || property === "caller") {
|
|
58835
|
+
return;
|
|
58782
58836
|
}
|
|
58783
|
-
|
|
58784
|
-
|
|
58837
|
+
const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
|
|
58838
|
+
const fromDescriptor = Object.getOwnPropertyDescriptor(from3, property);
|
|
58839
|
+
if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
|
|
58840
|
+
return;
|
|
58785
58841
|
}
|
|
58842
|
+
Object.defineProperty(to, property, fromDescriptor);
|
|
58786
58843
|
};
|
|
58787
|
-
|
|
58788
|
-
|
|
58789
|
-
var App = class {
|
|
58790
|
-
constructor(options = {}) {
|
|
58791
|
-
this.encryptionKey = options.encryptionKey || config_default.masterPasswordHash;
|
|
58792
|
-
this.dataFolder = options.dataFolder || config_default.dataFolder;
|
|
58793
|
-
this.name = options.name || "default";
|
|
58794
|
-
this.db = new DB({
|
|
58795
|
-
encryptionKey: this.encryptionKey,
|
|
58796
|
-
dataFolder: this.dataFolder,
|
|
58797
|
-
name: this.name
|
|
58798
|
-
});
|
|
58799
|
-
this.secrets = new Secrets(this.db);
|
|
58800
|
-
}
|
|
58801
|
-
static async masterKey(masterPassword, masterPasswordHash) {
|
|
58802
|
-
masterPassword = masterPassword || config_default.masterPassword;
|
|
58803
|
-
if (masterPasswordHash) {
|
|
58804
|
-
return masterPasswordHash;
|
|
58805
|
-
} else if (!masterPassword) {
|
|
58806
|
-
masterPassword = await ask({
|
|
58807
|
-
name: "masterPassword",
|
|
58808
|
-
message: "Password:",
|
|
58809
|
-
type: "password",
|
|
58810
|
-
required: true
|
|
58811
|
-
});
|
|
58812
|
-
}
|
|
58813
|
-
masterPasswordHash = Cipher.hash(masterPassword);
|
|
58814
|
-
return masterPasswordHash;
|
|
58815
|
-
}
|
|
58844
|
+
var canCopyProperty = function(toDescriptor, fromDescriptor) {
|
|
58845
|
+
return toDescriptor === void 0 || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
|
|
58816
58846
|
};
|
|
58817
|
-
|
|
58818
|
-
|
|
58819
|
-
|
|
58820
|
-
|
|
58821
|
-
{
|
|
58822
|
-
name: "password",
|
|
58823
|
-
message: "password:",
|
|
58824
|
-
type: "password",
|
|
58825
|
-
required: true
|
|
58826
|
-
}
|
|
58827
|
-
];
|
|
58828
|
-
if (confirm) {
|
|
58829
|
-
questions.push({
|
|
58830
|
-
name: "confirmPassword",
|
|
58831
|
-
message: "confirm password:",
|
|
58832
|
-
type: "password",
|
|
58833
|
-
required: true
|
|
58834
|
-
});
|
|
58835
|
-
}
|
|
58836
|
-
const input = await prompt2(questions);
|
|
58837
|
-
if (input.confirmPassword && input.password !== input.confirmPassword) {
|
|
58838
|
-
throw new Error("Passwords do not match");
|
|
58847
|
+
var changePrototype = (to, from3) => {
|
|
58848
|
+
const fromPrototype = Object.getPrototypeOf(from3);
|
|
58849
|
+
if (fromPrototype === Object.getPrototypeOf(to)) {
|
|
58850
|
+
return;
|
|
58839
58851
|
}
|
|
58840
|
-
|
|
58852
|
+
Object.setPrototypeOf(to, fromPrototype);
|
|
58841
58853
|
};
|
|
58842
|
-
var
|
|
58854
|
+
var wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/
|
|
58855
|
+
${fromBody}`;
|
|
58856
|
+
var toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, "toString");
|
|
58857
|
+
var toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name");
|
|
58858
|
+
var changeToString = (to, from3, name) => {
|
|
58859
|
+
const withName = name === "" ? "" : `with ${name.trim()}() `;
|
|
58860
|
+
const newToString = wrappedToString.bind(null, withName, from3.toString());
|
|
58861
|
+
Object.defineProperty(newToString, "name", toStringName);
|
|
58862
|
+
Object.defineProperty(to, "toString", { ...toStringDescriptor, value: newToString });
|
|
58863
|
+
};
|
|
58864
|
+
function mimicFunction(to, from3, { ignoreNonConfigurable = false } = {}) {
|
|
58865
|
+
const { name } = to;
|
|
58866
|
+
for (const property of Reflect.ownKeys(from3)) {
|
|
58867
|
+
copyProperty(to, from3, property, ignoreNonConfigurable);
|
|
58868
|
+
}
|
|
58869
|
+
changePrototype(to, from3);
|
|
58870
|
+
changeToString(to, from3, name);
|
|
58871
|
+
return to;
|
|
58872
|
+
}
|
|
58843
58873
|
|
|
58844
|
-
//
|
|
58845
|
-
var
|
|
58846
|
-
|
|
58847
|
-
|
|
58848
|
-
{
|
|
58849
|
-
name: "name",
|
|
58850
|
-
message: "name:",
|
|
58851
|
-
type: "input",
|
|
58852
|
-
required: true
|
|
58853
|
-
},
|
|
58854
|
-
{
|
|
58855
|
-
name: "type",
|
|
58856
|
-
message: "type:",
|
|
58857
|
-
type: "list",
|
|
58858
|
-
default: "password",
|
|
58859
|
-
choices: [
|
|
58860
|
-
{ name: "Password", value: "password" },
|
|
58861
|
-
{ name: "OTP", value: "otp" },
|
|
58862
|
-
{ name: "Note", value: "note" }
|
|
58863
|
-
],
|
|
58864
|
-
required: true
|
|
58865
|
-
},
|
|
58866
|
-
{
|
|
58867
|
-
name: "protected",
|
|
58868
|
-
message: "protected:",
|
|
58869
|
-
type: "confirm",
|
|
58870
|
-
default: false,
|
|
58871
|
-
required: true
|
|
58872
|
-
}
|
|
58873
|
-
]);
|
|
58874
|
-
let newSecret = { typeOptions: {} };
|
|
58875
|
-
let encryptionKey = app.db.encryptionKey;
|
|
58876
|
-
if (info.protected) {
|
|
58877
|
-
encryptionKey = await getEncryptionKey_default(true);
|
|
58874
|
+
// node_modules/.pnpm/debounce-fn@5.1.2/node_modules/debounce-fn/index.js
|
|
58875
|
+
var debounceFn = (inputFunction, options = {}) => {
|
|
58876
|
+
if (typeof inputFunction !== "function") {
|
|
58877
|
+
throw new TypeError(`Expected the first argument to be a function, got \`${typeof inputFunction}\``);
|
|
58878
58878
|
}
|
|
58879
|
-
|
|
58880
|
-
|
|
58881
|
-
|
|
58882
|
-
|
|
58883
|
-
|
|
58884
|
-
|
|
58885
|
-
|
|
58886
|
-
|
|
58887
|
-
|
|
58888
|
-
|
|
58889
|
-
|
|
58890
|
-
|
|
58891
|
-
|
|
58892
|
-
|
|
58893
|
-
|
|
58894
|
-
|
|
58895
|
-
|
|
58896
|
-
|
|
58897
|
-
|
|
58898
|
-
type: "password",
|
|
58899
|
-
required: true
|
|
58900
|
-
}
|
|
58901
|
-
]);
|
|
58902
|
-
newSecret = {
|
|
58903
|
-
...info,
|
|
58904
|
-
value: password.value,
|
|
58905
|
-
typeOptions: {
|
|
58906
|
-
username: password.username,
|
|
58907
|
-
url: password.url
|
|
58908
|
-
}
|
|
58909
|
-
};
|
|
58879
|
+
const {
|
|
58880
|
+
wait = 0,
|
|
58881
|
+
maxWait = Number.POSITIVE_INFINITY,
|
|
58882
|
+
before = false,
|
|
58883
|
+
after = true
|
|
58884
|
+
} = options;
|
|
58885
|
+
if (!before && !after) {
|
|
58886
|
+
throw new Error("Both `before` and `after` are false, function wouldn't be called.");
|
|
58887
|
+
}
|
|
58888
|
+
let timeout;
|
|
58889
|
+
let maxTimeout;
|
|
58890
|
+
let result;
|
|
58891
|
+
const debouncedFunction = function(...arguments_) {
|
|
58892
|
+
const context = this;
|
|
58893
|
+
const later = () => {
|
|
58894
|
+
timeout = void 0;
|
|
58895
|
+
if (maxTimeout) {
|
|
58896
|
+
clearTimeout(maxTimeout);
|
|
58897
|
+
maxTimeout = void 0;
|
|
58910
58898
|
}
|
|
58911
|
-
|
|
58912
|
-
|
|
58913
|
-
{
|
|
58914
|
-
const note = await prompt2([
|
|
58915
|
-
{
|
|
58916
|
-
name: "value",
|
|
58917
|
-
message: "note:",
|
|
58918
|
-
type: "password",
|
|
58919
|
-
required: true
|
|
58920
|
-
}
|
|
58921
|
-
]);
|
|
58922
|
-
newSecret = {
|
|
58923
|
-
...info,
|
|
58924
|
-
value: note.value,
|
|
58925
|
-
typeOptions: {}
|
|
58926
|
-
};
|
|
58899
|
+
if (after) {
|
|
58900
|
+
result = inputFunction.apply(context, arguments_);
|
|
58927
58901
|
}
|
|
58928
|
-
|
|
58929
|
-
|
|
58930
|
-
|
|
58931
|
-
|
|
58932
|
-
|
|
58933
|
-
|
|
58934
|
-
message: "username:",
|
|
58935
|
-
type: "input",
|
|
58936
|
-
required: true
|
|
58937
|
-
},
|
|
58938
|
-
{
|
|
58939
|
-
name: "value",
|
|
58940
|
-
message: "value:",
|
|
58941
|
-
type: "password",
|
|
58942
|
-
required: true
|
|
58943
|
-
}
|
|
58944
|
-
]);
|
|
58945
|
-
newSecret = {
|
|
58946
|
-
...info,
|
|
58947
|
-
value: otp.value,
|
|
58948
|
-
typeOptions: {
|
|
58949
|
-
username: otp.username
|
|
58950
|
-
}
|
|
58951
|
-
};
|
|
58902
|
+
};
|
|
58903
|
+
const maxLater = () => {
|
|
58904
|
+
maxTimeout = void 0;
|
|
58905
|
+
if (timeout) {
|
|
58906
|
+
clearTimeout(timeout);
|
|
58907
|
+
timeout = void 0;
|
|
58952
58908
|
}
|
|
58953
|
-
|
|
58954
|
-
|
|
58955
|
-
|
|
58909
|
+
if (after) {
|
|
58910
|
+
result = inputFunction.apply(context, arguments_);
|
|
58911
|
+
}
|
|
58912
|
+
};
|
|
58913
|
+
const shouldCallNow = before && !timeout;
|
|
58914
|
+
clearTimeout(timeout);
|
|
58915
|
+
timeout = setTimeout(later, wait);
|
|
58916
|
+
if (maxWait > 0 && maxWait !== Number.POSITIVE_INFINITY && !maxTimeout) {
|
|
58917
|
+
maxTimeout = setTimeout(maxLater, maxWait);
|
|
58918
|
+
}
|
|
58919
|
+
if (shouldCallNow) {
|
|
58920
|
+
result = inputFunction.apply(context, arguments_);
|
|
58921
|
+
}
|
|
58922
|
+
return result;
|
|
58923
|
+
};
|
|
58924
|
+
mimicFunction(debouncedFunction, inputFunction);
|
|
58925
|
+
debouncedFunction.cancel = () => {
|
|
58926
|
+
if (timeout) {
|
|
58927
|
+
clearTimeout(timeout);
|
|
58928
|
+
timeout = void 0;
|
|
58929
|
+
}
|
|
58930
|
+
if (maxTimeout) {
|
|
58931
|
+
clearTimeout(maxTimeout);
|
|
58932
|
+
maxTimeout = void 0;
|
|
58933
|
+
}
|
|
58934
|
+
};
|
|
58935
|
+
return debouncedFunction;
|
|
58956
58936
|
};
|
|
58957
|
-
var
|
|
58937
|
+
var debounce_fn_default = debounceFn;
|
|
58958
58938
|
|
|
58959
|
-
//
|
|
58960
|
-
var
|
|
58961
|
-
|
|
58962
|
-
|
|
58963
|
-
|
|
58939
|
+
// node_modules/.pnpm/conf@12.0.0/node_modules/conf/dist/source/index.js
|
|
58940
|
+
var import_semver = __toESM(require_semver2(), 1);
|
|
58941
|
+
|
|
58942
|
+
// node_modules/.pnpm/uint8array-extras@0.3.0/node_modules/uint8array-extras/index.js
|
|
58943
|
+
var objectToString = Object.prototype.toString;
|
|
58944
|
+
function isUint8Array(value) {
|
|
58945
|
+
return value && objectToString.call(value) === "[object Uint8Array]";
|
|
58946
|
+
}
|
|
58947
|
+
function assertUint8Array(value) {
|
|
58948
|
+
if (!isUint8Array(value)) {
|
|
58949
|
+
throw new TypeError(`Expected \`Uint8Array\`, got \`${typeof value}\``);
|
|
58964
58950
|
}
|
|
58965
|
-
|
|
58966
|
-
|
|
58967
|
-
|
|
58968
|
-
|
|
58969
|
-
const { id: secretId } = await prompt2({
|
|
58970
|
-
name: "id",
|
|
58971
|
-
message: "Secrets:",
|
|
58972
|
-
type: "list",
|
|
58973
|
-
choices,
|
|
58974
|
-
required: true
|
|
58975
|
-
});
|
|
58976
|
-
const secret = await app.secrets.get(secretId);
|
|
58977
|
-
if (!secret) {
|
|
58978
|
-
throw new Error("Secret not found");
|
|
58951
|
+
}
|
|
58952
|
+
function concatUint8Arrays(arrays, totalLength) {
|
|
58953
|
+
if (arrays.length === 0) {
|
|
58954
|
+
return new Uint8Array(0);
|
|
58979
58955
|
}
|
|
58980
|
-
|
|
58981
|
-
|
|
58982
|
-
|
|
58956
|
+
totalLength ??= arrays.reduce((accumulator, currentValue) => accumulator + currentValue.length, 0);
|
|
58957
|
+
const returnValue = new Uint8Array(totalLength);
|
|
58958
|
+
let offset = 0;
|
|
58959
|
+
for (const array of arrays) {
|
|
58960
|
+
assertUint8Array(array);
|
|
58961
|
+
returnValue.set(array, offset);
|
|
58962
|
+
offset += array.length;
|
|
58963
|
+
}
|
|
58964
|
+
return returnValue;
|
|
58965
|
+
}
|
|
58966
|
+
function uint8ArrayToString(array) {
|
|
58967
|
+
assertUint8Array(array);
|
|
58968
|
+
return new globalThis.TextDecoder().decode(array);
|
|
58969
|
+
}
|
|
58970
|
+
function assertString(value) {
|
|
58971
|
+
if (typeof value !== "string") {
|
|
58972
|
+
throw new TypeError(`Expected \`string\`, got \`${typeof value}\``);
|
|
58973
|
+
}
|
|
58974
|
+
}
|
|
58975
|
+
function stringToUint8Array(string) {
|
|
58976
|
+
assertString(string);
|
|
58977
|
+
return new globalThis.TextEncoder().encode(string);
|
|
58978
|
+
}
|
|
58979
|
+
var byteToHexLookupTable = Array.from({ length: 256 }, (_3, index) => index.toString(16).padStart(2, "0"));
|
|
58983
58980
|
|
|
58984
|
-
// node_modules/.pnpm/
|
|
58985
|
-
var
|
|
58986
|
-
var
|
|
58987
|
-
|
|
58988
|
-
|
|
58989
|
-
|
|
58990
|
-
|
|
58991
|
-
|
|
58992
|
-
|
|
58993
|
-
|
|
58994
|
-
|
|
58995
|
-
|
|
58981
|
+
// node_modules/.pnpm/conf@12.0.0/node_modules/conf/dist/source/index.js
|
|
58982
|
+
var Ajv = import_ajv.default.default;
|
|
58983
|
+
var ajvFormats = import_ajv_formats.default.default;
|
|
58984
|
+
var encryptionAlgorithm = "aes-256-cbc";
|
|
58985
|
+
var createPlainObject = () => /* @__PURE__ */ Object.create(null);
|
|
58986
|
+
var isExist = (data) => data !== void 0 && data !== null;
|
|
58987
|
+
var checkValueType = (key, value) => {
|
|
58988
|
+
const nonJsonTypes = /* @__PURE__ */ new Set([
|
|
58989
|
+
"undefined",
|
|
58990
|
+
"symbol",
|
|
58991
|
+
"function"
|
|
58992
|
+
]);
|
|
58993
|
+
const type = typeof value;
|
|
58994
|
+
if (nonJsonTypes.has(type)) {
|
|
58995
|
+
throw new TypeError(`Setting a value of type \`${type}\` for key \`${key}\` is not allowed as it's not supported by JSON`);
|
|
58996
58996
|
}
|
|
58997
|
-
return buf;
|
|
58998
58997
|
};
|
|
58999
|
-
var
|
|
59000
|
-
var
|
|
59001
|
-
|
|
59002
|
-
|
|
59003
|
-
|
|
59004
|
-
|
|
59005
|
-
|
|
59006
|
-
|
|
59007
|
-
|
|
59008
|
-
|
|
59009
|
-
|
|
59010
|
-
|
|
59011
|
-
|
|
59012
|
-
|
|
59013
|
-
|
|
59014
|
-
|
|
58998
|
+
var INTERNAL_KEY = "__internal__";
|
|
58999
|
+
var MIGRATION_KEY = `${INTERNAL_KEY}.migrations.version`;
|
|
59000
|
+
var Conf = class {
|
|
59001
|
+
path;
|
|
59002
|
+
events;
|
|
59003
|
+
#validator;
|
|
59004
|
+
#encryptionKey;
|
|
59005
|
+
#options;
|
|
59006
|
+
#defaultValues = {};
|
|
59007
|
+
constructor(partialOptions = {}) {
|
|
59008
|
+
const options = {
|
|
59009
|
+
configName: "config",
|
|
59010
|
+
fileExtension: "json",
|
|
59011
|
+
projectSuffix: "nodejs",
|
|
59012
|
+
clearInvalidConfig: false,
|
|
59013
|
+
accessPropertiesByDotNotation: true,
|
|
59014
|
+
configFileMode: 438,
|
|
59015
|
+
...partialOptions
|
|
59016
|
+
};
|
|
59017
|
+
if (!options.cwd) {
|
|
59018
|
+
if (!options.projectName) {
|
|
59019
|
+
throw new Error("Please specify the `projectName` option.");
|
|
59020
|
+
}
|
|
59021
|
+
options.cwd = envPaths(options.projectName, { suffix: options.projectSuffix }).config;
|
|
59015
59022
|
}
|
|
59016
|
-
|
|
59017
|
-
|
|
59018
|
-
|
|
59019
|
-
|
|
59020
|
-
|
|
59021
|
-
|
|
59022
|
-
|
|
59023
|
-
|
|
59024
|
-
})
|
|
59025
|
-
|
|
59026
|
-
|
|
59027
|
-
|
|
59028
|
-
|
|
59029
|
-
|
|
59030
|
-
|
|
59031
|
-
|
|
59032
|
-
|
|
59033
|
-
|
|
59034
|
-
|
|
59035
|
-
}
|
|
59036
|
-
|
|
59037
|
-
|
|
59038
|
-
|
|
59039
|
-
|
|
59040
|
-
|
|
59041
|
-
|
|
59042
|
-
|
|
59043
|
-
if (
|
|
59044
|
-
|
|
59023
|
+
this.#options = options;
|
|
59024
|
+
if (options.schema) {
|
|
59025
|
+
if (typeof options.schema !== "object") {
|
|
59026
|
+
throw new TypeError("The `schema` option must be an object.");
|
|
59027
|
+
}
|
|
59028
|
+
const ajv = new Ajv({
|
|
59029
|
+
allErrors: true,
|
|
59030
|
+
useDefaults: true
|
|
59031
|
+
});
|
|
59032
|
+
ajvFormats(ajv);
|
|
59033
|
+
const schema = {
|
|
59034
|
+
type: "object",
|
|
59035
|
+
properties: options.schema
|
|
59036
|
+
};
|
|
59037
|
+
this.#validator = ajv.compile(schema);
|
|
59038
|
+
for (const [key, value] of Object.entries(options.schema)) {
|
|
59039
|
+
if (value?.default) {
|
|
59040
|
+
this.#defaultValues[key] = value.default;
|
|
59041
|
+
}
|
|
59042
|
+
}
|
|
59043
|
+
}
|
|
59044
|
+
if (options.defaults) {
|
|
59045
|
+
this.#defaultValues = {
|
|
59046
|
+
...this.#defaultValues,
|
|
59047
|
+
...options.defaults
|
|
59048
|
+
};
|
|
59049
|
+
}
|
|
59050
|
+
if (options.serialize) {
|
|
59051
|
+
this._serialize = options.serialize;
|
|
59052
|
+
}
|
|
59053
|
+
if (options.deserialize) {
|
|
59054
|
+
this._deserialize = options.deserialize;
|
|
59055
|
+
}
|
|
59056
|
+
this.events = new EventTarget();
|
|
59057
|
+
this.#encryptionKey = options.encryptionKey;
|
|
59058
|
+
const fileExtension = options.fileExtension ? `.${options.fileExtension}` : "";
|
|
59059
|
+
this.path = import_node_path4.default.resolve(options.cwd, `${options.configName ?? "config"}${fileExtension}`);
|
|
59060
|
+
const fileStore = this.store;
|
|
59061
|
+
const store = Object.assign(createPlainObject(), options.defaults, fileStore);
|
|
59062
|
+
this._validate(store);
|
|
59063
|
+
try {
|
|
59064
|
+
import_node_assert2.default.deepEqual(fileStore, store);
|
|
59065
|
+
} catch {
|
|
59066
|
+
this.store = store;
|
|
59045
59067
|
}
|
|
59046
|
-
|
|
59047
|
-
|
|
59048
|
-
hmac.update(message);
|
|
59049
|
-
return hmac.getHMAC("ARRAYBUFFER");
|
|
59050
|
-
}
|
|
59051
|
-
};
|
|
59052
|
-
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
59053
|
-
var base32ToBuf = (str) => {
|
|
59054
|
-
let end = str.length;
|
|
59055
|
-
while (str[end - 1] === "=")
|
|
59056
|
-
--end;
|
|
59057
|
-
const cstr = (end < str.length ? str.substring(0, end) : str).toUpperCase();
|
|
59058
|
-
const buf = new ArrayBuffer(cstr.length * 5 / 8 | 0);
|
|
59059
|
-
const arr = new Uint8Array(buf);
|
|
59060
|
-
let bits = 0;
|
|
59061
|
-
let value = 0;
|
|
59062
|
-
let index = 0;
|
|
59063
|
-
for (let i = 0; i < cstr.length; i++) {
|
|
59064
|
-
const idx = ALPHABET.indexOf(cstr[i]);
|
|
59065
|
-
if (idx === -1)
|
|
59066
|
-
throw new TypeError(`Invalid character found: ${cstr[i]}`);
|
|
59067
|
-
value = value << 5 | idx;
|
|
59068
|
-
bits += 5;
|
|
59069
|
-
if (bits >= 8) {
|
|
59070
|
-
bits -= 8;
|
|
59071
|
-
arr[index++] = value >>> bits;
|
|
59068
|
+
if (options.watch) {
|
|
59069
|
+
this._watch();
|
|
59072
59070
|
}
|
|
59073
|
-
|
|
59074
|
-
|
|
59075
|
-
|
|
59076
|
-
|
|
59077
|
-
|
|
59078
|
-
let bits = 0;
|
|
59079
|
-
let value = 0;
|
|
59080
|
-
let str = "";
|
|
59081
|
-
for (let i = 0; i < arr.length; i++) {
|
|
59082
|
-
value = value << 8 | arr[i];
|
|
59083
|
-
bits += 8;
|
|
59084
|
-
while (bits >= 5) {
|
|
59085
|
-
str += ALPHABET[value >>> bits - 5 & 31];
|
|
59086
|
-
bits -= 5;
|
|
59071
|
+
if (options.migrations) {
|
|
59072
|
+
if (!options.projectVersion) {
|
|
59073
|
+
throw new Error("Please specify the `projectVersion` option.");
|
|
59074
|
+
}
|
|
59075
|
+
this._migrate(options.migrations, options.projectVersion, options.beforeEachMigration);
|
|
59087
59076
|
}
|
|
59088
59077
|
}
|
|
59089
|
-
|
|
59090
|
-
|
|
59091
|
-
|
|
59092
|
-
|
|
59093
|
-
};
|
|
59094
|
-
|
|
59095
|
-
const buf = new ArrayBuffer(str.length / 2);
|
|
59096
|
-
const arr = new Uint8Array(buf);
|
|
59097
|
-
for (let i = 0; i < str.length; i += 2) {
|
|
59098
|
-
arr[i / 2] = parseInt(str.substring(i, i + 2), 16);
|
|
59099
|
-
}
|
|
59100
|
-
return buf;
|
|
59101
|
-
};
|
|
59102
|
-
var hexFromBuf = (buf) => {
|
|
59103
|
-
const arr = new Uint8Array(buf);
|
|
59104
|
-
let str = "";
|
|
59105
|
-
for (let i = 0; i < arr.length; i++) {
|
|
59106
|
-
const hex = arr[i].toString(16);
|
|
59107
|
-
if (hex.length === 1)
|
|
59108
|
-
str += "0";
|
|
59109
|
-
str += hex;
|
|
59110
|
-
}
|
|
59111
|
-
return str.toUpperCase();
|
|
59112
|
-
};
|
|
59113
|
-
var latin1ToBuf = (str) => {
|
|
59114
|
-
const buf = new ArrayBuffer(str.length);
|
|
59115
|
-
const arr = new Uint8Array(buf);
|
|
59116
|
-
for (let i = 0; i < str.length; i++) {
|
|
59117
|
-
arr[i] = str.charCodeAt(i) & 255;
|
|
59078
|
+
get(key, defaultValue) {
|
|
59079
|
+
if (this.#options.accessPropertiesByDotNotation) {
|
|
59080
|
+
return this._get(key, defaultValue);
|
|
59081
|
+
}
|
|
59082
|
+
const { store } = this;
|
|
59083
|
+
return key in store ? store[key] : defaultValue;
|
|
59118
59084
|
}
|
|
59119
|
-
|
|
59120
|
-
|
|
59121
|
-
|
|
59122
|
-
|
|
59123
|
-
|
|
59124
|
-
|
|
59125
|
-
|
|
59085
|
+
set(key, value) {
|
|
59086
|
+
if (typeof key !== "string" && typeof key !== "object") {
|
|
59087
|
+
throw new TypeError(`Expected \`key\` to be of type \`string\` or \`object\`, got ${typeof key}`);
|
|
59088
|
+
}
|
|
59089
|
+
if (typeof key !== "object" && value === void 0) {
|
|
59090
|
+
throw new TypeError("Use `delete()` to clear values");
|
|
59091
|
+
}
|
|
59092
|
+
if (this._containsReservedKey(key)) {
|
|
59093
|
+
throw new TypeError(`Please don't use the ${INTERNAL_KEY} key, as it's used to manage this module internal operations.`);
|
|
59094
|
+
}
|
|
59095
|
+
const { store } = this;
|
|
59096
|
+
const set2 = (key2, value2) => {
|
|
59097
|
+
checkValueType(key2, value2);
|
|
59098
|
+
if (this.#options.accessPropertiesByDotNotation) {
|
|
59099
|
+
setProperty(store, key2, value2);
|
|
59100
|
+
} else {
|
|
59101
|
+
store[key2] = value2;
|
|
59102
|
+
}
|
|
59103
|
+
};
|
|
59104
|
+
if (typeof key === "object") {
|
|
59105
|
+
const object = key;
|
|
59106
|
+
for (const [key2, value2] of Object.entries(object)) {
|
|
59107
|
+
set2(key2, value2);
|
|
59108
|
+
}
|
|
59109
|
+
} else {
|
|
59110
|
+
set2(key, value);
|
|
59111
|
+
}
|
|
59112
|
+
this.store = store;
|
|
59126
59113
|
}
|
|
59127
|
-
|
|
59128
|
-
|
|
59129
|
-
|
|
59130
|
-
|
|
59131
|
-
|
|
59132
|
-
|
|
59133
|
-
|
|
59114
|
+
/**
|
|
59115
|
+
Check if an item exists.
|
|
59116
|
+
|
|
59117
|
+
@param key - The key of the item to check.
|
|
59118
|
+
*/
|
|
59119
|
+
has(key) {
|
|
59120
|
+
if (this.#options.accessPropertiesByDotNotation) {
|
|
59121
|
+
return hasProperty(this.store, key);
|
|
59122
|
+
}
|
|
59123
|
+
return key in this.store;
|
|
59134
59124
|
}
|
|
59135
|
-
|
|
59136
|
-
|
|
59137
|
-
|
|
59138
|
-
|
|
59139
|
-
|
|
59125
|
+
/**
|
|
59126
|
+
Reset items to their default values, as defined by the `defaults` or `schema` option.
|
|
59127
|
+
|
|
59128
|
+
@see `clear()` to reset all items.
|
|
59129
|
+
|
|
59130
|
+
@param keys - The keys of the items to reset.
|
|
59131
|
+
*/
|
|
59132
|
+
reset(...keys) {
|
|
59133
|
+
for (const key of keys) {
|
|
59134
|
+
if (isExist(this.#defaultValues[key])) {
|
|
59135
|
+
this.set(key, this.#defaultValues[key]);
|
|
59136
|
+
}
|
|
59137
|
+
}
|
|
59140
59138
|
}
|
|
59141
|
-
|
|
59142
|
-
};
|
|
59143
|
-
|
|
59144
|
-
|
|
59145
|
-
|
|
59146
|
-
|
|
59147
|
-
if (!globalScope.crypto?.getRandomValues) {
|
|
59148
|
-
throw new Error("Cryptography API not available");
|
|
59139
|
+
delete(key) {
|
|
59140
|
+
const { store } = this;
|
|
59141
|
+
if (this.#options.accessPropertiesByDotNotation) {
|
|
59142
|
+
deleteProperty(store, key);
|
|
59143
|
+
} else {
|
|
59144
|
+
delete store[key];
|
|
59149
59145
|
}
|
|
59150
|
-
|
|
59146
|
+
this.store = store;
|
|
59151
59147
|
}
|
|
59152
|
-
};
|
|
59153
|
-
var Secret = class _Secret {
|
|
59154
59148
|
/**
|
|
59155
|
-
|
|
59156
|
-
|
|
59157
|
-
|
|
59158
|
-
|
|
59159
|
-
|
|
59160
|
-
|
|
59161
|
-
|
|
59162
|
-
|
|
59163
|
-
|
|
59164
|
-
this.buffer = typeof buffer === "undefined" ? randomBytes2(size) : buffer;
|
|
59149
|
+
Delete all items.
|
|
59150
|
+
|
|
59151
|
+
This resets known items to their default values, if defined by the `defaults` or `schema` option.
|
|
59152
|
+
*/
|
|
59153
|
+
clear() {
|
|
59154
|
+
this.store = createPlainObject();
|
|
59155
|
+
for (const key of Object.keys(this.#defaultValues)) {
|
|
59156
|
+
this.reset(key);
|
|
59157
|
+
}
|
|
59165
59158
|
}
|
|
59166
59159
|
/**
|
|
59167
|
-
|
|
59168
|
-
|
|
59169
|
-
|
|
59170
|
-
|
|
59171
|
-
|
|
59172
|
-
|
|
59173
|
-
|
|
59174
|
-
|
|
59160
|
+
Watches the given `key`, calling `callback` on any changes.
|
|
59161
|
+
|
|
59162
|
+
@param key - The key wo watch.
|
|
59163
|
+
@param callback - A callback function that is called on any changes. When a `key` is first set `oldValue` will be `undefined`, and when a key is deleted `newValue` will be `undefined`.
|
|
59164
|
+
@returns A function, that when called, will unsubscribe.
|
|
59165
|
+
*/
|
|
59166
|
+
onDidChange(key, callback) {
|
|
59167
|
+
if (typeof key !== "string") {
|
|
59168
|
+
throw new TypeError(`Expected \`key\` to be of type \`string\`, got ${typeof key}`);
|
|
59169
|
+
}
|
|
59170
|
+
if (typeof callback !== "function") {
|
|
59171
|
+
throw new TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof callback}`);
|
|
59172
|
+
}
|
|
59173
|
+
return this._handleChange(() => this.get(key), callback);
|
|
59175
59174
|
}
|
|
59176
59175
|
/**
|
|
59177
|
-
|
|
59178
|
-
|
|
59179
|
-
|
|
59180
|
-
|
|
59181
|
-
|
|
59182
|
-
|
|
59183
|
-
|
|
59184
|
-
|
|
59176
|
+
Watches the whole config object, calling `callback` on any changes.
|
|
59177
|
+
|
|
59178
|
+
@param callback - A callback function that is called on any changes. When a `key` is first set `oldValue` will be `undefined`, and when a key is deleted `newValue` will be `undefined`.
|
|
59179
|
+
@returns A function, that when called, will unsubscribe.
|
|
59180
|
+
*/
|
|
59181
|
+
onDidAnyChange(callback) {
|
|
59182
|
+
if (typeof callback !== "function") {
|
|
59183
|
+
throw new TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof callback}`);
|
|
59184
|
+
}
|
|
59185
|
+
return this._handleChange(() => this.store, callback);
|
|
59185
59186
|
}
|
|
59186
|
-
|
|
59187
|
-
|
|
59188
|
-
|
|
59189
|
-
|
|
59190
|
-
|
|
59191
|
-
|
|
59192
|
-
|
|
59193
|
-
|
|
59194
|
-
|
|
59187
|
+
get size() {
|
|
59188
|
+
return Object.keys(this.store).length;
|
|
59189
|
+
}
|
|
59190
|
+
get store() {
|
|
59191
|
+
try {
|
|
59192
|
+
const data = import_node_fs2.default.readFileSync(this.path, this.#encryptionKey ? null : "utf8");
|
|
59193
|
+
const dataString = this._encryptData(data);
|
|
59194
|
+
const deserializedData = this._deserialize(dataString);
|
|
59195
|
+
this._validate(deserializedData);
|
|
59196
|
+
return Object.assign(createPlainObject(), deserializedData);
|
|
59197
|
+
} catch (error) {
|
|
59198
|
+
if (error?.code === "ENOENT") {
|
|
59199
|
+
this._ensureDirectory();
|
|
59200
|
+
return createPlainObject();
|
|
59201
|
+
}
|
|
59202
|
+
if (this.#options.clearInvalidConfig && error.name === "SyntaxError") {
|
|
59203
|
+
return createPlainObject();
|
|
59204
|
+
}
|
|
59205
|
+
throw error;
|
|
59206
|
+
}
|
|
59195
59207
|
}
|
|
59196
|
-
|
|
59197
|
-
|
|
59198
|
-
|
|
59199
|
-
|
|
59200
|
-
|
|
59201
|
-
static fromHex(str) {
|
|
59202
|
-
return new _Secret({
|
|
59203
|
-
buffer: hexToBuf(str)
|
|
59204
|
-
});
|
|
59208
|
+
set store(value) {
|
|
59209
|
+
this._ensureDirectory();
|
|
59210
|
+
this._validate(value);
|
|
59211
|
+
this._write(value);
|
|
59212
|
+
this.events.dispatchEvent(new Event("change"));
|
|
59205
59213
|
}
|
|
59206
|
-
|
|
59207
|
-
|
|
59208
|
-
|
|
59209
|
-
|
|
59210
|
-
get latin1() {
|
|
59211
|
-
Object.defineProperty(this, "latin1", {
|
|
59212
|
-
enumerable: true,
|
|
59213
|
-
value: latin1FromBuf(this.buffer)
|
|
59214
|
-
});
|
|
59215
|
-
return this.latin1;
|
|
59214
|
+
*[Symbol.iterator]() {
|
|
59215
|
+
for (const [key, value] of Object.entries(this.store)) {
|
|
59216
|
+
yield [key, value];
|
|
59217
|
+
}
|
|
59216
59218
|
}
|
|
59217
|
-
|
|
59218
|
-
|
|
59219
|
-
|
|
59220
|
-
|
|
59221
|
-
|
|
59222
|
-
|
|
59223
|
-
|
|
59224
|
-
|
|
59225
|
-
|
|
59226
|
-
|
|
59219
|
+
_encryptData(data) {
|
|
59220
|
+
if (!this.#encryptionKey) {
|
|
59221
|
+
return typeof data === "string" ? data : uint8ArrayToString(data);
|
|
59222
|
+
}
|
|
59223
|
+
try {
|
|
59224
|
+
const initializationVector = data.slice(0, 16);
|
|
59225
|
+
const password = import_node_crypto2.default.pbkdf2Sync(this.#encryptionKey, initializationVector.toString(), 1e4, 32, "sha512");
|
|
59226
|
+
const decipher = import_node_crypto2.default.createDecipheriv(encryptionAlgorithm, password, initializationVector);
|
|
59227
|
+
const slice = data.slice(17);
|
|
59228
|
+
const dataUpdate = typeof slice === "string" ? stringToUint8Array(slice) : slice;
|
|
59229
|
+
return uint8ArrayToString(concatUint8Arrays([decipher.update(dataUpdate), decipher.final()]));
|
|
59230
|
+
} catch {
|
|
59231
|
+
}
|
|
59232
|
+
return data.toString();
|
|
59227
59233
|
}
|
|
59228
|
-
|
|
59229
|
-
|
|
59230
|
-
|
|
59231
|
-
|
|
59232
|
-
|
|
59233
|
-
|
|
59234
|
-
|
|
59235
|
-
|
|
59236
|
-
|
|
59237
|
-
|
|
59234
|
+
_handleChange(getter, callback) {
|
|
59235
|
+
let currentValue = getter();
|
|
59236
|
+
const onChange = () => {
|
|
59237
|
+
const oldValue = currentValue;
|
|
59238
|
+
const newValue = getter();
|
|
59239
|
+
if ((0, import_node_util2.isDeepStrictEqual)(newValue, oldValue)) {
|
|
59240
|
+
return;
|
|
59241
|
+
}
|
|
59242
|
+
currentValue = newValue;
|
|
59243
|
+
callback.call(this, newValue, oldValue);
|
|
59244
|
+
};
|
|
59245
|
+
this.events.addEventListener("change", onChange);
|
|
59246
|
+
return () => {
|
|
59247
|
+
this.events.removeEventListener("change", onChange);
|
|
59248
|
+
};
|
|
59238
59249
|
}
|
|
59239
|
-
|
|
59240
|
-
|
|
59241
|
-
|
|
59242
|
-
|
|
59243
|
-
|
|
59244
|
-
|
|
59245
|
-
|
|
59246
|
-
|
|
59247
|
-
|
|
59248
|
-
|
|
59250
|
+
_deserialize = (value) => JSON.parse(value);
|
|
59251
|
+
_serialize = (value) => JSON.stringify(value, void 0, " ");
|
|
59252
|
+
_validate(data) {
|
|
59253
|
+
if (!this.#validator) {
|
|
59254
|
+
return;
|
|
59255
|
+
}
|
|
59256
|
+
const valid = this.#validator(data);
|
|
59257
|
+
if (valid || !this.#validator.errors) {
|
|
59258
|
+
return;
|
|
59259
|
+
}
|
|
59260
|
+
const errors = this.#validator.errors.map(({ instancePath, message = "" }) => `\`${instancePath.slice(1)}\` ${message}`);
|
|
59261
|
+
throw new Error("Config schema violation: " + errors.join("; "));
|
|
59249
59262
|
}
|
|
59250
|
-
|
|
59251
|
-
|
|
59252
|
-
|
|
59253
|
-
|
|
59254
|
-
|
|
59255
|
-
if (
|
|
59256
|
-
|
|
59263
|
+
_ensureDirectory() {
|
|
59264
|
+
import_node_fs2.default.mkdirSync(import_node_path4.default.dirname(this.path), { recursive: true });
|
|
59265
|
+
}
|
|
59266
|
+
_write(value) {
|
|
59267
|
+
let data = this._serialize(value);
|
|
59268
|
+
if (this.#encryptionKey) {
|
|
59269
|
+
const initializationVector = import_node_crypto2.default.randomBytes(16);
|
|
59270
|
+
const password = import_node_crypto2.default.pbkdf2Sync(this.#encryptionKey, initializationVector.toString(), 1e4, 32, "sha512");
|
|
59271
|
+
const cipher = import_node_crypto2.default.createCipheriv(encryptionAlgorithm, password, initializationVector);
|
|
59272
|
+
data = concatUint8Arrays([initializationVector, stringToUint8Array(":"), cipher.update(stringToUint8Array(data)), cipher.final()]);
|
|
59257
59273
|
}
|
|
59258
|
-
|
|
59259
|
-
|
|
59260
|
-
|
|
59261
|
-
|
|
59274
|
+
if (import_node_process7.default.env.SNAP) {
|
|
59275
|
+
import_node_fs2.default.writeFileSync(this.path, data, { mode: this.#options.configFileMode });
|
|
59276
|
+
} else {
|
|
59277
|
+
try {
|
|
59278
|
+
writeFileSync(this.path, data, { mode: this.#options.configFileMode });
|
|
59279
|
+
} catch (error) {
|
|
59280
|
+
if (error?.code === "EXDEV") {
|
|
59281
|
+
import_node_fs2.default.writeFileSync(this.path, data, { mode: this.#options.configFileMode });
|
|
59282
|
+
return;
|
|
59283
|
+
}
|
|
59284
|
+
throw error;
|
|
59285
|
+
}
|
|
59262
59286
|
}
|
|
59263
|
-
return out === 0;
|
|
59264
59287
|
}
|
|
59265
|
-
|
|
59266
|
-
|
|
59267
|
-
|
|
59268
|
-
|
|
59269
|
-
|
|
59270
|
-
|
|
59271
|
-
|
|
59272
|
-
|
|
59273
|
-
|
|
59274
|
-
|
|
59275
|
-
|
|
59276
|
-
|
|
59277
|
-
|
|
59278
|
-
|
|
59279
|
-
static get defaults() {
|
|
59280
|
-
return {
|
|
59281
|
-
issuer: "",
|
|
59282
|
-
label: "OTPAuth",
|
|
59283
|
-
issuerInLabel: true,
|
|
59284
|
-
algorithm: "SHA1",
|
|
59285
|
-
digits: 6,
|
|
59286
|
-
counter: 0,
|
|
59287
|
-
window: 1
|
|
59288
|
-
};
|
|
59288
|
+
_watch() {
|
|
59289
|
+
this._ensureDirectory();
|
|
59290
|
+
if (!import_node_fs2.default.existsSync(this.path)) {
|
|
59291
|
+
this._write(createPlainObject());
|
|
59292
|
+
}
|
|
59293
|
+
if (import_node_process7.default.platform === "win32") {
|
|
59294
|
+
import_node_fs2.default.watch(this.path, { persistent: false }, debounce_fn_default(() => {
|
|
59295
|
+
this.events.dispatchEvent(new Event("change"));
|
|
59296
|
+
}, { wait: 100 }));
|
|
59297
|
+
} else {
|
|
59298
|
+
import_node_fs2.default.watchFile(this.path, { persistent: false }, debounce_fn_default(() => {
|
|
59299
|
+
this.events.dispatchEvent(new Event("change"));
|
|
59300
|
+
}, { wait: 5e3 }));
|
|
59301
|
+
}
|
|
59289
59302
|
}
|
|
59290
|
-
|
|
59291
|
-
|
|
59292
|
-
|
|
59293
|
-
|
|
59294
|
-
|
|
59295
|
-
|
|
59296
|
-
|
|
59297
|
-
|
|
59298
|
-
|
|
59299
|
-
|
|
59300
|
-
|
|
59301
|
-
|
|
59302
|
-
|
|
59303
|
-
|
|
59304
|
-
|
|
59305
|
-
|
|
59306
|
-
|
|
59307
|
-
|
|
59308
|
-
|
|
59309
|
-
|
|
59310
|
-
|
|
59311
|
-
|
|
59312
|
-
|
|
59313
|
-
|
|
59314
|
-
this.
|
|
59315
|
-
|
|
59316
|
-
|
|
59303
|
+
_migrate(migrations, versionToMigrate, beforeEachMigration) {
|
|
59304
|
+
let previousMigratedVersion = this._get(MIGRATION_KEY, "0.0.0");
|
|
59305
|
+
const newerVersions = Object.keys(migrations).filter((candidateVersion) => this._shouldPerformMigration(candidateVersion, previousMigratedVersion, versionToMigrate));
|
|
59306
|
+
let storeBackup = { ...this.store };
|
|
59307
|
+
for (const version of newerVersions) {
|
|
59308
|
+
try {
|
|
59309
|
+
if (beforeEachMigration) {
|
|
59310
|
+
beforeEachMigration(this, {
|
|
59311
|
+
fromVersion: previousMigratedVersion,
|
|
59312
|
+
toVersion: version,
|
|
59313
|
+
finalVersion: versionToMigrate,
|
|
59314
|
+
versions: newerVersions
|
|
59315
|
+
});
|
|
59316
|
+
}
|
|
59317
|
+
const migration = migrations[version];
|
|
59318
|
+
migration?.(this);
|
|
59319
|
+
this._set(MIGRATION_KEY, version);
|
|
59320
|
+
previousMigratedVersion = version;
|
|
59321
|
+
storeBackup = { ...this.store };
|
|
59322
|
+
} catch (error) {
|
|
59323
|
+
this.store = storeBackup;
|
|
59324
|
+
throw new Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${error}`);
|
|
59325
|
+
}
|
|
59326
|
+
}
|
|
59327
|
+
if (this._isVersionInRangeFormat(previousMigratedVersion) || !import_semver.default.eq(previousMigratedVersion, versionToMigrate)) {
|
|
59328
|
+
this._set(MIGRATION_KEY, versionToMigrate);
|
|
59329
|
+
}
|
|
59317
59330
|
}
|
|
59318
|
-
|
|
59319
|
-
|
|
59320
|
-
|
|
59321
|
-
|
|
59322
|
-
|
|
59323
|
-
|
|
59324
|
-
|
|
59325
|
-
|
|
59326
|
-
|
|
59327
|
-
|
|
59328
|
-
|
|
59329
|
-
|
|
59330
|
-
|
|
59331
|
-
|
|
59332
|
-
|
|
59333
|
-
|
|
59334
|
-
|
|
59335
|
-
const otp = ((digest[offset] & 127) << 24 | (digest[offset + 1] & 255) << 16 | (digest[offset + 2] & 255) << 8 | digest[offset + 3] & 255) % 10 ** digits2;
|
|
59336
|
-
return otp.toString().padStart(digits2, "0");
|
|
59331
|
+
_containsReservedKey(key) {
|
|
59332
|
+
if (typeof key === "object") {
|
|
59333
|
+
const firsKey = Object.keys(key)[0];
|
|
59334
|
+
if (firsKey === INTERNAL_KEY) {
|
|
59335
|
+
return true;
|
|
59336
|
+
}
|
|
59337
|
+
}
|
|
59338
|
+
if (typeof key !== "string") {
|
|
59339
|
+
return false;
|
|
59340
|
+
}
|
|
59341
|
+
if (this.#options.accessPropertiesByDotNotation) {
|
|
59342
|
+
if (key.startsWith(`${INTERNAL_KEY}.`)) {
|
|
59343
|
+
return true;
|
|
59344
|
+
}
|
|
59345
|
+
return false;
|
|
59346
|
+
}
|
|
59347
|
+
return false;
|
|
59337
59348
|
}
|
|
59338
|
-
|
|
59339
|
-
|
|
59340
|
-
* @param {Object} [config] Configuration options.
|
|
59341
|
-
* @param {number} [config.counter=this.counter++] Counter value.
|
|
59342
|
-
* @returns {string} Token.
|
|
59343
|
-
*/
|
|
59344
|
-
generate({
|
|
59345
|
-
counter = this.counter++
|
|
59346
|
-
} = {}) {
|
|
59347
|
-
return _HOTP.generate({
|
|
59348
|
-
secret: this.secret,
|
|
59349
|
-
algorithm: this.algorithm,
|
|
59350
|
-
digits: this.digits,
|
|
59351
|
-
counter
|
|
59352
|
-
});
|
|
59349
|
+
_isVersionInRangeFormat(version) {
|
|
59350
|
+
return import_semver.default.clean(version) === null;
|
|
59353
59351
|
}
|
|
59354
|
-
|
|
59355
|
-
|
|
59356
|
-
|
|
59357
|
-
|
|
59358
|
-
* @param {Secret} config.secret Secret key.
|
|
59359
|
-
* @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.
|
|
59360
|
-
* @param {number} config.digits Token length.
|
|
59361
|
-
* @param {number} [config.counter=0] Counter value.
|
|
59362
|
-
* @param {number} [config.window=1] Window of counter values to test.
|
|
59363
|
-
* @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.
|
|
59364
|
-
*/
|
|
59365
|
-
static validate({
|
|
59366
|
-
token,
|
|
59367
|
-
secret,
|
|
59368
|
-
algorithm,
|
|
59369
|
-
digits: digits2,
|
|
59370
|
-
counter = _HOTP.defaults.counter,
|
|
59371
|
-
window: window2 = _HOTP.defaults.window
|
|
59372
|
-
}) {
|
|
59373
|
-
if (token.length !== digits2)
|
|
59374
|
-
return null;
|
|
59375
|
-
let delta = null;
|
|
59376
|
-
for (let i = counter - window2; i <= counter + window2; ++i) {
|
|
59377
|
-
const generatedToken = _HOTP.generate({
|
|
59378
|
-
secret,
|
|
59379
|
-
algorithm,
|
|
59380
|
-
digits: digits2,
|
|
59381
|
-
counter: i
|
|
59382
|
-
});
|
|
59383
|
-
if (timingSafeEqual2(token, generatedToken)) {
|
|
59384
|
-
delta = i - counter;
|
|
59352
|
+
_shouldPerformMigration(candidateVersion, previousMigratedVersion, versionToMigrate) {
|
|
59353
|
+
if (this._isVersionInRangeFormat(candidateVersion)) {
|
|
59354
|
+
if (previousMigratedVersion !== "0.0.0" && import_semver.default.satisfies(previousMigratedVersion, candidateVersion)) {
|
|
59355
|
+
return false;
|
|
59385
59356
|
}
|
|
59357
|
+
return import_semver.default.satisfies(versionToMigrate, candidateVersion);
|
|
59386
59358
|
}
|
|
59387
|
-
|
|
59359
|
+
if (import_semver.default.lte(candidateVersion, previousMigratedVersion)) {
|
|
59360
|
+
return false;
|
|
59361
|
+
}
|
|
59362
|
+
if (import_semver.default.gt(candidateVersion, versionToMigrate)) {
|
|
59363
|
+
return false;
|
|
59364
|
+
}
|
|
59365
|
+
return true;
|
|
59388
59366
|
}
|
|
59389
|
-
|
|
59390
|
-
|
|
59391
|
-
* @param {Object} config Configuration options.
|
|
59392
|
-
* @param {string} config.token Token value.
|
|
59393
|
-
* @param {number} [config.counter=this.counter] Counter value.
|
|
59394
|
-
* @param {number} [config.window=1] Window of counter values to test.
|
|
59395
|
-
* @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.
|
|
59396
|
-
*/
|
|
59397
|
-
validate({
|
|
59398
|
-
token,
|
|
59399
|
-
counter = this.counter,
|
|
59400
|
-
window: window2
|
|
59401
|
-
}) {
|
|
59402
|
-
return _HOTP.validate({
|
|
59403
|
-
token,
|
|
59404
|
-
secret: this.secret,
|
|
59405
|
-
algorithm: this.algorithm,
|
|
59406
|
-
digits: this.digits,
|
|
59407
|
-
counter,
|
|
59408
|
-
window: window2
|
|
59409
|
-
});
|
|
59367
|
+
_get(key, defaultValue) {
|
|
59368
|
+
return getProperty(this.store, key, defaultValue);
|
|
59410
59369
|
}
|
|
59411
|
-
|
|
59412
|
-
|
|
59413
|
-
|
|
59414
|
-
|
|
59415
|
-
toString() {
|
|
59416
|
-
const e = encodeURIComponent;
|
|
59417
|
-
return `otpauth://hotp/${this.issuer.length > 0 ? this.issuerInLabel ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&` : `${e(this.label)}?issuer=${e(this.issuer)}&` : `${e(this.label)}?`}secret=${e(this.secret.base32)}&algorithm=${e(this.algorithm)}&digits=${e(this.digits)}&counter=${e(this.counter)}`;
|
|
59370
|
+
_set(key, value) {
|
|
59371
|
+
const { store } = this;
|
|
59372
|
+
setProperty(store, key, value);
|
|
59373
|
+
this.store = store;
|
|
59418
59374
|
}
|
|
59419
59375
|
};
|
|
59420
|
-
|
|
59421
|
-
|
|
59422
|
-
|
|
59423
|
-
|
|
59424
|
-
|
|
59425
|
-
|
|
59426
|
-
|
|
59427
|
-
|
|
59428
|
-
|
|
59429
|
-
|
|
59430
|
-
|
|
59431
|
-
|
|
59432
|
-
|
|
59433
|
-
static get defaults() {
|
|
59434
|
-
return {
|
|
59435
|
-
issuer: "",
|
|
59436
|
-
label: "OTPAuth",
|
|
59437
|
-
issuerInLabel: true,
|
|
59438
|
-
algorithm: "SHA1",
|
|
59439
|
-
digits: 6,
|
|
59440
|
-
period: 30,
|
|
59441
|
-
window: 1
|
|
59442
|
-
};
|
|
59376
|
+
|
|
59377
|
+
// packages/sdk/db.js
|
|
59378
|
+
var projectName = "autho";
|
|
59379
|
+
var DB = class {
|
|
59380
|
+
constructor({ encryptionKey, name = "default", dataFolder }) {
|
|
59381
|
+
this.encryptionKey = encryptionKey;
|
|
59382
|
+
this.client = new Conf({
|
|
59383
|
+
projectName,
|
|
59384
|
+
encryptionKey,
|
|
59385
|
+
configName: name,
|
|
59386
|
+
cwd: dataFolder,
|
|
59387
|
+
projectSuffix: ""
|
|
59388
|
+
});
|
|
59443
59389
|
}
|
|
59444
|
-
|
|
59445
|
-
|
|
59446
|
-
* @param {Object} [config] Configuration options.
|
|
59447
|
-
* @param {string} [config.issuer=''] Account provider.
|
|
59448
|
-
* @param {string} [config.label='OTPAuth'] Account label.
|
|
59449
|
-
* @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.
|
|
59450
|
-
* @param {Secret|string} [config.secret=Secret] Secret key.
|
|
59451
|
-
* @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.
|
|
59452
|
-
* @param {number} [config.digits=6] Token length.
|
|
59453
|
-
* @param {number} [config.period=30] Token time-step duration.
|
|
59454
|
-
*/
|
|
59455
|
-
constructor({
|
|
59456
|
-
issuer = _TOTP.defaults.issuer,
|
|
59457
|
-
label = _TOTP.defaults.label,
|
|
59458
|
-
issuerInLabel = _TOTP.defaults.issuerInLabel,
|
|
59459
|
-
secret = new Secret(),
|
|
59460
|
-
algorithm = _TOTP.defaults.algorithm,
|
|
59461
|
-
digits: digits2 = _TOTP.defaults.digits,
|
|
59462
|
-
period = _TOTP.defaults.period
|
|
59463
|
-
} = {}) {
|
|
59464
|
-
this.issuer = issuer;
|
|
59465
|
-
this.label = label;
|
|
59466
|
-
this.issuerInLabel = issuerInLabel;
|
|
59467
|
-
this.secret = typeof secret === "string" ? Secret.fromBase32(secret) : secret;
|
|
59468
|
-
this.algorithm = algorithm.toUpperCase();
|
|
59469
|
-
this.digits = digits2;
|
|
59470
|
-
this.period = period;
|
|
59390
|
+
get(key, defaultValue) {
|
|
59391
|
+
return this.client.get(key, defaultValue);
|
|
59471
59392
|
}
|
|
59472
|
-
|
|
59473
|
-
|
|
59474
|
-
* @param {Object} config Configuration options.
|
|
59475
|
-
* @param {Secret} config.secret Secret key.
|
|
59476
|
-
* @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.
|
|
59477
|
-
* @param {number} [config.digits=6] Token length.
|
|
59478
|
-
* @param {number} [config.period=30] Token time-step duration.
|
|
59479
|
-
* @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.
|
|
59480
|
-
* @returns {string} Token.
|
|
59481
|
-
*/
|
|
59482
|
-
static generate({
|
|
59483
|
-
secret,
|
|
59484
|
-
algorithm,
|
|
59485
|
-
digits: digits2,
|
|
59486
|
-
period = _TOTP.defaults.period,
|
|
59487
|
-
timestamp = Date.now()
|
|
59488
|
-
}) {
|
|
59489
|
-
return HOTP.generate({
|
|
59490
|
-
secret,
|
|
59491
|
-
algorithm,
|
|
59492
|
-
digits: digits2,
|
|
59493
|
-
counter: Math.floor(timestamp / 1e3 / period)
|
|
59494
|
-
});
|
|
59393
|
+
set(key, value) {
|
|
59394
|
+
this.client.set(key, value);
|
|
59495
59395
|
}
|
|
59496
|
-
|
|
59497
|
-
|
|
59498
|
-
* @param {Object} [config] Configuration options.
|
|
59499
|
-
* @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.
|
|
59500
|
-
* @returns {string} Token.
|
|
59501
|
-
*/
|
|
59502
|
-
generate({
|
|
59503
|
-
timestamp = Date.now()
|
|
59504
|
-
} = {}) {
|
|
59505
|
-
return _TOTP.generate({
|
|
59506
|
-
secret: this.secret,
|
|
59507
|
-
algorithm: this.algorithm,
|
|
59508
|
-
digits: this.digits,
|
|
59509
|
-
period: this.period,
|
|
59510
|
-
timestamp
|
|
59511
|
-
});
|
|
59396
|
+
clear() {
|
|
59397
|
+
this.client.clear();
|
|
59512
59398
|
}
|
|
59513
|
-
|
|
59514
|
-
|
|
59515
|
-
|
|
59516
|
-
|
|
59517
|
-
|
|
59518
|
-
|
|
59519
|
-
|
|
59520
|
-
|
|
59521
|
-
|
|
59522
|
-
|
|
59523
|
-
|
|
59524
|
-
|
|
59525
|
-
|
|
59526
|
-
|
|
59527
|
-
|
|
59528
|
-
|
|
59529
|
-
|
|
59530
|
-
|
|
59531
|
-
timestamp = Date.now(),
|
|
59532
|
-
window: window2
|
|
59533
|
-
}) {
|
|
59534
|
-
return HOTP.validate({
|
|
59535
|
-
token,
|
|
59536
|
-
secret,
|
|
59537
|
-
algorithm,
|
|
59538
|
-
digits: digits2,
|
|
59539
|
-
counter: Math.floor(timestamp / 1e3 / period),
|
|
59540
|
-
window: window2
|
|
59399
|
+
store() {
|
|
59400
|
+
return this.client.store;
|
|
59401
|
+
}
|
|
59402
|
+
path() {
|
|
59403
|
+
return this.client.path;
|
|
59404
|
+
}
|
|
59405
|
+
};
|
|
59406
|
+
|
|
59407
|
+
// packages/cli/app.js
|
|
59408
|
+
var App = class {
|
|
59409
|
+
constructor(options = {}) {
|
|
59410
|
+
this.encryptionKey = options.encryptionKey || config_default.masterPasswordHash;
|
|
59411
|
+
this.dataFolder = options.dataFolder || config_default.dataFolder;
|
|
59412
|
+
this.name = options.name || config_default.name;
|
|
59413
|
+
this.db = new DB({
|
|
59414
|
+
encryptionKey: this.encryptionKey,
|
|
59415
|
+
dataFolder: this.dataFolder,
|
|
59416
|
+
name: this.name
|
|
59541
59417
|
});
|
|
59418
|
+
this.secrets = new Secrets(this.db);
|
|
59419
|
+
}
|
|
59420
|
+
static async masterKey(masterPassword, masterPasswordHash) {
|
|
59421
|
+
masterPassword = masterPassword || config_default.masterPassword;
|
|
59422
|
+
masterPasswordHash = masterPasswordHash || config_default.masterPasswordHash;
|
|
59423
|
+
if (masterPasswordHash) {
|
|
59424
|
+
return masterPasswordHash;
|
|
59425
|
+
} else if (!masterPassword) {
|
|
59426
|
+
masterPassword = await ask({
|
|
59427
|
+
name: "masterPassword",
|
|
59428
|
+
message: "Password:",
|
|
59429
|
+
type: "password",
|
|
59430
|
+
required: true
|
|
59431
|
+
});
|
|
59432
|
+
}
|
|
59433
|
+
masterPasswordHash = Cipher.hash(masterPassword);
|
|
59434
|
+
return masterPasswordHash;
|
|
59542
59435
|
}
|
|
59543
|
-
|
|
59544
|
-
|
|
59545
|
-
|
|
59546
|
-
|
|
59547
|
-
|
|
59548
|
-
|
|
59549
|
-
|
|
59550
|
-
|
|
59551
|
-
|
|
59552
|
-
|
|
59553
|
-
|
|
59554
|
-
|
|
59555
|
-
|
|
59556
|
-
|
|
59557
|
-
|
|
59558
|
-
|
|
59559
|
-
|
|
59560
|
-
|
|
59561
|
-
period: this.period,
|
|
59562
|
-
timestamp,
|
|
59563
|
-
window: window2
|
|
59436
|
+
};
|
|
59437
|
+
|
|
59438
|
+
// packages/cli/wizards/getEncryptionKey.js
|
|
59439
|
+
var wizard = async (confirm = false) => {
|
|
59440
|
+
const questions = [
|
|
59441
|
+
{
|
|
59442
|
+
name: "password",
|
|
59443
|
+
message: "password:",
|
|
59444
|
+
type: "password",
|
|
59445
|
+
required: true
|
|
59446
|
+
}
|
|
59447
|
+
];
|
|
59448
|
+
if (confirm) {
|
|
59449
|
+
questions.push({
|
|
59450
|
+
name: "confirmPassword",
|
|
59451
|
+
message: "confirm password:",
|
|
59452
|
+
type: "password",
|
|
59453
|
+
required: true
|
|
59564
59454
|
});
|
|
59565
59455
|
}
|
|
59566
|
-
|
|
59567
|
-
|
|
59568
|
-
|
|
59569
|
-
*/
|
|
59570
|
-
toString() {
|
|
59571
|
-
const e = encodeURIComponent;
|
|
59572
|
-
return `otpauth://totp/${this.issuer.length > 0 ? this.issuerInLabel ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&` : `${e(this.label)}?issuer=${e(this.issuer)}&` : `${e(this.label)}?`}secret=${e(this.secret.base32)}&algorithm=${e(this.algorithm)}&digits=${e(this.digits)}&period=${e(this.period)}`;
|
|
59456
|
+
const input = await prompt2(questions);
|
|
59457
|
+
if (input.confirmPassword && input.password !== input.confirmPassword) {
|
|
59458
|
+
throw new Error("Passwords do not match");
|
|
59573
59459
|
}
|
|
59460
|
+
return Cipher.hash(input.password);
|
|
59574
59461
|
};
|
|
59462
|
+
var getEncryptionKey_default = wizard;
|
|
59575
59463
|
|
|
59576
|
-
// packages/
|
|
59577
|
-
var
|
|
59578
|
-
|
|
59579
|
-
|
|
59580
|
-
|
|
59581
|
-
|
|
59582
|
-
|
|
59583
|
-
|
|
59584
|
-
|
|
59585
|
-
|
|
59586
|
-
|
|
59587
|
-
|
|
59464
|
+
// packages/cli/wizards/createSecret.js
|
|
59465
|
+
var wizard2 = async (app) => {
|
|
59466
|
+
const secrets = app.secrets;
|
|
59467
|
+
const info = await prompt2([
|
|
59468
|
+
{
|
|
59469
|
+
name: "name",
|
|
59470
|
+
message: "name:",
|
|
59471
|
+
type: "input",
|
|
59472
|
+
required: true
|
|
59473
|
+
},
|
|
59474
|
+
{
|
|
59475
|
+
name: "type",
|
|
59476
|
+
message: "type:",
|
|
59477
|
+
type: "list",
|
|
59478
|
+
default: "password",
|
|
59479
|
+
choices: [
|
|
59480
|
+
{ name: "Password", value: "password" },
|
|
59481
|
+
{ name: "OTP", value: "otp" },
|
|
59482
|
+
{ name: "Note", value: "note" }
|
|
59483
|
+
],
|
|
59484
|
+
required: true
|
|
59485
|
+
},
|
|
59486
|
+
{
|
|
59487
|
+
name: "protected",
|
|
59488
|
+
message: "protected:",
|
|
59489
|
+
type: "confirm",
|
|
59490
|
+
default: false,
|
|
59491
|
+
required: true
|
|
59492
|
+
}
|
|
59493
|
+
]);
|
|
59494
|
+
let newSecret = { typeOptions: {} };
|
|
59495
|
+
let encryptionKey = app.db.encryptionKey;
|
|
59496
|
+
if (info.protected) {
|
|
59497
|
+
encryptionKey = await getEncryptionKey_default(true);
|
|
59588
59498
|
}
|
|
59589
|
-
|
|
59590
|
-
|
|
59499
|
+
switch (info.type) {
|
|
59500
|
+
case "password":
|
|
59501
|
+
{
|
|
59502
|
+
const password = await prompt2([
|
|
59503
|
+
{
|
|
59504
|
+
name: "url",
|
|
59505
|
+
message: "url:",
|
|
59506
|
+
type: "input",
|
|
59507
|
+
required: false
|
|
59508
|
+
},
|
|
59509
|
+
{
|
|
59510
|
+
name: "username",
|
|
59511
|
+
message: "username:",
|
|
59512
|
+
type: "input",
|
|
59513
|
+
required: true
|
|
59514
|
+
},
|
|
59515
|
+
{
|
|
59516
|
+
name: "value",
|
|
59517
|
+
message: "password:",
|
|
59518
|
+
type: "password",
|
|
59519
|
+
required: true
|
|
59520
|
+
}
|
|
59521
|
+
]);
|
|
59522
|
+
newSecret = {
|
|
59523
|
+
...info,
|
|
59524
|
+
value: password.value,
|
|
59525
|
+
typeOptions: {
|
|
59526
|
+
username: password.username,
|
|
59527
|
+
url: password.url
|
|
59528
|
+
}
|
|
59529
|
+
};
|
|
59530
|
+
}
|
|
59531
|
+
break;
|
|
59532
|
+
case "note":
|
|
59533
|
+
{
|
|
59534
|
+
const note = await prompt2([
|
|
59535
|
+
{
|
|
59536
|
+
name: "value",
|
|
59537
|
+
message: "note:",
|
|
59538
|
+
type: "password",
|
|
59539
|
+
required: true
|
|
59540
|
+
}
|
|
59541
|
+
]);
|
|
59542
|
+
newSecret = {
|
|
59543
|
+
...info,
|
|
59544
|
+
value: note.value,
|
|
59545
|
+
typeOptions: {}
|
|
59546
|
+
};
|
|
59547
|
+
}
|
|
59548
|
+
break;
|
|
59549
|
+
case "otp":
|
|
59550
|
+
{
|
|
59551
|
+
const otp = await prompt2([
|
|
59552
|
+
{
|
|
59553
|
+
name: "username",
|
|
59554
|
+
message: "username:",
|
|
59555
|
+
type: "input",
|
|
59556
|
+
required: true
|
|
59557
|
+
},
|
|
59558
|
+
{
|
|
59559
|
+
name: "value",
|
|
59560
|
+
message: "value:",
|
|
59561
|
+
type: "password",
|
|
59562
|
+
required: true
|
|
59563
|
+
}
|
|
59564
|
+
]);
|
|
59565
|
+
const test = await prompt2([
|
|
59566
|
+
{
|
|
59567
|
+
name: "validate",
|
|
59568
|
+
message: "validate:",
|
|
59569
|
+
type: "confirm",
|
|
59570
|
+
default: false,
|
|
59571
|
+
required: true
|
|
59572
|
+
}
|
|
59573
|
+
]);
|
|
59574
|
+
if (test.validate) {
|
|
59575
|
+
generateOTP({
|
|
59576
|
+
name: info.name,
|
|
59577
|
+
value: otp.value
|
|
59578
|
+
});
|
|
59579
|
+
while (1) {
|
|
59580
|
+
const valid = await prompt2([
|
|
59581
|
+
{
|
|
59582
|
+
name: "try",
|
|
59583
|
+
message: "try again?",
|
|
59584
|
+
type: "confirm",
|
|
59585
|
+
default: false,
|
|
59586
|
+
required: true
|
|
59587
|
+
}
|
|
59588
|
+
]);
|
|
59589
|
+
if (!valid.try) {
|
|
59590
|
+
break;
|
|
59591
|
+
} else {
|
|
59592
|
+
generateOTP({
|
|
59593
|
+
name: info.name,
|
|
59594
|
+
value: otp.value
|
|
59595
|
+
});
|
|
59596
|
+
}
|
|
59597
|
+
}
|
|
59598
|
+
}
|
|
59599
|
+
newSecret = {
|
|
59600
|
+
...info,
|
|
59601
|
+
value: otp.value,
|
|
59602
|
+
typeOptions: {
|
|
59603
|
+
username: otp.username
|
|
59604
|
+
}
|
|
59605
|
+
};
|
|
59606
|
+
}
|
|
59607
|
+
break;
|
|
59591
59608
|
}
|
|
59592
|
-
|
|
59593
|
-
|
|
59609
|
+
const created = await secrets.add(newSecret, encryptionKey);
|
|
59610
|
+
console.log("Secret created:", created.id);
|
|
59611
|
+
};
|
|
59612
|
+
var createSecret_default = wizard2;
|
|
59613
|
+
|
|
59614
|
+
// packages/cli/wizards/getSecret.js
|
|
59615
|
+
var wizard3 = async (app) => {
|
|
59616
|
+
const existingSecrets = app.db.get("secrets", []);
|
|
59617
|
+
if (existingSecrets.length === 0) {
|
|
59618
|
+
throw new Error("No secrets found");
|
|
59619
|
+
}
|
|
59620
|
+
const choices = existingSecrets.map((secret2) => ({
|
|
59621
|
+
value: secret2.id,
|
|
59622
|
+
name: `${secret2.name} ${secret2.typeOptions.username ? `(${secret2.typeOptions.username}) ` : ""}(${secret2.id})`
|
|
59623
|
+
}));
|
|
59624
|
+
const { id: secretId } = await prompt2({
|
|
59625
|
+
name: "id",
|
|
59626
|
+
message: "Secrets:",
|
|
59627
|
+
type: "list",
|
|
59628
|
+
choices,
|
|
59629
|
+
required: true
|
|
59630
|
+
});
|
|
59631
|
+
const secret = await app.secrets.get(secretId);
|
|
59632
|
+
if (!secret) {
|
|
59633
|
+
throw new Error("Secret not found");
|
|
59594
59634
|
}
|
|
59635
|
+
return secret;
|
|
59595
59636
|
};
|
|
59637
|
+
var getSecret_default = wizard3;
|
|
59596
59638
|
|
|
59597
59639
|
// packages/shared/logger.js
|
|
59598
59640
|
var import_baloga = __toESM(require_baloga(), 1);
|
|
@@ -59620,18 +59662,41 @@ var basename = (filePath) => {
|
|
|
59620
59662
|
const folderName = import_path2.default.basename(normalizedPath);
|
|
59621
59663
|
return folderName;
|
|
59622
59664
|
};
|
|
59623
|
-
|
|
59624
|
-
"
|
|
59665
|
+
function printLine(text) {
|
|
59666
|
+
process.stdout.write("\x1B[2K\x1B[1G");
|
|
59667
|
+
process.stdout.write(text);
|
|
59668
|
+
}
|
|
59669
|
+
var countDown = async (textStart, textEnd, seconds) => {
|
|
59670
|
+
return new Promise((resolve) => {
|
|
59671
|
+
const interval = setInterval(() => {
|
|
59672
|
+
printLine(textStart + seconds + "s");
|
|
59673
|
+
seconds--;
|
|
59674
|
+
if (seconds < 0) {
|
|
59675
|
+
printLine(textEnd);
|
|
59676
|
+
process.stdout.write("\n");
|
|
59677
|
+
clearInterval(interval);
|
|
59678
|
+
resolve();
|
|
59679
|
+
}
|
|
59680
|
+
}, 1e3);
|
|
59681
|
+
});
|
|
59682
|
+
};
|
|
59683
|
+
var initApp = async (args, opts) => {
|
|
59684
|
+
const { password, passwordHash } = { ...opts, ...args };
|
|
59685
|
+
args.encryptionKey = await App.masterKey(
|
|
59686
|
+
password,
|
|
59687
|
+
passwordHash
|
|
59688
|
+
);
|
|
59689
|
+
const app = new App(args);
|
|
59690
|
+
return app;
|
|
59691
|
+
};
|
|
59692
|
+
program2.name("autho").description("Secrets manager").version("0.0.11").option("-p, --password <password>", "Master password").option("-ph, --passwordHash <passwordHash>", "Master password hash").option("-n, --name <name>", "Collection name").option(
|
|
59693
|
+
"--dataFolder <folderPath>",
|
|
59625
59694
|
"Folder path to store secrets db",
|
|
59626
59695
|
getAuthoAbsolutePath
|
|
59627
59696
|
).action(async (args) => {
|
|
59628
59697
|
try {
|
|
59629
|
-
logger2.debug("
|
|
59630
|
-
|
|
59631
|
-
args.password,
|
|
59632
|
-
args.passwordHash
|
|
59633
|
-
);
|
|
59634
|
-
const app = new App(args);
|
|
59698
|
+
logger2.debug("input:", args);
|
|
59699
|
+
const app = await initApp(args, program2.opts());
|
|
59635
59700
|
logger2.debug(`Reading data from:`, app.db.path());
|
|
59636
59701
|
let choices = [
|
|
59637
59702
|
{ value: "create", name: "Create new secret" },
|
|
@@ -59666,12 +59731,12 @@ program2.name("autho").description("Secrets manager").version("0.0.1").option("-
|
|
|
59666
59731
|
break;
|
|
59667
59732
|
case "otp":
|
|
59668
59733
|
{
|
|
59669
|
-
|
|
59670
|
-
|
|
59671
|
-
|
|
59672
|
-
|
|
59673
|
-
|
|
59674
|
-
|
|
59734
|
+
generateOTP(readSecret);
|
|
59735
|
+
await countDown(
|
|
59736
|
+
"Expired in: ",
|
|
59737
|
+
"The code is not longer valid, please generate new code.",
|
|
59738
|
+
30
|
|
59739
|
+
);
|
|
59675
59740
|
}
|
|
59676
59741
|
break;
|
|
59677
59742
|
}
|
|
@@ -59682,7 +59747,6 @@ program2.name("autho").description("Secrets manager").version("0.0.1").option("-
|
|
|
59682
59747
|
const deleteSecret = await getSecret_default(app);
|
|
59683
59748
|
await app.secrets.remove(deleteSecret.id);
|
|
59684
59749
|
console.log("Removed");
|
|
59685
|
-
process.exit(0);
|
|
59686
59750
|
}
|
|
59687
59751
|
break;
|
|
59688
59752
|
default:
|
|
@@ -59694,9 +59758,50 @@ program2.name("autho").description("Secrets manager").version("0.0.1").option("-
|
|
|
59694
59758
|
console.log(error.stack);
|
|
59695
59759
|
process.exit(1);
|
|
59696
59760
|
}
|
|
59761
|
+
process.exit(0);
|
|
59762
|
+
});
|
|
59763
|
+
program2.command("secret").description("Secret operations").option("--action <action>", "Secret action (create/list/read/delete)", "create").option("--id <id>", "Secret id").option("--decrypt", "Decrypt secret", false).action(async (args) => {
|
|
59764
|
+
try {
|
|
59765
|
+
logger2.debug(`input:`, args);
|
|
59766
|
+
const { id, decrypt, action } = args;
|
|
59767
|
+
const app = await initApp(args, program2.opts());
|
|
59768
|
+
logger2.debug(`Reading data from:`, app.db.path());
|
|
59769
|
+
switch (action) {
|
|
59770
|
+
case "read": {
|
|
59771
|
+
const selected = await app.secrets.get(id);
|
|
59772
|
+
if (!selected) {
|
|
59773
|
+
throw new Error("No secret found");
|
|
59774
|
+
}
|
|
59775
|
+
if (decrypt) {
|
|
59776
|
+
selected.value = Cipher.decrypt({
|
|
59777
|
+
...selected,
|
|
59778
|
+
encryptionKey: app.encryptionKey
|
|
59779
|
+
});
|
|
59780
|
+
}
|
|
59781
|
+
console.log(selected);
|
|
59782
|
+
break;
|
|
59783
|
+
}
|
|
59784
|
+
case "delete":
|
|
59785
|
+
await app.secrets.remove(id);
|
|
59786
|
+
break;
|
|
59787
|
+
case "create":
|
|
59788
|
+
await createSecret_default(app);
|
|
59789
|
+
break;
|
|
59790
|
+
case "list":
|
|
59791
|
+
console.dir(app.secrets.secrets);
|
|
59792
|
+
break;
|
|
59793
|
+
default:
|
|
59794
|
+
throw new Error("Unknown action:", action);
|
|
59795
|
+
}
|
|
59796
|
+
} catch (error) {
|
|
59797
|
+
logger2.error("Something went wrong, Error: ", error.message);
|
|
59798
|
+
console.log(error.stack);
|
|
59799
|
+
process.exit(1);
|
|
59800
|
+
}
|
|
59801
|
+
process.exit(0);
|
|
59697
59802
|
});
|
|
59698
59803
|
program2.command("file").description("Encrypt/Decrypt file").option("-f, --filePath <filePath>", "File path").option("-en, --encrypt", "Encrypt file", false).option("-de, --decrypt", "Decrypt file", false).option("--override", "Override original file", false).action(async (args) => {
|
|
59699
|
-
logger2.debug(`
|
|
59804
|
+
logger2.debug(`input:`, args);
|
|
59700
59805
|
const { encrypt, decrypt, override } = args;
|
|
59701
59806
|
let { filePath } = args;
|
|
59702
59807
|
filePath = toAbsolutePath(filePath);
|
|
@@ -59721,7 +59826,7 @@ program2.command("file").description("Encrypt/Decrypt file").option("-f, --fileP
|
|
|
59721
59826
|
});
|
|
59722
59827
|
program2.command("files").description("Encrypt/Decrypt file").option("--input <inputPath>", "Folder path").option("--output <outputPath>", "Folder path", process.cwd()).option("-en, --encrypt", "Encrypt folder", false).option("-de, --decrypt", "Decrypt folder", false).action(async (args) => {
|
|
59723
59828
|
try {
|
|
59724
|
-
logger2.debug(`
|
|
59829
|
+
logger2.debug(`input:`, args);
|
|
59725
59830
|
const { encrypt, decrypt } = args;
|
|
59726
59831
|
let { input, output } = args;
|
|
59727
59832
|
input = toAbsolutePath(input);
|
|
@@ -59755,7 +59860,7 @@ program2.command("files").description("Encrypt/Decrypt file").option("--input <i
|
|
|
59755
59860
|
}
|
|
59756
59861
|
process.exit(0);
|
|
59757
59862
|
});
|
|
59758
|
-
program2.parse();
|
|
59863
|
+
program2.parse(process.argv);
|
|
59759
59864
|
/*! Bundled license information:
|
|
59760
59865
|
|
|
59761
59866
|
safe-buffer/index.js:
|