@dimo-network/data-sdk 1.2.4 → 1.2.5

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 ADDED
@@ -0,0 +1,86 @@
1
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/dimo-network/data-sdk/npm-publish.yml?style=flat-square)
2
+ ![GitHub top language](https://img.shields.io/github/languages/top/dimo-network/data-sdk?style=flat-square)
3
+ ![GitHub License](https://img.shields.io/github/license/dimo-network/data-sdk?style=flat-square)
4
+ [![Downloads](https://img.shields.io/npm/d18m/@dimo-network/data-sdk.svg?style=flat-square)](https://www.npmjs.com/package/@dimo-network/data-sdk)
5
+ [![Discord](https://img.shields.io/discord/892438668453740634)](https://chat.dimo.zone/)
6
+ ![X (formerly Twitter) URL](https://img.shields.io/twitter/url?url=https%3A%2F%2Ftwitter.com%2FDIMO_Network&style=social)
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 は、[認証フロー](https://docs.dimo.org/developer-platform/getting-started/developer-guide/authentication) に必要なすべての手順を提供し、「開発者 JWT」(Developer JWT) を取得し、アプリと共有されている各車両の「車両 JWT」(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. Get DIMO Credits (DCX) either by paying in your local currency (via Stripe) or paying with a balance (if you have one).
53
- 3. Click on `Create app` and fill out the details about your project namespace (external-facing, e.g. `Drive2Survive LLC.`) and your application name (internal, e.g. `app-prod`)
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
- ...vehicleJwt,
203
+ ...developerJwt,
202
204
  privileges: [1, 3, 4],
203
205
  tokenId: <vehicle_token_id>
204
206
  });
@@ -0,0 +1,86 @@
1
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/dimo-network/data-sdk/npm-publish.yml?style=flat-square)
2
+ ![GitHub top language](https://img.shields.io/github/languages/top/dimo-network/data-sdk?style=flat-square)
3
+ ![GitHub License](https://img.shields.io/github/license/dimo-network/data-sdk?style=flat-square)
4
+ [![Downloads](https://img.shields.io/npm/d18m/@dimo-network/data-sdk.svg?style=flat-square)](https://www.npmjs.com/package/@dimo-network/data-sdk)
5
+ [![Discord](https://img.shields.io/discord/892438668453740634)](https://chat.dimo.zone/)
6
+ ![X (formerly Twitter) URL](https://img.shields.io/twitter/url?url=https%3A%2F%2Ftwitter.com%2FDIMO_Network&style=social)
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimo-network/data-sdk",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "DIMO Data SDK for JavaScript",
5
5
  "main": "dist/index.js",
6
6
  "author": "James Li",