@@ -585,7 +585,7 @@ Writes a value to a key in the DHT.
585
585
| Name | Type | Description |
586
586
| ------| ------| -------------|
587
587
| key | ` string ` | key to add to the dht |
588
- | value | ` Buffer ` | value to add to the dht |
588
+ | value | ` Uint8Array ` | value to add to the dht |
589
589
| [ options] | ` object ` | put options |
590
590
| [ options.minPeers] | ` number ` | minimum number of peers required to successfully put (default: closestPeers.length) |
591
591
@@ -600,7 +600,7 @@ Writes a value to a key in the DHT.
600
600
``` js
601
601
// ...
602
602
const key = ' /key'
603
- const value = Buffer . from (' oh hello there' )
603
+ const value = uint8ArrayFromString (' oh hello there' )
604
604
605
605
await libp2p .contentRouting .put (key, value)
606
606
```
@@ -623,7 +623,7 @@ Queries the DHT for a value stored for a given key.
623
623
624
624
| Type | Description |
625
625
| ------| -------------|
626
- | ` Promise<Buffer > ` | Value obtained from the DHT |
626
+ | ` Promise<Uint8Array > ` | Value obtained from the DHT |
627
627
628
628
#### Example
629
629
@@ -653,7 +653,7 @@ Queries the DHT for the n values stored for the given key (without sorting).
653
653
654
654
| Type | Description |
655
655
| ------| -------------|
656
- | ` Promise<Array<{from: PeerId, val: Buffer }>> ` | Array of records obtained from the DHT |
656
+ | ` Promise<Array<{from: PeerId, val: Uint8Array }>> ` | Array of records obtained from the DHT |
657
657
658
658
#### Example
659
659
@@ -970,7 +970,7 @@ Delete the provided peer from the book.
970
970
``` js
971
971
peerStore .metadataBook .delete (peerId)
972
972
// false
973
- peerStore .metadataBook .set (peerId, ' nickname' , Buffer . from (' homePeer' ))
973
+ peerStore .metadataBook .set (peerId, ' nickname' , uint8ArrayFromString (' homePeer' ))
974
974
peerStore .metadataBook .delete (peerId)
975
975
// true
976
976
```
@@ -999,7 +999,7 @@ Deletes the provided peer metadata key-value pair from the book.
999
999
``` js
1000
1000
peerStore .metadataBook .deleteValue (peerId, ' location' )
1001
1001
// false
1002
- peerStore .metadataBook .set (peerId, ' location' , Buffer . from (' Berlin' ))
1002
+ peerStore .metadataBook .set (peerId, ' location' , uint8ArrayFromString (' Berlin' ))
1003
1003
peerStore .metadataBook .deleteValue (peerId, ' location' )
1004
1004
// true
1005
1005
```
@@ -1020,14 +1020,14 @@ Get the known metadata of a provided peer.
1020
1020
1021
1021
| Type | Description |
1022
1022
| ------| -------------|
1023
- | ` Map<string, Buffer > ` | Peer Metadata |
1023
+ | ` Map<string, Uint8Array > ` | Peer Metadata |
1024
1024
1025
1025
#### Example
1026
1026
1027
1027
``` js
1028
1028
peerStore .metadataBook .get (peerId)
1029
1029
// undefined
1030
- peerStore .metadataBook .set (peerId, ' location' , Buffer . from (' Berlin' ))
1030
+ peerStore .metadataBook .set (peerId, ' location' , uint8ArrayFromString (' Berlin' ))
1031
1031
peerStore .metadataBook .get (peerId)
1032
1032
// Metadata Map
1033
1033
```
@@ -1049,14 +1049,14 @@ Get specific metadata of a provided peer.
1049
1049
1050
1050
| Type | Description |
1051
1051
| ------| -------------|
1052
- | ` Map<string, Buffer > ` | Peer Metadata |
1052
+ | ` Map<string, Uint8Array > ` | Peer Metadata |
1053
1053
1054
1054
#### Example
1055
1055
1056
1056
``` js
1057
1057
peerStore .metadataBook .getValue (peerId, ' location' )
1058
1058
// undefined
1059
- peerStore .metadataBook .set (peerId, ' location' , Buffer . from (' Berlin' ))
1059
+ peerStore .metadataBook .set (peerId, ' location' , uint8ArrayFromString (' Berlin' ))
1060
1060
peerStore .metadataBook .getValue (peerId, ' location' )
1061
1061
// Metadata Map
1062
1062
```
@@ -1073,7 +1073,7 @@ Set known metadata of a given `peerId`.
1073
1073
| ------| ------| -------------|
1074
1074
| peerId | [ ` PeerId ` ] [ peer-id ] | peerId to set |
1075
1075
| key | ` string ` | key of the metadata value to store |
1076
- | value | ` Buffer ` | metadata value to store |
1076
+ | value | ` Uint8Array ` | metadata value to store |
1077
1077
1078
1078
#### Returns
1079
1079
@@ -1084,7 +1084,7 @@ Set known metadata of a given `peerId`.
1084
1084
#### Example
1085
1085
1086
1086
``` js
1087
- peerStore .metadataBook .set (peerId, ' location' , Buffer . from (' Berlin' ))
1087
+ peerStore .metadataBook .set (peerId, ' location' , uint8ArrayFromString (' Berlin' ))
1088
1088
```
1089
1089
1090
1090
### peerStore.protoBook.delete
@@ -1308,7 +1308,7 @@ Publishes messages to the given topics.
1308
1308
| Name | Type | Description |
1309
1309
| ------| ------| -------------|
1310
1310
| topic | ` string ` | topic to publish |
1311
- | data | ` Buffer ` | data to publish |
1311
+ | data | ` Uint8Array ` | data to publish |
1312
1312
1313
1313
#### Returns
1314
1314
@@ -1320,7 +1320,7 @@ Publishes messages to the given topics.
1320
1320
1321
1321
``` js
1322
1322
const topic = ' topic'
1323
- const data = Buffer . from (' data' )
1323
+ const data = uint8ArrayFromString (' data' )
1324
1324
1325
1325
await libp2p .pubsub .publish (topic, data)
1326
1326
```
@@ -1336,7 +1336,7 @@ Subscribes the given handler to a pubsub topic.
1336
1336
| Name | Type | Description |
1337
1337
| ------| ------| -------------|
1338
1338
| topic | ` string ` | topic to subscribe |
1339
- | handler | ` function({ from: string, data: Buffer , seqno: Buffer , topicIDs: Array<string>, signature: Buffer , key: Buffer }) ` | handler for new data on topic |
1339
+ | handler | ` function({ from: string, data: Uint8Array , seqno: Uint8Array , topicIDs: Array<string>, signature: Uint8Array , key: Uint8Array }) ` | handler for new data on topic |
1340
1340
1341
1341
#### Returns
1342
1342
@@ -1679,19 +1679,19 @@ Encrypt protected data using the Cryptographic Message Syntax (CMS).
1679
1679
| Name | Type | Description |
1680
1680
| ------| ------| -------------|
1681
1681
| name | ` string ` | The local key name. |
1682
- | data | ` Buffer ` | The data to encrypt. |
1682
+ | data | ` Uint8Array ` | The data to encrypt. |
1683
1683
1684
1684
#### Returns
1685
1685
1686
1686
| Type | Description |
1687
1687
| ------| -------------|
1688
- | ` Promise<Buffer > ` | Encrypted data as a PKCS #7 message in DER. |
1688
+ | ` Promise<Uint8Array > ` | Encrypted data as a PKCS #7 message in DER. |
1689
1689
1690
1690
#### Example
1691
1691
1692
1692
``` js
1693
1693
const keyInfo = await libp2p .keychain .createKey (' keyTest' , ' rsa' , 4096 )
1694
- const enc = await libp2p .keychain .cms .encrypt (' keyTest' , Buffer . from (' data' ))
1694
+ const enc = await libp2p .keychain .cms .encrypt (' keyTest' , uint8ArrayFromString (' data' ))
1695
1695
```
1696
1696
1697
1697
### keychain.cms.decrypt
@@ -1711,13 +1711,13 @@ The keychain must contain one of the keys used to encrypt the data. If none of
1711
1711
1712
1712
| Type | Description |
1713
1713
| ------| -------------|
1714
- | ` Promise<Buffer > ` | Decrypted data. |
1714
+ | ` Promise<Uint8Array > ` | Decrypted data. |
1715
1715
1716
1716
#### Example
1717
1717
1718
1718
``` js
1719
1719
const keyInfo = await libp2p .keychain .createKey (' keyTest' , ' rsa' , 4096 )
1720
- const enc = await libp2p .keychain .cms .encrypt (' keyTest' , Buffer . from (' data' ))
1720
+ const enc = await libp2p .keychain .cms .encrypt (' keyTest' , uint8ArrayFromString (' data' ))
1721
1721
const decData = await libp2p .keychain .cms .decrypt (enc)
1722
1722
```
1723
1723
0 commit comments