@libp2p/pubsub 9.0.26-50b897139 → 9.0.26-71e5f7a5b
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.min.js +2 -3
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +20 -22
- package/dist/src/index.js.map +1 -1
- package/dist/src/peer-streams.d.ts.map +1 -1
- package/dist/src/peer-streams.js +1 -1
- package/dist/src/peer-streams.js.map +1 -1
- package/dist/src/sign.d.ts +3 -3
- package/dist/src/sign.d.ts.map +1 -1
- package/dist/src/sign.js +7 -19
- package/dist/src/sign.js.map +1 -1
- package/dist/src/utils.d.ts +2 -2
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +22 -17
- package/dist/src/utils.js.map +1 -1
- package/package.json +8 -9
- package/src/index.ts +22 -24
- package/src/peer-streams.ts +1 -1
- package/src/sign.ts +8 -23
- package/src/utils.ts +26 -20
- package/dist/src/errors.d.ts +0 -51
- package/dist/src/errors.d.ts.map +0 -1
- package/dist/src/errors.js +0 -53
- package/dist/src/errors.js.map +0 -1
- package/src/errors.ts +0 -57
package/src/index.ts
CHANGED
@@ -30,23 +30,23 @@
|
|
30
30
|
* ```
|
31
31
|
*/
|
32
32
|
|
33
|
-
import {
|
33
|
+
import { TypedEventEmitter, TopicValidatorResult, InvalidMessageError, NotStartedError, InvalidParametersError } from '@libp2p/interface'
|
34
34
|
import { PeerMap, PeerSet } from '@libp2p/peer-collections'
|
35
35
|
import { pipe } from 'it-pipe'
|
36
36
|
import Queue from 'p-queue'
|
37
|
-
import { codes } from './errors.js'
|
38
37
|
import { PeerStreams as PeerStreamsImpl } from './peer-streams.js'
|
39
38
|
import {
|
40
39
|
signMessage,
|
41
40
|
verifySignature
|
42
41
|
} from './sign.js'
|
43
42
|
import { toMessage, ensureArray, noSignMsgId, msgId, toRpcMessage, randomSeqno } from './utils.js'
|
44
|
-
import type { PubSub, Message, StrictNoSign, StrictSign, PubSubInit, PubSubEvents, PeerStreams, PubSubRPCMessage, PubSubRPC, PubSubRPCSubscription, SubscriptionChangeData, PublishResult, TopicValidatorFn, ComponentLogger, Logger, Connection, PeerId } from '@libp2p/interface'
|
43
|
+
import type { PubSub, Message, StrictNoSign, StrictSign, PubSubInit, PubSubEvents, PeerStreams, PubSubRPCMessage, PubSubRPC, PubSubRPCSubscription, SubscriptionChangeData, PublishResult, TopicValidatorFn, ComponentLogger, Logger, Connection, PeerId, PrivateKey } from '@libp2p/interface'
|
45
44
|
import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal'
|
46
45
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
47
46
|
|
48
47
|
export interface PubSubComponents {
|
49
48
|
peerId: PeerId
|
49
|
+
privateKey: PrivateKey
|
50
50
|
registrar: Registrar
|
51
51
|
logger: ComponentLogger
|
52
52
|
}
|
@@ -261,9 +261,7 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
261
261
|
* Registrar notifies a closing connection with pubsub protocol
|
262
262
|
*/
|
263
263
|
protected _onPeerDisconnected (peerId: PeerId, conn?: Connection): void {
|
264
|
-
|
265
|
-
|
266
|
-
this.log('connection ended', idB58Str)
|
264
|
+
this.log('connection ended %p', peerId)
|
267
265
|
this._removePeer(peerId)
|
268
266
|
}
|
269
267
|
|
@@ -486,22 +484,22 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
486
484
|
switch (signaturePolicy) {
|
487
485
|
case 'StrictSign':
|
488
486
|
if (msg.type !== 'signed') {
|
489
|
-
throw new
|
487
|
+
throw new InvalidMessageError('Message type should be "signed" when signature policy is StrictSign but it was not')
|
490
488
|
}
|
491
489
|
|
492
490
|
if (msg.sequenceNumber == null) {
|
493
|
-
throw new
|
491
|
+
throw new InvalidMessageError('Need seqno when signature policy is StrictSign but it was missing')
|
494
492
|
}
|
495
493
|
|
496
494
|
if (msg.key == null) {
|
497
|
-
throw new
|
495
|
+
throw new InvalidMessageError('Need key when signature policy is StrictSign but it was missing')
|
498
496
|
}
|
499
497
|
|
500
498
|
return msgId(msg.key, msg.sequenceNumber)
|
501
499
|
case 'StrictNoSign':
|
502
500
|
return noSignMsgId(msg.data)
|
503
501
|
default:
|
504
|
-
throw new
|
502
|
+
throw new InvalidMessageError('Cannot get message id: unhandled signature policy')
|
505
503
|
}
|
506
504
|
}
|
507
505
|
|
@@ -573,51 +571,51 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
573
571
|
switch (signaturePolicy) {
|
574
572
|
case 'StrictNoSign':
|
575
573
|
if (message.type !== 'unsigned') {
|
576
|
-
throw new
|
574
|
+
throw new InvalidMessageError('Message type should be "unsigned" when signature policy is StrictNoSign but it was not')
|
577
575
|
}
|
578
576
|
|
579
577
|
// @ts-expect-error should not be present
|
580
578
|
if (message.signature != null) {
|
581
|
-
throw new
|
579
|
+
throw new InvalidMessageError('StrictNoSigning: signature should not be present')
|
582
580
|
}
|
583
581
|
|
584
582
|
// @ts-expect-error should not be present
|
585
583
|
if (message.key != null) {
|
586
|
-
throw new
|
584
|
+
throw new InvalidMessageError('StrictNoSigning: key should not be present')
|
587
585
|
}
|
588
586
|
|
589
587
|
// @ts-expect-error should not be present
|
590
588
|
if (message.sequenceNumber != null) {
|
591
|
-
throw new
|
589
|
+
throw new InvalidMessageError('StrictNoSigning: seqno should not be present')
|
592
590
|
}
|
593
591
|
break
|
594
592
|
case 'StrictSign':
|
595
593
|
if (message.type !== 'signed') {
|
596
|
-
throw new
|
594
|
+
throw new InvalidMessageError('Message type should be "signed" when signature policy is StrictSign but it was not')
|
597
595
|
}
|
598
596
|
|
599
597
|
if (message.signature == null) {
|
600
|
-
throw new
|
598
|
+
throw new InvalidMessageError('StrictSigning: Signing required and no signature was present')
|
601
599
|
}
|
602
600
|
|
603
601
|
if (message.sequenceNumber == null) {
|
604
|
-
throw new
|
602
|
+
throw new InvalidMessageError('StrictSigning: Signing required and no sequenceNumber was present')
|
605
603
|
}
|
606
604
|
|
607
605
|
if (!(await verifySignature(message, this.encodeMessage.bind(this)))) {
|
608
|
-
throw new
|
606
|
+
throw new InvalidMessageError('StrictSigning: Invalid message signature')
|
609
607
|
}
|
610
608
|
|
611
609
|
break
|
612
610
|
default:
|
613
|
-
throw new
|
611
|
+
throw new InvalidMessageError('Cannot validate message: unhandled signature policy')
|
614
612
|
}
|
615
613
|
|
616
614
|
const validatorFn = this.topicValidators.get(message.topic)
|
617
615
|
if (validatorFn != null) {
|
618
616
|
const result = await validatorFn(from, message)
|
619
617
|
if (result === TopicValidatorResult.Reject || result === TopicValidatorResult.Ignore) {
|
620
|
-
throw new
|
618
|
+
throw new InvalidMessageError('Message validation failed')
|
621
619
|
}
|
622
620
|
}
|
623
621
|
}
|
@@ -630,14 +628,14 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
630
628
|
const signaturePolicy = this.globalSignaturePolicy
|
631
629
|
switch (signaturePolicy) {
|
632
630
|
case 'StrictSign':
|
633
|
-
return signMessage(this.components.
|
631
|
+
return signMessage(this.components.privateKey, message, this.encodeMessage.bind(this))
|
634
632
|
case 'StrictNoSign':
|
635
633
|
return Promise.resolve({
|
636
634
|
type: 'unsigned',
|
637
635
|
...message
|
638
636
|
})
|
639
637
|
default:
|
640
|
-
throw new
|
638
|
+
throw new InvalidMessageError('Cannot build message: unhandled signature policy')
|
641
639
|
}
|
642
640
|
}
|
643
641
|
|
@@ -648,11 +646,11 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
648
646
|
*/
|
649
647
|
getSubscribers (topic: string): PeerId[] {
|
650
648
|
if (!this.started) {
|
651
|
-
throw new
|
649
|
+
throw new NotStartedError('not started yet')
|
652
650
|
}
|
653
651
|
|
654
652
|
if (topic == null) {
|
655
|
-
throw new
|
653
|
+
throw new InvalidParametersError('Topic is required')
|
656
654
|
}
|
657
655
|
|
658
656
|
const peersInTopic = this.topics.get(topic.toString())
|
package/src/peer-streams.ts
CHANGED
package/src/sign.ts
CHANGED
@@ -1,31 +1,22 @@
|
|
1
|
-
import {
|
2
|
-
import { peerIdFromKeys } from '@libp2p/peer-id'
|
1
|
+
import { peerIdFromPrivateKey } from '@libp2p/peer-id'
|
3
2
|
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
|
4
3
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
5
4
|
import { toRpcMessage } from './utils.js'
|
6
|
-
import type { PeerId, PubSubRPCMessage, SignedMessage } from '@libp2p/interface'
|
5
|
+
import type { PeerId, PrivateKey, PubSubRPCMessage, PublicKey, SignedMessage } from '@libp2p/interface'
|
7
6
|
|
8
7
|
export const SignPrefix = uint8ArrayFromString('libp2p-pubsub:')
|
9
8
|
|
10
9
|
/**
|
11
10
|
* Signs the provided message with the given `peerId`
|
12
11
|
*/
|
13
|
-
export async function signMessage (
|
14
|
-
if (peerId.privateKey == null) {
|
15
|
-
throw new Error('Cannot sign message, no private key present')
|
16
|
-
}
|
17
|
-
|
18
|
-
if (peerId.publicKey == null) {
|
19
|
-
throw new Error('Cannot sign message, no public key present')
|
20
|
-
}
|
21
|
-
|
12
|
+
export async function signMessage (privateKey: PrivateKey, message: { from: PeerId, topic: string, data: Uint8Array, sequenceNumber: bigint }, encode: (rpc: PubSubRPCMessage) => Uint8Array): Promise<SignedMessage> {
|
22
13
|
// @ts-expect-error signature field is missing, added below
|
23
14
|
const outputMessage: SignedMessage = {
|
24
15
|
type: 'signed',
|
25
16
|
topic: message.topic,
|
26
17
|
data: message.data,
|
27
18
|
sequenceNumber: message.sequenceNumber,
|
28
|
-
from:
|
19
|
+
from: peerIdFromPrivateKey(privateKey)
|
29
20
|
}
|
30
21
|
|
31
22
|
// Get the message in bytes, and prepend with the pubsub prefix
|
@@ -34,9 +25,8 @@ export async function signMessage (peerId: PeerId, message: { from: PeerId, topi
|
|
34
25
|
encode(toRpcMessage(outputMessage)).subarray()
|
35
26
|
])
|
36
27
|
|
37
|
-
const privateKey = await keys.unmarshalPrivateKey(peerId.privateKey)
|
38
28
|
outputMessage.signature = await privateKey.sign(bytes)
|
39
|
-
outputMessage.key =
|
29
|
+
outputMessage.key = privateKey.publicKey
|
40
30
|
|
41
31
|
return outputMessage
|
42
32
|
}
|
@@ -68,8 +58,7 @@ export async function verifySignature (message: SignedMessage, encode: (rpc: Pub
|
|
68
58
|
])
|
69
59
|
|
70
60
|
// Get the public key
|
71
|
-
const
|
72
|
-
const pubKey = keys.unmarshalPublicKey(pubKeyBytes)
|
61
|
+
const pubKey = messagePublicKey(message)
|
73
62
|
|
74
63
|
// verify the base message
|
75
64
|
return pubKey.verify(bytes, message.signature)
|
@@ -79,7 +68,7 @@ export async function verifySignature (message: SignedMessage, encode: (rpc: Pub
|
|
79
68
|
* Returns the PublicKey associated with the given message.
|
80
69
|
* If no valid PublicKey can be retrieved an error will be returned.
|
81
70
|
*/
|
82
|
-
export
|
71
|
+
export function messagePublicKey (message: SignedMessage): PublicKey {
|
83
72
|
if (message.type !== 'signed') {
|
84
73
|
throw new Error('Message type must be "signed" to have a public key')
|
85
74
|
}
|
@@ -90,11 +79,7 @@ export async function messagePublicKey (message: SignedMessage): Promise<Uint8Ar
|
|
90
79
|
}
|
91
80
|
|
92
81
|
if (message.key != null) {
|
93
|
-
|
94
|
-
|
95
|
-
if (keyPeerId.publicKey != null) {
|
96
|
-
return keyPeerId.publicKey
|
97
|
-
}
|
82
|
+
return message.key
|
98
83
|
}
|
99
84
|
|
100
85
|
if (message.from.publicKey != null) {
|
package/src/utils.ts
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
import { randomBytes } from '@libp2p/crypto'
|
2
|
-
import {
|
3
|
-
import {
|
2
|
+
import { publicKeyFromProtobuf, publicKeyToProtobuf } from '@libp2p/crypto/keys'
|
3
|
+
import { InvalidMessageError } from '@libp2p/interface'
|
4
|
+
import { peerIdFromMultihash, peerIdFromPublicKey } from '@libp2p/peer-id'
|
5
|
+
import * as Digest from 'multiformats/hashes/digest'
|
4
6
|
import { sha256 } from 'multiformats/hashes/sha2'
|
5
7
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
6
8
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
7
|
-
import {
|
8
|
-
import type { Message, PubSubRPCMessage } from '@libp2p/interface'
|
9
|
+
import type { Message, PubSubRPCMessage, PublicKey } from '@libp2p/interface'
|
9
10
|
|
10
11
|
/**
|
11
12
|
* Generate a random sequence number
|
@@ -17,12 +18,13 @@ export function randomSeqno (): bigint {
|
|
17
18
|
/**
|
18
19
|
* Generate a message id, based on the `key` and `seqno`
|
19
20
|
*/
|
20
|
-
export const msgId = (key:
|
21
|
+
export const msgId = (key: PublicKey, seqno: bigint): Uint8Array => {
|
21
22
|
const seqnoBytes = uint8ArrayFromString(seqno.toString(16).padStart(16, '0'), 'base16')
|
23
|
+
const keyBytes = publicKeyToProtobuf(key)
|
22
24
|
|
23
|
-
const msgId = new Uint8Array(
|
24
|
-
msgId.set(
|
25
|
-
msgId.set(seqnoBytes,
|
25
|
+
const msgId = new Uint8Array(keyBytes.byteLength + seqnoBytes.length)
|
26
|
+
msgId.set(keyBytes, 0)
|
27
|
+
msgId.set(seqnoBytes, keyBytes.byteLength)
|
26
28
|
|
27
29
|
return msgId
|
28
30
|
}
|
@@ -71,13 +73,15 @@ const isSigned = async (message: PubSubRPCMessage): Promise<boolean> => {
|
|
71
73
|
return false
|
72
74
|
}
|
73
75
|
// if a public key is present in the `from` field, the message should be signed
|
74
|
-
const fromID =
|
76
|
+
const fromID = peerIdFromMultihash(Digest.decode(message.from))
|
75
77
|
if (fromID.publicKey != null) {
|
76
78
|
return true
|
77
79
|
}
|
78
80
|
|
79
81
|
if (message.key != null) {
|
80
|
-
const
|
82
|
+
const signingKey = message.key
|
83
|
+
const signingID = peerIdFromPublicKey(publicKeyFromProtobuf(signingKey))
|
84
|
+
|
81
85
|
return signingID.equals(fromID)
|
82
86
|
}
|
83
87
|
|
@@ -86,7 +90,7 @@ const isSigned = async (message: PubSubRPCMessage): Promise<boolean> => {
|
|
86
90
|
|
87
91
|
export const toMessage = async (message: PubSubRPCMessage): Promise<Message> => {
|
88
92
|
if (message.from == null) {
|
89
|
-
throw new
|
93
|
+
throw new InvalidMessageError('RPC message was missing from')
|
90
94
|
}
|
91
95
|
|
92
96
|
if (!await isSigned(message)) {
|
@@ -97,20 +101,21 @@ export const toMessage = async (message: PubSubRPCMessage): Promise<Message> =>
|
|
97
101
|
}
|
98
102
|
}
|
99
103
|
|
100
|
-
const from =
|
104
|
+
const from = peerIdFromMultihash(Digest.decode(message.from))
|
105
|
+
const key = message.key ?? from.publicKey
|
106
|
+
|
107
|
+
if (key == null) {
|
108
|
+
throw new InvalidMessageError('RPC message was missing public key')
|
109
|
+
}
|
101
110
|
|
102
111
|
const msg: Message = {
|
103
112
|
type: 'signed',
|
104
|
-
from
|
113
|
+
from,
|
105
114
|
topic: message.topic ?? '',
|
106
115
|
sequenceNumber: bigIntFromBytes(message.sequenceNumber ?? new Uint8Array(0)),
|
107
116
|
data: message.data ?? new Uint8Array(0),
|
108
117
|
signature: message.signature ?? new Uint8Array(0),
|
109
|
-
key:
|
110
|
-
}
|
111
|
-
|
112
|
-
if (msg.key.length === 0) {
|
113
|
-
throw new CodeError('Signed RPC message was missing key', codes.ERR_MISSING_KEY)
|
118
|
+
key: key instanceof Uint8Array ? publicKeyFromProtobuf(key) : key
|
114
119
|
}
|
115
120
|
|
116
121
|
return msg
|
@@ -119,12 +124,13 @@ export const toMessage = async (message: PubSubRPCMessage): Promise<Message> =>
|
|
119
124
|
export const toRpcMessage = (message: Message): PubSubRPCMessage => {
|
120
125
|
if (message.type === 'signed') {
|
121
126
|
return {
|
122
|
-
from: message.from.
|
127
|
+
from: message.from.toMultihash().bytes,
|
123
128
|
data: message.data,
|
124
129
|
sequenceNumber: bigIntToBytes(message.sequenceNumber),
|
125
130
|
topic: message.topic,
|
126
131
|
signature: message.signature,
|
127
|
-
|
132
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
133
|
+
key: message.key ? publicKeyToProtobuf(message.key) : undefined
|
128
134
|
}
|
129
135
|
}
|
130
136
|
|
package/dist/src/errors.d.ts
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
export declare const codes: {
|
2
|
-
/**
|
3
|
-
* Signature policy is invalid
|
4
|
-
*/
|
5
|
-
ERR_INVALID_SIGNATURE_POLICY: string;
|
6
|
-
/**
|
7
|
-
* Signature policy is unhandled
|
8
|
-
*/
|
9
|
-
ERR_UNHANDLED_SIGNATURE_POLICY: string;
|
10
|
-
/**
|
11
|
-
* Message expected to have a `signature`, but doesn't
|
12
|
-
*/
|
13
|
-
ERR_MISSING_SIGNATURE: string;
|
14
|
-
/**
|
15
|
-
* Message expected to have a `seqno`, but doesn't
|
16
|
-
*/
|
17
|
-
ERR_MISSING_SEQNO: string;
|
18
|
-
/**
|
19
|
-
* Message expected to have a `key`, but doesn't
|
20
|
-
*/
|
21
|
-
ERR_MISSING_KEY: string;
|
22
|
-
/**
|
23
|
-
* Message `signature` is invalid
|
24
|
-
*/
|
25
|
-
ERR_INVALID_SIGNATURE: string;
|
26
|
-
/**
|
27
|
-
* Message expected to have a `from`, but doesn't
|
28
|
-
*/
|
29
|
-
ERR_MISSING_FROM: string;
|
30
|
-
/**
|
31
|
-
* Message expected to not have a `from`, but does
|
32
|
-
*/
|
33
|
-
ERR_UNEXPECTED_FROM: string;
|
34
|
-
/**
|
35
|
-
* Message expected to not have a `signature`, but does
|
36
|
-
*/
|
37
|
-
ERR_UNEXPECTED_SIGNATURE: string;
|
38
|
-
/**
|
39
|
-
* Message expected to not have a `key`, but does
|
40
|
-
*/
|
41
|
-
ERR_UNEXPECTED_KEY: string;
|
42
|
-
/**
|
43
|
-
* Message expected to not have a `seqno`, but does
|
44
|
-
*/
|
45
|
-
ERR_UNEXPECTED_SEQNO: string;
|
46
|
-
/**
|
47
|
-
* Message failed topic validator
|
48
|
-
*/
|
49
|
-
ERR_TOPIC_VALIDATOR_REJECT: string;
|
50
|
-
};
|
51
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/src/errors.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK;IAChB;;OAEG;;IAEH;;OAEG;;IAKH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAKH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAA"}
|
package/dist/src/errors.js
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
export const codes = {
|
2
|
-
/**
|
3
|
-
* Signature policy is invalid
|
4
|
-
*/
|
5
|
-
ERR_INVALID_SIGNATURE_POLICY: 'ERR_INVALID_SIGNATURE_POLICY',
|
6
|
-
/**
|
7
|
-
* Signature policy is unhandled
|
8
|
-
*/
|
9
|
-
ERR_UNHANDLED_SIGNATURE_POLICY: 'ERR_UNHANDLED_SIGNATURE_POLICY',
|
10
|
-
// Strict signing codes
|
11
|
-
/**
|
12
|
-
* Message expected to have a `signature`, but doesn't
|
13
|
-
*/
|
14
|
-
ERR_MISSING_SIGNATURE: 'ERR_MISSING_SIGNATURE',
|
15
|
-
/**
|
16
|
-
* Message expected to have a `seqno`, but doesn't
|
17
|
-
*/
|
18
|
-
ERR_MISSING_SEQNO: 'ERR_MISSING_SEQNO',
|
19
|
-
/**
|
20
|
-
* Message expected to have a `key`, but doesn't
|
21
|
-
*/
|
22
|
-
ERR_MISSING_KEY: 'ERR_MISSING_KEY',
|
23
|
-
/**
|
24
|
-
* Message `signature` is invalid
|
25
|
-
*/
|
26
|
-
ERR_INVALID_SIGNATURE: 'ERR_INVALID_SIGNATURE',
|
27
|
-
/**
|
28
|
-
* Message expected to have a `from`, but doesn't
|
29
|
-
*/
|
30
|
-
ERR_MISSING_FROM: 'ERR_MISSING_FROM',
|
31
|
-
// Strict no-signing codes
|
32
|
-
/**
|
33
|
-
* Message expected to not have a `from`, but does
|
34
|
-
*/
|
35
|
-
ERR_UNEXPECTED_FROM: 'ERR_UNEXPECTED_FROM',
|
36
|
-
/**
|
37
|
-
* Message expected to not have a `signature`, but does
|
38
|
-
*/
|
39
|
-
ERR_UNEXPECTED_SIGNATURE: 'ERR_UNEXPECTED_SIGNATURE',
|
40
|
-
/**
|
41
|
-
* Message expected to not have a `key`, but does
|
42
|
-
*/
|
43
|
-
ERR_UNEXPECTED_KEY: 'ERR_UNEXPECTED_KEY',
|
44
|
-
/**
|
45
|
-
* Message expected to not have a `seqno`, but does
|
46
|
-
*/
|
47
|
-
ERR_UNEXPECTED_SEQNO: 'ERR_UNEXPECTED_SEQNO',
|
48
|
-
/**
|
49
|
-
* Message failed topic validator
|
50
|
-
*/
|
51
|
-
ERR_TOPIC_VALIDATOR_REJECT: 'ERR_TOPIC_VALIDATOR_REJECT'
|
52
|
-
};
|
53
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/src/errors.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB;;OAEG;IACH,4BAA4B,EAAE,8BAA8B;IAC5D;;OAEG;IACH,8BAA8B,EAAE,gCAAgC;IAEhE,uBAAuB;IAEvB;;OAEG;IACH,qBAAqB,EAAE,uBAAuB;IAC9C;;OAEG;IACH,iBAAiB,EAAE,mBAAmB;IACtC;;OAEG;IACH,eAAe,EAAE,iBAAiB;IAClC;;OAEG;IACH,qBAAqB,EAAE,uBAAuB;IAC9C;;OAEG;IACH,gBAAgB,EAAE,kBAAkB;IAEpC,0BAA0B;IAE1B;;OAEG;IACH,mBAAmB,EAAE,qBAAqB;IAC1C;;OAEG;IACH,wBAAwB,EAAE,0BAA0B;IACpD;;OAEG;IACH,kBAAkB,EAAE,oBAAoB;IACxC;;OAEG;IACH,oBAAoB,EAAE,sBAAsB;IAE5C;;OAEG;IACH,0BAA0B,EAAE,4BAA4B;CACzD,CAAA"}
|
package/src/errors.ts
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
export const codes = {
|
2
|
-
/**
|
3
|
-
* Signature policy is invalid
|
4
|
-
*/
|
5
|
-
ERR_INVALID_SIGNATURE_POLICY: 'ERR_INVALID_SIGNATURE_POLICY',
|
6
|
-
/**
|
7
|
-
* Signature policy is unhandled
|
8
|
-
*/
|
9
|
-
ERR_UNHANDLED_SIGNATURE_POLICY: 'ERR_UNHANDLED_SIGNATURE_POLICY',
|
10
|
-
|
11
|
-
// Strict signing codes
|
12
|
-
|
13
|
-
/**
|
14
|
-
* Message expected to have a `signature`, but doesn't
|
15
|
-
*/
|
16
|
-
ERR_MISSING_SIGNATURE: 'ERR_MISSING_SIGNATURE',
|
17
|
-
/**
|
18
|
-
* Message expected to have a `seqno`, but doesn't
|
19
|
-
*/
|
20
|
-
ERR_MISSING_SEQNO: 'ERR_MISSING_SEQNO',
|
21
|
-
/**
|
22
|
-
* Message expected to have a `key`, but doesn't
|
23
|
-
*/
|
24
|
-
ERR_MISSING_KEY: 'ERR_MISSING_KEY',
|
25
|
-
/**
|
26
|
-
* Message `signature` is invalid
|
27
|
-
*/
|
28
|
-
ERR_INVALID_SIGNATURE: 'ERR_INVALID_SIGNATURE',
|
29
|
-
/**
|
30
|
-
* Message expected to have a `from`, but doesn't
|
31
|
-
*/
|
32
|
-
ERR_MISSING_FROM: 'ERR_MISSING_FROM',
|
33
|
-
|
34
|
-
// Strict no-signing codes
|
35
|
-
|
36
|
-
/**
|
37
|
-
* Message expected to not have a `from`, but does
|
38
|
-
*/
|
39
|
-
ERR_UNEXPECTED_FROM: 'ERR_UNEXPECTED_FROM',
|
40
|
-
/**
|
41
|
-
* Message expected to not have a `signature`, but does
|
42
|
-
*/
|
43
|
-
ERR_UNEXPECTED_SIGNATURE: 'ERR_UNEXPECTED_SIGNATURE',
|
44
|
-
/**
|
45
|
-
* Message expected to not have a `key`, but does
|
46
|
-
*/
|
47
|
-
ERR_UNEXPECTED_KEY: 'ERR_UNEXPECTED_KEY',
|
48
|
-
/**
|
49
|
-
* Message expected to not have a `seqno`, but does
|
50
|
-
*/
|
51
|
-
ERR_UNEXPECTED_SEQNO: 'ERR_UNEXPECTED_SEQNO',
|
52
|
-
|
53
|
-
/**
|
54
|
-
* Message failed topic validator
|
55
|
-
*/
|
56
|
-
ERR_TOPIC_VALIDATOR_REJECT: 'ERR_TOPIC_VALIDATOR_REJECT'
|
57
|
-
}
|