小编Dav*_*tti的帖子

只能在Swift 3中使用Touch ID访问Keychain中的数据

我正在努力实现以下代码:

  • 将一些数据存储在Keychain中.
  • 仅当用户使用Touch ID或Pass Code进行身份验证时才获取数据.

我看了钥匙扣和身份验证与Touch ID演示,并了解以下内容:

如果在向Keychain中添加新值时设置了正确的参数,则下次尝试将其取出时,系统将自动显示Touch ID弹出窗口.

我写了一些代码,但我的假设不起作用.这就是我写的:

    //
    //  Secret value to store
    //
    let valueData = "The Top Secret Message V1".data(using: .utf8)!;

    //
    //  Create the Access Controll object telling how the new value
    //  should be stored. Force Touch ID by the system on Read.
    //
    let sacObject =
        SecAccessControlCreateWithFlags(kCFAllocatorDefault,
                            kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly,
                            .userPresence,
                            nil);

    //
    //  Create the Key Value array, that holds the query to store 
    //  our data
    //
    let insert_query: NSDictionary …
Run Code Online (Sandbox Code Playgroud)

keychain ios touch-id swift

29
推荐指数
1
解决办法
6639
查看次数

InstanceAgent :: Plugins :: CodeDeployPlugin :: CommandPoller:缺少凭据

我正在尝试使用AWS CodeDeploy将GitHub项目部署到EC2实例.在关注了2个视频教程之后,我还是得到了以下错误:

2017-02-01 12:20:08 INFO  [codedeploy-agent(1379)]: master 1379: Spawned child 1/1
2017-02-01 12:20:09 INFO  [codedeploy-agent(1383)]: On Premises config file does not exist or not readable
2017-02-01 12:20:09 INFO  [codedeploy-agent(1383)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandExecutor: Archives to retain is: 5}
2017-02-01 12:20:09 INFO  [codedeploy-agent(1383)]: Version file found in /opt/codedeploy-agent/.version.
2017-02-01 12:20:09 ERROR [codedeploy-agent(1383)]: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Missing credentials - please check if this instance was started with an IAM instance profile
Run Code Online (Sandbox Code Playgroud)

我有两个IAM:

  • CodeDeployInstanceRole
  • CodeDeployServiceRole

EC2实例的CodeDeployInstanceRole

策略名称:AmazonEC2RoleforAWSCodeDeploy

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "s3:GetObject",
        "s3:GetObjectVersion", …
Run Code Online (Sandbox Code Playgroud)

github amazon-ec2 amazon-web-services amazon-iam aws-code-deploy

13
推荐指数
3
解决办法
4071
查看次数

如何在 OpenCV 相机中禁用缓冲区?

我遇到过这种情况,我使用 OpenCV 来检测相机前的人脸并对这些人脸进行一些机器学习。我遇到的问题是,一旦我完成所有处理,然后去抓取下一帧,我就会得到过去,而不是现在。意思是,我将读取缓冲区内的内容,而不是实际在相机前的内容。因为我不在乎处理时哪些人脸出现在相机前面,所以我关心现在在相机前面的是什么。

我确实尝试将缓冲区大小设置为1,这确实有很大帮助,但我仍然会获得至少 3 次缓冲区读取。将 FPS 设置为 1,也无助于 100% 消除这种情况。波纹管是我的流程。

let cv = require('opencv4nodejs');

let camera = new cv.VideoCapture(camera_port);

camera.set(cv.CAP_PROP_BUFFERSIZE, 1);
camera.set(cv.CAP_PROP_FPS, 2);
camera.set(cv.CAP_PROP_POS_FRAMES , 1);

function loop()
{
    //
    //  <>> Grab one frame from the Camera buffer.
    //
    let rgb_mat = camera.read();

    //  Do to gray scale

    //  Do face detection

    //  Crop the image

    //  Do some ML stuff

    //  Do whats needs to be done after the results are in.

    //
    //  <>> …
Run Code Online (Sandbox Code Playgroud)

camera buffer opencv node.js opencv4nodejs

12
推荐指数
2
解决办法
8392
查看次数

NodeJS中的Readline正在绘制不需要的行

我有以下问题,我在终端窗口中绘制ASCII字符,并将光标移动到另一个位置,并使用以下代码重复该过程.

const readline = require('readline');

//
//  Set the direction of the cursor
//
let dirrection_y = true;
let dirrection_x = true;

//
//  Set the initial position of the cursor
//
let position_x = 0;
let position_y = 0;

//
//  Get the terminal window size
//
let window_x = process.stdout.columns;
let window_y = process.stdout.rows;

//
//  Set the cursor to the top left corner of the terminal window so we can clear
//  the terminal screen
//
readline.cursorTo(process.stdout, …
Run Code Online (Sandbox Code Playgroud)

javascript terminal node.js

9
推荐指数
1
解决办法
435
查看次数

为什么 changeResourceRecordSets 未被授权访问此资源?

我正在尝试在 Route 53 中创建一个 Alias 类型的新记录,以告诉 Route 53 起诉 CloudFront 为该站点提供服务。我正在尝试使用以下代码执行此操作:

let options = {
    ChangeBatch: {
        Changes: [{
            Action: "CREATE",
            ResourceRecordSet: {
                AliasTarget: {
                    DNSName: '12kjh31k2hj3.cloudfront.net',
                    EvaluateTargetHealth: false,
                    HostedZoneId: 'JKEJWQHKJQWKK'
                },
                Name: 'example.com',
                Type: "A"
            }
        }],
        Comment: "S3 Hosted Site"
    },
    HostedZoneId: 'Z2FDTNDATAQYW2' // Fixed ID CloudFront distribution
};

route53.changeResourceRecordSets(options, function(error, data) {

    //
    //  1.  Check if there was an error
    //
    if(error)
    {
        return reject(error);
    }

    //
    //  -> Move to the next chain
    //
    return …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services node.js amazon-iam aws-sdk

5
推荐指数
1
解决办法
1750
查看次数

CodeDeploy找不到我的AWS Lambda函数

当它们在AWS CodePipeline中工作时,CodeDeploy和AWS Lambda出现问题。这是我的设置:

  1. 来源GitHub
  2. AWS CodeBuild
  3. AWS CodeDeploy

问题

步骤1.和2.可以正常工作,但是在CodeDeploy上,出现以下错误:

操作执行失败的BundleType必须为YAML或JSON

如果我解压缩CodeBuild生成的工件,则所有文件都就位。

如果尝试从CodeDeploy手动部署到AWS Lambda,则会收到其他消息...

部署失败部署失败,因为目标Lambda函数FUNCTION_NAME不存在或者找不到指定的函数版本或别名

关于哪个错误消息有效,或者它们是否相同但具有不同的错误消息,这非常混乱。

设置

该功能的ARN为:

arn:aws:lambda:us-east-1:239748505547:function:email_submition
Run Code Online (Sandbox Code Playgroud)

别名的ARN为:

arn:aws:lambda:us-east-1:239748505547:function:email_submition:default
Run Code Online (Sandbox Code Playgroud)

而且我的appspec.yml文件具有以下内容

version: 0.0
Resources:
  - email_submition:
      Type: AWS::Lambda::Function
      Properties:
        Name: "email_submition"
        Alias: "default"
        CurrentVersion: "1"
        TargetVersion: "2"
Run Code Online (Sandbox Code Playgroud)

该项目的文件夹结构为:

.gitignore
appspec.yml
buildspec.yml
index.js
README.md
Run Code Online (Sandbox Code Playgroud)

我在此配置中缺少什么?

amazon-s3 amazon-web-services aws-code-deploy aws-lambda aws-codepipeline

5
推荐指数
2
解决办法
5442
查看次数

Docker中的Bcrypt安装失败

我创建了一个在Docker中运行的MongoDB节点应用程序.它工作正常,直到我包含node.bcrypt.js.这使得与节点崩溃node-gypbcrypt.

该应用程序在本地和Heroku上运行良好.

我尝试安装一些我在网上找到的建议包,根据错误消息已知需要这些包.这就是为什么我添加了一些额外的依赖项,请参阅node-gyp下面的dockerfile中的相关行.

现在它已经到了我找不到更多建议的地方,但它仍然无法正常工作.我觉得它在本地和Heorku上工作很奇怪,但在Docker上却没有,因此它是我所缺少的.

提前致谢.

错误:

> crowdshelf-server@1.0.0 start /server
> node index.js

  COPY Release/bcrypt_lib.node
make: Leaving directory `/server/node_modules/bcrypt/build'
module.js:338
    throw err;
          ^
Error: Cannot find module './lib/topologies/server'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/server/node_modules/mongodb/node_modules/mongodb-core/index.js:3:13)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)

npm ERR! Linux 3.13.0-58-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
npm …
Run Code Online (Sandbox Code Playgroud)

bcrypt node.js docker

4
推荐指数
1
解决办法
6851
查看次数

在Express中提供静态文件 - 它是否被缓存?

在ExpressJS 文档中,没有关于如何加载文件的信息.

我的问题是:当我请求一个静态文件时,是否每次请求都从磁盘加载文件?或者以某种方式缓存?如果是这样,怎么样?

node.js express

4
推荐指数
1
解决办法
1620
查看次数

Google Cloud Print API-打印PDF时的白页

我想发送一个使用Google Cloud Print API打印的PDF文件。下面的代码将给我一个积极的信息,告诉我已生成一页。当我去检查结果时,我在空白页上打上了门。

如果我将打印内容保存在Google云端硬盘中,也会发生相同的结果。

代码

unirest.post('https://www.google.com/cloudprint/submit')
.header('Authorization', 'Bearer ' + token)
.header("Accept-Charset", "utf-8")
.field('xsrf', xsrf_token)
.field('printerid', printerId)
.field('ticket', '{"version": "1.0", "print": {}}')
.field('title', 'Test from Simpe.li')
.field('contentType', 'application/pdf')
.attach('content', buffer)
.end(function (res) {

    console.log(res);

});
Run Code Online (Sandbox Code Playgroud)

我知道我要发送的是PDF,因为当我更改

.field('contentType', 'application/pdf')
Run Code Online (Sandbox Code Playgroud)

.field('contentType', 'text/plain')
Run Code Online (Sandbox Code Playgroud)

我将获得53页文本,这是PDF文件的原始内容。

在此处输入图片说明

我做错了什么?

技术规格

  • NodeJS v4.1.1
  • Unirest v0.4.2

pdf node.js google-cloud-print unirest

3
推荐指数
1
解决办法
1538
查看次数

在ExpressJS下检测HTTPS仅适用于4种方法中的1种

我最近在我的网站上添加了SSL证书.添加HTTPS支持后,我想将人们重定向到安全连接.我用谷歌搜索如何检测HTTPS,并在堆栈上找到许多不同的方式.它接缝他们为他人工作,但他们不适合我.在检查安全连接的4种方法中,只有一种有效.

什么对我不起作用:

  • req.secure:即使我手动放置https:// 总是返回false
  • req.connection.encrypted:即使我手动放入https://也总是返回undefined
  • req.protocol:即使我手动放置https:// 总是返回http

什么有效:

req.headers ['x-forwarded-proto']是实际返回现实的唯一方式.

知道这一点后,我通过以下方式重定向到安全连接:

// Check if the connection is secure, if not, reddiret to a secure one.
function requireHTTPS(req, res, next) {
    if(process.env.NODE_ENV == 'production') {
        if (req.headers['x-forwarded-proto'] !== 'https') {
            return res.redirect('https://' + req.get('host') + req.url);
        }
    }

    next();
}

app.use(requireHTTPS);
Run Code Online (Sandbox Code Playgroud)

在上面提到的任何其他方式中,我会得到一个重定向循环,因为即使重定向到HTTPS之后,上述方法也会返回falsehttp.

我的问题是:为什么其他方法不起作用?

技术规格:

  • 网站:https://simpe.li
  • 在Heroku上主持
  • 节点版本:4.1.1
  • 快递:4.13.0

ssl heroku node.js express

2
推荐指数
1
解决办法
250
查看次数