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

查看:75
本文介绍了流星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.

这就是我所做的:

在package/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)){<login>} 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.

如果您想使用加密货币之类的文件,则必须制作一个仅客户端版本,并将其放入您的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天全站免登陆