@dimo-network/data-sdk 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -2
- package/dist/api/resources/Attestation/index.js +23 -6
- package/dist/cjs/index.js +23 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +23 -6
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -186,11 +186,58 @@ For path parameters, simply feed in an input that matches with the expected path
|
|
|
186
186
|
```ts
|
|
187
187
|
dimo.attestation.createVinVC({
|
|
188
188
|
...vehicle_jwt,
|
|
189
|
-
tokenId: 117315
|
|
190
|
-
force: false
|
|
189
|
+
tokenId: 117315
|
|
191
190
|
})
|
|
192
191
|
```
|
|
193
192
|
|
|
193
|
+
#### Vehicle JWT
|
|
194
|
+
|
|
195
|
+
As the 2nd leg of the API authentication, applications may exchange for short-lived [Vehicle JWT](https://docs.dimo.org/developer-platform/getting-started/developer-guide/authentication#getting-a-jwt) for specific vehicles that granted permissions to the app. This uses the [DIMO Token Exchange API](https://docs.dimo.org/developer-platform/api-references/dimo-protocol/token-exchange-api/token-exchange-api-endpoints).
|
|
196
|
+
|
|
197
|
+
For the end users of your application, they will need to share their vehicle permissions via the DIMO Mobile App or via your implementation of [Login with DIMO](https://docs.dimo.org/developer-platform/getting-started/developer-guide/login-with-dimo) or even by sharing on the Vehicle NFT directly. Once vehicles are shared, you will be able to get a Vehicle JWT.
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
const vehicle_jwt = await dimo.tokenexchange.exchange({
|
|
201
|
+
...auth,
|
|
202
|
+
privileges: [1, 5],
|
|
203
|
+
tokenId: <vehicle_token_id>
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// Vehicle Status uses privId 1
|
|
207
|
+
await dimo.devicedata.getVehicleStatus({
|
|
208
|
+
...vehicle_jwt,
|
|
209
|
+
tokenId: <vehicle_token_id>
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// VIN Verifiable Credentials uses privId 5
|
|
213
|
+
await dimo.attestation.createVinVC({
|
|
214
|
+
...vehicle_jwt,
|
|
215
|
+
tokenId: <vehicle_token_id>
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// Odometer Statement Verifiable Credentials uses privId 4
|
|
219
|
+
await dimo.attestation.createOdometerStatementVC({
|
|
220
|
+
...vehicle_jwt,
|
|
221
|
+
tokenId: <vehicle_token_id>,
|
|
222
|
+
timestamp: '2023-01-01T00:00:00Z' // Optional timestamp
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// Vehicle Health Verifiable Credentials uses privId 4
|
|
226
|
+
await dimo.attestation.createVehicleHealthVC({
|
|
227
|
+
...vehicle_jwt,
|
|
228
|
+
tokenId: <vehicle_token_id>,
|
|
229
|
+
startTime: '2023-01-01T00:00:00Z',
|
|
230
|
+
endTime: '2023-01-15T00:00:00Z'
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// Vehicle Position Verifiable Credentials uses privId 4
|
|
234
|
+
await dimo.attestation.createVehiclePositionVC({
|
|
235
|
+
...vehicle_jwt,
|
|
236
|
+
tokenId: <vehicle_token_id>,
|
|
237
|
+
timestamp: '2023-01-01T00:00:00Z'
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
194
241
|
### Querying the DIMO GraphQL API
|
|
195
242
|
|
|
196
243
|
The SDK accepts any type of valid custom GraphQL queries, but we've also included a few sample queries to help you understand the DIMO GraphQL APIs. There's also a helper function called `paginate` that you can use to paginate through the GraphQL pages, see `getVehiclePrivileges.ts` on how it's being used.
|
|
@@ -5,16 +5,33 @@ export class Attestation extends Resource {
|
|
|
5
5
|
this.setResource({
|
|
6
6
|
createVinVC: {
|
|
7
7
|
method: 'POST',
|
|
8
|
-
path: '/
|
|
8
|
+
path: '/v2/attestation/vin/:tokenId',
|
|
9
|
+
auth: 'vehicle_jwt'
|
|
10
|
+
},
|
|
11
|
+
createOdometerStatementVC: {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
path: '/v2/attestation/odometer-statement/:tokenId',
|
|
9
14
|
auth: 'vehicle_jwt',
|
|
10
|
-
|
|
11
|
-
'
|
|
15
|
+
body: {
|
|
16
|
+
'timestamp': false // Optional parameter
|
|
12
17
|
}
|
|
13
18
|
},
|
|
14
|
-
|
|
19
|
+
createVehicleHealthVC: {
|
|
15
20
|
method: 'POST',
|
|
16
|
-
path: '/
|
|
17
|
-
auth: 'vehicle_jwt'
|
|
21
|
+
path: '/v2/attestation/vehicle-health/:tokenId',
|
|
22
|
+
auth: 'vehicle_jwt',
|
|
23
|
+
body: {
|
|
24
|
+
'startTime': true, // Required parameter
|
|
25
|
+
'endTime': true // Required parameter
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
createVehiclePositionVC: {
|
|
29
|
+
method: 'POST',
|
|
30
|
+
path: '/v2/attestation/vehicle-position/:tokenId',
|
|
31
|
+
auth: 'vehicle_jwt',
|
|
32
|
+
body: {
|
|
33
|
+
'timestamp': true // Required parameter
|
|
34
|
+
}
|
|
18
35
|
}
|
|
19
36
|
});
|
|
20
37
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -142456,16 +142456,33 @@ class Attestation extends Resource {
|
|
|
142456
142456
|
this.setResource({
|
|
142457
142457
|
createVinVC: {
|
|
142458
142458
|
method: 'POST',
|
|
142459
|
-
path: '/
|
|
142459
|
+
path: '/v2/attestation/vin/:tokenId',
|
|
142460
|
+
auth: 'vehicle_jwt'
|
|
142461
|
+
},
|
|
142462
|
+
createOdometerStatementVC: {
|
|
142463
|
+
method: 'POST',
|
|
142464
|
+
path: '/v2/attestation/odometer-statement/:tokenId',
|
|
142460
142465
|
auth: 'vehicle_jwt',
|
|
142461
|
-
|
|
142462
|
-
'
|
|
142466
|
+
body: {
|
|
142467
|
+
'timestamp': false // Optional parameter
|
|
142463
142468
|
}
|
|
142464
142469
|
},
|
|
142465
|
-
|
|
142470
|
+
createVehicleHealthVC: {
|
|
142466
142471
|
method: 'POST',
|
|
142467
|
-
path: '/
|
|
142468
|
-
auth: 'vehicle_jwt'
|
|
142472
|
+
path: '/v2/attestation/vehicle-health/:tokenId',
|
|
142473
|
+
auth: 'vehicle_jwt',
|
|
142474
|
+
body: {
|
|
142475
|
+
'startTime': true, // Required parameter
|
|
142476
|
+
'endTime': true // Required parameter
|
|
142477
|
+
}
|
|
142478
|
+
},
|
|
142479
|
+
createVehiclePositionVC: {
|
|
142480
|
+
method: 'POST',
|
|
142481
|
+
path: '/v2/attestation/vehicle-position/:tokenId',
|
|
142482
|
+
auth: 'vehicle_jwt',
|
|
142483
|
+
body: {
|
|
142484
|
+
'timestamp': true // Required parameter
|
|
142485
|
+
}
|
|
142469
142486
|
}
|
|
142470
142487
|
});
|
|
142471
142488
|
}
|