@dimo-network/data-sdk 1.2.4 → 1.3.0
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.jp.md +86 -0
- package/README.md +6 -4
- package/README.zh-tw.md +86 -0
- package/dist/api/Resource.d.ts +10 -10
- package/dist/api/Resource.js +4 -7
- package/dist/api/resources/DimoRestResources.d.ts +10 -8
- package/dist/api/resources/DimoRestResources.js +10 -8
- package/dist/api/resources/VehicleEvents/index.d.ts +7 -0
- package/dist/api/resources/VehicleEvents/index.js +85 -0
- package/dist/api/types/Endpoint.d.ts +11 -0
- package/dist/api/types/Endpoint.js +2 -0
- package/dist/dimo.d.ts +5 -3
- package/dist/dimo.js +17 -12
- package/dist/environments/index.d.ts +3 -0
- package/dist/environments/index.js +24 -21
- package/dist/index.cjs +124 -34
- package/jest.config.js +17 -14
- package/package.json +2 -2
- package/dist/streamr/index.d.ts +0 -0
- package/dist/streamr/index.js +0 -51
package/README.jp.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+

|
|
4
|
+
[](https://www.npmjs.com/package/@dimo-network/data-sdk)
|
|
5
|
+
[](https://chat.dimo.zone/)
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
# DIMO(智猛)Data SDK
|
|
9
|
+
## 概要
|
|
10
|
+
DIMO Data SDK は、TypeScript で構築された公式ライブラリであり、DIMO API を簡単かつ効率的に利用できるように設計されています。この SDK は、開発者が DIMO プラットフォームと統合する際の複雑さを軽減し、迅速な開発を可能にします。API 呼び出しの抽象化、データ操作の簡素化、そして堅牢な型安全性を提供することで、開発者体験を向上させます。
|
|
11
|
+
|
|
12
|
+
## インストール
|
|
13
|
+
|
|
14
|
+
[npm](https://www.npmjs.com/package/@dimo-network/data-sdk) を使用する場合:
|
|
15
|
+
```bash
|
|
16
|
+
npm install @dimo-network/data-sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
[yarn](https://classic.yarnpkg.com/en/package/@dimo-network/data-sdk) を使用する場合:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
yarn add @dimo-network/data-sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 単体テスト
|
|
26
|
+
`npm test` または `npm run test` を実行して、Jest テストを実行します。
|
|
27
|
+
|
|
28
|
+
## API ドキュメント
|
|
29
|
+
DIMO での開発や API に関する詳細情報については、DIMO の [開発者向けドキュメント](https://docs.dimo.org/developer-platform) をご覧ください。
|
|
30
|
+
|
|
31
|
+
## SDK の使用方法
|
|
32
|
+
### SDK ライブラリ
|
|
33
|
+
|
|
34
|
+
(TypeScript / ES Modules)
|
|
35
|
+
```ts
|
|
36
|
+
import { DIMO } from '@dimo-network/data-sdk';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
(CommonJS)
|
|
40
|
+
```js
|
|
41
|
+
const { DIMO } = require('@dimo-network/data-sdk')
|
|
42
|
+
```
|
|
43
|
+
### SDK 初期化
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
const dimo = new DIMO('Production');
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 開発者登録
|
|
50
|
+
認証プロセスの一環として、[DIMO 開発者コンソール](https://console.dimo.org/) を通じて開発者ライセンスを取得する必要があります。登録を開始するには、以下の手順に従ってください:
|
|
51
|
+
1. [DIMO 開発者コンソール](https://console.dimo.org/) にサインアップします。
|
|
52
|
+
2. 「ライセンスを作成」(Create a License) をクリックし、ライセンスに関する詳細を入力します。
|
|
53
|
+
3. API キー(API Key)を生成し、希望するリダイレクト URI(RedirectURI)を追加します。
|
|
54
|
+
|
|
55
|
+
### 開発者認証
|
|
56
|
+
本 SDK は、「開発者用 JWT を取得するための[認証フロー](https://docs.dimo.org/developer-platform/getting-started/developer-guide/authentication) に必要なすべての手順」と、「アプリと共有された各車両に対して Vehicle JWT を取得するための手順」を提供します。
|
|
57
|
+
|
|
58
|
+
#### 認証の前提条件
|
|
59
|
+
1. 開発者ライセンス
|
|
60
|
+
2. API キー、リダイレクト URI(RedirectURI)
|
|
61
|
+
3. 適切な [TypeScript を使用したプロジェクトのセットアップ](https://nodejs.keicode.com/typescript/create-ts-project.php)。
|
|
62
|
+
|
|
63
|
+
#### 開発者 JWT
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const developerJwt = await dimo.auth.getDeveloperJwt({
|
|
67
|
+
client_id: '<client_id>',
|
|
68
|
+
domain: '<domain/redirect_uri>',
|
|
69
|
+
private_key: '<api_key>',
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### 車両 JWT
|
|
74
|
+
消費者から車両データを取得するには、アプリケーションが短期間有効な [車両 JWT](https://docs.dimo.org/developer-platform/getting-started/developer-guide/authentication#getting-a-jwt) を交換する必要があります。この 車両 JWT は、アプリに権限を付与した車両に対して取得されます。
|
|
75
|
+
|
|
76
|
+
消費者は事前に車両の権限を共有する必要があります。そのためには、[Login with DIMO](https://docs.dimo.org/developer-platform/getting-started/developer-guide/login-with-dimo) や DIMO Mobile のような実装が必要です。この手順が完了すると、車両データを取得できるようになります。
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const vehicleJwt = await dimo.tokenexchange.getVehicleJwt({
|
|
80
|
+
...developerJwt,
|
|
81
|
+
tokenId: 117315
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## SDK への貢献方法
|
|
86
|
+
SDK への貢献についての詳細は、[こちら](https://github.com/DIMO-Network/data-sdk/blob/master/CONTRIBUTING.md)をご覧ください。
|
package/README.md
CHANGED
|
@@ -49,14 +49,16 @@ const dimo = new DIMO('Production');
|
|
|
49
49
|
### Developer Registration
|
|
50
50
|
As part of the authentication process, you will need to obtain a Developer License via the [DIMO Developer Console](https://console.dimo.org/). To get started with registration, follow the steps below:
|
|
51
51
|
1. Sign up on the [DIMO Developer Console](https://console.dimo.org/).
|
|
52
|
-
2.
|
|
53
|
-
3.
|
|
54
|
-
4. Generate an API key and add in your preferred redirect URI.
|
|
52
|
+
2. Click on `Create a license` and fill out the details about your license.
|
|
53
|
+
3. Generate an API key and add in your preferred redirect URI.
|
|
55
54
|
|
|
56
55
|
### Authentication
|
|
57
56
|
|
|
58
57
|
The SDK provides you with all the steps needed in the [Authentication Flow](https://docs.dimo.org/developer-platform/getting-started/developer-guide/authentication) to obtain a Developer JWT & to get Vehicle JWT for each vehicle shared with your app.
|
|
59
58
|
|
|
59
|
+
#### Prerequisites for Authentication
|
|
60
|
+
1. A valid Developer License with a `client_id`
|
|
61
|
+
2. A valid API key, generated via the Developer Console
|
|
60
62
|
3. A proper [project set up with TypeScript](https://www.digitalocean.com/community/tutorials/setting-up-a-node-project-with-typescript).
|
|
61
63
|
|
|
62
64
|
#### Developer JWT
|
|
@@ -198,7 +200,7 @@ The GraphQL entry points are designed almost identical to the REST API entry poi
|
|
|
198
200
|
|
|
199
201
|
```ts
|
|
200
202
|
const vehicleJwt = await dimo.tokenexchange.exchange({
|
|
201
|
-
...
|
|
203
|
+
...developerJwt,
|
|
202
204
|
privileges: [1, 3, 4],
|
|
203
205
|
tokenId: <vehicle_token_id>
|
|
204
206
|
});
|
package/README.zh-tw.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+

|
|
4
|
+
[](https://www.npmjs.com/package/@dimo-network/data-sdk)
|
|
5
|
+
[](https://chat.dimo.zone/)
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
# DIMO(智猛)Data SDK
|
|
9
|
+
## 概述
|
|
10
|
+
DIMO Data SDK 是一個以 TypeScript 構建的官方函式庫,旨在讓開發者能夠簡單且高效地使用 DIMO API。此 SDK 減少了開發者在整合 DIMO 平台時的複雜性,並加速開發過程。透過 API 調用的抽象化、簡化數據操作以及提供強大的型別安全性,提升了開發者的使用體驗。
|
|
11
|
+
|
|
12
|
+
## 安裝
|
|
13
|
+
|
|
14
|
+
使用 [npm](https://www.npmjs.com/package/@dimo-network/data-sdk):
|
|
15
|
+
```bash
|
|
16
|
+
npm install @dimo-network/data-sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
使用 [yarn](https://classic.yarnpkg.com/en/package/@dimo-network/data-sdk):
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
yarn add @dimo-network/data-sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 單元測試
|
|
26
|
+
執行 `npm test` 或 `npm run test` 來運行 Jest 測試。
|
|
27
|
+
|
|
28
|
+
## API 文件
|
|
29
|
+
有關 DIMO 開發或 API 的詳細資訊,請參閱 DIMO 的 [開發者文件](https://docs.dimo.org/developer-platform)。
|
|
30
|
+
|
|
31
|
+
## SDK 使用方法
|
|
32
|
+
### 訪問函式庫
|
|
33
|
+
|
|
34
|
+
(TypeScript / ES Modules)
|
|
35
|
+
```ts
|
|
36
|
+
import { DIMO } from '@dimo-network/data-sdk';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
(CommonJS)
|
|
40
|
+
```js
|
|
41
|
+
const { DIMO } = require('@dimo-network/data-sdk')
|
|
42
|
+
```
|
|
43
|
+
### SDK 初始化
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
const dimo = new DIMO('Production');
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 開發者註冊
|
|
50
|
+
作為認證流程的一部分,您需要先通過 [DIMO Developer Console](https://console.dimo.org/) 獲取開發者授權身份。請按照以下步驟開始註冊:
|
|
51
|
+
1. 造訪 [DIMO 開發者主控台](https://console.dimo.org/) 並註冊帳號。
|
|
52
|
+
2. 點擊「創建執照」(Create a License),並輸入您的相關執照詳細資訊。
|
|
53
|
+
3. 生成 API 金鑰(API Key),並新增所需的統一資源識別碼(Redirect URI)。
|
|
54
|
+
|
|
55
|
+
### 開發者認證
|
|
56
|
+
SDK 提供了[認證流程](https://docs.dimo.org/developer-platform/getting-started/developer-guide/authentication) 所需的所有步驟,幫助您獲取「開發者 JWT」(Developer JWT)以及每輛與應用程式共享的車輛所使用的「車輛 JWT」(Vehicle JWT)。
|
|
57
|
+
|
|
58
|
+
#### 認證的前置條件
|
|
59
|
+
1. 開發者執照
|
|
60
|
+
2. API 金鑰以及至少一組自訂的統一資源識別碼(Redirect URI)
|
|
61
|
+
3. 適當的 [TypeScript 環境設置](https://learn.microsoft.com/zh-tw/visualstudio/javascript/compile-typescript-code-npm?view=vs-2022)。
|
|
62
|
+
|
|
63
|
+
#### 開發者 JWT
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const developerJwt = await dimo.auth.getDeveloperJwt({
|
|
67
|
+
client_id: '<client_id>',
|
|
68
|
+
domain: '<domain/redirect_uri>',
|
|
69
|
+
private_key: '<api_key>',
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### 車輛 JWT
|
|
74
|
+
若要從消費者處獲取車輛數據,應用程式需要交換短期有效的 [車輛 JWT](https://docs.dimo.org/developer-platform/getting-started/developer-guide/authentication#getting-a-jwt)。此車輛 JWT 是針對授權應用程式的車輛生成的。
|
|
75
|
+
|
|
76
|
+
消費者需要事先與您的應用程式共享車輛授權。為此,您可以透過前端整合 [Login with DIMO](https://docs.dimo.org/developer-platform/getting-started/developer-guide/login-with-dimo) 或開發出類似 DIMO Mobile 全端的功能。完成「分享」此步驟後,您將能夠自由獲取車輛數據。
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const vehicleJwt = await dimo.tokenexchange.getVehicleJwt({
|
|
80
|
+
...developerJwt,
|
|
81
|
+
tokenId: 117315
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## SDK 貢獻
|
|
86
|
+
有關如何貢獻於此 SDK 的詳細資訊,請參閱[此處](https://github.com/DIMO-Network/data-sdk/blob/master/CONTRIBUTING.md)。
|
package/dist/api/Resource.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
api:
|
|
7
|
-
resourceName:
|
|
8
|
-
env:
|
|
9
|
-
constructor(api:
|
|
10
|
-
protected setResource(resources:
|
|
1
|
+
/** @format */
|
|
2
|
+
import { DimoEnvironment } from "../environments";
|
|
3
|
+
import { ResourceMap } from "./types/Endpoint";
|
|
4
|
+
export declare class Resource<TApi = string> {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
api: TApi;
|
|
7
|
+
resourceName: string;
|
|
8
|
+
env: keyof typeof DimoEnvironment;
|
|
9
|
+
constructor(api: TApi, resourceName: string, env: keyof typeof DimoEnvironment);
|
|
10
|
+
protected setResource<T extends ResourceMap>(resources: T): void;
|
|
11
11
|
}
|
package/dist/api/Resource.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/** @format */
|
|
2
|
+
import { Method } from "./Method";
|
|
2
3
|
export class Resource {
|
|
3
4
|
api;
|
|
4
5
|
resourceName;
|
|
@@ -9,12 +10,8 @@ export class Resource {
|
|
|
9
10
|
this.env = env;
|
|
10
11
|
}
|
|
11
12
|
setResource(resources) {
|
|
12
|
-
Object.keys(resources).forEach(key => {
|
|
13
|
-
this[key] = (params = {}) => Method(resources[key],
|
|
14
|
-
this.api, // Setup the base URL
|
|
15
|
-
params, // Pass through the params
|
|
16
|
-
this.env // Identiy the environment
|
|
17
|
-
);
|
|
13
|
+
Object.keys(resources).forEach((key) => {
|
|
14
|
+
this[key] = (params = {}) => Method(resources[key], this.api, params, this.env);
|
|
18
15
|
});
|
|
19
16
|
}
|
|
20
17
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
1
|
+
/** @format */
|
|
2
|
+
import { Attestation } from "./Attestation";
|
|
3
|
+
import { Auth } from "./Auth";
|
|
4
|
+
import { DeviceDefinitions } from "./DeviceDefinitions";
|
|
5
|
+
import { Devices } from "./Devices";
|
|
6
|
+
import { TokenExchange } from "./TokenExchange";
|
|
7
|
+
import { Trips } from "./Trips";
|
|
8
|
+
import { Valuations } from "./Valuations";
|
|
9
|
+
import { VehicleEvents } from "./VehicleEvents";
|
|
10
|
+
export { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleEvents, };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
1
|
+
/** @format */
|
|
2
|
+
import { Attestation } from "./Attestation";
|
|
3
|
+
import { Auth } from "./Auth";
|
|
4
|
+
import { DeviceDefinitions } from "./DeviceDefinitions";
|
|
5
|
+
import { Devices } from "./Devices";
|
|
6
|
+
import { TokenExchange } from "./TokenExchange";
|
|
7
|
+
import { Trips } from "./Trips";
|
|
8
|
+
import { Valuations } from "./Valuations";
|
|
9
|
+
import { VehicleEvents } from "./VehicleEvents";
|
|
10
|
+
export { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleEvents, };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
import { Resource } from "api/Resource";
|
|
3
|
+
class VehicleEvents extends Resource {
|
|
4
|
+
constructor(api, env) {
|
|
5
|
+
super(api, "VehicleEvents", env);
|
|
6
|
+
this.setResource({
|
|
7
|
+
listWebhooks: {
|
|
8
|
+
method: "GET",
|
|
9
|
+
path: "/v1/webhooks",
|
|
10
|
+
auth: "developer_jwt",
|
|
11
|
+
},
|
|
12
|
+
createWebhook: {
|
|
13
|
+
method: "POST",
|
|
14
|
+
path: "/v1/webhooks",
|
|
15
|
+
body: {
|
|
16
|
+
service: true,
|
|
17
|
+
data: true,
|
|
18
|
+
trigger: true,
|
|
19
|
+
setup: true,
|
|
20
|
+
description: false,
|
|
21
|
+
target_uri: true,
|
|
22
|
+
status: true,
|
|
23
|
+
verification_token: true,
|
|
24
|
+
},
|
|
25
|
+
auth: "developer_jwt",
|
|
26
|
+
},
|
|
27
|
+
updateWebhook: {
|
|
28
|
+
method: "PUT",
|
|
29
|
+
path: "/v1/webhooks/:webhookId",
|
|
30
|
+
body: {
|
|
31
|
+
service: true,
|
|
32
|
+
data: true,
|
|
33
|
+
trigger: true,
|
|
34
|
+
setup: true,
|
|
35
|
+
description: false,
|
|
36
|
+
target_uri: true,
|
|
37
|
+
status: true,
|
|
38
|
+
verification_token: true,
|
|
39
|
+
},
|
|
40
|
+
auth: "developer_jwt",
|
|
41
|
+
},
|
|
42
|
+
deleteWebhook: {
|
|
43
|
+
method: "DELETE",
|
|
44
|
+
path: "/v1/webhooks/:webhookId",
|
|
45
|
+
auth: "developer_jwt",
|
|
46
|
+
},
|
|
47
|
+
getWebhookSignalNames: {
|
|
48
|
+
method: "GET",
|
|
49
|
+
path: "/v1/webhooks/signals",
|
|
50
|
+
auth: "developer_jwt",
|
|
51
|
+
},
|
|
52
|
+
listSubscribedVehicles: {
|
|
53
|
+
method: "GET",
|
|
54
|
+
path: "/v1/webhooks/:webhookId",
|
|
55
|
+
auth: "developer_jwt",
|
|
56
|
+
},
|
|
57
|
+
listVehicleSubscriptions: {
|
|
58
|
+
method: "GET",
|
|
59
|
+
path: "/v1/webhooks/vehicles/:tokenId",
|
|
60
|
+
auth: "developer_jwt",
|
|
61
|
+
},
|
|
62
|
+
subscribeVehicle: {
|
|
63
|
+
method: "POST",
|
|
64
|
+
path: "/v1/webhooks/:webhookId/subscribe/:tokenId",
|
|
65
|
+
auth: "developer_jwt",
|
|
66
|
+
},
|
|
67
|
+
subscribeAllVehicles: {
|
|
68
|
+
method: "POST",
|
|
69
|
+
path: "/v1/webhooks/:webhookId/subscribe/all",
|
|
70
|
+
auth: "developer_jwt",
|
|
71
|
+
},
|
|
72
|
+
unsubscribeVehicle: {
|
|
73
|
+
method: "DELETE",
|
|
74
|
+
path: "/v1/webhooks/:webhookId/unsubscribe/:tokenId",
|
|
75
|
+
auth: "developer_jwt",
|
|
76
|
+
},
|
|
77
|
+
unsubscribeAllVehicles: {
|
|
78
|
+
method: "DELETE",
|
|
79
|
+
path: "/v1/webhooks/:webhookId/unsubscribe/all",
|
|
80
|
+
auth: "developer_jwt",
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export { VehicleEvents };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
export type EndpointDefinition = {
|
|
3
|
+
method: "GET" | "POST" | "PUT" | "DELETE" | "FUNCTION";
|
|
4
|
+
path: string;
|
|
5
|
+
auth?: "developer_jwt" | "vehicle_jwt";
|
|
6
|
+
body?: Record<string, boolean | string | number>;
|
|
7
|
+
queryParams?: Record<string, boolean | string | number>;
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
return?: string;
|
|
10
|
+
};
|
|
11
|
+
export type ResourceMap = Record<string, EndpointDefinition>;
|
package/dist/dimo.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
/** @format */
|
|
2
|
+
import { DimoEnvironment } from "./environments";
|
|
3
|
+
import { Identity, Telemetry } from "./graphql/resources/DimoGraphqlResources";
|
|
4
|
+
import { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleEvents } from "./api/resources/DimoRestResources";
|
|
4
5
|
export declare class DIMO {
|
|
5
6
|
attestation: Attestation;
|
|
6
7
|
auth: Auth;
|
|
@@ -11,6 +12,7 @@ export declare class DIMO {
|
|
|
11
12
|
tokenexchange: TokenExchange;
|
|
12
13
|
trips: Trips;
|
|
13
14
|
valuations: Valuations;
|
|
15
|
+
vehicleEvents: VehicleEvents;
|
|
14
16
|
constructor(env: keyof typeof DimoEnvironment);
|
|
15
17
|
authenticate(): Promise<any>;
|
|
16
18
|
}
|
package/dist/dimo.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
/** @format */
|
|
2
|
+
import { DimoEnvironment } from "./environments";
|
|
3
|
+
import { DimoError } from "./errors";
|
|
4
|
+
import { Identity, Telemetry } from "./graphql/resources/DimoGraphqlResources";
|
|
5
|
+
import { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleEvents, } from "./api/resources/DimoRestResources";
|
|
5
6
|
// import { Stream } from './streamr';
|
|
6
7
|
export class DIMO {
|
|
7
8
|
attestation;
|
|
@@ -13,6 +14,7 @@ export class DIMO {
|
|
|
13
14
|
tokenexchange;
|
|
14
15
|
trips;
|
|
15
16
|
valuations;
|
|
17
|
+
vehicleEvents;
|
|
16
18
|
constructor(env) {
|
|
17
19
|
this.identity = new Identity(DimoEnvironment[env].Identity, env);
|
|
18
20
|
this.telemetry = new Telemetry(DimoEnvironment[env].Telemetry, env);
|
|
@@ -26,26 +28,29 @@ export class DIMO {
|
|
|
26
28
|
this.tokenexchange = new TokenExchange(DimoEnvironment[env].TokenExchange, env);
|
|
27
29
|
this.trips = new Trips(DimoEnvironment[env].Trips, env);
|
|
28
30
|
this.valuations = new Valuations(DimoEnvironment[env].Valuations, env);
|
|
31
|
+
this.vehicleEvents = new VehicleEvents(DimoEnvironment[env].VehicleEvents, env);
|
|
29
32
|
}
|
|
30
33
|
// Helper Function
|
|
31
34
|
async authenticate() {
|
|
32
35
|
let fs;
|
|
33
36
|
try {
|
|
34
37
|
// Dynamically import fs
|
|
35
|
-
if (typeof process !==
|
|
36
|
-
|
|
38
|
+
if (typeof process !== "undefined" &&
|
|
39
|
+
process.versions &&
|
|
40
|
+
process.versions.node) {
|
|
41
|
+
fs = await import("fs");
|
|
37
42
|
}
|
|
38
43
|
else {
|
|
39
44
|
// Optionally handle the case where 'fs' is not available, returns null
|
|
40
|
-
console.log(
|
|
45
|
+
console.log("Not in Node.js environment; `fs` module is not available.");
|
|
41
46
|
return null;
|
|
42
47
|
}
|
|
43
|
-
if (!fs.existsSync(
|
|
48
|
+
if (!fs.existsSync(".credentials.json")) {
|
|
44
49
|
throw new DimoError({
|
|
45
|
-
message:
|
|
50
|
+
message: "Credentials file does not exist",
|
|
46
51
|
});
|
|
47
52
|
}
|
|
48
|
-
const data = fs.readFileSync(
|
|
53
|
+
const data = fs.readFileSync(".credentials.json", "utf8");
|
|
49
54
|
const credentials = JSON.parse(data);
|
|
50
55
|
const authHeader = await this.auth.getDeveloperJwt({
|
|
51
56
|
client_id: credentials.client_id,
|
|
@@ -56,10 +61,10 @@ export class DIMO {
|
|
|
56
61
|
}
|
|
57
62
|
catch (error) {
|
|
58
63
|
// Handle file not existing and other errors
|
|
59
|
-
console.error(
|
|
64
|
+
console.error("Failed to authenticate:", error.message);
|
|
60
65
|
// Decide whether to throw the error or handle it differently
|
|
61
66
|
throw new DimoError({
|
|
62
|
-
message:
|
|
67
|
+
message: "Authentication failed",
|
|
63
68
|
});
|
|
64
69
|
}
|
|
65
70
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @format */
|
|
1
2
|
export declare const DimoEnvironment: {
|
|
2
3
|
readonly Production: {
|
|
3
4
|
readonly Attestation: "https://attestation-api.dimo.zone";
|
|
@@ -10,6 +11,7 @@ export declare const DimoEnvironment: {
|
|
|
10
11
|
readonly Trips: "https://trips-api.dimo.zone";
|
|
11
12
|
readonly Valuations: "https://valuations-api.dimo.zone";
|
|
12
13
|
readonly VehicleSignalDecoding: "https://vehicle-signal-decoding.dimo.zone";
|
|
14
|
+
readonly VehicleEvents: "https://vehicle-events-api.dimo.zone";
|
|
13
15
|
};
|
|
14
16
|
readonly Dev: {
|
|
15
17
|
readonly Attestation: "https://attestation-api.dev.dimo.zone";
|
|
@@ -22,6 +24,7 @@ export declare const DimoEnvironment: {
|
|
|
22
24
|
readonly Trips: "https://trips-api.dev.dimo.zone";
|
|
23
25
|
readonly Valuations: "https://valuations-api.dev.dimo.zone";
|
|
24
26
|
readonly VehicleSignalDecoding: "https://vehicle-signal-decoding.dev.dimo.zone";
|
|
27
|
+
readonly VehicleEvents: "https://vehicle-events-api.dev.dimo.zone";
|
|
25
28
|
};
|
|
26
29
|
};
|
|
27
30
|
export type DimoEnvironment = typeof DimoEnvironment.Production | typeof DimoEnvironment.Dev;
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
+
/** @format */
|
|
1
2
|
export const DimoEnvironment = {
|
|
2
3
|
Production: {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
Attestation: "https://attestation-api.dimo.zone",
|
|
5
|
+
Auth: "https://auth.dimo.zone",
|
|
6
|
+
Identity: "https://identity-api.dimo.zone/query",
|
|
7
|
+
Devices: "https://devices-api.dimo.zone",
|
|
8
|
+
DeviceDefinitions: "https://device-definitions-api.dimo.zone",
|
|
9
|
+
Telemetry: "https://telemetry-api.dimo.zone/query",
|
|
10
|
+
TokenExchange: "https://token-exchange-api.dimo.zone",
|
|
11
|
+
Trips: "https://trips-api.dimo.zone",
|
|
12
|
+
Valuations: "https://valuations-api.dimo.zone",
|
|
13
|
+
VehicleSignalDecoding: "https://vehicle-signal-decoding.dimo.zone",
|
|
14
|
+
VehicleEvents: "https://vehicle-events-api.dimo.zone",
|
|
13
15
|
},
|
|
14
16
|
Dev: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
Attestation: "https://attestation-api.dev.dimo.zone",
|
|
18
|
+
Auth: "https://auth.dev.dimo.zone",
|
|
19
|
+
Identity: "https://identity-api.dev.dimo.zone/query",
|
|
20
|
+
Devices: "https://devices-api.dev.dimo.zone",
|
|
21
|
+
DeviceDefinitions: "https://device-definitions-api.dev.dimo.zone",
|
|
22
|
+
Telemetry: "https://telemetry-api.dev.dimo.zone/query",
|
|
23
|
+
TokenExchange: "https://token-exchange-api.dev.dimo.zone",
|
|
24
|
+
Trips: "https://trips-api.dev.dimo.zone",
|
|
25
|
+
Valuations: "https://valuations-api.dev.dimo.zone",
|
|
26
|
+
VehicleSignalDecoding: "https://vehicle-signal-decoding.dev.dimo.zone",
|
|
27
|
+
VehicleEvents: "https://vehicle-events-api.dev.dimo.zone",
|
|
28
|
+
},
|
|
26
29
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -22009,31 +22009,34 @@ const {
|
|
|
22009
22009
|
mergeConfig
|
|
22010
22010
|
} = axios;
|
|
22011
22011
|
|
|
22012
|
+
/** @format */
|
|
22012
22013
|
const DimoEnvironment = {
|
|
22013
22014
|
Production: {
|
|
22014
|
-
|
|
22015
|
-
|
|
22016
|
-
|
|
22017
|
-
|
|
22018
|
-
|
|
22019
|
-
|
|
22020
|
-
|
|
22021
|
-
|
|
22022
|
-
|
|
22023
|
-
|
|
22015
|
+
Attestation: "https://attestation-api.dimo.zone",
|
|
22016
|
+
Auth: "https://auth.dimo.zone",
|
|
22017
|
+
Identity: "https://identity-api.dimo.zone/query",
|
|
22018
|
+
Devices: "https://devices-api.dimo.zone",
|
|
22019
|
+
DeviceDefinitions: "https://device-definitions-api.dimo.zone",
|
|
22020
|
+
Telemetry: "https://telemetry-api.dimo.zone/query",
|
|
22021
|
+
TokenExchange: "https://token-exchange-api.dimo.zone",
|
|
22022
|
+
Trips: "https://trips-api.dimo.zone",
|
|
22023
|
+
Valuations: "https://valuations-api.dimo.zone",
|
|
22024
|
+
VehicleSignalDecoding: "https://vehicle-signal-decoding.dimo.zone",
|
|
22025
|
+
VehicleEvents: "https://vehicle-events-api.dimo.zone",
|
|
22024
22026
|
},
|
|
22025
22027
|
Dev: {
|
|
22026
|
-
|
|
22027
|
-
|
|
22028
|
-
|
|
22029
|
-
|
|
22030
|
-
|
|
22031
|
-
|
|
22032
|
-
|
|
22033
|
-
|
|
22034
|
-
|
|
22035
|
-
|
|
22036
|
-
|
|
22028
|
+
Attestation: "https://attestation-api.dev.dimo.zone",
|
|
22029
|
+
Auth: "https://auth.dev.dimo.zone",
|
|
22030
|
+
Identity: "https://identity-api.dev.dimo.zone/query",
|
|
22031
|
+
Devices: "https://devices-api.dev.dimo.zone",
|
|
22032
|
+
DeviceDefinitions: "https://device-definitions-api.dev.dimo.zone",
|
|
22033
|
+
Telemetry: "https://telemetry-api.dev.dimo.zone/query",
|
|
22034
|
+
TokenExchange: "https://token-exchange-api.dev.dimo.zone",
|
|
22035
|
+
Trips: "https://trips-api.dev.dimo.zone",
|
|
22036
|
+
Valuations: "https://valuations-api.dev.dimo.zone",
|
|
22037
|
+
VehicleSignalDecoding: "https://vehicle-signal-decoding.dev.dimo.zone",
|
|
22038
|
+
VehicleEvents: "https://vehicle-events-api.dev.dimo.zone",
|
|
22039
|
+
},
|
|
22037
22040
|
};
|
|
22038
22041
|
|
|
22039
22042
|
class DimoError extends Error {
|
|
@@ -22474,6 +22477,7 @@ class Telemetry extends Resource$1 {
|
|
|
22474
22477
|
}
|
|
22475
22478
|
}
|
|
22476
22479
|
|
|
22480
|
+
/** @format */
|
|
22477
22481
|
// import { Stream } from './streamr';
|
|
22478
22482
|
class DIMO {
|
|
22479
22483
|
attestation;
|
|
@@ -22485,6 +22489,7 @@ class DIMO {
|
|
|
22485
22489
|
tokenexchange;
|
|
22486
22490
|
trips;
|
|
22487
22491
|
valuations;
|
|
22492
|
+
vehicleEvents;
|
|
22488
22493
|
constructor(env) {
|
|
22489
22494
|
this.identity = new Identity(DimoEnvironment[env].Identity, env);
|
|
22490
22495
|
this.telemetry = new Telemetry(DimoEnvironment[env].Telemetry, env);
|
|
@@ -22498,26 +22503,29 @@ class DIMO {
|
|
|
22498
22503
|
this.tokenexchange = new TokenExchange(DimoEnvironment[env].TokenExchange, env);
|
|
22499
22504
|
this.trips = new Trips(DimoEnvironment[env].Trips, env);
|
|
22500
22505
|
this.valuations = new Valuations(DimoEnvironment[env].Valuations, env);
|
|
22506
|
+
this.vehicleEvents = new VehicleEvents(DimoEnvironment[env].VehicleEvents, env);
|
|
22501
22507
|
}
|
|
22502
22508
|
// Helper Function
|
|
22503
22509
|
async authenticate() {
|
|
22504
22510
|
let fs;
|
|
22505
22511
|
try {
|
|
22506
22512
|
// Dynamically import fs
|
|
22507
|
-
if (typeof process !==
|
|
22513
|
+
if (typeof process !== "undefined" &&
|
|
22514
|
+
process.versions &&
|
|
22515
|
+
process.versions.node) {
|
|
22508
22516
|
fs = await import('fs');
|
|
22509
22517
|
}
|
|
22510
22518
|
else {
|
|
22511
22519
|
// Optionally handle the case where 'fs' is not available, returns null
|
|
22512
|
-
console.log(
|
|
22520
|
+
console.log("Not in Node.js environment; `fs` module is not available.");
|
|
22513
22521
|
return null;
|
|
22514
22522
|
}
|
|
22515
|
-
if (!fs.existsSync(
|
|
22523
|
+
if (!fs.existsSync(".credentials.json")) {
|
|
22516
22524
|
throw new DimoError({
|
|
22517
|
-
message:
|
|
22525
|
+
message: "Credentials file does not exist",
|
|
22518
22526
|
});
|
|
22519
22527
|
}
|
|
22520
|
-
const data = fs.readFileSync(
|
|
22528
|
+
const data = fs.readFileSync(".credentials.json", "utf8");
|
|
22521
22529
|
const credentials = JSON.parse(data);
|
|
22522
22530
|
const authHeader = await this.auth.getDeveloperJwt({
|
|
22523
22531
|
client_id: credentials.client_id,
|
|
@@ -22528,10 +22536,10 @@ class DIMO {
|
|
|
22528
22536
|
}
|
|
22529
22537
|
catch (error) {
|
|
22530
22538
|
// Handle file not existing and other errors
|
|
22531
|
-
console.error(
|
|
22539
|
+
console.error("Failed to authenticate:", error.message);
|
|
22532
22540
|
// Decide whether to throw the error or handle it differently
|
|
22533
22541
|
throw new DimoError({
|
|
22534
|
-
message:
|
|
22542
|
+
message: "Authentication failed",
|
|
22535
22543
|
});
|
|
22536
22544
|
}
|
|
22537
22545
|
}
|
|
@@ -144220,6 +144228,7 @@ const Method = async (resource, baseUrl, params = {}, env) => {
|
|
|
144220
144228
|
}
|
|
144221
144229
|
};
|
|
144222
144230
|
|
|
144231
|
+
/** @format */
|
|
144223
144232
|
class Resource {
|
|
144224
144233
|
api;
|
|
144225
144234
|
resourceName;
|
|
@@ -144230,12 +144239,8 @@ class Resource {
|
|
|
144230
144239
|
this.env = env;
|
|
144231
144240
|
}
|
|
144232
144241
|
setResource(resources) {
|
|
144233
|
-
Object.keys(resources).forEach(key => {
|
|
144234
|
-
this[key] = (params = {}) => Method(resources[key],
|
|
144235
|
-
this.api, // Setup the base URL
|
|
144236
|
-
params, // Pass through the params
|
|
144237
|
-
this.env // Identiy the environment
|
|
144238
|
-
);
|
|
144242
|
+
Object.keys(resources).forEach((key) => {
|
|
144243
|
+
this[key] = (params = {}) => Method(resources[key], this.api, params, this.env);
|
|
144239
144244
|
});
|
|
144240
144245
|
}
|
|
144241
144246
|
}
|
|
@@ -144401,6 +144406,90 @@ class Valuations extends Resource {
|
|
|
144401
144406
|
}
|
|
144402
144407
|
}
|
|
144403
144408
|
|
|
144409
|
+
/** @format */
|
|
144410
|
+
class VehicleEvents extends Resource {
|
|
144411
|
+
constructor(api, env) {
|
|
144412
|
+
super(api, "VehicleEvents", env);
|
|
144413
|
+
this.setResource({
|
|
144414
|
+
listWebhooks: {
|
|
144415
|
+
method: "GET",
|
|
144416
|
+
path: "/v1/webhooks",
|
|
144417
|
+
auth: "developer_jwt",
|
|
144418
|
+
},
|
|
144419
|
+
createWebhook: {
|
|
144420
|
+
method: "POST",
|
|
144421
|
+
path: "/v1/webhooks",
|
|
144422
|
+
body: {
|
|
144423
|
+
service: true,
|
|
144424
|
+
data: true,
|
|
144425
|
+
trigger: true,
|
|
144426
|
+
setup: true,
|
|
144427
|
+
description: false,
|
|
144428
|
+
target_uri: true,
|
|
144429
|
+
status: true,
|
|
144430
|
+
verification_token: true,
|
|
144431
|
+
},
|
|
144432
|
+
auth: "developer_jwt",
|
|
144433
|
+
},
|
|
144434
|
+
updateWebhook: {
|
|
144435
|
+
method: "PUT",
|
|
144436
|
+
path: "/v1/webhooks/:webhookId",
|
|
144437
|
+
body: {
|
|
144438
|
+
service: true,
|
|
144439
|
+
data: true,
|
|
144440
|
+
trigger: true,
|
|
144441
|
+
setup: true,
|
|
144442
|
+
description: false,
|
|
144443
|
+
target_uri: true,
|
|
144444
|
+
status: true,
|
|
144445
|
+
verification_token: true,
|
|
144446
|
+
},
|
|
144447
|
+
auth: "developer_jwt",
|
|
144448
|
+
},
|
|
144449
|
+
deleteWebhook: {
|
|
144450
|
+
method: "DELETE",
|
|
144451
|
+
path: "/v1/webhooks/:webhookId",
|
|
144452
|
+
auth: "developer_jwt",
|
|
144453
|
+
},
|
|
144454
|
+
getWebhookSignalNames: {
|
|
144455
|
+
method: "GET",
|
|
144456
|
+
path: "/v1/webhooks/signals",
|
|
144457
|
+
auth: "developer_jwt",
|
|
144458
|
+
},
|
|
144459
|
+
listSubscribedVehicles: {
|
|
144460
|
+
method: "GET",
|
|
144461
|
+
path: "/v1/webhooks/:webhookId",
|
|
144462
|
+
auth: "developer_jwt",
|
|
144463
|
+
},
|
|
144464
|
+
listVehicleSubscriptions: {
|
|
144465
|
+
method: "GET",
|
|
144466
|
+
path: "/v1/webhooks/vehicles/:tokenId",
|
|
144467
|
+
auth: "developer_jwt",
|
|
144468
|
+
},
|
|
144469
|
+
subscribeVehicle: {
|
|
144470
|
+
method: "POST",
|
|
144471
|
+
path: "/v1/webhooks/:webhookId/subscribe/:tokenId",
|
|
144472
|
+
auth: "developer_jwt",
|
|
144473
|
+
},
|
|
144474
|
+
subscribeAllVehicles: {
|
|
144475
|
+
method: "POST",
|
|
144476
|
+
path: "/v1/webhooks/:webhookId/subscribe/all",
|
|
144477
|
+
auth: "developer_jwt",
|
|
144478
|
+
},
|
|
144479
|
+
unsubscribeVehicle: {
|
|
144480
|
+
method: "DELETE",
|
|
144481
|
+
path: "/v1/webhooks/:webhookId/unsubscribe/:tokenId",
|
|
144482
|
+
auth: "developer_jwt",
|
|
144483
|
+
},
|
|
144484
|
+
unsubscribeAllVehicles: {
|
|
144485
|
+
method: "DELETE",
|
|
144486
|
+
path: "/v1/webhooks/:webhookId/unsubscribe/all",
|
|
144487
|
+
auth: "developer_jwt",
|
|
144488
|
+
},
|
|
144489
|
+
});
|
|
144490
|
+
}
|
|
144491
|
+
}
|
|
144492
|
+
|
|
144404
144493
|
exports.Attestation = Attestation;
|
|
144405
144494
|
exports.Auth = Auth;
|
|
144406
144495
|
exports.DIMO = DIMO;
|
|
@@ -144414,3 +144503,4 @@ exports.Telemetry = Telemetry;
|
|
|
144414
144503
|
exports.TokenExchange = TokenExchange;
|
|
144415
144504
|
exports.Trips = Trips;
|
|
144416
144505
|
exports.Valuations = Valuations;
|
|
144506
|
+
exports.VehicleEvents = VehicleEvents;
|
package/jest.config.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
1
3
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
preset: "ts-jest",
|
|
5
|
+
testEnvironment: "node",
|
|
6
|
+
roots: ["<rootDir>/src"],
|
|
7
|
+
testMatch: ["**/__tests__/**/*.ts", "**/?(*.)+(spec|test).ts"],
|
|
8
|
+
transform: {
|
|
9
|
+
"^.+\\.tsx?$": "ts-jest", // Transform TypeScript files
|
|
10
|
+
"^.+\\.mjs$": "babel-jest", // Transform .mjs files using Babel
|
|
11
|
+
"^.+\\.js$": "babel-jest", // Transform JavaScript files
|
|
12
|
+
},
|
|
13
|
+
transformIgnorePatterns: ["<rootDir>/node_modules/"],
|
|
14
|
+
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node", "mjs"],
|
|
15
|
+
moduleNameMapper: {
|
|
16
|
+
"^api/(.*)$": "<rootDir>/src/api/$1",
|
|
17
|
+
"^@/(.*)$": "<rootDir>/src/$1",
|
|
18
|
+
},
|
|
16
19
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimo-network/data-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "DIMO Data SDK for JavaScript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "James Li",
|
|
7
|
-
"contributors": [],
|
|
7
|
+
"contributors": ["Yusuf Çırak"],
|
|
8
8
|
"license": "Apache-2.0",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"exports": {
|
package/dist/streamr/index.d.ts
DELETED
|
File without changes
|
package/dist/streamr/index.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import StreamrClient from '@streamr/sdk';
|
|
3
|
-
// import { DimoError } from '../errors';
|
|
4
|
-
// import { Observable } from 'rxjs';
|
|
5
|
-
// import { catchError, finalize } from 'rxjs/operators';
|
|
6
|
-
// type StreamOptions = {
|
|
7
|
-
// streamId: string,
|
|
8
|
-
// clientId: string,
|
|
9
|
-
// privateKey: string,
|
|
10
|
-
// log?: string
|
|
11
|
-
// };
|
|
12
|
-
// export const Stream = async ({ streamId, clientId, privateKey, log }: StreamOptions) => {
|
|
13
|
-
// return new Observable(observer => {
|
|
14
|
-
// const client = new StreamrClient({
|
|
15
|
-
// logLevel: 'info' || log,
|
|
16
|
-
// auth: {
|
|
17
|
-
// //this is the signer private key the developer adds
|
|
18
|
-
// privateKey: privateKey
|
|
19
|
-
// },
|
|
20
|
-
// });
|
|
21
|
-
// const setupStream = async () => {
|
|
22
|
-
// try {
|
|
23
|
-
// const stream = await client.getStream(streamId);
|
|
24
|
-
// await client.subscribe({
|
|
25
|
-
// streamId,
|
|
26
|
-
// erc1271Contract: clientId,
|
|
27
|
-
// }, (msg) => {
|
|
28
|
-
// observer.next(msg);
|
|
29
|
-
// });
|
|
30
|
-
// } catch (error) {
|
|
31
|
-
// console.error('Streamr connection failed:', error);
|
|
32
|
-
// observer.error(new DimoError({
|
|
33
|
-
// message: 'Streamr connection failure'
|
|
34
|
-
// }));
|
|
35
|
-
// observer.complete();
|
|
36
|
-
// }
|
|
37
|
-
// };
|
|
38
|
-
// setupStream();
|
|
39
|
-
// return async () => {
|
|
40
|
-
// await client.unsubscribe(streamId);
|
|
41
|
-
// }
|
|
42
|
-
// }).pipe(
|
|
43
|
-
// catchError(error => {
|
|
44
|
-
// console.error('Streamr subscription error:', error);
|
|
45
|
-
// return new Observable();
|
|
46
|
-
// }),
|
|
47
|
-
// finalize(() => {
|
|
48
|
-
// console.log('Cleaning up Stream listeners');
|
|
49
|
-
// })
|
|
50
|
-
// );
|
|
51
|
-
// }
|