@waku/rln 0.1.6-76fb1ea.0 → 0.1.6-86bbf5b.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/bundle/index.js +1 -1
- package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +0 -1
- package/bundle/packages/core/dist/lib/connection_manager/keep_alive_manager.js +0 -1
- package/bundle/packages/core/dist/lib/filter/filter.js +0 -3
- package/bundle/packages/core/dist/lib/light_push/light_push.js +0 -3
- package/bundle/packages/core/dist/lib/message/version_0.js +0 -2
- package/bundle/packages/core/dist/lib/metadata/metadata.js +0 -3
- package/bundle/packages/core/dist/lib/store/store.js +0 -3
- package/bundle/packages/proto/dist/generated/light_push.js +22 -28
- package/bundle/packages/rln/dist/codec.js +0 -1
- package/bundle/packages/rln/dist/contract/constants.js +7 -1
- package/bundle/packages/rln/dist/contract/rln_base_contract.js +10 -6
- package/bundle/packages/rln/dist/contract/rln_contract.js +0 -1
- package/bundle/packages/rln/dist/credentials_manager.js +16 -15
- package/bundle/packages/rln/dist/identity.js +40 -7
- package/bundle/packages/rln/dist/keystore/keystore.js +15 -12
- package/bundle/packages/rln/dist/message.js +0 -15
- package/bundle/packages/rln/dist/rln.js +0 -15
- package/bundle/packages/rln/dist/utils/bytes.js +37 -16
- package/bundle/packages/rln/dist/utils/epoch.js +0 -1
- package/bundle/packages/utils/dist/common/sharding/index.js +0 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/contract/constants.d.ts +6 -0
- package/dist/contract/constants.js +6 -0
- package/dist/contract/constants.js.map +1 -1
- package/dist/contract/rln_base_contract.js +10 -5
- package/dist/contract/rln_base_contract.js.map +1 -1
- package/dist/credentials_manager.js +16 -14
- package/dist/credentials_manager.js.map +1 -1
- package/dist/identity.d.ts +11 -2
- package/dist/identity.js +26 -6
- package/dist/identity.js.map +1 -1
- package/dist/keystore/keystore.js +15 -11
- package/dist/keystore/keystore.js.map +1 -1
- package/dist/utils/bytes.d.ts +12 -5
- package/dist/utils/bytes.js +36 -15
- package/dist/utils/bytes.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/contract/constants.ts +9 -0
- package/src/contract/rln_base_contract.ts +12 -13
- package/src/credentials_manager.ts +27 -21
- package/src/identity.ts +41 -6
- package/src/keystore/keystore.ts +28 -24
- package/src/utils/bytes.ts +46 -25
- package/src/utils/index.ts +1 -1
- package/bundle/packages/core/dist/lib/light_push/light_push_v3.js +0 -31
- package/bundle/packages/core/dist/lib/light_push/status_codes.js +0 -26
- package/bundle/packages/core/dist/lib/light_push/status_codes_v3.js +0 -17
- package/bundle/packages/interfaces/dist/light_push_v3.js +0 -16
- package/bundle/packages/proto/dist/generated/light_push_v2.js +0 -389
- package/bundle/packages/proto/dist/generated/light_push_v3.js +0 -348
- package/dist/contract/test-utils.d.ts +0 -39
- package/dist/contract/test-utils.js +0 -118
- package/dist/contract/test-utils.js.map +0 -1
- package/src/contract/test-utils.ts +0 -179
@@ -79,7 +79,8 @@ export class RLNBaseContract {
|
|
79
79
|
const instance = new RLNBaseContract(options);
|
80
80
|
const [min, max] = await Promise.all([
|
81
81
|
instance.contract.minMembershipRateLimit(),
|
82
|
-
instance.contract.maxMembershipRateLimit()
|
82
|
+
instance.contract.maxMembershipRateLimit(),
|
83
|
+
instance.contract.Q()
|
83
84
|
]);
|
84
85
|
instance.minRateLimit = ethers.BigNumber.from(min).toNumber();
|
85
86
|
instance.maxRateLimit = ethers.BigNumber.from(max).toNumber();
|
@@ -490,7 +491,6 @@ export class RLNBaseContract {
|
|
490
491
|
log.error(`Error in withdraw: ${(error as Error).message}`);
|
491
492
|
}
|
492
493
|
}
|
493
|
-
|
494
494
|
public async registerWithIdentity(
|
495
495
|
identity: IdentityCredential
|
496
496
|
): Promise<DecryptedCredentials | undefined> {
|
@@ -499,10 +499,12 @@ export class RLNBaseContract {
|
|
499
499
|
`Registering identity with rate limit: ${this.rateLimit} messages/epoch`
|
500
500
|
);
|
501
501
|
|
502
|
-
|
503
|
-
|
504
|
-
identity.IDCommitmentBigInt
|
502
|
+
const idCommitmentBigInt = IdentityCredential.getIdCommitmentBigInt(
|
503
|
+
identity.IDCommitment
|
505
504
|
);
|
505
|
+
|
506
|
+
// Check if the ID commitment is already registered
|
507
|
+
const existingIndex = await this.getMemberIndex(idCommitmentBigInt);
|
506
508
|
if (existingIndex) {
|
507
509
|
throw new Error(
|
508
510
|
`ID commitment is already registered with index ${existingIndex}`
|
@@ -518,19 +520,16 @@ export class RLNBaseContract {
|
|
518
520
|
}
|
519
521
|
|
520
522
|
const estimatedGas = await this.contract.estimateGas.register(
|
521
|
-
|
523
|
+
idCommitmentBigInt,
|
522
524
|
this.rateLimit,
|
523
525
|
[]
|
524
526
|
);
|
525
527
|
const gasLimit = estimatedGas.add(10000);
|
526
528
|
|
527
529
|
const txRegisterResponse: ethers.ContractTransaction =
|
528
|
-
await this.contract.register(
|
529
|
-
|
530
|
-
|
531
|
-
[],
|
532
|
-
{ gasLimit }
|
533
|
-
);
|
530
|
+
await this.contract.register(idCommitmentBigInt, this.rateLimit, [], {
|
531
|
+
gasLimit
|
532
|
+
});
|
534
533
|
|
535
534
|
const txRegisterReceipt = await txRegisterResponse.wait();
|
536
535
|
|
@@ -626,7 +625,7 @@ export class RLNBaseContract {
|
|
626
625
|
permit.v,
|
627
626
|
permit.r,
|
628
627
|
permit.s,
|
629
|
-
identity.
|
628
|
+
IdentityCredential.getIdCommitmentBigInt(identity.IDCommitment),
|
630
629
|
this.rateLimit,
|
631
630
|
idCommitmentsToErase.map((id) => ethers.BigNumber.from(id))
|
632
631
|
);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { hmac } from "@noble/hashes/hmac";
|
2
|
-
import { sha256 } from "@noble/hashes/
|
2
|
+
import { sha256 } from "@noble/hashes/sha2";
|
3
3
|
import { Logger } from "@waku/utils";
|
4
4
|
import { ethers } from "ethers";
|
5
5
|
|
@@ -13,10 +13,7 @@ import type {
|
|
13
13
|
} from "./keystore/index.js";
|
14
14
|
import { KeystoreEntity, Password } from "./keystore/types.js";
|
15
15
|
import { RegisterMembershipOptions, StartRLNOptions } from "./types.js";
|
16
|
-
import {
|
17
|
-
buildBigIntFromUint8Array,
|
18
|
-
extractMetaMaskSigner
|
19
|
-
} from "./utils/index.js";
|
16
|
+
import { extractMetaMaskSigner, switchEndianness } from "./utils/index.js";
|
20
17
|
import { Zerokit } from "./zerokit.js";
|
21
18
|
|
22
19
|
const log = new Logger("waku:credentials");
|
@@ -116,7 +113,9 @@ export class RLNCredentialsManager {
|
|
116
113
|
);
|
117
114
|
} else {
|
118
115
|
log.info("Using local implementation to generate identity");
|
119
|
-
identity = this.generateSeededIdentityCredential(
|
116
|
+
identity = await this.generateSeededIdentityCredential(
|
117
|
+
options.signature
|
118
|
+
);
|
120
119
|
}
|
121
120
|
}
|
122
121
|
|
@@ -249,7 +248,9 @@ export class RLNCredentialsManager {
|
|
249
248
|
* @param seed A string seed to generate the identity from
|
250
249
|
* @returns IdentityCredential
|
251
250
|
*/
|
252
|
-
private generateSeededIdentityCredential(
|
251
|
+
private async generateSeededIdentityCredential(
|
252
|
+
seed: string
|
253
|
+
): Promise<IdentityCredential> {
|
253
254
|
log.info("Generating seeded identity credential");
|
254
255
|
// Convert the seed to bytes
|
255
256
|
const encoder = new TextEncoder();
|
@@ -257,26 +258,31 @@ export class RLNCredentialsManager {
|
|
257
258
|
|
258
259
|
// Generate deterministic values using HMAC-SHA256
|
259
260
|
// We use different context strings for each component to ensure they're different
|
260
|
-
const
|
261
|
-
const
|
261
|
+
const idTrapdoorBE = hmac(sha256, seedBytes, encoder.encode("IDTrapdoor"));
|
262
|
+
const idNullifierBE = hmac(
|
263
|
+
sha256,
|
264
|
+
seedBytes,
|
265
|
+
encoder.encode("IDNullifier")
|
266
|
+
);
|
262
267
|
|
263
|
-
|
264
|
-
const
|
265
|
-
const idSecretHash = sha256(combinedBytes);
|
268
|
+
const combinedBytes = new Uint8Array([...idTrapdoorBE, ...idNullifierBE]);
|
269
|
+
const idSecretHashBE = sha256(combinedBytes);
|
266
270
|
|
267
|
-
|
268
|
-
const idCommitment = sha256(idSecretHash);
|
271
|
+
const idCommitmentBE = sha256(idSecretHashBE);
|
269
272
|
|
270
|
-
//
|
271
|
-
|
273
|
+
// All hashing functions return big-endian bytes
|
274
|
+
// We need to switch to little-endian for the identity credential
|
275
|
+
const idTrapdoorLE = switchEndianness(idTrapdoorBE);
|
276
|
+
const idNullifierLE = switchEndianness(idNullifierBE);
|
277
|
+
const idSecretHashLE = switchEndianness(idSecretHashBE);
|
278
|
+
const idCommitmentLE = switchEndianness(idCommitmentBE);
|
272
279
|
|
273
280
|
log.info("Successfully generated identity credential");
|
274
281
|
return new IdentityCredential(
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
idCommitmentBigInt
|
282
|
+
idTrapdoorLE,
|
283
|
+
idNullifierLE,
|
284
|
+
idSecretHashLE,
|
285
|
+
idCommitmentLE
|
280
286
|
);
|
281
287
|
}
|
282
288
|
}
|
package/src/identity.ts
CHANGED
@@ -1,12 +1,22 @@
|
|
1
|
-
import {
|
1
|
+
import { Logger } from "@waku/utils";
|
2
|
+
|
3
|
+
import { DEFAULT_Q } from "./contract/constants.js";
|
4
|
+
import {
|
5
|
+
buildBigIntFromUint8ArrayLE,
|
6
|
+
switchEndiannessBigInt
|
7
|
+
} from "./utils/bytes.js";
|
8
|
+
|
9
|
+
const log = new Logger("waku:rln:identity");
|
2
10
|
|
3
11
|
export class IdentityCredential {
|
12
|
+
/**
|
13
|
+
* All variables are in little-endian format
|
14
|
+
*/
|
4
15
|
public constructor(
|
5
16
|
public readonly IDTrapdoor: Uint8Array,
|
6
17
|
public readonly IDNullifier: Uint8Array,
|
7
18
|
public readonly IDSecretHash: Uint8Array,
|
8
|
-
public readonly IDCommitment: Uint8Array
|
9
|
-
public readonly IDCommitmentBigInt: bigint
|
19
|
+
public readonly IDCommitment: Uint8Array
|
10
20
|
) {}
|
11
21
|
|
12
22
|
public static fromBytes(memKeys: Uint8Array): IdentityCredential {
|
@@ -18,14 +28,39 @@ export class IdentityCredential {
|
|
18
28
|
const idNullifier = memKeys.subarray(32, 64);
|
19
29
|
const idSecretHash = memKeys.subarray(64, 96);
|
20
30
|
const idCommitment = memKeys.subarray(96, 128);
|
21
|
-
const idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment, 32);
|
22
31
|
|
23
32
|
return new IdentityCredential(
|
24
33
|
idTrapdoor,
|
25
34
|
idNullifier,
|
26
35
|
idSecretHash,
|
27
|
-
idCommitment
|
28
|
-
idCommitmentBigInt
|
36
|
+
idCommitment
|
29
37
|
);
|
30
38
|
}
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Converts an ID commitment from bytes to a BigInt, normalizing it against a limit if needed
|
42
|
+
* @param bytes The ID commitment bytes to convert
|
43
|
+
* @param limit Optional limit to normalize against (Q value)
|
44
|
+
* @returns The ID commitment as a BigInt
|
45
|
+
*/
|
46
|
+
public static getIdCommitmentBigInt(
|
47
|
+
idCommitment: Uint8Array,
|
48
|
+
returnType: "big-endian" | "little-endian" = "big-endian",
|
49
|
+
limit: bigint = DEFAULT_Q
|
50
|
+
): bigint {
|
51
|
+
let idCommitmentBigIntLE = buildBigIntFromUint8ArrayLE(idCommitment);
|
52
|
+
|
53
|
+
if (limit && idCommitmentBigIntLE >= limit) {
|
54
|
+
log.warn(
|
55
|
+
`ID commitment is greater than Q, reducing it by Q: ${idCommitmentBigIntLE} % ${limit}`
|
56
|
+
);
|
57
|
+
idCommitmentBigIntLE = idCommitmentBigIntLE % limit;
|
58
|
+
}
|
59
|
+
|
60
|
+
if (returnType === "big-endian") {
|
61
|
+
return switchEndiannessBigInt(idCommitmentBigIntLE);
|
62
|
+
}
|
63
|
+
|
64
|
+
return idCommitmentBigIntLE;
|
65
|
+
}
|
31
66
|
}
|
package/src/keystore/keystore.ts
CHANGED
@@ -14,8 +14,6 @@ import {
|
|
14
14
|
import _ from "lodash";
|
15
15
|
import { v4 as uuidV4 } from "uuid";
|
16
16
|
|
17
|
-
import { buildBigIntFromUint8Array } from "../utils/bytes.js";
|
18
|
-
|
19
17
|
import { decryptEipKeystore, keccak256Checksum } from "./cipher.js";
|
20
18
|
import { isCredentialValid, isKeystoreValid } from "./schema_validator.js";
|
21
19
|
import type {
|
@@ -250,26 +248,25 @@ export class Keystore {
|
|
250
248
|
const str = bytesToUtf8(bytes);
|
251
249
|
const obj = JSON.parse(str);
|
252
250
|
|
253
|
-
|
251
|
+
const idCommitmentLE = Keystore.fromArraylikeToBytes(
|
252
|
+
_.get(obj, "identityCredential.idCommitment", [])
|
253
|
+
);
|
254
|
+
const idTrapdoorLE = Keystore.fromArraylikeToBytes(
|
255
|
+
_.get(obj, "identityCredential.idTrapdoor", [])
|
256
|
+
);
|
257
|
+
const idNullifierLE = Keystore.fromArraylikeToBytes(
|
258
|
+
_.get(obj, "identityCredential.idNullifier", [])
|
259
|
+
);
|
260
|
+
const idSecretHashLE = Keystore.fromArraylikeToBytes(
|
261
|
+
_.get(obj, "identityCredential.idSecretHash", [])
|
262
|
+
);
|
263
|
+
|
254
264
|
return {
|
255
265
|
identity: {
|
256
|
-
IDCommitment:
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
_.get(obj, "identityCredential.idTrapdoor", [])
|
261
|
-
),
|
262
|
-
IDNullifier: Keystore.fromArraylikeToBytes(
|
263
|
-
_.get(obj, "identityCredential.idNullifier", [])
|
264
|
-
),
|
265
|
-
IDCommitmentBigInt: buildBigIntFromUint8Array(
|
266
|
-
Keystore.fromArraylikeToBytes(
|
267
|
-
_.get(obj, "identityCredential.idCommitment", [])
|
268
|
-
)
|
269
|
-
),
|
270
|
-
IDSecretHash: Keystore.fromArraylikeToBytes(
|
271
|
-
_.get(obj, "identityCredential.idSecretHash", [])
|
272
|
-
)
|
266
|
+
IDCommitment: idCommitmentLE,
|
267
|
+
IDTrapdoor: idTrapdoorLE,
|
268
|
+
IDNullifier: idNullifierLE,
|
269
|
+
IDSecretHash: idSecretHashLE
|
273
270
|
},
|
274
271
|
membership: {
|
275
272
|
treeIndex: _.get(obj, "treeIndex"),
|
@@ -321,14 +318,21 @@ export class Keystore {
|
|
321
318
|
// follows nwaku implementation
|
322
319
|
// https://github.com/waku-org/nwaku/blob/f05528d4be3d3c876a8b07f9bb7dfaae8aa8ec6e/waku/waku_keystore/protocol_types.nim#L98
|
323
320
|
private static fromIdentityToBytes(options: KeystoreEntity): Uint8Array {
|
321
|
+
function toLittleEndian(bytes: Uint8Array): Uint8Array {
|
322
|
+
return new Uint8Array(bytes).reverse();
|
323
|
+
}
|
324
324
|
return utf8ToBytes(
|
325
325
|
JSON.stringify({
|
326
326
|
treeIndex: options.membership.treeIndex,
|
327
327
|
identityCredential: {
|
328
|
-
idCommitment: Array.from(
|
329
|
-
|
330
|
-
|
331
|
-
|
328
|
+
idCommitment: Array.from(
|
329
|
+
toLittleEndian(options.identity.IDCommitment)
|
330
|
+
),
|
331
|
+
idNullifier: Array.from(toLittleEndian(options.identity.IDNullifier)),
|
332
|
+
idSecretHash: Array.from(
|
333
|
+
toLittleEndian(options.identity.IDSecretHash)
|
334
|
+
),
|
335
|
+
idTrapdoor: Array.from(toLittleEndian(options.identity.IDTrapdoor))
|
332
336
|
},
|
333
337
|
membershipContract: {
|
334
338
|
chainId: options.membership.chainId,
|
package/src/utils/bytes.ts
CHANGED
@@ -17,18 +17,38 @@ export function concatenate(...input: Uint8Array[]): Uint8Array {
|
|
17
17
|
return result;
|
18
18
|
}
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
20
|
+
export function switchEndianness(bytes: Uint8Array): Uint8Array {
|
21
|
+
return new Uint8Array(bytes.reverse());
|
22
|
+
}
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Builds a BigInt from a little-endian Uint8Array
|
26
|
+
* @param bytes The little-endian bytes to convert
|
27
|
+
* @returns The resulting BigInt in little-endian format
|
28
|
+
*/
|
29
|
+
export function buildBigIntFromUint8ArrayLE(bytes: Uint8Array): bigint {
|
30
|
+
let result = 0n;
|
31
|
+
for (let i = bytes.length - 1; i >= 0; i--) {
|
32
|
+
result = (result << 8n) + BigInt(bytes[i]);
|
33
|
+
}
|
34
|
+
return result;
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Switches endianness of a bigint value
|
39
|
+
* @param value The bigint value to switch endianness for
|
40
|
+
* @returns The bigint value with reversed endianness
|
41
|
+
*/
|
42
|
+
export function switchEndiannessBigInt(value: bigint): bigint {
|
43
|
+
// Convert bigint to byte array
|
44
|
+
const bytes = [];
|
45
|
+
while (value > 0n) {
|
46
|
+
bytes.push(Number(value & 0xffn));
|
47
|
+
value >>= 8n;
|
48
|
+
}
|
49
|
+
|
50
|
+
// Reverse bytes and convert back to bigint
|
51
|
+
return bytes.reverse().reduce((acc, byte) => (acc << 8n) + BigInt(byte), 0n);
|
32
52
|
}
|
33
53
|
|
34
54
|
export function writeUIntLE(
|
@@ -56,19 +76,6 @@ export function writeUIntLE(
|
|
56
76
|
return buf;
|
57
77
|
}
|
58
78
|
|
59
|
-
/**
|
60
|
-
* Transforms Uint8Array into BigInt
|
61
|
-
* @param array: Uint8Array
|
62
|
-
* @returns BigInt
|
63
|
-
*/
|
64
|
-
export function buildBigIntFromUint8Array(
|
65
|
-
array: Uint8Array,
|
66
|
-
byteOffset: number = 0
|
67
|
-
): bigint {
|
68
|
-
const dataView = new DataView(array.buffer);
|
69
|
-
return dataView.getBigUint64(byteOffset, true);
|
70
|
-
}
|
71
|
-
|
72
79
|
/**
|
73
80
|
* Fills with zeros to set length
|
74
81
|
* @param array little endian Uint8Array
|
@@ -82,3 +89,17 @@ export function zeroPadLE(array: Uint8Array, length: number): Uint8Array {
|
|
82
89
|
}
|
83
90
|
return result;
|
84
91
|
}
|
92
|
+
|
93
|
+
// Adapted from https://github.com/feross/buffer
|
94
|
+
function checkInt(
|
95
|
+
buf: Uint8Array,
|
96
|
+
value: number,
|
97
|
+
offset: number,
|
98
|
+
ext: number,
|
99
|
+
max: number,
|
100
|
+
min: number
|
101
|
+
): void {
|
102
|
+
if (value > max || value < min)
|
103
|
+
throw new RangeError('"value" argument is out of bounds');
|
104
|
+
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
105
|
+
}
|
package/src/utils/index.ts
CHANGED
@@ -1,31 +0,0 @@
|
|
1
|
-
import '../../../../interfaces/dist/light_push_v3.js';
|
2
|
-
import '../../../../interfaces/dist/protocols.js';
|
3
|
-
import '../../../../interfaces/dist/connection_manager.js';
|
4
|
-
import '../../../../interfaces/dist/health_indicator.js';
|
5
|
-
import '../../../../proto/dist/generated/message.js';
|
6
|
-
import '../../../../proto/dist/generated/filter.js';
|
7
|
-
import '../../../../proto/dist/generated/topic_only_message.js';
|
8
|
-
import '../../../../proto/dist/generated/filter_v2.js';
|
9
|
-
import '../../../../proto/dist/generated/light_push.js';
|
10
|
-
import '../../../../proto/dist/generated/light_push_v2.js';
|
11
|
-
import '../../../../proto/dist/generated/light_push_v3.js';
|
12
|
-
import '../../../../proto/dist/generated/store_v3.js';
|
13
|
-
import '../../../../proto/dist/generated/peer_exchange.js';
|
14
|
-
import '../../../../proto/dist/generated/metadata.js';
|
15
|
-
import '../../../../proto/dist/generated/sds_message.js';
|
16
|
-
import '../../../../../node_modules/multiformats/dist/src/bases/base10.js';
|
17
|
-
import '../../../../../node_modules/multiformats/dist/src/bases/base16.js';
|
18
|
-
import '../../../../../node_modules/multiformats/dist/src/bases/base2.js';
|
19
|
-
import '../../../../../node_modules/multiformats/dist/src/bases/base256emoji.js';
|
20
|
-
import '../../../../../node_modules/multiformats/dist/src/bases/base32.js';
|
21
|
-
import '../../../../../node_modules/multiformats/dist/src/bases/base36.js';
|
22
|
-
import '../../../../../node_modules/multiformats/dist/src/bases/base58.js';
|
23
|
-
import '../../../../../node_modules/multiformats/dist/src/bases/base64.js';
|
24
|
-
import '../../../../../node_modules/multiformats/dist/src/bases/base8.js';
|
25
|
-
import '../../../../../node_modules/multiformats/dist/src/bases/identity.js';
|
26
|
-
import '../../../../../node_modules/multiformats/dist/src/codecs/json.js';
|
27
|
-
import { Logger } from '../../../../utils/dist/logger/index.js';
|
28
|
-
import '../../../../../node_modules/it-length-prefixed/dist/src/decode.js';
|
29
|
-
import './status_codes_v3.js';
|
30
|
-
|
31
|
-
new Logger("light-push-v3");
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import '../../../../interfaces/dist/light_push_v3.js';
|
2
|
-
import '../../../../interfaces/dist/protocols.js';
|
3
|
-
import '../../../../interfaces/dist/connection_manager.js';
|
4
|
-
import '../../../../interfaces/dist/health_indicator.js';
|
5
|
-
|
6
|
-
var LightPushStatusCode;
|
7
|
-
(function (LightPushStatusCode) {
|
8
|
-
LightPushStatusCode[LightPushStatusCode["SUCCESS"] = 200] = "SUCCESS";
|
9
|
-
LightPushStatusCode[LightPushStatusCode["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
10
|
-
LightPushStatusCode[LightPushStatusCode["UNSUPPORTED_PUBSUB_TOPIC"] = 404] = "UNSUPPORTED_PUBSUB_TOPIC";
|
11
|
-
LightPushStatusCode[LightPushStatusCode["REQUEST_TOO_LARGE"] = 413] = "REQUEST_TOO_LARGE";
|
12
|
-
LightPushStatusCode[LightPushStatusCode["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
13
|
-
LightPushStatusCode[LightPushStatusCode["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
14
|
-
LightPushStatusCode[LightPushStatusCode["NO_PEERS_TO_RELAY"] = 503] = "NO_PEERS_TO_RELAY";
|
15
|
-
})(LightPushStatusCode || (LightPushStatusCode = {}));
|
16
|
-
({
|
17
|
-
[LightPushStatusCode.SUCCESS]: "Message pushed successfully",
|
18
|
-
[LightPushStatusCode.BAD_REQUEST]: "Invalid request format or missing required fields",
|
19
|
-
[LightPushStatusCode.UNSUPPORTED_PUBSUB_TOPIC]: "The specified pubsub topic is not supported",
|
20
|
-
[LightPushStatusCode.REQUEST_TOO_LARGE]: "Message size exceeds maximum allowed size",
|
21
|
-
[LightPushStatusCode.TOO_MANY_REQUESTS]: "Rate limit exceeded, too many requests",
|
22
|
-
[LightPushStatusCode.INTERNAL_SERVER_ERROR]: "Internal server error occurred",
|
23
|
-
[LightPushStatusCode.NO_PEERS_TO_RELAY]: "No relay peers available to forward the message"
|
24
|
-
});
|
25
|
-
|
26
|
-
export { LightPushStatusCode };
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { LightPushStatusCodeV3 } from '../../../../interfaces/dist/light_push_v3.js';
|
2
|
-
import '../../../../interfaces/dist/protocols.js';
|
3
|
-
import '../../../../interfaces/dist/connection_manager.js';
|
4
|
-
import '../../../../interfaces/dist/health_indicator.js';
|
5
|
-
|
6
|
-
({
|
7
|
-
[LightPushStatusCodeV3.SUCCESS]: "Message sent successfully",
|
8
|
-
[LightPushStatusCodeV3.BAD_REQUEST]: "Bad request format",
|
9
|
-
[LightPushStatusCodeV3.PAYLOAD_TOO_LARGE]: "Message payload exceeds maximum size",
|
10
|
-
[LightPushStatusCodeV3.INVALID_MESSAGE_ERROR]: "Message validation failed",
|
11
|
-
[LightPushStatusCodeV3.UNSUPPORTED_PUBSUB_TOPIC]: "Unsupported pubsub topic",
|
12
|
-
[LightPushStatusCodeV3.TOO_MANY_REQUESTS]: "Rate limit exceeded",
|
13
|
-
[LightPushStatusCodeV3.INTERNAL_SERVER_ERROR]: "Internal server error",
|
14
|
-
[LightPushStatusCodeV3.SERVICE_NOT_AVAILABLE]: "Service temporarily unavailable",
|
15
|
-
[LightPushStatusCodeV3.OUT_OF_RLN_PROOF]: "RLN proof generation failed",
|
16
|
-
[LightPushStatusCodeV3.NO_PEERS_TO_RELAY]: "No relay peers available"
|
17
|
-
});
|
@@ -1,16 +0,0 @@
|
|
1
|
-
// Light Push V3 Protocol Types and Constants
|
2
|
-
var LightPushStatusCodeV3;
|
3
|
-
(function (LightPushStatusCodeV3) {
|
4
|
-
LightPushStatusCodeV3[LightPushStatusCodeV3["SUCCESS"] = 200] = "SUCCESS";
|
5
|
-
LightPushStatusCodeV3[LightPushStatusCodeV3["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
6
|
-
LightPushStatusCodeV3[LightPushStatusCodeV3["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
7
|
-
LightPushStatusCodeV3[LightPushStatusCodeV3["INVALID_MESSAGE_ERROR"] = 420] = "INVALID_MESSAGE_ERROR";
|
8
|
-
LightPushStatusCodeV3[LightPushStatusCodeV3["UNSUPPORTED_PUBSUB_TOPIC"] = 421] = "UNSUPPORTED_PUBSUB_TOPIC";
|
9
|
-
LightPushStatusCodeV3[LightPushStatusCodeV3["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
10
|
-
LightPushStatusCodeV3[LightPushStatusCodeV3["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
11
|
-
LightPushStatusCodeV3[LightPushStatusCodeV3["SERVICE_NOT_AVAILABLE"] = 503] = "SERVICE_NOT_AVAILABLE";
|
12
|
-
LightPushStatusCodeV3[LightPushStatusCodeV3["OUT_OF_RLN_PROOF"] = 504] = "OUT_OF_RLN_PROOF";
|
13
|
-
LightPushStatusCodeV3[LightPushStatusCodeV3["NO_PEERS_TO_RELAY"] = 505] = "NO_PEERS_TO_RELAY";
|
14
|
-
})(LightPushStatusCodeV3 || (LightPushStatusCodeV3 = {}));
|
15
|
-
|
16
|
-
export { LightPushStatusCodeV3 };
|