|
1 | 1 | ---
|
2 | 2 | title: Getting Started
|
3 |
| -description: DataProtector getting started guide |
| 3 | +description: DataProtector getting started |
4 | 4 | ---
|
5 | 5 |
|
6 | 6 | # Getting Started
|
7 | 7 |
|
8 |
| -This page is under development. |
| 8 | +[](https://www.npmjs.com/package/@iexec/dataprotector) |
9 | 9 |
|
10 |
| -<!-- TODO: Add the getting started guide --> |
| 10 | +## Overview |
| 11 | + |
| 12 | +### Prerequisites |
| 13 | + |
| 14 | +Before getting started, ensure that you have the following installed on your |
| 15 | +system: |
| 16 | + |
| 17 | +\- [**Node.js**](https://nodejs.org/en/) version 18 or higher |
| 18 | + |
| 19 | +\- [**NPM**](https://docs.npmjs.com/) (Node.js package manager) |
| 20 | + |
| 21 | +### Installation |
| 22 | + |
| 23 | +::: code-group |
| 24 | + |
| 25 | +```sh [npm] |
| 26 | +npm install @iexec/dataprotector |
| 27 | +``` |
| 28 | + |
| 29 | +```sh [yarn] |
| 30 | +yarn add @iexec/dataprotector |
| 31 | +``` |
| 32 | + |
| 33 | +```sh [pnpm] |
| 34 | +pnpm add @iexec/dataprotector |
| 35 | +``` |
| 36 | + |
| 37 | +```sh [bun] |
| 38 | +bun add @iexec/dataprotector |
| 39 | +``` |
| 40 | + |
| 41 | +::: |
| 42 | + |
| 43 | +**This package is an ESM package. Your project needs to use ESM too.** |
| 44 | + [**Read more**](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) |
| 45 | + |
| 46 | +If you use it with **Webpack**, some polyfills will be needed. You can find a |
| 47 | +minimal working project |
| 48 | +[here](https://github.com/iExecBlockchainComputing/dataprotector-sdk/tree/115b797cf62dcff0f41e2ba783405d5083d78922/packages/demo/browser-webpack). |
| 49 | + |
| 50 | +### Instantiate SDK |
| 51 | + |
| 52 | +Depending on your project's requirements, you can instantiate the SDK using the |
| 53 | +umbrella module for full functionality or opt for one of the submodules to |
| 54 | +access specific sets of features. |
| 55 | + |
| 56 | +#### Instantiate using the umbrella module |
| 57 | + |
| 58 | +For projects requiring the full functionality of the SDK, including both core |
| 59 | +and sharing functions. |
| 60 | + |
| 61 | +::: code-group |
| 62 | + |
| 63 | +```ts twoslash [Browser] |
| 64 | +declare global { |
| 65 | + interface Window { |
| 66 | + ethereum: any; |
| 67 | + } |
| 68 | +} |
| 69 | +// ---cut--- |
| 70 | +import { IExecDataProtector } from '@iexec/dataprotector'; |
| 71 | + |
| 72 | +const web3Provider = window.ethereum; |
| 73 | +// Instantiate using the umbrella module for full functionality |
| 74 | +const dataProtector = new IExecDataProtector(web3Provider); |
| 75 | + |
| 76 | +const dataProtectorCore = dataProtector.core; |
| 77 | +const dataProtectorSharing = dataProtector.sharing; |
| 78 | +``` |
| 79 | + |
| 80 | +```ts twoslash [NodeJS] |
| 81 | +import { IExecDataProtector, getWeb3Provider } from '@iexec/dataprotector'; |
| 82 | + |
| 83 | +// Get Web3 provider from a private key |
| 84 | +const web3Provider = getWeb3Provider('YOUR_PRIVATE_KEY'); |
| 85 | + |
| 86 | +// Instantiate using the umbrella module for full functionality |
| 87 | +const dataProtector = new IExecDataProtector(web3Provider); |
| 88 | + |
| 89 | +const dataProtectorCore = dataProtector.core; // access to core methods |
| 90 | +const dataProtectorSharing = dataProtector.sharing; // access to methods |
| 91 | +``` |
| 92 | + |
| 93 | +::: |
| 94 | + |
| 95 | +#### Instantiate only the `core` module |
| 96 | + |
| 97 | +For projects focusing solely on core data protection functions. |
| 98 | + |
| 99 | +::: code-group |
| 100 | + |
| 101 | +```ts twoslash [Browser] |
| 102 | +declare global { |
| 103 | + interface Window { |
| 104 | + ethereum: any; |
| 105 | + } |
| 106 | +} |
| 107 | +// ---cut--- |
| 108 | +import { IExecDataProtectorCore } from '@iexec/dataprotector'; |
| 109 | + |
| 110 | +const web3Provider = window.ethereum; |
| 111 | +// Instantiate only the Core module |
| 112 | +const dataProtectorCore = new IExecDataProtectorCore(web3Provider); |
| 113 | +``` |
| 114 | + |
| 115 | +```ts twoslash [NodeJS] |
| 116 | +import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'; |
| 117 | + |
| 118 | +// Get Web3 provider from a private key |
| 119 | +const web3Provider = getWeb3Provider('YOUR_PRIVATE_KEY'); |
| 120 | + |
| 121 | +// Instantiate only the Core module |
| 122 | +const dataProtectorCore = new IExecDataProtectorCore(web3Provider); |
| 123 | +``` |
| 124 | + |
| 125 | +::: |
| 126 | + |
| 127 | +#### Instantiate only the `sharing` module |
| 128 | + |
| 129 | +For projects that need access management functions specifically. |
| 130 | + |
| 131 | +::: code-group |
| 132 | + |
| 133 | +```ts twoslash [Browser] |
| 134 | +declare global { |
| 135 | + interface Window { |
| 136 | + ethereum: any; |
| 137 | + } |
| 138 | +} |
| 139 | +// ---cut--- |
| 140 | +import { IExecDataProtectorSharing } from '@iexec/dataprotector'; |
| 141 | + |
| 142 | +const web3Provider = window.ethereum; |
| 143 | +// Instantiate only the Sharing module |
| 144 | +const dataProtectorSharing = new IExecDataProtectorSharing(web3Provider); |
| 145 | +``` |
| 146 | + |
| 147 | +```ts twoslash [NodeJS] |
| 148 | +import { |
| 149 | + IExecDataProtectorSharing, |
| 150 | + getWeb3Provider, |
| 151 | +} from '@iexec/dataprotector'; |
| 152 | + |
| 153 | +// Get Web3 provider from a private key |
| 154 | +const web3Provider = getWeb3Provider('YOUR_PRIVATE_KEY'); |
| 155 | + |
| 156 | +// Instantiate only the Sharing module |
| 157 | +const dataProtectorSharing = new IExecDataProtectorSharing(web3Provider); |
| 158 | +``` |
| 159 | + |
| 160 | +::: |
| 161 | + |
| 162 | +#### Instantiate without a Web3 provider |
| 163 | + |
| 164 | +For projects that only require read functions, you can instantiate the SDK |
| 165 | +without a Web3 provider. |
| 166 | + |
| 167 | +::: code-group |
| 168 | + |
| 169 | +```ts twoslash [Singleton Modules] |
| 170 | +import { |
| 171 | + IExecDataProtectorSharing, |
| 172 | + IExecDataProtectorCore, |
| 173 | +} from '@iexec/dataprotector'; |
| 174 | + |
| 175 | +// Instantiate only the Core module for read-only core methods |
| 176 | +const dataProtectorCore = new IExecDataProtectorCore(); |
| 177 | +// Instantiate only the Sharing module for read-only sharing methods |
| 178 | +const dataProtectorSharing = new IExecDataProtectorSharing(); |
| 179 | +``` |
| 180 | + |
| 181 | +```ts twoslash [Umbrella Module] |
| 182 | +import { IExecDataProtector } from '@iexec/dataprotector'; |
| 183 | + |
| 184 | +// Instantiate using the umbrella module for read-only functions |
| 185 | +const dataProtector = new IExecDataProtector(); |
| 186 | + |
| 187 | +// Access to read-only core methods |
| 188 | +const dataProtectorCore = dataProtector.core; |
| 189 | +// Access to read-only sharing methods |
| 190 | +const dataProtectorSharing = dataProtector.sharing; |
| 191 | +``` |
| 192 | + |
| 193 | +::: |
| 194 | + |
| 195 | +#### Advanced configuration |
| 196 | + |
| 197 | +To add optional parameters, see |
| 198 | +[advanced configuration](./advanced/advanced-configuration.md). |
| 199 | + |
| 200 | +::: info |
| 201 | + |
| 202 | +🧪 While protected data are processed in **TEE** by **intel SGX** technology by |
| 203 | +default, `@iexec/dataprotector` can be configured to create and process |
| 204 | +protected data in the experimental **intel TDX** environment. |
| 205 | + |
| 206 | +For more details see: |
| 207 | + |
| 208 | +- [configure DataProtector TDX](./advanced/advanced-configuration.md#iexecoptions) |
| 209 | +- [create TDX protected data](./dataProtectorCore/protectData.md#usage) |
| 210 | +- [process TDX protected data](./dataProtectorCore/processProtectedData.md#workerpool) |
| 211 | + |
| 212 | +⚠️ Keep in mind: TDX mode is experimental and can be subject to instabilities or |
| 213 | +discontinuity. |
| 214 | + |
| 215 | +::: |
| 216 | + |
| 217 | +## Sandbox |
| 218 | + |
| 219 | +### Core methods |
| 220 | + |
| 221 | +<a href="https://codesandbox.io/p/github/iExecBlockchainComputing/dataprotector-sandbox/main" target="_blank" rel="noreferrer" class="link-as-block" style="margin-top: 16px"> |
| 222 | + ⚡ Code Sandbox |
| 223 | +</a> |
| 224 | + |
| 225 | +Corresponding GitHub repository: |
| 226 | + |
| 227 | +<a href="https://github.com/iExecBlockchainComputing/dataprotector-sandbox" target="_blank" rel="noreferrer" class="link-as-block"> |
| 228 | + 🔎 GitHub repository sandbox |
| 229 | +</a> |
| 230 | + |
| 231 | +### Sharing methods |
| 232 | + |
| 233 | +<a href="https://codesandbox.io/p/github/iExecBlockchainComputing/dataprotector-sharing-sandbox/main" target="_blank" rel="noreferrer" class="link-as-block" style="margin-top: 16px"> |
| 234 | + ⚡ Code Sandbox |
| 235 | +</a> |
| 236 | + |
| 237 | +Corresponding GitHub repository: |
| 238 | + |
| 239 | +<a href="https://github.com/iExecBlockchainComputing/dataprotector-sharing-sandbox" target="_blank" rel="noreferrer" class="link-as-block"> |
| 240 | + 🔎 GitHub repository sandbox |
| 241 | +</a> |
0 commit comments