流星 Npm 模块客户端? [英] Meteor Npm-module client-side?

查看:27
本文介绍了流星 Npm 模块客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在客户端使用 Npm-Modules?

Is it possible to use Npm-Modules on client-side?

更具体地说:

我想使用 node.js 内置的加密模块来加密用户输入的密码,然后将带有签名 (/hmac) 的加密密码发送到我的服务器.

I want to use node.js built-in crypto-module for encrypting a password the user enters and then send the encrypted password with a signature(/hmac) to my server.

我需要这样做,因为我必须能够检索服务器端的原始密码,因为之后我要将其发送到 ldap 服务器,因为用户应该使用相同的用户名进行身份验证/他在该服务器上注册的密码.

I need to do it that way, because I must be able to retrieve the original password server-side, because afterwards I'm going to send it to a ldap-server, because the user should authenticate with the same username/password he is registered with on that server.

这就是我所做的:

在包/crypto/中创建:-package.js:

created in packages/crypto/: -package.js:

Package.on_use(function(api) { api.add_files('crypto.js',['server','client']);});

-crypto.js:crypto = Npm.require("crypto");

-crypto.js: crypto = Npm.require("crypto");

它在服务器上运行良好,但在客户端上显示参考错误:Npm 未定义".那么,是否可以在客户端使用加密模块?

It works fine on the server, but on the client it says "Reference Error: Npm is not defined". So, is it possible to use the crypto-module on client-side?

是否有其他方法可以实现这一目标?

Are there any alternatives for achieving this goal?

谢谢!

是否有任何好的替代方法可以以安全的方式获取服务器的密码,以便服务器可以检索原始密码?我认为在客户端执行 ldap() 请求(例如:if(checkLdap(usrname,password)){} else{fail}) 可以轻易绕过吗?

Is there any good alternative for getting the password to the server in a secure way, so that the server can retrieve the original password? I think doing the ldap()-request on the client-side (like: if(checkLdap(usrname,password)){<login>} else{fail}) can be easily bypassed?

推荐答案

不能在客户端使用 Npm 模块,因为 Npm 模块是通过 node.js 扩展的,它只能在服务器端运行.

Its not possible to use Npm modules on the client side since Npm modules are extensions via node.js which only runs on the server end.

如果你想使用像crypto这样的文件,你必须制作一个仅限客户端的版本并将它放在你的Meteor应用程序的/client/lib

If you want to use a file like crypto you would have to make a client side only version and put it in /client/lib of your Meteor app

虽然这可能正式成为可能,但 Meteor 不支持这一点.

While this may be possible officially, Meteor doesn't support this.

您必须使用此项目手动包含 requirejs:https://github.com/apendua/require

You would have to include requirejs manually using this project: https://github.com/apendua/require

这篇关于流星 Npm 模块客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆