Skip to content

Commit

Permalink
v1.0.0.beta is ready : Merge pull request #31 from Itheum/d-mark
Browse files Browse the repository at this point in the history
v1.0.0 beta release : Native Auth Support
  • Loading branch information
newbreedofgeek authored Sep 10, 2023
2 parents 0b05824 + 1a6e907 commit 1e128f1
Show file tree
Hide file tree
Showing 9 changed files with 798 additions and 158 deletions.
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ This SDK is currently focused on interacting with the Itheum's Data NFT technolo

## SDK DOCS

Note that all param requirements and method docs are marked up in the typescript code, so if you use typescript in your project your development tool (e.g. Visual Studio Code) will provide intellisense for all methods and functions.

### 1. Interacting with Data NFTs

```typescript
Expand Down Expand Up @@ -57,15 +59,32 @@ const address = 'address';
const dataNfts = [];
dataNfts = await DataNft.ownedByAddress(address);

// Retrieves the DataNft message from marshal to sign
// Retrieves the specific DataNft
const dataNft = DataNft.createFromApi(nonce);

// (A) Get a message from the Data Marshal node for your to sign to prove ownership
const message = await dataNft.messageToSign();

// Sign the message with a wallet
// (B) Sign the message with a wallet and obtain a signature
const signature = 'signature';

// Unlock the data inside the dataNft
dataNft.viewData(message, signature); // optional params "stream" (stream out data instead of downloading file), "fwdAllHeaders"/"fwdHeaderKeys", "fwdHeaderMapLookup" can be used to pass headers like Authorization to origin servers
// There are 2 methods to open a data NFT and view the content -->

// Method 1) Unlock the data inside the Data NFT via signature verification
dataNft.viewData({
message,
signature
}); // optional params "stream" (stream out data instead of downloading file), "fwdAllHeaders"/"fwdHeaderKeys", "fwdHeaderMapLookup" can be used to pass headers like Authorization to origin Data Stream servers


// Method 2) OR, you can use a MultiversX Native Auth access token to unlock the data inside the Data NFT without the need for the the signature steps above (A)(B). This has a much better UX
dataNft.viewDataViaMVXNativeAuth({
mvxNativeAuthOrigins: "http://localhost:3000", "https://mycoolsite.com"], // same whitelist domains your client app used when generating native auth token
mvxNativeAuthMaxExpirySeconds: 300, // same expiry seconds your client app used when generating native auth token
fwdHeaderMapLookup: {
authorization : "Bearer myNativeAuthToken"
}
}); // optional params "stream" (stream out data instead of downloading file), "fwdAllHeaders"/"fwdHeaderKeys" can be used to pass on the headers like Authorization to origin Data Stream servers
```

### 2. Interacting with Data NFT Minter
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@itheum/sdk-mx-data-nft",
"version": "0.1.1",
"version": "1.0.0.beta.1",
"description": "SDK for Itheum's Data NFT Technology on MultiversX Blockchain",
"main": "out/index.js",
"types": "out/index.d.js",
Expand Down
Loading

0 comments on commit 1e128f1

Please sign in to comment.