Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!bytesCmp(newNonceHash1, response.new_nonce_hash1)) {
const err = reject(ERR.dh.nonce.hash1())/*::.mapRej(dhAnswerFail)*/
return err
}
const serverSalt = bytesXor(newNonce.slice(0, 8), serverNonce.slice(0, 8))
// console.log('Auth successfull!', authKeyID, authKey, serverSalt)
const authBlock = {
authKeyID : /*:: toCryptoKey(*/ id /*::)*/,
authKey : /*:: toCryptoKey(*/ key /*::)*/,
//eslint-disable-next-line
serverSalt: /*:: toCryptoKey(*/ serverSalt /*::)*/,
}
const result: Fluture = of(authBlock)
return result
}
const Future = require('fluture');
const { isEmpty, pathOr, pipe } = require('ramda');
const webpack = require('webpack');
const DevServer = require('webpack-dev-server');
const { toArray } = require('./utils');
// errors :: (Error|Array Error err -> Object stats) -> Array Error
const getErrors = (err, stats) => (err ? toArray(err) : stats.toJson().errors);
// compiler :: Object config -> Future Error Object
const compiler = pipe(Future.of, Future.ap(Future.of(webpack)));
// compile :: Object config -> Future Error Object
const compile = pipe(
compiler,
Future.chain(compiler => Future((reject, resolve) => {
compiler.run((err, stats) => {
const errors = getErrors(err, stats);
isEmpty(errors) ? resolve(stats) : reject(errors);
});
}))
);
// devServer :: Object config -> Future Error Object
const devServer = pipe(
compiler,
nixConfigPathTemplate => {
if (nixConfigPathTemplate === NOT_MODIFIED_ENV) {
return of(none);
}
const nixConfigPath = nixConfigPathTemplate.replace(
"${workspaceRoot}",
workspaceRoot
);
// NOTE: all sync commands could throw exception
try {
return of(
pipe(
nixConfigPath,
getShellCmd("env", nixAttr),
mapNullable(
flow(
// HACK: sync operation using for block tread and prevent loading other
// extension before environment will be applied
execSync,
parseEnv,
applyEnv
)
),
)
);
} catch (err) {
return reject(err);
it('tests functor (left on Either)', function(done) {
const add = a => b => a + b;
const error = new Error();
const fe = FlutureTMonetEither.of(Future.of(Either.Left(error))).map(add(1));
fe.fork(
(val) => {
assert.strictEqual(val, error);
done();
},
noop
);
});
it('tests Either.Left in first FTE', function(done) {
FlutureTMonetEither
.fromFuture(Future.of('val'))
.filter(always(false), 'error')
.and(FlutureTMonetEither.fromEither(Either.Right('val')))
.fork(
(val) => {
assert.strictEqual(val, 'error');
done();
},
noop
);
});
export function safeImport(
fileName: string
): Future.FutureInstance {
let moduleObj = null
try {
moduleObj = require(fileName)
} catch (e) {
return e.code === 'MODULE_NOT_FOUND' ? Future.of(fileName) : Future.reject(e)
}
return Future.of(moduleObj)
}
export const userRegister = (registerData) => {
const usersWithEmail = models.Users.chain().find({
email: registerData.email,
})
if (usersWithEmail.count() > 0) {
return Future.reject("email_already_exists")
}
const createdUser = models.Users.insert({
email: registerData.email,
password: registerData.password,
})
return Future.of({ userId: createdUser.$loki })
}
function filterFiles(files: string[]): Future.FutureInstance {
const alias = files.filter((file: string) => {
return file.startsWith(name[0]) && file.includes(name[1])
})[0]
return alias ? Future.of(alias) : Future.reject(name)
}
}
export function cardsGet() {
const data = models.Cards.chain()
.data()
.map(mapCard)
.reverse()
return Future.of(data)
}
export async function cardRead(ctx) {
const data = mapCard(models.Cards.findOne({ $loki: +ctx.params.cardId }))
return Future.of(data)
}