publish-browser-extension
Version:
Easily publish web extensions to their stores
3,828 lines • 132 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined")
return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __commonJS = (cb, mod) => function __require2() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
// node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js
var require_safe_buffer = __commonJS({
"node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js"(exports, module) {
"use strict";
var buffer = __require("buffer");
var Buffer2 = buffer.Buffer;
function copyProps(src, dst) {
for (var key in src) {
dst[key] = src[key];
}
}
if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
module.exports = buffer;
} else {
copyProps(buffer, exports);
exports.Buffer = SafeBuffer;
}
function SafeBuffer(arg, encodingOrOffset, length) {
return Buffer2(arg, encodingOrOffset, length);
}
SafeBuffer.prototype = Object.create(Buffer2.prototype);
copyProps(Buffer2, SafeBuffer);
SafeBuffer.from = function(arg, encodingOrOffset, length) {
if (typeof arg === "number") {
throw new TypeError("Argument must not be a number");
}
return Buffer2(arg, encodingOrOffset, length);
};
SafeBuffer.alloc = function(size, fill, encoding) {
if (typeof size !== "number") {
throw new TypeError("Argument must be a number");
}
var buf = Buffer2(size);
if (fill !== void 0) {
if (typeof encoding === "string") {
buf.fill(fill, encoding);
} else {
buf.fill(fill);
}
} else {
buf.fill(0);
}
return buf;
};
SafeBuffer.allocUnsafe = function(size) {
if (typeof size !== "number") {
throw new TypeError("Argument must be a number");
}
return Buffer2(size);
};
SafeBuffer.allocUnsafeSlow = function(size) {
if (typeof size !== "number") {
throw new TypeError("Argument must be a number");
}
return buffer.SlowBuffer(size);
};
}
});
// node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/data-stream.js
var require_data_stream = __commonJS({
"node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/data-stream.js"(exports, module) {
"use strict";
var Buffer2 = require_safe_buffer().Buffer;
var Stream = __require("stream");
var util = __require("util");
function DataStream(data) {
this.buffer = null;
this.writable = true;
this.readable = true;
if (!data) {
this.buffer = Buffer2.alloc(0);
return this;
}
if (typeof data.pipe === "function") {
this.buffer = Buffer2.alloc(0);
data.pipe(this);
return this;
}
if (data.length || typeof data === "object") {
this.buffer = data;
this.writable = false;
process.nextTick(function() {
this.emit("end", data);
this.readable = false;
this.emit("close");
}.bind(this));
return this;
}
throw new TypeError("Unexpected data type (" + typeof data + ")");
}
util.inherits(DataStream, Stream);
DataStream.prototype.write = function write(data) {
this.buffer = Buffer2.concat([this.buffer, Buffer2.from(data)]);
this.emit("data", data);
};
DataStream.prototype.end = function end(data) {
if (data)
this.write(data);
this.emit("end", data);
this.emit("close");
this.writable = false;
this.readable = false;
};
module.exports = DataStream;
}
});
// node_modules/.pnpm/buffer-equal-constant-time@1.0.1/node_modules/buffer-equal-constant-time/index.js
var require_buffer_equal_constant_time = __commonJS({
"node_modules/.pnpm/buffer-equal-constant-time@1.0.1/node_modules/buffer-equal-constant-time/index.js"(exports, module) {
"use strict";
var Buffer2 = __require("buffer").Buffer;
var SlowBuffer = __require("buffer").SlowBuffer;
module.exports = bufferEq;
function bufferEq(a, b) {
if (!Buffer2.isBuffer(a) || !Buffer2.isBuffer(b)) {
return false;
}
if (a.length !== b.length) {
return false;
}
var c = 0;
for (var i = 0; i < a.length; i++) {
c |= a[i] ^ b[i];
}
return c === 0;
}
bufferEq.install = function() {
Buffer2.prototype.equal = SlowBuffer.prototype.equal = function equal(that) {
return bufferEq(this, that);
};
};
var origBufEqual = Buffer2.prototype.equal;
var origSlowBufEqual = SlowBuffer.prototype.equal;
bufferEq.restore = function() {
Buffer2.prototype.equal = origBufEqual;
SlowBuffer.prototype.equal = origSlowBufEqual;
};
}
});
// node_modules/.pnpm/ecdsa-sig-formatter@1.0.11/node_modules/ecdsa-sig-formatter/src/param-bytes-for-alg.js
var require_param_bytes_for_alg = __commonJS({
"node_modules/.pnpm/ecdsa-sig-formatter@1.0.11/node_modules/ecdsa-sig-formatter/src/param-bytes-for-alg.js"(exports, module) {
"use strict";
function getParamSize(keySize) {
var result = (keySize / 8 | 0) + (keySize % 8 === 0 ? 0 : 1);
return result;
}
var paramBytesForAlg = {
ES256: getParamSize(256),
ES384: getParamSize(384),
ES512: getParamSize(521)
};
function getParamBytesForAlg(alg) {
var paramBytes = paramBytesForAlg[alg];
if (paramBytes) {
return paramBytes;
}
throw new Error('Unknown algorithm "' + alg + '"');
}
module.exports = getParamBytesForAlg;
}
});
// node_modules/.pnpm/ecdsa-sig-formatter@1.0.11/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js
var require_ecdsa_sig_formatter = __commonJS({
"node_modules/.pnpm/ecdsa-sig-formatter@1.0.11/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js"(exports, module) {
"use strict";
var Buffer2 = require_safe_buffer().Buffer;
var getParamBytesForAlg = require_param_bytes_for_alg();
var MAX_OCTET = 128;
var CLASS_UNIVERSAL = 0;
var PRIMITIVE_BIT = 32;
var TAG_SEQ = 16;
var TAG_INT = 2;
var ENCODED_TAG_SEQ = TAG_SEQ | PRIMITIVE_BIT | CLASS_UNIVERSAL << 6;
var ENCODED_TAG_INT = TAG_INT | CLASS_UNIVERSAL << 6;
function base64Url(base64) {
return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
}
function signatureAsBuffer(signature) {
if (Buffer2.isBuffer(signature)) {
return signature;
} else if ("string" === typeof signature) {
return Buffer2.from(signature, "base64");
}
throw new TypeError("ECDSA signature must be a Base64 string or a Buffer");
}
function derToJose(signature, alg) {
signature = signatureAsBuffer(signature);
var paramBytes = getParamBytesForAlg(alg);
var maxEncodedParamLength = paramBytes + 1;
var inputLength = signature.length;
var offset = 0;
if (signature[offset++] !== ENCODED_TAG_SEQ) {
throw new Error('Could not find expected "seq"');
}
var seqLength = signature[offset++];
if (seqLength === (MAX_OCTET | 1)) {
seqLength = signature[offset++];
}
if (inputLength - offset < seqLength) {
throw new Error('"seq" specified length of "' + seqLength + '", only "' + (inputLength - offset) + '" remaining');
}
if (signature[offset++] !== ENCODED_TAG_INT) {
throw new Error('Could not find expected "int" for "r"');
}
var rLength = signature[offset++];
if (inputLength - offset - 2 < rLength) {
throw new Error('"r" specified length of "' + rLength + '", only "' + (inputLength - offset - 2) + '" available');
}
if (maxEncodedParamLength < rLength) {
throw new Error('"r" specified length of "' + rLength + '", max of "' + maxEncodedParamLength + '" is acceptable');
}
var rOffset = offset;
offset += rLength;
if (signature[offset++] !== ENCODED_TAG_INT) {
throw new Error('Could not find expected "int" for "s"');
}
var sLength = signature[offset++];
if (inputLength - offset !== sLength) {
throw new Error('"s" specified length of "' + sLength + '", expected "' + (inputLength - offset) + '"');
}
if (maxEncodedParamLength < sLength) {
throw new Error('"s" specified length of "' + sLength + '", max of "' + maxEncodedParamLength + '" is acceptable');
}
var sOffset = offset;
offset += sLength;
if (offset !== inputLength) {
throw new Error('Expected to consume entire buffer, but "' + (inputLength - offset) + '" bytes remain');
}
var rPadding = paramBytes - rLength, sPadding = paramBytes - sLength;
var dst = Buffer2.allocUnsafe(rPadding + rLength + sPadding + sLength);
for (offset = 0; offset < rPadding; ++offset) {
dst[offset] = 0;
}
signature.copy(dst, offset, rOffset + Math.max(-rPadding, 0), rOffset + rLength);
offset = paramBytes;
for (var o = offset; offset < o + sPadding; ++offset) {
dst[offset] = 0;
}
signature.copy(dst, offset, sOffset + Math.max(-sPadding, 0), sOffset + sLength);
dst = dst.toString("base64");
dst = base64Url(dst);
return dst;
}
function countPadding(buf, start, stop) {
var padding = 0;
while (start + padding < stop && buf[start + padding] === 0) {
++padding;
}
var needsSign = buf[start + padding] >= MAX_OCTET;
if (needsSign) {
--padding;
}
return padding;
}
function joseToDer(signature, alg) {
signature = signatureAsBuffer(signature);
var paramBytes = getParamBytesForAlg(alg);
var signatureBytes = signature.length;
if (signatureBytes !== paramBytes * 2) {
throw new TypeError('"' + alg + '" signatures must be "' + paramBytes * 2 + '" bytes, saw "' + signatureBytes + '"');
}
var rPadding = countPadding(signature, 0, paramBytes);
var sPadding = countPadding(signature, paramBytes, signature.length);
var rLength = paramBytes - rPadding;
var sLength = paramBytes - sPadding;
var rsBytes = 1 + 1 + rLength + 1 + 1 + sLength;
var shortLength = rsBytes < MAX_OCTET;
var dst = Buffer2.allocUnsafe((shortLength ? 2 : 3) + rsBytes);
var offset = 0;
dst[offset++] = ENCODED_TAG_SEQ;
if (shortLength) {
dst[offset++] = rsBytes;
} else {
dst[offset++] = MAX_OCTET | 1;
dst[offset++] = rsBytes & 255;
}
dst[offset++] = ENCODED_TAG_INT;
dst[offset++] = rLength;
if (rPadding < 0) {
dst[offset++] = 0;
offset += signature.copy(dst, offset, 0, paramBytes);
} else {
offset += signature.copy(dst, offset, rPadding, paramBytes);
}
dst[offset++] = ENCODED_TAG_INT;
dst[offset++] = sLength;
if (sPadding < 0) {
dst[offset++] = 0;
signature.copy(dst, offset, paramBytes);
} else {
signature.copy(dst, offset, paramBytes + sPadding);
}
return dst;
}
module.exports = {
derToJose,
joseToDer
};
}
});
// node_modules/.pnpm/jwa@1.4.1/node_modules/jwa/index.js
var require_jwa = __commonJS({
"node_modules/.pnpm/jwa@1.4.1/node_modules/jwa/index.js"(exports, module) {
"use strict";
var bufferEqual = require_buffer_equal_constant_time();
var Buffer2 = require_safe_buffer().Buffer;
var crypto = __require("crypto");
var formatEcdsa = require_ecdsa_sig_formatter();
var util = __require("util");
var MSG_INVALID_ALGORITHM = '"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".';
var MSG_INVALID_SECRET = "secret must be a string or buffer";
var MSG_INVALID_VERIFIER_KEY = "key must be a string or a buffer";
var MSG_INVALID_SIGNER_KEY = "key must be a string, a buffer or an object";
var supportsKeyObjects = typeof crypto.createPublicKey === "function";
if (supportsKeyObjects) {
MSG_INVALID_VERIFIER_KEY += " or a KeyObject";
MSG_INVALID_SECRET += "or a KeyObject";
}
function checkIsPublicKey(key) {
if (Buffer2.isBuffer(key)) {
return;
}
if (typeof key === "string") {
return;
}
if (!supportsKeyObjects) {
throw typeError(MSG_INVALID_VERIFIER_KEY);
}
if (typeof key !== "object") {
throw typeError(MSG_INVALID_VERIFIER_KEY);
}
if (typeof key.type !== "string") {
throw typeError(MSG_INVALID_VERIFIER_KEY);
}
if (typeof key.asymmetricKeyType !== "string") {
throw typeError(MSG_INVALID_VERIFIER_KEY);
}
if (typeof key.export !== "function") {
throw typeError(MSG_INVALID_VERIFIER_KEY);
}
}
function checkIsPrivateKey(key) {
if (Buffer2.isBuffer(key)) {
return;
}
if (typeof key === "string") {
return;
}
if (typeof key === "object") {
return;
}
throw typeError(MSG_INVALID_SIGNER_KEY);
}
function checkIsSecretKey(key) {
if (Buffer2.isBuffer(key)) {
return;
}
if (typeof key === "string") {
return key;
}
if (!supportsKeyObjects) {
throw typeError(MSG_INVALID_SECRET);
}
if (typeof key !== "object") {
throw typeError(MSG_INVALID_SECRET);
}
if (key.type !== "secret") {
throw typeError(MSG_INVALID_SECRET);
}
if (typeof key.export !== "function") {
throw typeError(MSG_INVALID_SECRET);
}
}
function fromBase64(base64) {
return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
}
function toBase64(base64url) {
base64url = base64url.toString();
var padding = 4 - base64url.length % 4;
if (padding !== 4) {
for (var i = 0; i < padding; ++i) {
base64url += "=";
}
}
return base64url.replace(/\-/g, "+").replace(/_/g, "/");
}
function typeError(template) {
var args = [].slice.call(arguments, 1);
var errMsg = util.format.bind(util, template).apply(null, args);
return new TypeError(errMsg);
}
function bufferOrString(obj) {
return Buffer2.isBuffer(obj) || typeof obj === "string";
}
function normalizeInput(thing) {
if (!bufferOrString(thing))
thing = JSON.stringify(thing);
return thing;
}
function createHmacSigner(bits) {
return function sign(thing, secret) {
checkIsSecretKey(secret);
thing = normalizeInput(thing);
var hmac = crypto.createHmac("sha" + bits, secret);
var sig = (hmac.update(thing), hmac.digest("base64"));
return fromBase64(sig);
};
}
function createHmacVerifier(bits) {
return function verify(thing, signature, secret) {
var computedSig = createHmacSigner(bits)(thing, secret);
return bufferEqual(Buffer2.from(signature), Buffer2.from(computedSig));
};
}
function createKeySigner(bits) {
return function sign(thing, privateKey) {
checkIsPrivateKey(privateKey);
thing = normalizeInput(thing);
var signer = crypto.createSign("RSA-SHA" + bits);
var sig = (signer.update(thing), signer.sign(privateKey, "base64"));
return fromBase64(sig);
};
}
function createKeyVerifier(bits) {
return function verify(thing, signature, publicKey) {
checkIsPublicKey(publicKey);
thing = normalizeInput(thing);
signature = toBase64(signature);
var verifier = crypto.createVerify("RSA-SHA" + bits);
verifier.update(thing);
return verifier.verify(publicKey, signature, "base64");
};
}
function createPSSKeySigner(bits) {
return function sign(thing, privateKey) {
checkIsPrivateKey(privateKey);
thing = normalizeInput(thing);
var signer = crypto.createSign("RSA-SHA" + bits);
var sig = (signer.update(thing), signer.sign({
key: privateKey,
padding: crypto.constants.RSA_PKCS1_PSS_PADDING,
saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST
}, "base64"));
return fromBase64(sig);
};
}
function createPSSKeyVerifier(bits) {
return function verify(thing, signature, publicKey) {
checkIsPublicKey(publicKey);
thing = normalizeInput(thing);
signature = toBase64(signature);
var verifier = crypto.createVerify("RSA-SHA" + bits);
verifier.update(thing);
return verifier.verify({
key: publicKey,
padding: crypto.constants.RSA_PKCS1_PSS_PADDING,
saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST
}, signature, "base64");
};
}
function createECDSASigner(bits) {
var inner = createKeySigner(bits);
return function sign() {
var signature = inner.apply(null, arguments);
signature = formatEcdsa.derToJose(signature, "ES" + bits);
return signature;
};
}
function createECDSAVerifer(bits) {
var inner = createKeyVerifier(bits);
return function verify(thing, signature, publicKey) {
signature = formatEcdsa.joseToDer(signature, "ES" + bits).toString("base64");
var result = inner(thing, signature, publicKey);
return result;
};
}
function createNoneSigner() {
return function sign() {
return "";
};
}
function createNoneVerifier() {
return function verify(thing, signature) {
return signature === "";
};
}
module.exports = function jwa(algorithm) {
var signerFactories = {
hs: createHmacSigner,
rs: createKeySigner,
ps: createPSSKeySigner,
es: createECDSASigner,
none: createNoneSigner
};
var verifierFactories = {
hs: createHmacVerifier,
rs: createKeyVerifier,
ps: createPSSKeyVerifier,
es: createECDSAVerifer,
none: createNoneVerifier
};
var match = algorithm.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/i);
if (!match)
throw typeError(MSG_INVALID_ALGORITHM, algorithm);
var algo = (match[1] || match[3]).toLowerCase();
var bits = match[2];
return {
sign: signerFactories[algo](bits),
verify: verifierFactories[algo](bits)
};
};
}
});
// node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/tostring.js
var require_tostring = __commonJS({
"node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/tostring.js"(exports, module) {
"use strict";
var Buffer2 = __require("buffer").Buffer;
module.exports = function toString(obj) {
if (typeof obj === "string")
return obj;
if (typeof obj === "number" || Buffer2.isBuffer(obj))
return obj.toString();
return JSON.stringify(obj);
};
}
});
// node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/sign-stream.js
var require_sign_stream = __commonJS({
"node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/sign-stream.js"(exports, module) {
"use strict";
var Buffer2 = require_safe_buffer().Buffer;
var DataStream = require_data_stream();
var jwa = require_jwa();
var Stream = __require("stream");
var toString = require_tostring();
var util = __require("util");
function base64url(string, encoding) {
return Buffer2.from(string, encoding).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
}
function jwsSecuredInput(header, payload, encoding) {
encoding = encoding || "utf8";
var encodedHeader = base64url(toString(header), "binary");
var encodedPayload = base64url(toString(payload), encoding);
return util.format("%s.%s", encodedHeader, encodedPayload);
}
function jwsSign(opts) {
var header = opts.header;
var payload = opts.payload;
var secretOrKey = opts.secret || opts.privateKey;
var encoding = opts.encoding;
var algo = jwa(header.alg);
var securedInput = jwsSecuredInput(header, payload, encoding);
var signature = algo.sign(securedInput, secretOrKey);
return util.format("%s.%s", securedInput, signature);
}
function SignStream(opts) {
var secret = opts.secret || opts.privateKey || opts.key;
var secretStream = new DataStream(secret);
this.readable = true;
this.header = opts.header;
this.encoding = opts.encoding;
this.secret = this.privateKey = this.key = secretStream;
this.payload = new DataStream(opts.payload);
this.secret.once("close", function() {
if (!this.payload.writable && this.readable)
this.sign();
}.bind(this));
this.payload.once("close", function() {
if (!this.secret.writable && this.readable)
this.sign();
}.bind(this));
}
util.inherits(SignStream, Stream);
SignStream.prototype.sign = function sign() {
try {
var signature = jwsSign({
header: this.header,
payload: this.payload.buffer,
secret: this.secret.buffer,
encoding: this.encoding
});
this.emit("done", signature);
this.emit("data", signature);
this.emit("end");
this.readable = false;
return signature;
} catch (e) {
this.readable = false;
this.emit("error", e);
this.emit("close");
}
};
SignStream.sign = jwsSign;
module.exports = SignStream;
}
});
// node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/verify-stream.js
var require_verify_stream = __commonJS({
"node_modules/.pnpm/jws@3.2.2/node_modules/jws/lib/verify-stream.js"(exports, module) {
"use strict";
var Buffer2 = require_safe_buffer().Buffer;
var DataStream = require_data_stream();
var jwa = require_jwa();
var Stream = __require("stream");
var toString = require_tostring();
var util = __require("util");
var JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;
function isObject(thing) {
return Object.prototype.toString.call(thing) === "[object Object]";
}
function safeJsonParse(thing) {
if (isObject(thing))
return thing;
try {
return JSON.parse(thing);
} catch (e) {
return void 0;
}
}
function headerFromJWS(jwsSig) {
var encodedHeader = jwsSig.split(".", 1)[0];
return safeJsonParse(Buffer2.from(encodedHeader, "base64").toString("binary"));
}
function securedInputFromJWS(jwsSig) {
return jwsSig.split(".", 2).join(".");
}
function signatureFromJWS(jwsSig) {
return jwsSig.split(".")[2];
}
function payloadFromJWS(jwsSig, encoding) {
encoding = encoding || "utf8";
var payload = jwsSig.split(".")[1];
return Buffer2.from(payload, "base64").toString(encoding);
}
function isValidJws(string) {
return JWS_REGEX.test(string) && !!headerFromJWS(string);
}
function jwsVerify(jwsSig, algorithm, secretOrKey) {
if (!algorithm) {
var err = new Error("Missing algorithm parameter for jws.verify");
err.code = "MISSING_ALGORITHM";
throw err;
}
jwsSig = toString(jwsSig);
var signature = signatureFromJWS(jwsSig);
var securedInput = securedInputFromJWS(jwsSig);
var algo = jwa(algorithm);
return algo.verify(securedInput, signature, secretOrKey);
}
function jwsDecode(jwsSig, opts) {
opts = opts || {};
jwsSig = toString(jwsSig);
if (!isValidJws(jwsSig))
return null;
var header = headerFromJWS(jwsSig);
if (!header)
return null;
var payload = payloadFromJWS(jwsSig);
if (header.typ === "JWT" || opts.json)
payload = JSON.parse(payload, opts.encoding);
return {
header,
payload,
signature: signatureFromJWS(jwsSig)
};
}
function VerifyStream(opts) {
opts = opts || {};
var secretOrKey = opts.secret || opts.publicKey || opts.key;
var secretStream = new DataStream(secretOrKey);
this.readable = true;
this.algorithm = opts.algorithm;
this.encoding = opts.encoding;
this.secret = this.publicKey = this.key = secretStream;
this.signature = new DataStream(opts.signature);
this.secret.once("close", function() {
if (!this.signature.writable && this.readable)
this.verify();
}.bind(this));
this.signature.once("close", function() {
if (!this.secret.writable && this.readable)
this.verify();
}.bind(this));
}
util.inherits(VerifyStream, Stream);
VerifyStream.prototype.verify = function verify() {
try {
var valid = jwsVerify(this.signature.buffer, this.algorithm, this.key.buffer);
var obj = jwsDecode(this.signature.buffer, this.encoding);
this.emit("done", valid, obj);
this.emit("data", valid);
this.emit("end");
this.readable = false;
return valid;
} catch (e) {
this.readable = false;
this.emit("error", e);
this.emit("close");
}
};
VerifyStream.decode = jwsDecode;
VerifyStream.isValid = isValidJws;
VerifyStream.verify = jwsVerify;
module.exports = VerifyStream;
}
});
// node_modules/.pnpm/jws@3.2.2/node_modules/jws/index.js
var require_jws = __commonJS({
"node_modules/.pnpm/jws@3.2.2/node_modules/jws/index.js"(exports) {
"use strict";
var SignStream = require_sign_stream();
var VerifyStream = require_verify_stream();
var ALGORITHMS = [
"HS256",
"HS384",
"HS512",
"RS256",
"RS384",
"RS512",
"PS256",
"PS384",
"PS512",
"ES256",
"ES384",
"ES512"
];
exports.ALGORITHMS = ALGORITHMS;
exports.sign = SignStream.sign;
exports.verify = VerifyStream.verify;
exports.decode = VerifyStream.decode;
exports.isValid = VerifyStream.isValid;
exports.createSign = function createSign(opts) {
return new SignStream(opts);
};
exports.createVerify = function createVerify(opts) {
return new VerifyStream(opts);
};
}
});
// node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/decode.js
var require_decode = __commonJS({
"node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/decode.js"(exports, module) {
"use strict";
var jws = require_jws();
module.exports = function(jwt2, options) {
options = options || {};
var decoded = jws.decode(jwt2, options);
if (!decoded) {
return null;
}
var payload = decoded.payload;
if (typeof payload === "string") {
try {
var obj = JSON.parse(payload);
if (obj !== null && typeof obj === "object") {
payload = obj;
}
} catch (e) {
}
}
if (options.complete === true) {
return {
header: decoded.header,
payload,
signature: decoded.signature
};
}
return payload;
};
}
});
// node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/lib/JsonWebTokenError.js
var require_JsonWebTokenError = __commonJS({
"node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/lib/JsonWebTokenError.js"(exports, module) {
"use strict";
var JsonWebTokenError = function(message, error) {
Error.call(this, message);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
this.name = "JsonWebTokenError";
this.message = message;
if (error)
this.inner = error;
};
JsonWebTokenError.prototype = Object.create(Error.prototype);
JsonWebTokenError.prototype.constructor = JsonWebTokenError;
module.exports = JsonWebTokenError;
}
});
// node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/lib/NotBeforeError.js
var require_NotBeforeError = __commonJS({
"node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/lib/NotBeforeError.js"(exports, module) {
"use strict";
var JsonWebTokenError = require_JsonWebTokenError();
var NotBeforeError = function(message, date) {
JsonWebTokenError.call(this, message);
this.name = "NotBeforeError";
this.date = date;
};
NotBeforeError.prototype = Object.create(JsonWebTokenError.prototype);
NotBeforeError.prototype.constructor = NotBeforeError;
module.exports = NotBeforeError;
}
});
// node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/lib/TokenExpiredError.js
var require_TokenExpiredError = __commonJS({
"node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/lib/TokenExpiredError.js"(exports, module) {
"use strict";
var JsonWebTokenError = require_JsonWebTokenError();
var TokenExpiredError = function(message, expiredAt) {
JsonWebTokenError.call(this, message);
this.name = "TokenExpiredError";
this.expiredAt = expiredAt;
};
TokenExpiredError.prototype = Object.create(JsonWebTokenError.prototype);
TokenExpiredError.prototype.constructor = TokenExpiredError;
module.exports = TokenExpiredError;
}
});
// node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js
var require_ms = __commonJS({
"node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"(exports, module) {
"use strict";
var s = 1e3;
var m = s * 60;
var h = m * 60;
var d = h * 24;
var w = d * 7;
var y = d * 365.25;
module.exports = function(val, options) {
options = options || {};
var type = typeof val;
if (type === "string" && val.length > 0) {
return parse(val);
} else if (type === "number" && isFinite(val)) {
return options.long ? fmtLong(val) : fmtShort(val);
}
throw new Error(
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
);
};
function parse(str) {
str = String(str);
if (str.length > 100) {
return;
}
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
str
);
if (!match) {
return;
}
var n = parseFloat(match[1]);
var type = (match[2] || "ms").toLowerCase();
switch (type) {
case "years":
case "year":
case "yrs":
case "yr":
case "y":
return n * y;
case "weeks":
case "week":
case "w":
return n * w;
case "days":
case "day":
case "d":
return n * d;
case "hours":
case "hour":
case "hrs":
case "hr":
case "h":
return n * h;
case "minutes":
case "minute":
case "mins":
case "min":
case "m":
return n * m;
case "seconds":
case "second":
case "secs":
case "sec":
case "s":
return n * s;
case "milliseconds":
case "millisecond":
case "msecs":
case "msec":
case "ms":
return n;
default:
return void 0;
}
}
function fmtShort(ms) {
var msAbs = Math.abs(ms);
if (msAbs >= d) {
return Math.round(ms / d) + "d";
}
if (msAbs >= h) {
return Math.round(ms / h) + "h";
}
if (msAbs >= m) {
return Math.round(ms / m) + "m";
}
if (msAbs >= s) {
return Math.round(ms / s) + "s";
}
return ms + "ms";
}
function fmtLong(ms) {
var msAbs = Math.abs(ms);
if (msAbs >= d) {
return plural2(ms, msAbs, d, "day");
}
if (msAbs >= h) {
return plural2(ms, msAbs, h, "hour");
}
if (msAbs >= m) {
return plural2(ms, msAbs, m, "minute");
}
if (msAbs >= s) {
return plural2(ms, msAbs, s, "second");
}
return ms + " ms";
}
function plural2(ms, msAbs, n, name) {
var isPlural = msAbs >= n * 1.5;
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
}
}
});
// node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/lib/timespan.js
var require_timespan = __commonJS({
"node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/lib/timespan.js"(exports, module) {
"use strict";
var ms = require_ms();
module.exports = function(time, iat) {
var timestamp = iat || Math.floor(Date.now() / 1e3);
if (typeof time === "string") {
var milliseconds = ms(time);
if (typeof milliseconds === "undefined") {
return;
}
return Math.floor(timestamp + milliseconds / 1e3);
} else if (typeof time === "number") {
return timestamp + time;
} else {
return;
}
};
}
});
// node_modules/.pnpm/semver@5.7.1/node_modules/semver/semver.js
var require_semver = __commonJS({
"node_modules/.pnpm/semver@5.7.1/node_modules/semver/semver.js"(exports, module) {
"use strict";
exports = module.exports = SemVer;
var debug;
if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
debug = function() {
var args = Array.prototype.slice.call(arguments, 0);
args.unshift("SEMVER");
console.log.apply(console, args);
};
} else {
debug = function() {
};
}
exports.SEMVER_SPEC_VERSION = "2.0.0";
var MAX_LENGTH = 256;
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
9007199254740991;
var MAX_SAFE_COMPONENT_LENGTH = 16;
var re = exports.re = [];
var src = exports.src = [];
var R = 0;
var NUMERICIDENTIFIER = R++;
src[NUMERICIDENTIFIER] = "0|[1-9]\\d*";
var NUMERICIDENTIFIERLOOSE = R++;
src[NUMERICIDENTIFIERLOOSE] = "[0-9]+";
var NONNUMERICIDENTIFIER = R++;
src[NONNUMERICIDENTIFIER] = "\\d*[a-zA-Z-][a-zA-Z0-9-]*";
var MAINVERSION = R++;
src[MAINVERSION] = "(" + src[NUMERICIDENTIFIER] + ")\\.(" + src[NUMERICIDENTIFIER] + ")\\.(" + src[NUMERICIDENTIFIER] + ")";
var MAINVERSIONLOOSE = R++;
src[MAINVERSIONLOOSE] = "(" + src[NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[NUMERICIDENTIFIERLOOSE] + ")";
var PRERELEASEIDENTIFIER = R++;
src[PRERELEASEIDENTIFIER] = "(?:" + src[NUMERICIDENTIFIER] + "|" + src[NONNUMERICIDENTIFIER] + ")";
var PRERELEASEIDENTIFIERLOOSE = R++;
src[PRERELEASEIDENTIFIERLOOSE] = "(?:" + src[NUMERICIDENTIFIERLOOSE] + "|" + src[NONNUMERICIDENTIFIER] + ")";
var PRERELEASE = R++;
src[PRERELEASE] = "(?:-(" + src[PRERELEASEIDENTIFIER] + "(?:\\." + src[PRERELEASEIDENTIFIER] + ")*))";
var PRERELEASELOOSE = R++;
src[PRERELEASELOOSE] = "(?:-?(" + src[PRERELEASEIDENTIFIERLOOSE] + "(?:\\." + src[PRERELEASEIDENTIFIERLOOSE] + ")*))";
var BUILDIDENTIFIER = R++;
src[BUILDIDENTIFIER] = "[0-9A-Za-z-]+";
var BUILD = R++;
src[BUILD] = "(?:\\+(" + src[BUILDIDENTIFIER] + "(?:\\." + src[BUILDIDENTIFIER] + ")*))";
var FULL = R++;
var FULLPLAIN = "v?" + src[MAINVERSION] + src[PRERELEASE] + "?" + src[BUILD] + "?";
src[FULL] = "^" + FULLPLAIN + "$";
var LOOSEPLAIN = "[v=\\s]*" + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + "?" + src[BUILD] + "?";
var LOOSE = R++;
src[LOOSE] = "^" + LOOSEPLAIN + "$";
var GTLT = R++;
src[GTLT] = "((?:<|>)?=?)";
var XRANGEIDENTIFIERLOOSE = R++;
src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + "|x|X|\\*";
var XRANGEIDENTIFIER = R++;
src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + "|x|X|\\*";
var XRANGEPLAIN = R++;
src[XRANGEPLAIN] = "[v=\\s]*(" + src[XRANGEIDENTIFIER] + ")(?:\\.(" + src[XRANGEIDENTIFIER] + ")(?:\\.(" + src[XRANGEIDENTIFIER] + ")(?:" + src[PRERELEASE] + ")?" + src[BUILD] + "?)?)?";
var XRANGEPLAINLOOSE = R++;
src[XRANGEPLAINLOOSE] = "[v=\\s]*(" + src[XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[XRANGEIDENTIFIERLOOSE] + ")(?:" + src[PRERELEASELOOSE] + ")?" + src[BUILD] + "?)?)?";
var XRANGE = R++;
src[XRANGE] = "^" + src[GTLT] + "\\s*" + src[XRANGEPLAIN] + "$";
var XRANGELOOSE = R++;
src[XRANGELOOSE] = "^" + src[GTLT] + "\\s*" + src[XRANGEPLAINLOOSE] + "$";
var COERCE = R++;
src[COERCE] = "(?:^|[^\\d])(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "})(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:$|[^\\d])";
var LONETILDE = R++;
src[LONETILDE] = "(?:~>?)";
var TILDETRIM = R++;
src[TILDETRIM] = "(\\s*)" + src[LONETILDE] + "\\s+";
re[TILDETRIM] = new RegExp(src[TILDETRIM], "g");
var tildeTrimReplace = "$1~";
var TILDE = R++;
src[TILDE] = "^" + src[LONETILDE] + src[XRANGEPLAIN] + "$";
var TILDELOOSE = R++;
src[TILDELOOSE] = "^" + src[LONETILDE] + src[XRANGEPLAINLOOSE] + "$";
var LONECARET = R++;
src[LONECARET] = "(?:\\^)";
var CARETTRIM = R++;
src[CARETTRIM] = "(\\s*)" + src[LONECARET] + "\\s+";
re[CARETTRIM] = new RegExp(src[CARETTRIM], "g");
var caretTrimReplace = "$1^";
var CARET = R++;
src[CARET] = "^" + src[LONECARET] + src[XRANGEPLAIN] + "$";
var CARETLOOSE = R++;
src[CARETLOOSE] = "^" + src[LONECARET] + src[XRANGEPLAINLOOSE] + "$";
var COMPARATORLOOSE = R++;
src[COMPARATORLOOSE] = "^" + src[GTLT] + "\\s*(" + LOOSEPLAIN + ")$|^$";
var COMPARATOR = R++;
src[COMPARATOR] = "^" + src[GTLT] + "\\s*(" + FULLPLAIN + ")$|^$";
var COMPARATORTRIM = R++;
src[COMPARATORTRIM] = "(\\s*)" + src[GTLT] + "\\s*(" + LOOSEPLAIN + "|" + src[XRANGEPLAIN] + ")";
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], "g");
var comparatorTrimReplace = "$1$2$3";
var HYPHENRANGE = R++;
src[HYPHENRANGE] = "^\\s*(" + src[XRANGEPLAIN] + ")\\s+-\\s+(" + src[XRANGEPLAIN] + ")\\s*$";
var HYPHENRANGELOOSE = R++;
src[HYPHENRANGELOOSE] = "^\\s*(" + src[XRANGEPLAINLOOSE] + ")\\s+-\\s+(" + src[XRANGEPLAINLOOSE] + ")\\s*$";
var STAR = R++;
src[STAR] = "(<|>)?=?\\s*\\*";
for (i = 0; i < R; i++) {
debug(i, src[i]);
if (!re[i]) {
re[i] = new RegExp(src[i]);
}
}
var i;
exports.parse = parse;
function parse(version, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (version instanceof SemVer) {
return version;
}
if (typeof version !== "string") {
return null;
}
if (version.length > MAX_LENGTH) {
return null;
}
var r = options.loose ? re[LOOSE] : re[FULL];
if (!r.test(version)) {
return null;
}
try {
return new SemVer(version, options);
} catch (er) {
return null;
}
}
exports.valid = valid;
function valid(version, options) {
var v = parse(version, options);
return v ? v.version : null;
}
exports.clean = clean;
function clean(version, options) {
var s = parse(version.trim().replace(/^[=v]+/, ""), options);
return s ? s.version : null;
}
exports.SemVer = SemVer;
function SemVer(version, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (version instanceof SemVer) {
if (version.loose === options.loose) {
return version;
} else {
version = version.version;
}
} else if (typeof version !== "string") {
throw new TypeError("Invalid Version: " + version);
}
if (version.length > MAX_LENGTH) {
throw new TypeError("version is longer than " + MAX_LENGTH + " characters");
}
if (!(this instanceof SemVer)) {
return new SemVer(version, options);
}
debug("SemVer", version, options);
this.options = options;
this.loose = !!options.loose;
var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL]);
if (!m) {
throw new TypeError("Invalid Version: " + version);
}
this.raw = version;
this.major = +m[1];
this.minor = +m[2];
this.patch = +m[3];
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
throw new TypeError("Invalid major version");
}
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
throw new TypeError("Invalid minor version");
}
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
throw new TypeError("Invalid patch version");
}
if (!m[4]) {
this.prerelease = [];
} else {
this.prerelease = m[4].split(".").map(function(id) {
if (/^[0-9]+$/.test(id)) {
var num = +id;
if (num >= 0 && num < MAX_SAFE_INTEGER) {
return num;
}
}
return id;
});
}
this.build = m[5] ? m[5].split(".") : [];
this.format();
}
SemVer.prototype.format = function() {
this.version = this.major + "." + this.minor + "." + this.patch;
if (this.prerelease.length) {
this.version += "-" + this.prerelease.join(".");
}
return this.version;
};
SemVer.prototype.toString = function() {
return this.version;
};
SemVer.prototype.compare = function(other) {
debug("SemVer.compare", this.version, this.options, other);
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
return this.compareMain(other) || this.comparePre(other);
};
SemVer.prototype.compareMain = function(other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
};
SemVer.prototype.comparePre = function(other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
if (this.prerelease.length && !other.prerelease.length) {
return -1;
} else if (!this.prerelease.length && other.prerelease.length) {
return 1;
} else if (!this.prerelease.length && !other.prerelease.length) {
return 0;
}
var i2 = 0;
do {
var a = this.prerelease[i2];
var b = other.prerelease[i2];
debug("prerelease compare", i2, a, b);
if (a === void 0 && b === void 0) {
return 0;
} else if (b === void 0) {
return 1;
} else if (a === void 0) {
return -1;
} else if (a === b) {
continue;
} else {
return compareIdentifiers(a, b);
}
} while (++i2);
};
SemVer.prototype.inc = function(release, identifier) {
switch (release) {
case "premajor":
this.prerelease.length = 0;
this.patch = 0;
this.minor = 0;
this.major++;
this.inc("pre", identifier);
break;
case "preminor":
this.prerelease.length = 0;
this.patch = 0;
this.minor++;
this.inc("pre", identifier);
break;
case "prepatch":
this.prerelease.length = 0;
this.inc("patch", identifier);
this.inc("pre", identifier);
break;
case "prerelease":
if (this.prerelease.length === 0) {
this.inc("patch", identifier);
}
this.inc("pre", identifier);
break;
case "major":
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
this.major++;
}
this.minor = 0;
this.patch = 0;
this.prerelease = [];
break;
case "minor":
if (this.patch !== 0 || this.prerelease.length === 0) {
this.minor++;
}
this.patch = 0;
this.prerelease = [];
break;
case "patch":
if (this.prerelease.length === 0) {
this.patch++;
}
this.prerelease = [];
break;
case "pre":
if (this.prerelease.length === 0) {
this.prerelease = [0];
} else {
var i2 = this.prerelease.length;
while (--i2 >= 0) {
if (typeof this.prerelease[i2] === "number") {
this.prerelease[i2]++;
i2 = -2;
}
}
if (i2 === -1) {
this.prerelease.push(0);
}
}
if (identifier) {
if (this.prerelease[0] === identifier) {
if (isNaN(this.prerelease[1])) {
this.prerelease = [identifier, 0];
}
} else {
this.prerelease = [identifier, 0];
}
}
break;
default:
throw new Error("invalid increment argument: " + release);
}
this.format();
this.raw = this.version;
return this;
};
exports.inc = inc;
function inc(version, release, loose, identifier) {
if (typeof loose === "string") {
identifier = loose;
loose = void 0;
}
try {
return new SemVer(version, loose).inc(release, identifier).version;
} catch (er) {
return null;
}
}
exports.diff = diff;
function diff(version1, version2) {
if (eq(version1, version2)) {
return null;
} else {
var v1 = parse(version1);
var v2 = parse(version2);
var prefix = "";
if (v1.prerelease.length || v2.prerelease.length) {
prefix = "pre";
var defaultResult = "prerelease";
}
for (var key in v1) {
if (key === "major" || key === "minor" || key === "patch") {
if (v1[key] !== v2[key]) {
return prefix + key;
}
}
}
return defaultResult;
}
}
exports.compareIdentifiers = compareIdentifiers;
var numeric = /^[0-9]+$/;
function compareIdentifiers(a, b) {
var anum = numeric.test(a);
var bnum = numeric.test(b);
if (anum && bnum) {
a = +a;
b = +b;
}
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
}
exports.rcompareIdentifiers = rcompareIdentifiers;
function rcompareIdentifiers(a, b) {
return compareIdentifiers(b, a);
}
exports.major = major;
function major(a, loose) {
return new SemVer(a, loose).major;
}
exports.minor = minor;
function minor(a, loose) {
return new SemVer(a, loose).minor;
}
exports.patch = patch;
function patch(a, loose) {
return new SemVer(a, loose).patch;
}
exports.compare = compare;
function compare(a, b, loose) {
return new SemVer(a, loose).compare(new SemVer(b, loose));
}
exports.compareLoose = compareLoose;
function compareLoose(a, b) {
return compare(a, b, true);
}
exports.rcompare = rcompare;
function rcompare(a, b, loose) {
return compare(b, a, loose);
}
exports.sort = sort;
function sort(list, loose) {
return list.sort(function(a, b) {
return exports.compare(a, b, loose);
});
}
exports.rsort = rsort;
function rsort(list, loose) {
return list.sort(function(a, b) {
return exports.rcompare(a, b, loose);
});
}
exports.gt = gt;
function gt(a, b, loose) {
return compare(a, b, loose) > 0;
}
exports.lt = lt;
function lt(a, b, loose) {
return compare(a, b, loose) < 0;
}
exports.eq = eq;
function eq(a, b, loose) {
return compare(a, b, loose) === 0;
}
exports.neq = neq;
function neq(a, b, loose) {
return compare(a, b, loose) !== 0;
}
exports.gte = gte;
function gte(a, b, loose) {
return compare(a, b, loose) >= 0;
}
exports.lte = lte;
function lte(a, b, loose) {
return compare(a, b, loose) <= 0;
}
exports.cmp = cmp;
function cmp(a, op, b, loose) {
switch (op) {
case "===":
if (typeof a === "object")
a = a.version;
if (typeof b === "object")
b = b.version;
return a === b;
case "!==":
if (typeof a === "object")
a = a.version;
if (typeof b === "object")
b = b.version;
return a !== b;
case "":
case "=":
case "==":
return eq(a, b, loose);
case "!=":
return neq(a, b, loose);
case ">":
return gt(a, b, loose);
case ">=":
return gte(a, b, loose);
case "<":
return lt(a, b, loose);
case "<=":
return lte(a, b, loose);
default:
throw new TypeError("Invalid operator: " + op);
}
}
exports.Comparator = Comparator;
function Comparator(comp, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (comp instanceof Comparator) {
if (comp.loose === !!options.loose) {
return comp;
} else {
comp = comp.value;
}
}
if (!(this instanceof Comparator)) {
return new Comparator(comp, options);
}
debug("comparator", comp, options);
this.options = options;
this.loose = !!options.loose;
this.parse(comp);
if (this.semver === ANY) {
this.value = "";
} else {
this.value = this.operator + this.semver.version;
}
debug("comp", this);
}
var ANY = {};
Comparator.prototype.parse = function(comp) {
var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
var m = comp.match(r);
if (!m) {
throw new TypeError("Invalid comparator: " + comp);
}
this.operator = m[1];
if (this.operator === "=") {
this.operator = "";
}
if (!m[2]) {
this.semver = ANY;
} else {
this.semver = new SemVer(m[2], this.options.loose);
}
};
Comparator.prototype.toString = function() {
return this.value;
};
Comparator.prototype.test = function(version) {
debug("Comparator.test", version, this.options.loose);
if (this.semver === ANY) {
return true;
}
if (typeof version === "string") {
version = new SemVer(version, this.options);
}
return cmp(version, this.operator, this.semver, this.options);
};
Comparator.prototype.intersects = function(comp, options) {
if (!(comp instanceof Comparator)) {
throw new TypeError("a Comparator is required");
}
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
var rangeTmp;
if (this.operator === "") {
rangeTmp = new Range(comp.value, options);
return satisfies(this.value, rangeTmp, options);
} else if (comp.operator === "") {
rangeTmp = new Range(this.value, options);
return satisfies(comp.semver, rangeTmp, options);
}
var sameDirectionIncreasing = (this.operator === ">=" || this.operator === ">") && (comp.operator === ">=" || comp.operator === ">");
var sameDirectionDecreasing = (this.operator === "<=" || this.operator === "<") && (comp.operator === "<=" || comp.operator === "<");
var sameSemVer = this.semver.version === comp.semver.version;
var differentDirectionsInclusive = (this.operator === ">=" || this.operator === "<=") && (comp.operator === ">=" || comp.operator === "<=");
var oppositeDirectionsLessThan = cmp(this.semver, "<", comp.semver, options) && ((this.operator === ">=" || this.operator === ">") && (comp.operator === "<=" || comp.operator === "<"));
var oppositeDirectionsGreaterThan = cmp(this.semver, ">", comp.semver, options) && ((this.operator === "<=" || this.operator === "<") && (comp.operator === ">=" || comp.operator === ">"));
return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
};
exports.Range = Range;
function Range(range, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (range instanceof Range) {
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
return range;
} else {
return new Range(range.raw, options);
}
}
if (range instanceof Comparator) {
return new Range(range.value, options);
}
if (!(this instanceof Range)) {
return new Range(range, options);
}
this.options = options;
this.loose = !!options.loose;
this.includePrerelease = !!options.includePrerelease;
this.raw = range;
this.set = range.split(/\s*\|\|\s*/).map(function(range2) {
return this.parseRange(range2.trim());
}, this).filter(function(c) {
return c.length;
});
if (!this.set.length) {
throw new TypeError("Invalid SemVer Range: " + range);
}
this.format();
}
Range.prototype.format = function() {
this.range = this.set.map(function(comps) {
return comps.join(" ").trim();
}).join("||").trim();
return this.range;
};
Range.prototype.toString = function() {
return this.range;
};
Range.prototype.parseRange = function(range) {
var loose = this.options.loose;
range = range.trim();
var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
range = range.replace(hr, hyphenReplace);
debug("hyphen replace", range);
range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
debug("comparator trim", range, re[COMPARATORTRIM]);
range = range.replace(re[TILDETRIM], tildeTrimReplace);
range = range.replace(re[CARETTRIM], caretTrimReplace);
range = range.split(/\s+/).join(" ");
var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
var set = range.split(" ").map(function(comp) {
return parseComparator(comp, this.options);
}, this).join(" ").split(/\s+/);
if (this.options.loose) {
set = set.filter(function(comp) {
return !!comp.match(compRe);
});
}
set = set.map(function(comp) {
return new Comparator(comp, this.options);
}, this);
return set;
};
Range.prototype.intersects = function(range, options) {
if (!(range instanceof Range)) {
throw new TypeError("a Range is required");
}
return this.set.some(function(thisComparators) {
return thisComparators.every(function(thisComparator) {
return range.set.some(function(rangeComparators) {
return rangeComparators.every(function(rangeComparator) {
return thisComparator.intersects(rangeComparator, options);
});
});
});
});
};
exports.toComparators = toComparators;
function toComparators(range, options) {
return new Range(range, options).set.map(function(comp) {
return comp.map(function(c) {
return c.value;
}).join(" ").trim().split(" ");
});
}
function parseComparator(comp, options) {
debug("comp", comp, options);
comp = replaceCarets(comp, options);
debug("caret", comp);
comp = replaceTildes(comp, options);
debug("tildes", comp);
comp = replaceXRanges(comp, options);
debug("xrange", comp);
comp = replaceStars(comp, options);
debug("stars", comp);
return comp;
}
function isX(id) {
return !id || id.toLowerCase() === "x" || id === "*";
}
function replaceTildes(comp, options) {
return comp.trim().split(/\s+/).map(function(comp2) {
return replaceTilde(comp2, options);
}).join(" ");
}
function replaceTilde(comp, options) {
var r = options.loose ? re[TILDELOOSE] : re[TILDE];
return comp.replace(r, function(_, M, m, p, pr) {
debug("tilde", comp, _, M, m, p, pr);
var ret;
if (isX(M)) {
ret = "";
} else if (isX(m)) {
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
} else if (isX(p)) {
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
} else if (pr) {
debug("replaceTilde pr", pr);
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
} else {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
}
debug("tilde return", ret);
return ret;
});
}
function replaceCarets(comp, options) {
return comp.trim().split(/\s+/).map(function(comp2) {
return replaceCaret(comp2, options);
}).join(" ");
}
function replaceCaret(comp, options) {
debug("caret", comp, options);
var r = options.loose ? re[CARETLOOSE] : re[CARET];
return comp.replace(r, function(_, M, m, p, pr) {
debug("caret", comp, _, M, m, p, pr);
var ret;
if (isX(M)) {
ret = "";
} else if (isX(m)) {
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
} else if (isX(p)) {
if (M === "0") {
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
} else {
ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0";
}
} else if (pr) {
debug("replaceCaret pr", pr);
if (M === "0") {
if (m === "0") {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1);
} else {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
}
} else {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0";
}
} else {
debug("no pr");
if (M === "0") {
if (m === "0") {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1);
} else {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
}
} else {
ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0";
}
}
debug("caret return", ret);
return ret;
});
}
function replaceXRanges(comp, options) {
debug("replaceXRanges", comp, options);
return comp.split(/\s+/).map(function(comp2) {
return replaceXRange(comp2, options);
}).join(" ");
}
function replaceXRange(comp, options) {
comp = comp.trim();
var r = options.loose ? re[XRANGELOOSE] : re[XRANGE];
return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
debug("xRange", comp, ret, gtlt, M, m, p, pr);
var xM = isX(M);
var xm = xM || isX(m);
var xp = xm || isX(p);
var anyX = xp;
if (gtlt === "=" && anyX) {
gtlt = "";
}
if (xM) {
if (gtlt === ">" || gtlt === "<") {
ret = "<0.0.0";
} else {
ret = "*";
}
} else if (gtlt && anyX) {
if (xm) {
m = 0;
}
p = 0;
if (gtlt === ">") {
gtlt = ">=";
if (xm) {
M = +M + 1;
m = 0;
p = 0;
} else {
m = +m + 1;
p = 0;
}
} else if (gtlt === "<=") {
gtlt = "<";
if (xm) {
M = +M + 1;
} else {
m = +m + 1;
}
}
ret = gtlt + M + "." + m + "." + p;
} else if (xm) {
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
} else if (xp) {
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
}
debug("xRange return", ret);
return ret;
});
}
function replaceStars(comp, options) {
debug("replaceStars", comp, options);
return comp.trim().replace(re[STAR], "");
}
function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
if (isX(fM)) {
from = "";
} else if (isX(fm)) {
from = ">=" + fM + ".0.0";
} else if (isX(fp)) {
from = ">=" + fM + "." + fm + ".0";
} else {
from = ">=" + from;
}
if (isX(tM)) {
to = "";
} else if (isX(tm)) {
to = "<" + (+tM + 1) + ".0.0";
} else if (isX(tp)) {
to = "<" + tM + "." + (+tm + 1) + ".0";
} else if (tpr) {
to = "<=" + tM + "." + tm + "." + tp + "-" + tpr;
} else {
to = "<=" + to;
}
return (from + " " + to).trim();
}
Range.prototype.test = function(version) {
if (!version) {
return false;
}
if (typeof version === "string") {
version = new SemVer(version, this.options);
}
for (var i2 = 0; i2 < this.set.length; i2++) {
if (testSet(this.set[i2], version, this.options)) {
return true;
}
}
return false;
};
function testSet(set, version, options) {
for (var i2 = 0; i2 < set.length; i2++) {
if (!set[i2].test(version)) {
return false;
}
}
if (version.prerelease.length && !options.includePrerelease) {
for (i2 = 0; i2 < set.length; i2++) {
debug(set[i2].semver);
if (set[i2].semver === ANY) {
continue;
}
if (set[i2].semver.prerelease.length > 0) {
var allowed = set[i2].semver;
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
return true;
}
}
}
return false;
}
return true;
}
exports.satisfies = satisfies;
function satisfies(version, range, options) {
try {
range = new Range(range, options);
} catch (er) {
return false;
}
return range.test(version);
}
exports.maxSatisfying = maxSatisfying;
function maxSatisfying(versions, range, options) {
var max = null;
var maxSV = null;
try {
var rangeObj = new Range(range, options);
} catch (er) {
return null;
}
versions.forEach(function(v) {
if (rangeObj.test(v)) {
if (!max || maxSV.compare(v) === -1) {
max = v;
maxSV = new SemVer(max, options);
}
}
});
return max;
}
exports.minSatisfying = minSatisfying;
function minSatisfying(versions, range, options) {
var min = null;
var minSV = null;
try {
var rangeObj = new Range(range, options);
} catch (er) {
return null;
}
versions.forEach(function(v) {
if (rangeObj.test(v)) {
if (!min || minSV.compare(v) === 1) {
min = v;
minSV = new SemVer(min, options);
}
}
});
return min;
}
exports.minVersion = minVersion;
function minVersion(range, loose) {
range = new Range(range, loose);
var minver = new SemVer("0.0.0");
if (range.test(minver)) {
return minver;
}
minver = new SemVer("0.0.0-0");
if (range.test(minver)) {
return minver;
}
minver = null;
for (var i2 = 0; i2 < range.set.length; ++i2) {
var comparators = range.set[i2];
comparators.forEach(function(comparator) {
var compver = new SemVer(comparator.semver.version);
switch (comparator.operator) {
case ">":
if (compver.prerelease.length === 0) {
compver.patch++;
} else {
compver.prerelease.push(0);
}
compver.raw = compver.format();
case "":
case ">=":
if (!minver || gt(minver, compver)) {
minver = compver;
}
break;
case "<":
case "<=":
break;
default:
throw new Error("Unexpected operation: " + comparator.operator);
}
});
}
if (minver && range.test(minver)) {
return minver;
}
return null;
}
exports.validRange = validRange;
function validRange(range, options) {
try {
return new Range(range, options).range || "*";
} catch (er) {
return null;
}
}
exports.ltr = ltr;
function ltr(version, range, options) {
return outside(version, range, "<", options);
}
exports.gtr = gtr;
function gtr(version, range, options) {
return outside(version, range, ">", options);
}
exports.outside = outside;
function outside(version, range, hilo, options) {
version = new SemVer(version, options);
range = new Range(range, options);
var gtfn, ltefn, ltfn, comp, ecomp;
switch (hilo) {
case ">":
gtfn = gt;
ltefn = lte;
ltfn = lt;
comp = ">";
ecomp = ">=";
break;
case "<":
gtfn = lt;
ltefn = gte;
ltfn = gt;
comp = "<";
ecomp = "<=";
break;
default:
throw new TypeError('Must provide a hilo val of "<" or ">"');
}
if (satisfies(version, range, options)) {
return false;
}
for (var i2 = 0; i2 < range.set.length; ++i2) {
var comparators = range.set[i2];
var high = null;
var low = null;
comparators.forEach(function(comparator) {
if (comparator.semver === ANY) {
comparator = new Comparator(">=0.0.0");
}
high = high || comparator;
low = low || comparator;
if (gtfn(comparator.semver, high.semver, options)) {
high = comparator;
} else if (ltfn(comparator.semver, low.semver, options)) {
low = comparator;
}
});
if (high.operator === comp || high.operator === ecomp) {
return false;
}
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
return false;
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
return false;
}
}
return true;
}
exports.prerelease = prerelease;
function prerelease(version, options) {
var parsed = parse(version, options);
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
}
exports.intersects = intersects;
function intersects(r1, r2, options) {
r1 = new Range(r1, options);
r2 = new Range(r2, options);
return r1.intersects(r2);
}
exports.coerce = coerce;
function coerce(version) {
if (version instanceof SemVer) {
return version;
}
if (typeof version !== "string") {
return null;
}
var match = version.match(re[COERCE]);
if (match == null) {
return null;
}
return parse(match[1] + "." + (match[2] || "0") + "." + (match[3] || "0"));
}
}
});
// node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/lib/psSupported.js
var require_psSupported = __commonJS({
"node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/lib/psSupported.js"(exports, module) {
"use strict";
var semver = require_semver();
module.exports = semver.satisfies(process.version, "^6.12.0 || >=8.0.0");
}
});
// node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/verify.js
var require_verify = __commonJS({
"node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/verify.js"(exports, module) {
"use strict";
var JsonWebTokenError = require_JsonWebTokenError();
var NotBeforeError = require_NotBeforeError();
var TokenExpiredError = require_TokenExpiredError();
var decode = require_decode();
var timespan = require_timespan();
var PS_SUPPORTED = require_psSupported();
var jws = require_jws();
var PUB_KEY_ALGS = ["RS256", "RS384", "RS512", "ES256", "ES384", "ES512"];
var RSA_KEY_ALGS = ["RS256", "RS384", "RS512"];
var HS_ALGS = ["HS256", "HS384", "HS512"];
if (PS_SUPPORTED) {
PUB_KEY_ALGS.splice(3, 0, "PS256", "PS384", "PS512");
RSA_KEY_ALGS.splice(3, 0, "PS256", "PS384", "PS512");
}
module.exports = function(jwtString, secretOrPublicKey, options, callback) {
if (typeof options === "function" && !callback) {
callback = options;
options = {};
}
if (!options) {
options = {};
}
options = Object.assign({}, options);
var done;
if (callback) {
done = callback;
} else {
done = function(err, data) {
if (err)
throw err;
return data;
};
}
if (options.clockTimestamp && typeof options.clockTimestamp !== "number") {
return done(new JsonWebTokenError("clockTimestamp must be a number"));
}
if (options.nonce !== void 0 && (typeof options.nonce !== "string" || options.nonce.trim() === "")) {
return done(new JsonWebTokenError("nonce must be a non-empty string"));
}
var clockTimestamp = options.clockTimestamp || Math.floor(Date.now() / 1e3);
if (!jwtString) {
return done(new JsonWebTokenError("jwt must be provided"));
}
if (typeof jwtString !== "string") {
return done(new JsonWebTokenError("jwt must be a string"));
}
var parts = jwtString.split(".");
if (parts.length !== 3) {
return done(new JsonWebTokenError("jwt malformed"));
}
var decodedToken;
try {
decodedToken = decode(jwtString, { complete: true });
} catch (err) {
return done(err);
}
if (!decodedToken) {
return done(new JsonWebTokenError("invalid token"));
}
var header = decodedToken.header;
var getSecret;
if (typeof secretOrPublicKey === "function") {
if (!callback) {
return done(new JsonWebTokenError("verify must be called asynchronous if secret or public key is provided as a callback"));
}
getSecret = secretOrPublicKey;
} else {
getSecret = function(header2, secretCallback) {
return secretCallback(null, secretOrPublicKey);
};
}
return getSecret(header, function(err, secretOrPublicKey2) {
if (err) {
return done(new JsonWebTokenError("error in secret or public key callback: " + err.message));
}
var hasSignature = parts[2].trim() !== "";
if (!hasSignature && secretOrPublicKey2) {
return done(new JsonWebTokenError("jwt signature is required"));
}
if (hasSignature && !secretOrPublicKey2) {
return done(new JsonWebTokenError("secret or public key must be provided"));
}
if (!hasSignature && !options.algorithms) {
options.algorithms = ["none"];
}
if (!options.algorithms) {
options.algorithms = ~secretOrPublicKey2.toString().indexOf("BEGIN CERTIFICATE") || ~secretOrPublicKey2.toString().indexOf("BEGIN PUBLIC KEY") ? PUB_KEY_ALGS : ~secretOrPublicKey2.toString().indexOf("BEGIN RSA PUBLIC KEY") ? RSA_KEY_ALGS : HS_ALGS;
}
if (!~options.algorithms.indexOf(decodedToken.header.alg)) {
return done(new JsonWebTokenError("invalid algorithm"));
}
var valid;
try {
valid = jws.verify(jwtString, decodedToken.header.alg, secretOrPublicKey2);
} catch (e) {
return done(e);
}
if (!valid) {
return done(new JsonWebTokenError("invalid signature"));
}
var payload = decodedToken.payload;
if (typeof payload.nbf !== "undefined" && !options.ignoreNotBefore) {
if (typeof payload.nbf !== "number") {
return done(new JsonWebTokenError("invalid nbf value"));
}
if (payload.nbf > clockTimestamp + (options.clockTolerance || 0)) {
return done(new NotBeforeError("jwt not active", new Date(payload.nbf * 1e3)));
}
}
if (typeof payload.exp !== "undefined" && !options.ignoreExpiration) {
if (typeof payload.exp !== "number") {
return done(new JsonWebTokenError("invalid exp value"));
}
if (clockTimestamp >= payload.exp + (options.clockTolerance || 0)) {
return done(new TokenExpiredError("jwt expired", new Date(payload.exp * 1e3)));
}
}
if (options.audience) {
var audiences = Array.isArray(options.audience) ? options.audience : [options.audience];
var target = Array.isArray(payload.aud) ? payload.aud : [payload.aud];
var match = target.some(function(targetAudience) {
return audiences.some(function(audience) {
return audience instanceof RegExp ? audience.test(targetAudience) : audience === targetAudience;
});
});
if (!match) {
return done(new JsonWebTokenError("jwt audience invalid. expected: " + audiences.join(" or ")));
}
}
if (options.issuer) {
var invalid_issuer = typeof options.issuer === "string" && payload.iss !== options.issuer || Array.isArray(options.issuer) && options.issuer.indexOf(payload.iss) === -1;
if (invalid_issuer) {
return done(new JsonWebTokenError("jwt issuer invalid. expected: " + options.issuer));
}
}
if (options.subject) {
if (payload.sub !== options.subject) {
return done(new JsonWebTokenError("jwt subject invalid. expected: " + options.subject));
}
}
if (options.jwtid) {
if (payload.jti !== options.jwtid) {
return done(new JsonWebTokenError("jwt jwtid invalid. expected: " + options.jwtid));
}
}
if (options.nonce) {
if (payload.nonce !== options.nonce) {
return done(new JsonWebTokenError("jwt nonce invalid. expected: " + options.nonce));
}
}
if (options.maxAge) {
if (typeof payload.iat !== "number") {
return done(new JsonWebTokenError("iat required when maxAge is specified"));
}
var maxAgeTimestamp = timespan(options.maxAge, payload.iat);
if (typeof maxAgeTimestamp === "undefined") {
return done(new JsonWebTokenError('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));
}
if (clockTimestamp >= maxAgeTimestamp + (options.clockTolerance || 0)) {
return done(new TokenExpiredError("maxAge exceeded", new Date(maxAgeTimestamp * 1e3)));
}
}
if (options.complete === true) {
var signature = decodedToken.signature;
return done(null, {
header,
payload,
signature
});
}
return done(null, payload);
});
};
}
});
// node_modules/.pnpm/lodash.includes@4.3.0/node_modules/lodash.includes/index.js
var require_lodash = __commonJS({
"node_modules/.pnpm/lodash.includes@4.3.0/node_modules/lodash.includes/index.js"(exports, module) {
"use strict";
var INFINITY = 1 / 0;
var MAX_SAFE_INTEGER = 9007199254740991;
var MAX_INTEGER = 17976931348623157e292;
var NAN = 0 / 0;
var argsTag = "[object Arguments]";
var funcTag = "[object Function]";
var genTag = "[object GeneratorFunction]";
var stringTag = "[object String]";
var symbolTag = "[object Symbol]";
var reTrim = /^\s+|\s+$/g;
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
var reIsBinary = /^0b[01]+$/i;
var reIsOctal = /^0o[0-7]+$/i;
var reIsUint = /^(?:0|[1-9]\d*)$/;
var freeParseInt = parseInt;
function arrayMap(array, iteratee) {
var index = -1, length = array ? array.length : 0, result = Array(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
}
function baseFindIndex(array, predicate, fromIndex, fromRight) {
var length = array.length, index = fromIndex + (fromRight ? 1 : -1);
while (fromRight ? index-- : ++index < length) {
if (predicate(array[index], index, array)) {
return index;
}
}
return -1;
}
function baseIndexOf(array, value, fromIndex) {
if (value !== value) {
return baseFindIndex(array, baseIsNaN, fromIndex);
}
var index = fromIndex - 1, length = array.length;
while (++index < length) {
if (array[index] === value) {
return index;
}
}
return -1;
}
function baseIsNaN(value) {
return value !== value;
}
function baseTimes(n, iteratee) {
var index = -1, result = Array(n);
while (++index < n) {
result[index] = iteratee(index);
}
return result;
}
function baseValues(object, props) {
return arrayMap(props, function(key) {
return object[key];
});
}
function overArg(func, transform) {
return function(arg) {
return func(transform(arg));
};
}
var objectProto = Object.prototype;
var hasOwnProperty = objectProto.hasOwnProperty;
var objectToString = objectProto.toString;
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
var nativeKeys = overArg(Object.keys, Object);
var nativeMax = Math.max;
function arrayLikeKeys(value, inherited) {
var result = isArray(value) || isArguments(value) ? baseTimes(value.length, String) : [];
var length = result.length, skipIndexes = !!length;
for (var key in value) {
if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && (key == "length" || isIndex(key, length)))) {
result.push(key);
}
}
return result;
}
function baseKeys(object) {
if (!isPrototype(object)) {
return nativeKeys(object);
}
var result = [];
for (var key in Object(object)) {
if (hasOwnProperty.call(object, key) && key != "constructor") {
result.push(key);
}
}
return result;
}
function isIndex(value, length) {
length = length == null ? MAX_SAFE_INTEGER : length;
return !!length && (typeof value == "number" || reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
}
function isPrototype(value) {
var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto;
return value === proto;
}
function includes(collection, value, fromIndex, guard) {
collection = isArrayLike(collection) ? collection : values(collection);
fromIndex = fromIndex && !guard ? toInteger(fromIndex) : 0;
var length = collection.length;
if (fromIndex < 0) {
fromIndex = nativeMax(length + fromIndex, 0);
}
return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1;
}
function isArguments(value) {
return isArrayLikeObject(value) && hasOwnProperty.call(value, "callee") && (!propertyIsEnumerable.call(value, "callee") || objectToString.call(value) == argsTag);
}
var isArray = Array.isArray;
function isArrayLike(value) {
return value != null && isLength(value.length) && !isFunction(value);
}
function isArrayLikeObject(value) {
return isObjectLike(value) && isArrayLike(value);
}
function isFunction(value) {
var tag = isObject(value) ? objectToString.call(value) : "";
return tag == funcTag || tag == genTag;
}
function isLength(value) {
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
}
function isObject(value) {
var type = typeof value;
return !!value && (type == "object" || type == "function");
}
function isObjectLike(value) {
return !!value && typeof value == "object";
}
function isString(value) {
return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag;
}
function isSymbol(value) {
return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
}
function toFinite(value) {
if (!value) {
return value === 0 ? value : 0;
}
value = toNumber(value);
if (value === INFINITY || value === -INFINITY) {
var sign = value < 0 ? -1 : 1;
return sign * MAX_INTEGER;
}
return value === value ? value : 0;
}
function toInteger(value) {
var result = toFinite(value), remainder = result % 1;
return result === result ? remainder ? result - remainder : result : 0;
}
function toNumber(value) {
if (typeof value == "number") {
return value;
}
if (isSymbol(value)) {
return NAN;
}
if (isObject(value)) {
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
value = isObject(other) ? other + "" : other;
}
if (typeof value != "string") {
return value === 0 ? value : +value;
}
value = value.replace(reTrim, "");
var isBinary = reIsBinary.test(value);
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
}
function keys(object) {
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
}
function values(object) {
return object ? baseValues(object, keys(object)) : [];
}
module.exports = includes;
}
});
// node_modules/.pnpm/lodash.isboolean@3.0.3/node_modules/lodash.isboolean/index.js
var require_lodash2 = __commonJS({
"node_modules/.pnpm/lodash.isboolean@3.0.3/node_modules/lodash.isboolean/index.js"(exports, module) {
"use strict";
var boolTag = "[object Boolean]";
var objectProto = Object.prototype;
var objectToString = objectProto.toString;
function isBoolean(value) {
return value === true || value === false || isObjectLike(value) && objectToString.call(value) == boolTag;
}
function isObjectLike(value) {
return !!value && typeof value == "object";
}
module.exports = isBoolean;
}
});
// node_modules/.pnpm/lodash.isinteger@4.0.4/node_modules/lodash.isinteger/index.js
var require_lodash3 = __commonJS({
"node_modules/.pnpm/lodash.isinteger@4.0.4/node_modules/lodash.isinteger/index.js"(exports, module) {
"use strict";
var INFINITY = 1 / 0;
var MAX_INTEGER = 17976931348623157e292;
var NAN = 0 / 0;
var symbolTag = "[object Symbol]";
var reTrim = /^\s+|\s+$/g;
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
var reIsBinary = /^0b[01]+$/i;
var reIsOctal = /^0o[0-7]+$/i;
var freeParseInt = parseInt;
var objectProto = Object.prototype;
var objectToString = objectProto.toString;
function isInteger(value) {
return typeof value == "number" && value == toInteger(value);
}
function isObject(value) {
var type = typeof value;
return !!value && (type == "object" || type == "function");
}
function isObjectLike(value) {
return !!value && typeof value == "object";
}
function isSymbol(value) {
return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
}
function toFinite(value) {
if (!value) {
return value === 0 ? value : 0;
}
value = toNumber(value);
if (value === INFINITY || value === -INFINITY) {
var sign = value < 0 ? -1 : 1;
return sign * MAX_INTEGER;
}
return value === value ? value : 0;
}
function toInteger(value) {
var result = toFinite(value), remainder = result % 1;
return result === result ? remainder ? result - remainder : result : 0;
}
function toNumber(value) {
if (typeof value == "number") {
return value;
}
if (isSymbol(value)) {
return NAN;
}
if (isObject(value)) {
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
value = isObject(other) ? other + "" : other;
}
if (typeof value != "string") {
return value === 0 ? value : +value;
}
value = value.replace(reTrim, "");
var isBinary = reIsBinary.test(value);
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
}
module.exports = isInteger;
}
});
// node_modules/.pnpm/lodash.isnumber@3.0.3/node_modules/lodash.isnumber/index.js
var require_lodash4 = __commonJS({
"node_modules/.pnpm/lodash.isnumber@3.0.3/node_modules/lodash.isnumber/index.js"(exports, module) {
"use strict";
var numberTag = "[object Number]";
var objectProto = Object.prototype;
var objectToString = objectProto.toString;
function isObjectLike(value) {
return !!value && typeof value == "object";
}
function isNumber(value) {
return typeof value == "number" || isObjectLike(value) && objectToString.call(value) == numberTag;
}
module.exports = isNumber;
}
});
// node_modules/.pnpm/lodash.isplainobject@4.0.6/node_modules/lodash.isplainobject/index.js
var require_lodash5 = __commonJS({
"node_modules/.pnpm/lodash.isplainobject@4.0.6/node_modules/lodash.isplainobject/index.js"(exports, module) {
"use strict";
var objectTag = "[object Object]";
function isHostObject(value) {
var result = false;
if (value != null && typeof value.toString != "function") {
try {
result = !!(value + "");
} catch (e) {
}
}
return result;
}
function overArg(func, transform) {
return function(arg) {
return func(transform(arg));
};
}
var funcProto = Function.prototype;
var objectProto = Object.prototype;
var funcToString = funcProto.toString;
var hasOwnProperty = objectProto.hasOwnProperty;
var objectCtorString = funcToString.call(Object);
var objectToString = objectProto.toString;
var getPrototype = overArg(Object.getPrototypeOf, Object);
function isObjectLike(value) {
return !!value && typeof value == "object";
}
function isPlainObject(value) {
if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) {
return false;
}
var proto = getPrototype(value);
if (proto === null) {
return true;
}
var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
}
module.exports = isPlainObject;
}
});
// node_modules/.pnpm/lodash.isstring@4.0.1/node_modules/lodash.isstring/index.js
var require_lodash6 = __commonJS({
"node_modules/.pnpm/lodash.isstring@4.0.1/node_modules/lodash.isstring/index.js"(exports, module) {
"use strict";
var stringTag = "[object String]";
var objectProto = Object.prototype;
var objectToString = objectProto.toString;
var isArray = Array.isArray;
function isObjectLike(value) {
return !!value && typeof value == "object";
}
function isString(value) {
return typeof value == "string" || !isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag;
}
module.exports = isString;
}
});
// node_modules/.pnpm/lodash.once@4.1.1/node_modules/lodash.once/index.js
var require_lodash7 = __commonJS({
"node_modules/.pnpm/lodash.once@4.1.1/node_modules/lodash.once/index.js"(exports, module) {
"use strict";
var FUNC_ERROR_TEXT = "Expected a function";
var INFINITY = 1 / 0;
var MAX_INTEGER = 17976931348623157e292;
var NAN = 0 / 0;
var symbolTag = "[object Symbol]";
var reTrim = /^\s+|\s+$/g;
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
var reIsBinary = /^0b[01]+$/i;
var reIsOctal = /^0o[0-7]+$/i;
var freeParseInt = parseInt;
var objectProto = Object.prototype;
var objectToString = objectProto.toString;
function before(n, func) {
var result;
if (typeof func != "function") {
throw new TypeError(FUNC_ERROR_TEXT);
}
n = toInteger(n);
return function() {
if (--n > 0) {
result = func.apply(this, arguments);
}
if (n <= 1) {
func = void 0;
}
return result;
};
}
function once(func) {
return before(2, func);
}
function isObject(value) {
var type = typeof value;
return !!value && (type == "object" || type == "function");
}
function isObjectLike(value) {
return !!value && typeof value == "object";
}
function isSymbol(value) {
return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
}
function toFinite(value) {
if (!value) {
return value === 0 ? value : 0;
}
value = toNumber(value);
if (value === INFINITY || value === -INFINITY) {
var sign = value < 0 ? -1 : 1;
return sign * MAX_INTEGER;
}
return value === value ? value : 0;
}
function toInteger(value) {
var result = toFinite(value), remainder = result % 1;
return result === result ? remainder ? result - remainder : result : 0;
}
function toNumber(value) {
if (typeof value == "number") {
return value;
}
if (isSymbol(value)) {
return NAN;
}
if (isObject(value)) {
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
value = isObject(other) ? other + "" : other;
}
if (typeof value != "string") {
return value === 0 ? value : +value;
}
value = value.replace(reTrim, "");
var isBinary = reIsBinary.test(value);
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
}
module.exports = once;
}
});
// node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/sign.js
var require_sign = __commonJS({
"node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/sign.js"(exports, module) {
"use strict";
var timespan = require_timespan();
var PS_SUPPORTED = require_psSupported();
var jws = require_jws();
var includes = require_lodash();
var isBoolean = require_lodash2();
var isInteger = require_lodash3();
var isNumber = require_lodash4();
var isPlainObject = require_lodash5();
var isString = require_lodash6();
var once = require_lodash7();
var SUPPORTED_ALGS = ["RS256", "RS384", "RS512", "ES256", "ES384", "ES512", "HS256", "HS384", "HS512", "none"];
if (PS_SUPPORTED) {
SUPPORTED_ALGS.splice(3, 0, "PS256", "PS384", "PS512");
}
var sign_options_schema = {
expiresIn: { isValid: function(value) {
return isInteger(value) || isString(value) && value;
}, message: '"expiresIn" should be a number of seconds or string representing a timespan' },
notBefore: { isValid: function(value) {
return isInteger(value) || isString(value) && value;
}, message: '"notBefore" should be a number of seconds or string representing a timespan' },
audience: { isValid: function(value) {
return isString(value) || Array.isArray(value);
}, message: '"audience" must be a string or array' },
algorithm: { isValid: includes.bind(null, SUPPORTED_ALGS), message: '"algorithm" must be a valid string enum value' },
header: { isValid: isPlainObject, message: '"header" must be an object' },
encoding: { isValid: isString, message: '"encoding" must be a string' },
issuer: { isValid: isString, message: '"issuer" must be a string' },
subject: { isValid: isString, message: '"subject" must be a string' },
jwtid: { isValid: isString, message: '"jwtid" must be a string' },
noTimestamp: { isValid: isBoolean, message: '"noTimestamp" must be a boolean' },
keyid: { isValid: isString, message: '"keyid" must be a string' },
mutatePayload: { isValid: isBoolean, message: '"mutatePayload" must be a boolean' }
};
var registered_claims_schema = {
iat: { isValid: isNumber, message: '"iat" should be a number of seconds' },
exp: { isValid: isNumber, message: '"exp" should be a number of seconds' },
nbf: { isValid: isNumber, message: '"nbf" should be a number of seconds' }
};
function validate(schema, allowUnknown, object, parameterName) {
if (!isPlainObject(object)) {
throw new Error('Expected "' + parameterName + '" to be a plain object.');
}
Object.keys(object).forEach(function(key) {
var validator = schema[key];
if (!validator) {
if (!allowUnknown) {
throw new Error('"' + key + '" is not allowed in "' + parameterName + '"');
}
return;
}
if (!validator.isValid(object[key])) {
throw new Error(validator.message);
}
});
}
function validateOptions(options) {
return validate(sign_options_schema, false, options, "options");
}
function validatePayload(payload) {
return validate(registered_claims_schema, true, payload, "payload");
}
var options_to_payload = {
"audience": "aud",
"issuer": "iss",
"subject": "sub",
"jwtid": "jti"
};
var options_for_objects = [
"expiresIn",
"notBefore",
"noTimestamp",
"audience",
"issuer",
"subject",
"jwtid"
];
module.exports = function(payload, secretOrPrivateKey, options, callback) {
if (typeof options === "function") {
callback = options;
options = {};
} else {
options = options || {};
}
var isObjectPayload = typeof payload === "object" && !Buffer.isBuffer(payload);
var header = Object.assign({
alg: options.algorithm || "HS256",
typ: isObjectPayload ? "JWT" : void 0,
kid: options.keyid
}, options.header);
function failure(err) {
if (callback) {
return callback(err);
}
throw err;
}
if (!secretOrPrivateKey && options.algorithm !== "none") {
return failure(new Error("secretOrPrivateKey must have a value"));
}
if (typeof payload === "undefined") {
return failure(new Error("payload is required"));
} else if (isObjectPayload) {
try {
validatePayload(payload);
} catch (error) {
return failure(error);
}
if (!options.mutatePayload) {
payload = Object.assign({}, payload);
}
} else {
var invalid_options = options_for_objects.filter(function(opt) {
return typeof options[opt] !== "undefined";
});
if (invalid_options.length > 0) {
return failure(new Error("invalid " + invalid_options.join(",") + " option for " + typeof payload + " payload"));
}
}
if (typeof payload.exp !== "undefined" && typeof options.expiresIn !== "undefined") {
return failure(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));
}
if (typeof payload.nbf !== "undefined" && typeof options.notBefore !== "undefined") {
return failure(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));
}
try {
validateOptions(options);
} catch (error) {
return failure(error);
}
var timestamp = payload.iat || Math.floor(Date.now() / 1e3);
if (options.noTimestamp) {
delete payload.iat;
} else if (isObjectPayload) {
payload.iat = timestamp;
}
if (typeof options.notBefore !== "undefined") {
try {
payload.nbf = timespan(options.notBefore, timestamp);
} catch (err) {
return failure(err);
}
if (typeof payload.nbf === "undefined") {
return failure(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));
}
}
if (typeof options.expiresIn !== "undefined" && typeof payload === "object") {
try {
payload.exp = timespan(options.expiresIn, timestamp);
} catch (err) {
return failure(err);
}
if (typeof payload.exp === "undefined") {
return failure(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));
}
}
Object.keys(options_to_payload).forEach(function(key) {
var claim = options_to_payload[key];
if (typeof options[key] !== "undefined") {
if (typeof payload[claim] !== "undefined") {
return failure(new Error('Bad "options.' + key + '" option. The payload already has an "' + claim + '" property.'));
}
payload[claim] = options[key];
}
});
var encoding = options.encoding || "utf8";
if (typeof callback === "function") {
callback = callback && once(callback);
jws.createSign({
header,
privateKey: secretOrPrivateKey,
payload,
encoding
}).once("error", callback).once("done", function(signature) {
callback(null, signature);
});
} else {
return jws.sign({ header, payload, secret: secretOrPrivateKey, encoding });
}
};
}
});
// node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/index.js
var require_jsonwebtoken = __commonJS({
"node_modules/.pnpm/jsonwebtoken@8.5.1/node_modules/jsonwebtoken/index.js"(exports, module) {
"use strict";
module.exports = {
decode: require_decode(),
verify: require_verify(),
sign: require_sign(),
JsonWebTokenError: require_JsonWebTokenError(),
NotBeforeError: require_NotBeforeError(),
TokenExpiredError: require_TokenExpiredError()
};
}
});
// src/submit.ts
import { Listr } from "listr2";
// src/chrome/chrome-api.ts
import { FormData } from "formdata-node";
import { fileFromPath } from "formdata-node/file-from-path";
// src/utils/fetch.ts
import { createFetch } from "ofetch";
var fetch = createFetch({
defaults: {
onResponseError: (ctx) => {
console.log("Request:", ctx.request);
console.log("Response:", JSON.stringify(ctx.response, null, 2));
}
}
});
// src/chrome/chrome-api.ts
var CwsApi = class {
constructor(options) {
this.options = options;
}
tokenEndpoint() {
return new URL("https://oauth2.googleapis.com/token");
}
uploadEndpoint(extensionId) {
return new URL(
`https://www.googleapis.com/upload/chromewebstore/v1.1/items/${extensionId}`
);
}
publishEndpoint(extensionId) {
return new URL(
`https://www.googleapis.com/chromewebstore/v1.1/items/${extensionId}/publish`
);
}
async uploadZip(params) {
const Authorization = await this.getAuthHeader(params.token);
const endpoint = this.uploadEndpoint(params.extensionId);
const form = new FormData();
form.append("image", await fileFromPath(params.zipFile));
await fetch(endpoint.href, {
method: "PUT",
body: form,
headers: {
Authorization,
"x-goog-api-version": "2"
}
});
}
async submitForReview(params) {
const Authorization = await this.getAuthHeader(params.token);
const endpoint = this.publishEndpoint(params.extensionId);
if (params.publishTarget)
endpoint.searchParams.append("publishTarget", params.publishTarget);
if (params.deployPercentage != null)
endpoint.searchParams.set(
"deployPercentage",
String(params.deployPercentage)
);
if (params.reviewExemption != null)
endpoint.searchParams.set(
"reviewExemption",
String(params.reviewExemption)
);
await fetch(endpoint.href, {
method: "POST",
headers: {
Authorization,
"x-goog-api-version": "2",
"Content-Length": "0"
}
});
}
getToken() {
const endpoint = this.tokenEndpoint();
return fetch(endpoint.href, {
method: "POST",
body: JSON.stringify({
client_id: this.options.clientId,
client_secret: this.options.clientSecret,
refresh_token: this.options.refreshToken,
grant_type: "refresh_token",
redirect_uri: "urn:ietf:wg:oauth:2.0:oob"
})
});
}
async getAuthHeader(token) {
return `${token.token_type} ${token.access_token}`;
}
};
// src/chrome/chrome-web-store.ts
import { z } from "zod";
// src/utils/fs.ts
import fs from "node:fs/promises";
async function ensureZipExists(path) {
try {
await fs.lstat(path);
} catch {
throw Error("ZIP file does not exist: " + path);
}
}
// src/chrome/chrome-web-store.ts
var ChromeWebStoreOptions = z.object({
zip: z.string().min(1),
extensionId: z.string().min(1).trim(),
clientId: z.string().min(1).trim(),
clientSecret: z.string().min(1).trim(),
refreshToken: z.string().min(1).trim(),
publishTarget: z.enum(["default", "trustedTesters"]).default("default"),
deployPercentage: z.number().int().min(1).max(100).optional(),
reviewExemption: z.boolean().default(false),
skipSubmitReview: z.boolean().default(false)
});
var ChromeWebStore = class {
constructor(options, setStatus) {
this.options = options;
this.setStatus = setStatus;
}
async submit(dryRun) {
const api = new CwsApi(this.options);
this.setStatus("Getting an access token");
const token = await api.getToken();
if (dryRun) {
this.setStatus("DRY RUN: Skipped upload and publishing");
return;
}
this.setStatus("Uploading new ZIP file");
await api.uploadZip({
extensionId: this.options.extensionId,
zipFile: this.options.zip,
token
});
if (this.options.skipSubmitReview) {
this.setStatus("Skipping submission (skipSubmitReview=true)");
return;
}
this.setStatus("Submitting for review");
await api.submitForReview({
extensionId: this.options.extensionId,
publishTarget: this.options.publishTarget,
token,
deployPercentage: this.options.deployPercentage,
reviewExemption: this.options.reviewExemption
});
}
async ensureZipsExist() {
await ensureZipExists(this.options.zip);
}
};
// src/config.ts
import { z as z4 } from "zod";
// src/edge/edge-api.ts
import fs2 from "fs";
var EdgeApi = class {
constructor(options) {
this.options = options;
}
/**
* Docs: https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/api/using-addons-api#sample-request
*/
getToken() {
return Promise.resolve({
access_token: this.options.apiKey,
expires_in: 0,
token_type: "ApiKey"
});
}
/**
* Docs: https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/api/using-addons-api#uploading-a-package-to-update-an-existing-submission
*/
async uploadDraft(params) {
const endpoint = `https://api.addons.microsoftedge.microsoft.com/v1/products/${params.productId}/submissions/draft/package`;
const file = fs2.createReadStream(params.zipFile);
const res = await fetch.raw(endpoint, {
method: "POST",
body: file,
headers: {
...this.getAuthHeaders(params.token),
"Content-Type": "application/zip"
}
});
const operationId = res.headers.get("Location");
if (!operationId)
throw Error(
"Edge API did not return an operation ID in the Location header."
);
return { operationId };
}
/**
* Docs: https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/api/using-addons-api#checking-the-status-of-a-package-upload
*/
uploadDraftOperation(params) {
const endpoint = `https://api.addons.microsoftedge.microsoft.com/v1/products/${params.productId}/submissions/draft/package/operations/${params.operationId}`;
return fetch(endpoint, {
headers: this.getAuthHeaders(params.token)
});
}
/**
* Docs: https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/api/using-addons-api#publishing-the-submission
*/
async publish(params) {
const endpoint = `https://api.addons.microsoftedge.microsoft.com/v1/products/${params.productId}/submissions`;
const res = await fetch(endpoint, {
method: "POST",
body: JSON.stringify({}),
headers: this.getAuthHeaders(params.token)
});
}
getAuthHeaders(token) {
return {
Authorization: `${token.token_type} ${token.access_token}`,
...token.token_type === "ApiKey" ? { "X-ClientID": this.options.clientId } : {}
};
}
};
// src/utils/sleep.ts
function sleep(ms) {
return new Promise((res) => setTimeout(res, ms));
}
// src/utils/withTimeout.ts
function withTimeout(promise, ms) {
return new Promise((res, rej) => {
const timeout = setTimeout(() => rej(`Timed out after ${ms}ms`), ms);
promise.then(res, rej).finally(() => clearTimeout(timeout));
});
}
// src/edge/edge-addon-store.ts
import { z as z2 } from "zod";
var EdgeAddonStoreOptions = z2.object({
zip: z2.string().min(1),
productId: z2.string().min(1).trim(),
clientId: z2.string().min(1).trim(),
skipSubmitReview: z2.boolean().default(false),
apiKey: z2.string().min(1).trim(),
/** @deprecated: API v1.0 authorization field no longer in use. */
clientSecret: z2.string().optional(),
/** @deprecated: API v1.0 authorization field no longer in use. */
accessTokenUrl: z2.string().optional()
});
var EdgeAddonStore = class {
constructor(options, setStatus) {
this.options = options;
this.setStatus = setStatus;
this.api = new EdgeApi(options);
}
api;
async ensureZipsExist() {
await ensureZipExists(this.options.zip);
}
async submit(dryRun) {
this.setStatus("Getting authorization token");
const token = await this.api.getToken();
if (dryRun) {
this.setStatus("DRY RUN: Skipped upload and publishing");
return;
}
const pollInterval = 5e3;
const timeout = 10 * 6e4;
const uploadPromise = this.uploadAndPollValidation(token, pollInterval);
await withTimeout(uploadPromise, timeout);
if (this.options.skipSubmitReview) {
this.setStatus("Skipping submission (skipSubmitReview=true)");
return;
}
this.setStatus("Submitting new version");
await this.api.publish({
token,
productId: this.options.productId
});
}
async uploadAndPollValidation(token, pollIntervalMs) {
this.setStatus("Uploading new ZIP file");
const { operationId } = await this.api.uploadDraft({
token,
productId: this.options.productId,
zipFile: this.options.zip
});
this.setStatus("Waiting for validation results");
let operation;
do {
await sleep(pollIntervalMs);
operation = await this.api.uploadDraftOperation({
token,
operationId,
productId: this.options.productId
});
} while (operation.status === "InProgress");
if (operation.status === "Failed") {
throw Error(`Validation failed: ${JSON.stringify(operation, null, 2)}`);
} else {
this.setStatus("Extension is valid");
}
}
};
// src/firefox/firefox-api.ts
var import_jsonwebtoken = __toESM(require_jsonwebtoken(), 1);
import { FormData as FormData2 } from "formdata-node";
import { fileFromPath as fileFromPath2 } from "formdata-node/file-from-path";
var AddonsApi = class {
constructor(options) {
this.options = options;
}
addonDetailEndpoint(extensionId) {
return new URL(
`https://addons.mozilla.org/api/v5/addons/addon/${extensionId}`
);
}
addonsUploadCreateEndpoint() {
return new URL(`https://addons.mozilla.org/api/v5/addons/upload/`);
}
addonsUploadDetailsEndpoint(uploadUuid) {
return new URL(
`https://addons.mozilla.org/api/v5/addons/upload/${uploadUuid}`
);
}
addonVersionCreateEndpoint(extensionId) {
return new URL(
`https://addons.mozilla.org/api/v5/addons/addon/${extensionId}/versions/`
);
}
/**
* Docs: https://addons-server.readthedocs.io/en/latest/topics/api/addons.html#detail
*/
details(params) {
const endpoint = this.addonDetailEndpoint(params.extensionId);
return fetch(endpoint.href, {
headers: {
Authorization: this.getAuthHeader()
}
});
}
/**
* Docs: https://addons-server.readthedocs.io/en/latest/topics/api/addons.html#upload-create
*/
async uploadCreate(params) {
const endpoint = this.addonsUploadCreateEndpoint();
const form = new FormData2();
form.append("channel", params.channel);
form.append("upload", await fileFromPath2(params.file));
return await fetch(endpoint.href, {
method: "POST",
body: form,
headers: {
Authorization: this.getAuthHeader()
}
});
}
/**
* Docs: https://addons-server.readthedocs.io/en/latest/topics/api/addons.html#upload-detail
*/
uploadDetail(params) {
const endpoint = this.addonsUploadDetailsEndpoint(params.uuid);
return fetch(endpoint.href, {
headers: {
Authorization: this.getAuthHeader()
}
});
}
async versionCreate(params) {
const endpoint = this.addonVersionCreateEndpoint(params.extensionId);
const form = new FormData2();
form.append("upload", params.uploadUuid);
if (params.sourceFile) {
form.append("source", await fileFromPath2(params.sourceFile));
} else {
form.append("source", "");
}
return await fetch(endpoint.href, {
method: "POST",
body: form,
headers: {
Authorization: this.getAuthHeader()
}
});
}
/**
* See https://addons-server.readthedocs.io/en/latest/topics/api/auth.html
*/
createJwt(timeoutInS = 30) {
const issuedAt = Math.floor(Date.now() / 1e3);
const payload = {
iss: this.options.jwtIssuer,
jti: Math.random().toString(),
iat: issuedAt,
exp: issuedAt + timeoutInS
};
const secret = this.options.jwtSecret ?? "";
return import_jsonwebtoken.default.sign(payload, secret, { algorithm: "HS256" });
}
getAuthHeader() {
return `JWT ${this.createJwt()}`;
}
};
// src/utils/plural.ts
function plural(count, word, pluralForm) {
if (count === 1)
return `${count} ${word}`;
return `${count} ${pluralForm ?? `${word}s`}`;
}
// src/firefox/firefox-addon-store.ts
import { z as z3 } from "zod";
var FirefoxAddonStoreOptions = z3.object({
zip: z3.string().min(1),
sourcesZip: z3.string().min(1).optional(),
extensionId: z3.string().min(1).trim(),
jwtIssuer: z3.string().min(1).trim(),
jwtSecret: z3.string().min(1).trim(),
channel: z3.enum(["listed", "unlisted"]).default("listed")
});
var FirefoxAddonStore = class {
constructor(options, setStatus) {
this.options = options;
this.setStatus = setStatus;
this.api = new AddonsApi(options);
}
api;
async ensureZipsExist() {
await ensureZipExists(this.options.zip);
if (this.options.sourcesZip) {
await ensureZipExists(this.options.sourcesZip);
}
}
async submit(dryRun) {
this.setStatus("Getting addon details");
const addon = await this.api.details({
extensionId: this.wrappedExtensionId
});
if (dryRun) {
this.setStatus("DRY RUN: Skipped upload and publishing");
return;
}
const pollInterval = 5e3;
const timeout = 10 * 6e4;
const uploadPromise = this.uploadAndPollValidation(pollInterval);
const upload = await withTimeout(uploadPromise, timeout);
this.setStatus("Submitting new version");
const version = await this.api.versionCreate({
extensionId: this.wrappedExtensionId,
sourceFile: this.options.sourcesZip,
uploadUuid: upload.uuid
});
const validationUrl = `https://addons.mozilla.org/en-US/developers/addon/${addon.id}/file/${version.file.id}/validation`;
const { errors, notices, warnings } = upload.validation;
this.setStatus(
`Validation results: ${plural(errors, "error")}, ${plural(
warnings,
"warning"
)}, ${plural(notices, "notice")}`
);
if (!upload.valid)
throw Error(`Extension is invalid: ${validationUrl}`);
else
console.log("Firefox validation results: " + validationUrl);
}
async uploadAndPollValidation(pollIntervalMs) {
this.setStatus("Uploading new ZIP file");
let details = await this.api.uploadCreate({
file: this.options.zip,
channel: this.options.channel
});
this.setStatus("Waiting for validation results");
while (!details.processed) {
await sleep(pollIntervalMs);
details = await this.api.uploadDetail(details);
}
return details;
}
/**
* Ensure the extension id is wrapped in curly braces, that's what the addon store API is expecting
* @example
* "test" -> "{test}"
*/
get wrappedExtensionId() {
let id = this.options.extensionId;
if (id.includes("@"))
return id;
if (!id.startsWith("{"))
id = "{" + id;
if (!id.endsWith("}"))
id += "}";
return id;
}
};
// src/config.ts
function resolveConfig(config) {
const dryRun = config.dryRun ?? booleanEnv("DRY_RUN") ?? false;
const chromeZip = config.chrome?.zip ?? stringEnv("CHROME_ZIP");
const firefoxZip = config.firefox?.zip ?? stringEnv("FIREFOX_ZIP");
const edgeZip = config.edge?.zip ?? stringEnv("EDGE_ZIP");
return {
dryRun,
chrome: chromeZip == null ? void 0 : {
zip: chromeZip,
extensionId: config.chrome?.extensionId ?? stringEnv("CHROME_EXTENSION_ID"),
clientId: config.chrome?.clientId ?? stringEnv("CHROME_CLIENT_ID"),
clientSecret: config.chrome?.clientSecret ?? stringEnv("CHROME_CLIENT_SECRET"),
refreshToken: config.chrome?.refreshToken ?? stringEnv("CHROME_REFRESH_TOKEN"),
publishTarget: config.chrome?.publishTarget ?? stringEnv("CHROME_PUBLISH_TARGET") ?? "default",
deployPercentage: config.chrome?.deployPercentage ?? intEnv("CHROME_DEPLOY_PERCENTAGE"),
reviewExemption: config.chrome?.reviewExemption ?? booleanEnv("CHROME_REVIEW_EXEMPTION") ?? false,
skipSubmitReview: config.chrome?.skipSubmitReview ?? booleanEnv("CHROME_SKIP_SUBMIT_REVIEW") ?? false
},
firefox: firefoxZip == null ? void 0 : {
zip: firefoxZip,
sourcesZip: config.firefox?.sourcesZip ?? stringEnv("FIREFOX_SOURCES_ZIP"),
extensionId: config.firefox?.extensionId ?? stringEnv("FIREFOX_EXTENSION_ID"),
jwtIssuer: config.firefox?.jwtIssuer ?? stringEnv("FIREFOX_JWT_ISSUER"),
jwtSecret: config.firefox?.jwtSecret ?? stringEnv("FIREFOX_JWT_SECRET"),
channel: config.firefox?.channel ?? stringEnv("FIREFOX_CHANNEL") ?? "listed"
},
edge: edgeZip == null ? void 0 : {
zip: edgeZip,
productId: config.edge?.productId ?? stringEnv("EDGE_PRODUCT_ID"),
clientId: config.edge?.clientId ?? stringEnv("EDGE_CLIENT_ID"),
apiKey: config.edge?.apiKey ?? stringEnv("EDGE_API_KEY"),
clientSecret: config.edge?.clientSecret ?? stringEnv("EDGE_CLIENT_SECRET"),
accessTokenUrl: config.edge?.accessTokenUrl ?? stringEnv("EDGE_ACCESS_TOKEN_URL"),
skipSubmitReview: config.edge?.skipSubmitReview ?? booleanEnv("EDGE_SKIP_SUBMIT_REVIEW") ?? false
}
};
}
function toScreamingSnakeCase(str) {
return str.replace(/([A-Z])/g, "_$1").replace(/-/g, "_").toUpperCase();
}
function validateConfig(config) {
const result = InternalConfig.safeParse(config);
if (!result.success) {
throw Error(
"Missing required config: " + result.error.errors.map((i) => i.path.map((j) => toScreamingSnakeCase(String(j))).join("_")).join(", "),
{ cause: result.error }
);
}
return result.data;
}
function booleanEnv(name) {
return !process.env[name] ? void 0 : process.env[name] === "true";
}
function stringEnv(name) {
return !process.env[name] ? void 0 : process.env[name];
}
function intEnv(name) {
return !process.env[name] ? void 0 : parseInt(process.env[name]);
}
var InlineConfig = z4.object({
/**
* When true, just check authentication, don't upload any zip files or submit any updates.
*/
dryRun: z4.boolean().optional(),
/**
* Options for publishing to chrome.
*/
chrome: ChromeWebStoreOptions.partial().optional(),
/**
* Options for publishing to Firefox.
*/
firefox: FirefoxAddonStoreOptions.partial().optional(),
/**
* Options for publishing to Edge.
*/
edge: EdgeAddonStoreOptions.partial().optional()
});
var InternalConfig = z4.object({
dryRun: z4.boolean(),
chrome: ChromeWebStoreOptions.optional(),
firefox: FirefoxAddonStoreOptions.optional(),
edge: EdgeAddonStoreOptions.optional()
});
// src/submit.ts
import consola from "consola";
async function submit(config) {
const internalConfig = validateConfig(resolveConfig(config));
console.log("");
consola.info("Publishing Extension");
if (internalConfig.dryRun) {
consola.warn("Dry run, skipping submission");
}
if (internalConfig.edge?.clientSecret || internalConfig.edge?.accessTokenUrl) {
consola.warn(
[
"Edge API v1.0 was deprecated Jan 1, 2025. v1.1 of the API requires different authentication. To upgrade:",
" 1. Remove the `--edge-client-secret` or `EDGE_CLIENT_SECRET` environment variable",
" 2. Remove the `--edge-access-token-url` or `EDGE_ACCESS_TOKEN_URL` environment variable",
" 3. Follow the instructions below to add the `--edge-api-key` flag or `EDGE_API_KEY` environment variable",
"Or run `publish-extension init` and re-initialize the edge store.",
"",
"To generate an API key:",
" 1. Visit https://partner.microsoft.com/en-us/dashboard/microsoftedge/publishapi",
" 2. Enable the v1.1 API if necessary",
" 3. Create an new API key",
"",
"Refer to Microsoft API reference for more details: https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/api/using-addons-api?tabs=v1-1#overview-of-using-the-update-rest-api"
].join("\n")
);
}
const stores = [];
if (internalConfig.chrome) {
stores.push({
id: "chrome",
name: "Chrome Web Store",
getStore: (setStatus) => new ChromeWebStore(internalConfig.chrome, setStatus)
});
}
if (internalConfig.firefox) {
stores.push({
id: "firefox",
name: "Firefox Addon Store",
getStore: (setStatus) => new FirefoxAddonStore(internalConfig.firefox, setStatus)
});
}
if (internalConfig.edge) {
stores.push({
id: "edge",
name: "Edge Addon Store",
getStore: (setStatus) => new EdgeAddonStore(internalConfig.edge, setStatus)
});
}
if (stores.length === 0) {
throw Error("No ZIP files detected to upload");
}
const results = {};
const tasks = new Listr(
stores.map(({ id, name, getStore }) => ({
title: name,
async task(_ctx, task) {
try {
const setStatus = (text) => {
task.output = `[${id}] ${text}`;
};
const store = getStore(setStatus);
setStatus("Checking ZIP files exist");
await store.ensureZipsExist();
await store.submit(internalConfig.dryRun);
results[id] = { success: true };
} catch (err) {
consola.error(err);
results[id] = { success: false, err };
throw err;
}
}
})),
{
exitOnError: false,
collectErrors: "minimal",
concurrent: true
}
);
await tasks.run();
const errors = Object.entries(results).filter(([_id, result]) => {
return !result.success;
});
if (errors.length > 0) {
throw Error(`Submissions failed: ${errors.length}`, { cause: errors });
}
return results;
}
// src/init.ts
import consola2 from "consola";
import { copyFile, writeFile, readFile } from "node:fs/promises";
import { ofetch } from "ofetch";
var envFile = ".env.submit";
async function init(config) {
consola2.info(`Initialize or update an existing \`${envFile}\` file.`);
const previousConfig = resolveConfig(config);
const stores = await prompt(
"What stores do you want to configure?",
{
type: "multiselect",
options: [
{ value: "chrome", label: "Chrome Web Store" },
{ value: "firefox", label: "Firefox Addon Store" },
{ value: "edge", label: "Edge Addon Store" }
],
required: false
}
);
const replacements = [];
if (stores?.includes("chrome")) {
replacements.push(...await initChrome(previousConfig.chrome));
}
if (stores?.includes("firefox")) {
replacements.push(...await initFirefox(previousConfig.firefox));
}
if (stores?.includes("edge")) {
replacements.push(...await initEdge(previousConfig.edge));
}
await updateEnvFile(replacements);
console.log();
consola2.log(
"To submit an update, run:\n\n `publish-extension --chrome-zip path/to/extension.zip \\`\n `--firefox-zip path/to/extension.zip \\`\n `--edge-zip path/to/extension.zip`"
);
}
async function prompt(message, options, previousValue) {
let result = await consola2.prompt(message, {
default: previousValue,
placeholder: previousValue,
...options
});
if (typeof result === "symbol") {
throw Error("Canceled");
}
if (typeof result === "string") {
result = result.trim();
}
return result;
}
async function initChrome(previousOptions) {
const entries = [];
console.log();
consola2.start("Chrome Web Store\n");
consola2.log("`--chrome-extension-id` can be found:");
consola2.log(" 1. Under the extension name in the CWS developer console");
consola2.log(" 2. In the URL of the CWS page for the item");
consola2.log("Example: `ocfdgncpifmegplaglcnglhioflaimkd`");
const extensionId = await prompt(
"Enter the extension ID:",
{
type: "text"
},
previousOptions?.extensionId
);
entries.push(["CHROME_EXTENSION_ID", extensionId]);
console.log();
consola2.log(
'`--chrome-client-id` and `--chrome-client-secret` are generated by following the "Initial Setup" from:'
);
console.log("https://developer.chrome.com/docs/webstore/using-api#setup");
const clientId = await prompt(
"Enter your client ID:",
{ type: "text" },
previousOptions?.clientId
);
entries.push(["CHROME_CLIENT_ID", clientId]);
const clientSecret = await prompt(
"Enter your client secret:",
{ type: "text" },
previousOptions?.clientSecret
);
entries.push(["CHROME_CLIENT_SECRET", clientSecret]);
const generateRefreshToken = await prompt(
"Generate new refresh token?",
{ type: "confirm" }
);
if (generateRefreshToken) {
const authCodeUrl = `https://accounts.google.com/o/oauth2/auth?response_type=code&scope=https://www.googleapis.com/auth/chromewebstore&client_id=${clientId}&redirect_uri=urn:ietf:wg:oauth:2.0:oob`;
consola2.log(authCodeUrl);
const authCode = await consola2.prompt(
"Open the above URL, login, and enter the auth code:",
{
type: "text",
required: true
}
);
const data = new URLSearchParams();
data.set("client_id", clientId);
data.set("client_secret", clientSecret);
data.set("code", authCode);
data.set("grant_type", "authorization_code");
data.set("redirect_uri", "urn:ietf:wg:oauth:2.0:oob");
const tokenUrl = `https://accounts.google.com/o/oauth2/token`;
const res = await ofetch(tokenUrl, {
method: "POST",
body: data
});
const refreshToken = res.refresh_token;
consola2.info(`Refresh token: \`${refreshToken}\``);
entries.push(["CHROME_REFRESH_TOKEN", refreshToken]);
}
const publishTarget = await prompt(
"`--chrome-publish-target`: Where do you want to release to?",
{
type: "select",
options: [
{
label: "Default",
value: "default",
hint: "Public release channel"
},
{
label: "Trusted Testers",
value: "trustedTesters",
hint: "Prerelease, internal channel"
}
],
initial: previousOptions?.publishTarget
},
previousOptions?.publishTarget
);
entries.push(["CHROME_PUBLISH_TARGET", publishTarget]);
const submitForReview = await prompt(
"When uploading, automatically submit new update for review?",
{ type: "confirm" },
!previousOptions?.skipSubmitReview
);
entries.push(["CHROME_SKIP_SUBMIT_REVIEW", !submitForReview]);
return entries;
}
async function initFirefox(previousOptions) {
const entries = [];
console.log();
consola2.start("Firefox Addon Store\n");
consola2.info(
"Your `--firefox-extension-id` is listed at the bottom of the details page on:"
);
console.log("https://addons.mozilla.org/en-US/developers/");
const extensionId = await prompt(
"Enter extension ID:",
{
type: "text"
},
previousOptions?.extensionId
);
entries.push(["FIREFOX_EXTENSION_ID", extensionId]);
console.log();
consola2.log(
"`--firefox-jwt-issuer` and `--firefox-jwt-secret` are available at:"
);
console.log("https://addons.mozilla.org/developers/addon/api/key/");
const jwtIssuer = await prompt(
"Enter your JWT issuer:",
{ type: "text" },
previousOptions?.jwtIssuer
);
entries.push(["FIREFOX_JWT_ISSUER", jwtIssuer]);
const jwtSecret = await prompt(
"Enter your JWT secret:",
{ type: "text" },
previousOptions?.jwtSecret
);
entries.push(["FIREFOX_JWT_SECRET", jwtSecret]);
const channel = await prompt(
"`--firefox-channel`: Which channel do you want to release to?",
{
type: "select",
options: [
{
label: "Listed",
value: "listed",
hint: "Hosted on addons.mozilla.com"
},
{ label: "Unlisted", value: "unlisted", hint: "For self-hosting" }
],
initial: previousOptions?.channel
},
previousOptions?.channel
);
entries.push(["FIREFOX_CHANNEL", channel]);
return entries;
}
async function initEdge(previousOptions) {
const entries = [];
console.log();
consola2.start("Edge Addon Store\n");
consola2.info(
"Your `--edge-product-id` is listed On the developer dashboard, at the top of the page under the extension name"
);
console.log("https://partner.microsoft.com/dashboard/microsoftedge/overview");
const productId = await prompt(
"Enter product ID:",
{
type: "text"
},
previousOptions?.productId
);
entries.push(["EDGE_PRODUCT_ID", productId]);
console.log();
consola2.log(
"`--edge-client-id` and either `--edge-api-key` (API v1.1) or `--edge-client-secret` and `--edge-access-token-url` (API v1.0) can be created following:"
);
console.log(
"https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/api/using-addons-api#before-you-begin"
);
const clientId = await prompt(
"Enter your client ID:",
{ type: "text" },
previousOptions?.clientId
);
entries.push(["EDGE_CLIENT_ID", clientId]);
const apiKey = await prompt(
"Enter your API key:",
{ type: "text" },
previousOptions?.apiKey
);
entries.push(["EDGE_API_KEY", apiKey]);
const submitForReview = await prompt(
"When uploading, automatically submit new update for review?",
{ type: "confirm" },
!previousOptions?.skipSubmitReview
);
entries.push(["EDGE_SKIP_SUBMIT_REVIEW", !submitForReview]);
return entries;
}
async function updateEnvFile(entries) {
consola2.start(`Writing to \`${envFile}\`...`);
let template = await readFile(envFile, "utf-8").catch(() => "");
for (const [name, value] of entries) {
const formattedValue = typeof value === "string" ? `"${value}"` : value;
const replacement = `${name}=${formattedValue}`;
const pattern = new RegExp(`^${name}=.*$`, "m");
const existing = template.match(pattern);
if (existing) {
template = template.replace(existing[0], replacement);
} else {
template += `
${replacement}`;
}
}
const backupFilename = `${envFile}.backup-${Date.now()}`;
await copyFile(envFile, backupFilename).then(() => {
consola2.info(`Backed up old \`${envFile}\` to \`${backupFilename}\``);
}).catch(() => {
});
await writeFile(envFile, template, "utf-8");
console.log();
consola2.success("Wrote config to `.env.submit`");
}
export {
AddonsApi,
ChromeWebStore,
ChromeWebStoreOptions,
CwsApi,
EdgeAddonStore,
EdgeAddonStoreOptions,
EdgeApi,
FirefoxAddonStore,
FirefoxAddonStoreOptions,
InlineConfig,
init,
submit
};
/*! Bundled license information:
safe-buffer/index.js:
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
*/
//# sourceMappingURL=index.js.map