entity-server-client 0.3.2 → 1.0.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.
Files changed (69) hide show
  1. package/dist/EntityServerClient.d.ts +432 -0
  2. package/dist/client/base.d.ts +84 -0
  3. package/dist/client/hmac.d.ts +8 -0
  4. package/dist/client/packet.d.ts +24 -0
  5. package/dist/client/request.d.ts +16 -0
  6. package/dist/client/utils.d.ts +8 -0
  7. package/dist/hooks/useEntityServer.d.ts +63 -0
  8. package/{src/index.ts → dist/index.d.ts} +1 -3
  9. package/dist/index.js +2 -0
  10. package/dist/index.js.map +7 -0
  11. package/dist/mixins/alimtalk.d.ts +56 -0
  12. package/dist/mixins/auth.d.ts +100 -0
  13. package/dist/mixins/email.d.ts +51 -0
  14. package/dist/mixins/entity.d.ts +126 -0
  15. package/dist/mixins/file.d.ts +85 -0
  16. package/dist/mixins/identity.d.ts +52 -0
  17. package/dist/mixins/llm.d.ts +94 -0
  18. package/dist/mixins/pg.d.ts +63 -0
  19. package/dist/mixins/push.d.ts +101 -0
  20. package/dist/mixins/sms.d.ts +55 -0
  21. package/dist/mixins/smtp.d.ts +51 -0
  22. package/dist/mixins/utils.d.ts +88 -0
  23. package/dist/packet.d.ts +11 -0
  24. package/dist/packet.js +2 -0
  25. package/dist/packet.js.map +7 -0
  26. package/dist/react.js +2 -0
  27. package/dist/react.js.map +7 -0
  28. package/{src/types.ts → dist/types.d.ts} +2 -42
  29. package/package.json +9 -36
  30. package/LICENSE +0 -21
  31. package/README.md +0 -128
  32. package/build.mjs +0 -36
  33. package/docs/api/alimtalk.md +0 -62
  34. package/docs/api/auth.md +0 -256
  35. package/docs/api/email.md +0 -37
  36. package/docs/api/entity.md +0 -273
  37. package/docs/api/file.md +0 -80
  38. package/docs/api/health.md +0 -47
  39. package/docs/api/identity.md +0 -32
  40. package/docs/api/import.md +0 -45
  41. package/docs/api/packet.md +0 -90
  42. package/docs/api/pg.md +0 -90
  43. package/docs/api/push.md +0 -107
  44. package/docs/api/react.md +0 -141
  45. package/docs/api/request.md +0 -118
  46. package/docs/api/setup.md +0 -43
  47. package/docs/api/sms.md +0 -45
  48. package/docs/api/smtp.md +0 -33
  49. package/docs/api/transaction.md +0 -50
  50. package/docs/api/utils.md +0 -52
  51. package/docs/apis.md +0 -26
  52. package/docs/react.md +0 -137
  53. package/src/EntityServerClient.ts +0 -28
  54. package/src/client/base.ts +0 -348
  55. package/src/client/hmac.ts +0 -41
  56. package/src/client/packet.ts +0 -77
  57. package/src/client/request.ts +0 -139
  58. package/src/client/utils.ts +0 -33
  59. package/src/hooks/useEntityServer.ts +0 -154
  60. package/src/mixins/auth.ts +0 -143
  61. package/src/mixins/entity.ts +0 -205
  62. package/src/mixins/file.ts +0 -99
  63. package/src/mixins/push.ts +0 -109
  64. package/src/mixins/smtp.ts +0 -20
  65. package/src/mixins/utils.ts +0 -106
  66. package/src/packet.ts +0 -84
  67. package/tests/packet.test.mjs +0 -50
  68. package/tsconfig.json +0 -14
  69. /package/{src/react.ts → dist/react.d.ts} +0 -0
@@ -0,0 +1,85 @@
1
+ import type { FileMeta, FileUploadOptions } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ export declare function FileMixin<TBase extends GConstructor<EntityServerClientBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ /**
6
+ * 파일을 업로드합니다. (multipart/form-data)
7
+ *
8
+ * ```ts
9
+ * const input = document.querySelector('input[type="file"]');
10
+ * const result = await client.fileUpload("product", input.files[0]);
11
+ * console.log(result.data.uuid);
12
+ * ```
13
+ */
14
+ fileUpload(entity: string, file: File | Blob, opts?: FileUploadOptions): Promise<{
15
+ ok: boolean;
16
+ uuid: string;
17
+ data: FileMeta;
18
+ }>;
19
+ /** 파일을 다운로드합니다. `ArrayBuffer`를 반환합니다. */
20
+ fileDownload(entity: string, uuid: string): Promise<ArrayBuffer>;
21
+ /** 파일을 삭제합니다. */
22
+ fileDelete(entity: string, uuid: string): Promise<{
23
+ ok: boolean;
24
+ uuid: string;
25
+ deleted: boolean;
26
+ }>;
27
+ /** 엔티티에 연결된 파일 목록을 조회합니다. */
28
+ fileList(entity: string, opts?: {
29
+ refSeq?: number;
30
+ }): Promise<{
31
+ ok: boolean;
32
+ data: {
33
+ items: FileMeta[];
34
+ total: number;
35
+ };
36
+ }>;
37
+ /** 파일 메타 정보를 조회합니다. */
38
+ fileMeta(entity: string, uuid: string): Promise<{
39
+ ok: boolean;
40
+ data: FileMeta;
41
+ }>;
42
+ /** 임시 파일 접근 토큰을 발급합니다. */
43
+ fileToken(uuid: string): Promise<{
44
+ ok: boolean;
45
+ token: string;
46
+ }>;
47
+ /** 파일 인라인 뷰 URL을 반환합니다. (fetch 없음, URL 조합만) */
48
+ fileUrl(uuid: string): string;
49
+ baseUrl: string;
50
+ token: string;
51
+ anonymousPacketToken: string;
52
+ apiKey: string;
53
+ hmacSecret: string;
54
+ encryptRequests: boolean;
55
+ activeTxId: string | null;
56
+ keepSession: boolean;
57
+ refreshBuffer: number;
58
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
59
+ onSessionExpired?: (error: Error) => void;
60
+ _sessionRefreshToken: string | null;
61
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
62
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
63
+ setToken(token: string): void;
64
+ setAnonymousPacketToken(token: string): void;
65
+ setApiKey(apiKey: string): void;
66
+ setHmacSecret(secret: string): void;
67
+ setEncryptRequests(value: boolean): void;
68
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
69
+ access_token: string;
70
+ expires_in: number;
71
+ }>): void;
72
+ _clearRefreshTimer(): void;
73
+ stopKeepSession(): void;
74
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
75
+ get _reqOpts(): import("../client/request").RequestOptions;
76
+ requestJson<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
77
+ requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
78
+ requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
79
+ requestFormBinary(method: string, path: string, form: FormData, withAuth?: boolean): Promise<ArrayBuffer>;
80
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
81
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
82
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
83
+ _requestFormBinary(method: string, path: string, form: FormData, withAuth?: boolean): Promise<ArrayBuffer>;
84
+ };
85
+ } & TBase;
@@ -0,0 +1,52 @@
1
+ import type { IdentityRequestOptions } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ export declare function IdentityMixin<TBase extends GConstructor<EntityServerClientBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ /** 본인인증 요청을 생성합니다. */
6
+ identityRequest(opts: IdentityRequestOptions): Promise<{
7
+ ok: boolean;
8
+ data: Record<string, unknown>;
9
+ }>;
10
+ /** 본인인증 결과를 조회합니다. */
11
+ identityResult(requestId: string): Promise<{
12
+ ok: boolean;
13
+ data: Record<string, unknown>;
14
+ }>;
15
+ /** CI 해시 중복 여부를 확인합니다. */
16
+ identityVerifyCI(ciHash: string): Promise<{
17
+ ok: boolean;
18
+ data: {
19
+ exists: boolean;
20
+ account_seq?: number;
21
+ };
22
+ }>;
23
+ baseUrl: string;
24
+ token: string;
25
+ apiKey: string;
26
+ hmacSecret: string;
27
+ encryptRequests: boolean;
28
+ activeTxId: string | null;
29
+ keepSession: boolean;
30
+ refreshBuffer: number;
31
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
32
+ onSessionExpired?: (error: Error) => void;
33
+ _sessionRefreshToken: string | null;
34
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
35
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
36
+ setToken(token: string): void;
37
+ setApiKey(apiKey: string): void;
38
+ setHmacSecret(secret: string): void;
39
+ setEncryptRequests(value: boolean): void;
40
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
41
+ access_token: string;
42
+ expires_in: number;
43
+ }>): void;
44
+ _clearRefreshTimer(): void;
45
+ stopKeepSession(): void;
46
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
47
+ get _reqOpts(): import("../client/request").RequestOptions;
48
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
49
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
50
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
51
+ };
52
+ } & TBase;
@@ -0,0 +1,94 @@
1
+ /**
2
+ * LlmMixin — LLM API 클라이언트 Mixin
3
+ *
4
+ * 설계문서 Section 14 기준 구현.
5
+ */
6
+ import type { LlmChatRequest, LlmChatResponse, LlmConversationCreateRequest, LlmConversationDetail, LlmConversationListResponse, LlmConversationUpdateRequest, LlmDocumentIngestRequest, LlmDocumentIngestResponse, LlmDocumentListResponse, LlmProvidersResponse, LlmRAGChatRequest, LlmRAGSearchRequest, LlmRAGSearchResponse, LlmUsageResponse, LlmUsageSummaryResponse, LlmCacheStats } from "../types";
7
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
8
+ export declare function LlmMixin<TBase extends GConstructor<EntityServerClientBase>>(Base: TBase): {
9
+ new (...args: any[]): {
10
+ /** SSE/스트리밍 응답을 위한 raw fetch — Response 객체 반환 */
11
+ _llmStream(path: string, body: unknown): Promise<Response>;
12
+ llmChat(req: LlmChatRequest): Promise<LlmChatResponse>;
13
+ llmChatStream(req: LlmChatRequest): Promise<Response>;
14
+ llmCreateConversation(req: LlmConversationCreateRequest): Promise<{
15
+ ok: boolean;
16
+ data: {
17
+ seq: number;
18
+ };
19
+ }>;
20
+ llmSendMessage(seq: number, req: LlmChatRequest): Promise<LlmChatResponse>;
21
+ llmListConversations(params?: {
22
+ page?: number;
23
+ limit?: number;
24
+ user_seq?: number;
25
+ }): Promise<LlmConversationListResponse>;
26
+ llmGetConversation(seq: number): Promise<LlmConversationDetail>;
27
+ llmUpdateConversation(seq: number, req: LlmConversationUpdateRequest): Promise<{
28
+ ok: boolean;
29
+ }>;
30
+ llmDeleteConversation(seq: number): Promise<{
31
+ ok: boolean;
32
+ }>;
33
+ llmGetProviders(): Promise<LlmProvidersResponse>;
34
+ llmGetUsage(params?: {
35
+ provider?: string;
36
+ start_date?: string;
37
+ end_date?: string;
38
+ }): Promise<LlmUsageResponse>;
39
+ llmGetUsageSummary(params?: {
40
+ provider?: string;
41
+ start_date?: string;
42
+ end_date?: string;
43
+ }): Promise<LlmUsageSummaryResponse>;
44
+ llmIngestDocument(req: LlmDocumentIngestRequest): Promise<LlmDocumentIngestResponse>;
45
+ llmListDocuments(params?: {
46
+ page?: number;
47
+ limit?: number;
48
+ }): Promise<LlmDocumentListResponse>;
49
+ llmDeleteDocument(id: string): Promise<{
50
+ ok: boolean;
51
+ }>;
52
+ llmSearchDocuments(req: LlmRAGSearchRequest): Promise<LlmRAGSearchResponse>;
53
+ llmChatWithRAG(req: LlmRAGChatRequest): Promise<LlmChatResponse>;
54
+ llmChatWithRAGStream(req: LlmRAGChatRequest): Promise<Response>;
55
+ llmRebuildRAGIndex(): Promise<{
56
+ ok: boolean;
57
+ }>;
58
+ llmGetCacheStats(): Promise<{
59
+ ok: boolean;
60
+ data: LlmCacheStats;
61
+ }>;
62
+ llmClearCache(): Promise<{
63
+ ok: boolean;
64
+ }>;
65
+ baseUrl: string;
66
+ token: string;
67
+ apiKey: string;
68
+ hmacSecret: string;
69
+ encryptRequests: boolean;
70
+ activeTxId: string | null;
71
+ keepSession: boolean;
72
+ refreshBuffer: number;
73
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
74
+ onSessionExpired?: (error: Error) => void;
75
+ _sessionRefreshToken: string | null;
76
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
77
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
78
+ setToken(token: string): void;
79
+ setApiKey(apiKey: string): void;
80
+ setHmacSecret(secret: string): void;
81
+ setEncryptRequests(value: boolean): void;
82
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
83
+ access_token: string;
84
+ expires_in: number;
85
+ }>): void;
86
+ _clearRefreshTimer(): void;
87
+ stopKeepSession(): void;
88
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
89
+ get _reqOpts(): import("../client/request").RequestOptions;
90
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
91
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
92
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
93
+ };
94
+ } & TBase;
@@ -0,0 +1,63 @@
1
+ import type { PgCreateOrderRequest, PgConfirmPaymentRequest, PgCancelPaymentRequest } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ export declare function PgMixin<TBase extends GConstructor<EntityServerClientBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ /** 결제 주문을 생성합니다. */
6
+ pgCreateOrder(req: PgCreateOrderRequest): Promise<{
7
+ ok: boolean;
8
+ data: Record<string, unknown>;
9
+ }>;
10
+ /** 주문 정보를 조회합니다. */
11
+ pgGetOrder(orderId: string): Promise<{
12
+ ok: boolean;
13
+ data: Record<string, unknown>;
14
+ }>;
15
+ /** 결제를 승인합니다. */
16
+ pgConfirmPayment(req: PgConfirmPaymentRequest): Promise<{
17
+ ok: boolean;
18
+ data: Record<string, unknown>;
19
+ }>;
20
+ /** 결제를 취소합니다. */
21
+ pgCancelPayment(orderId: string, req: PgCancelPaymentRequest): Promise<{
22
+ ok: boolean;
23
+ data: Record<string, unknown>;
24
+ }>;
25
+ /** 결제 상태를 외부 PG와 동기화합니다. */
26
+ pgSyncPayment(orderId: string): Promise<{
27
+ ok: boolean;
28
+ }>;
29
+ /** 클라이언트 SDK 설정을 반환합니다 (공개 API, 인증 불필요). */
30
+ pgConfig(): Promise<{
31
+ ok: boolean;
32
+ data: Record<string, unknown>;
33
+ }>;
34
+ baseUrl: string;
35
+ token: string;
36
+ apiKey: string;
37
+ hmacSecret: string;
38
+ encryptRequests: boolean;
39
+ activeTxId: string | null;
40
+ keepSession: boolean;
41
+ refreshBuffer: number;
42
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
43
+ onSessionExpired?: (error: Error) => void;
44
+ _sessionRefreshToken: string | null;
45
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
46
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
47
+ setToken(token: string): void;
48
+ setApiKey(apiKey: string): void;
49
+ setHmacSecret(secret: string): void;
50
+ setEncryptRequests(value: boolean): void;
51
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
52
+ access_token: string;
53
+ expires_in: number;
54
+ }>): void;
55
+ _clearRefreshTimer(): void;
56
+ stopKeepSession(): void;
57
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
58
+ get _reqOpts(): import("../client/request").RequestOptions;
59
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
60
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
61
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
62
+ };
63
+ } & TBase;
@@ -0,0 +1,101 @@
1
+ import type { EntityListParams, EntityListResult, RegisterPushDeviceOptions } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ type WithSubmit = EntityServerClientBase & {
4
+ submit(entity: string, data: Record<string, unknown>, opts?: {
5
+ transactionId?: string;
6
+ skipHooks?: boolean;
7
+ }): Promise<{
8
+ ok: boolean;
9
+ seq: number;
10
+ }>;
11
+ list<T = unknown>(entity: string, params?: EntityListParams): Promise<{
12
+ ok: boolean;
13
+ data: EntityListResult<T>;
14
+ }>;
15
+ };
16
+ export declare function PushMixin<TBase extends GConstructor<WithSubmit>>(Base: TBase): {
17
+ new (...args: any[]): {
18
+ /**
19
+ * 푸시 관련 엔티티로 payload를 전송(Submit)합니다.
20
+ * 내부적으로 `submit()` 메서드를 호출합니다.
21
+ */
22
+ push(pushEntity: string, payload: Record<string, unknown>, opts?: {
23
+ transactionId?: string;
24
+ }): Promise<{
25
+ ok: boolean;
26
+ seq: number;
27
+ }>;
28
+ /** 푸시 로그 엔티티 목록을 조회합니다. */
29
+ pushLogList<T = unknown>(params?: EntityListParams): Promise<{
30
+ ok: boolean;
31
+ data: EntityListResult<T>;
32
+ }>;
33
+ /** 계정의 푸시 디바이스를 등록합니다. */
34
+ registerPushDevice(accountSeq: number, deviceId: string, pushToken: string, opts?: RegisterPushDeviceOptions): Promise<{
35
+ ok: boolean;
36
+ seq: number;
37
+ }>;
38
+ /** 디바이스 레코드의 푸시 토큰을 갱신합니다. */
39
+ updatePushDeviceToken(deviceSeq: number, pushToken: string, opts?: {
40
+ pushEnabled?: boolean;
41
+ transactionId?: string;
42
+ }): Promise<{
43
+ ok: boolean;
44
+ seq: number;
45
+ }>;
46
+ /** 디바이스의 푸시 수신을 비활성화합니다. */
47
+ disablePushDevice(deviceSeq: number, opts?: {
48
+ transactionId?: string;
49
+ }): Promise<{
50
+ ok: boolean;
51
+ seq: number;
52
+ }>;
53
+ baseUrl: string;
54
+ token: string;
55
+ anonymousPacketToken: string;
56
+ apiKey: string;
57
+ hmacSecret: string;
58
+ encryptRequests: boolean;
59
+ activeTxId: string | null;
60
+ keepSession: boolean;
61
+ refreshBuffer: number;
62
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
63
+ onSessionExpired?: (error: Error) => void;
64
+ _sessionRefreshToken: string | null;
65
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
66
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
67
+ setToken(token: string): void;
68
+ setAnonymousPacketToken(token: string): void;
69
+ setApiKey(apiKey: string): void;
70
+ setHmacSecret(secret: string): void;
71
+ setEncryptRequests(value: boolean): void;
72
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
73
+ access_token: string;
74
+ expires_in: number;
75
+ }>): void;
76
+ _clearRefreshTimer(): void;
77
+ stopKeepSession(): void;
78
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
79
+ get _reqOpts(): import("../client/request").RequestOptions;
80
+ requestJson<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
81
+ requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
82
+ requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
83
+ requestFormBinary(method: string, path: string, form: FormData, withAuth?: boolean): Promise<ArrayBuffer>;
84
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
85
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
86
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
87
+ _requestFormBinary(method: string, path: string, form: FormData, withAuth?: boolean): Promise<ArrayBuffer>;
88
+ submit(entity: string, data: Record<string, unknown>, opts?: {
89
+ transactionId?: string;
90
+ skipHooks?: boolean;
91
+ }): Promise<{
92
+ ok: boolean;
93
+ seq: number;
94
+ }>;
95
+ list<T = unknown>(entity: string, params?: EntityListParams): Promise<{
96
+ ok: boolean;
97
+ data: EntityListResult<T>;
98
+ }>;
99
+ };
100
+ } & TBase;
101
+ export {};
@@ -0,0 +1,55 @@
1
+ import type { SmsSendRequest } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ export declare function SmsMixin<TBase extends GConstructor<EntityServerClientBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ /** SMS를 발송합니다. */
6
+ smsSend(req: SmsSendRequest): Promise<{
7
+ ok: boolean;
8
+ seq: number;
9
+ }>;
10
+ /** SMS 발송 상태를 조회합니다. */
11
+ smsStatus(seq: number): Promise<{
12
+ ok: boolean;
13
+ status: string;
14
+ }>;
15
+ /** SMS 인증 코드를 발송합니다. */
16
+ smsVerificationSend(phone: string, opts?: {
17
+ purpose?: string;
18
+ }): Promise<{
19
+ ok: boolean;
20
+ }>;
21
+ /** SMS 인증 코드를 검증합니다. */
22
+ smsVerificationVerify(phone: string, code: string): Promise<{
23
+ ok: boolean;
24
+ verified: boolean;
25
+ }>;
26
+ baseUrl: string;
27
+ token: string;
28
+ apiKey: string;
29
+ hmacSecret: string;
30
+ encryptRequests: boolean;
31
+ activeTxId: string | null;
32
+ keepSession: boolean;
33
+ refreshBuffer: number;
34
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
35
+ onSessionExpired?: (error: Error) => void;
36
+ _sessionRefreshToken: string | null;
37
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
38
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
39
+ setToken(token: string): void;
40
+ setApiKey(apiKey: string): void;
41
+ setHmacSecret(secret: string): void;
42
+ setEncryptRequests(value: boolean): void;
43
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
44
+ access_token: string;
45
+ expires_in: number;
46
+ }>): void;
47
+ _clearRefreshTimer(): void;
48
+ stopKeepSession(): void;
49
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
50
+ get _reqOpts(): import("../client/request").RequestOptions;
51
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
52
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
53
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
54
+ };
55
+ } & TBase;
@@ -0,0 +1,51 @@
1
+ import type { SmtpSendRequest } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ export declare function SmtpMixin<TBase extends GConstructor<EntityServerClientBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ /** SMTP로 메일을 발송합니다. */
6
+ smtpSend(req: SmtpSendRequest): Promise<{
7
+ ok: boolean;
8
+ seq: number;
9
+ }>;
10
+ /** SMTP 발송 상태를 조회합니다. */
11
+ smtpStatus(seq: number): Promise<{
12
+ ok: boolean;
13
+ status: string;
14
+ }>;
15
+ baseUrl: string;
16
+ token: string;
17
+ anonymousPacketToken: string;
18
+ apiKey: string;
19
+ hmacSecret: string;
20
+ encryptRequests: boolean;
21
+ activeTxId: string | null;
22
+ keepSession: boolean;
23
+ refreshBuffer: number;
24
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
25
+ onSessionExpired?: (error: Error) => void;
26
+ _sessionRefreshToken: string | null;
27
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
28
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
29
+ setToken(token: string): void;
30
+ setAnonymousPacketToken(token: string): void;
31
+ setApiKey(apiKey: string): void;
32
+ setHmacSecret(secret: string): void;
33
+ setEncryptRequests(value: boolean): void;
34
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
35
+ access_token: string;
36
+ expires_in: number;
37
+ }>): void;
38
+ _clearRefreshTimer(): void;
39
+ stopKeepSession(): void;
40
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
41
+ get _reqOpts(): import("../client/request").RequestOptions;
42
+ requestJson<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
43
+ requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
44
+ requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
45
+ requestFormBinary(method: string, path: string, form: FormData, withAuth?: boolean): Promise<ArrayBuffer>;
46
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
47
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
48
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
49
+ _requestFormBinary(method: string, path: string, form: FormData, withAuth?: boolean): Promise<ArrayBuffer>;
50
+ };
51
+ } & TBase;
@@ -0,0 +1,88 @@
1
+ import type { QRCodeOptions, BarcodeOptions, Pdf2PngOptions } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ export declare function UtilsMixin<TBase extends GConstructor<EntityServerClientBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ /**
6
+ * QR 코드 PNG를 생성합니다. `ArrayBuffer`를 반환합니다.
7
+ *
8
+ * ```ts
9
+ * const buf = await client.qrcode("https://example.com");
10
+ * const blob = new Blob([buf], { type: "image/png" });
11
+ * img.src = URL.createObjectURL(blob);
12
+ * ```
13
+ */
14
+ qrcode(content: string, opts?: QRCodeOptions): Promise<ArrayBuffer>;
15
+ /**
16
+ * QR 코드를 base64/data URI JSON으로 반환합니다.
17
+ *
18
+ * ```ts
19
+ * const { data_uri } = await client.qrcodeBase64("https://example.com");
20
+ * img.src = data_uri;
21
+ * ```
22
+ */
23
+ qrcodeBase64(content: string, opts?: QRCodeOptions): Promise<{
24
+ ok: boolean;
25
+ data: string;
26
+ data_uri: string;
27
+ }>;
28
+ /** QR 코드를 ASCII 아트 텍스트로 반환합니다. */
29
+ qrcodeText(content: string, opts?: QRCodeOptions): Promise<{
30
+ ok: boolean;
31
+ text: string;
32
+ }>;
33
+ /**
34
+ * 바코드 PNG를 생성합니다. `ArrayBuffer`를 반환합니다.
35
+ *
36
+ * ```ts
37
+ * const buf = await client.barcode("1234567890128", { type: "ean13" });
38
+ * ```
39
+ */
40
+ barcode(content: string, opts?: BarcodeOptions): Promise<ArrayBuffer>;
41
+ /**
42
+ * PDF를 PNG 이미지로 변환합니다.
43
+ *
44
+ * 단일 페이지 요청이면 `image/png` ArrayBuffer,
45
+ * 다중 페이지 요청이면 `application/zip` ArrayBuffer를 반환합니다.
46
+ *
47
+ * ```ts
48
+ * const buf = await client.pdf2png(pdfArrayBuffer, { dpi: 200 });
49
+ * ```
50
+ */
51
+ pdf2png(pdfData: ArrayBuffer | Uint8Array<ArrayBuffer>, opts?: Pdf2PngOptions): Promise<ArrayBuffer>;
52
+ baseUrl: string;
53
+ token: string;
54
+ anonymousPacketToken: string;
55
+ apiKey: string;
56
+ hmacSecret: string;
57
+ encryptRequests: boolean;
58
+ activeTxId: string | null;
59
+ keepSession: boolean;
60
+ refreshBuffer: number;
61
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
62
+ onSessionExpired?: (error: Error) => void;
63
+ _sessionRefreshToken: string | null;
64
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
65
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
66
+ setToken(token: string): void;
67
+ setAnonymousPacketToken(token: string): void;
68
+ setApiKey(apiKey: string): void;
69
+ setHmacSecret(secret: string): void;
70
+ setEncryptRequests(value: boolean): void;
71
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
72
+ access_token: string;
73
+ expires_in: number;
74
+ }>): void;
75
+ _clearRefreshTimer(): void;
76
+ stopKeepSession(): void;
77
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
78
+ get _reqOpts(): import("../client/request").RequestOptions;
79
+ requestJson<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
80
+ requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
81
+ requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
82
+ requestFormBinary(method: string, path: string, form: FormData, withAuth?: boolean): Promise<ArrayBuffer>;
83
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
84
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
85
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
86
+ _requestFormBinary(method: string, path: string, form: FormData, withAuth?: boolean): Promise<ArrayBuffer>;
87
+ };
88
+ } & TBase;
@@ -0,0 +1,11 @@
1
+ export declare const PACKET_KEY_SIZE = 32;
2
+ export declare const PACKET_MAGIC_MIN = 2;
3
+ export declare const PACKET_MAGIC_RANGE = 14;
4
+ export declare const PACKET_NONCE_SIZE = 24;
5
+ export declare const PACKET_TAG_SIZE = 16;
6
+ export declare const PACKET_HKDF_SALT = "entity-server:hkdf:v1";
7
+ export declare const PACKET_INFO_LABEL = "entity-server:packet-encryption";
8
+ export declare function derivePacketKey(source: string, infoLabel?: string): Uint8Array;
9
+ export declare function packetMagicLenFromKey(key: ArrayBuffer | Uint8Array, magicMin?: number, magicRange?: number): number;
10
+ export declare function encryptPacket(plaintext: ArrayBuffer | Uint8Array, key: ArrayBuffer | Uint8Array, magicMin?: number, magicRange?: number): Uint8Array;
11
+ export declare function decryptPacket(buffer: ArrayBuffer | Uint8Array, key: ArrayBuffer | Uint8Array, magicMin?: number, magicRange?: number): Uint8Array;
package/dist/packet.js ADDED
@@ -0,0 +1,2 @@
1
+ import{xchacha20poly1305 as h}from"@noble/ciphers/chacha";import{sha256 as d}from"@noble/hashes/sha2";import{hkdf as m}from"@noble/hashes/hkdf";var f=32,u=2,E=14,o=24,T=16,k="entity-server:hkdf:v1",B="entity-server:packet-encryption";function s(r){return r instanceof Uint8Array?r:new Uint8Array(r)}function P(r,e=B){return m(d,new TextEncoder().encode(r),new TextEncoder().encode(k),new TextEncoder().encode(e),f)}function U(r,e=u,c=E){let n=s(r);return n.length<f?e:e+n[f-1]%c}function g(r,e,c=u,n=E){let i=s(r),y=s(e),t=U(y,c,n),p=crypto.getRandomValues(new Uint8Array(t)),a=crypto.getRandomValues(new Uint8Array(o)),x=h(y,a).encrypt(i),A=new Uint8Array(t+o+x.length);return A.set(p,0),A.set(a,t),A.set(x,t+o),A}function w(r,e,c=u,n=E){let i=s(r),y=s(e),t=U(y,c,n);if(i.length<t+o+T)throw new Error("Encrypted packet too short");let p=i.slice(t,t+o),a=i.slice(t+o);return h(y,p).decrypt(a)}export{k as PACKET_HKDF_SALT,B as PACKET_INFO_LABEL,f as PACKET_KEY_SIZE,u as PACKET_MAGIC_MIN,E as PACKET_MAGIC_RANGE,o as PACKET_NONCE_SIZE,T as PACKET_TAG_SIZE,w as decryptPacket,P as derivePacketKey,g as encryptPacket,U as packetMagicLenFromKey};
2
+ //# sourceMappingURL=packet.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/packet.ts"],
4
+ "sourcesContent": ["// @ts-ignore\nimport { xchacha20poly1305 } from \"@noble/ciphers/chacha\";\n// @ts-ignore\nimport { sha256 } from \"@noble/hashes/sha2\";\n// @ts-ignore\nimport { hkdf } from \"@noble/hashes/hkdf\";\n\nexport const PACKET_KEY_SIZE = 32;\nexport const PACKET_MAGIC_MIN = 2;\nexport const PACKET_MAGIC_RANGE = 14;\nexport const PACKET_NONCE_SIZE = 24;\nexport const PACKET_TAG_SIZE = 16;\nexport const PACKET_HKDF_SALT = \"entity-server:hkdf:v1\";\nexport const PACKET_INFO_LABEL = \"entity-server:packet-encryption\";\n\nfunction toUint8Array(data: ArrayBuffer | Uint8Array): Uint8Array {\n return data instanceof Uint8Array ? data : new Uint8Array(data);\n}\n\nexport function derivePacketKey(\n source: string,\n infoLabel = PACKET_INFO_LABEL,\n): Uint8Array {\n return hkdf(\n sha256,\n new TextEncoder().encode(source),\n new TextEncoder().encode(PACKET_HKDF_SALT),\n new TextEncoder().encode(infoLabel),\n PACKET_KEY_SIZE,\n );\n}\n\nexport function packetMagicLenFromKey(\n key: ArrayBuffer | Uint8Array,\n magicMin = PACKET_MAGIC_MIN,\n magicRange = PACKET_MAGIC_RANGE,\n): number {\n const keyBytes = toUint8Array(key);\n if (keyBytes.length < PACKET_KEY_SIZE) return magicMin;\n return magicMin + (keyBytes[PACKET_KEY_SIZE - 1]! % magicRange);\n}\n\nexport function encryptPacket(\n plaintext: ArrayBuffer | Uint8Array,\n key: ArrayBuffer | Uint8Array,\n magicMin = PACKET_MAGIC_MIN,\n magicRange = PACKET_MAGIC_RANGE,\n): Uint8Array {\n const plaintextBytes = toUint8Array(plaintext);\n const keyBytes = toUint8Array(key);\n const magicLen = packetMagicLenFromKey(keyBytes, magicMin, magicRange);\n const magic = crypto.getRandomValues(new Uint8Array(magicLen));\n const nonce = crypto.getRandomValues(new Uint8Array(PACKET_NONCE_SIZE));\n const cipher = xchacha20poly1305(keyBytes, nonce);\n const ciphertext = cipher.encrypt(plaintextBytes);\n const result = new Uint8Array(\n magicLen + PACKET_NONCE_SIZE + ciphertext.length,\n );\n\n result.set(magic, 0);\n result.set(nonce, magicLen);\n result.set(ciphertext, magicLen + PACKET_NONCE_SIZE);\n return result;\n}\n\nexport function decryptPacket(\n buffer: ArrayBuffer | Uint8Array,\n key: ArrayBuffer | Uint8Array,\n magicMin = PACKET_MAGIC_MIN,\n magicRange = PACKET_MAGIC_RANGE,\n): Uint8Array {\n const data = toUint8Array(buffer);\n const keyBytes = toUint8Array(key);\n const magicLen = packetMagicLenFromKey(keyBytes, magicMin, magicRange);\n\n if (data.length < magicLen + PACKET_NONCE_SIZE + PACKET_TAG_SIZE) {\n throw new Error(\"Encrypted packet too short\");\n }\n\n const nonce = data.slice(magicLen, magicLen + PACKET_NONCE_SIZE);\n const ciphertext = data.slice(magicLen + PACKET_NONCE_SIZE);\n const cipher = xchacha20poly1305(keyBytes, nonce);\n return cipher.decrypt(ciphertext);\n}\n"],
5
+ "mappings": "AACA,OAAS,qBAAAA,MAAyB,wBAElC,OAAS,UAAAC,MAAc,qBAEvB,OAAS,QAAAC,MAAY,qBAEd,IAAMC,EAAkB,GAClBC,EAAmB,EACnBC,EAAqB,GACrBC,EAAoB,GACpBC,EAAkB,GAClBC,EAAmB,wBACnBC,EAAoB,kCAEjC,SAASC,EAAaC,EAA4C,CAC9D,OAAOA,aAAgB,WAAaA,EAAO,IAAI,WAAWA,CAAI,CAClE,CAEO,SAASC,EACZC,EACAC,EAAYL,EACF,CACV,OAAOP,EACHD,EACA,IAAI,YAAY,EAAE,OAAOY,CAAM,EAC/B,IAAI,YAAY,EAAE,OAAOL,CAAgB,EACzC,IAAI,YAAY,EAAE,OAAOM,CAAS,EAClCX,CACJ,CACJ,CAEO,SAASY,EACZC,EACAC,EAAWb,EACXc,EAAab,EACP,CACN,IAAMc,EAAWT,EAAaM,CAAG,EACjC,OAAIG,EAAS,OAAShB,EAAwBc,EACvCA,EAAYE,EAAShB,EAAkB,CAAC,EAAKe,CACxD,CAEO,SAASE,EACZC,EACAL,EACAC,EAAWb,EACXc,EAAab,EACH,CACV,IAAMiB,EAAiBZ,EAAaW,CAAS,EACvCF,EAAWT,EAAaM,CAAG,EAC3BO,EAAWR,EAAsBI,EAAUF,EAAUC,CAAU,EAC/DM,EAAQ,OAAO,gBAAgB,IAAI,WAAWD,CAAQ,CAAC,EACvDE,EAAQ,OAAO,gBAAgB,IAAI,WAAWnB,CAAiB,CAAC,EAEhEoB,EADS1B,EAAkBmB,EAAUM,CAAK,EACtB,QAAQH,CAAc,EAC1CK,EAAS,IAAI,WACfJ,EAAWjB,EAAoBoB,EAAW,MAC9C,EAEA,OAAAC,EAAO,IAAIH,EAAO,CAAC,EACnBG,EAAO,IAAIF,EAAOF,CAAQ,EAC1BI,EAAO,IAAID,EAAYH,EAAWjB,CAAiB,EAC5CqB,CACX,CAEO,SAASC,EACZC,EACAb,EACAC,EAAWb,EACXc,EAAab,EACH,CACV,IAAMM,EAAOD,EAAamB,CAAM,EAC1BV,EAAWT,EAAaM,CAAG,EAC3BO,EAAWR,EAAsBI,EAAUF,EAAUC,CAAU,EAErE,GAAIP,EAAK,OAASY,EAAWjB,EAAoBC,EAC7C,MAAM,IAAI,MAAM,4BAA4B,EAGhD,IAAMkB,EAAQd,EAAK,MAAMY,EAAUA,EAAWjB,CAAiB,EACzDoB,EAAaf,EAAK,MAAMY,EAAWjB,CAAiB,EAE1D,OADeN,EAAkBmB,EAAUM,CAAK,EAClC,QAAQC,CAAU,CACpC",
6
+ "names": ["xchacha20poly1305", "sha256", "hkdf", "PACKET_KEY_SIZE", "PACKET_MAGIC_MIN", "PACKET_MAGIC_RANGE", "PACKET_NONCE_SIZE", "PACKET_TAG_SIZE", "PACKET_HKDF_SALT", "PACKET_INFO_LABEL", "toUint8Array", "data", "derivePacketKey", "source", "infoLabel", "packetMagicLenFromKey", "key", "magicMin", "magicRange", "keyBytes", "encryptPacket", "plaintext", "plaintextBytes", "magicLen", "magic", "nonce", "ciphertext", "result", "decryptPacket", "buffer"]
7
+ }