helia 6.1.4 → 7.0.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.
Files changed (92) hide show
  1. package/dist/index.min.js +65 -55
  2. package/dist/index.min.js.map +4 -4
  3. package/dist/src/block-storage.d.ts +62 -0
  4. package/dist/src/block-storage.d.ts.map +1 -0
  5. package/dist/src/block-storage.js +159 -0
  6. package/dist/src/block-storage.js.map +1 -0
  7. package/dist/src/datastore-version.d.ts +3 -0
  8. package/dist/src/datastore-version.d.ts.map +1 -0
  9. package/dist/src/datastore-version.js +20 -0
  10. package/dist/src/datastore-version.js.map +1 -0
  11. package/dist/src/get-codec.d.ts +4 -0
  12. package/dist/src/get-codec.d.ts.map +1 -0
  13. package/dist/src/get-codec.js +31 -0
  14. package/dist/src/get-codec.js.map +1 -0
  15. package/dist/src/get-crypto.d.ts +4 -0
  16. package/dist/src/get-crypto.d.ts.map +1 -0
  17. package/dist/src/get-crypto.js +35 -0
  18. package/dist/src/get-crypto.js.map +1 -0
  19. package/dist/src/get-hasher.d.ts +4 -0
  20. package/dist/src/get-hasher.d.ts.map +1 -0
  21. package/dist/src/get-hasher.js +31 -0
  22. package/dist/src/get-hasher.js.map +1 -0
  23. package/dist/src/helia.d.ts +165 -0
  24. package/dist/src/helia.d.ts.map +1 -0
  25. package/dist/src/helia.js +165 -0
  26. package/dist/src/helia.js.map +1 -0
  27. package/dist/src/index.d.ts +30 -19
  28. package/dist/src/index.d.ts.map +1 -1
  29. package/dist/src/index.js +78 -12
  30. package/dist/src/index.js.map +1 -1
  31. package/dist/src/networked-storage.d.ts +28 -0
  32. package/dist/src/networked-storage.d.ts.map +1 -0
  33. package/dist/src/networked-storage.js +52 -0
  34. package/dist/src/networked-storage.js.map +1 -0
  35. package/dist/src/pins.d.ts +21 -0
  36. package/dist/src/pins.d.ts.map +1 -0
  37. package/dist/src/pins.js +140 -0
  38. package/dist/src/pins.js.map +1 -0
  39. package/dist/src/routing.d.ts +51 -0
  40. package/dist/src/routing.d.ts.map +1 -0
  41. package/dist/src/routing.js +311 -0
  42. package/dist/src/routing.js.map +1 -0
  43. package/dist/src/session-storage.d.ts +47 -0
  44. package/dist/src/session-storage.d.ts.map +1 -0
  45. package/dist/src/session-storage.js +148 -0
  46. package/dist/src/session-storage.js.map +1 -0
  47. package/dist/src/storage.d.ts +55 -0
  48. package/dist/src/storage.d.ts.map +1 -0
  49. package/dist/src/storage.js +225 -0
  50. package/dist/src/storage.js.map +1 -0
  51. package/dist/src/version.d.ts +1 -1
  52. package/dist/src/version.js +1 -1
  53. package/dist/typedoc-urls.json +3 -6
  54. package/package.json +38 -41
  55. package/src/block-storage.ts +194 -0
  56. package/src/datastore-version.ts +25 -0
  57. package/src/get-codec.ts +39 -0
  58. package/src/get-crypto.ts +44 -0
  59. package/src/get-hasher.ts +39 -0
  60. package/src/helia.ts +364 -0
  61. package/src/index.ts +58 -30
  62. package/src/networked-storage.ts +74 -0
  63. package/src/pins.ts +208 -0
  64. package/src/routing.ts +389 -0
  65. package/src/session-storage.ts +174 -0
  66. package/src/storage.ts +294 -0
  67. package/src/version.ts +1 -1
  68. package/dist/src/utils/bootstrappers.d.ts +0 -4
  69. package/dist/src/utils/bootstrappers.d.ts.map +0 -1
  70. package/dist/src/utils/bootstrappers.js +0 -13
  71. package/dist/src/utils/bootstrappers.js.map +0 -1
  72. package/dist/src/utils/helia-defaults.d.ts +0 -48
  73. package/dist/src/utils/helia-defaults.d.ts.map +0 -1
  74. package/dist/src/utils/helia-defaults.js +0 -85
  75. package/dist/src/utils/helia-defaults.js.map +0 -1
  76. package/dist/src/utils/libp2p-defaults.browser.d.ts +0 -19
  77. package/dist/src/utils/libp2p-defaults.browser.d.ts.map +0 -1
  78. package/dist/src/utils/libp2p-defaults.browser.js +0 -73
  79. package/dist/src/utils/libp2p-defaults.browser.js.map +0 -1
  80. package/dist/src/utils/libp2p-defaults.d.ts +0 -49
  81. package/dist/src/utils/libp2p-defaults.d.ts.map +0 -1
  82. package/dist/src/utils/libp2p-defaults.js +0 -113
  83. package/dist/src/utils/libp2p-defaults.js.map +0 -1
  84. package/dist/src/utils/libp2p.d.ts +0 -19
  85. package/dist/src/utils/libp2p.d.ts.map +0 -1
  86. package/dist/src/utils/libp2p.js +0 -19
  87. package/dist/src/utils/libp2p.js.map +0 -1
  88. package/src/utils/bootstrappers.ts +0 -12
  89. package/src/utils/helia-defaults.ts +0 -92
  90. package/src/utils/libp2p-defaults.browser.ts +0 -92
  91. package/src/utils/libp2p-defaults.ts +0 -137
  92. package/src/utils/libp2p.ts +0 -42
@@ -1,73 +0,0 @@
1
- import { noise } from '@chainsafe/libp2p-noise';
2
- import { yamux } from '@chainsafe/libp2p-yamux';
3
- import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client';
4
- import { delegatedHTTPRoutingDefaults } from '@helia/routers';
5
- import { autoNAT } from '@libp2p/autonat';
6
- import { bootstrap } from '@libp2p/bootstrap';
7
- import { circuitRelayTransport } from '@libp2p/circuit-relay-v2';
8
- import { dcutr } from '@libp2p/dcutr';
9
- import { http } from '@libp2p/http';
10
- import { identify, identifyPush } from '@libp2p/identify';
11
- import { kadDHT } from '@libp2p/kad-dht';
12
- import { keychain } from '@libp2p/keychain';
13
- import { mplex } from '@libp2p/mplex';
14
- import { ping } from '@libp2p/ping';
15
- import { webRTC, webRTCDirect } from '@libp2p/webrtc';
16
- import { webSockets } from '@libp2p/websockets';
17
- import { ipnsSelector } from 'ipns/selector';
18
- import { ipnsValidator } from 'ipns/validator';
19
- import { userAgent } from 'libp2p/user-agent';
20
- import { name, version } from "../version.js";
21
- import { bootstrapConfig } from "./bootstrappers.js";
22
- export function libp2pDefaults(options = {}) {
23
- const agentVersion = `${name}/${version} ${userAgent()}`;
24
- return {
25
- privateKey: options.privateKey,
26
- dns: options.dns,
27
- nodeInfo: {
28
- userAgent: agentVersion
29
- },
30
- addresses: {
31
- listen: [
32
- '/p2p-circuit',
33
- '/webrtc'
34
- ]
35
- },
36
- transports: [
37
- circuitRelayTransport(),
38
- webRTC(),
39
- webRTCDirect(),
40
- webSockets()
41
- ],
42
- connectionEncrypters: [
43
- noise()
44
- ],
45
- streamMuxers: [
46
- yamux(),
47
- mplex()
48
- ],
49
- peerDiscovery: [
50
- bootstrap(bootstrapConfig)
51
- ],
52
- services: {
53
- autoNAT: autoNAT(),
54
- dcutr: dcutr(),
55
- delegatedRouting: delegatedRoutingV1HttpApiClient(delegatedHTTPRoutingDefaults()),
56
- dht: kadDHT({
57
- clientMode: true,
58
- validators: {
59
- ipns: ipnsValidator
60
- },
61
- selectors: {
62
- ipns: ipnsSelector
63
- }
64
- }),
65
- identify: identify(),
66
- identifyPush: identifyPush(),
67
- keychain: keychain(options.keychain),
68
- ping: ping(),
69
- http: http()
70
- }
71
- };
72
- }
73
- //# sourceMappingURL=libp2p-defaults.browser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"libp2p-defaults.browser.js","sourceRoot":"","sources":["../../../src/utils/libp2p-defaults.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAC/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAA;AAC7F,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;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,GAAG,EAAE,MAAM,CAAC;gBACV,UAAU,EAAE,IAAI;gBAChB,UAAU,EAAE;oBACV,IAAI,EAAE,aAAa;iBACpB;gBACD,SAAS,EAAE;oBACT,IAAI,EAAE,YAAY;iBACnB;aACF,CAAC;YACF,QAAQ,EAAE,QAAQ,EAAE;YACpB,YAAY,EAAE,YAAY,EAAE;YAC5B,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC;YACpC,IAAI,EAAE,IAAI,EAAE;YACZ,IAAI,EAAE,IAAI,EAAE;SACb;KACF,CAAA;AACH,CAAC"}
@@ -1,49 +0,0 @@
1
- import type { Libp2pDefaultsOptions } from './libp2p.ts';
2
- import type { AutoTLS } from '@ipshipyard/libp2p-auto-tls';
3
- import type { CircuitRelayService } from '@libp2p/circuit-relay-v2';
4
- import type { HTTP } from '@libp2p/http';
5
- import type { Identify } from '@libp2p/identify';
6
- import type { KadDHT } from '@libp2p/kad-dht';
7
- import type { Keychain } from '@libp2p/keychain';
8
- import type { Ping } from '@libp2p/ping';
9
- import type { Libp2pOptions } from 'libp2p';
10
- export interface DefaultLibp2pServices extends Record<string, unknown> {
11
- autoNAT: unknown;
12
- autoTLS: AutoTLS;
13
- dcutr: unknown;
14
- delegatedRouting: unknown;
15
- dht: KadDHT;
16
- identify: Identify;
17
- keychain: Keychain;
18
- ping: Ping;
19
- relay: CircuitRelayService;
20
- upnp: unknown;
21
- http: HTTP;
22
- }
23
- /**
24
- * Returns the default libp2p config used by Helia which can then be modified or
25
- * extended to suit individual applications.
26
- *
27
- * @example Adding an additional libp2p service
28
- *
29
- * ```ts
30
- * import { myService } from '@example/my-service'
31
- * import { createHelia, libp2pDefaults } from 'helia'
32
- *
33
- * // get a copy of the default libp2p config
34
- * const libp2p = libp2pDefaults()
35
- *
36
- * // add the custom service to the service map
37
- * libp2p.services.myService = myService()
38
- *
39
- * // create a Helia node with the custom libp2p config
40
- * const helia = await createHelia({
41
- * libp2p
42
- * })
43
- *
44
- * //... use service
45
- * helia.libp2p.services.myService.serviceMethod()
46
- * ```
47
- */
48
- export declare function libp2pDefaults(options?: Libp2pDefaultsOptions): Libp2pOptions<DefaultLibp2pServices> & Required<Pick<Libp2pOptions<DefaultLibp2pServices>, 'services'>>;
49
- //# sourceMappingURL=libp2p-defaults.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"libp2p-defaults.d.ts","sourceRoot":"","sources":["../../../src/utils/libp2p-defaults.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAE3C,MAAM,WAAW,qBAAsB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACpE,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;IACd,gBAAgB,EAAE,OAAO,CAAA;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,QAAQ,CAAA;IAClB,QAAQ,EAAE,QAAQ,CAAA;IAClB,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,mBAAmB,CAAA;IAC1B,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,IAAI,CAAA;CACX;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,cAAc,CAAE,OAAO,GAAE,qBAA0B,GAAG,aAAa,CAAC,qBAAqB,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC,EAAE,UAAU,CAAC,CAAC,CA6D5K"}
@@ -1,113 +0,0 @@
1
- import { noise } from '@chainsafe/libp2p-noise';
2
- import { yamux } from '@chainsafe/libp2p-yamux';
3
- import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client';
4
- import { delegatedHTTPRoutingDefaults } from '@helia/routers';
5
- import { autoTLS } from '@ipshipyard/libp2p-auto-tls';
6
- import { autoNAT } from '@libp2p/autonat';
7
- import { bootstrap } from '@libp2p/bootstrap';
8
- import { circuitRelayTransport, circuitRelayServer } from '@libp2p/circuit-relay-v2';
9
- import { dcutr } from '@libp2p/dcutr';
10
- import { http } from '@libp2p/http';
11
- import { identify, identifyPush } from '@libp2p/identify';
12
- import { kadDHT } from '@libp2p/kad-dht';
13
- import { keychain } from '@libp2p/keychain';
14
- import { mdns } from '@libp2p/mdns';
15
- import { mplex } from '@libp2p/mplex';
16
- import { ping } from '@libp2p/ping';
17
- import { tcp } from '@libp2p/tcp';
18
- import { tls } from '@libp2p/tls';
19
- import { uPnPNAT } from '@libp2p/upnp-nat';
20
- import { webRTC, webRTCDirect } from '@libp2p/webrtc';
21
- import { webSockets } from '@libp2p/websockets';
22
- import { ipnsSelector } from 'ipns/selector';
23
- import { ipnsValidator } from 'ipns/validator';
24
- import { userAgent } from 'libp2p/user-agent';
25
- import { name, version } from "../version.js";
26
- import { bootstrapConfig } from "./bootstrappers.js";
27
- /**
28
- * Returns the default libp2p config used by Helia which can then be modified or
29
- * extended to suit individual applications.
30
- *
31
- * @example Adding an additional libp2p service
32
- *
33
- * ```ts
34
- * import { myService } from '@example/my-service'
35
- * import { createHelia, libp2pDefaults } from 'helia'
36
- *
37
- * // get a copy of the default libp2p config
38
- * const libp2p = libp2pDefaults()
39
- *
40
- * // add the custom service to the service map
41
- * libp2p.services.myService = myService()
42
- *
43
- * // create a Helia node with the custom libp2p config
44
- * const helia = await createHelia({
45
- * libp2p
46
- * })
47
- *
48
- * //... use service
49
- * helia.libp2p.services.myService.serviceMethod()
50
- * ```
51
- */
52
- export function libp2pDefaults(options = {}) {
53
- const agentVersion = `${name}/${version} ${userAgent()}`;
54
- return {
55
- privateKey: options.privateKey,
56
- dns: options.dns,
57
- nodeInfo: {
58
- userAgent: agentVersion
59
- },
60
- addresses: {
61
- listen: [
62
- '/ip4/0.0.0.0/tcp/0',
63
- '/ip4/0.0.0.0/tcp/0/ws',
64
- '/ip4/0.0.0.0/udp/0/webrtc-direct',
65
- '/ip6/::/tcp/0',
66
- '/ip6/::/tcp/0/ws',
67
- '/ip6/::/udp/0/webrtc-direct',
68
- '/p2p-circuit'
69
- ]
70
- },
71
- transports: [
72
- circuitRelayTransport(),
73
- tcp(),
74
- webRTC(),
75
- webRTCDirect(),
76
- webSockets()
77
- ],
78
- connectionEncrypters: [
79
- noise(),
80
- tls()
81
- ],
82
- streamMuxers: [
83
- yamux(),
84
- mplex()
85
- ],
86
- peerDiscovery: [
87
- mdns(),
88
- bootstrap(bootstrapConfig)
89
- ],
90
- services: {
91
- autoNAT: autoNAT(),
92
- autoTLS: autoTLS(),
93
- dcutr: dcutr(),
94
- delegatedRouting: delegatedRoutingV1HttpApiClient(delegatedHTTPRoutingDefaults()),
95
- dht: kadDHT({
96
- validators: {
97
- ipns: ipnsValidator
98
- },
99
- selectors: {
100
- ipns: ipnsSelector
101
- }
102
- }),
103
- identify: identify(),
104
- identifyPush: identifyPush(),
105
- keychain: keychain(options.keychain),
106
- ping: ping(),
107
- relay: circuitRelayServer(),
108
- upnp: uPnPNAT(),
109
- http: http()
110
- }
111
- };
112
- }
113
- //# sourceMappingURL=libp2p-defaults.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"libp2p-defaults.js","sourceRoot":"","sources":["../../../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,EAAE;YACpB,YAAY,EAAE,YAAY,EAAE;YAC5B,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC;YACpC,IAAI,EAAE,IAAI,EAAE;YACZ,KAAK,EAAE,kBAAkB,EAAE;YAC3B,IAAI,EAAE,OAAO,EAAE;YACf,IAAI,EAAE,IAAI,EAAE;SACb;KACF,CAAA;AACH,CAAC"}
@@ -1,19 +0,0 @@
1
- import type { ComponentLogger, Libp2p, PrivateKey } from '@libp2p/interface';
2
- import type { KeychainInit } from '@libp2p/keychain';
3
- import type { DNS } from '@multiformats/dns';
4
- import type { Datastore } from 'interface-datastore';
5
- import type { Libp2pOptions } from 'libp2p';
6
- export interface CreateLibp2pOptions<T extends Record<string, unknown>> {
7
- datastore: Datastore;
8
- libp2p?: Libp2pOptions<T>;
9
- logger?: ComponentLogger;
10
- keychain?: KeychainInit;
11
- start?: boolean;
12
- }
13
- export interface Libp2pDefaultsOptions {
14
- privateKey?: PrivateKey;
15
- keychain?: KeychainInit;
16
- dns?: DNS;
17
- }
18
- export declare function createLibp2p<T extends Record<string, unknown>>(options: CreateLibp2pOptions<T>): Promise<Libp2p<T>>;
19
- //# sourceMappingURL=libp2p.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"libp2p.d.ts","sourceRoot":"","sources":["../../../src/utils/libp2p.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAE3C,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACpE,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;IACzB,MAAM,CAAC,EAAE,eAAe,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,GAAG,CAAA;CACV;AAED,wBAAsB,YAAY,CAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAG,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAkB3H"}
@@ -1,19 +0,0 @@
1
- import { loadOrCreateSelfKey } from '@libp2p/config';
2
- import { createLibp2p as create } from 'libp2p';
3
- import { libp2pDefaults } from "./libp2p-defaults.js";
4
- export async function createLibp2p(options) {
5
- const libp2pOptions = options.libp2p ?? {};
6
- // if no peer id was passed, try to load it from the keychain
7
- if (libp2pOptions.privateKey == null && options.datastore != null) {
8
- libp2pOptions.privateKey = await loadOrCreateSelfKey(options.datastore, options.keychain);
9
- }
10
- const defaults = libp2pDefaults(libp2pOptions);
11
- defaults.datastore = defaults.datastore ?? options.datastore;
12
- const node = await create({
13
- ...defaults,
14
- ...libp2pOptions,
15
- start: false
16
- });
17
- return node;
18
- }
19
- //# sourceMappingURL=libp2p.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"libp2p.js","sourceRoot":"","sources":["../../../src/utils/libp2p.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAqBrD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAsC,OAA+B;IACrG,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAA;IAE1C,6DAA6D;IAC7D,IAAI,aAAa,CAAC,UAAU,IAAI,IAAI,IAAI,OAAO,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;QAClE,aAAa,CAAC,UAAU,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC3F,CAAC;IAED,MAAM,QAAQ,GAAQ,cAAc,CAAC,aAAa,CAAC,CAAA;IACnD,QAAQ,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAA;IAE5D,MAAM,IAAI,GAAG,MAAM,MAAM,CAAI;QAC3B,GAAG,QAAQ;QACX,GAAG,aAAa;QAChB,KAAK,EAAE,KAAK;KACb,CAAC,CAAA;IAEF,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -1,12 +0,0 @@
1
- // this list comes from https://github.com/ipfs/kubo/blob/da28fbc65a2e0f1ce59f9923823326ae2bc4f713/config/bootstrap_peers.go#L17
2
- export const bootstrapConfig = {
3
- list: [
4
- '/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN',
5
- '/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb',
6
- '/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt',
7
- // va1 is not in the TXT records for _dnsaddr.bootstrap.libp2p.io yet
8
- // so use the host name directly
9
- '/dnsaddr/va1.bootstrap.libp2p.io/p2p/12D3KooWKnDdG3iXw9eTFijk3EWSunZcFi54Zka4wmtqtt6rPxc8',
10
- '/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ'
11
- ]
12
- }
@@ -1,92 +0,0 @@
1
- /**
2
- * @packageDocumentation
3
- *
4
- * Exports a `createHelia` function that returns an object that implements the {@link Helia} API.
5
- *
6
- * Pass it to other modules like {@link https://www.npmjs.com/package/@helia/unixfs | @helia/unixfs} to make files available on the distributed web.
7
- *
8
- * @example
9
- *
10
- * ```typescript
11
- * import { createHelia } from 'helia'
12
- * import { unixfs } from '@helia/unixfs'
13
- * import { CID } from 'multiformats/cid'
14
- *
15
- * const helia = await createHelia()
16
- *
17
- * const fs = unixfs(helia)
18
- * fs.cat(CID.parse('bafyFoo'))
19
- * ```
20
- */
21
-
22
- import { bitswap, trustlessGateway } from '@helia/block-brokers'
23
- import { httpGatewayRouting, libp2pRouting } from '@helia/routers'
24
- import { MemoryBlockstore } from 'blockstore-core'
25
- import { MemoryDatastore } from 'datastore-core'
26
- import { isLibp2p } from 'libp2p'
27
- import { createLibp2p } from '../utils/libp2p.ts'
28
- import type { DefaultLibp2pServices } from '../utils/libp2p-defaults.ts'
29
- import type { HeliaInit } from '@helia/utils'
30
- import type { Libp2p } from '@libp2p/interface'
31
-
32
- /**
33
- * Create and return the default options used to create a Helia node
34
- *
35
- * @example Adding an additional libp2p service
36
- *
37
- * ```ts
38
- * import { myService } from '@example/my-service'
39
- * import { createHelia, heliaDefaults } from 'helia'
40
- *
41
- * // get a copy of the default libp2p config
42
- * const init = heliaDefaults()
43
- *
44
- * // add the custom service to the service map
45
- * init.libp2p.services.myService = myService()
46
- *
47
- * // create a Helia node with the custom config
48
- * const helia = await createHelia(init)
49
- *
50
- * //... use service
51
- * helia.libp2p.services.myService.serviceMethod()
52
- * ```
53
- */
54
- export async function heliaDefaults <T extends Libp2p> (init: Partial<HeliaInit<T>> = {}): Promise<Omit<HeliaInit<T>, 'libp2p'> & { libp2p: T }> {
55
- const datastore = init.datastore ?? new MemoryDatastore()
56
- const blockstore = init.blockstore ?? new MemoryBlockstore()
57
-
58
- let libp2p: any
59
-
60
- if (isLibp2p(init.libp2p)) {
61
- libp2p = init.libp2p as any
62
- } else {
63
- libp2p = await createLibp2p<DefaultLibp2pServices>({
64
- ...init,
65
- libp2p: {
66
- dns: init.dns,
67
- ...init.libp2p,
68
-
69
- // ignore the libp2p start parameter as it should be on the main init
70
- // object instead
71
- start: undefined
72
- },
73
- datastore
74
- })
75
- }
76
-
77
- return {
78
- ...init,
79
- libp2p,
80
- datastore,
81
- blockstore,
82
- blockBrokers: init.blockBrokers ?? [
83
- trustlessGateway(),
84
- bitswap()
85
- ],
86
- routers: init.routers ?? [
87
- libp2pRouting(libp2p),
88
- httpGatewayRouting()
89
- ],
90
- metrics: libp2p.metrics
91
- }
92
- }
@@ -1,92 +0,0 @@
1
- import { noise } from '@chainsafe/libp2p-noise'
2
- import { yamux } from '@chainsafe/libp2p-yamux'
3
- import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
4
- import { delegatedHTTPRoutingDefaults } from '@helia/routers'
5
- import { autoNAT } from '@libp2p/autonat'
6
- import { bootstrap } from '@libp2p/bootstrap'
7
- import { circuitRelayTransport } from '@libp2p/circuit-relay-v2'
8
- import { dcutr } from '@libp2p/dcutr'
9
- import { http } from '@libp2p/http'
10
- import { identify, identifyPush } from '@libp2p/identify'
11
- import { kadDHT } from '@libp2p/kad-dht'
12
- import { keychain } from '@libp2p/keychain'
13
- import { mplex } from '@libp2p/mplex'
14
- import { ping } from '@libp2p/ping'
15
- import { webRTC, webRTCDirect } from '@libp2p/webrtc'
16
- import { webSockets } from '@libp2p/websockets'
17
- import { ipnsSelector } from 'ipns/selector'
18
- import { ipnsValidator } from 'ipns/validator'
19
- import { userAgent } from 'libp2p/user-agent'
20
- import { name, version } from '../version.ts'
21
- import { bootstrapConfig } from './bootstrappers.ts'
22
- import type { Libp2pDefaultsOptions } from './libp2p.ts'
23
- import type { HTTP } from '@libp2p/http'
24
- import type { Identify } from '@libp2p/identify'
25
- import type { KadDHT } from '@libp2p/kad-dht'
26
- import type { Keychain } from '@libp2p/keychain'
27
- import type { Ping } from '@libp2p/ping'
28
- import type { Libp2pOptions } from 'libp2p'
29
-
30
- export interface DefaultLibp2pServices extends Record<string, unknown> {
31
- autoNAT: unknown
32
- dcutr: unknown
33
- delegatedRouting: unknown
34
- dht: KadDHT
35
- identify: Identify
36
- keychain: Keychain
37
- ping: Ping
38
- http: HTTP
39
- }
40
-
41
- export function libp2pDefaults (options: Libp2pDefaultsOptions = {}): Libp2pOptions<DefaultLibp2pServices> & Required<Pick<Libp2pOptions<DefaultLibp2pServices>, 'services'>> {
42
- const agentVersion = `${name}/${version} ${userAgent()}`
43
-
44
- return {
45
- privateKey: options.privateKey,
46
- dns: options.dns,
47
- nodeInfo: {
48
- userAgent: agentVersion
49
- },
50
- addresses: {
51
- listen: [
52
- '/p2p-circuit',
53
- '/webrtc'
54
- ]
55
- },
56
- transports: [
57
- circuitRelayTransport(),
58
- webRTC(),
59
- webRTCDirect(),
60
- webSockets()
61
- ],
62
- connectionEncrypters: [
63
- noise()
64
- ],
65
- streamMuxers: [
66
- yamux(),
67
- mplex()
68
- ],
69
- peerDiscovery: [
70
- bootstrap(bootstrapConfig)
71
- ],
72
- services: {
73
- autoNAT: autoNAT(),
74
- dcutr: dcutr(),
75
- delegatedRouting: delegatedRoutingV1HttpApiClient(delegatedHTTPRoutingDefaults()),
76
- dht: kadDHT({
77
- clientMode: true,
78
- validators: {
79
- ipns: ipnsValidator
80
- },
81
- selectors: {
82
- ipns: ipnsSelector
83
- }
84
- }),
85
- identify: identify(),
86
- identifyPush: identifyPush(),
87
- keychain: keychain(options.keychain),
88
- ping: ping(),
89
- http: http()
90
- }
91
- }
92
- }
@@ -1,137 +0,0 @@
1
- import { noise } from '@chainsafe/libp2p-noise'
2
- import { yamux } from '@chainsafe/libp2p-yamux'
3
- import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
4
- import { delegatedHTTPRoutingDefaults } from '@helia/routers'
5
- import { autoTLS } from '@ipshipyard/libp2p-auto-tls'
6
- import { autoNAT } from '@libp2p/autonat'
7
- import { bootstrap } from '@libp2p/bootstrap'
8
- import { circuitRelayTransport, circuitRelayServer } from '@libp2p/circuit-relay-v2'
9
- import { dcutr } from '@libp2p/dcutr'
10
- import { http } from '@libp2p/http'
11
- import { identify, identifyPush } from '@libp2p/identify'
12
- import { kadDHT } from '@libp2p/kad-dht'
13
- import { keychain } from '@libp2p/keychain'
14
- import { mdns } from '@libp2p/mdns'
15
- import { mplex } from '@libp2p/mplex'
16
- import { ping } from '@libp2p/ping'
17
- import { tcp } from '@libp2p/tcp'
18
- import { tls } from '@libp2p/tls'
19
- import { uPnPNAT } from '@libp2p/upnp-nat'
20
- import { webRTC, webRTCDirect } from '@libp2p/webrtc'
21
- import { webSockets } from '@libp2p/websockets'
22
- import { ipnsSelector } from 'ipns/selector'
23
- import { ipnsValidator } from 'ipns/validator'
24
- import { userAgent } from 'libp2p/user-agent'
25
- import { name, version } from '../version.ts'
26
- import { bootstrapConfig } from './bootstrappers.ts'
27
- import type { Libp2pDefaultsOptions } from './libp2p.ts'
28
- import type { AutoTLS } from '@ipshipyard/libp2p-auto-tls'
29
- import type { CircuitRelayService } from '@libp2p/circuit-relay-v2'
30
- import type { HTTP } from '@libp2p/http'
31
- import type { Identify } from '@libp2p/identify'
32
- import type { KadDHT } from '@libp2p/kad-dht'
33
- import type { Keychain } from '@libp2p/keychain'
34
- import type { Ping } from '@libp2p/ping'
35
- import type { Libp2pOptions } from 'libp2p'
36
-
37
- export interface DefaultLibp2pServices extends Record<string, unknown> {
38
- autoNAT: unknown
39
- autoTLS: AutoTLS
40
- dcutr: unknown
41
- delegatedRouting: unknown
42
- dht: KadDHT
43
- identify: Identify
44
- keychain: Keychain
45
- ping: Ping
46
- relay: CircuitRelayService
47
- upnp: unknown
48
- http: HTTP
49
- }
50
-
51
- /**
52
- * Returns the default libp2p config used by Helia which can then be modified or
53
- * extended to suit individual applications.
54
- *
55
- * @example Adding an additional libp2p service
56
- *
57
- * ```ts
58
- * import { myService } from '@example/my-service'
59
- * import { createHelia, libp2pDefaults } from 'helia'
60
- *
61
- * // get a copy of the default libp2p config
62
- * const libp2p = libp2pDefaults()
63
- *
64
- * // add the custom service to the service map
65
- * libp2p.services.myService = myService()
66
- *
67
- * // create a Helia node with the custom libp2p config
68
- * const helia = await createHelia({
69
- * libp2p
70
- * })
71
- *
72
- * //... use service
73
- * helia.libp2p.services.myService.serviceMethod()
74
- * ```
75
- */
76
- export function libp2pDefaults (options: Libp2pDefaultsOptions = {}): Libp2pOptions<DefaultLibp2pServices> & Required<Pick<Libp2pOptions<DefaultLibp2pServices>, 'services'>> {
77
- const agentVersion = `${name}/${version} ${userAgent()}`
78
-
79
- return {
80
- privateKey: options.privateKey,
81
- dns: options.dns,
82
- nodeInfo: {
83
- userAgent: agentVersion
84
- },
85
- addresses: {
86
- listen: [
87
- '/ip4/0.0.0.0/tcp/0',
88
- '/ip4/0.0.0.0/tcp/0/ws',
89
- '/ip4/0.0.0.0/udp/0/webrtc-direct',
90
- '/ip6/::/tcp/0',
91
- '/ip6/::/tcp/0/ws',
92
- '/ip6/::/udp/0/webrtc-direct',
93
- '/p2p-circuit'
94
- ]
95
- },
96
- transports: [
97
- circuitRelayTransport(),
98
- tcp(),
99
- webRTC(),
100
- webRTCDirect(),
101
- webSockets()
102
- ],
103
- connectionEncrypters: [
104
- noise(),
105
- tls()
106
- ],
107
- streamMuxers: [
108
- yamux(),
109
- mplex()
110
- ],
111
- peerDiscovery: [
112
- mdns(),
113
- bootstrap(bootstrapConfig)
114
- ],
115
- services: {
116
- autoNAT: autoNAT(),
117
- autoTLS: autoTLS(),
118
- dcutr: dcutr(),
119
- delegatedRouting: delegatedRoutingV1HttpApiClient(delegatedHTTPRoutingDefaults()),
120
- dht: kadDHT({
121
- validators: {
122
- ipns: ipnsValidator
123
- },
124
- selectors: {
125
- ipns: ipnsSelector
126
- }
127
- }),
128
- identify: identify(),
129
- identifyPush: identifyPush(),
130
- keychain: keychain(options.keychain),
131
- ping: ping(),
132
- relay: circuitRelayServer(),
133
- upnp: uPnPNAT(),
134
- http: http()
135
- }
136
- }
137
- }