Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} catch (err) {
console.error('Failed to setup pro plain!', userRecord, err)
var message = err.message
if (err.code === 'card_declined') {
message = 'Oh dear! Your card was declined. Please check the card information and try again.'
}
if (!message) {
message = 'Failed to create an account with Stripe. Try again or contact support.'
}
throw new BadRequestError(message)
}
// update local records
this.usersDB.update(userRecord.id, {
plan: 'pro',
diskQuota: bytes.parse(this.config.proDiskUsageLimit),
namedArchiveQuota: this.config.proNamedArchivesLimit,
stripeCustomerId: customerId,
stripeSubscriptionId: subscription.id,
stripeTokenId: token.id,
stripeCardId: token.card.id,
stripeCardBrand: token.card.brand,
stripeCardCountry: token.card.country,
stripeCardCVCCheck: token.card.cvc_check,
stripeCardExpMonth: token.card.exp_month,
stripeCardExpYear: token.card.exp_year,
stripeCardLast4: token.card.last4
})
} finally {
release()
}
}
function handleSubmit (evt) {
evt.preventDefault()
const url = form.elements.url.value.trim()
// Accept URLs without protocol
.replace(/^(?!https?:\/\/)/i, 'https://')
// Accept Direct MEGA URL input
.replace(/https?:\/\/directme.ga\/(?:view)?[?#]([^&]+)/i, 'https://mega.nz/#$1')
// Normalize mega.co.nz to mega.nz
.replace('https://mega.co.nz/', 'https://mega.nz/')
const size = bytes.parse(form.elements.size.value.trim())
// Show that's possible loading from the hash
window.location.hash = url
output.textContent = 'Loading file info...'
splitFromURL(url, size).then(result => {
if (result.folder) {
const list = document.createElement('ul')
const files = createFileList(result.folder)
for (let {file, filePath} of files) {
const li = document.createElement('li')
const anchor = document.createElement('a')
anchor.textContent = filePath
anchor.href = '#' + url + '!' + file.downloadId[1]
anchor.addEventListener('click', handleFileClick)
function urlencoded (options) {
var opts = options || {}
// notice because option default will flip in next major
if (opts.extended === undefined) {
deprecate('undefined extended: provide extended option')
}
var extended = opts.extended !== false
var inflate = opts.inflate !== false
var limit = typeof opts.limit !== 'number'
? bytes.parse(opts.limit || '100kb')
: opts.limit
var type = opts.type || 'application/x-www-form-urlencoded'
var verify = opts.verify || false
if (verify !== false && typeof verify !== 'function') {
throw new TypeError('option verify must be function')
}
// create the appropriate query parser
var queryparse = extended
? extendedparser(opts)
: simpleparser(opts)
// create the appropriate type checking function
var shouldParse = typeof type !== 'function'
? typeChecker(type)
function json(options) {
var opts = options || {}
var limit = typeof opts.limit !== 'number'
? bytes.parse(opts.limit || '100kb')
: opts.limit
var inflate = opts.inflate !== false
var reviver = opts.reviver
var strict = opts.strict !== false
var type = opts.type || 'application/json'
var verify = opts.verify || false
if (verify !== false && typeof verify !== 'function') {
throw new TypeError('option verify must be function')
}
// create the appropriate type checking function
var shouldParse = typeof type !== 'function'
? typeChecker(type)
: type
function json (options) {
var opts = options || {}
var limit = typeof opts.limit !== 'number'
? bytes.parse(opts.limit || '100kb')
: opts.limit
var inflate = opts.inflate !== false
var reviver = opts.reviver
var strict = opts.strict !== false
var type = opts.type || 'application/json'
var verify = opts.verify || false
if (verify !== false && typeof verify !== 'function') {
throw new TypeError('option verify must be function')
}
// create the appropriate type checking function
var shouldParse = typeof type !== 'function'
? typeChecker(type)
: type
if (validator.isUUID(zname)) {
z = getdata(zname, zname);
} else {
z = getdata(zname);
}
if (z == null) {
console.log("Container does not exists");
}
}
if (z.brand != 'bhyve' && z.brand != 'kvm') {
if ("ram" in createOptions) {
rctl.ram = createOptions.ram;
if (/^[0-9]+(gb|mb)$/.test(rctl.ram.toLowerCase())) {
obj['max-physical-memory'] = bytes.parse(rctl.ram).toString();
obj['max-locked-memory'] = bytes.parse(rctl.ram).toString();
obj['max-swap'] = (bytes.parse(rctl.ram).toString() * 2).toString();
obj['cpu-shares'] = ((bytes.parse(rctl.ram).toString() /
1024 / 1024) * 2).toString();
obj['max-lwps'] = '3000';
} else {
console.log("Error Memory should be specified as mb or gb");
return null;
}
}
if ("dedicated-cpu" in createOptions) {
obj['dedicated-cpu'] = createOptions['dedicated-cpu'];
obj.importance = createOptions['dedicated-cpu-importance'];
} else if ("cpu-shares" in createOptions) {
if (/^[0-9]+$/.test(createOptions['cpu-shares'])) {
obj['cpu-shares'] = createOptions['cpu-shares'];
.then(() => {
this.name = name;
this.maxRequestSize = bytes.parse(entryPoint.config.maxRequestSize);
assert(
typeof this.name === 'string' && this.name.length > 0,
'Invalid "name" parameter value: expected a non empty string value');
if (entryPoint.config.protocols && entryPoint.config.protocols[name]) {
this.config = entryPoint.config.protocols[name];
}
assert(
Number.isInteger(this.maxRequestSize),
'Invalid "maxRequestSize" parameter value: expected a numeric value');
return true;
});
}
function getTransferDiff(
currentTransfer: string,
baselineTransfer: string,
): number {
return 1 - bytes.parse(currentTransfer) / bytes.parse(baselineTransfer);
}
const getMaxpayload = function({ limits: { maxpayload } }) {
return bytes.parse(maxpayload)
}