Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
options.stdio = getValidStdio(options.stdio || 'pipe', true).stdio;
if (options.input) {
var stdin = options.stdio[0] = { ...options.stdio[0] };
stdin.input = options.input;
}
// We may want to pass data in on any given fd, ensure it is a valid buffer
for (var i = 0; i < options.stdio.length; i++) {
var input = options.stdio[i] && options.stdio[i].input;
if (input != null) {
var pipe = options.stdio[i] = { ...options.stdio[i] };
if (isArrayBufferView(input)) {
pipe.input = input;
} else if (typeof input === 'string') {
pipe.input = Buffer.from(input, options.encoding);
} else {
throw new ERR_INVALID_ARG_TYPE(`options.stdio[${i}]`,
['Buffer',
'TypedArray',
'DataView',
'string'],
input);
}
}
}
return child_process.spawnSync(opts);
}
test('公钥密码', () => {
const publicText = crypto.publicEncrypt(publicKey, Buffer.from(plainText))
const privateText = crypto.privateDecrypt(privateKey, publicText)
expect(privateText.toString()).toBe(plainText)
})
async function checkAuth(req) {
const auth = req.headers.authorization || '';
if (!auth) {
return false;
}
const match = auth.match(/^bearer\s+([^\s]+)\s*$/i);
if (!match) {
return false;
}
const reqToken = Buffer.from(match[1]);
if (reqToken.length !== httpToken.length) {
return false;
}
return timingSafeEqual(reqToken, httpToken);
}
function toJose ({ r, s, recoveryParam }) {
const jose = Buffer.alloc(recoverable ? 65 : 64)
Buffer.from(r, 'hex').copy(jose, 0)
Buffer.from(s, 'hex').copy(jose, 32)
if (recoverable) {
if (recoveryParam === undefined) throw new Error('Signer did not return a recoveryParam')
jose[64] = recoveryParam
}
return base64url.encode(jose)
}
const getContents = function ({
destFormat,
file: { contents, path },
}) {
const srcFormat = getByExt({ path });
const content = contents.toString();
const contentA = srcFormat.parseContent(content, { path });
const contentB = destFormat.serializeContent(contentA);
const contentC = Buffer.from(contentB);
return contentC;
};
function encodeRealpathResult(result, options, err) {
if (!options || !options.encoding || options.encoding === 'utf8' || err)
return result;
const asBuffer = Buffer.from(result);
if (options.encoding === 'buffer') {
return asBuffer;
} else {
return asBuffer.toString(options.encoding);
}
}
return {
type,
block,
value: Ignore.decode(Buffer.from(data, 'base64'))
}
case FeedItemType.Join:
return {
type,
block,
value: Join.decode(Buffer.from(data, 'base64'))
}
case FeedItemType.Leave:
return {
type,
block,
value: Leave.decode(Buffer.from(data, 'base64'))
}
case FeedItemType.Announce:
return {
type,
block,
value: Announce.decode(Buffer.from(data, 'base64'))
}
}
}
export async function file(blockId: string): Promise {
const result = await FilesBridge.file(blockId)
return Files.decode(Buffer.from(result, 'base64'))
}
function _uint8ArrayToBuffer(chunk) {
return Buffer.from(chunk);
}