在离线播放器中保护SCORM内容

我正在开发桌面应用程序(在浏览器中启动一个包含index.html的zip文件)。 我想保护最终用户的zip文件,以便在没有App的情况下不能访问zip的内容。 注意:zip将包括HTML,JS和CSS文件的几个,我的应用程序将通过在浏览器中显示它的index.html文件来使用它。 我可以encryption我的内容,但在使用/启动内容的index.html(通过我的应用程序在浏览器)之前,我将不得不解密和提取到本地文件系统的压缩。 那时用户将获得解密内容的访问权限。 有没有办法以某种方式保存在内存中的解密内容从哪里浏览器可以访问HTML文件并显示它们?

mongoose保存不工作在if语句的第二部分

我在Node / Express API中有一个函数,首先检查我的“Contacts”集合中是否存在“Contact”。 如果是这样,我做一个更新。 如果查询中的电子邮件不存在,则创build一个新电子邮件。 如果联系人存在,contact.save()将起作用。 但是,如果联系人不存在,contact.save()会生成一个错误消息,说“contact.save()不是一个函数。 我不明白我做错了什么。 希望在那里的人能够看到它很容易,给我一些build议。 这里是代码: // SEARCH IF CONTACT EXISTS IN SENDERS CONTACTS – BY OWNERID AND EMAIL IN EMAILS Contact.findOne({'owner_id': req.body.owner_id, 'emails.email_address':req.body.invited_email}, function(err, contact){ if(err) console.log('Error in looking for contact.'); // IF A CONTACT EXISTS — if(contact){ console.log('–> CONTACT FOUND'); // SET CONTACT SHARED INFORMATION contact.shared.invite_id = req.body.invited_first_name […]

使用$ set-mongoose更新字段时,保留对象的其余部分

以下是我的collections结构: { "_id" : ObjectId("59c9e021af4886c9149a28c7"), "userkey" : "r1Et2ZNdW", "devicekey" : "12345", "analog" : { "4" : 458, "6" : 448, "7" : 100 }, "__v" : 0 } 我收集的更新代码是: DeviceModel.update({_id : device.id}, {$set : {"analog" : analog}}, function(err, doc){ if(err) throw err; console.log("Device switches updated"); }); 我想更新“模拟”对象的一个​​(或多个)值。 我可能会或可能不会有“模拟”集合的全部价值。 这意味着大部分时间我将只有{"7" : 200}或{"6" : 500}等等。 如果我在我上面的更新代码中使用它,它会起作用。 但问题是对象的其余部分将被删除。 […]

在整个项目中忽略eslint的具体错误

我使用的是AdonisJs(NodeJS框架),他们创build了一个名为use的函数来导入文件,比如它们是命名空间,比如use('App/Services/User')而不是require('../app/Services/User') 。 问题是eslint会抛出错误'use' is not defined no-undef 。 这时我有两种方法: 把eslint注释禁用每个文件中该行的警报,但这很烦人 使用require而不是use ,但是这个function很有用。 有没有办法在整个项目中禁用“一次全部” use函数的具体no-undef ?

Angular2应用程序初始加载问题。 typescript.js文件是4.75MB

我为我的J2EE应用程序(Spring MVC)使用Angular2。 我已经实现了延迟加载 ,但它仍然需要更多的时间(大约2分钟!!! )加载最初。 有两个大文件正在加载: typescript.js:4.75 MB compiler.umd.js:0.98 MB 而typescript.js文件不是caching。 每次重新加载它的下载。 我的systemjs.config.js文件是: System .config({ transpiler : 'ts', typescriptOptions : { "target" : "es5", "module" : "commonjs", "moduleResolution" : "node", "sourceMap" : true, "emitDecoratorMetadata" : true, "experimentalDecorators" : true, "lib" : [ "es2015", "dom" ], "noImplicitAny" : true, "suppressImplicitAnyIndexErrors" : true }, meta : { […]

我怎么能检查它是否是一个12字节的String对象,MongoDB中的ObjectID?

我想检查一个正确的ObjectID来继续我的代码。 我在NodeJS上,我不想得到这个错误: 错误:传入的参数必须是12个字节的单个string或24个hex字符的string 其实我有这些testing: if (!user.id || !user.id.match("/^[0-9a-fA-f]{24}$") || !typeof(user.id) === 'string') { console.log("user id is required !") return callback("user id is required !") } 对于24个hex字符的string,我得到这个正则expression式: !user.id.match("/^[0-9a-fA-f]{24}$") 我正在检查它是否是一个12字节的string: !typeof(user.id) === 'string' 我应该如何为12个字节添加validation? 有什么想法吗?

Node.js Mongoose Promise迷路了

我有一个mongoDB的Node.js API。 有一个创build用户的路由,需要散列密码,为此我使用bcryptjs包。 路线如下所示: router.route('/user') .post(function(req, res) { if(req.body.password === req.body.passwordConfirm) { userManager.addUser(req.body) .then(function(response) { // waiting for the result of the mongoDB save res.send({data:response}); }); } else { res.send({err:'passwords do not match'}); } }) 和userManager.addUSer: this.addUser = function(userobject) { bcrypt.genSalt(10, function(err, salt) { // generate a salt if(err !== null) { console.log(err); } else […]

从Firebase云端function连接到条带时出错

我正在尝试使用Firebase和Stripe从我的Android应用程序处理信用卡付款。 我已经在客户端上获取了一个Stripe标记,并且在我的Firebase Cloud Function中使用了一个数据库触发器来捕获新订单的发布时间。 这是我的function代码。 const stripe = require('stripe')('sk_test_XXXXXXXXXXXXXXXXXXXXXXXX'); return admin.database() .ref() .child('orders') .child(userId) .child(orderId) .child('token') .once('value') .then(snapshot => { return snapshot.val(); }) .then(token => { const amount = order.amount; console.log('Amount:', amount); console.log('token:', token.id); const idempotency_key = orderId; const source = token.id; const currency = 'usd'; const charge = {amount, currency, source}; return stripe.charges.create(charge, { […]

节点:用一个callback参数模拟一个函数

我正在尝试编写一个函数读取一个jsonfile到一个对象的unit testing。 我读了文件 jsonfile.readFile(filename, function (err, obj) { //… }); 对于我的unit testing,我想嘲笑这个函数,而不是实际读取文件,它只会返回一个固定的json块并传递给callback函数。 我遇到的麻烦是如何嘲笑这个function。 我见过sinon ,它支持模拟函数,但我找不到任何描述如何为我正在嘲笑的函数实际定义自定义行为。 Sinon看起来像允许我定义我想要的函数返回,我期望它被调用的频率等等,但是实际上并没有定义一个模拟函数。 基本上,我想要这样的东西: mock(jsonfile, 'readFile', function(filename, callback) { callback(null, {attr1:"foo"}); }); 我怎么和sinon做这个?

是否有一个节点模块的常见模式,需要asynchronous加载大文件才有用?

我不喜欢我见过的任何东西… 模 import lineReader from 'line-reader' let bigFile = './huge-file.csv' export default class DooDad { constructor() { this.dictionary = new Map() // Something like this seems like it'd be nice… // await this.load() } load() { return new Promise((resolve, reject) => { lineReader.eachLine(bigFile, (line, last) => { // this.dictionary = The contents of huge-file.csv }) […]