@libp2p/record 0.10.6 → 1.0.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.
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -1
- package/package.json +5 -7
- package/src/index.ts +10 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IRecord } from './record.js';
|
|
1
2
|
export declare class Libp2pRecord {
|
|
2
3
|
key: Uint8Array;
|
|
3
4
|
value: Uint8Array;
|
|
@@ -19,6 +20,6 @@ export declare class Libp2pRecord {
|
|
|
19
20
|
/**
|
|
20
21
|
* Create a record from the raw object returned from the protobuf library
|
|
21
22
|
*/
|
|
22
|
-
static fromDeserialized(obj:
|
|
23
|
+
static fromDeserialized(obj: IRecord): Libp2pRecord;
|
|
23
24
|
}
|
|
24
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAER,MAAM,aAAa,CAAA;AAGpB,qBAAa,YAAY;IAChB,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,UAAU,CAAA;IACjB,YAAY,CAAC,EAAE,IAAI,CAAA;gBAEb,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,IAAI;IAcpE,SAAS;IAIT;;OAEG;IACH,gBAAgB;;;;;IAQhB;;OAEG;IACH,MAAM,CAAC,WAAW,CAAE,GAAG,EAAE,UAAU;IAUnC;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAE,GAAG,EAAE,OAAO;CAoBtC"}
|
package/dist/src/index.js
CHANGED
|
@@ -45,6 +45,12 @@ export class Libp2pRecord {
|
|
|
45
45
|
if (obj.timeReceived != null) {
|
|
46
46
|
recvtime = utils.parseRFC3339(obj.timeReceived);
|
|
47
47
|
}
|
|
48
|
+
if (obj.key == null) {
|
|
49
|
+
throw new Error('key missing from deserialized object');
|
|
50
|
+
}
|
|
51
|
+
if (obj.value == null) {
|
|
52
|
+
throw new Error('value missing from deserialized object');
|
|
53
|
+
}
|
|
48
54
|
const rec = new Libp2pRecord(obj.key, obj.value, recvtime);
|
|
49
55
|
return rec;
|
|
50
56
|
}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,IAAI,QAAQ,EACnB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC,MAAM,OAAO,YAAY;IAKvB,YAAa,GAAe,EAAE,KAAiB,EAAE,YAAmB;QAClE,IAAI,CAAC,CAAC,GAAG,YAAY,UAAU,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;SAC5C;QAED,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,EAAE;YAClC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;SAC9C;QAED,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED,SAAS;QACP,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAA;IAC1D,CAAC;IA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
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "libp2p record implementation",
|
|
5
5
|
"author": "Friedel Ziegelmayer <dignifiedquire@gmail.com>",
|
|
6
6
|
"license": "Apache-2.0 OR MIT",
|
|
@@ -155,8 +155,8 @@
|
|
|
155
155
|
"test:firefox-webworker": "npm run test -- -t webworker -- --browser firefox",
|
|
156
156
|
"build": "tsc",
|
|
157
157
|
"postbuild": "npm run build:copy-proto-files",
|
|
158
|
-
"
|
|
159
|
-
"
|
|
158
|
+
"generate:proto": "pbjs -t static-module -w es6 -r libp2p-record --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/record/record.js ./src/record/record.proto",
|
|
159
|
+
"generate:proto-types": "pbts -o src/record/record.d.ts src/record/record.js",
|
|
160
160
|
"build:copy-proto-files": "cp src/record* dist/src",
|
|
161
161
|
"release": "semantic-release"
|
|
162
162
|
},
|
|
@@ -168,9 +168,7 @@
|
|
|
168
168
|
},
|
|
169
169
|
"devDependencies": {
|
|
170
170
|
"@libp2p/crypto": "^0.22.7",
|
|
171
|
-
"@libp2p/interfaces": "^1.
|
|
172
|
-
"aegir": "^36.1.3"
|
|
173
|
-
"npm-run-all": "^4.1.5",
|
|
174
|
-
"util": "^0.12.4"
|
|
171
|
+
"@libp2p/interfaces": "^1.3.3",
|
|
172
|
+
"aegir": "^36.1.3"
|
|
175
173
|
}
|
|
176
174
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
IRecord,
|
|
2
3
|
Record as PBRecord
|
|
3
4
|
} from './record.js'
|
|
4
5
|
import * as utils from './utils.js'
|
|
@@ -53,12 +54,20 @@ export class Libp2pRecord {
|
|
|
53
54
|
/**
|
|
54
55
|
* Create a record from the raw object returned from the protobuf library
|
|
55
56
|
*/
|
|
56
|
-
static fromDeserialized (obj:
|
|
57
|
+
static fromDeserialized (obj: IRecord) {
|
|
57
58
|
let recvtime
|
|
58
59
|
if (obj.timeReceived != null) {
|
|
59
60
|
recvtime = utils.parseRFC3339(obj.timeReceived)
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
if (obj.key == null) {
|
|
64
|
+
throw new Error('key missing from deserialized object')
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (obj.value == null) {
|
|
68
|
+
throw new Error('value missing from deserialized object')
|
|
69
|
+
}
|
|
70
|
+
|
|
62
71
|
const rec = new Libp2pRecord(
|
|
63
72
|
obj.key, obj.value, recvtime
|
|
64
73
|
)
|