moeralib 0.15.4 → 0.15.5

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.
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.verifyFingerprintSignature = exports.signFingerprint = exports.digestFingerprint = exports.fingerprintBytes = exports.rawToPrivateKey = exports.rawPrivateKey = exports.rawToPublicKey = exports.rawPublicKey = exports.mnemonicToPrivateKey = exports.generateMnemonicKey = exports.generateKey = void 0;
39
+ const crypto_1 = __importDefault(require("crypto"));
40
+ const util_1 = require("util");
41
+ const bip39 = __importStar(require("@scure/bip39"));
42
+ const english_1 = require("@scure/bip39/wordlists/english");
43
+ const fingerprint_1 = require("./fingerprint");
44
+ const EMPTY_KEY = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
45
+ const CURVE_FIELD = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f");
46
+ /**
47
+ * Generate a pair of cryptographic keys.
48
+ *
49
+ * @return {Promise<crypto.KeyPairKeyObjectResult>} the keys
50
+ */
51
+ function generateKey() {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ return (0, util_1.promisify)(crypto_1.default.generateKeyPair)("ec", { namedCurve: "secp256k1" });
54
+ });
55
+ }
56
+ exports.generateKey = generateKey;
57
+ /**
58
+ * Generate a private cryptographic key with a mnemonic.
59
+ *
60
+ * @return {Promise<[string, crypto.KeyObject]>} the mnemonic and the key
61
+ */
62
+ function generateMnemonicKey() {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const mnemonic = bip39.generateMnemonic(english_1.wordlist, 256);
65
+ const privateKey = yield mnemonicToPrivateKey(mnemonic);
66
+ return [mnemonic, privateKey];
67
+ });
68
+ }
69
+ exports.generateMnemonicKey = generateMnemonicKey;
70
+ /**
71
+ * Restore a private key from the given mnemonic.
72
+ *
73
+ * @param {string} mnemonic - the mnemonic
74
+ * @return {Promise<crypto.KeyObject>} the private key
75
+ */
76
+ function mnemonicToPrivateKey(mnemonic) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ const seed = yield bip39.mnemonicToSeed(mnemonic);
79
+ let seedValue = BigInt(0);
80
+ for (let i = 0; i < seed.length; i++) {
81
+ seedValue = (seedValue << BigInt(8)) + BigInt(seed[i]);
82
+ }
83
+ const dValue = (seedValue % CURVE_FIELD).toString(16).padStart(64, "0");
84
+ const d = Buffer.alloc(32);
85
+ for (let i = 0; i < 32; i++) {
86
+ d.writeUint8(parseInt(dValue.substring(i * 2, 2), 16), i);
87
+ }
88
+ return crypto_1.default.createPrivateKey({
89
+ format: "jwk",
90
+ key: {
91
+ kty: "EC",
92
+ d: d.toString("base64url"),
93
+ crv: "secp256k1"
94
+ }
95
+ });
96
+ });
97
+ }
98
+ exports.mnemonicToPrivateKey = mnemonicToPrivateKey;
99
+ /**
100
+ * Convert a public key to the raw format used by the naming server.
101
+ *
102
+ * @param {crypto.KeyObject} publicKey - the public key
103
+ * @return {Buffer} the raw public key
104
+ */
105
+ function rawPublicKey(publicKey) {
106
+ var _a, _b;
107
+ const jwk = publicKey.export({ format: "jwk" });
108
+ return Buffer.concat([
109
+ Buffer.from((_a = jwk.x) !== null && _a !== void 0 ? _a : EMPTY_KEY, "base64url"),
110
+ Buffer.from((_b = jwk.y) !== null && _b !== void 0 ? _b : EMPTY_KEY, "base64url")
111
+ ]);
112
+ }
113
+ exports.rawPublicKey = rawPublicKey;
114
+ /**
115
+ * Restore a public key from the raw format.
116
+ *
117
+ * @param {Buffer} rawPublicKey - the raw public key
118
+ * @return {crypto.KeyObject} the public key
119
+ */
120
+ function rawToPublicKey(rawPublicKey) {
121
+ const x = rawPublicKey.subarray(0, 32).toString("base64url");
122
+ const y = rawPublicKey.subarray(32, 64).toString("base64url");
123
+ return crypto_1.default.createPublicKey({
124
+ format: "jwk",
125
+ key: {
126
+ kty: "EC",
127
+ x,
128
+ y,
129
+ crv: "secp256k1"
130
+ }
131
+ });
132
+ }
133
+ exports.rawToPublicKey = rawToPublicKey;
134
+ /**
135
+ * Convert a private key to the raw format to pass to the client.
136
+ *
137
+ * @param {crypto.KeyObject} privateKey - the private key
138
+ * @return {Buffer} the raw private key
139
+ */
140
+ function rawPrivateKey(privateKey) {
141
+ var _a;
142
+ const jwk = privateKey.export({ format: "jwk" });
143
+ return Buffer.from((_a = jwk.d) !== null && _a !== void 0 ? _a : EMPTY_KEY, "base64url");
144
+ }
145
+ exports.rawPrivateKey = rawPrivateKey;
146
+ /**
147
+ * Restore a private key from the raw format.
148
+ *
149
+ * @param {Buffer} rawPrivateKey - the raw private key
150
+ * @return {crypto.KeyObject} the private key
151
+ */
152
+ function rawToPrivateKey(rawPrivateKey) {
153
+ const d = rawPrivateKey.toString("base64url");
154
+ return crypto_1.default.createPrivateKey({
155
+ format: "jwk",
156
+ key: {
157
+ kty: "EC",
158
+ // x and y here are placeholders
159
+ x: 'xJrw0U2Qb1xyoxpfwCYVwCZakhd-LbjeBvLLNGAPTEU',
160
+ y: 'INp-PvmYleX19zhuXbwfnIcZO9a8RSuK7r-_4jneDGM',
161
+ d,
162
+ crv: "secp256k1"
163
+ }
164
+ });
165
+ }
166
+ exports.rawToPrivateKey = rawToPrivateKey;
167
+ /**
168
+ * Encode a fingerprint in the binary form, using the given fingerprint data and schema.
169
+ *
170
+ * @param {Fingerprint} fingerprint - the fingerprint data
171
+ * @param {FingerprintSchema} schema - the fingerprint schema
172
+ * @return {Buffer} the fingerprint in the binary form
173
+ */
174
+ function fingerprintBytes(fingerprint, schema) {
175
+ const fingerprintWriter = new fingerprint_1.FingerprintWriter();
176
+ fingerprintWriter.append(fingerprint, schema);
177
+ return fingerprintWriter.toBytes();
178
+ }
179
+ exports.fingerprintBytes = fingerprintBytes;
180
+ /**
181
+ * Calculate a cryptographic digest of the fingerprint.
182
+ *
183
+ * @param {Buffer} fingerprint - the fingerprint
184
+ * @return {Buffer} the digest
185
+ */
186
+ function digestFingerprint(fingerprint) {
187
+ const digest = crypto_1.default.createHash("sha3-256");
188
+ digest.update(fingerprint);
189
+ return digest.digest();
190
+ }
191
+ exports.digestFingerprint = digestFingerprint;
192
+ /**
193
+ * Sign a fingerprint with a private key.
194
+ *
195
+ * @param {Buffer} fingerprint - the fingerprint to be signed
196
+ * @param {crypto.KeyObject} privateKey - the private key
197
+ * @return {Buffer} the signature
198
+ */
199
+ function signFingerprint(fingerprint, privateKey) {
200
+ const sign = crypto_1.default.createSign("SHA3-256");
201
+ sign.update(fingerprint);
202
+ return sign.sign(privateKey);
203
+ }
204
+ exports.signFingerprint = signFingerprint;
205
+ /**
206
+ * Verify a fingerprint signature with the given public key.
207
+ *
208
+ * @param {Buffer} fingerprint - the original fingerprint
209
+ * @param {Buffer} signature - the signature to be verified
210
+ * @param {crypto.KeyObject} publicKey - the public key for verification
211
+ * @return {boolean} `true`, if the signature is correct, `false` otherwise
212
+ */
213
+ function verifyFingerprintSignature(fingerprint, signature, publicKey) {
214
+ const verify = crypto_1.default.createVerify("SHA3-256");
215
+ verify.update(fingerprint);
216
+ return verify.verify(publicKey, signature);
217
+ }
218
+ exports.verifyFingerprintSignature = verifyFingerprintSignature;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FingerprintWriter = void 0;
4
+ class FingerprintWriter {
5
+ constructor() {
6
+ this.data = [];
7
+ }
8
+ appendNull() {
9
+ this.data.push(0xff);
10
+ }
11
+ appendString(str) {
12
+ if (str == null) {
13
+ this.appendNull();
14
+ return;
15
+ }
16
+ const buf = Buffer.from(str);
17
+ this.appendNumber(buf.length);
18
+ this.data.push(...buf.values());
19
+ }
20
+ appendBoolean(b) {
21
+ this.data.push(b ? 1 : 0);
22
+ }
23
+ appendNumber(l) {
24
+ let len;
25
+ if (l < 0xfc) {
26
+ len = 1;
27
+ }
28
+ else if (l <= 0xffff) {
29
+ this.data.push(0xfc);
30
+ len = 2;
31
+ }
32
+ else if (l <= 0xffffffff) {
33
+ this.data.push(0xfd);
34
+ len = 4;
35
+ }
36
+ else {
37
+ this.data.push(0xfe);
38
+ len = 8;
39
+ }
40
+ for (let i = 0; i < len; i++) {
41
+ this.data.push(l & 0xff);
42
+ l = l >> 8;
43
+ }
44
+ }
45
+ appendBytes(b) {
46
+ this.appendNumber(b.length);
47
+ this.data.push(...b.values());
48
+ }
49
+ appendFingerprint(fingerprint, schema) {
50
+ for (const field of schema) {
51
+ this.append(fingerprint[field[0]], field[1]);
52
+ }
53
+ }
54
+ appendList(list, type) {
55
+ const writer = new FingerprintWriter();
56
+ list.forEach(value => writer.append(value, type));
57
+ this.appendBytes(writer.toBytes());
58
+ }
59
+ append(value, type) {
60
+ if (value == null) {
61
+ this.appendNull();
62
+ }
63
+ else if (Array.isArray(type)) {
64
+ this.appendFingerprint(value, type);
65
+ }
66
+ else if (type.endsWith("[]")) {
67
+ this.appendList(value, type.substring(0, type.length - 2));
68
+ }
69
+ else if (type === "string") {
70
+ this.appendString(value);
71
+ }
72
+ else if (type === "boolean") {
73
+ this.appendBoolean(value);
74
+ }
75
+ else if (type === "number") {
76
+ this.appendNumber(value);
77
+ }
78
+ else if (type === "bytes") {
79
+ this.appendBytes(value);
80
+ }
81
+ }
82
+ toBytes() {
83
+ return Buffer.from(this.data);
84
+ }
85
+ }
86
+ exports.FingerprintWriter = FingerprintWriter;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyFingerprintSignature = exports.signFingerprint = exports.digestFingerprint = exports.rawToPublicKey = exports.rawToPrivateKey = exports.rawPublicKey = exports.rawPrivateKey = exports.mnemonicToPrivateKey = exports.generateMnemonicKey = exports.generateKey = void 0;
4
+ var crypto_1 = require("./crypto");
5
+ Object.defineProperty(exports, "generateKey", { enumerable: true, get: function () { return crypto_1.generateKey; } });
6
+ Object.defineProperty(exports, "generateMnemonicKey", { enumerable: true, get: function () { return crypto_1.generateMnemonicKey; } });
7
+ Object.defineProperty(exports, "mnemonicToPrivateKey", { enumerable: true, get: function () { return crypto_1.mnemonicToPrivateKey; } });
8
+ Object.defineProperty(exports, "rawPrivateKey", { enumerable: true, get: function () { return crypto_1.rawPrivateKey; } });
9
+ Object.defineProperty(exports, "rawPublicKey", { enumerable: true, get: function () { return crypto_1.rawPublicKey; } });
10
+ Object.defineProperty(exports, "rawToPrivateKey", { enumerable: true, get: function () { return crypto_1.rawToPrivateKey; } });
11
+ Object.defineProperty(exports, "rawToPublicKey", { enumerable: true, get: function () { return crypto_1.rawToPublicKey; } });
12
+ Object.defineProperty(exports, "digestFingerprint", { enumerable: true, get: function () { return crypto_1.digestFingerprint; } });
13
+ Object.defineProperty(exports, "signFingerprint", { enumerable: true, get: function () { return crypto_1.signFingerprint; } });
14
+ Object.defineProperty(exports, "verifyFingerprintSignature", { enumerable: true, get: function () { return crypto_1.verifyFingerprintSignature; } });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPutCallFingerprint0 = void 0;
4
+ const crypto_1 = require("../crypto/crypto");
5
+ const PUT_CALL_FINGERPRINT0_SCHEMA = [
6
+ ["version", "number"],
7
+ ["name", "string"],
8
+ ["generation", "number"],
9
+ ["updating_key", "bytes"],
10
+ ["node_uri", "string"],
11
+ ["signing_key", "bytes"],
12
+ ["valid_from", "number"],
13
+ ["previous_digest", "bytes"],
14
+ ];
15
+ function createPutCallFingerprint0(name, generation, updatingKey, nodeUri, signingKey, validFrom, previousDigest) {
16
+ return (0, crypto_1.fingerprintBytes)({ "version": 0, name, generation, updatingKey, nodeUri, signingKey, validFrom, previousDigest }, PUT_CALL_FINGERPRINT0_SCHEMA);
17
+ }
18
+ exports.createPutCallFingerprint0 = createPutCallFingerprint0;
@@ -8,8 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.MoeraCarteSource = exports.MoeraCartesError = void 0;
15
+ exports.generateCarte = exports.MoeraCarteSource = exports.MoeraCartesError = void 0;
16
+ const crypto_1 = __importDefault(require("crypto"));
17
+ const util_1 = require("util");
18
+ const types_1 = require("./types");
19
+ const fingerprints_1 = require("./fingerprints");
20
+ const crypto_2 = require("../crypto");
13
21
  /**
14
22
  * Error obtaining valid cartes.
15
23
  */
@@ -22,26 +30,36 @@ class MoeraCartesError extends Error {
22
30
  }
23
31
  }
24
32
  exports.MoeraCartesError = MoeraCartesError;
25
- function isAdminCarte(carte) {
26
- return carte.permissions == null || carte.permissions.includes("other");
27
- }
28
33
  /**
29
34
  * Class that gets cartes from the given node, caches them and supplies them for authentication.
30
35
  */
31
36
  class MoeraCarteSource {
32
37
  /**
33
38
  * @param {MoeraNode} node node to get cartes from
39
+ * @param {Scope[] | null} clientScope permissions to be granted to the cartes; if not set, all permissions of
40
+ * the cartes' owner are granted
41
+ * @param {Scope[] | null} adminScope additional administrative permissions (of those granted to the cartes' owner
42
+ * by the target node) to be granted to the cartes
43
+ * @param {string | null} targetNodeName if set, the cartes are valid for authentication on the specified node only
34
44
  */
35
- constructor(node) {
45
+ constructor(node, clientScope = null, adminScope = null, targetNodeName = null) {
36
46
  this.cartes = [];
37
47
  this.node = node;
48
+ this.clientScope = clientScope !== null && clientScope !== void 0 ? clientScope : ["all"];
49
+ this.adminScope = adminScope !== null && adminScope !== void 0 ? adminScope : [];
50
+ this.targetNodeName = targetNodeName;
38
51
  }
39
52
  /**
40
53
  * Force renewing the cached list of cartes.
41
54
  */
42
55
  renew() {
43
56
  return __awaiter(this, void 0, void 0, function* () {
44
- this.cartes = (yield this.node.getCartes()).cartes;
57
+ const attributes = {
58
+ clientScope: this.clientScope,
59
+ adminScope: this.adminScope,
60
+ nodeName: this.targetNodeName
61
+ };
62
+ this.cartes = (yield this.node.createCartes(attributes)).cartes;
45
63
  });
46
64
  }
47
65
  /**
@@ -53,7 +71,7 @@ class MoeraCarteSource {
53
71
  return __awaiter(this, void 0, void 0, function* () {
54
72
  for (const renewed of [false, true]) {
55
73
  const now = Math.floor(Date.now() / 1000);
56
- this.cartes = this.cartes.filter(c => c.deadline > now && isAdminCarte(c));
74
+ this.cartes = this.cartes.filter(c => c.deadline > now);
57
75
  if (this.cartes.length === 0) {
58
76
  if (renewed) {
59
77
  throw new MoeraCartesError("Could not obtain a valid carte from the node");
@@ -73,3 +91,34 @@ class MoeraCarteSource {
73
91
  }
74
92
  }
75
93
  exports.MoeraCarteSource = MoeraCarteSource;
94
+ function toScopeMask(scope) {
95
+ let mask = 0;
96
+ for (const sc of scope) {
97
+ mask |= types_1.SCOPE_VALUES[sc];
98
+ }
99
+ return mask;
100
+ }
101
+ /**
102
+ * Generate a carte with the given parameters and sign it with the provided private signing key.
103
+ *
104
+ * @param {string | null} ownerName - name of the node authenticating with the carte
105
+ * @param {crypto.KeyObject} signingKey - the private signing key to sign the carte
106
+ * @param {number} beginning - timestamp of the beginning of the carte's life
107
+ * @param {GenerateCarteOptions} options - carte options
108
+ * @return {Promise<string>} the carte
109
+ */
110
+ function generateCarte(ownerName_1, signingKey_1, beginning_1) {
111
+ return __awaiter(this, arguments, void 0, function* (ownerName, signingKey, beginning, { ttl = 600, address = null, nodeName = null, clientScope = types_1.SCOPE_VALUES["all"], adminScope = 0 } = {}) {
112
+ if (Array.isArray(clientScope)) {
113
+ clientScope = toScopeMask(clientScope);
114
+ }
115
+ if (Array.isArray(adminScope)) {
116
+ adminScope = toScopeMask(adminScope);
117
+ }
118
+ const salt = yield (0, util_1.promisify)(crypto_1.default.randomBytes)(8);
119
+ const fingerprint = (0, fingerprints_1.createCarteFingerprint2)(ownerName, address, beginning, beginning + ttl, nodeName, clientScope, adminScope, salt);
120
+ const signature = (0, crypto_2.signFingerprint)(fingerprint, signingKey);
121
+ return Buffer.concat([fingerprint, signature]).toString("base64url");
122
+ });
123
+ }
124
+ exports.generateCarte = generateCarte;
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ // This file is generated
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.createSheriffOrderFingerprint0 = exports.createReactionFingerprint0 = exports.createPushRelayRegisterFingerprint0 = exports.createPushRelayMessageFingerprint0 = exports.createPostingFingerprint0 = exports.createPostingFingerprint1 = exports.createNotificationPacketFingerprint0 = exports.createNotificationPacketFingerprint1 = exports.createCommentFingerprint0 = exports.createCarteFingerprint0 = exports.createCarteFingerprint1 = exports.createCarteFingerprint2 = exports.createAttachmentFingerprint0 = void 0;
5
+ const crypto_1 = require("../crypto/crypto");
6
+ const ATTACHMENT_FINGERPRINT0_SCHEMA = [
7
+ ["version", "number"],
8
+ ["objectType", "string"],
9
+ ["digest", "bytes"],
10
+ ];
11
+ function createAttachmentFingerprint0(digest) {
12
+ return (0, crypto_1.fingerprintBytes)({ "version": 0, "objectType": "ATTACHMENT", digest }, ATTACHMENT_FINGERPRINT0_SCHEMA);
13
+ }
14
+ exports.createAttachmentFingerprint0 = createAttachmentFingerprint0;
15
+ const CARTE_FINGERPRINT2_SCHEMA = [
16
+ ["version", "number"],
17
+ ["objectType", "string"],
18
+ ["ownerName", "string"],
19
+ ["address", "string"],
20
+ ["beginning", "number"],
21
+ ["deadline", "number"],
22
+ ["nodeName", "string"],
23
+ ["clientScope", "number"],
24
+ ["adminScope", "number"],
25
+ ["salt", "bytes"],
26
+ ];
27
+ function createCarteFingerprint2(ownerName, address, beginning, deadline, nodeName, clientScope, adminScope, salt) {
28
+ return (0, crypto_1.fingerprintBytes)({ "version": 2, "objectType": "CARTE", ownerName, address, beginning, deadline, nodeName, clientScope, adminScope,
29
+ salt }, CARTE_FINGERPRINT2_SCHEMA);
30
+ }
31
+ exports.createCarteFingerprint2 = createCarteFingerprint2;
32
+ const CARTE_FINGERPRINT1_SCHEMA = [
33
+ ["version", "number"],
34
+ ["objectType", "string"],
35
+ ["ownerName", "string"],
36
+ ["address", "string"],
37
+ ["beginning", "number"],
38
+ ["deadline", "number"],
39
+ ["nodeName", "string"],
40
+ ["authCategory", "number"],
41
+ ["salt", "bytes"],
42
+ ];
43
+ function createCarteFingerprint1(ownerName, address, beginning, deadline, nodeName, authCategory, salt) {
44
+ return (0, crypto_1.fingerprintBytes)({ "version": 1, "objectType": "CARTE", ownerName, address, beginning, deadline, nodeName, authCategory, salt }, CARTE_FINGERPRINT1_SCHEMA);
45
+ }
46
+ exports.createCarteFingerprint1 = createCarteFingerprint1;
47
+ const CARTE_FINGERPRINT0_SCHEMA = [
48
+ ["version", "number"],
49
+ ["objectType", "string"],
50
+ ["ownerName", "string"],
51
+ ["address", "string"],
52
+ ["beginning", "number"],
53
+ ["deadline", "number"],
54
+ ["permissions", "number"],
55
+ ["salt", "bytes"],
56
+ ];
57
+ function createCarteFingerprint0(ownerName, address, beginning, deadline, permissions, salt) {
58
+ return (0, crypto_1.fingerprintBytes)({ "version": 0, "objectType": "CARTE", ownerName, address, beginning, deadline, permissions, salt }, CARTE_FINGERPRINT0_SCHEMA);
59
+ }
60
+ exports.createCarteFingerprint0 = createCarteFingerprint0;
61
+ const COMMENT_FINGERPRINT0_SCHEMA = [
62
+ ["version", "number"],
63
+ ["objectType", "string"],
64
+ ["ownerName", "string"],
65
+ ["postingFingerprint", "bytes"],
66
+ ["repliedToFingerprint", "bytes"],
67
+ ["bodySrcHash", "bytes"],
68
+ ["bodySrcFormat", "string"],
69
+ ["body", "string"],
70
+ ["bodyFormat", "string"],
71
+ ["createdAt", "number"],
72
+ ["permissions", "number"],
73
+ ["attachments", "bytes[]"],
74
+ ];
75
+ function createCommentFingerprint0(ownerName, postingFingerprint, repliedToFingerprint, bodySrcHash, bodySrcFormat, body, bodyFormat, createdAt, permissions, attachments) {
76
+ return (0, crypto_1.fingerprintBytes)({ "version": 0, "objectType": "COMMENT", ownerName, postingFingerprint, repliedToFingerprint, bodySrcHash,
77
+ bodySrcFormat, body, bodyFormat, createdAt, permissions, attachments }, COMMENT_FINGERPRINT0_SCHEMA);
78
+ }
79
+ exports.createCommentFingerprint0 = createCommentFingerprint0;
80
+ const NOTIFICATION_PACKET_FINGERPRINT1_SCHEMA = [
81
+ ["version", "number"],
82
+ ["objectType", "string"],
83
+ ["id", "string"],
84
+ ["nodeName", "string"],
85
+ ["fullName", "string"],
86
+ ["createdAt", "number"],
87
+ ["type", "string"],
88
+ ["notification", "string"],
89
+ ];
90
+ function createNotificationPacketFingerprint1(id, nodeName, fullName, createdAt, type, notification) {
91
+ return (0, crypto_1.fingerprintBytes)({ "version": 1, "objectType": "NOTIFICATION_PACKET", id, nodeName, fullName, createdAt, type, notification }, NOTIFICATION_PACKET_FINGERPRINT1_SCHEMA);
92
+ }
93
+ exports.createNotificationPacketFingerprint1 = createNotificationPacketFingerprint1;
94
+ const NOTIFICATION_PACKET_FINGERPRINT0_SCHEMA = [
95
+ ["version", "number"],
96
+ ["objectType", "string"],
97
+ ["id", "string"],
98
+ ["nodeName", "string"],
99
+ ["createdAt", "number"],
100
+ ["type", "string"],
101
+ ["notification", "string"],
102
+ ];
103
+ function createNotificationPacketFingerprint0(id, nodeName, createdAt, type, notification) {
104
+ return (0, crypto_1.fingerprintBytes)({ "version": 0, "objectType": "NOTIFICATION_PACKET", id, nodeName, createdAt, type, notification }, NOTIFICATION_PACKET_FINGERPRINT0_SCHEMA);
105
+ }
106
+ exports.createNotificationPacketFingerprint0 = createNotificationPacketFingerprint0;
107
+ const POSTING_FINGERPRINT1_SCHEMA = [
108
+ ["version", "number"],
109
+ ["objectType", "string"],
110
+ ["receiverName", "string"],
111
+ ["ownerName", "string"],
112
+ ["bodySrcHash", "bytes"],
113
+ ["bodySrcFormat", "string"],
114
+ ["body", "string"],
115
+ ["bodyFormat", "string"],
116
+ ["createdAt", "number"],
117
+ ["permissions", "number"],
118
+ ["attachments", "bytes[]"],
119
+ ];
120
+ function createPostingFingerprint1(receiverName, ownerName, bodySrcHash, bodySrcFormat, body, bodyFormat, createdAt, permissions, attachments) {
121
+ return (0, crypto_1.fingerprintBytes)({ "version": 1, "objectType": "POSTING", receiverName, ownerName, bodySrcHash, bodySrcFormat, body, bodyFormat,
122
+ createdAt, permissions, attachments }, POSTING_FINGERPRINT1_SCHEMA);
123
+ }
124
+ exports.createPostingFingerprint1 = createPostingFingerprint1;
125
+ const POSTING_FINGERPRINT0_SCHEMA = [
126
+ ["version", "number"],
127
+ ["objectType", "string"],
128
+ ["receiverName", "string"],
129
+ ["ownerName", "string"],
130
+ ["bodySrcHash", "bytes"],
131
+ ["bodySrcFormat", "string"],
132
+ ["body", "string"],
133
+ ["bodyFormat", "string"],
134
+ ["createdAt", "number"],
135
+ ["permissions", "number"],
136
+ ["attachments", "number"],
137
+ ];
138
+ function createPostingFingerprint0(receiverName, ownerName, bodySrcHash, bodySrcFormat, body, bodyFormat, createdAt, permissions, attachments) {
139
+ return (0, crypto_1.fingerprintBytes)({ "version": 0, "objectType": "POSTING", receiverName, ownerName, bodySrcHash, bodySrcFormat, body, bodyFormat,
140
+ createdAt, permissions, attachments }, POSTING_FINGERPRINT0_SCHEMA);
141
+ }
142
+ exports.createPostingFingerprint0 = createPostingFingerprint0;
143
+ const PUSH_RELAY_MESSAGE_FINGERPRINT0_SCHEMA = [
144
+ ["version", "number"],
145
+ ["objectType", "string"],
146
+ ["signedAt", "number"],
147
+ ];
148
+ function createPushRelayMessageFingerprint0(signedAt) {
149
+ return (0, crypto_1.fingerprintBytes)({ "version": 0, "objectType": "PUSH_RELAY_MESSAGE", signedAt }, PUSH_RELAY_MESSAGE_FINGERPRINT0_SCHEMA);
150
+ }
151
+ exports.createPushRelayMessageFingerprint0 = createPushRelayMessageFingerprint0;
152
+ const PUSH_RELAY_REGISTER_FINGERPRINT0_SCHEMA = [
153
+ ["version", "number"],
154
+ ["objectType", "string"],
155
+ ["clientId", "string"],
156
+ ["lang", "string"],
157
+ ["signedAt", "number"],
158
+ ];
159
+ function createPushRelayRegisterFingerprint0(clientId, lang, signedAt) {
160
+ return (0, crypto_1.fingerprintBytes)({ "version": 0, "objectType": "PUSH_RELAY_REGISTER", clientId, lang, signedAt }, PUSH_RELAY_REGISTER_FINGERPRINT0_SCHEMA);
161
+ }
162
+ exports.createPushRelayRegisterFingerprint0 = createPushRelayRegisterFingerprint0;
163
+ const REACTION_FINGERPRINT0_SCHEMA = [
164
+ ["version", "number"],
165
+ ["objectType", "string"],
166
+ ["ownerName", "string"],
167
+ ["entryFingerprint", "bytes"],
168
+ ["negative", "boolean"],
169
+ ["emoji", "number"],
170
+ ];
171
+ function createReactionFingerprint0(ownerName, entryFingerprint, negative, emoji) {
172
+ return (0, crypto_1.fingerprintBytes)({ "version": 0, "objectType": "REACTION", ownerName, entryFingerprint, negative, emoji }, REACTION_FINGERPRINT0_SCHEMA);
173
+ }
174
+ exports.createReactionFingerprint0 = createReactionFingerprint0;
175
+ const SHERIFF_ORDER_FINGERPRINT0_SCHEMA = [
176
+ ["version", "number"],
177
+ ["objectType", "string"],
178
+ ["sheriffName", "string"],
179
+ ["nodeName", "string"],
180
+ ["feedName", "string"],
181
+ ["entryFingerprint", "bytes"],
182
+ ["category", "string"],
183
+ ["reasonCode", "string"],
184
+ ["reasonDetails", "string"],
185
+ ["createdAt", "number"],
186
+ ];
187
+ function createSheriffOrderFingerprint0(sheriffName, nodeName, feedName, entryFingerprint, category, reasonCode, reasonDetails, createdAt) {
188
+ return (0, crypto_1.fingerprintBytes)({ "version": 0, "objectType": "SHERIFF_ORDER", sheriffName, nodeName, feedName, entryFingerprint, category,
189
+ reasonCode, reasonDetails, createdAt }, SHERIFF_ORDER_FINGERPRINT0_SCHEMA);
190
+ }
191
+ exports.createSheriffOrderFingerprint0 = createSheriffOrderFingerprint0;
package/lib/node/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateNodeSchema = exports.MoeraCartesError = exports.MoeraCarteSource = exports.moeraRoot = exports.MoeraNodeCallError = exports.MoeraNodeConnectionError = exports.MoeraNodeApiError = exports.MoeraNodeError = exports.MoeraNode = void 0;
3
+ exports.validateNodeSchema = exports.generateCarte = exports.MoeraCartesError = exports.MoeraCarteSource = exports.moeraRoot = exports.MoeraNodeCallError = exports.MoeraNodeConnectionError = exports.MoeraNodeApiError = exports.MoeraNodeError = exports.MoeraNode = void 0;
4
4
  var node_1 = require("./node");
5
5
  Object.defineProperty(exports, "MoeraNode", { enumerable: true, get: function () { return node_1.MoeraNode; } });
6
6
  var caller_1 = require("./caller");
@@ -12,5 +12,6 @@ Object.defineProperty(exports, "moeraRoot", { enumerable: true, get: function ()
12
12
  var cartes_1 = require("./cartes");
13
13
  Object.defineProperty(exports, "MoeraCarteSource", { enumerable: true, get: function () { return cartes_1.MoeraCarteSource; } });
14
14
  Object.defineProperty(exports, "MoeraCartesError", { enumerable: true, get: function () { return cartes_1.MoeraCartesError; } });
15
+ Object.defineProperty(exports, "generateCarte", { enumerable: true, get: function () { return cartes_1.generateCarte; } });
15
16
  var validate_1 = require("./validate");
16
17
  Object.defineProperty(exports, "validateNodeSchema", { enumerable: true, get: function () { return validate_1.validateSchema; } });