@kanmon-hq/tollgate-ui 1.1.2 → 1.1.4
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.ja.md +165 -0
- package/README.md +69 -48
- package/dist/tollgate-ui.js +1761 -1761
- package/dist/tollgate-ui.umd.cjs +39 -39
- package/package.json +3 -2
package/README.ja.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# @kanmon-hq/tollgate-ui
|
|
2
|
+
|
|
3
|
+
[English](README.md) | **日本語**
|
|
4
|
+
|
|
5
|
+
Tollgate API Gateway & Key Broker 向けの組み込み型 Web Components UI ライブラリ。
|
|
6
|
+
Vue 3、React、Next.js、Vanilla HTML などあらゆるフロントエンド環境に単一のカスタム要素として簡単に組み込み可能です。
|
|
7
|
+
|
|
8
|
+
## 特徴
|
|
9
|
+
|
|
10
|
+
- ⚡ **Web Components (Custom Elements)**: フレームワークに依存せず `<tollgate-console>` タグで利用可能
|
|
11
|
+
- 🛡️ **Shadow DOM スコープ保護**: ホストアプリケーションの CSS と干渉しない完全隔離スタイリング
|
|
12
|
+
- 🎨 **リッチな管理 UI**: API キーの発行・クォータ管理・レートリミット制御・Graceful ローテーション・キー単体認可検証テスターを内蔵
|
|
13
|
+
- 🏢 **マルチテナント完全対応**: テナント切り替え、スコープ管理、サービスキー分離に対応
|
|
14
|
+
|
|
15
|
+
## インストール
|
|
16
|
+
|
|
17
|
+
### npm からインストール (推奨)
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @kanmon-hq/tollgate-ui
|
|
21
|
+
# または
|
|
22
|
+
pnpm add @kanmon-hq/tollgate-ui
|
|
23
|
+
# または
|
|
24
|
+
yarn add @kanmon-hq/tollgate-ui
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### GitHub Packages からインストール
|
|
28
|
+
|
|
29
|
+
プロジェクト直下の `.npmrc` に以下を設定してインストールします:
|
|
30
|
+
|
|
31
|
+
```ini
|
|
32
|
+
@kanmon-hq:registry=https://npm.pkg.github.com
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install @kanmon-hq/tollgate-ui
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 使い方
|
|
40
|
+
|
|
41
|
+
### 1. Vanilla HTML / CDN
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<!DOCTYPE html>
|
|
45
|
+
<html lang="ja">
|
|
46
|
+
<head>
|
|
47
|
+
<meta charset="UTF-8">
|
|
48
|
+
<script type="module" src="https://unpkg.com/@kanmon-hq/tollgate-ui/dist/tollgate-ui.js"></script>
|
|
49
|
+
</head>
|
|
50
|
+
<body class="bg-slate-950 p-8">
|
|
51
|
+
<tollgate-console
|
|
52
|
+
api-base-url="http://localhost:8000"
|
|
53
|
+
admin-token="your-admin-secret"
|
|
54
|
+
tenants-json='[{"id":"tenant-corp-a","name":"Corp A"},{"id":"tenant-corp-b","name":"Corp B"}]'
|
|
55
|
+
></tollgate-console>
|
|
56
|
+
</body>
|
|
57
|
+
</html>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 2. Vue 3 での利用
|
|
61
|
+
|
|
62
|
+
```vue
|
|
63
|
+
<script setup lang="ts">
|
|
64
|
+
import '@kanmon-hq/tollgate-ui'
|
|
65
|
+
// または
|
|
66
|
+
// import { registerTollgateUI } from '@kanmon-hq/tollgate-ui'
|
|
67
|
+
// registerTollgateUI()
|
|
68
|
+
|
|
69
|
+
const tenants = [
|
|
70
|
+
{ id: 'tenant-corp-a', name: '企業 A' },
|
|
71
|
+
{ id: 'tenant-corp-b', name: '企業 B' }
|
|
72
|
+
]
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<template>
|
|
76
|
+
<div class="p-6">
|
|
77
|
+
<tollgate-console
|
|
78
|
+
api-base-url="/api"
|
|
79
|
+
admin-token="secret-token"
|
|
80
|
+
:tenants-json="tenants"
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
83
|
+
</template>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
> **Note (Vue 3)**: Vite 設定等でカスタム要素として扱う場合は `compilerOptions.isCustomElement: (tag) => tag.startsWith('tollgate-')` を指定してください。
|
|
87
|
+
|
|
88
|
+
### 3. React / Next.js での利用
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import React, { useEffect } from 'react'
|
|
92
|
+
|
|
93
|
+
export function TollgateAdminPage() {
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
import('@kanmon-hq/tollgate-ui')
|
|
96
|
+
}, [])
|
|
97
|
+
|
|
98
|
+
const tenants = [
|
|
99
|
+
{ id: 'tenant-corp-a', name: '企業 A' },
|
|
100
|
+
{ id: 'tenant-corp-b', name: '企業 B' }
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<div className="p-6">
|
|
105
|
+
{/* @ts-ignore custom element */}
|
|
106
|
+
<tollgate-console
|
|
107
|
+
api-base-url={process.env.NEXT_PUBLIC_TOLLGATE_API_URL}
|
|
108
|
+
admin-token="your-admin-secret"
|
|
109
|
+
tenants-json={JSON.stringify(tenants)}
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Props (Attributes / Properties)
|
|
117
|
+
|
|
118
|
+
| 属性名 | 型 | 説明 | デフォルト値 / 環境変数フォールバック |
|
|
119
|
+
| :--- | :--- | :--- | :--- |
|
|
120
|
+
| `api-base-url` | `string` | Tollgate サーバーの Base URL (例: `http://localhost:8000`, `/api`) | `""` / `VITE_TOLLGATE_API_BASE_URL` |
|
|
121
|
+
| `admin-token` | `string` | 管理者認可シークレット / Bearer トークン | `""` / `VITE_TOLLGATE_ADMIN_TOKEN` |
|
|
122
|
+
| `tenant-id` | `string` | 特定テナントに限定する場合のテナントID | `""` |
|
|
123
|
+
| `tenants-json` | `string` \| `TenantOption[]` | テナント一覧の配列(またはJSON文字列) | `[]` / `VITE_TOLLGATE_TENANTS` |
|
|
124
|
+
| `embedded` | `boolean` | ヘッダーを非表示にしてコンポーネントのみ埋め込むモード | `false` |
|
|
125
|
+
| `title` | `string` | ヘッダータイトル | `"API Key Gateway (Tollgate) 管理コンソール"` |
|
|
126
|
+
|
|
127
|
+
## 環境変数 (デフォルト設定)
|
|
128
|
+
|
|
129
|
+
ビルド時やローカル開発時、属性が省略された場合のデフォルト値を `.env` 等の環境変数で設定可能です:
|
|
130
|
+
|
|
131
|
+
```env
|
|
132
|
+
# Tollgate UI — Environment Variables
|
|
133
|
+
VITE_TOLLGATE_API_BASE_URL=http://localhost:8000
|
|
134
|
+
VITE_TOLLGATE_ADMIN_TOKEN=admin-secret-key-for-local-dev
|
|
135
|
+
VITE_TOLLGATE_TENANTS=[{"id":"tenant-risk-01","name":"Risk Division"},{"id":"tenant-finance-02","name":"Finance Division"}]
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## UI 上での動的エンドポイント変更
|
|
139
|
+
|
|
140
|
+
- ヘッダー右上の **エンドポイントバッジ / 接続設定ボタン(⚙️)** をクリックすることで、モーダル上から API Base URL や Admin Token を動的に変更・接続テスト・即時リロードが可能です。
|
|
141
|
+
- UI 上で変更した設定はブラウザの `localStorage` に保持され、リロード後も維持されます。「初期値に戻す」ボタンで環境変数/Props のデフォルト値に戻すことができます。
|
|
142
|
+
|
|
143
|
+
## 解決優先順位 (Resolution Order)
|
|
144
|
+
|
|
145
|
+
1. **UI 手動設定** (`localStorage`)
|
|
146
|
+
2. **Props / Attributes** (`api-base-url`, `admin-token`, `tenants-json`)
|
|
147
|
+
3. **環境変数** (`VITE_TOLLGATE_*`) またはグローバル定義 (`window.__TOLLGATE_CONFIG__`)
|
|
148
|
+
4. **デフォルト値** (同一オリジン / 空文字)
|
|
149
|
+
|
|
150
|
+
## 開発
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# 依存関係インストール
|
|
154
|
+
npm install
|
|
155
|
+
|
|
156
|
+
# 開発サーバー起動 (http://localhost:5173/)
|
|
157
|
+
npm run dev
|
|
158
|
+
|
|
159
|
+
# Web Components ライブラリビルド
|
|
160
|
+
npm run build
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## ライセンス
|
|
164
|
+
|
|
165
|
+
MPL-2.0
|
package/README.md
CHANGED
|
@@ -1,46 +1,60 @@
|
|
|
1
1
|
# @kanmon-hq/tollgate-ui
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
Vue 3、React、Next.js、Vanilla HTML などあらゆるフロントエンド環境に単一のカスタム要素として簡単に組み込み可能です。
|
|
3
|
+
**English** | [日本語](README.ja.md)
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@kanmon-hq/tollgate-ui)
|
|
6
|
+
[](LICENSE)
|
|
7
7
|
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
- 🎨 **リッチな管理 UI**: API キーの発行・クォータ管理・レートリミット制御・Graceful ローテーション・キー単体認可検証テスターを内蔵
|
|
11
|
-
- 🏢 **マルチテナント完全対応**: テナント切り替え、スコープ管理、サービスキー分離に対応
|
|
8
|
+
An embeddable, framework-agnostic Web Components UI suite for the **Tollgate** API Gateway & Key Broker.
|
|
9
|
+
Easily embed a full-featured API key management console into any frontend stack (Vue 3, React, Next.js, Angular, or Vanilla HTML) via a single `<tollgate-console>` custom element.
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
---
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- ⚡ **Web Components (Custom Elements)**: Framework-independent, drops into any web app via `<tollgate-console>`.
|
|
16
|
+
- 🛡️ **Shadow DOM Style Isolation**: Zero CSS leakage. Completely isolated styling that never conflicts with host application stylesheets (Bootstrap, Tailwind, etc.).
|
|
17
|
+
- 🎨 **Feature-Rich Admin UI**: Built-in issuance, quota and RPM limits, graceful zero-downtime key rotation, suspensions, and real-time authorization testing.
|
|
18
|
+
- 🏢 **Multi-Tenant Native**: Seamless switching between tenants, scope selection, service key separation, and bulk tenant revocation.
|
|
19
|
+
- ⚙️ **Interactive Connection Settings**: Dynamic modal in the UI to update API Base URLs and Admin Tokens on the fly with `localStorage` persistence.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
### From npm (Recommended)
|
|
16
26
|
|
|
17
27
|
```bash
|
|
18
28
|
npm install @kanmon-hq/tollgate-ui
|
|
19
|
-
#
|
|
29
|
+
# or
|
|
20
30
|
pnpm add @kanmon-hq/tollgate-ui
|
|
21
|
-
#
|
|
31
|
+
# or
|
|
22
32
|
yarn add @kanmon-hq/tollgate-ui
|
|
23
33
|
```
|
|
24
34
|
|
|
25
|
-
### GitHub Packages
|
|
35
|
+
### From GitHub Packages
|
|
26
36
|
|
|
27
|
-
|
|
37
|
+
Configure your `.npmrc` in the project root:
|
|
28
38
|
|
|
29
39
|
```ini
|
|
30
40
|
@kanmon-hq:registry=https://npm.pkg.github.com
|
|
31
41
|
```
|
|
32
42
|
|
|
43
|
+
Then install:
|
|
44
|
+
|
|
33
45
|
```bash
|
|
34
46
|
npm install @kanmon-hq/tollgate-ui
|
|
35
47
|
```
|
|
36
48
|
|
|
37
|
-
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
38
52
|
|
|
39
53
|
### 1. Vanilla HTML / CDN
|
|
40
54
|
|
|
41
55
|
```html
|
|
42
56
|
<!DOCTYPE html>
|
|
43
|
-
<html lang="
|
|
57
|
+
<html lang="en">
|
|
44
58
|
<head>
|
|
45
59
|
<meta charset="UTF-8">
|
|
46
60
|
<script type="module" src="https://unpkg.com/@kanmon-hq/tollgate-ui/dist/tollgate-ui.js"></script>
|
|
@@ -55,18 +69,18 @@ npm install @kanmon-hq/tollgate-ui
|
|
|
55
69
|
</html>
|
|
56
70
|
```
|
|
57
71
|
|
|
58
|
-
### 2. Vue 3
|
|
72
|
+
### 2. Vue 3
|
|
59
73
|
|
|
60
74
|
```vue
|
|
61
75
|
<script setup lang="ts">
|
|
62
76
|
import '@kanmon-hq/tollgate-ui'
|
|
63
|
-
//
|
|
77
|
+
// Alternatively:
|
|
64
78
|
// import { registerTollgateUI } from '@kanmon-hq/tollgate-ui'
|
|
65
79
|
// registerTollgateUI()
|
|
66
80
|
|
|
67
81
|
const tenants = [
|
|
68
|
-
{ id: 'tenant-corp-a', name: '
|
|
69
|
-
{ id: 'tenant-corp-b', name: '
|
|
82
|
+
{ id: 'tenant-corp-a', name: 'Corp A' },
|
|
83
|
+
{ id: 'tenant-corp-b', name: 'Corp B' }
|
|
70
84
|
]
|
|
71
85
|
</script>
|
|
72
86
|
|
|
@@ -74,16 +88,16 @@ const tenants = [
|
|
|
74
88
|
<div class="p-6">
|
|
75
89
|
<tollgate-console
|
|
76
90
|
api-base-url="/api"
|
|
77
|
-
admin-token="secret
|
|
91
|
+
admin-token="your-admin-secret"
|
|
78
92
|
:tenants-json="tenants"
|
|
79
93
|
/>
|
|
80
94
|
</div>
|
|
81
95
|
</template>
|
|
82
96
|
```
|
|
83
97
|
|
|
84
|
-
> **
|
|
98
|
+
> **Vue 3 Tip**: If using Vite, configure `compilerOptions.isCustomElement: (tag) => tag.startsWith('tollgate-')` in `@vitejs/plugin-vue` to avoid custom element compiler warnings.
|
|
85
99
|
|
|
86
|
-
### 3. React / Next.js
|
|
100
|
+
### 3. React / Next.js
|
|
87
101
|
|
|
88
102
|
```tsx
|
|
89
103
|
import React, { useEffect } from 'react'
|
|
@@ -94,8 +108,8 @@ export function TollgateAdminPage() {
|
|
|
94
108
|
}, [])
|
|
95
109
|
|
|
96
110
|
const tenants = [
|
|
97
|
-
{ id: 'tenant-corp-a', name: '
|
|
98
|
-
{ id: 'tenant-corp-b', name: '
|
|
111
|
+
{ id: 'tenant-corp-a', name: 'Corp A' },
|
|
112
|
+
{ id: 'tenant-corp-b', name: 'Corp B' }
|
|
99
113
|
]
|
|
100
114
|
|
|
101
115
|
return (
|
|
@@ -111,20 +125,24 @@ export function TollgateAdminPage() {
|
|
|
111
125
|
}
|
|
112
126
|
```
|
|
113
127
|
|
|
128
|
+
---
|
|
129
|
+
|
|
114
130
|
## Props (Attributes / Properties)
|
|
115
131
|
|
|
116
|
-
|
|
|
117
|
-
|
|
118
|
-
| `api-base-url` | `string` |
|
|
119
|
-
| `admin-token` | `string` |
|
|
120
|
-
| `tenant-id` | `string` |
|
|
121
|
-
| `tenants-json` | `string` \| `TenantOption[]` |
|
|
122
|
-
| `embedded` | `boolean` |
|
|
123
|
-
| `title` | `string` |
|
|
132
|
+
| Attribute | Type | Description | Default / Fallback |
|
|
133
|
+
|:---|:---|:---|:---|
|
|
134
|
+
| `api-base-url` | `string` | Base URL of the Tollgate server (e.g. `http://localhost:8000`, `/api`) | `""` / `VITE_TOLLGATE_API_BASE_URL` |
|
|
135
|
+
| `admin-token` | `string` | Master administrative secret / Bearer token | `""` / `VITE_TOLLGATE_ADMIN_TOKEN` |
|
|
136
|
+
| `tenant-id` | `string` | Restrict console to a specific tenant ID | `""` |
|
|
137
|
+
| `tenants-json` | `string` \| `TenantOption[]` | Array of selectable tenants (or JSON string) | `[]` / `VITE_TOLLGATE_TENANTS` |
|
|
138
|
+
| `embedded` | `boolean` | Hide header banner for cleaner embedded layouts | `false` |
|
|
139
|
+
| `title` | `string` | Header banner title text | `"API Key Gateway (Tollgate) Management Console"` |
|
|
140
|
+
|
|
141
|
+
---
|
|
124
142
|
|
|
125
|
-
##
|
|
143
|
+
## Environment Variables (Build Defaults)
|
|
126
144
|
|
|
127
|
-
|
|
145
|
+
When running locally or building default configuration bundles, fallbacks can be injected via `.env`:
|
|
128
146
|
|
|
129
147
|
```env
|
|
130
148
|
# Tollgate UI — Environment Variables
|
|
@@ -133,31 +151,34 @@ VITE_TOLLGATE_ADMIN_TOKEN=admin-secret-key-for-local-dev
|
|
|
133
151
|
VITE_TOLLGATE_TENANTS=[{"id":"tenant-risk-01","name":"Risk Division"},{"id":"tenant-finance-02","name":"Finance Division"}]
|
|
134
152
|
```
|
|
135
153
|
|
|
136
|
-
|
|
154
|
+
---
|
|
137
155
|
|
|
138
|
-
|
|
139
|
-
- UI 上で変更した設定はブラウザの `localStorage` に保持され、リロード後も維持されます。「初期値に戻す」ボタンで環境変数/Props のデフォルト値に戻すことができます。
|
|
156
|
+
## Configuration Resolution Order
|
|
140
157
|
|
|
141
|
-
|
|
158
|
+
Configuration values resolve in the following order of precedence:
|
|
142
159
|
|
|
143
|
-
1. **UI
|
|
144
|
-
2. **
|
|
145
|
-
3.
|
|
146
|
-
4.
|
|
160
|
+
1. **Interactive UI Overrides** (`localStorage` via connection settings modal)
|
|
161
|
+
2. **Component Attributes / Props** (`api-base-url`, `admin-token`, `tenants-json`)
|
|
162
|
+
3. **Build Environment Variables** (`VITE_TOLLGATE_*`) or Global Object (`window.__TOLLGATE_CONFIG__`)
|
|
163
|
+
4. **Defaults** (Same-origin relative path / empty strings)
|
|
147
164
|
|
|
148
|
-
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Development
|
|
149
168
|
|
|
150
169
|
```bash
|
|
151
|
-
#
|
|
170
|
+
# Install dependencies
|
|
152
171
|
npm install
|
|
153
172
|
|
|
154
|
-
#
|
|
173
|
+
# Start development server (http://localhost:5173/)
|
|
155
174
|
npm run dev
|
|
156
175
|
|
|
157
|
-
# Web
|
|
176
|
+
# Build Web Component library bundle
|
|
158
177
|
npm run build
|
|
159
178
|
```
|
|
160
179
|
|
|
161
|
-
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## License
|
|
162
183
|
|
|
163
|
-
MPL-2.0
|
|
184
|
+
This project is licensed under the [Mozilla Public License 2.0 (MPL-2.0)](LICENSE).
|