entity-client 1.0.7 → 1.0.8
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 +362 -0
- package/dist/EntityAppServerApi.d.ts +1080 -0
- package/dist/EntityAppServerApi.js +2 -0
- package/dist/EntityAppServerApi.js.map +7 -0
- package/dist/{EntityServerClient.d.ts → EntityServerApi.d.ts} +114 -20
- package/dist/EntityServerApi.js +2 -0
- package/dist/EntityServerApi.js.map +7 -0
- package/dist/client/base.d.ts +13 -4
- package/dist/client/base.js +1 -1
- package/dist/client/base.js.map +3 -3
- package/dist/hooks/useEntityAppServer.d.ts +18 -0
- package/dist/hooks/useEntityAppServer.js +2 -0
- package/dist/hooks/useEntityAppServer.js.map +7 -0
- package/dist/hooks/useEntityClient.d.ts +74 -0
- package/dist/hooks/useEntityClient.js +2 -0
- package/dist/hooks/useEntityClient.js.map +7 -0
- package/dist/hooks/useEntityServer.d.ts +5 -88
- package/dist/hooks/useEntityServer.js +1 -1
- package/dist/hooks/useEntityServer.js.map +3 -3
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/mixins/app/index.d.ts +6 -6
- package/dist/mixins/app/index.js +1 -1
- package/dist/mixins/app/index.js.map +2 -2
- package/dist/mixins/app/plugins/alimtalk.d.ts +68 -0
- package/dist/mixins/app/plugins/alimtalk.js +2 -0
- package/dist/mixins/app/plugins/alimtalk.js.map +7 -0
- package/dist/mixins/app/plugins/friendtalk.d.ts +62 -0
- package/dist/mixins/app/plugins/friendtalk.js +2 -0
- package/dist/mixins/app/plugins/friendtalk.js.map +7 -0
- package/dist/mixins/app/plugins/holidays.d.ts +70 -0
- package/dist/mixins/app/plugins/holidays.js +2 -0
- package/dist/mixins/app/plugins/holidays.js.map +7 -0
- package/dist/mixins/app/plugins/identity.d.ts +68 -0
- package/dist/mixins/app/plugins/identity.js +2 -0
- package/dist/mixins/app/plugins/identity.js.map +7 -0
- package/dist/mixins/app/plugins/index.d.ts +10 -0
- package/dist/mixins/app/plugins/index.js +2 -0
- package/dist/mixins/app/plugins/index.js.map +7 -0
- package/dist/mixins/app/plugins/llm.d.ts +130 -0
- package/dist/mixins/app/plugins/llm.js +2 -0
- package/dist/mixins/app/plugins/llm.js.map +7 -0
- package/dist/mixins/app/plugins/ocr.d.ts +76 -0
- package/dist/mixins/app/plugins/ocr.js +2 -0
- package/dist/mixins/app/plugins/ocr.js.map +7 -0
- package/dist/mixins/app/plugins/pg.d.ts +74 -0
- package/dist/mixins/app/plugins/pg.js +2 -0
- package/dist/mixins/app/plugins/pg.js.map +7 -0
- package/dist/mixins/app/plugins/push.d.ts +70 -0
- package/dist/mixins/app/plugins/push.js +2 -0
- package/dist/mixins/app/plugins/push.js.map +7 -0
- package/dist/mixins/app/plugins/sms.d.ts +68 -0
- package/dist/mixins/app/plugins/sms.js +2 -0
- package/dist/mixins/app/plugins/sms.js.map +7 -0
- package/dist/mixins/app/plugins/taxinvoice.d.ts +72 -0
- package/dist/mixins/app/plugins/taxinvoice.js +2 -0
- package/dist/mixins/app/plugins/taxinvoice.js.map +7 -0
- package/dist/mixins/app/{account.d.ts → routes/account.d.ts} +11 -5
- package/dist/mixins/app/routes/account.js +2 -0
- package/dist/mixins/app/routes/account.js.map +7 -0
- package/dist/mixins/app/{board.d.ts → routes/board.d.ts} +11 -5
- package/dist/mixins/app/routes/board.js +2 -0
- package/dist/mixins/app/routes/board.js.map +7 -0
- package/dist/mixins/app/{email-verify.d.ts → routes/email-verify.d.ts} +11 -5
- package/dist/mixins/app/routes/email-verify.js +2 -0
- package/dist/mixins/app/routes/email-verify.js.map +7 -0
- package/dist/mixins/app/{oauth.d.ts → routes/oauth.d.ts} +11 -5
- package/dist/mixins/app/routes/oauth.js +2 -0
- package/dist/mixins/app/routes/oauth.js.map +7 -0
- package/dist/mixins/app/{password-reset.d.ts → routes/password-reset.d.ts} +11 -5
- package/dist/mixins/app/routes/password-reset.js +2 -0
- package/dist/mixins/app/routes/password-reset.js.map +7 -0
- package/dist/mixins/app/{two-factor.d.ts → routes/two-factor.d.ts} +11 -5
- package/dist/mixins/app/routes/two-factor.js +2 -0
- package/dist/mixins/app/routes/two-factor.js.map +7 -0
- package/dist/mixins/server/admin.d.ts +7 -1
- package/dist/mixins/server/admin.js +1 -1
- package/dist/mixins/server/admin.js.map +2 -2
- package/dist/mixins/{auth.d.ts → server/auth.d.ts} +12 -20
- package/dist/mixins/{auth.js → server/auth.js} +1 -1
- package/dist/mixins/server/auth.js.map +7 -0
- package/dist/mixins/{entity.d.ts → server/entity.d.ts} +12 -6
- package/dist/mixins/server/entity.js +2 -0
- package/dist/mixins/server/entity.js.map +7 -0
- package/dist/mixins/{file.d.ts → server/file.d.ts} +12 -6
- package/dist/mixins/server/file.js.map +7 -0
- package/dist/mixins/server/index.d.ts +7 -6
- package/dist/mixins/server/index.js +1 -1
- package/dist/mixins/server/index.js.map +3 -3
- package/dist/mixins/{push.d.ts → server/push.d.ts} +12 -6
- package/dist/mixins/server/push.js.map +7 -0
- package/dist/mixins/{smtp.d.ts → server/smtp.d.ts} +14 -6
- package/dist/mixins/server/smtp.js +2 -0
- package/dist/mixins/server/smtp.js.map +7 -0
- package/dist/mixins/server/transaction.d.ts +66 -0
- package/dist/mixins/server/transaction.js +2 -0
- package/dist/mixins/server/transaction.js.map +7 -0
- package/dist/mixins/{utils.d.ts → server/utils.d.ts} +12 -6
- package/dist/mixins/server/utils.js +2 -0
- package/dist/mixins/server/utils.js.map +7 -0
- package/dist/react.d.ts +2 -0
- package/dist/react.js +1 -1
- package/dist/react.js.map +4 -4
- package/package.json +2 -2
- package/dist/EntityAppServerClient.d.ts +0 -383
- package/dist/EntityAppServerClient.js +0 -2
- package/dist/EntityAppServerClient.js.map +0 -7
- package/dist/EntityServerClient.js +0 -2
- package/dist/EntityServerClient.js.map +0 -7
- package/dist/mixins/app/account.js +0 -2
- package/dist/mixins/app/account.js.map +0 -7
- package/dist/mixins/app/board.js +0 -2
- package/dist/mixins/app/board.js.map +0 -7
- package/dist/mixins/app/email-verify.js +0 -2
- package/dist/mixins/app/email-verify.js.map +0 -7
- package/dist/mixins/app/oauth.js +0 -2
- package/dist/mixins/app/oauth.js.map +0 -7
- package/dist/mixins/app/password-reset.js +0 -2
- package/dist/mixins/app/password-reset.js.map +0 -7
- package/dist/mixins/app/two-factor.js +0 -2
- package/dist/mixins/app/two-factor.js.map +0 -7
- package/dist/mixins/auth.js.map +0 -7
- package/dist/mixins/entity.js +0 -2
- package/dist/mixins/entity.js.map +0 -7
- package/dist/mixins/file.js.map +0 -7
- package/dist/mixins/push.js.map +0 -7
- package/dist/mixins/smtp.js +0 -2
- package/dist/mixins/smtp.js.map +0 -7
- package/dist/mixins/utils.js +0 -2
- package/dist/mixins/utils.js.map +0 -7
- /package/dist/mixins/{file.js → server/file.js} +0 -0
- /package/dist/mixins/{push.js → server/push.js} +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
# entity-client
|
|
2
|
+
|
|
3
|
+
[entity-server](https://github.com/ehfuse/entity-server)(Go/Fiber)와 [entity-app-server](https://github.com/ehfuse/entity-app-server)(Node.js/Fastify)의 모든 라우트를 TypeScript로 래핑한 클라이언트 SDK입니다.
|
|
4
|
+
|
|
5
|
+
인증 헤더, 패킷 암호화, HMAC 서명, CSRF 토큰, 세션 갱신 등을 자동으로 처리합니다.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 설치
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install entity-client
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 클래스 구성
|
|
18
|
+
|
|
19
|
+
| 클래스 | 대상 서버 | 포함 기능 |
|
|
20
|
+
| -------------------- | ------------------------ | ------------------------------------------------------------------------- |
|
|
21
|
+
| `EntityServerApi` | entity-server (Go) | 인증, 엔티티 CRUD, 파일, SMTP, 알림, 트랜잭션, 유틸 |
|
|
22
|
+
| `EntityAppServerApi` | entity-app-server (Node) | 위 전체 + 계정, 게시판, 이메일인증, OAuth, 비밀번호재설정, 2FA + 플러그인 |
|
|
23
|
+
|
|
24
|
+
`EntityAppServerApi`는 `EntityServerApi`를 상속하므로 entity-server 라우트도 모두 포함합니다.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 빠른 시작
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { EntityServerApi, EntityAppServerApi } from "entity-client";
|
|
32
|
+
|
|
33
|
+
// entity-server 전용
|
|
34
|
+
const server = new EntityServerApi({ baseUrl: "https://api.example.com" });
|
|
35
|
+
await server.login("user@example.com", "password");
|
|
36
|
+
const { data } = await server.get("account", 1);
|
|
37
|
+
|
|
38
|
+
// entity-app-server (앱 라우트 + 플러그인 포함)
|
|
39
|
+
const appServer = new EntityAppServerApi({
|
|
40
|
+
baseUrl: "https://app.example.com",
|
|
41
|
+
});
|
|
42
|
+
await appServer.accountLogin({ id: "user@example.com", password: "password" });
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 전역 싱글턴 사용
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { entityServer, entityAppServer } from "entity-client";
|
|
49
|
+
|
|
50
|
+
entityServer.configure({ baseUrl: "https://api.example.com" });
|
|
51
|
+
entityServer.setToken("access_token");
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 생성 옵션
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
const client = new EntityServerApi({
|
|
60
|
+
baseUrl: "https://api.example.com", // 기본값: VITE_ENTITY_SERVER_URL 환경변수
|
|
61
|
+
token: "access_token",
|
|
62
|
+
hmacSecret: "secret", // HMAC 서명 활성화
|
|
63
|
+
encryptRequests: true, // 요청 바디 패킷 암호화
|
|
64
|
+
csrfEnabled: true, // CSRF 토큰 자동 갱신
|
|
65
|
+
keepSession: true, // access_token 만료 전 자동 갱신
|
|
66
|
+
onTokenRefreshed: (token, expiresIn) => {
|
|
67
|
+
localStorage.setItem("refresh_token", token);
|
|
68
|
+
},
|
|
69
|
+
onSessionExpired: (err) => {
|
|
70
|
+
location.href = "/login";
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## entity-server API (EntityServerApi)
|
|
78
|
+
|
|
79
|
+
### 인증
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
// 로그인
|
|
83
|
+
const { access_token, refresh_token } = await client.login("id", "pw");
|
|
84
|
+
|
|
85
|
+
// 토큰 갱신
|
|
86
|
+
await client.refreshToken(refresh_token);
|
|
87
|
+
|
|
88
|
+
// 로그아웃
|
|
89
|
+
await client.logout();
|
|
90
|
+
|
|
91
|
+
// 회원가입
|
|
92
|
+
await client.register({ id: "user", password: "pw", name: "홍길동" });
|
|
93
|
+
|
|
94
|
+
// 비밀번호 변경
|
|
95
|
+
await client.changePassword({ current_password: "old", new_password: "new" });
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 엔티티 CRUD
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
// 단건 조회
|
|
102
|
+
const { data } = await client.get<User>("account", seq);
|
|
103
|
+
|
|
104
|
+
// 목록 조회
|
|
105
|
+
const { data } = await client.list<User>("account", {
|
|
106
|
+
page: 1,
|
|
107
|
+
limit: 20,
|
|
108
|
+
conditions: { status: "active" },
|
|
109
|
+
orderBy: "created_at",
|
|
110
|
+
orderDir: "DESC",
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// 조건 단건 조회
|
|
114
|
+
const { data } = await client.find<User>("account", {
|
|
115
|
+
email: "user@example.com",
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// 생성 / 수정 (seq 없으면 INSERT, 있으면 UPDATE)
|
|
119
|
+
const { seq } = await client.submit("account", {
|
|
120
|
+
name: "홍길동",
|
|
121
|
+
email: "a@b.com",
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// 삭제 (기본: 소프트 삭제)
|
|
125
|
+
await client.delete("account", seq);
|
|
126
|
+
await client.delete("account", seq, { hard: true }); // 하드 삭제
|
|
127
|
+
|
|
128
|
+
// 건수 조회
|
|
129
|
+
const { count } = await client.count("account", { status: "active" });
|
|
130
|
+
|
|
131
|
+
// 커스텀 SQL 조회
|
|
132
|
+
const { data } = await client.query("account", {
|
|
133
|
+
select: ["seq", "name", "email"],
|
|
134
|
+
where: "status = 'active'",
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// 변경 이력
|
|
138
|
+
const { data } = await client.history("account", seq);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 트랜잭션
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
const txId = await client.transStart();
|
|
145
|
+
try {
|
|
146
|
+
await client.submit("order", { ...orderData, seq: undefined });
|
|
147
|
+
await client.submit("order_item", { ...itemData }, { transactionId: txId });
|
|
148
|
+
await client.transCommit();
|
|
149
|
+
} catch (e) {
|
|
150
|
+
await client.transRollback();
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 파일
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
// 업로드
|
|
158
|
+
const { uuid } = await client.fileUpload(file, { entity: "account", seq: 1 });
|
|
159
|
+
|
|
160
|
+
// 목록
|
|
161
|
+
const { data } = await client.fileList({ entity: "account", seq: 1 });
|
|
162
|
+
|
|
163
|
+
// 삭제
|
|
164
|
+
await client.fileDelete(uuid);
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### SMTP
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
await client.smtpSend({
|
|
171
|
+
to: "user@example.com",
|
|
172
|
+
template: "welcome",
|
|
173
|
+
vars: { name: "홍길동" },
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## entity-app-server API (EntityAppServerApi)
|
|
180
|
+
|
|
181
|
+
`EntityServerApi`의 모든 메서드에 더해 아래가 추가됩니다.
|
|
182
|
+
|
|
183
|
+
### 계정
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
await client.accountLogin({ id: "user@example.com", password: "pw" });
|
|
187
|
+
await client.accountRegister({ ... });
|
|
188
|
+
await client.accountWithdraw({ reason: "탈퇴" });
|
|
189
|
+
await client.accountReactivate({ id: "user@example.com", password: "pw" });
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 게시판
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
// 카테고리
|
|
196
|
+
await client.boardCategoryList();
|
|
197
|
+
await client.boardCategoryCreate({ name: "공지사항" });
|
|
198
|
+
|
|
199
|
+
// 게시글
|
|
200
|
+
const { data } = await client.boardPostList({ category_seq: 1, page: 1 });
|
|
201
|
+
const { seq } = await client.boardPostCreate({
|
|
202
|
+
title: "제목",
|
|
203
|
+
content: "내용",
|
|
204
|
+
category_seq: 1,
|
|
205
|
+
});
|
|
206
|
+
await client.boardPostUpdate(seq, { title: "수정 제목" });
|
|
207
|
+
await client.boardPostDelete(seq);
|
|
208
|
+
|
|
209
|
+
// 댓글
|
|
210
|
+
await client.boardCommentCreate(postSeq, { content: "댓글" });
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### OAuth
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
const { url } = await client.oauthAuthorize({
|
|
217
|
+
provider: "kakao",
|
|
218
|
+
redirect_uri: "...",
|
|
219
|
+
});
|
|
220
|
+
const { access_token } = await client.oauthCallback({
|
|
221
|
+
provider: "kakao",
|
|
222
|
+
code: "...",
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### 이메일 인증 / 비밀번호 재설정
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
await client.emailVerifySend({ email: "user@example.com" });
|
|
230
|
+
await client.emailVerifyConfirm({ email: "user@example.com", code: "123456" });
|
|
231
|
+
|
|
232
|
+
await client.passwordResetRequest({ email: "user@example.com" });
|
|
233
|
+
await client.passwordResetConfirm({ token: "...", new_password: "newpw" });
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### 2FA
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
await client.twoFactorSetup();
|
|
240
|
+
await client.twoFactorVerify({ code: "123456" });
|
|
241
|
+
await client.twoFactorDisable();
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### 플러그인
|
|
245
|
+
|
|
246
|
+
| 플러그인 | 메서드 예시 |
|
|
247
|
+
| ------------------- | ------------------------------------------ |
|
|
248
|
+
| 알림톡 (Alimtalk) | `alimtalkSend()` |
|
|
249
|
+
| 친구톡 (Friendtalk) | `friendtalkSend()` |
|
|
250
|
+
| SMS | `smsSend()` |
|
|
251
|
+
| 앱 푸시 (FCM) | `appPushSend()` |
|
|
252
|
+
| 결제 (PG) | `pgPaymentRequest()`, `pgPaymentConfirm()` |
|
|
253
|
+
| 세금계산서 | `taxinvoiceIssue()` |
|
|
254
|
+
| OCR | `ocrExtract()` |
|
|
255
|
+
| LLM | `llmChat()` |
|
|
256
|
+
| 신원인증 | `identityVerify()` |
|
|
257
|
+
| 공휴일 | `holidaysList()` |
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## 커스텀 라우트 직접 호출
|
|
262
|
+
|
|
263
|
+
SDK에 없는 엔드포인트는 `client.http`를 사용합니다. 인증·암호화가 그대로 적용됩니다.
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
// GET
|
|
267
|
+
const res = await client.http.get<{ version: string }>("/api/v1/status", false);
|
|
268
|
+
|
|
269
|
+
// POST
|
|
270
|
+
const res = await client.http.post<MyResponse>("/api/v1/custom", {
|
|
271
|
+
key: "value",
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// PUT / PATCH / DELETE
|
|
275
|
+
await client.http.put("/api/v1/resource/1", { name: "updated" });
|
|
276
|
+
await client.http.patch("/api/v1/resource/1", { status: "active" });
|
|
277
|
+
await client.http.delete("/api/v1/resource/1");
|
|
278
|
+
|
|
279
|
+
// 추가 헤더
|
|
280
|
+
await client.http.post("/api/v1/endpoint", body, true, { "X-Custom": "value" });
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
바이너리·폼 데이터:
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
const buffer = await client.requestBinary("GET", "/api/v1/export/report.pdf");
|
|
287
|
+
|
|
288
|
+
const form = new FormData();
|
|
289
|
+
form.append("file", fileBlob, "doc.pdf");
|
|
290
|
+
const res = await client.requestForm<{ ok: boolean }>(
|
|
291
|
+
"POST",
|
|
292
|
+
"/api/v1/upload",
|
|
293
|
+
form,
|
|
294
|
+
);
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## React 훅
|
|
300
|
+
|
|
301
|
+
```tsx
|
|
302
|
+
import { useEntityServer, useEntityAppServer } from "entity-client/react";
|
|
303
|
+
|
|
304
|
+
function MyComponent() {
|
|
305
|
+
const { client, submit, del, isPending, error } = useEntityServer();
|
|
306
|
+
|
|
307
|
+
const handleSave = async () => {
|
|
308
|
+
await submit("account", { name: "홍길동" });
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
const handleDelete = async (seq: number) => {
|
|
312
|
+
await del("account", seq);
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
return (
|
|
316
|
+
<button onClick={handleSave} disabled={isPending}>
|
|
317
|
+
{isPending ? "저장 중..." : "저장"}
|
|
318
|
+
</button>
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
옵션:
|
|
324
|
+
|
|
325
|
+
```tsx
|
|
326
|
+
// 별도 인스턴스 (singleton=false)
|
|
327
|
+
const { client } = useEntityServer({
|
|
328
|
+
singleton: false,
|
|
329
|
+
baseUrl: "https://...",
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
// 세션 복원
|
|
333
|
+
const { client } = useEntityServer({
|
|
334
|
+
resumeSession: localStorage.getItem("refresh_token") ?? undefined,
|
|
335
|
+
});
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## 패킷 암호화
|
|
341
|
+
|
|
342
|
+
서버에서 `encryptRequests: true`를 요구하는 경우 클라이언트 옵션에도 동일하게 설정합니다. 요청 바디 암호화와 응답 복호화가 자동으로 처리됩니다.
|
|
343
|
+
|
|
344
|
+
```ts
|
|
345
|
+
const client = new EntityServerApi({
|
|
346
|
+
baseUrl: "https://api.example.com",
|
|
347
|
+
anonymousPacketToken: "shared_secret",
|
|
348
|
+
encryptRequests: true,
|
|
349
|
+
});
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
패킷 유틸리티를 직접 사용하려면:
|
|
353
|
+
|
|
354
|
+
```ts
|
|
355
|
+
import { encryptPacket, decryptPacket } from "entity-client/packet";
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## 라이선스
|
|
361
|
+
|
|
362
|
+
MIT
|