Skip to content

Commit da4b624

Browse files
committed
Includes PeerID in Leth token generation.
Bumps the version to 0.20.0. Does not include the fixes to hardcoded JS needed to make the example work on Leth.
1 parent ed616d7 commit da4b624

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

example/gateway-browser/src/pages/Wallet.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default class WalletPage extends Component {
1919
wallet: '',
2020
tld: 'lsn',
2121
address: null,
22+
peerId: "",
2223
web3: null,
2324
ensAddress: '',
2425
resolverAddress: '',
@@ -59,9 +60,10 @@ export default class WalletPage extends Component {
5960
};
6061

6162
generateAuthToken = async () => {
62-
const { web3, address } = this.state;
63+
const { web3, address, peerId } = this.state;
64+
6365
try {
64-
const token = await Leth.Token.generateAuthToken(web3, { address, tokenBlocksLifespan: 10000 });
66+
const token = await Leth.Token.generateAuthToken(web3, { address, tokenBlocksLifespan: 10000, peerId });
6567

6668
this.setState({ authToken: token });
6769
} catch (err) {
@@ -118,6 +120,10 @@ export default class WalletPage extends Component {
118120

119121
<br/>
120122
<h3>Step 3: Generate Leth auth token</h3>
123+
<label>PeerID:
124+
<input type='input' style={{ width: '350px' }} value={this.state.peerId}
125+
onChange={(e) => this.setState({ peerId: e.target.value })}/>
126+
</label>
121127
<textarea value={this.state.authToken} rows="12" cols="50"/>
122128
<br/>
123129
<button onClick={() => this.generateAuthToken()}>Generate</button>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lightstreams-js-sdk",
3-
"version": "0.19.5",
3+
"version": "0.20.0",
44
"description": "Lightstreams JS SDK for building mainstream DApps with support for Programmable Decentralized Private Storage.",
55
"author": "Gabriel Garrido",
66
"contributors": [

src/leth/token.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66

77
const Web3Wrapper = require('../web3');
88

9-
module.exports.generateAuthToken = async (web3, { address, tokenBlocksLifespan }) => {
9+
module.exports.generateAuthToken = async (web3, { address, tokenBlocksLifespan, peerId }) => {
1010
return new Promise(async (resolve, reject) => {
1111
try {
1212
const currentBlock = await Web3Wrapper.getBlockNumber(web3);
1313
const expirationBlock = currentBlock + tokenBlocksLifespan;
1414

1515
const claims = {
16-
blockchain: "ETH",
16+
blockchain: "PHT",
17+
peer_id: peerId,
1718
eth_address: address,
1819
iat: currentBlock,
1920
eat: expirationBlock

0 commit comments

Comments
 (0)