|
| 1 | +--- |
| 2 | +title: getGrantedAccess |
| 3 | +description: |
| 4 | + Retrieve all granted access details for a protected data object with iExec's |
| 5 | + getGrantedAccess method. Filter access by user, application, or both, and |
| 6 | + manage access with pagination. |
| 7 | +--- |
| 8 | + |
| 9 | +# getGrantedAccess |
| 10 | + |
| 11 | +This method provides a listing of all access grants given for the specified |
| 12 | +protected data object. Options for filtering include specifying an authorized |
| 13 | +user, an authorized app, or both. |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +The request object is a JSON `GetGrantedAccessParams` object. Each address in |
| 18 | +the object is a string representation of an ethereum address or ENS name |
| 19 | +(Ethereum Name Service) reference. |
| 20 | + |
| 21 | +```ts twoslash |
| 22 | +import { IExecIApp, getWeb3Provider } from '@mage-sombre/iapp'; |
| 23 | + |
| 24 | +const web3Provider = getWeb3Provider('PRIVATE_KEY'); |
| 25 | +const dataProtectorCore = new IExecIApp(web3Provider); |
| 26 | +// ---cut--- |
| 27 | +const listGrantedAccess = await dataProtectorCore.getGrantedAccess({ |
| 28 | + protectedData: '0x123abc...', |
| 29 | + authorizedApp: '0x456def...', |
| 30 | + authorizedUser: '0x789cba...', |
| 31 | + page: 1, |
| 32 | + pageSize: 100, |
| 33 | +}); |
| 34 | +``` |
| 35 | + |
| 36 | +## Parameters |
| 37 | + |
| 38 | +```ts twoslash |
| 39 | +import { type GetGrantedAccessParams } from '@mage-sombre/iapp'; |
| 40 | +``` |
| 41 | + |
| 42 | +### protectedData <OptionalBadge /> |
| 43 | + |
| 44 | +**Type:** `AddressOrENS` |
| 45 | + |
| 46 | +Address of the protected data object for which you are querying access |
| 47 | +authorization grants. It's a representation of ethereum address or ENS name |
| 48 | +(Ethereum Name Service). If no address is specified, it will return all granted |
| 49 | +access for any protected data. |
| 50 | + |
| 51 | +**Usage example:** |
| 52 | + |
| 53 | +```ts twoslash |
| 54 | +import { IExecIApp, getWeb3Provider } from '@mage-sombre/iapp'; |
| 55 | + |
| 56 | +const web3Provider = getWeb3Provider('PRIVATE_KEY'); |
| 57 | +const dataProtectorCore = new IExecIApp(web3Provider); |
| 58 | +// ---cut--- |
| 59 | +const listGrantedAccess = await dataProtectorCore.getGrantedAccess({ |
| 60 | + protectedData: '0x123abc...', // [!code focus] |
| 61 | +}); |
| 62 | +``` |
| 63 | + |
| 64 | +### authorizedApp <OptionalBadge /> |
| 65 | + |
| 66 | +**Type:** `AddressOrENS` |
| 67 | + |
| 68 | +Optional filter to restrict the results to include only authorizations for the |
| 69 | +specified application. It's a representation of ethereum address or ENS name |
| 70 | +(Ethereum Name Service). If no address is specified, it will return all granted |
| 71 | +access for any application. |
| 72 | + |
| 73 | +**Usage example:** |
| 74 | + |
| 75 | +```ts twoslash |
| 76 | +import { IExecIApp, getWeb3Provider } from '@mage-sombre/iapp'; |
| 77 | + |
| 78 | +const web3Provider = getWeb3Provider('PRIVATE_KEY'); |
| 79 | +const dataProtectorCore = new IExecIApp(web3Provider); |
| 80 | +// ---cut--- |
| 81 | +const listGrantedAccess = await dataProtectorCore.getGrantedAccess({ |
| 82 | + authorizedApp: '0x456def...', // [!code focus] |
| 83 | +}); |
| 84 | +``` |
| 85 | + |
| 86 | +::: tip |
| 87 | + |
| 88 | +If you specified an application whitelist when using |
| 89 | +[`grantAccess`](/references/dataProtector/dataProtectorCore/grantAccess), you |
| 90 | +must specify that same whitelist address when using this filtering option. The |
| 91 | +`getGrantedAccess` method does not check against whitelist smart contracts when |
| 92 | +aggregating results. If you granted authorization to a whitelist but specify an |
| 93 | +application address for the `authorizedApp` parameter, you will not receive any |
| 94 | +results unless you _also_ explicitly granted access to that application address. |
| 95 | + |
| 96 | +::: |
| 97 | + |
| 98 | +### authorizedUser <OptionalBadge /> |
| 99 | + |
| 100 | +**Type:** `AddressOrENS` |
| 101 | + |
| 102 | +Optional filter to restrict the results to include only authorizations for the |
| 103 | +specified user. It's a string representation of ethereum address or ENS name |
| 104 | +(Ethereum Name Service). If no address is specified, it will return all granted |
| 105 | +access for any user. |
| 106 | + |
| 107 | +**Usage example:** |
| 108 | + |
| 109 | +```ts twoslash |
| 110 | +import { IExecIApp, getWeb3Provider } from '@mage-sombre/iapp'; |
| 111 | + |
| 112 | +const web3Provider = getWeb3Provider('PRIVATE_KEY'); |
| 113 | +const dataProtectorCore = new IExecIApp(web3Provider); |
| 114 | +// ---cut--- |
| 115 | +const listGrantedAccess = await dataProtectorCore.getGrantedAccess({ |
| 116 | + authorizedUser: '0x789cba...', // [!code focus] |
| 117 | +}); |
| 118 | +``` |
| 119 | + |
| 120 | +### isUserStrict <OptionalBadge /> |
| 121 | + |
| 122 | +**Type:** `boolean` |
| 123 | +**Default:** `false` |
| 124 | + |
| 125 | +Optional filter to restrict the results to include only authorizations for the |
| 126 | +specified user. Authorizations made for `any` user are not returned. |
| 127 | + |
| 128 | +```ts twoslash |
| 129 | +import { IExecIApp, getWeb3Provider } from '@mage-sombre/iapp'; |
| 130 | + |
| 131 | +const web3Provider = getWeb3Provider('PRIVATE_KEY'); |
| 132 | +const dataProtectorCore = new IExecIApp(web3Provider); |
| 133 | +// ---cut--- |
| 134 | + |
| 135 | +const listGrantedAccess = await dataProtectorCore.getGrantedAccess({ |
| 136 | + protectedData: '0x123abc...', |
| 137 | + authorizedApp: '0x456def...', |
| 138 | + authorizedUser: '0x789cba...', |
| 139 | + isUserStrict: true, // [!code focus] |
| 140 | +}); |
| 141 | +``` |
| 142 | + |
| 143 | +### page <OptionalBadge /> |
| 144 | + |
| 145 | +**Type:** `number` |
| 146 | +**Default:** `0` |
| 147 | + |
| 148 | +Specifies the page number of the result set to return. Pages are zero-based |
| 149 | +indexed, with the default value being `0`, indicating the first page. If used, |
| 150 | +you can also specify the `pageSize` parameter to control the number of records |
| 151 | +per page. By default, when no page number is specified, the system returns the |
| 152 | +first page (page 0) containing `20` elements. |
| 153 | + |
| 154 | +**Usage example:** |
| 155 | + |
| 156 | +```ts twoslash |
| 157 | +import { IExecIApp, getWeb3Provider } from '@mage-sombre/iapp'; |
| 158 | + |
| 159 | +const web3Provider = getWeb3Provider('PRIVATE_KEY'); |
| 160 | +const dataProtectorCore = new IExecIApp(web3Provider); |
| 161 | +// ---cut--- |
| 162 | +const listGrantedAccess = await dataProtectorCore.getGrantedAccess({ |
| 163 | + protectedData: '0x123abc...', |
| 164 | + page: 1, // [!code focus] |
| 165 | + pageSize: 100, |
| 166 | +}); |
| 167 | +``` |
| 168 | + |
| 169 | +### pageSize <OptionalBadge /> |
| 170 | + |
| 171 | +**Type:** `number` |
| 172 | +**Default:** `20` |
| 173 | +**Range:** `[10...1000]` |
| 174 | + |
| 175 | +Specifies the number of records to include in each page of the result set. This |
| 176 | +is used in conjunction with the optional `page` parameter to limit the size of |
| 177 | +each page. |
| 178 | + |
| 179 | +**Usage example:** |
| 180 | + |
| 181 | +```ts twoslash |
| 182 | +import { IExecIApp, getWeb3Provider } from '@mage-sombre/iapp'; |
| 183 | + |
| 184 | +const web3Provider = getWeb3Provider('PRIVATE_KEY'); |
| 185 | +const dataProtectorCore = new IExecIApp(web3Provider); |
| 186 | +// ---cut--- |
| 187 | +const listGrantedAccess = await dataProtectorCore.getGrantedAccess({ |
| 188 | + protectedData: '0x123abc...', |
| 189 | + page: 1, |
| 190 | + pageSize: 100, // [!code focus] |
| 191 | +}); |
| 192 | +``` |
| 193 | + |
| 194 | +## Return Value |
| 195 | + |
| 196 | +```ts twoslash |
| 197 | +import { type GrantedAccessResponse } from '@mage-sombre/iapp'; |
| 198 | +``` |
| 199 | + |
| 200 | +The return value for this method has two fields: a `count` parameter indicating |
| 201 | +the number of results, and an array of `GrantedAccess` objects containing all |
| 202 | +access data. When using the optional paging parameters, the `count` will be |
| 203 | +limited by the selected `pageSize` parameter. You may use these result objects |
| 204 | +in conjunction with the [revokeOneAccess](revokeOneAccess.md) method to revoke a |
| 205 | +previously granted authorization for access. |
| 206 | + |
| 207 | +### count |
| 208 | + |
| 209 | +**Type:** `number` |
| 210 | + |
| 211 | +An integer value indicating the number of results returned by this method. This |
| 212 | +is of particular note when using paging as the number of records returned may be |
| 213 | +smaller than the page size. |
| 214 | + |
| 215 | +### grantedAccess |
| 216 | + |
| 217 | +**Type:** GrantedAccess |
| 218 | + |
| 219 | +See [`GrantedAccess`](/references/iapp-generator/sdk/types#grantedaccess) |
| 220 | + |
| 221 | +<script setup> |
| 222 | +import OptionalBadge from '@/components/OptionalBadge.vue' |
| 223 | +</script> |
0 commit comments