Git Product home page Git Product logo

passkit-node-quickstart's Introduction

PassKit Node Quickstart

License: MIT NPM

Overview

This quickstart aims to help get NodeJs developers up and running with the PassKit SDK as quickly as possible.

Prerequisites

You will need the following:

Configuration

  1. Download or clone this quickstart repository.

  2. Create a new folder inside src called certs and add the following three PassKit credential files into it. Files can be found in the sdk credentials email you receive on signup:

    • certificate.pem
    • ca-chain.pem
    • key.pem
  3. Add the on time password you used to generate your SDK credentials into the src/config/config.js PASSPHRASE variable

  4. If you wish to receive enrolment emails, edit lines 281 and 307 of the QuickStartLoyalty class to provide an address where you can receive mail.

  5. Run npm i

Running the tests

Run npm run test

The Loyalty tests will create a membership program with 2 tiers, 2 members and 3 member events.

The tests will display URLs to the generated passes and to the enrolment page. It will pause for a period determined in the test file on line 64.

The tests will then delete and clean-up all assets that it created.

If you don't want you assets to be deleted, comment out lines 10 - 12 in the test/quick-start-loyalty.test.js file.

Notes

For implementing in your own projects, use the PassKitClient class to manage connection to the PassKit gRPC endpoints.

The quickstart uses the PassKit official node sdk found here: https://www.npmjs.com/package/passkit-node-sdk

passkit-node-quickstart's People

Contributors

pkpfr avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

vasejs junerodney

passkit-node-quickstart's Issues

FAIL src/test/quick-start-loyalty.test.js

Node version: 21.4.0
npm version: 10.4.0
OS: PopOS 22.04

I made sure to put the certs directory into the correct place along with all the .pem files. I also made sure to make necessary changes to the config file. I also made sure to double check my password was correct.

npm run test

> [email protected] test
> jest

 FAIL  src/test/quick-start-loyalty.test.js
  ● Test suite failed to run

    Failed to load gRPC binary module because it was not installed for the current system
    Expected directory: node-v120-linux-x64-glibc
    Found: [node-v67-linux-x64-glibc]
    This problem can often be fixed by running "npm rebuild" on the current system
    Original error: Cannot find module '/home/harry/alt-rew/passkit-node-quickstart/node_modules/grpc/src/node/extension_binary/node-v120-linux-x64-glibc/grpc_node.node' from 'node_modules/grpc/src/grpc_extension.js'

    Require stack:
      node_modules/grpc/src/grpc_extension.js
      node_modules/grpc/src/client_interceptors.js
      node_modules/grpc/src/client.js
      node_modules/grpc/index.js
      node_modules/passkit-node-sdk/io/core/a_rpc_templates_grpc_pb.js
      src/lib/client.js
      src/lib/quick-start-loyalty.js
      src/test/quick-start-loyalty.test.js


    However, Jest was able to find:
        './grpc_extension.js'

    You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].

    See https://jestjs.io/docs/en/configuration#modulefileextensions-arraystring

      1 | const {
      2 |   TemplatesClient,
    > 3 | } = require("passkit-node-sdk/io/core/a_rpc_templates_grpc_pb");
        |     ^
      4 | const {
      5 |   ImagesClient,
      6 | } = require("passkit-node-sdk/io/core/a_rpc_images_grpc_pb");

      at Object.<anonymous> (node_modules/grpc/src/grpc_extension.js:53:17)
      at Object.<anonymous> (node_modules/grpc/src/client_interceptors.js:144:12)
      at Object.<anonymous> (node_modules/grpc/src/client.js:35:27)
      at Object.<anonymous> (node_modules/grpc/index.js:27:14)
      at Object.<anonymous> (node_modules/passkit-node-sdk/io/core/a_rpc_templates_grpc_pb.js:4:12)
      at Object.<anonymous> (src/lib/client.js:3:5)
      at Object.<anonymous> (src/lib/quick-start-loyalty.js:28:21)
      at Object.<anonymous> (src/test/quick-start-loyalty.test.js:1:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.404 s
Ran all test suites.
(node:24668) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

test failed

% npm run test

[email protected] test
jest

jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
Usually this happens when watchman isn't running. Create an empty .watchmanconfig file in your project's root folder or initialize a git or hg repository in your project.
Error: Watchman error: std::__1::system_error: open: /Users/peter/Downloads/passkit-node-quickstart: Operation not permitted. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.
console.log
Creating images

  at QuickStartLoyalty.createImages (src/lib/quick-start-loyalty.js:105:13)

console.log
Error: Error: 16 UNAUTHENTICATED: could not find a user record for user
at Object..exports.createStatusError (/Users/peter/Downloads/passkit-node-quickstart/node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (/Users/peter/Downloads/passkit-node-quickstart/node_modules/grpc/src/client_interceptors.js:1209:28)
at InterceptingListener.Object..InterceptingListener._callNext (/Users/peter/Downloads/passkit-node-quickstart/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.Object..InterceptingListener.onReceiveStatus (/Users/peter/Downloads/passkit-node-quickstart/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/Users/peter/Downloads/passkit-node-quickstart/node_modules/grpc/src/client_interceptors.js:847:24) {
code: 16,
metadata: Metadata {
_internal_repr: {
date: [Array],
'content-length': [Array],
'strict-transport-security': [Array]
},
flags: 0
},
details: 'could not find a user record for user'
}

  at QuickStartLoyalty.runQuickStart (src/lib/quick-start-loyalty.js:82:15)

console.log
Enrollment URL: https://pub1.pskt.io/c/

  at Object.<anonymous> (src/test/quick-start-loyalty.test.js:49:13)

console.log
Bronze Pass Url: https://pub1.pskt.io/

  at Object.<anonymous> (src/test/quick-start-loyalty.test.js:53:13)

console.log
Silver Pass Url: https://pub1.pskt.io/

  at Object.<anonymous> (src/test/quick-start-loyalty.test.js:57:13)

console.log
Data will be removed in 1 minutes

  at Object.<anonymous> (src/test/quick-start-loyalty.test.js:62:13)

console.log
Delete Program

  at QuickStartLoyalty.deleteProgram (src/lib/quick-start-loyalty.js:425:13)

FAIL src/test/quick-start-loyalty.test.js (65.226 s)
quick start loyalty
✕ has all image assets (1 ms)
✕ has template assets (2 ms)
✕ has program assets (1 ms)
✕ has tier assets
✕ has member assets (1 ms)
✓ has event assets
✓ shows urls (60005 ms)

● quick start loyalty › has all image assets

TypeError: Cannot read properties of undefined (reading 'getIcon')

  14 | describe("quick start loyalty", () => {
  15 |   it("has all image assets", () => {
> 16 |     expect(quickStart.imageIds.getIcon()).toBeTruthy();
     |                                ^
  17 |     expect(quickStart.imageIds.getLogo()).toBeTruthy();
  18 |     expect(quickStart.imageIds.getHero()).toBeTruthy();
  19 |     expect(quickStart.imageIds.getStrip()).toBeTruthy();

  at Object.<anonymous> (src/test/quick-start-loyalty.test.js:16:32)

● quick start loyalty › has template assets

expect(received).toBeTruthy()

Received: ""

  21 | 
  22 |   it("has template assets", () => {
> 23 |     expect(quickStart.silverTemplateId).toBeTruthy();
     |                                         ^
  24 |     expect(quickStart.silverTemplateId).toBeTruthy();
  25 |     expect(quickStart.silverTemplateId.length).toBe(22);
  26 |     expect(quickStart.bronzeTemplateId.length).toBe(22);

  at Object.<anonymous> (src/test/quick-start-loyalty.test.js:23:41)

● quick start loyalty › has program assets

expect(received).toBeTruthy()

Received: ""

  28 | 
  29 |   it("has program assets", () => {
> 30 |     expect(quickStart.programId).toBeTruthy();
     |                                  ^
  31 |     expect(quickStart.programId.length).toBe(22);
  32 |   });
  33 | 

  at Object.<anonymous> (src/test/quick-start-loyalty.test.js:30:34)

● quick start loyalty › has tier assets

expect(received).toBeTruthy()

Received: ""

  33 | 
  34 |   it("has tier assets", () => {
> 35 |     expect(quickStart.silverTierId).toBeTruthy();
     |                                     ^
  36 |     expect(quickStart.bronzeTierId).toBeTruthy();
  37 |   });
  38 | 

  at Object.<anonymous> (src/test/quick-start-loyalty.test.js:35:37)

● quick start loyalty › has member assets

expect(received).toBeTruthy()

Received: ""

  38 | 
  39 |   it("has member assets", () => {
> 40 |     expect(quickStart.bronzeMemberId).toBeTruthy();
     |                                       ^
  41 |     expect(quickStart.silverMemberId).toBeTruthy();
  42 |   });
  43 | 

  at Object.<anonymous> (src/test/quick-start-loyalty.test.js:40:39)

Test Suites: 1 failed, 1 total
Tests: 5 failed, 2 passed, 7 total
Snapshots: 0 total
Time: 65.463 s, estimated 66 s
Ran all test suites.
console.log
Error: Error: 16 UNAUTHENTICATED: could not find a user record for user
at Object..exports.createStatusError (/Users/peter/Downloads/passkit-node-quickstart/node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (/Users/peter/Downloads/passkit-node-quickstart/node_modules/grpc/src/client_interceptors.js:1209:28)
at InterceptingListener.Object..InterceptingListener._callNext (/Users/peter/Downloads/passkit-node-quickstart/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.Object..InterceptingListener.onReceiveStatus (/Users/peter/Downloads/passkit-node-quickstart/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/Users/peter/Downloads/passkit-node-quickstart/node_modules/grpc/src/client_interceptors.js:847:24) {
code: 16,
metadata: Metadata {
_internal_repr: {
date: [Array],
'content-length': [Array],
'strict-transport-security': [Array]
},
flags: 0
},
details: 'could not find a user record for user'
}

  at QuickStartLoyalty.cleanUp (src/lib/quick-start-loyalty.js:99:15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.