rxome-generator 1.0.1 → 1.0.2

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.
package/lib/rxome-api.cjs CHANGED
@@ -58,12 +58,20 @@ exports.unpack = unpack;
58
58
  return FS.readFileSync( name ).slice(0,44);
59
59
  }
60
60
 
61
- exports.generateApiKeys = async (name = 'rxome', dir = '.') => {
61
+ exports.generateApiKeys = async () => {
62
62
  const privateKey = ED.utils.randomPrivateKey();
63
63
  const publicKey = await ED.getPublicKey(privateKey);
64
+ return {
65
+ privateKey: privateKey,
66
+ publicKey: publicKey
67
+ }
68
+ }
69
+
70
+ exports.writeApiKeys = async (name = 'rxome', dir = '.') => {
71
+ const key = await this.generateApiKeys();
64
72
  await Promise.all([
65
- FS.writeFile( `${dir}/${name}.private.apikey`, bufferToBase64( privateKey ), { mode: 0o600 }, err => { if (err) throw err; } ),
66
- FS.writeFile( `${dir}/${name}.public.apikey`, bufferToBase64( publicKey ), { mode: 0o600 }, err => { if (err) throw err; } )
73
+ FS.writeFile( `${dir}/${name}.private.apikey`, bufferToBase64( key.privateKey ), { mode: 0o600 }, err => { if (err) throw err; } ),
74
+ FS.writeFile( `${dir}/${name}.public.apikey`, bufferToBase64( key.publicKey ), { mode: 0o600 }, err => { if (err) throw err; } )
67
75
  ]);
68
76
  }
69
77
 
@@ -4,7 +4,7 @@ const ED = require( 'noble-ed25519' );
4
4
 
5
5
  describe('API access', () => {
6
6
  test.skip('generates valid API access keys', async () => {
7
- await RxAPI.generateApiKeys( '__TESTSUITE_jesttest' );
7
+ await RxAPI.writeApiKeys( '__TESTSUITE_jesttest' );
8
8
  expect( FS.existsSync('__TESTSUITE_jesttest.private.apikey') ).toBe( true );
9
9
  expect( FS.existsSync('__TESTSUITE_jesttest.public.apikey') ).toBe( true );
10
10
  expect( FS.statSync('__TESTSUITE_jesttest.private.apikey').size - 44 ).toBeLessThan( 2 );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rxome-generator",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Generates QR codes containing medical information for use with the FindMe2Care platform.",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/rxcode.js CHANGED
@@ -25,7 +25,7 @@ const DEMO_CREDENTIALS = ApiDemo.DEMO_CREDENTIALS
25
25
  const DEMO_PRIVATE_KEY = ApiDemo.CRYPT_PRIVATE_KEY
26
26
  const DEMO_PUBLIC_KEY = ApiDemo.CRYPT_PUBLIC_KEY
27
27
 
28
- const VERSION = '1.0.1'
28
+ const VERSION = '1.0.2'
29
29
 
30
30
  program
31
31
  .name('rxcode')
@@ -166,7 +166,7 @@ program.command('apikeys')
166
166
  .argument('[file prefix]', 'Prefix for file names (default: rxome)')
167
167
  .option('-d, --directory <dir>', 'output directory', '.')
168
168
  .action( (prefix, options) => {
169
- RxAPI.generateApiKeys( prefix || 'rxome', options.directory )
169
+ RxAPI.writeApiKeys( prefix || 'rxome', options.directory )
170
170
  });
171
171
 
172
172