entity-client 1.0.19 → 1.0.21

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 (73) hide show
  1. package/README.md +362 -362
  2. package/dist/EntityAppServerApi.d.ts +32 -16
  3. package/dist/EntityAppServerApi.js.map +1 -1
  4. package/dist/EntityServerApi.d.ts +16 -8
  5. package/dist/EntityServerApi.js.map +1 -1
  6. package/dist/client/base.d.ts +4 -1
  7. package/dist/client/base.js +1 -1
  8. package/dist/client/base.js.map +3 -3
  9. package/dist/client/hmac.js.map +1 -1
  10. package/dist/client/packet.js.map +1 -1
  11. package/dist/client/request.js.map +1 -1
  12. package/dist/client/utils.js.map +1 -1
  13. package/dist/hooks/useEntityAppServer.js.map +1 -1
  14. package/dist/hooks/useEntityClient.js.map +1 -1
  15. package/dist/hooks/useEntityServer.js.map +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/index.js.map +3 -3
  18. package/dist/mixins/app/index.js.map +1 -1
  19. package/dist/mixins/app/plugins/alimtalk.d.ts +2 -1
  20. package/dist/mixins/app/plugins/alimtalk.js.map +1 -1
  21. package/dist/mixins/app/plugins/friendtalk.d.ts +2 -1
  22. package/dist/mixins/app/plugins/friendtalk.js.map +1 -1
  23. package/dist/mixins/app/plugins/holidays.d.ts +2 -1
  24. package/dist/mixins/app/plugins/holidays.js.map +1 -1
  25. package/dist/mixins/app/plugins/identity.d.ts +2 -1
  26. package/dist/mixins/app/plugins/identity.js.map +1 -1
  27. package/dist/mixins/app/plugins/index.js.map +1 -1
  28. package/dist/mixins/app/plugins/llm.d.ts +2 -1
  29. package/dist/mixins/app/plugins/llm.js.map +1 -1
  30. package/dist/mixins/app/plugins/ocr.d.ts +2 -1
  31. package/dist/mixins/app/plugins/ocr.js.map +1 -1
  32. package/dist/mixins/app/plugins/pg.d.ts +2 -1
  33. package/dist/mixins/app/plugins/pg.js.map +1 -1
  34. package/dist/mixins/app/plugins/push.d.ts +2 -1
  35. package/dist/mixins/app/plugins/push.js.map +1 -1
  36. package/dist/mixins/app/plugins/sms.d.ts +2 -1
  37. package/dist/mixins/app/plugins/sms.js.map +1 -1
  38. package/dist/mixins/app/plugins/taxinvoice.d.ts +2 -1
  39. package/dist/mixins/app/plugins/taxinvoice.js.map +1 -1
  40. package/dist/mixins/app/routes/account.d.ts +2 -1
  41. package/dist/mixins/app/routes/account.js.map +1 -1
  42. package/dist/mixins/app/routes/board.d.ts +2 -1
  43. package/dist/mixins/app/routes/board.js.map +1 -1
  44. package/dist/mixins/app/routes/email-verify.d.ts +2 -1
  45. package/dist/mixins/app/routes/email-verify.js.map +1 -1
  46. package/dist/mixins/app/routes/oauth.d.ts +2 -1
  47. package/dist/mixins/app/routes/oauth.js.map +1 -1
  48. package/dist/mixins/app/routes/password-reset.d.ts +2 -1
  49. package/dist/mixins/app/routes/password-reset.js.map +1 -1
  50. package/dist/mixins/app/routes/two-factor.d.ts +2 -1
  51. package/dist/mixins/app/routes/two-factor.js.map +1 -1
  52. package/dist/mixins/server/admin.d.ts +2 -1
  53. package/dist/mixins/server/admin.js.map +1 -1
  54. package/dist/mixins/server/auth.d.ts +3 -1
  55. package/dist/mixins/server/auth.js +1 -1
  56. package/dist/mixins/server/auth.js.map +3 -3
  57. package/dist/mixins/server/entity.d.ts +2 -1
  58. package/dist/mixins/server/entity.js.map +1 -1
  59. package/dist/mixins/server/file.d.ts +2 -1
  60. package/dist/mixins/server/file.js.map +1 -1
  61. package/dist/mixins/server/index.js.map +1 -1
  62. package/dist/mixins/server/push.d.ts +2 -1
  63. package/dist/mixins/server/push.js.map +1 -1
  64. package/dist/mixins/server/smtp.d.ts +2 -1
  65. package/dist/mixins/server/smtp.js.map +1 -1
  66. package/dist/mixins/server/transaction.d.ts +2 -1
  67. package/dist/mixins/server/transaction.js.map +1 -1
  68. package/dist/mixins/server/utils.d.ts +2 -1
  69. package/dist/mixins/server/utils.js.map +1 -1
  70. package/dist/packet.js.map +1 -1
  71. package/dist/react.js +1 -1
  72. package/dist/react.js.map +3 -3
  73. package/package.json +57 -57
@@ -40,6 +40,7 @@ declare const EntityAppServerApi_base: {
40
40
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
41
41
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
42
42
  setToken(token: string): void;
43
+ setAccessTokenFromResponse(token: string): void;
43
44
  setAnonymousPacketToken(token: string): void;
44
45
  setApiKey(apiKey: string): void;
45
46
  setHmacSecret(secret: string): void;
@@ -56,7 +57,7 @@ declare const EntityAppServerApi_base: {
56
57
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
57
58
  subscribeRealtime(subscriptions: string[]): boolean;
58
59
  unsubscribeRealtime(subscriptions: string[]): boolean;
59
- startHealthTick(intervalMs?: number): void;
60
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
60
61
  stopHealthTick(): void;
61
62
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
62
63
  access_token: string;
@@ -124,6 +125,7 @@ declare const EntityAppServerApi_base: {
124
125
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
125
126
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
126
127
  setToken(token: string): void;
128
+ setAccessTokenFromResponse(token: string): void;
127
129
  setAnonymousPacketToken(token: string): void;
128
130
  setApiKey(apiKey: string): void;
129
131
  setHmacSecret(secret: string): void;
@@ -140,7 +142,7 @@ declare const EntityAppServerApi_base: {
140
142
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
141
143
  subscribeRealtime(subscriptions: string[]): boolean;
142
144
  unsubscribeRealtime(subscriptions: string[]): boolean;
143
- startHealthTick(intervalMs?: number): void;
145
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
144
146
  stopHealthTick(): void;
145
147
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
146
148
  access_token: string;
@@ -211,6 +213,7 @@ declare const EntityAppServerApi_base: {
211
213
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
212
214
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
213
215
  setToken(token: string): void;
216
+ setAccessTokenFromResponse(token: string): void;
214
217
  setAnonymousPacketToken(token: string): void;
215
218
  setApiKey(apiKey: string): void;
216
219
  setHmacSecret(secret: string): void;
@@ -227,7 +230,7 @@ declare const EntityAppServerApi_base: {
227
230
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
228
231
  subscribeRealtime(subscriptions: string[]): boolean;
229
232
  unsubscribeRealtime(subscriptions: string[]): boolean;
230
- startHealthTick(intervalMs?: number): void;
233
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
231
234
  stopHealthTick(): void;
232
235
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
233
236
  access_token: string;
@@ -299,6 +302,7 @@ declare const EntityAppServerApi_base: {
299
302
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
300
303
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
301
304
  setToken(token: string): void;
305
+ setAccessTokenFromResponse(token: string): void;
302
306
  setAnonymousPacketToken(token: string): void;
303
307
  setApiKey(apiKey: string): void;
304
308
  setHmacSecret(secret: string): void;
@@ -315,7 +319,7 @@ declare const EntityAppServerApi_base: {
315
319
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
316
320
  subscribeRealtime(subscriptions: string[]): boolean;
317
321
  unsubscribeRealtime(subscriptions: string[]): boolean;
318
- startHealthTick(intervalMs?: number): void;
322
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
319
323
  stopHealthTick(): void;
320
324
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
321
325
  access_token: string;
@@ -389,6 +393,7 @@ declare const EntityAppServerApi_base: {
389
393
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
390
394
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
391
395
  setToken(token: string): void;
396
+ setAccessTokenFromResponse(token: string): void;
392
397
  setAnonymousPacketToken(token: string): void;
393
398
  setApiKey(apiKey: string): void;
394
399
  setHmacSecret(secret: string): void;
@@ -405,7 +410,7 @@ declare const EntityAppServerApi_base: {
405
410
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
406
411
  subscribeRealtime(subscriptions: string[]): boolean;
407
412
  unsubscribeRealtime(subscriptions: string[]): boolean;
408
- startHealthTick(intervalMs?: number): void;
413
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
409
414
  stopHealthTick(): void;
410
415
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
411
416
  access_token: string;
@@ -478,6 +483,7 @@ declare const EntityAppServerApi_base: {
478
483
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
479
484
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
480
485
  setToken(token: string): void;
486
+ setAccessTokenFromResponse(token: string): void;
481
487
  setAnonymousPacketToken(token: string): void;
482
488
  setApiKey(apiKey: string): void;
483
489
  setHmacSecret(secret: string): void;
@@ -494,7 +500,7 @@ declare const EntityAppServerApi_base: {
494
500
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
495
501
  subscribeRealtime(subscriptions: string[]): boolean;
496
502
  unsubscribeRealtime(subscriptions: string[]): boolean;
497
- startHealthTick(intervalMs?: number): void;
503
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
498
504
  stopHealthTick(): void;
499
505
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
500
506
  access_token: string;
@@ -569,6 +575,7 @@ declare const EntityAppServerApi_base: {
569
575
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
570
576
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
571
577
  setToken(token: string): void;
578
+ setAccessTokenFromResponse(token: string): void;
572
579
  setAnonymousPacketToken(token: string): void;
573
580
  setApiKey(apiKey: string): void;
574
581
  setHmacSecret(secret: string): void;
@@ -585,7 +592,7 @@ declare const EntityAppServerApi_base: {
585
592
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
586
593
  subscribeRealtime(subscriptions: string[]): boolean;
587
594
  unsubscribeRealtime(subscriptions: string[]): boolean;
588
- startHealthTick(intervalMs?: number): void;
595
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
589
596
  stopHealthTick(): void;
590
597
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
591
598
  access_token: string;
@@ -687,6 +694,7 @@ declare const EntityAppServerApi_base: {
687
694
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
688
695
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
689
696
  setToken(token: string): void;
697
+ setAccessTokenFromResponse(token: string): void;
690
698
  setAnonymousPacketToken(token: string): void;
691
699
  setApiKey(apiKey: string): void;
692
700
  setHmacSecret(secret: string): void;
@@ -703,7 +711,7 @@ declare const EntityAppServerApi_base: {
703
711
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
704
712
  subscribeRealtime(subscriptions: string[]): boolean;
705
713
  unsubscribeRealtime(subscriptions: string[]): boolean;
706
- startHealthTick(intervalMs?: number): void;
714
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
707
715
  stopHealthTick(): void;
708
716
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
709
717
  access_token: string;
@@ -774,6 +782,7 @@ declare const EntityAppServerApi_base: {
774
782
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
775
783
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
776
784
  setToken(token: string): void;
785
+ setAccessTokenFromResponse(token: string): void;
777
786
  setAnonymousPacketToken(token: string): void;
778
787
  setApiKey(apiKey: string): void;
779
788
  setHmacSecret(secret: string): void;
@@ -790,7 +799,7 @@ declare const EntityAppServerApi_base: {
790
799
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
791
800
  subscribeRealtime(subscriptions: string[]): boolean;
792
801
  unsubscribeRealtime(subscriptions: string[]): boolean;
793
- startHealthTick(intervalMs?: number): void;
802
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
794
803
  stopHealthTick(): void;
795
804
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
796
805
  access_token: string;
@@ -864,6 +873,7 @@ declare const EntityAppServerApi_base: {
864
873
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
865
874
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
866
875
  setToken(token: string): void;
876
+ setAccessTokenFromResponse(token: string): void;
867
877
  setAnonymousPacketToken(token: string): void;
868
878
  setApiKey(apiKey: string): void;
869
879
  setHmacSecret(secret: string): void;
@@ -880,7 +890,7 @@ declare const EntityAppServerApi_base: {
880
890
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
881
891
  subscribeRealtime(subscriptions: string[]): boolean;
882
892
  unsubscribeRealtime(subscriptions: string[]): boolean;
883
- startHealthTick(intervalMs?: number): void;
893
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
884
894
  stopHealthTick(): void;
885
895
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
886
896
  access_token: string;
@@ -953,6 +963,7 @@ declare const EntityAppServerApi_base: {
953
963
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
954
964
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
955
965
  setToken(token: string): void;
966
+ setAccessTokenFromResponse(token: string): void;
956
967
  setAnonymousPacketToken(token: string): void;
957
968
  setApiKey(apiKey: string): void;
958
969
  setHmacSecret(secret: string): void;
@@ -969,7 +980,7 @@ declare const EntityAppServerApi_base: {
969
980
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
970
981
  subscribeRealtime(subscriptions: string[]): boolean;
971
982
  unsubscribeRealtime(subscriptions: string[]): boolean;
972
- startHealthTick(intervalMs?: number): void;
983
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
973
984
  stopHealthTick(): void;
974
985
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
975
986
  access_token: string;
@@ -1043,6 +1054,7 @@ declare const EntityAppServerApi_base: {
1043
1054
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
1044
1055
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
1045
1056
  setToken(token: string): void;
1057
+ setAccessTokenFromResponse(token: string): void;
1046
1058
  setAnonymousPacketToken(token: string): void;
1047
1059
  setApiKey(apiKey: string): void;
1048
1060
  setHmacSecret(secret: string): void;
@@ -1059,7 +1071,7 @@ declare const EntityAppServerApi_base: {
1059
1071
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
1060
1072
  subscribeRealtime(subscriptions: string[]): boolean;
1061
1073
  unsubscribeRealtime(subscriptions: string[]): boolean;
1062
- startHealthTick(intervalMs?: number): void;
1074
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
1063
1075
  stopHealthTick(): void;
1064
1076
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
1065
1077
  access_token: string;
@@ -1131,6 +1143,7 @@ declare const EntityAppServerApi_base: {
1131
1143
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
1132
1144
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
1133
1145
  setToken(token: string): void;
1146
+ setAccessTokenFromResponse(token: string): void;
1134
1147
  setAnonymousPacketToken(token: string): void;
1135
1148
  setApiKey(apiKey: string): void;
1136
1149
  setHmacSecret(secret: string): void;
@@ -1147,7 +1160,7 @@ declare const EntityAppServerApi_base: {
1147
1160
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
1148
1161
  subscribeRealtime(subscriptions: string[]): boolean;
1149
1162
  unsubscribeRealtime(subscriptions: string[]): boolean;
1150
- startHealthTick(intervalMs?: number): void;
1163
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
1151
1164
  stopHealthTick(): void;
1152
1165
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
1153
1166
  access_token: string;
@@ -1219,6 +1232,7 @@ declare const EntityAppServerApi_base: {
1219
1232
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
1220
1233
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
1221
1234
  setToken(token: string): void;
1235
+ setAccessTokenFromResponse(token: string): void;
1222
1236
  setAnonymousPacketToken(token: string): void;
1223
1237
  setApiKey(apiKey: string): void;
1224
1238
  setHmacSecret(secret: string): void;
@@ -1235,7 +1249,7 @@ declare const EntityAppServerApi_base: {
1235
1249
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
1236
1250
  subscribeRealtime(subscriptions: string[]): boolean;
1237
1251
  unsubscribeRealtime(subscriptions: string[]): boolean;
1238
- startHealthTick(intervalMs?: number): void;
1252
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
1239
1253
  stopHealthTick(): void;
1240
1254
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
1241
1255
  access_token: string;
@@ -1335,6 +1349,7 @@ declare const EntityAppServerApi_base: {
1335
1349
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
1336
1350
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
1337
1351
  setToken(token: string): void;
1352
+ setAccessTokenFromResponse(token: string): void;
1338
1353
  setAnonymousPacketToken(token: string): void;
1339
1354
  setApiKey(apiKey: string): void;
1340
1355
  setHmacSecret(secret: string): void;
@@ -1351,7 +1366,7 @@ declare const EntityAppServerApi_base: {
1351
1366
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
1352
1367
  subscribeRealtime(subscriptions: string[]): boolean;
1353
1368
  unsubscribeRealtime(subscriptions: string[]): boolean;
1354
- startHealthTick(intervalMs?: number): void;
1369
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
1355
1370
  stopHealthTick(): void;
1356
1371
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
1357
1372
  access_token: string;
@@ -1428,6 +1443,7 @@ declare const EntityAppServerApi_base: {
1428
1443
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
1429
1444
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
1430
1445
  setToken(token: string): void;
1446
+ setAccessTokenFromResponse(token: string): void;
1431
1447
  setAnonymousPacketToken(token: string): void;
1432
1448
  setApiKey(apiKey: string): void;
1433
1449
  setHmacSecret(secret: string): void;
@@ -1444,7 +1460,7 @@ declare const EntityAppServerApi_base: {
1444
1460
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
1445
1461
  subscribeRealtime(subscriptions: string[]): boolean;
1446
1462
  unsubscribeRealtime(subscriptions: string[]): boolean;
1447
- startHealthTick(intervalMs?: number): void;
1463
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
1448
1464
  stopHealthTick(): void;
1449
1465
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
1450
1466
  access_token: string;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/EntityAppServerApi.ts"],
4
- "sourcesContent": ["import { EntityServerApi } from \"./EntityServerApi.js\";\nimport {\n AccountAppMixin,\n BoardMixin,\n EmailVerifyMixin,\n OAuthMixin,\n PasswordResetMixin,\n TwoFactorMixin,\n} from \"./mixins/app/index.js\";\nimport {\n AlimtalkMixin,\n AppPushMixin,\n FriendtalkMixin,\n HolidaysMixin,\n IdentityMixin,\n LlmMixin,\n OcrMixin,\n PgMixin,\n SmsMixin,\n TaxinvoiceMixin,\n} from \"./mixins/app/plugins/index.js\";\n\nexport class EntityAppServerApi extends AlimtalkMixin(\n FriendtalkMixin(\n SmsMixin(\n AppPushMixin(\n PgMixin(\n TaxinvoiceMixin(\n OcrMixin(\n LlmMixin(\n IdentityMixin(\n HolidaysMixin(\n OAuthMixin(\n TwoFactorMixin(\n PasswordResetMixin(\n EmailVerifyMixin(\n BoardMixin(\n AccountAppMixin(\n EntityServerApi,\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n ),\n) {}\n"],
4
+ "sourcesContent": ["import { EntityServerApi } from \"./EntityServerApi.js\";\r\nimport {\r\n AccountAppMixin,\r\n BoardMixin,\r\n EmailVerifyMixin,\r\n OAuthMixin,\r\n PasswordResetMixin,\r\n TwoFactorMixin,\r\n} from \"./mixins/app/index.js\";\r\nimport {\r\n AlimtalkMixin,\r\n AppPushMixin,\r\n FriendtalkMixin,\r\n HolidaysMixin,\r\n IdentityMixin,\r\n LlmMixin,\r\n OcrMixin,\r\n PgMixin,\r\n SmsMixin,\r\n TaxinvoiceMixin,\r\n} from \"./mixins/app/plugins/index.js\";\r\n\r\nexport class EntityAppServerApi extends AlimtalkMixin(\r\n FriendtalkMixin(\r\n SmsMixin(\r\n AppPushMixin(\r\n PgMixin(\r\n TaxinvoiceMixin(\r\n OcrMixin(\r\n LlmMixin(\r\n IdentityMixin(\r\n HolidaysMixin(\r\n OAuthMixin(\r\n TwoFactorMixin(\r\n PasswordResetMixin(\r\n EmailVerifyMixin(\r\n BoardMixin(\r\n AccountAppMixin(\r\n EntityServerApi,\r\n ),\r\n ),\r\n ),\r\n ),\r\n ),\r\n ),\r\n ),\r\n ),\r\n ),\r\n ),\r\n ),\r\n ),\r\n ),\r\n ),\r\n ),\r\n) {}\r\n"],
5
5
  "mappings": "AAAA,OAAS,mBAAAA,MAAuB,uBAChC,OACI,mBAAAC,EACA,cAAAC,EACA,oBAAAC,EACA,cAAAC,EACA,sBAAAC,EACA,kBAAAC,MACG,wBACP,OACI,iBAAAC,EACA,gBAAAC,EACA,mBAAAC,EACA,iBAAAC,EACA,iBAAAC,EACA,YAAAC,EACA,YAAAC,EACA,WAAAC,EACA,YAAAC,EACA,mBAAAC,MACG,gCAEA,MAAMC,UAA2BV,EACpCE,EACIM,EACIP,EACIM,EACIE,EACIH,EACID,EACID,EACID,EACIN,EACIE,EACID,EACIF,EACID,EACID,EACID,CACJ,CACJ,CACJ,CACJ,CACJ,CACJ,CACJ,CACJ,CACJ,CACJ,CACJ,CACJ,CACJ,CACJ,CACJ,CACJ,CAAE,CAAC",
6
6
  "names": ["EntityServerApi", "AccountAppMixin", "BoardMixin", "EmailVerifyMixin", "OAuthMixin", "PasswordResetMixin", "TwoFactorMixin", "AlimtalkMixin", "AppPushMixin", "FriendtalkMixin", "HolidaysMixin", "IdentityMixin", "LlmMixin", "OcrMixin", "PgMixin", "SmsMixin", "TaxinvoiceMixin", "EntityAppServerApi"]
7
7
  }
@@ -71,6 +71,7 @@ declare const EntityServerApi_base: {
71
71
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
72
72
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
73
73
  setToken(token: string): void;
74
+ setAccessTokenFromResponse(token: string): void;
74
75
  setAnonymousPacketToken(token: string): void;
75
76
  setApiKey(apiKey: string): void;
76
77
  setHmacSecret(secret: string): void;
@@ -87,7 +88,7 @@ declare const EntityServerApi_base: {
87
88
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
88
89
  subscribeRealtime(subscriptions: string[]): boolean;
89
90
  unsubscribeRealtime(subscriptions: string[]): boolean;
90
- startHealthTick(intervalMs?: number): void;
91
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
91
92
  stopHealthTick(): void;
92
93
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
93
94
  access_token: string;
@@ -157,6 +158,7 @@ declare const EntityServerApi_base: {
157
158
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
158
159
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
159
160
  setToken(token: string): void;
161
+ setAccessTokenFromResponse(token: string): void;
160
162
  setAnonymousPacketToken(token: string): void;
161
163
  setApiKey(apiKey: string): void;
162
164
  setHmacSecret(secret: string): void;
@@ -173,7 +175,7 @@ declare const EntityServerApi_base: {
173
175
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
174
176
  subscribeRealtime(subscriptions: string[]): boolean;
175
177
  unsubscribeRealtime(subscriptions: string[]): boolean;
176
- startHealthTick(intervalMs?: number): void;
178
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
177
179
  stopHealthTick(): void;
178
180
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
179
181
  access_token: string;
@@ -305,6 +307,7 @@ declare const EntityServerApi_base: {
305
307
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
306
308
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
307
309
  setToken(token: string): void;
310
+ setAccessTokenFromResponse(token: string): void;
308
311
  setAnonymousPacketToken(token: string): void;
309
312
  setApiKey(apiKey: string): void;
310
313
  setHmacSecret(secret: string): void;
@@ -321,7 +324,7 @@ declare const EntityServerApi_base: {
321
324
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
322
325
  subscribeRealtime(subscriptions: string[]): boolean;
323
326
  unsubscribeRealtime(subscriptions: string[]): boolean;
324
- startHealthTick(intervalMs?: number): void;
327
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
325
328
  stopHealthTick(): void;
326
329
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
327
330
  access_token: string;
@@ -397,6 +400,7 @@ declare const EntityServerApi_base: {
397
400
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
398
401
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
399
402
  setToken(token: string): void;
403
+ setAccessTokenFromResponse(token: string): void;
400
404
  setAnonymousPacketToken(token: string): void;
401
405
  setApiKey(apiKey: string): void;
402
406
  setHmacSecret(secret: string): void;
@@ -413,7 +417,7 @@ declare const EntityServerApi_base: {
413
417
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
414
418
  subscribeRealtime(subscriptions: string[]): boolean;
415
419
  unsubscribeRealtime(subscriptions: string[]): boolean;
416
- startHealthTick(intervalMs?: number): void;
420
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
417
421
  stopHealthTick(): void;
418
422
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
419
423
  access_token: string;
@@ -507,6 +511,7 @@ declare const EntityServerApi_base: {
507
511
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
508
512
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
509
513
  setToken(token: string): void;
514
+ setAccessTokenFromResponse(token: string): void;
510
515
  setAnonymousPacketToken(token: string): void;
511
516
  setApiKey(apiKey: string): void;
512
517
  setHmacSecret(secret: string): void;
@@ -523,7 +528,7 @@ declare const EntityServerApi_base: {
523
528
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
524
529
  subscribeRealtime(subscriptions: string[]): boolean;
525
530
  unsubscribeRealtime(subscriptions: string[]): boolean;
526
- startHealthTick(intervalMs?: number): void;
531
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
527
532
  stopHealthTick(): void;
528
533
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
529
534
  access_token: string;
@@ -652,6 +657,7 @@ declare const EntityServerApi_base: {
652
657
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
653
658
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
654
659
  setToken(token: string): void;
660
+ setAccessTokenFromResponse(token: string): void;
655
661
  setAnonymousPacketToken(token: string): void;
656
662
  setApiKey(apiKey: string): void;
657
663
  setHmacSecret(secret: string): void;
@@ -668,7 +674,7 @@ declare const EntityServerApi_base: {
668
674
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
669
675
  subscribeRealtime(subscriptions: string[]): boolean;
670
676
  unsubscribeRealtime(subscriptions: string[]): boolean;
671
- startHealthTick(intervalMs?: number): void;
677
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
672
678
  stopHealthTick(): void;
673
679
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
674
680
  access_token: string;
@@ -801,6 +807,7 @@ declare const EntityServerApi_base: {
801
807
  realtimeEventListeners: Map<string, Set<import("./types.js").RealtimeMessageListener>>;
802
808
  configure(options: Partial<import("./types.js").EntityServerClientOptions>): void;
803
809
  setToken(token: string): void;
810
+ setAccessTokenFromResponse(token: string): void;
804
811
  setAnonymousPacketToken(token: string): void;
805
812
  setApiKey(apiKey: string): void;
806
813
  setHmacSecret(secret: string): void;
@@ -817,7 +824,7 @@ declare const EntityServerApi_base: {
817
824
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
818
825
  subscribeRealtime(subscriptions: string[]): boolean;
819
826
  unsubscribeRealtime(subscriptions: string[]): boolean;
820
- startHealthTick(intervalMs?: number): void;
827
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
821
828
  stopHealthTick(): void;
822
829
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
823
830
  access_token: string;
@@ -852,6 +859,7 @@ declare const EntityServerApi_base: {
852
859
  authBootstrapPromise: Promise<void> | null;
853
860
  authBootstrapToken: string;
854
861
  authBootstrapAnonymousCompleted: boolean;
862
+ setAccessTokenFromResponse(token: string): void;
855
863
  csrfRefresher: () => Promise<void>;
856
864
  checkHealth(bootstrapAuth?: boolean): Promise<{
857
865
  status: string;
@@ -933,7 +941,7 @@ declare const EntityServerApi_base: {
933
941
  sendRealtime(message: import("./types.js").RealtimeEnvelope | Record<string, unknown>): boolean;
934
942
  subscribeRealtime(subscriptions: string[]): boolean;
935
943
  unsubscribeRealtime(subscriptions: string[]): boolean;
936
- startHealthTick(intervalMs?: number): void;
944
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
937
945
  stopHealthTick(): void;
938
946
  scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
939
947
  access_token: string;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/EntityServerApi.ts"],
4
- "sourcesContent": ["/**\n * @file EntityServerApi.ts\n * entity-server core route\uC6A9 Mixin \uC870\uD569 \uD074\uB77C\uC774\uC5B8\uD2B8.\n *\n * \uC808(section)\uBCC4 \uAD6C\uD604:\n * src/client/base.ts \u2014 \uC0C1\uD0DC\u00B7\uC0DD\uC131\uC790\u00B7\uACF5\uD1B5 \uD5EC\uD37C\n * src/mixins/server/* \u2014 entity-server core route mixin\n * src/mixins/app/* \u2014 entity-app-server plugin mixin\n */\nimport { EntityServerClientBase } from \"./client/base.js\";\nimport {\n AdminMixin,\n AuthMixin,\n EntityMixin,\n FileMixin,\n PushMixin,\n SmtpMixin,\n TransactionMixin,\n UtilsMixin,\n} from \"./mixins/server/index.js\";\n\n// \u2500\u2500\u2500 Composed class \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport class EntityServerApi extends UtilsMixin(\n TransactionMixin(\n FileMixin(\n SmtpMixin(\n PushMixin(\n AdminMixin(EntityMixin(AuthMixin(EntityServerClientBase))),\n ),\n ),\n ),\n ),\n) {}\n"],
4
+ "sourcesContent": ["/**\r\n * @file EntityServerApi.ts\r\n * entity-server core route\uC6A9 Mixin \uC870\uD569 \uD074\uB77C\uC774\uC5B8\uD2B8.\r\n *\r\n * \uC808(section)\uBCC4 \uAD6C\uD604:\r\n * src/client/base.ts \u2014 \uC0C1\uD0DC\u00B7\uC0DD\uC131\uC790\u00B7\uACF5\uD1B5 \uD5EC\uD37C\r\n * src/mixins/server/* \u2014 entity-server core route mixin\r\n * src/mixins/app/* \u2014 entity-app-server plugin mixin\r\n */\r\nimport { EntityServerClientBase } from \"./client/base.js\";\r\nimport {\r\n AdminMixin,\r\n AuthMixin,\r\n EntityMixin,\r\n FileMixin,\r\n PushMixin,\r\n SmtpMixin,\r\n TransactionMixin,\r\n UtilsMixin,\r\n} from \"./mixins/server/index.js\";\r\n\r\n// \u2500\u2500\u2500 Composed class \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\r\n\r\nexport class EntityServerApi extends UtilsMixin(\r\n TransactionMixin(\r\n FileMixin(\r\n SmtpMixin(\r\n PushMixin(\r\n AdminMixin(EntityMixin(AuthMixin(EntityServerClientBase))),\r\n ),\r\n ),\r\n ),\r\n ),\r\n) {}\r\n"],
5
5
  "mappings": "AASA,OAAS,0BAAAA,MAA8B,mBACvC,OACI,cAAAC,EACA,aAAAC,EACA,eAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,oBAAAC,EACA,cAAAC,MACG,2BAIA,MAAMC,UAAwBD,EACjCD,EACIH,EACIE,EACID,EACIJ,EAAWE,EAAYD,EAAUF,CAAsB,CAAC,CAAC,CAC7D,CACJ,CACJ,CACJ,CACJ,CAAE,CAAC",
6
6
  "names": ["EntityServerClientBase", "AdminMixin", "AuthMixin", "EntityMixin", "FileMixin", "PushMixin", "SmtpMixin", "TransactionMixin", "UtilsMixin", "EntityServerApi"]
7
7
  }
@@ -47,6 +47,8 @@ export declare class EntityServerClientBase {
47
47
  configure(options: Partial<EntityServerClientOptions>): void;
48
48
  /** 인증 요청에 사용할 JWT Access Token을 설정합니다. */
49
49
  setToken(token: string): void;
50
+ /** 응답 헤더로 받은 access token 갱신을 반영한다. */
51
+ setAccessTokenFromResponse(token: string): void;
50
52
  /** 익명 패킷 암호화용 토큰을 설정합니다. */
51
53
  setAnonymousPacketToken(token: string): void;
52
54
  /** HMAC 인증용 API Key를 설정합니다. */
@@ -73,8 +75,9 @@ export declare class EntityServerClientBase {
73
75
  * keepSession=true 이면 각 tick에서 세션 부트스트랩도 함께 시도합니다.
74
76
  *
75
77
  * @param intervalMs 호출 주기(ms). 기본값: 5분
78
+ * @param runImmediately true면 시작 직후 첫 tick을 즉시 실행합니다.
76
79
  */
77
- startHealthTick(intervalMs?: number): void;
80
+ startHealthTick(intervalMs?: number, runImmediately?: boolean): void;
78
81
  /** health tick 타이머를 중지합니다. */
79
82
  stopHealthTick(): void;
80
83
  /** @deprecated 세션 연장은 health tick 기반 부트스트랩으로 대체되었습니다. */
@@ -1,2 +1,2 @@
1
- import{readEnv as m}from"./utils.js";import{derivePacketKey as u,parseRequestBody as f}from"./packet.js";import{entityRequest as l}from"./request.js";const c="/v1/realtime";class y{baseUrl;token;anonymousPacketToken;apiKey;hmacSecret;encryptRequests;csrfEnabled;csrfHeaderName;csrfCookieName;csrfRefresher=null;activeTxId=null;keepSession;refreshBuffer;onTokenRefreshed;onSessionExpired;onHealthChange;sessionRefreshToken=null;refreshTimer=null;healthTickTimer=null;healthTickPromise=null;realtimeEnabled;realtimePath;realtimeAutoConnect;realtimeAutoReconnect;realtimeReconnectDelayMs;realtimeStatus;realtimeSocket=null;realtimeConnectPromise=null;realtimeReconnectTimer=null;realtimeShouldReconnect=!1;realtimeMessageListeners=new Set;realtimeStatusListeners=new Set;realtimeEventListeners=new Map;constructor(e={}){const t=m("VITE_ENTITY_SERVER_URL");this.baseUrl=(e.baseUrl??t??"").replace(/\/$/,""),this.token=e.token??"",this.anonymousPacketToken=e.anonymousPacketToken??"",this.apiKey=e.apiKey??"",this.hmacSecret=e.hmacSecret??"",this.encryptRequests=e.encryptRequests??!1,this.csrfEnabled=e.csrfEnabled??!1,this.csrfHeaderName=e.csrfHeaderName??"x-csrf-token",this.csrfCookieName=e.csrfCookieName??"_csrf",this.keepSession=e.keepSession??!1,this.refreshBuffer=e.refreshBuffer??60,this.onTokenRefreshed=e.onTokenRefreshed,this.onSessionExpired=e.onSessionExpired,this.onHealthChange=e.onHealthChange,this.realtimeEnabled=!1,this.realtimePath=c,this.realtimeAutoConnect=!0,this.realtimeAutoReconnect=!0,this.realtimeReconnectDelayMs=3e3,this.realtimeStatus="idle",this.applyRealtimeOptions(e.realtime),typeof e.healthTickInterval=="number"&&e.healthTickInterval>0&&Promise.resolve().then(()=>this.startHealthTick(e.healthTickInterval))}configure(e){typeof e.baseUrl=="string"&&(this.baseUrl=e.baseUrl.replace(/\/$/,"")),typeof e.token=="string"&&(this.token=e.token),typeof e.anonymousPacketToken=="string"&&(this.anonymousPacketToken=e.anonymousPacketToken),typeof e.encryptRequests=="boolean"&&(this.encryptRequests=e.encryptRequests),typeof e.csrfEnabled=="boolean"&&(this.csrfEnabled=e.csrfEnabled),typeof e.csrfHeaderName=="string"&&(this.csrfHeaderName=e.csrfHeaderName),typeof e.csrfCookieName=="string"&&(this.csrfCookieName=e.csrfCookieName),typeof e.apiKey=="string"&&(this.apiKey=e.apiKey),typeof e.hmacSecret=="string"&&(this.hmacSecret=e.hmacSecret),typeof e.keepSession=="boolean"&&(this.keepSession=e.keepSession),typeof e.refreshBuffer=="number"&&(this.refreshBuffer=e.refreshBuffer),e.onTokenRefreshed&&(this.onTokenRefreshed=e.onTokenRefreshed),e.onSessionExpired&&(this.onSessionExpired=e.onSessionExpired),e.onHealthChange&&(this.onHealthChange=e.onHealthChange),typeof e.realtime<"u"&&this.applyRealtimeOptions(e.realtime),typeof e.healthTickInterval=="number"&&e.healthTickInterval>0&&Promise.resolve().then(()=>this.startHealthTick(e.healthTickInterval))}setToken(e){if(this.token=e,!e){this.disconnectRealtime("token_cleared");return}this.realtimeEnabled&&this.realtimeAutoConnect&&this.connectRealtime().catch(()=>{})}setAnonymousPacketToken(e){this.anonymousPacketToken=e}setApiKey(e){this.apiKey=e}setHmacSecret(e){this.hmacSecret=e}setEncryptRequests(e){this.encryptRequests=e}setCsrfEnabled(e){this.csrfEnabled=e}addRealtimeListener(e){this.realtimeMessageListeners.add(e)}removeRealtimeListener(e){this.realtimeMessageListeners.delete(e)}addRealtimeStatusListener(e){this.realtimeStatusListeners.add(e)}removeRealtimeStatusListener(e){this.realtimeStatusListeners.delete(e)}addRealtimeEventListener(e,t){const s=String(e).trim();s&&(this.realtimeEventListeners.has(s)||this.realtimeEventListeners.set(s,new Set),this.realtimeEventListeners.get(s).add(t))}removeRealtimeEventListener(e,t){const s=String(e).trim();if(!s)return;const i=this.realtimeEventListeners.get(s);i&&(i.delete(t),i.size===0&&this.realtimeEventListeners.delete(s))}async connectRealtime(){if(!this.realtimeEnabled){this.setRealtimeStatus("disabled","realtime_disabled");return}if(!this.token)throw new Error("Cannot open realtime connection without access token.");if(typeof WebSocket>"u")throw new Error("WebSocket is not available in this environment.");if(this.realtimeSocket&&this.realtimeSocket.readyState===WebSocket.OPEN)return;if(this.realtimeSocket&&this.realtimeSocket.readyState===WebSocket.CONNECTING&&this.realtimeConnectPromise)return this.realtimeConnectPromise;this.clearRealtimeReconnectTimer(),this.realtimeShouldReconnect=this.realtimeAutoReconnect,this.setRealtimeStatus("connecting","connect_requested");const e=new WebSocket(this.buildRealtimeUrl());return this.realtimeSocket=e,this.realtimeConnectPromise=new Promise((t,s)=>{let i=!1;const r=()=>{i||(i=!0,this.realtimeConnectPromise=null,t())},n=a=>{i||(i=!0,this.realtimeConnectPromise=null,s(a))};e.addEventListener("open",()=>{this.setRealtimeStatus("open","socket_open"),r()}),e.addEventListener("message",a=>{this.handleRealtimeMessage(a.data)}),e.addEventListener("error",()=>{this.setRealtimeStatus("closed","socket_error",new Error("Realtime socket error."))}),e.addEventListener("close",a=>{this.realtimeSocket===e&&(this.realtimeSocket=null);const o=a.reason||"socket_closed",h=new Error(`Realtime socket closed (${a.code}${a.reason?`: ${a.reason}`:""}).`);this.setRealtimeStatus("closed",o,h),i||n(h),this.realtimeShouldReconnect&&this.realtimeEnabled&&this.realtimeAutoReconnect&&this.token&&this.scheduleRealtimeReconnect(o)})}),this.realtimeConnectPromise}disconnectRealtime(e="client_disconnect"){if(this.realtimeShouldReconnect=!1,this.clearRealtimeReconnectTimer(),this.realtimeSocket){const t=this.realtimeSocket;this.realtimeSocket=null;try{(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(1e3,e)}catch{}}this.realtimeConnectPromise=null,this.setRealtimeStatus(this.realtimeEnabled?"idle":"disabled",e)}sendRealtime(e){return!this.realtimeSocket||this.realtimeSocket.readyState!==WebSocket.OPEN?!1:(this.realtimeSocket.send(JSON.stringify(e)),!0)}subscribeRealtime(e){return this.sendRealtime({type:"subscribe",channel:"session",event:"session.subscribe",data:{subscriptions:e}})}unsubscribeRealtime(e){return this.sendRealtime({type:"unsubscribe",channel:"session",event:"session.unsubscribe",data:{subscriptions:e}})}startHealthTick(e=300*1e3){this.stopHealthTick();const t=()=>{this.healthTickPromise||(this.healthTickPromise=(this.csrfRefresher?this.csrfRefresher():Promise.resolve()).then(()=>{this.onHealthChange?.(!0)}).catch(()=>{this.onHealthChange?.(!1)}).finally(()=>{this.healthTickPromise=null}))};t(),this.healthTickTimer=setInterval(t,e)}stopHealthTick(){this.healthTickTimer!==null&&(clearInterval(this.healthTickTimer),this.healthTickTimer=null),this.healthTickPromise=null}scheduleKeepSession(e,t,s){this.clearRefreshTimer(),this.sessionRefreshToken=e;const i=Math.max((t-this.refreshBuffer)*1e3,0);this.refreshTimer=setTimeout(async()=>{if(this.sessionRefreshToken)try{const r=await s(this.sessionRefreshToken);this.onTokenRefreshed?.(r.access_token,r.expires_in),this.scheduleKeepSession(this.sessionRefreshToken,r.expires_in,s)}catch(r){this.clearRefreshTimer(),this.onSessionExpired?.(r instanceof Error?r:new Error(String(r)))}},i)}clearRefreshTimer(){this.refreshTimer!==null&&(clearTimeout(this.refreshTimer),this.refreshTimer=null)}stopKeepSession(){this.clearRefreshTimer(),this.sessionRefreshToken=null}applyRealtimeOptions(e){const t=typeof e=="boolean"?{enabled:e}:e??{};if(this.realtimeEnabled=t.enabled??!1,this.realtimePath=String(t.path??c).trim()||c,this.realtimeAutoConnect=t.autoConnect??!0,this.realtimeAutoReconnect=t.autoReconnect??!0,this.realtimeReconnectDelayMs=Math.max(250,t.reconnectDelayMs??3e3),!this.realtimeEnabled){this.disconnectRealtime("realtime_disabled");return}this.setRealtimeStatus("idle","realtime_enabled"),this.token&&this.realtimeAutoConnect&&this.connectRealtime().catch(()=>{})}buildRealtimeUrl(){const t=this.baseUrl||m("VITE_ENTITY_SERVER_URL")||""||(typeof window<"u"?window.location.origin:"");if(!t)throw new Error("Realtime connection requires baseUrl.");const s=new URL(this.realtimePath,t);return s.protocol=s.protocol==="https:"?"wss:":"ws:",s.searchParams.set("access_token",this.token),s.toString()}handleRealtimeMessage(e){if(typeof e!="string")return;let t;try{t=JSON.parse(e)}catch{return}for(const i of this.realtimeMessageListeners)i(t);const s=this.realtimeEventListeners.get(t.event);if(s)for(const i of s)i(t)}scheduleRealtimeReconnect(e){this.clearRealtimeReconnectTimer(),this.realtimeReconnectTimer=setTimeout(()=>{this.realtimeReconnectTimer=null,!(!this.realtimeEnabled||!this.token)&&(this.setRealtimeStatus("connecting",`${e}:reconnect`),this.connectRealtime().catch(()=>{}))},this.realtimeReconnectDelayMs)}clearRealtimeReconnectTimer(){this.realtimeReconnectTimer!==null&&(clearTimeout(this.realtimeReconnectTimer),this.realtimeReconnectTimer=null)}setRealtimeStatus(e,t,s){const i=this.realtimeStatus;if(!(i===e&&typeof t>"u"&&typeof s>"u")){this.realtimeStatus=e;for(const r of this.realtimeStatusListeners)r({status:e,previousStatus:i,...t?{reason:t}:{},...s?{error:s}:{}})}}applyCsrfHealth(){if(!(typeof document>"u")){for(const e of document.cookie.split(";")){const t=e.indexOf("=");if(!(t<0)&&e.substring(0,t).trim()===this.csrfCookieName){this.csrfEnabled=!!e.substring(t+1).trim();return}}this.csrfEnabled=!1}}readRequestBody(e,t="application/json",s=!1){const i=u(this.hmacSecret,this.token||this.anonymousPacketToken);return f(e,t,s,i)}get reqOpts(){return{baseUrl:this.baseUrl,token:this.token,anonymousPacketToken:this.anonymousPacketToken,apiKey:this.apiKey,hmacSecret:this.hmacSecret,encryptRequests:this.encryptRequests,csrfEnabled:this.csrfEnabled,csrfHeaderName:this.csrfHeaderName,csrfCookieName:this.csrfCookieName,refreshCsrfCookie:this.csrfEnabled?this.csrfRefresher:null,onAccessToken:e=>{this.token=e}}}prepareRequest(e){return Promise.resolve()}get http(){const e=this;return{get(t,s=!0,i,r){return e.prepareRequest(s).then(()=>l(e.reqOpts,"GET",t,void 0,s,i,r??!0))},post(t,s,i=!0,r,n){return e.prepareRequest(i).then(()=>l(e.reqOpts,"POST",t,s,i,r,n??!0))},put(t,s,i=!0,r,n){return e.prepareRequest(i).then(()=>l(e.reqOpts,"PUT",t,s,i,r,n??!0))},patch(t,s,i=!0,r,n){return e.prepareRequest(i).then(()=>l(e.reqOpts,"PATCH",t,s,i,r,n??!0))},delete(t,s,i=!0,r,n){return e.prepareRequest(i).then(()=>l(e.reqOpts,"DELETE",t,s,i,r,n??!0))}}}request(e,t,s,i=!0,r,n){return this.prepareRequest(i).then(()=>l(this.reqOpts,e,t,s,i,r,n??!0))}async requestBinary(e,t,s,i=!0){await this.prepareRequest(i);const r={"Content-Type":"application/json"};i&&this.token&&(r.Authorization=`Bearer ${this.token}`),this.apiKey&&(r["X-API-Key"]=this.apiKey);const n=await fetch(this.baseUrl+t,{method:e,headers:r,...s!=null?{body:JSON.stringify(s)}:{},credentials:"include"});if(!n.ok){const a=await n.text(),o=new Error(`HTTP ${n.status}: ${a}`);throw o.status=n.status,o}return n.arrayBuffer()}async requestForm(e,t,s,i=!0){const r={};i&&this.token&&(r.Authorization=`Bearer ${this.token}`),this.apiKey&&(r["X-API-Key"]=this.apiKey);const n=await fetch(this.baseUrl+t,{method:e,headers:r,body:s,credentials:"include"}),a=await n.json();if(!a.ok){const o=new Error(a.message??`EntityServer error (HTTP ${n.status})`);throw o.status=n.status,o}return a}async requestFormBinary(e,t,s,i=!0){const r={};i&&this.token&&(r.Authorization=`Bearer ${this.token}`),this.apiKey&&(r["X-API-Key"]=this.apiKey);const n=await fetch(this.baseUrl+t,{method:e,headers:r,body:s,credentials:"include"});if(!n.ok){const a=await n.text(),o=new Error(`HTTP ${n.status}: ${a}`);throw o.status=n.status,o}return n.arrayBuffer()}}export{y as EntityServerClientBase};
1
+ import{readEnv as m}from"./utils.js";import{derivePacketKey as u,parseRequestBody as f}from"./packet.js";import{entityRequest as l}from"./request.js";const c="/v1/realtime";class y{baseUrl;token;anonymousPacketToken;apiKey;hmacSecret;encryptRequests;csrfEnabled;csrfHeaderName;csrfCookieName;csrfRefresher=null;activeTxId=null;keepSession;refreshBuffer;onTokenRefreshed;onSessionExpired;onHealthChange;sessionRefreshToken=null;refreshTimer=null;healthTickTimer=null;healthTickPromise=null;realtimeEnabled;realtimePath;realtimeAutoConnect;realtimeAutoReconnect;realtimeReconnectDelayMs;realtimeStatus;realtimeSocket=null;realtimeConnectPromise=null;realtimeReconnectTimer=null;realtimeShouldReconnect=!1;realtimeMessageListeners=new Set;realtimeStatusListeners=new Set;realtimeEventListeners=new Map;constructor(e={}){const t=m("VITE_ENTITY_SERVER_URL");this.baseUrl=(e.baseUrl??t??"").replace(/\/$/,""),this.token=e.token??"",this.anonymousPacketToken=e.anonymousPacketToken??"",this.apiKey=e.apiKey??"",this.hmacSecret=e.hmacSecret??"",this.encryptRequests=e.encryptRequests??!1,this.csrfEnabled=e.csrfEnabled??!1,this.csrfHeaderName=e.csrfHeaderName??"x-csrf-token",this.csrfCookieName=e.csrfCookieName??"_csrf",this.keepSession=e.keepSession??!1,this.refreshBuffer=e.refreshBuffer??60,this.onTokenRefreshed=e.onTokenRefreshed,this.onSessionExpired=e.onSessionExpired,this.onHealthChange=e.onHealthChange,this.realtimeEnabled=!1,this.realtimePath=c,this.realtimeAutoConnect=!0,this.realtimeAutoReconnect=!0,this.realtimeReconnectDelayMs=3e3,this.realtimeStatus="idle",this.applyRealtimeOptions(e.realtime),typeof e.healthTickInterval=="number"&&e.healthTickInterval>0&&Promise.resolve().then(()=>this.startHealthTick(e.healthTickInterval,!1))}configure(e){typeof e.baseUrl=="string"&&(this.baseUrl=e.baseUrl.replace(/\/$/,"")),typeof e.token=="string"&&(this.token=e.token),typeof e.anonymousPacketToken=="string"&&(this.anonymousPacketToken=e.anonymousPacketToken),typeof e.encryptRequests=="boolean"&&(this.encryptRequests=e.encryptRequests),typeof e.csrfEnabled=="boolean"&&(this.csrfEnabled=e.csrfEnabled),typeof e.csrfHeaderName=="string"&&(this.csrfHeaderName=e.csrfHeaderName),typeof e.csrfCookieName=="string"&&(this.csrfCookieName=e.csrfCookieName),typeof e.apiKey=="string"&&(this.apiKey=e.apiKey),typeof e.hmacSecret=="string"&&(this.hmacSecret=e.hmacSecret),typeof e.keepSession=="boolean"&&(this.keepSession=e.keepSession),typeof e.refreshBuffer=="number"&&(this.refreshBuffer=e.refreshBuffer),e.onTokenRefreshed&&(this.onTokenRefreshed=e.onTokenRefreshed),e.onSessionExpired&&(this.onSessionExpired=e.onSessionExpired),e.onHealthChange&&(this.onHealthChange=e.onHealthChange),typeof e.realtime<"u"&&this.applyRealtimeOptions(e.realtime),typeof e.healthTickInterval=="number"&&e.healthTickInterval>0&&Promise.resolve().then(()=>this.startHealthTick(e.healthTickInterval,!1))}setToken(e){if(this.token=e,!e){this.disconnectRealtime("token_cleared");return}this.realtimeEnabled&&this.realtimeAutoConnect&&this.connectRealtime().catch(()=>{})}setAccessTokenFromResponse(e){this.token=e}setAnonymousPacketToken(e){this.anonymousPacketToken=e}setApiKey(e){this.apiKey=e}setHmacSecret(e){this.hmacSecret=e}setEncryptRequests(e){this.encryptRequests=e}setCsrfEnabled(e){this.csrfEnabled=e}addRealtimeListener(e){this.realtimeMessageListeners.add(e)}removeRealtimeListener(e){this.realtimeMessageListeners.delete(e)}addRealtimeStatusListener(e){this.realtimeStatusListeners.add(e)}removeRealtimeStatusListener(e){this.realtimeStatusListeners.delete(e)}addRealtimeEventListener(e,t){const s=String(e).trim();s&&(this.realtimeEventListeners.has(s)||this.realtimeEventListeners.set(s,new Set),this.realtimeEventListeners.get(s).add(t))}removeRealtimeEventListener(e,t){const s=String(e).trim();if(!s)return;const i=this.realtimeEventListeners.get(s);i&&(i.delete(t),i.size===0&&this.realtimeEventListeners.delete(s))}async connectRealtime(){if(!this.realtimeEnabled){this.setRealtimeStatus("disabled","realtime_disabled");return}if(!this.token)throw new Error("Cannot open realtime connection without access token.");if(typeof WebSocket>"u")throw new Error("WebSocket is not available in this environment.");if(this.realtimeSocket&&this.realtimeSocket.readyState===WebSocket.OPEN)return;if(this.realtimeSocket&&this.realtimeSocket.readyState===WebSocket.CONNECTING&&this.realtimeConnectPromise)return this.realtimeConnectPromise;this.clearRealtimeReconnectTimer(),this.realtimeShouldReconnect=this.realtimeAutoReconnect,this.setRealtimeStatus("connecting","connect_requested");const e=new WebSocket(this.buildRealtimeUrl());return this.realtimeSocket=e,this.realtimeConnectPromise=new Promise((t,s)=>{let i=!1;const r=()=>{i||(i=!0,this.realtimeConnectPromise=null,t())},n=a=>{i||(i=!0,this.realtimeConnectPromise=null,s(a))};e.addEventListener("open",()=>{this.setRealtimeStatus("open","socket_open"),r()}),e.addEventListener("message",a=>{this.handleRealtimeMessage(a.data)}),e.addEventListener("error",()=>{this.setRealtimeStatus("closed","socket_error",new Error("Realtime socket error."))}),e.addEventListener("close",a=>{this.realtimeSocket===e&&(this.realtimeSocket=null);const o=a.reason||"socket_closed",h=new Error(`Realtime socket closed (${a.code}${a.reason?`: ${a.reason}`:""}).`);this.setRealtimeStatus("closed",o,h),i||n(h),this.realtimeShouldReconnect&&this.realtimeEnabled&&this.realtimeAutoReconnect&&this.token&&this.scheduleRealtimeReconnect(o)})}),this.realtimeConnectPromise}disconnectRealtime(e="client_disconnect"){if(this.realtimeShouldReconnect=!1,this.clearRealtimeReconnectTimer(),this.realtimeSocket){const t=this.realtimeSocket;this.realtimeSocket=null;try{(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(1e3,e)}catch{}}this.realtimeConnectPromise=null,this.setRealtimeStatus(this.realtimeEnabled?"idle":"disabled",e)}sendRealtime(e){return!this.realtimeSocket||this.realtimeSocket.readyState!==WebSocket.OPEN?!1:(this.realtimeSocket.send(JSON.stringify(e)),!0)}subscribeRealtime(e){return this.sendRealtime({type:"subscribe",channel:"session",event:"session.subscribe",data:{subscriptions:e}})}unsubscribeRealtime(e){return this.sendRealtime({type:"unsubscribe",channel:"session",event:"session.unsubscribe",data:{subscriptions:e}})}startHealthTick(e=300*1e3,t=!0){this.stopHealthTick();const s=()=>{this.healthTickPromise||(this.healthTickPromise=(this.csrfRefresher?this.csrfRefresher():Promise.resolve()).then(()=>{this.onHealthChange?.(!0)}).catch(()=>{this.onHealthChange?.(!1)}).finally(()=>{this.healthTickPromise=null}))};t&&s(),this.healthTickTimer=setInterval(s,e)}stopHealthTick(){this.healthTickTimer!==null&&(clearInterval(this.healthTickTimer),this.healthTickTimer=null),this.healthTickPromise=null}scheduleKeepSession(e,t,s){this.clearRefreshTimer(),this.sessionRefreshToken=e;const i=Math.max((t-this.refreshBuffer)*1e3,0);this.refreshTimer=setTimeout(async()=>{if(this.sessionRefreshToken)try{const r=await s(this.sessionRefreshToken);this.onTokenRefreshed?.(r.access_token,r.expires_in),this.scheduleKeepSession(this.sessionRefreshToken,r.expires_in,s)}catch(r){this.clearRefreshTimer(),this.onSessionExpired?.(r instanceof Error?r:new Error(String(r)))}},i)}clearRefreshTimer(){this.refreshTimer!==null&&(clearTimeout(this.refreshTimer),this.refreshTimer=null)}stopKeepSession(){this.clearRefreshTimer(),this.sessionRefreshToken=null}applyRealtimeOptions(e){const t=typeof e=="boolean"?{enabled:e}:e??{};if(this.realtimeEnabled=t.enabled??!1,this.realtimePath=String(t.path??c).trim()||c,this.realtimeAutoConnect=t.autoConnect??!0,this.realtimeAutoReconnect=t.autoReconnect??!0,this.realtimeReconnectDelayMs=Math.max(250,t.reconnectDelayMs??3e3),!this.realtimeEnabled){this.disconnectRealtime("realtime_disabled");return}this.setRealtimeStatus("idle","realtime_enabled"),this.token&&this.realtimeAutoConnect&&this.connectRealtime().catch(()=>{})}buildRealtimeUrl(){const t=this.baseUrl||m("VITE_ENTITY_SERVER_URL")||""||(typeof window<"u"?window.location.origin:"");if(!t)throw new Error("Realtime connection requires baseUrl.");const s=new URL(this.realtimePath,t);return s.protocol=s.protocol==="https:"?"wss:":"ws:",s.searchParams.set("access_token",this.token),s.toString()}handleRealtimeMessage(e){if(typeof e!="string")return;let t;try{t=JSON.parse(e)}catch{return}for(const i of this.realtimeMessageListeners)i(t);const s=this.realtimeEventListeners.get(t.event);if(s)for(const i of s)i(t)}scheduleRealtimeReconnect(e){this.clearRealtimeReconnectTimer(),this.realtimeReconnectTimer=setTimeout(()=>{this.realtimeReconnectTimer=null,!(!this.realtimeEnabled||!this.token)&&(this.setRealtimeStatus("connecting",`${e}:reconnect`),this.connectRealtime().catch(()=>{}))},this.realtimeReconnectDelayMs)}clearRealtimeReconnectTimer(){this.realtimeReconnectTimer!==null&&(clearTimeout(this.realtimeReconnectTimer),this.realtimeReconnectTimer=null)}setRealtimeStatus(e,t,s){const i=this.realtimeStatus;if(!(i===e&&typeof t>"u"&&typeof s>"u")){this.realtimeStatus=e;for(const r of this.realtimeStatusListeners)r({status:e,previousStatus:i,...t?{reason:t}:{},...s?{error:s}:{}})}}applyCsrfHealth(){if(!(typeof document>"u")){for(const e of document.cookie.split(";")){const t=e.indexOf("=");if(!(t<0)&&e.substring(0,t).trim()===this.csrfCookieName){this.csrfEnabled=!!e.substring(t+1).trim();return}}this.csrfEnabled=!1}}readRequestBody(e,t="application/json",s=!1){const i=u(this.hmacSecret,this.token||this.anonymousPacketToken);return f(e,t,s,i)}get reqOpts(){return{baseUrl:this.baseUrl,token:this.token,anonymousPacketToken:this.anonymousPacketToken,apiKey:this.apiKey,hmacSecret:this.hmacSecret,encryptRequests:this.encryptRequests,csrfEnabled:this.csrfEnabled,csrfHeaderName:this.csrfHeaderName,csrfCookieName:this.csrfCookieName,refreshCsrfCookie:this.csrfEnabled?this.csrfRefresher:null,onAccessToken:e=>{this.setAccessTokenFromResponse(e)}}}prepareRequest(e){return Promise.resolve()}get http(){const e=this;return{get(t,s=!0,i,r){return e.prepareRequest(s).then(()=>l(e.reqOpts,"GET",t,void 0,s,i,r??!0))},post(t,s,i=!0,r,n){return e.prepareRequest(i).then(()=>l(e.reqOpts,"POST",t,s,i,r,n??!0))},put(t,s,i=!0,r,n){return e.prepareRequest(i).then(()=>l(e.reqOpts,"PUT",t,s,i,r,n??!0))},patch(t,s,i=!0,r,n){return e.prepareRequest(i).then(()=>l(e.reqOpts,"PATCH",t,s,i,r,n??!0))},delete(t,s,i=!0,r,n){return e.prepareRequest(i).then(()=>l(e.reqOpts,"DELETE",t,s,i,r,n??!0))}}}request(e,t,s,i=!0,r,n){return this.prepareRequest(i).then(()=>l(this.reqOpts,e,t,s,i,r,n??!0))}async requestBinary(e,t,s,i=!0){await this.prepareRequest(i);const r={"Content-Type":"application/json"};i&&this.token&&(r.Authorization=`Bearer ${this.token}`),this.apiKey&&(r["X-API-Key"]=this.apiKey);const n=await fetch(this.baseUrl+t,{method:e,headers:r,...s!=null?{body:JSON.stringify(s)}:{},credentials:"include"});if(!n.ok){const a=await n.text(),o=new Error(`HTTP ${n.status}: ${a}`);throw o.status=n.status,o}return n.arrayBuffer()}async requestForm(e,t,s,i=!0){const r={};i&&this.token&&(r.Authorization=`Bearer ${this.token}`),this.apiKey&&(r["X-API-Key"]=this.apiKey);const n=await fetch(this.baseUrl+t,{method:e,headers:r,body:s,credentials:"include"}),a=await n.json();if(!a.ok){const o=new Error(a.message??`EntityServer error (HTTP ${n.status})`);throw o.status=n.status,o}return a}async requestFormBinary(e,t,s,i=!0){const r={};i&&this.token&&(r.Authorization=`Bearer ${this.token}`),this.apiKey&&(r["X-API-Key"]=this.apiKey);const n=await fetch(this.baseUrl+t,{method:e,headers:r,body:s,credentials:"include"});if(!n.ok){const a=await n.text(),o=new Error(`HTTP ${n.status}: ${a}`);throw o.status=n.status,o}return n.arrayBuffer()}}export{y as EntityServerClientBase};
2
2
  //# sourceMappingURL=base.js.map