pathchain 1.0.8 → 1.0.9
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/README.md +146 -9
- package/index.js +11 -0
- package/maker.js +1 -1
- package/package.json +1 -1
- package/proto/entity.proto +7 -0
- package/proto/secret.proto +8 -0
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# pathchain [](https://badge.fury.io/js/pathchain) [](https://badge.fury.io/js/pathchain) [](http://github.com/rockstarallegue/pathchain.git)
|
|
2
2
|

|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
Pathchain is a tool to build path-shaped data structures that are chained one to another from the moment the tool
|
|
5
|
+
Pathchain is a tool to build path-shaped data structures that are chained one to another from the very moment the tool is initialized. The data behaves like a data tree where you can track the very origin of anything by tracking the origin file hashnames that created any hashname of any file in the chain. Pathchain uses Google's Protocol Buffers to encode and decode the data structures optimally and SHA-256 to build the hashname chain.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
# Pathchain documentation
|
|
@@ -10,18 +10,29 @@ Pathchain is a tool to build path-shaped data structures that are chained one to
|
|
|
10
10
|
## Makers
|
|
11
11
|
Maker functions recieve new data to encode into the chain.
|
|
12
12
|
|
|
13
|
-
| Function
|
|
14
|
-
|
|
|
15
|
-
| [`makeMoment()`](#Moment)
|
|
16
|
-
| [`makePioneer()`](#Pioneer)
|
|
13
|
+
| Function | Parameters |
|
|
14
|
+
| ---------------------------- | --------------------------------------- |
|
|
15
|
+
| [`makeMoment()`](#Moment) | datetime, lat, lon, x, y, z, format |
|
|
16
|
+
| [`makePioneer()`](#Pioneer) | format |
|
|
17
|
+
| [`makeSecret()`](#Secret) | author, format |
|
|
17
18
|
|
|
18
19
|
|
|
20
|
+
## Getters
|
|
21
|
+
Getter functions retrieve objects given a hashname and author information
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
| Function | Parameters |
|
|
24
|
+
| --------------------------- | ---------------------------------------- |
|
|
25
|
+
| [`getMoment()`](#Moment) | xmoment |
|
|
26
|
+
| [`getPioneer()`](#Pioneer) | (none) |
|
|
27
|
+
| [`getSecret()`](#Secret) | xsecret |
|
|
21
28
|
|
|
22
|
-
A moment is the mimimum representation of the pathoschain data structures. Moments are the trunk of any path. They're represented by default with a `MM DD YYYY HH:mm:SSS [GMT]Z` datetime format for `time` and a planet earth representation (0, 0, 0) in general as `space`.
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
|
|
31
|
+
## Moment
|
|
32
|
+
|
|
33
|
+
A moment is the mimimum representation of the pathchain data structures. Moments are the trunk of every path . They're represented by default with a `MM DD YYYY HH:mm:SSS [GMT]Z` datetime format for `time` and a planet earth representation (0, 0, 0) in general as `space`.
|
|
34
|
+
|
|
35
|
+
`<moment>` :: space and time data ::= { `<“moments/”>` + sha256(`<moment>`) }
|
|
25
36
|
|
|
26
37
|
#### Protocol Buffer file:
|
|
27
38
|
|
|
@@ -125,3 +136,129 @@ Moment object: {
|
|
|
125
136
|
}
|
|
126
137
|
}
|
|
127
138
|
```
|
|
139
|
+
|
|
140
|
+
## Secret
|
|
141
|
+
|
|
142
|
+
A secret is an OTP (One Time Password) generated by an entity. The moment it is used, it becomes useless. Secrets are represented as SHA-256 hashes, like everything on pathchain.
|
|
143
|
+
|
|
144
|
+
`<secret>` :: secret hash generated by an entity ::= { `<“secrets/”>` + sha256(`<moment>` + `<entity>`) }
|
|
145
|
+
|
|
146
|
+
#### Protocol Buffer file:
|
|
147
|
+
|
|
148
|
+
``` proto
|
|
149
|
+
syntax = "proto3";
|
|
150
|
+
|
|
151
|
+
message secret {
|
|
152
|
+
required string register = 1;
|
|
153
|
+
required string author = 2;
|
|
154
|
+
required bool used = 3;
|
|
155
|
+
required string tag = 4;
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### Secret maker
|
|
160
|
+
|
|
161
|
+
Parameter rules:
|
|
162
|
+
|Parameter |Required |
|
|
163
|
+
|-------------------------|----------|
|
|
164
|
+
|{string} author |(required)|
|
|
165
|
+
|{string} format |(optional)|
|
|
166
|
+
|
|
167
|
+
Summoning `makeMoment(author, format)`:
|
|
168
|
+
```javascript
|
|
169
|
+
const pathchain = require("pathchain"); // Summoning pathchain
|
|
170
|
+
|
|
171
|
+
var sec_pioneer_buff = pathchain.makeSecret(author); // Making a secret with an existing entity hash
|
|
172
|
+
console.log("Secret buffer: ", secret); // Printing
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Console:
|
|
176
|
+
``` bash
|
|
177
|
+
Secret buffer: c0f9d300e1b28253455e1835f13ca18d000333152a6a9a9b106d0407612980a8
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### Secret usage (using a secret / checking if a secret has been used)
|
|
181
|
+
|
|
182
|
+
Parameter rules:
|
|
183
|
+
|Parameter |Required |
|
|
184
|
+
|-------------------------|----------|
|
|
185
|
+
|{string} xsecret |(required)|
|
|
186
|
+
|
|
187
|
+
Summoning `useSecret(xsecret)`:
|
|
188
|
+
```javascript
|
|
189
|
+
const pathchain = require("pathchain"); // Summoning pathchain
|
|
190
|
+
|
|
191
|
+
var secret_buff = pathchain.makeSecret(author); // Making a secret with an existing entity hash
|
|
192
|
+
console.log("Secret buffer: ", secret); // Printing
|
|
193
|
+
|
|
194
|
+
// Checking if the secret has been used (before using it)
|
|
195
|
+
var used = pathchain.isSecretUsed(secret_buff);
|
|
196
|
+
console.log("Secret buffer used?: ", used); // Printing
|
|
197
|
+
|
|
198
|
+
// Using the secret
|
|
199
|
+
pathchain.useSecret(secret_buff);
|
|
200
|
+
|
|
201
|
+
// Checking if the secret has been used (before using it)
|
|
202
|
+
var used = pathchain.isSecretUsed(secret_buff);
|
|
203
|
+
console.log("Secret buffer used?: ", used); // Printing
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Console:
|
|
207
|
+
``` bash
|
|
208
|
+
Secret buffer: c0f9d300e1b28253455e1835f13ca18d000333152a6a9a9b106d0407612980a8
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
``` bash
|
|
212
|
+
Secret buffer used?: false
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
``` bash
|
|
216
|
+
Secret buffer used?: true
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
#### Secret getter
|
|
221
|
+
|
|
222
|
+
Parameter rules:
|
|
223
|
+
|Parameter |Required |
|
|
224
|
+
|-------------------------|----------|
|
|
225
|
+
|{string} xsecret |(optional)|
|
|
226
|
+
|
|
227
|
+
Summoning `getSecretObj(xsecret)`
|
|
228
|
+
```
|
|
229
|
+
const pathchain = require("pathchain"); // Summoning pathchain
|
|
230
|
+
|
|
231
|
+
const secret_nuff = pathchain.makeSecret(author); // Secret creation
|
|
232
|
+
|
|
233
|
+
var secret_obj = pathchain.getSecretObj(secret_buff); // Getting object from hashname
|
|
234
|
+
|
|
235
|
+
console.log("Secret object: ", secret_obj); // Printing
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Console:
|
|
239
|
+
``` bash
|
|
240
|
+
Secret object: {
|
|
241
|
+
register: 'moments/638976edf4684e746f9bd013bd2e9145b1316ee42b40b0877185f6aeda960b8d',
|
|
242
|
+
author: 'pioneer/ebd4ff7e4f69d1c4c2b529eb60a7ca72bb459c1458e1a011b26b6ea84901d143',
|
|
243
|
+
used: false,
|
|
244
|
+
tag: 'secrets/574e8fee76ba4dc93c2f4cd79399aa01e6cfb19257e4eb305dcfaeb16649b7bf'
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
## Pioneer
|
|
250
|
+
|
|
251
|
+
A pioneer is a user with all its content made public. It is the first entity on the system and can only generate one [secret](#Secret) in order to initiate the human chain for the system. The pioneer buffer exists as a single buffer in the `pioneer` folder and as an entity in the `entities` folder.
|
|
252
|
+
|
|
253
|
+
`<pioneer>` :: pioneer entity ::= { `<“pioneer/”>` + sha256(`<moment>`) }
|
|
254
|
+
|
|
255
|
+
#### Protocol Buffer file:
|
|
256
|
+
``` javascript
|
|
257
|
+
syntax = "proto3";
|
|
258
|
+
|
|
259
|
+
message entity {
|
|
260
|
+
required string register = 1;
|
|
261
|
+
required string invite = 2;
|
|
262
|
+
required string tag = 3;
|
|
263
|
+
}
|
|
264
|
+
```
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const maker = require("./maker");
|
|
2
2
|
const getter = require("./getter");
|
|
3
|
+
const checker = require("./checker");
|
|
3
4
|
|
|
4
5
|
///////////////
|
|
5
6
|
/// HELLO ///
|
|
@@ -103,6 +104,16 @@ exports.useSecret = (xsecret) => {
|
|
|
103
104
|
return secret_buffer
|
|
104
105
|
}
|
|
105
106
|
|
|
107
|
+
/** isSecretUsed
|
|
108
|
+
* [Check secret availability]
|
|
109
|
+
*
|
|
110
|
+
* @return {bool} true/false
|
|
111
|
+
*/
|
|
112
|
+
exports.isSecretUsed = (xsecret) => {
|
|
113
|
+
const is_secret_used = checker.isSecretUsed(xsecret)
|
|
114
|
+
return is_secret_used
|
|
115
|
+
}
|
|
116
|
+
|
|
106
117
|
/** getSecretObj
|
|
107
118
|
* [Function that recieves a moment hash and returns the moment object]
|
|
108
119
|
*
|
package/maker.js
CHANGED
|
@@ -101,7 +101,7 @@ function secret(author, format) {
|
|
|
101
101
|
/** pioneer
|
|
102
102
|
* [Pioneer Protocol Buffer Creation]
|
|
103
103
|
*
|
|
104
|
-
* @param {string}
|
|
104
|
+
* @param {string} xbigbang (required) // The creation moment is the bigbang of the system
|
|
105
105
|
* @param {string} format (required)
|
|
106
106
|
*
|
|
107
107
|
* @return {string} pioneer_buffer
|
package/package.json
CHANGED