@peerbit/test-lib 0.0.1-e182140 → 0.0.1-e209d2e
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.js +81 -41
- package/dist/src/index.js.map +1 -1
- package/package.json +14 -11
package/dist/src/index.js
CHANGED
|
@@ -1,52 +1,92 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
6
27
|
};
|
|
7
|
-
var
|
|
8
|
-
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
9
34
|
};
|
|
10
35
|
import { field, variant, vec } from "@dao-xyz/borsh";
|
|
11
36
|
import {} from "@libp2p/interface";
|
|
12
37
|
import { Ed25519PublicKey, PublicSignKey } from "@peerbit/crypto";
|
|
13
38
|
import { Program } from "@peerbit/program";
|
|
14
39
|
import { DString } from "@peerbit/string";
|
|
15
|
-
let PermissionedString =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
let PermissionedString = (() => {
|
|
41
|
+
let _classDecorators = [variant("permissioned_string")];
|
|
42
|
+
let _classDescriptor;
|
|
43
|
+
let _classExtraInitializers = [];
|
|
44
|
+
let _classThis;
|
|
45
|
+
let _classSuper = Program;
|
|
46
|
+
let __store_decorators;
|
|
47
|
+
let __store_initializers = [];
|
|
48
|
+
let __store_extraInitializers = [];
|
|
49
|
+
let _trusted_decorators;
|
|
50
|
+
let _trusted_initializers = [];
|
|
51
|
+
let _trusted_extraInitializers = [];
|
|
52
|
+
var PermissionedString = class extends _classSuper {
|
|
53
|
+
static { _classThis = this; }
|
|
54
|
+
static {
|
|
55
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
56
|
+
__store_decorators = [field({ type: DString })];
|
|
57
|
+
_trusted_decorators = [field({ type: vec(PublicSignKey) })];
|
|
58
|
+
__esDecorate(null, null, __store_decorators, { kind: "field", name: "_store", static: false, private: false, access: { has: obj => "_store" in obj, get: obj => obj._store, set: (obj, value) => { obj._store = value; } }, metadata: _metadata }, __store_initializers, __store_extraInitializers);
|
|
59
|
+
__esDecorate(null, null, _trusted_decorators, { kind: "field", name: "trusted", static: false, private: false, access: { has: obj => "trusted" in obj, get: obj => obj.trusted, set: (obj, value) => { obj.trusted = value; } }, metadata: _metadata }, _trusted_initializers, _trusted_extraInitializers);
|
|
60
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
61
|
+
PermissionedString = _classThis = _classDescriptor.value;
|
|
62
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
63
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
64
|
+
}
|
|
65
|
+
_store = __runInitializers(this, __store_initializers, void 0);
|
|
66
|
+
trusted = (__runInitializers(this, __store_extraInitializers), __runInitializers(this, _trusted_initializers, void 0));
|
|
67
|
+
constructor(properties) {
|
|
68
|
+
super();
|
|
69
|
+
__runInitializers(this, _trusted_extraInitializers);
|
|
70
|
+
this._store = properties?.store || new DString({});
|
|
71
|
+
this.trusted =
|
|
72
|
+
properties?.trusted.map((x) => x instanceof PublicSignKey ? x : Ed25519PublicKey.fromPeerId(x)) || [];
|
|
73
|
+
}
|
|
74
|
+
get store() {
|
|
75
|
+
return this._store;
|
|
76
|
+
}
|
|
77
|
+
async open(_args) {
|
|
78
|
+
await this._store.open();
|
|
79
|
+
}
|
|
80
|
+
isTrusted(keyHash) {
|
|
81
|
+
for (const t of this.trusted) {
|
|
82
|
+
if (t.hashcode() == keyHash) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
34
85
|
}
|
|
86
|
+
return false;
|
|
35
87
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
__decorate([
|
|
40
|
-
field({ type: DString }),
|
|
41
|
-
__metadata("design:type", DString)
|
|
42
|
-
], PermissionedString.prototype, "_store", void 0);
|
|
43
|
-
__decorate([
|
|
44
|
-
field({ type: vec(PublicSignKey) }),
|
|
45
|
-
__metadata("design:type", Array)
|
|
46
|
-
], PermissionedString.prototype, "trusted", void 0);
|
|
47
|
-
PermissionedString = __decorate([
|
|
48
|
-
variant("permissioned_string"),
|
|
49
|
-
__metadata("design:paramtypes", [Object])
|
|
50
|
-
], PermissionedString);
|
|
88
|
+
};
|
|
89
|
+
return PermissionedString = _classThis;
|
|
90
|
+
})();
|
|
51
91
|
export { PermissionedString };
|
|
52
92
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;IAG7B,kBAAkB;4BAD9B,OAAO,CAAC,qBAAqB,CAAC;;;;sBACS,OAAO;;;;;;;kCAAf,SAA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
4
|
"author": "dao.xyz",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -57,18 +57,21 @@
|
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=16.15.1"
|
|
59
59
|
},
|
|
60
|
-
"scripts": {
|
|
61
|
-
"clean": "shx rm -rf dist/*",
|
|
62
|
-
"build": "yarn clean && tsc -p tsconfig.json; tsc -p tsconfig.json",
|
|
63
|
-
"test": "aegir test -t node"
|
|
64
|
-
},
|
|
65
60
|
"devDependencies": {
|
|
66
61
|
"tty-table": "^4.2.1",
|
|
67
|
-
"@peerbit/test-utils": "2.
|
|
68
|
-
"libp2p": "^
|
|
62
|
+
"@peerbit/test-utils": "2.3.14-e209d2e",
|
|
63
|
+
"libp2p": "^3.1.0"
|
|
69
64
|
},
|
|
70
65
|
"dependencies": {
|
|
71
|
-
"@
|
|
72
|
-
"
|
|
66
|
+
"@dao-xyz/borsh": "^6.0.0",
|
|
67
|
+
"@libp2p/interface": "^3.1.0",
|
|
68
|
+
"@peerbit/crypto": "2.4.1-e209d2e",
|
|
69
|
+
"@peerbit/program": "5.5.2-e209d2e",
|
|
70
|
+
"@peerbit/string": "5.1.15-e209d2e"
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"clean": "shx rm -rf dist/*",
|
|
74
|
+
"build": "pnpm run clean && tsc -p tsconfig.json && tsc -p tsconfig.json",
|
|
75
|
+
"test": "aegir test -t node"
|
|
73
76
|
}
|
|
74
|
-
}
|
|
77
|
+
}
|