@dimo-network/data-sdk 1.3.1 → 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.
Files changed (47) hide show
  1. package/README.md +49 -2
  2. package/dist/api/resources/Attestation/index.js +23 -6
  3. package/dist/{index.cjs → cjs/index.js} +1292 -3069
  4. package/dist/cjs/index.js.map +1 -0
  5. package/dist/esm/index.js +142714 -0
  6. package/dist/esm/index.js.map +1 -0
  7. package/dist/types/api/Method.d.ts +2 -0
  8. package/dist/types/api/Method.test.d.ts +1 -0
  9. package/dist/types/api/Resource.d.ts +11 -0
  10. package/dist/types/api/functions/getDeveloperJwt.d.ts +7 -0
  11. package/dist/types/api/functions/getVehicleJwt.d.ts +7 -0
  12. package/dist/types/api/functions/index.d.ts +4 -0
  13. package/dist/types/api/functions/signChallenge.d.ts +5 -0
  14. package/dist/types/api/index.d.ts +1 -0
  15. package/dist/types/api/resources/Attestation/index.d.ts +5 -0
  16. package/dist/types/api/resources/Auth/index.d.ts +5 -0
  17. package/dist/types/api/resources/DeviceDefinitions/index.d.ts +5 -0
  18. package/dist/types/api/resources/Devices/index.d.ts +5 -0
  19. package/dist/types/api/resources/DimoRestResources.d.ts +10 -0
  20. package/dist/types/api/resources/TokenExchange/index.d.ts +5 -0
  21. package/dist/types/api/resources/Trips/index.d.ts +5 -0
  22. package/dist/types/api/resources/Valuations/index.d.ts +5 -0
  23. package/dist/types/api/resources/VehicleEvents/index.d.ts +7 -0
  24. package/dist/types/api/types/Endpoint.d.ts +11 -0
  25. package/dist/types/constants.d.ts +14 -0
  26. package/dist/types/dimo.d.ts +18 -0
  27. package/dist/types/dimo.test.d.ts +1 -0
  28. package/dist/types/environments/index.d.ts +30 -0
  29. package/dist/types/errors/DimoError.d.ts +9 -0
  30. package/dist/types/errors/index.d.ts +1 -0
  31. package/dist/types/graphql/Query.d.ts +3 -0
  32. package/dist/types/graphql/Query.test.d.ts +1 -0
  33. package/dist/types/graphql/Resource.d.ts +16 -0
  34. package/dist/types/graphql/functions/getVehiclePrivileges.d.ts +6 -0
  35. package/dist/types/graphql/functions/getVin.d.ts +5 -0
  36. package/dist/types/graphql/functions/index.d.ts +3 -0
  37. package/dist/types/graphql/index.d.ts +1 -0
  38. package/dist/types/graphql/resources/DimoGraphqlResources.d.ts +3 -0
  39. package/dist/types/graphql/resources/Identity/index.d.ts +5 -0
  40. package/dist/types/graphql/resources/Telemetry/index.d.ts +5 -0
  41. package/dist/types/graphql/util/paginate.d.ts +9 -0
  42. package/dist/types/index.d.ts +18 -0
  43. package/dist/types/util/decodeJwt.d.ts +1 -0
  44. package/dist/types/util/decodePermissions.d.ts +1 -0
  45. package/dist/types/util/index.d.ts +8 -0
  46. package/package.json +14 -9
  47. package/rollup.config.js +33 -9
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: '/v1/vc/vin/:tokenId',
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
- queryParams: {
11
- 'force': false
15
+ body: {
16
+ 'timestamp': false // Optional parameter
12
17
  }
13
18
  },
14
- createPomVC: {
19
+ createVehicleHealthVC: {
15
20
  method: 'POST',
16
- path: '/v1/vc/pom/:tokenId',
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
  }