Browse Source

generate a global identity keypair

Kieran Gibb 2 years ago
parent
commit
7e6f1cc461
No known key found for this signature in database
3 changed files with 6 additions and 21 deletions
  1. 4
    1
      README.md
  2. 0
    14
      example.yaml
  3. 2
    6
      index.js

+ 4
- 1
README.md View File

@@ -1,6 +1,6 @@
1 1
 # cobox-config
2 2
 
3
-Stores and retrieves a YAML configuration file for use with the cobox stack.
3
+Stores and retrieves a YAML configuration file for use with the cobox stack. Also loads up master key to generate a global identity.
4 4
 
5 5
 ## Example
6 6
 
@@ -52,3 +52,6 @@ config.groups.list()
52 52
 ```
53 53
 
54 54
 List saved groups
55
+
56
+## Future Features
57
+* Store names against ID's in YAML config file for multiple identity capability

+ 0
- 14
example.yaml View File

@@ -7,17 +7,3 @@ groups:
7 7
       symmetricKey: 7790efea443b9ebee384939bbd3f43d2841212790a0180342aca16a63f199431
8 8
   byName:
9 9
     group-a: *ref_0
10
-
11
-identities:
12
-  byKey:
13
-    736a1f0369923a5f1c8710ca1713bedccd8d051c42fe28b0bb031640f5293e4c: &ref_1
14
-      name: Alice
15
-      publicKey: 736a1f0369923a5f1c8710ca1713bedccd8d051c42fe28b0bb031640f5293e4c
16
-      secretKey: 7790efea443b9ebee384939bbd3f43d2841212790a0180342aca16a63f199431
17
-    ed49273be24fac7fce884a2908708e15abfb84b608b0084808968b4c75870218: &ref_2
18
-      name: bob
19
-      publicKey: ed49273be24fac7fce884a2908708e15abfb84b608b0084808968b4c75870218
20
-      secretKey: 54ddf6b77f306749737e8115efd31ffd1e4636d1336888cdfaf9dc2f91d45c7d
21
-  byName:
22
-    Alice: *ref_1
23
-    bob: *ref_2

+ 2
- 6
index.js View File

@@ -7,6 +7,7 @@ const logger = require('./logger')
7 7
 const crypto = require('cobox-crypto')
8 8
 
9 9
 const CONFIG_FILE = 'config.yml'
10
+const IDENTITY_SUBKEY_ID = 0
10 11
 
11 12
 module.exports = (storage, opts) => new CoBoxConfig(storage, opts)
12 13
 
@@ -20,7 +21,6 @@ const defaultOptions = () => ({
20 21
 const defaultConfig = () => ({
21 22
   options: defaultOptions(),
22 23
   groups: { byKey: {}, byName: {} },
23
-  identities: { byKey: {}, byName: {} }
24 24
 })
25 25
 
26 26
 // filename-safe date (probably there is a better way to do this)
@@ -38,7 +38,6 @@ class CoBoxConfig {
38 38
     if (!fs.existsSync(this.storage)) {
39 39
       fs.writeFileSync(this.storage, yaml.safeDump(defaultConfig(), { sortKeys: true }))
40 40
       this._groups = config.groups
41
-      this._identities = config.identities
42 41
       this._options = config.options
43 42
     } else {
44 43
       this.load()
@@ -52,11 +51,10 @@ class CoBoxConfig {
52 51
       this.masterKey = fs.readFileSync(masterKeyPath)
53 52
     }
54 53
 
54
+    this.identity = crypto.keyPair(this.masterKey, IDENTITY_SUBKEY_ID)
55 55
     this.logger = logger(path.join(this.root, 'logs', logfile))
56 56
     this.log = this.logger('cobox-config')
57
-
58 57
     this.groups = KeyHandler(this._groups)
59
-    this.identities = KeyHandler(this._identities)
60 58
     this.options = MapHandler(this._options)
61 59
   }
62 60
 
@@ -64,7 +62,6 @@ class CoBoxConfig {
64 62
     try {
65 63
       var config = defaultConfig()
66 64
       config.groups = this._groups
67
-      config.identities = this._identities
68 65
       config.options = this._options
69 66
 
70 67
       fs.writeFileSync(this.storage, yaml.safeDump(config, { sortKeys: true }))
@@ -79,7 +76,6 @@ class CoBoxConfig {
79 76
     try {
80 77
       const config = yaml.safeLoad(fs.readFileSync(this.storage, 'utf8'))
81 78
       this._groups = config.groups
82
-      this._identities = config.identities
83 79
       this._options = config.options || defaultOptions()
84 80
       return true
85 81
     } catch (err) {