beanbagdb 0.5.52 → 0.5.53
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/package.json +3 -2
- package/src/index.js +259 -265
- package/src/system_schema.js +34 -4
- package/test/couchdb.js +2 -2
- package/test/operations.test.js +1687 -286
- package/test/pouchdb.js +12 -6
- package/test/test1.js +134 -168
package/src/system_schema.js
CHANGED
|
@@ -19,7 +19,7 @@ export const schema_schema = {
|
|
|
19
19
|
},
|
|
20
20
|
name: {
|
|
21
21
|
type: "string",
|
|
22
|
-
minLength:
|
|
22
|
+
minLength: 4,
|
|
23
23
|
maxLength: 50,
|
|
24
24
|
pattern: "^[a-zA-Z][a-zA-Z0-9_]*$",
|
|
25
25
|
description:"This is the name of the schema.It cannot be changed later"
|
|
@@ -74,16 +74,17 @@ export const schema_schema = {
|
|
|
74
74
|
default: false,
|
|
75
75
|
description:
|
|
76
76
|
"If set, only a single records with this schema will be allowed to insert in the database",
|
|
77
|
-
}
|
|
77
|
+
}
|
|
78
78
|
},
|
|
79
|
-
required :["primary_keys","non_editable_fields","
|
|
79
|
+
required :["primary_keys","non_editable_fields","encrypted_fields"]
|
|
80
80
|
},
|
|
81
81
|
},
|
|
82
82
|
required: ["name","description","schema", "settings"],
|
|
83
83
|
},
|
|
84
84
|
settings: {
|
|
85
|
-
|
|
85
|
+
primary_keys: ["name"],
|
|
86
86
|
editable_fields: ["schema", "settings","description"],
|
|
87
|
+
encrypted_fields:[]
|
|
87
88
|
},
|
|
88
89
|
};
|
|
89
90
|
|
|
@@ -160,6 +161,35 @@ export const system_schemas = {
|
|
|
160
161
|
single_record:false
|
|
161
162
|
},
|
|
162
163
|
}
|
|
164
|
+
// ,
|
|
165
|
+
// edges:{
|
|
166
|
+
// name:"edges",
|
|
167
|
+
// description:"To relate one document to another.Labels can be configured using the db_network setting document.This stores edges of a simple directed graph",
|
|
168
|
+
// schema:{
|
|
169
|
+
// required:["graph","node1","node2","label"],
|
|
170
|
+
// type:"object",
|
|
171
|
+
// additionalProperties: false,
|
|
172
|
+
// properties : {
|
|
173
|
+
// graph:{
|
|
174
|
+
// type:"string",
|
|
175
|
+
// minLength:3,
|
|
176
|
+
// default:"default",
|
|
177
|
+
// maxLength:100,
|
|
178
|
+
// description:"Name of the graph in which this edge is being added. This is managed by the db_network setting "
|
|
179
|
+
// },
|
|
180
|
+
// node1:{
|
|
181
|
+
// type:"string",
|
|
182
|
+
// description:"the source of this directed edge. this must be a valid document id."
|
|
183
|
+
// }
|
|
184
|
+
// }
|
|
185
|
+
// },
|
|
186
|
+
// settings :{
|
|
187
|
+
// primary_key:["graph","node1","node2","label"],
|
|
188
|
+
// non_editable_fields:["node1","node2","graph"],
|
|
189
|
+
// encrypted_fields:[],
|
|
190
|
+
// single_record:false
|
|
191
|
+
// }
|
|
192
|
+
// }
|
|
163
193
|
};
|
|
164
194
|
|
|
165
195
|
// this is not stored in the DB. only for validating the metadata during doc update
|
package/test/couchdb.js
CHANGED
|
@@ -41,7 +41,7 @@ export class BeanBagDB_CouchDB extends BeanBagDB {
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
utils:{
|
|
44
|
-
encrypt: (text,encryptionKey)=>{
|
|
44
|
+
encrypt: async (text,encryptionKey)=>{
|
|
45
45
|
const key = crypto.scryptSync(encryptionKey, 'salt', 32); // Derive a 256-bit key
|
|
46
46
|
const iv = crypto.randomBytes(16); // Initialization vector
|
|
47
47
|
const cipher = crypto.createCipheriv('aes-256-cbc', key, iv);
|
|
@@ -49,7 +49,7 @@ export class BeanBagDB_CouchDB extends BeanBagDB {
|
|
|
49
49
|
encrypted += cipher.final('hex');
|
|
50
50
|
return iv.toString('hex') + ':' + encrypted; // Prepend the IV for later use
|
|
51
51
|
},
|
|
52
|
-
decrypt : (encryptedText, encryptionKey)=>{
|
|
52
|
+
decrypt : async (encryptedText, encryptionKey)=>{
|
|
53
53
|
const key = crypto.scryptSync(encryptionKey, 'salt', 32); // Derive a 256-bit key
|
|
54
54
|
const [iv, encrypted] = encryptedText.split(':').map(part => Buffer.from(part, 'hex'));
|
|
55
55
|
const decipher = crypto.createDecipheriv('aes-256-cbc', key, iv);
|