@blueid/access-cli 0.108.0 → 0.110.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { program, Option } from 'commander'
1
+ import { program, Option, } from 'commander'
2
2
 
3
3
  import { outputFormats } from '../shared/outputBuffer.js'
4
4
 
@@ -42,7 +42,8 @@ program
42
42
  .addOption(new Option('--meta [meta]', 'Optional meta data in JSON format for the device'))
43
43
  .addOption(
44
44
  new Option('--format [format]', 'The output format to be used')
45
- .choices(['file', 'file_hex'].concat(outputFormats))
46
- .makeOptionMandatory(),
47
- )
45
+ .choices(['file', 'file_hex'].concat(outputFormats))
46
+ .makeOptionMandatory(),
47
+ )
48
+ .addOption(new Option('--dev', 'Run the command using the development environment'))
48
49
  .action(action)
@@ -7,7 +7,7 @@ import { apiPost } from '../shared/api.js'
7
7
 
8
8
  import { BlueSharedDemoData } from '../proto/BlueCore_pb.js'
9
9
 
10
- export default async ({ vendorIdentity, hardwareType, hardwareVersion, hardwareSerialNumber, hardwareName, meta }) => {
10
+ export default async ({ vendorIdentity, hardwareType, hardwareVersion, hardwareSerialNumber, hardwareName, meta, dev }) => {
11
11
  if (vendorIdentity === 'test') {
12
12
  return {
13
13
  deviceId: BlueSharedDemoData.fields.findJsonName('deviceId').default,
@@ -57,7 +57,7 @@ export default async ({ vendorIdentity, hardwareType, hardwareVersion, hardwareS
57
57
  throw new Error(`Failed to create signature with: ${e.message}`)
58
58
  }
59
59
 
60
- const response = await apiPost('/access/registerDevice', payload)
60
+ const response = await apiPost('/access/registerDevice', payload, { dev })
61
61
 
62
62
  const {
63
63
  deviceId,
@@ -32,6 +32,7 @@ export const BlueReturnCode = proto2.makeEnum(
32
32
  {no: -19, name: "Disconnected"},
33
33
  {no: -20, name: "PointerConversionFailed"},
34
34
  {no: -21, name: "Unavailable"},
35
+ {no: -22, name: "Aborted"},
35
36
  {no: -29, name: "Test"},
36
37
  {no: -30, name: "EncodeDataWriteFailed"},
37
38
  {no: -31, name: "EncodeDataWriteNothingWritten"},
package/lib/shared/api.js CHANGED
@@ -1,6 +1,12 @@
1
1
  import axios from 'axios'
2
2
 
3
- const apiUrl = 'https://api.dev.blue-id.com'
3
+ function getApiUrl({ dev = false } = {}) {
4
+ if (dev) {
5
+ return 'https://api.dev.blue-id.com'
6
+ }
7
+
8
+ return 'https://api.blue-id.com'
9
+ }
4
10
 
5
11
  async function runAxiosCall(call) {
6
12
  try {
@@ -9,17 +15,17 @@ async function runAxiosCall(call) {
9
15
  let errorText = ''
10
16
  try {
11
17
  errorText = JSON.stringify(e.response.data, null, 4)
12
- } catch {
18
+ } catch (error) {
13
19
  errorText = e.response ? e.response.toString() : ''
14
20
  }
15
21
  throw new Error(`Http Error (${e.code}): ${errorText}`)
16
22
  }
17
23
  }
18
24
 
19
- export async function apiGet(path) {
20
- return runAxiosCall(() => axios.get(`${apiUrl}${path}`))
25
+ export async function apiGet(path, options) {
26
+ return runAxiosCall(() => axios.get(`${getApiUrl(options)}${path}`))
21
27
  }
22
28
 
23
- export async function apiPost(path, body) {
24
- return runAxiosCall(() => axios.post(`${apiUrl}${path}`, body))
29
+ export async function apiPost(path, body, options) {
30
+ return runAxiosCall(() => axios.post(`${getApiUrl(options)}${path}`, body))
25
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueid/access-cli",
3
- "version": "0.108.0",
3
+ "version": "0.110.0",
4
4
  "description": "BlueID Access CLI",
5
5
  "type": "module",
6
6
  "main": "./index.js",