@libp2p/kad-dht 12.0.10 → 12.0.11
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/index.min.js +3 -3
- package/dist/src/content-fetching/index.d.ts +1 -2
- package/dist/src/content-fetching/index.d.ts.map +1 -1
- package/dist/src/content-fetching/index.js +1 -5
- package/dist/src/content-fetching/index.js.map +1 -1
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +9 -7
- package/dist/src/content-routing/index.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/network.d.ts.map +1 -1
- package/dist/src/network.js +1 -1
- package/dist/src/network.js.map +1 -1
- package/dist/src/peer-routing/index.js +1 -1
- package/dist/src/peer-routing/index.js.map +1 -1
- package/dist/src/query/events.d.ts +1 -1
- package/dist/src/query/events.d.ts.map +1 -1
- package/dist/src/query/manager.d.ts +1 -1
- package/dist/src/query/manager.d.ts.map +1 -1
- package/dist/src/query/manager.js +5 -2
- package/dist/src/query/manager.js.map +1 -1
- package/dist/src/query/query-path.d.ts.map +1 -1
- package/dist/src/query/query-path.js +3 -0
- package/dist/src/query/query-path.js.map +1 -1
- package/dist/src/query-self.d.ts.map +1 -1
- package/dist/src/query-self.js +3 -2
- package/dist/src/query-self.js.map +1 -1
- package/dist/src/record/validators.d.ts +1 -1
- package/dist/src/record/validators.d.ts.map +1 -1
- package/dist/src/rpc/handlers/get-value.d.ts +1 -1
- package/dist/src/rpc/handlers/get-value.d.ts.map +1 -1
- package/dist/src/rpc/handlers/get-value.js +1 -1
- package/dist/src/rpc/handlers/get-value.js.map +1 -1
- package/dist/src/rpc/handlers/put-value.js +1 -1
- package/dist/src/rpc/handlers/put-value.js.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/utils.js.map +1 -1
- package/dist/typedoc-urls.json +0 -1
- package/package.json +19 -18
- package/src/content-fetching/index.ts +1 -6
- package/src/content-routing/index.ts +11 -7
- package/src/index.ts +1 -1
- package/src/network.ts +1 -1
- package/src/peer-routing/index.ts +1 -1
- package/src/query/events.ts +1 -1
- package/src/query/manager.ts +7 -3
- package/src/query/query-path.ts +4 -0
- package/src/query-self.ts +3 -2
- package/src/record/validators.ts +1 -1
- package/src/rpc/handlers/get-value.ts +1 -1
- package/src/rpc/handlers/put-value.ts +1 -1
- package/src/utils.ts +1 -1
- package/dist/src/record/index.d.ts +0 -22
- package/dist/src/record/index.d.ts.map +0 -1
- package/dist/src/record/index.js +0 -53
- package/dist/src/record/index.js.map +0 -1
- package/dist/src/record/record.d.ts +0 -13
- package/dist/src/record/record.d.ts.map +0 -1
- package/dist/src/record/record.js +0 -67
- package/dist/src/record/record.js.map +0 -1
- package/dist/src/record/utils.d.ts +0 -11
- package/dist/src/record/utils.d.ts.map +0 -1
- package/dist/src/record/utils.js +0 -41
- package/dist/src/record/utils.js.map +0 -1
- package/src/record/index.ts +0 -70
- package/src/record/record.proto +0 -20
- package/src/record/record.ts +0 -87
- package/src/record/utils.ts +0 -46
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"put-value.js","sourceRoot":"","sources":["../../../../src/rpc/handlers/put-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"put-value.js","sourceRoot":"","sources":["../../../../src/rpc/handlers/put-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAiBlD,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AI,CAAC,GAAG,CAAC,+CAA+C,EAAE,GAAG,EAAE,SAAS,CAAC,CAAA;QAC3E,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,iDAAiD,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;QACvE,CAAC;QAED,OAAO,GAAG,CAAA;IACZ,CAAC;CACF"}
|
package/dist/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AAM7C,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAKxD,wBAAgB,4BAA4B,CAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAkCtE;AAED,wBAAgB,2BAA2B,CAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,CA4BrE;AAED,wBAAgB,iBAAiB,CAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAE3D;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAIzE;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAExE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAE,GAAG,EAAE,UAAU,GAAG,GAAG,CAEjD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAE,GAAG,EAAE,UAAU,GAAG,GAAG,CAEvD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAKzD;AAED,wBAAgB,cAAc,CAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAExD;AAED,wBAAgB,SAAS,CAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAEnD;AAED,wBAAgB,gBAAgB,CAAE,GAAG,EAAE,UAAU,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,CAK/E;AAED,wBAAgB,QAAQ,CAAE,QAAQ,EAAE,MAAM,IAAI,EAAE,IAAI,GAAE,MAAY,GAAG,MAAM,IAAI,CAO9E;AAUD,wBAAgB,iBAAiB,CAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAwBhE"}
|
package/dist/src/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { peerIdFromBytes } from '@libp2p/peer-id';
|
|
2
|
+
import { Libp2pRecord } from '@libp2p/record';
|
|
2
3
|
import { isPrivateIp } from '@libp2p/utils/private-ip';
|
|
3
4
|
import { Key } from 'interface-datastore/key';
|
|
4
5
|
import { sha256 } from 'multiformats/hashes/sha2';
|
|
@@ -6,7 +7,6 @@ import { concat as uint8ArrayConcat } from 'uint8arrays/concat';
|
|
|
6
7
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
|
7
8
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
|
|
8
9
|
import { RECORD_KEY_PREFIX } from './constants.js';
|
|
9
|
-
import { Libp2pRecord } from './record/index.js';
|
|
10
10
|
// const IPNS_PREFIX = uint8ArrayFromString('/ipns/')
|
|
11
11
|
const PK_PREFIX = uint8ArrayFromString('/pk/');
|
|
12
12
|
export function removePrivateAddressesMapper(peer) {
|
package/dist/src/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MA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,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAED,0BAA0B;IAC1B,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,EAAE,CAAC;QAC9F,OAAO,IAAI,CAAA;IACb,CAAC;IAED,aAAa;IACb,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC3D,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,CAAA;QAE1C,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/dist/typedoc-urls.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"EventTypes": "https://libp2p.github.io/js-libp2p/enums/_libp2p_kad_dht.EventTypes.html",
|
|
4
4
|
".:EventTypes": "https://libp2p.github.io/js-libp2p/enums/_libp2p_kad_dht.EventTypes.html",
|
|
5
5
|
"MessageType": "https://libp2p.github.io/js-libp2p/enums/_libp2p_kad_dht.MessageType-1.html",
|
|
6
|
-
"Record": "https://libp2p.github.io/js-libp2p/classes/_libp2p_kad_dht.Record.html",
|
|
7
6
|
"AddPeerEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.AddPeerEvent.html",
|
|
8
7
|
".:AddPeerEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.AddPeerEvent.html",
|
|
9
8
|
"DHTRecord": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.DHTRecord.html",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/kad-dht",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.11",
|
|
4
4
|
"description": "JavaScript implementation of the Kad-DHT for libp2p",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/kad-dht#readme",
|
|
@@ -57,14 +57,14 @@
|
|
|
57
57
|
"doc-check": "aegir doc-check"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@libp2p/crypto": "^4.0.
|
|
61
|
-
"@libp2p/interface": "^1.1.
|
|
62
|
-
"@libp2p/interface-internal": "^1.0.
|
|
63
|
-
"@libp2p/peer-collections": "^5.1.
|
|
64
|
-
"@libp2p/peer-id": "^4.0.
|
|
65
|
-
"@libp2p/
|
|
66
|
-
"@
|
|
67
|
-
"@
|
|
60
|
+
"@libp2p/crypto": "^4.0.5",
|
|
61
|
+
"@libp2p/interface": "^1.1.6",
|
|
62
|
+
"@libp2p/interface-internal": "^1.0.11",
|
|
63
|
+
"@libp2p/peer-collections": "^5.1.9",
|
|
64
|
+
"@libp2p/peer-id": "^4.0.9",
|
|
65
|
+
"@libp2p/record": "^4.0.0",
|
|
66
|
+
"@libp2p/utils": "^5.2.8",
|
|
67
|
+
"@multiformats/multiaddr": "^12.2.1",
|
|
68
68
|
"any-signal": "^4.1.1",
|
|
69
69
|
"hashlru": "^2.3.0",
|
|
70
70
|
"interface-datastore": "^8.2.11",
|
|
@@ -79,26 +79,27 @@
|
|
|
79
79
|
"it-pushable": "^3.2.3",
|
|
80
80
|
"it-take": "^3.0.4",
|
|
81
81
|
"multiformats": "^13.1.0",
|
|
82
|
-
"p-defer": "^4.0.
|
|
83
|
-
"p-event": "^6.0.
|
|
82
|
+
"p-defer": "^4.0.1",
|
|
83
|
+
"p-event": "^6.0.1",
|
|
84
84
|
"p-queue": "^8.0.1",
|
|
85
85
|
"progress-events": "^1.0.0",
|
|
86
86
|
"protons-runtime": "^5.4.0",
|
|
87
87
|
"race-signal": "^1.0.2",
|
|
88
88
|
"uint8-varint": "^2.0.4",
|
|
89
89
|
"uint8arraylist": "^2.4.8",
|
|
90
|
-
"uint8arrays": "^5.0.
|
|
90
|
+
"uint8arrays": "^5.0.3"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
|
-
"@libp2p/interface-compliance-tests": "^5.3.
|
|
94
|
-
"@libp2p/logger": "^4.0.
|
|
95
|
-
"@libp2p/peer-id-factory": "^4.0.
|
|
96
|
-
"@libp2p/peer-store": "^10.0.
|
|
93
|
+
"@libp2p/interface-compliance-tests": "^5.3.4",
|
|
94
|
+
"@libp2p/logger": "^4.0.9",
|
|
95
|
+
"@libp2p/peer-id-factory": "^4.0.9",
|
|
96
|
+
"@libp2p/peer-store": "^10.0.13",
|
|
97
97
|
"@types/lodash.random": "^3.2.9",
|
|
98
98
|
"@types/lodash.range": "^3.2.9",
|
|
99
|
+
"@types/sinon": "^17.0.3",
|
|
99
100
|
"@types/which": "^3.0.3",
|
|
100
|
-
"aegir": "^42.2.
|
|
101
|
-
"datastore-core": "^9.2.
|
|
101
|
+
"aegir": "^42.2.5",
|
|
102
|
+
"datastore-core": "^9.2.9",
|
|
102
103
|
"datastore-level": "^10.1.7",
|
|
103
104
|
"delay": "^6.0.0",
|
|
104
105
|
"execa": "^8.0.1",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CodeError } from '@libp2p/interface'
|
|
2
|
+
import { Libp2pRecord } from '@libp2p/record'
|
|
2
3
|
import map from 'it-map'
|
|
3
4
|
import parallel from 'it-parallel'
|
|
4
5
|
import { pipe } from 'it-pipe'
|
|
@@ -11,7 +12,6 @@ import {
|
|
|
11
12
|
valueEvent,
|
|
12
13
|
queryErrorEvent
|
|
13
14
|
} from '../query/events.js'
|
|
14
|
-
import { Libp2pRecord } from '../record/index.js'
|
|
15
15
|
import { bestRecord } from '../record/selectors.js'
|
|
16
16
|
import { verifyRecord } from '../record/validators.js'
|
|
17
17
|
import { createPutRecord, bufferToRecordKey } from '../utils.js'
|
|
@@ -53,11 +53,6 @@ export class ContentFetching {
|
|
|
53
53
|
this.network = network
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
async putLocal (key: Uint8Array, rec: Uint8Array): Promise<void> {
|
|
57
|
-
const dsKey = bufferToRecordKey(key)
|
|
58
|
-
await this.components.datastore.put(dsKey, rec)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
56
|
/**
|
|
62
57
|
* Attempt to retrieve the value for the given key from
|
|
63
58
|
* the local datastore
|
|
@@ -128,6 +128,7 @@ export class ContentRouting {
|
|
|
128
128
|
*/
|
|
129
129
|
async * findProviders (key: CID, options: RoutingOptions): AsyncGenerator<PeerResponseEvent | ProviderEvent | QueryEvent> {
|
|
130
130
|
const toFind = this.routingTable.kBucketSize
|
|
131
|
+
let found = 0
|
|
131
132
|
const target = key.multihash.bytes
|
|
132
133
|
const self = this // eslint-disable-line @typescript-eslint/no-this-alias
|
|
133
134
|
|
|
@@ -158,11 +159,12 @@ export class ContentRouting {
|
|
|
158
159
|
|
|
159
160
|
yield peerResponseEvent({ from: this.components.peerId, messageType: MessageType.GET_PROVIDERS, providers }, options)
|
|
160
161
|
yield providerEvent({ from: this.components.peerId, providers }, options)
|
|
161
|
-
}
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
found += providers.length
|
|
164
|
+
|
|
165
|
+
if (found >= toFind) {
|
|
166
|
+
return
|
|
167
|
+
}
|
|
166
168
|
}
|
|
167
169
|
|
|
168
170
|
/**
|
|
@@ -201,10 +203,12 @@ export class ContentRouting {
|
|
|
201
203
|
|
|
202
204
|
if (newProviders.length > 0) {
|
|
203
205
|
yield providerEvent({ from: event.from, providers: newProviders }, options)
|
|
204
|
-
}
|
|
205
206
|
|
|
206
|
-
|
|
207
|
-
|
|
207
|
+
found += newProviders.length
|
|
208
|
+
|
|
209
|
+
if (found >= toFind) {
|
|
210
|
+
return
|
|
211
|
+
}
|
|
208
212
|
}
|
|
209
213
|
}
|
|
210
214
|
}
|
package/src/index.ts
CHANGED
|
@@ -90,7 +90,7 @@ import type { Datastore } from 'interface-datastore'
|
|
|
90
90
|
import type { CID } from 'multiformats/cid'
|
|
91
91
|
import type { ProgressEvent } from 'progress-events'
|
|
92
92
|
|
|
93
|
-
export { Libp2pRecord as Record } from '
|
|
93
|
+
export { Libp2pRecord as Record } from '@libp2p/record'
|
|
94
94
|
export { removePrivateAddressesMapper, removePublicAddressesMapper, passthroughMapper }
|
|
95
95
|
|
|
96
96
|
/**
|
package/src/network.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TypedEventEmitter } from '@libp2p/interface'
|
|
2
|
+
import { Libp2pRecord } from '@libp2p/record'
|
|
2
3
|
import { pbStream } from 'it-protobuf-stream'
|
|
3
4
|
import { CodeError } from 'protons-runtime'
|
|
4
5
|
import { Message } from './message/dht.js'
|
|
@@ -9,7 +10,6 @@ import {
|
|
|
9
10
|
peerResponseEvent,
|
|
10
11
|
queryErrorEvent
|
|
11
12
|
} from './query/events.js'
|
|
12
|
-
import { Libp2pRecord } from './record/index.js'
|
|
13
13
|
import type { KadDHTComponents, QueryEvent } from './index.js'
|
|
14
14
|
import type { AbortOptions, Logger, Stream, PeerId, PeerInfo, Startable, RoutingOptions } from '@libp2p/interface'
|
|
15
15
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { keys } from '@libp2p/crypto'
|
|
2
2
|
import { CodeError } from '@libp2p/interface'
|
|
3
3
|
import { peerIdFromKeys } from '@libp2p/peer-id'
|
|
4
|
+
import { Libp2pRecord } from '@libp2p/record'
|
|
4
5
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
5
6
|
import { MessageType } from '../message/dht.js'
|
|
6
7
|
import { PeerDistanceList } from '../peer-list/peer-distance-list.js'
|
|
@@ -9,7 +10,6 @@ import {
|
|
|
9
10
|
finalPeerEvent,
|
|
10
11
|
valueEvent
|
|
11
12
|
} from '../query/events.js'
|
|
12
|
-
import { Libp2pRecord } from '../record/index.js'
|
|
13
13
|
import { verifyRecord } from '../record/validators.js'
|
|
14
14
|
import * as utils from '../utils.js'
|
|
15
15
|
import type { KadDHTComponents, DHTRecord, DialPeerEvent, FinalPeerEvent, QueryEvent, Validators } from '../index.js'
|
package/src/query/events.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CustomEvent } from '@libp2p/interface'
|
|
2
2
|
import type { MessageType, SendQueryEvent, PeerResponseEvent, DialPeerEvent, AddPeerEvent, ValueEvent, ProviderEvent, QueryErrorEvent, FinalPeerEvent } from '../index.js'
|
|
3
|
-
import type { Libp2pRecord } from '../record/index.js'
|
|
4
3
|
import type { PeerId, PeerInfo } from '@libp2p/interface'
|
|
4
|
+
import type { Libp2pRecord } from '@libp2p/record'
|
|
5
5
|
import type { ProgressOptions } from 'progress-events'
|
|
6
6
|
|
|
7
7
|
export interface QueryEventFields {
|
package/src/query/manager.ts
CHANGED
|
@@ -48,7 +48,7 @@ export interface QueryOptions extends RoutingOptions {
|
|
|
48
48
|
export class QueryManager implements Startable {
|
|
49
49
|
public disjointPaths: number
|
|
50
50
|
private readonly alpha: number
|
|
51
|
-
private
|
|
51
|
+
private shutDownController: AbortController
|
|
52
52
|
private running: boolean
|
|
53
53
|
private queries: number
|
|
54
54
|
private readonly logger: ComponentLogger
|
|
@@ -96,6 +96,11 @@ export class QueryManager implements Startable {
|
|
|
96
96
|
*/
|
|
97
97
|
async start (): Promise<void> {
|
|
98
98
|
this.running = true
|
|
99
|
+
|
|
100
|
+
// allow us to stop queries on shut down
|
|
101
|
+
this.shutDownController = new AbortController()
|
|
102
|
+
// make sure we don't make a lot of noise in the logs
|
|
103
|
+
setMaxListeners(Infinity, this.shutDownController.signal)
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
/**
|
|
@@ -131,7 +136,6 @@ export class QueryManager implements Startable {
|
|
|
131
136
|
// if the user breaks out of a for..await of loop iterating over query
|
|
132
137
|
// results we need to cancel any in-flight network requests
|
|
133
138
|
const queryEarlyExitController = new AbortController()
|
|
134
|
-
setMaxListeners(Infinity, queryEarlyExitController.signal)
|
|
135
139
|
|
|
136
140
|
const signal = anySignal([
|
|
137
141
|
this.shutDownController.signal,
|
|
@@ -141,7 +145,7 @@ export class QueryManager implements Startable {
|
|
|
141
145
|
|
|
142
146
|
// this signal will get listened to for every invocation of queryFunc
|
|
143
147
|
// so make sure we don't make a lot of noise in the logs
|
|
144
|
-
setMaxListeners(Infinity, signal)
|
|
148
|
+
setMaxListeners(Infinity, signal, queryEarlyExitController.signal)
|
|
145
149
|
|
|
146
150
|
const log = this.logger.forComponent(`${this.logPrefix}:query:` + uint8ArrayToString(key, 'base58btc'))
|
|
147
151
|
|
package/src/query/query-path.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setMaxListeners } from '@libp2p/interface'
|
|
1
2
|
import { anySignal } from 'any-signal'
|
|
2
3
|
import Queue from 'p-queue'
|
|
3
4
|
import { toString } from 'uint8arrays/to-string'
|
|
@@ -112,6 +113,9 @@ export async function * queryPath (options: QueryPathOptions): AsyncGenerator<Qu
|
|
|
112
113
|
|
|
113
114
|
const compoundSignal = anySignal(signals)
|
|
114
115
|
|
|
116
|
+
// this signal can get listened to a lot
|
|
117
|
+
setMaxListeners(Infinity, compoundSignal)
|
|
118
|
+
|
|
115
119
|
try {
|
|
116
120
|
for await (const event of query({
|
|
117
121
|
key,
|
package/src/query-self.ts
CHANGED
|
@@ -106,10 +106,11 @@ export class QuerySelf implements Startable {
|
|
|
106
106
|
|
|
107
107
|
if (this.started) {
|
|
108
108
|
this.controller = new AbortController()
|
|
109
|
-
const
|
|
109
|
+
const timeoutSignal = AbortSignal.timeout(this.queryTimeout)
|
|
110
|
+
const signal = anySignal([this.controller.signal, timeoutSignal])
|
|
110
111
|
|
|
111
112
|
// this controller will get used for lots of dial attempts so make sure we don't cause warnings to be logged
|
|
112
|
-
setMaxListeners(Infinity, signal)
|
|
113
|
+
setMaxListeners(Infinity, signal, this.controller.signal, timeoutSignal)
|
|
113
114
|
|
|
114
115
|
try {
|
|
115
116
|
if (this.routingTable.size === 0) {
|
package/src/record/validators.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { CodeError } from '@libp2p/interface'
|
|
|
2
2
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
3
3
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
4
4
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
5
|
-
import type { Libp2pRecord } from './index.js'
|
|
6
5
|
import type { Validators } from '../index.js'
|
|
6
|
+
import type { Libp2pRecord } from '@libp2p/record'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Checks a record and ensures it is still valid.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CodeError } from '@libp2p/interface'
|
|
2
|
+
import { Libp2pRecord } from '@libp2p/record'
|
|
2
3
|
import {
|
|
3
4
|
MAX_RECORD_AGE
|
|
4
5
|
} from '../../constants.js'
|
|
5
6
|
import { MessageType } from '../../message/dht.js'
|
|
6
|
-
import { Libp2pRecord } from '../../record/index.js'
|
|
7
7
|
import { bufferToRecordKey, isPublicKeyKey, fromPublicKeyKey } from '../../utils.js'
|
|
8
8
|
import type { Message } from '../../message/dht.js'
|
|
9
9
|
import type { PeerRouting } from '../../peer-routing/index.js'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CodeError } from '@libp2p/interface'
|
|
2
|
-
import { Libp2pRecord } from '
|
|
2
|
+
import { Libp2pRecord } from '@libp2p/record'
|
|
3
3
|
import { verifyRecord } from '../../record/validators.js'
|
|
4
4
|
import { bufferToRecordKey } from '../../utils.js'
|
|
5
5
|
import type { Validators } from '../../index.js'
|
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { peerIdFromBytes } from '@libp2p/peer-id'
|
|
2
|
+
import { Libp2pRecord } from '@libp2p/record'
|
|
2
3
|
import { isPrivateIp } from '@libp2p/utils/private-ip'
|
|
3
4
|
import { Key } from 'interface-datastore/key'
|
|
4
5
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
@@ -6,7 +7,6 @@ import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
|
|
|
6
7
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
7
8
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
8
9
|
import { RECORD_KEY_PREFIX } from './constants.js'
|
|
9
|
-
import { Libp2pRecord } from './record/index.js'
|
|
10
10
|
import type { PeerId, PeerInfo } from '@libp2p/interface'
|
|
11
11
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
12
12
|
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Record } from './record.js';
|
|
2
|
-
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
3
|
-
export declare class Libp2pRecord {
|
|
4
|
-
key: Uint8Array;
|
|
5
|
-
value: Uint8Array;
|
|
6
|
-
timeReceived: Date;
|
|
7
|
-
constructor(key: Uint8Array, value: Uint8Array, timeReceived: Date);
|
|
8
|
-
serialize(): Uint8Array;
|
|
9
|
-
/**
|
|
10
|
-
* Return the object format ready to be given to the protobuf library.
|
|
11
|
-
*/
|
|
12
|
-
prepareSerialize(): Record;
|
|
13
|
-
/**
|
|
14
|
-
* Decode a protobuf encoded record
|
|
15
|
-
*/
|
|
16
|
-
static deserialize(raw: Uint8Array | Uint8ArrayList): Libp2pRecord;
|
|
17
|
-
/**
|
|
18
|
-
* Create a record from the raw object returned from the protobuf library
|
|
19
|
-
*/
|
|
20
|
-
static fromDeserialized(obj: Record): Libp2pRecord;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/record/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACP,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,qBAAa,YAAY;IAChB,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,UAAU,CAAA;IACjB,YAAY,EAAE,IAAI,CAAA;gBAEZ,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI;IAcnE,SAAS,IAAK,UAAU;IAIxB;;OAEG;IACH,gBAAgB,IAAK,MAAM;IAQ3B;;OAEG;IACH,MAAM,CAAC,WAAW,CAAE,GAAG,EAAE,UAAU,GAAG,cAAc,GAAG,YAAY;IAMnE;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAE,GAAG,EAAE,MAAM,GAAG,YAAY;CAiBpD"}
|
package/dist/src/record/index.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Record } from './record.js';
|
|
2
|
-
import * as utils from './utils.js';
|
|
3
|
-
export class Libp2pRecord {
|
|
4
|
-
key;
|
|
5
|
-
value;
|
|
6
|
-
timeReceived;
|
|
7
|
-
constructor(key, value, timeReceived) {
|
|
8
|
-
if (!(key instanceof Uint8Array)) {
|
|
9
|
-
throw new Error('key must be a Uint8Array');
|
|
10
|
-
}
|
|
11
|
-
if (!(value instanceof Uint8Array)) {
|
|
12
|
-
throw new Error('value must be a Uint8Array');
|
|
13
|
-
}
|
|
14
|
-
this.key = key;
|
|
15
|
-
this.value = value;
|
|
16
|
-
this.timeReceived = timeReceived;
|
|
17
|
-
}
|
|
18
|
-
serialize() {
|
|
19
|
-
return Record.encode(this.prepareSerialize());
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Return the object format ready to be given to the protobuf library.
|
|
23
|
-
*/
|
|
24
|
-
prepareSerialize() {
|
|
25
|
-
return {
|
|
26
|
-
key: this.key,
|
|
27
|
-
value: this.value,
|
|
28
|
-
timeReceived: utils.toRFC3339(this.timeReceived)
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Decode a protobuf encoded record
|
|
33
|
-
*/
|
|
34
|
-
static deserialize(raw) {
|
|
35
|
-
const rec = Record.decode(raw);
|
|
36
|
-
return new Libp2pRecord(rec.key, rec.value, new Date(rec.timeReceived));
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Create a record from the raw object returned from the protobuf library
|
|
40
|
-
*/
|
|
41
|
-
static fromDeserialized(obj) {
|
|
42
|
-
const recvtime = utils.parseRFC3339(obj.timeReceived);
|
|
43
|
-
if (obj.key == null) {
|
|
44
|
-
throw new Error('key missing from deserialized object');
|
|
45
|
-
}
|
|
46
|
-
if (obj.value == null) {
|
|
47
|
-
throw new Error('value missing from deserialized object');
|
|
48
|
-
}
|
|
49
|
-
const rec = new Libp2pRecord(obj.key, obj.value, recvtime);
|
|
50
|
-
return rec;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/record/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACP,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAGnC,MAAM,OAAO,YAAY;IAChB,GAAG,CAAY;IACf,KAAK,CAAY;IACjB,YAAY,CAAM;IAEzB,YAAa,GAAe,EAAE,KAAiB,EAAE,YAAkB;QACjE,IAAI,CAAC,CAAC,GAAG,YAAY,UAAU,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;QAC7C,CAAC;QAED,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,EAAE,CAAC;YACnC,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AG,CAAA;IACZ,CAAC;CACF"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Codec } from 'protons-runtime';
|
|
2
|
-
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
3
|
-
export interface Record {
|
|
4
|
-
key: Uint8Array;
|
|
5
|
-
value: Uint8Array;
|
|
6
|
-
timeReceived: string;
|
|
7
|
-
}
|
|
8
|
-
export declare namespace Record {
|
|
9
|
-
const codec: () => Codec<Record>;
|
|
10
|
-
const encode: (obj: Partial<Record>) => Uint8Array;
|
|
11
|
-
const decode: (buf: Uint8Array | Uint8ArrayList) => Record;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=record.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../src/record/record.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,UAAU,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,yBAAiB,MAAM,CAAC;IAGf,MAAM,KAAK,QAAO,MAAM,MAAM,CA0DpC,CAAA;IAEM,MAAM,MAAM,QAAS,QAAQ,MAAM,CAAC,KAAG,UAE7C,CAAA;IAEM,MAAM,MAAM,QAAS,UAAU,GAAG,cAAc,KAAG,MAEzD,CAAA;CACF"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/export */
|
|
2
|
-
/* eslint-disable complexity */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-namespace */
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
6
|
-
import { encodeMessage, decodeMessage, message } from 'protons-runtime';
|
|
7
|
-
export var Record;
|
|
8
|
-
(function (Record) {
|
|
9
|
-
let _codec;
|
|
10
|
-
Record.codec = () => {
|
|
11
|
-
if (_codec == null) {
|
|
12
|
-
_codec = message((obj, w, opts = {}) => {
|
|
13
|
-
if (opts.lengthDelimited !== false) {
|
|
14
|
-
w.fork();
|
|
15
|
-
}
|
|
16
|
-
if ((obj.key != null && obj.key.byteLength > 0)) {
|
|
17
|
-
w.uint32(10);
|
|
18
|
-
w.bytes(obj.key);
|
|
19
|
-
}
|
|
20
|
-
if ((obj.value != null && obj.value.byteLength > 0)) {
|
|
21
|
-
w.uint32(18);
|
|
22
|
-
w.bytes(obj.value);
|
|
23
|
-
}
|
|
24
|
-
if ((obj.timeReceived != null && obj.timeReceived !== '')) {
|
|
25
|
-
w.uint32(42);
|
|
26
|
-
w.string(obj.timeReceived);
|
|
27
|
-
}
|
|
28
|
-
if (opts.lengthDelimited !== false) {
|
|
29
|
-
w.ldelim();
|
|
30
|
-
}
|
|
31
|
-
}, (reader, length) => {
|
|
32
|
-
const obj = {
|
|
33
|
-
key: new Uint8Array(0),
|
|
34
|
-
value: new Uint8Array(0),
|
|
35
|
-
timeReceived: ''
|
|
36
|
-
};
|
|
37
|
-
const end = length == null ? reader.len : reader.pos + length;
|
|
38
|
-
while (reader.pos < end) {
|
|
39
|
-
const tag = reader.uint32();
|
|
40
|
-
switch (tag >>> 3) {
|
|
41
|
-
case 1:
|
|
42
|
-
obj.key = reader.bytes();
|
|
43
|
-
break;
|
|
44
|
-
case 2:
|
|
45
|
-
obj.value = reader.bytes();
|
|
46
|
-
break;
|
|
47
|
-
case 5:
|
|
48
|
-
obj.timeReceived = reader.string();
|
|
49
|
-
break;
|
|
50
|
-
default:
|
|
51
|
-
reader.skipType(tag & 7);
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return obj;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return _codec;
|
|
59
|
-
};
|
|
60
|
-
Record.encode = (obj) => {
|
|
61
|
-
return encodeMessage(obj, Record.codec());
|
|
62
|
-
};
|
|
63
|
-
Record.decode = (buf) => {
|
|
64
|
-
return decodeMessage(buf, Record.codec());
|
|
65
|
-
};
|
|
66
|
-
})(Record || (Record = {}));
|
|
67
|
-
//# sourceMappingURL=record.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../src/record/record.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,+BAA+B;AAC/B,oDAAoD;AACpD,8EAA8E;AAC9E,0DAA0D;AAE1D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAUvE,MAAM,KAAW,MAAM,CAsEtB;AAtED,WAAiB,MAAM;IACrB,IAAI,MAAqB,CAAA;IAEZ,YAAK,GAAG,GAAkB,EAAE;QACvC,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,MAAM,GAAG,OAAO,CAAS,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;gBAC7C,IAAI,IAAI,CAAC,eAAe,KAAK,KAAK,EAAE,CAAC;oBACnC,CAAC,CAAC,IAAI,EAAE,CAAA;gBACV,CAAC;gBAED,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC;oBAChD,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;oBACZ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;gBAClB,CAAC;gBAED,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC;oBACpD,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;oBACZ,CAAC,CAAC,KA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,CAAA;4BACxB,MAAK;oBACT,CAAC;gBACH,CAAC;gBAED,OAAO,GAAG,CAAA;YACZ,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IAEY,aAAM,GAAG,CAAC,GAAoB,EAAc,EAAE;QACzD,OAAO,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;IAC3C,CAAC,CAAA;IAEY,aAAM,GAAG,CAAC,GAAgC,EAAU,EAAE;QACjE,OAAO,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;IAC3C,CAAC,CAAA;AACH,CAAC,EAtEgB,MAAM,KAAN,MAAM,QAsEtB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert a JavaScript date into an `RFC3339Nano` formatted
|
|
3
|
-
* string
|
|
4
|
-
*/
|
|
5
|
-
export declare function toRFC3339(time: Date): string;
|
|
6
|
-
/**
|
|
7
|
-
* Parses a date string formatted as `RFC3339Nano` into a
|
|
8
|
-
* JavaScript Date object
|
|
9
|
-
*/
|
|
10
|
-
export declare function parseRFC3339(time: string): Date;
|
|
11
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/record/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,SAAS,CAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAW7C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAwBhD"}
|
package/dist/src/record/utils.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert a JavaScript date into an `RFC3339Nano` formatted
|
|
3
|
-
* string
|
|
4
|
-
*/
|
|
5
|
-
export function toRFC3339(time) {
|
|
6
|
-
const year = time.getUTCFullYear();
|
|
7
|
-
const month = String(time.getUTCMonth() + 1).padStart(2, '0');
|
|
8
|
-
const day = String(time.getUTCDate()).padStart(2, '0');
|
|
9
|
-
const hour = String(time.getUTCHours()).padStart(2, '0');
|
|
10
|
-
const minute = String(time.getUTCMinutes()).padStart(2, '0');
|
|
11
|
-
const seconds = String(time.getUTCSeconds()).padStart(2, '0');
|
|
12
|
-
const milliseconds = time.getUTCMilliseconds();
|
|
13
|
-
const nanoseconds = String(milliseconds * 1000 * 1000).padStart(9, '0');
|
|
14
|
-
return `${year}-${month}-${day}T${hour}:${minute}:${seconds}.${nanoseconds}Z`;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Parses a date string formatted as `RFC3339Nano` into a
|
|
18
|
-
* JavaScript Date object
|
|
19
|
-
*/
|
|
20
|
-
export function parseRFC3339(time) {
|
|
21
|
-
const rfc3339Matcher = new RegExp(
|
|
22
|
-
// 2006-01-02T
|
|
23
|
-
'(\\d{4})-(\\d{2})-(\\d{2})T' +
|
|
24
|
-
// 15:04:05
|
|
25
|
-
'(\\d{2}):(\\d{2}):(\\d{2})' +
|
|
26
|
-
// .999999999Z
|
|
27
|
-
'\\.(\\d+)Z');
|
|
28
|
-
const m = String(time).trim().match(rfc3339Matcher);
|
|
29
|
-
if (m == null) {
|
|
30
|
-
throw new Error('Invalid format');
|
|
31
|
-
}
|
|
32
|
-
const year = parseInt(m[1], 10);
|
|
33
|
-
const month = parseInt(m[2], 10) - 1;
|
|
34
|
-
const date = parseInt(m[3], 10);
|
|
35
|
-
const hour = parseInt(m[4], 10);
|
|
36
|
-
const minute = parseInt(m[5], 10);
|
|
37
|
-
const second = parseInt(m[6], 10);
|
|
38
|
-
const millisecond = parseInt(m[7].slice(0, -6), 10);
|
|
39
|
-
return new Date(Date.UTC(year, month, date, hour, minute, second, millisecond));
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version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