nolo-cli 0.33.0-alpha.9 → 0.34.0-alpha.3

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 (164) hide show
  1. package/{_executeModel-2WR4RTZZ.js → _executeModel-TMUXL7J5.js} +64 -65
  2. package/{action-OQWPNKAH.js → action-KMBZ3LCZ.js} +12 -12
  3. package/{addContentAction-YVINZQTF.js → addContentAction-KQ44UT2U.js} +10 -10
  4. package/{addDialogAgentAction-6IOCIEPI.js → addDialogAgentAction-ILSDCMYL.js} +9 -9
  5. package/{agentDeleteCommand-H22WRYC6.js → agentDeleteCommand-KA2IQAPG.js} +40 -39
  6. package/{agentEmailCommands-DGJVCMCG.js → agentEmailCommands-UIYBGCZW.js} +74 -75
  7. package/{agentListCommands-6NWMLIMQ.js → agentListCommands-L6JNUOLH.js} +47 -37
  8. package/{agentMachineCommands-5MUO6RDI.js → agentMachineCommands-5CQW5NZR.js} +37 -36
  9. package/agentProviderCommands-65ZC2WB4.js +122 -0
  10. package/{agentPullCommand-YH5GEBK4.js → agentPullCommand-TSWAJPS2.js} +1 -1
  11. package/agentRecordCommands-VUDJQIZH.js +112 -0
  12. package/agentRunCommand-EJWYF3BL.js +132 -0
  13. package/{agentRunControl-SCIVRZWX.js → agentRunControl-7MUPSYDQ.js} +7 -1
  14. package/{agentRuntimeLocal-PRAR3NCW.js → agentRuntimeLocal-XXBMDMBU.js} +33 -33
  15. package/{agentSlice-AMDSTXP5.js → agentSlice-HTIEYKIU.js} +12 -12
  16. package/agentSuperviseCommands-MKWW3ICX.js +640 -0
  17. package/{appDeleteCommands-L5PKC42V.js → appDeleteCommands-OUBL6VHB.js} +35 -34
  18. package/{appDeployCommands-3J7Z4XWV.js → appDeployCommands-BZSS2MX4.js} +35 -34
  19. package/{appDeployStatusCommands-YTRPXE72.js → appDeployStatusCommands-P2ZQOY5X.js} +35 -34
  20. package/{appGetCommands-JVXV5WXD.js → appGetCommands-WCFWQZZM.js} +35 -34
  21. package/{appListCommands-7KDEOJSO.js → appListCommands-FVJ3QNL7.js} +35 -34
  22. package/{authCommand-6Y5LTMZB.js → authCommand-B2XRHNJH.js} +19 -19
  23. package/{authCommands-EAPFGNHN.js → authCommands-GWABTFMR.js} +6 -6
  24. package/{chatQueueReduxAdapter-ZKSS6XRV.js → chatQueueReduxAdapter-ZP2ZS63U.js} +28 -28
  25. package/{chunk-UM4H3URE.js → chunk-23KKIMD5.js} +7 -7
  26. package/chunk-2BWU4ORW.js +2574 -0
  27. package/{chunk-2UECQ7RE.js → chunk-3AOLVADY.js} +1 -1
  28. package/{chunk-M2YMQOLC.js → chunk-4APLX2RT.js} +75 -10
  29. package/{chunk-ZHYK3N56.js → chunk-4AWH4LQA.js} +3 -1
  30. package/{chunk-3GZXL6FM.js → chunk-4DMPISV6.js} +7 -3
  31. package/{chunk-BQ3OHLR5.js → chunk-5GQ6XCJY.js} +1217 -691
  32. package/{chunk-GOIDVXK5.js → chunk-5LDKQUOT.js} +21 -8
  33. package/{chunk-OIQPORYI.js → chunk-64KIQZA2.js} +175 -2
  34. package/{chunk-6XIE5ZGI.js → chunk-6HIGYUBQ.js} +1 -1
  35. package/chunk-6XG52ZQ6.js +146 -0
  36. package/{chunk-FMEVI5TG.js → chunk-7CH6U3FL.js} +1 -1
  37. package/chunk-AA2YUJNV.js +54 -0
  38. package/{chunk-7INB7NXF.js → chunk-AE5GVFMG.js} +294 -54
  39. package/{chunk-UNOTBWZZ.js → chunk-B6H5XCT2.js} +8 -8
  40. package/{chunk-NNWHHCVP.js → chunk-BMB563Y6.js} +10 -4
  41. package/{chunk-DFUPZE6V.js → chunk-C6ELZQ7H.js} +249 -34
  42. package/{chunk-7KNERA53.js → chunk-E2OQ5N2F.js} +87 -13
  43. package/{chunk-6HYVJV7B.js → chunk-ESHYE7WU.js} +2 -1
  44. package/{chunk-KHCLMKZZ.js → chunk-EY7V7REW.js} +280 -6
  45. package/{chunk-JZPBVBIY.js → chunk-FD36SCCD.js} +19 -8
  46. package/{chunk-DKMOY3QI.js → chunk-FGLKRJDI.js} +54 -3
  47. package/{chunk-MQWVAOIU.js → chunk-FT4XBCK4.js} +33 -158
  48. package/{chunk-2QTEYCR7.js → chunk-FTM4KUOZ.js} +17 -17
  49. package/{chunk-U4TRT5V4.js → chunk-GEPHJJW4.js} +1 -1
  50. package/{chunk-7YYHKBJP.js → chunk-GKHV4UH5.js} +1 -1
  51. package/{chunk-2IVEXF7P.js → chunk-GUYMR3JL.js} +6 -33
  52. package/{chunk-YDTYDA5W.js → chunk-GZRMWK5R.js} +6 -4
  53. package/{chunk-X664KVEV.js → chunk-HHBXCRJS.js} +204 -123
  54. package/{chunk-AN7DGYMW.js → chunk-I7VDDN45.js} +4579 -3131
  55. package/{chunk-DSBGWT2C.js → chunk-IEEEWIVO.js} +10 -10
  56. package/{chunk-75U775RZ.js → chunk-IFS5CUEH.js} +1 -1
  57. package/{chunk-WLH5BAKX.js → chunk-IIOHYLIG.js} +9 -4
  58. package/{chunk-UEAUAXYS.js → chunk-ILZY5B4U.js} +2063 -214
  59. package/chunk-IMHO5LC6.js +370 -0
  60. package/{chunk-ADLYMQB6.js → chunk-IZCHPD7T.js} +52 -3
  61. package/{chunk-ITIA6OAQ.js → chunk-IZNJDUJ4.js} +5 -5
  62. package/{chunk-X2DAEZ3X.js → chunk-J5NMOM35.js} +1 -1
  63. package/{chunk-RPRRIFXV.js → chunk-JI2TIPLP.js} +1 -1
  64. package/{chunk-EGRJC4ZN.js → chunk-JIADXJYU.js} +1 -1
  65. package/{chunk-IHEC7VBF.js → chunk-K4KIFRIN.js} +1 -1
  66. package/{chunk-WJSW43QZ.js → chunk-L3JWI7WX.js} +0 -1
  67. package/{chunk-3RUW3ONU.js → chunk-LD6Y6RJY.js} +4 -4
  68. package/chunk-M3JQWYBC.js +387 -0
  69. package/{chunk-GM6PU7B6.js → chunk-MEYIRKDN.js} +0 -1
  70. package/{chunk-6YXDOOSH.js → chunk-MGIHZ5CJ.js} +4 -4
  71. package/{chunk-4F5M2MW5.js → chunk-MJWX4JQO.js} +2 -2
  72. package/{chunk-Q5ITEGIN.js → chunk-N4XRDM26.js} +1 -1
  73. package/{chunk-5CS33IBL.js → chunk-NQ4N4IGO.js} +11 -12
  74. package/{chunk-ZZ2MH7LE.js → chunk-O6OSWFZQ.js} +0 -1
  75. package/{chunk-RJKIB55Y.js → chunk-OSCSEJJR.js} +15 -8
  76. package/{chunk-HUCT7HID.js → chunk-P2I7ELDC.js} +3 -3
  77. package/{chunk-BXPBZVRE.js → chunk-PILJX4DH.js} +285 -251
  78. package/{chunk-SCUETSRP.js → chunk-PV734VZX.js} +1 -1
  79. package/{chunk-XLLTJXAD.js → chunk-QI3CHZUT.js} +39 -2672
  80. package/{chunk-WNHST4IE.js → chunk-RKRXAL3V.js} +5451 -5013
  81. package/{chunk-7E72JMBB.js → chunk-SMPAUSX5.js} +46 -5
  82. package/{chunk-5X4GQ53C.js → chunk-TLBZMLLJ.js} +7 -7
  83. package/{chunk-ASDXPOJH.js → chunk-U6QQLXWI.js} +1 -1
  84. package/{chunk-NUO3QFWD.js → chunk-UNHKVD2N.js} +1 -1
  85. package/{chunk-GE6IWA5N.js → chunk-UNZDCI3O.js} +126 -1
  86. package/{chunk-CPYYM4RJ.js → chunk-V5GA74HI.js} +19 -5
  87. package/{chunk-FXFGNOT2.js → chunk-VFVCYIRQ.js} +1 -1
  88. package/{chunk-G7E4NWFE.js → chunk-W445DPVT.js} +1 -1
  89. package/{chunk-EMW55KKX.js → chunk-WBZE7C6S.js} +1 -1
  90. package/{chunk-3UG2IIZ3.js → chunk-WN5AJG5I.js} +1 -1
  91. package/{chunk-KSRFVP36.js → chunk-WRN7L5CS.js} +1 -1
  92. package/{chunk-GJXRIOLS.js → chunk-WRP5TTM6.js} +4 -84
  93. package/chunk-X2K2JSO4.js +163 -0
  94. package/{chunk-OR2HNLVO.js → chunk-X6EN3KJX.js} +279 -477
  95. package/{chunk-VWY2CZD2.js → chunk-XMFDQYWA.js} +3 -3
  96. package/{chunk-IKWTTKWG.js → chunk-XQES6LXQ.js} +2 -2
  97. package/{chunk-IR6W62Q6.js → chunk-XT73C4VH.js} +18 -21
  98. package/{chunk-7L5CQQIT.js → chunk-Y5W623XU.js} +15 -15
  99. package/{chunk-RY57GLGW.js → chunk-YPREESF4.js} +42 -5
  100. package/{chunk-BQXOGBFN.js → chunk-YZ2WE6CW.js} +2 -2
  101. package/{chunk-DNQK7M7K.js → chunk-Z7COG62J.js} +4 -4
  102. package/{chunk-3WXRAHCG.js → chunk-ZBB3MZR3.js} +3 -3
  103. package/{cliExecutor-DW3PHGEL.js → cliExecutor-BBUVQU4L.js} +2 -2
  104. package/{clipboardy-MMBYVRLF.js → clipboardy-PRUHGPGC.js} +4 -3
  105. package/{codingSkills-DY5MINPG.js → codingSkills-6F4EQFCM.js} +4 -5
  106. package/cooldownCommands-C2SZLEEO.js +90 -0
  107. package/{createAgentAutomationAction-GVSJL2CI.js → createAgentAutomationAction-TGUXUZCY.js} +28 -30
  108. package/createDialogAction-FD5AEOUF.js +58 -0
  109. package/{createPageAction-M2VDKBYS.js → createPageAction-NPC3LYNK.js} +31 -34
  110. package/{dbSlice-UI2VCBLG.js → dbSlice-PIQGICNM.js} +9 -9
  111. package/{deleteFile-XQXPBFFB.js → deleteFile-NPZ64DFN.js} +4 -4
  112. package/{dialogCommands-26DBYNBT.js → dialogCommands-ZF2RSNCG.js} +37 -36
  113. package/{dialogSlice-FFGLRCBL.js → dialogSlice-6BINHWQT.js} +27 -27
  114. package/dist-VODFSGNG.js +7442 -0
  115. package/{docCreateCommands-F2ASWG6B.js → docCreateCommands-4VQ5MOHP.js} +36 -36
  116. package/{docDeleteCommands-A4URDZPI.js → docDeleteCommands-M7WLNVPB.js} +37 -37
  117. package/{docReadCommands-DO6VHDZD.js → docReadCommands-6LU6P2WT.js} +36 -36
  118. package/{docStore-EDAE7RNT.js → docStore-SIUFLABN.js} +29 -31
  119. package/{docUpdateCommands-ZTXZ3RTP.js → docUpdateCommands-S2LX4ENL.js} +39 -39
  120. package/{fetchMessages-7QRCCRYK.js → fetchMessages-CUEFN4GQ.js} +4 -4
  121. package/{getPricing-L2ENXWHV.js → getPricing-P3E2WRIH.js} +5 -5
  122. package/{handleSendMessageAction-CIRLGHOC.js → handleSendMessageAction-QVG5YNZY.js} +29 -29
  123. package/index.js +92 -77
  124. package/{localDialogRead-SLMPV5SK.js → localDialogRead-P7CHFMIC.js} +1 -1
  125. package/{localRuntimeAuthority-E3R24J4T.js → localRuntimeAuthority-S77B5QVB.js} +6 -2
  126. package/{localRuntimeDb-DDZCJFQZ.js → localRuntimeDb-N3H3HQ7G.js} +1 -1
  127. package/{machineCommands-NIQNCYJV.js → machineCommands-OSEBN7BZ.js} +76 -77
  128. package/{machineInfo-M6KB6HZN.js → machineInfo-66ZFUMLE.js} +1 -1
  129. package/{machineWsRunDispatch-EMTSQGAR.js → machineWsRunDispatch-NTJQCIIF.js} +68 -69
  130. package/{models-OX2S5C6Q.js → models-L7S2EKPM.js} +2 -2
  131. package/package.json +1 -1
  132. package/{read-2VHEHCAN.js → read-6C2XD3YZ.js} +5 -5
  133. package/{readDocTool-CSWD6NPC.js → readDocTool-Y7AB365O.js} +1 -1
  134. package/{readlineWorkspace-A2JBJWLI.js → readlineWorkspace-JPME5S7A.js} +4860 -3476
  135. package/{removeDialogAgentAction-2T7BPM3T.js → removeDialogAgentAction-KG5WMJRZ.js} +13 -13
  136. package/{runAgentClientLoop-BV4736ED.js → runAgentClientLoop-SOKEXCUF.js} +61 -61
  137. package/{runtimeDoctorCommands-KIKM6BIO.js → runtimeDoctorCommands-HT4O2PXL.js} +6 -6
  138. package/{setDialogExtraReferencesAction-GPT37HTW.js → setDialogExtraReferencesAction-O2NLXMSM.js} +10 -10
  139. package/{setPrimaryDialogAgentAction-3746P7IW.js → setPrimaryDialogAgentAction-FYYUY7PB.js} +13 -13
  140. package/{settingSlice-FIFOQ6OR.js → settingSlice-GPLI6E3M.js} +11 -11
  141. package/{skillDiscovery-KLLKXPUO.js → skillDiscovery-GPUDHDTZ.js} +3 -4
  142. package/{slateUtils-VO2FU36K.js → slateUtils-RIZES3PV.js} +1 -1
  143. package/{spaceCommands-AYZQHDB3.js → spaceCommands-Z5JLMFFJ.js} +223 -37
  144. package/{spaceSlice-43BNF22B.js → spaceSlice-Z3BGCLGX.js} +28 -30
  145. package/{streamAgentChatTurn-OLLRSITV.js → streamAgentChatTurn-INF5RGK4.js} +115 -129
  146. package/{switchDialogAgentAction-MQTUTQHL.js → switchDialogAgentAction-GH5P6Q3Z.js} +9 -9
  147. package/{chunk-IDAU4UFS.js → syncMapping-N6RGXGBW.js} +11 -11
  148. package/{tableCommands-QE47K72R.js → tableCommands-PQUJ55AS.js} +3 -3
  149. package/{tools-2SI3FXLL.js → tools-ZELMSJZ3.js} +45 -47
  150. package/{tuiSummaryLlmCaller-EAWQ3IZX.js → tuiSummaryLlmCaller-LH7F2SP7.js} +18 -18
  151. package/{updateCommands-AK2RDOFR.js → updateCommands-MNDUIKN7.js} +2 -2
  152. package/{updateDialogTitleAction-YJEQFYOA.js → updateDialogTitleAction-EDUCIB7G.js} +31 -33
  153. package/agentRecordCommands-YMGKT2WF.js +0 -113
  154. package/agentRunCommand-LYEMVQJH.js +0 -131
  155. package/chunk-AETZ7AD6.js +0 -274
  156. package/chunk-D5JI6VDM.js +0 -1800
  157. package/chunk-M3JEW6N6.js +0 -193
  158. package/chunk-ZURFOV5J.js +0 -105
  159. package/chunk-ZWS6DUHX.js +0 -480
  160. package/createDialogAction-VVR46Q2A.js +0 -61
  161. package/syncMapping-RK2MANUX.js +0 -43
  162. package/{chunk-KMSZPTM6.js → chunk-2WKUUY2E.js} +3 -3
  163. package/{chunk-CWMSB67P.js → chunk-AGGIDPCZ.js} +0 -0
  164. package/{chunk-SAQQLJZ5.js → chunk-JDSUTNYY.js} +3 -3
@@ -1,39 +1,25 @@
1
1
  import {
2
- authRoutes
3
- } from "./chunk-M3JEW6N6.js";
4
- import {
5
- clearSyncMappings
6
- } from "./chunk-IDAU4UFS.js";
7
- import {
8
- abortAllMessages,
9
- clearDialogState,
10
- clearWorkflow,
11
2
  deleteDialog,
12
- resetMsgs,
13
3
  toast
14
- } from "./chunk-BXPBZVRE.js";
4
+ } from "./chunk-PILJX4DH.js";
15
5
  import {
16
6
  deleteServerSyncedCredential
17
- } from "./chunk-5X4GQ53C.js";
7
+ } from "./chunk-TLBZMLLJ.js";
18
8
  import {
19
9
  require_date_fns
20
10
  } from "./chunk-M76ECQRD.js";
21
11
  import {
22
- createFileCredentialBroker
23
- } from "./chunk-5CS33IBL.js";
24
- import {
25
- clearPendingAttachments,
26
- clearPendingUserInputQueue,
27
12
  require_react
28
13
  } from "./chunk-MRWGHF56.js";
14
+ import {
15
+ createFileCredentialBroker
16
+ } from "./chunk-NQ4N4IGO.js";
29
17
  import {
30
18
  toErrorMessage
31
19
  } from "./chunk-HNMXYYJR.js";
32
20
  import {
33
- isSystemAdmin,
34
- selectRemoteServer,
35
- selectRemoteSyncServers
36
- } from "./chunk-UNOTBWZZ.js";
21
+ isSystemAdmin
22
+ } from "./chunk-B6H5XCT2.js";
37
23
  import {
38
24
  asRecordOrEmpty
39
25
  } from "./chunk-KX6YBIHG.js";
@@ -44,7 +30,7 @@ import {
44
30
  createSpaceKey,
45
31
  localSpaceAuthorityPatchStamp,
46
32
  normalizeSpaceId
47
- } from "./chunk-4F5M2MW5.js";
33
+ } from "./chunk-MJWX4JQO.js";
48
34
  import {
49
35
  patch,
50
36
  read,
@@ -57,7 +43,7 @@ import {
57
43
  uploadFileAction,
58
44
  upsertSSREntity,
59
45
  write
60
- } from "./chunk-UM4H3URE.js";
46
+ } from "./chunk-23KKIMD5.js";
61
47
  import {
62
48
  DB_PREFIX,
63
49
  SEPARATOR,
@@ -76,17 +62,20 @@ import {
76
62
  splitKey,
77
63
  toTrimmedString,
78
64
  ulid
79
- } from "./chunk-KMSZPTM6.js";
80
- import {
81
- asOptionalFiniteNumber
82
- } from "./chunk-WWC7I6TA.js";
65
+ } from "./chunk-2WKUUY2E.js";
83
66
  import {
84
67
  asNonEmptyStringArray,
85
68
  asTrimmedNonEmptyStringArray
86
69
  } from "./chunk-I42VC5KR.js";
70
+ import {
71
+ asOptionalFiniteNumber
72
+ } from "./chunk-WWC7I6TA.js";
87
73
  import {
88
74
  readAction
89
- } from "./chunk-IR6W62Q6.js";
75
+ } from "./chunk-XT73C4VH.js";
76
+ import {
77
+ extractUserId
78
+ } from "./chunk-BJIRLHJR.js";
90
79
  import {
91
80
  DEVICE_LOCAL_OWNER_ID,
92
81
  asyncThunkCreator,
@@ -102,18 +91,20 @@ import {
102
91
  scheduleWriteReplication,
103
92
  selectIdentityUserId,
104
93
  selectRuntimeSnapshot
105
- } from "./chunk-X664KVEV.js";
94
+ } from "./chunk-HHBXCRJS.js";
106
95
  import {
107
96
  createClientLogger,
108
97
  fetchFromServer,
109
- fetchWithTransientReadRetry,
110
98
  getAllServers,
111
99
  logger
112
- } from "./chunk-WJSW43QZ.js";
100
+ } from "./chunk-L3JWI7WX.js";
113
101
  import {
114
102
  buildTombstoneRecord,
115
103
  isTombstoneRecord
116
104
  } from "./chunk-GBRG75BQ.js";
105
+ import {
106
+ isRecord
107
+ } from "./chunk-KUG52IAP.js";
117
108
  import {
118
109
  asTrimmedString
119
110
  } from "./chunk-3EUW3WEO.js";
@@ -121,21 +112,13 @@ import {
121
112
  asOptionalPositiveFiniteNumber
122
113
  } from "./chunk-U6VC4MU4.js";
123
114
  import {
124
- extractUserId
125
- } from "./chunk-BJIRLHJR.js";
126
- import {
127
- isRecord
128
- } from "./chunk-KUG52IAP.js";
129
- import {
130
- API_ENDPOINTS,
131
- API_VERSION
115
+ API_ENDPOINTS
132
116
  } from "./chunk-LCBAMY2M.js";
133
117
  import {
134
118
  asOptionalTrimmedString
135
119
  } from "./chunk-G3SUCT4W.js";
136
120
  import {
137
121
  __commonJS,
138
- __require,
139
122
  __toESM
140
123
  } from "./chunk-4VNS5WPM.js";
141
124
 
@@ -252,1587 +235,6 @@ var require_html_parse_stringify = __commonJS({
252
235
  }
253
236
  });
254
237
 
255
- // node_modules/crypto-js/core.js
256
- var require_core = __commonJS({
257
- "node_modules/crypto-js/core.js"(exports, module) {
258
- (function(root, factory) {
259
- if (typeof exports === "object") {
260
- module.exports = exports = factory();
261
- } else if (typeof define === "function" && define.amd) {
262
- define([], factory);
263
- } else {
264
- root.CryptoJS = factory();
265
- }
266
- })(exports, function() {
267
- var CryptoJS = CryptoJS || function(Math2, undefined2) {
268
- var crypto;
269
- if (typeof window !== "undefined" && window.crypto) {
270
- crypto = window.crypto;
271
- }
272
- if (typeof self !== "undefined" && self.crypto) {
273
- crypto = self.crypto;
274
- }
275
- if (typeof globalThis !== "undefined" && globalThis.crypto) {
276
- crypto = globalThis.crypto;
277
- }
278
- if (!crypto && typeof window !== "undefined" && window.msCrypto) {
279
- crypto = window.msCrypto;
280
- }
281
- if (!crypto && typeof global !== "undefined" && global.crypto) {
282
- crypto = global.crypto;
283
- }
284
- if (!crypto && typeof __require === "function") {
285
- try {
286
- crypto = __require("crypto");
287
- } catch (err2) {
288
- }
289
- }
290
- var cryptoSecureRandomInt = function() {
291
- if (crypto) {
292
- if (typeof crypto.getRandomValues === "function") {
293
- try {
294
- return crypto.getRandomValues(new Uint32Array(1))[0];
295
- } catch (err2) {
296
- }
297
- }
298
- if (typeof crypto.randomBytes === "function") {
299
- try {
300
- return crypto.randomBytes(4).readInt32LE();
301
- } catch (err2) {
302
- }
303
- }
304
- }
305
- throw new Error("Native crypto module could not be used to get secure random number.");
306
- };
307
- var create = Object.create || /* @__PURE__ */ function() {
308
- function F() {
309
- }
310
- return function(obj) {
311
- var subtype;
312
- F.prototype = obj;
313
- subtype = new F();
314
- F.prototype = null;
315
- return subtype;
316
- };
317
- }();
318
- var C = {};
319
- var C_lib = C.lib = {};
320
- var Base = C_lib.Base = /* @__PURE__ */ function() {
321
- return {
322
- /**
323
- * Creates a new object that inherits from this object.
324
- *
325
- * @param {Object} overrides Properties to copy into the new object.
326
- *
327
- * @return {Object} The new object.
328
- *
329
- * @static
330
- *
331
- * @example
332
- *
333
- * var MyType = CryptoJS.lib.Base.extend({
334
- * field: 'value',
335
- *
336
- * method: function () {
337
- * }
338
- * });
339
- */
340
- extend: function(overrides) {
341
- var subtype = create(this);
342
- if (overrides) {
343
- subtype.mixIn(overrides);
344
- }
345
- if (!subtype.hasOwnProperty("init") || this.init === subtype.init) {
346
- subtype.init = function() {
347
- subtype.$super.init.apply(this, arguments);
348
- };
349
- }
350
- subtype.init.prototype = subtype;
351
- subtype.$super = this;
352
- return subtype;
353
- },
354
- /**
355
- * Extends this object and runs the init method.
356
- * Arguments to create() will be passed to init().
357
- *
358
- * @return {Object} The new object.
359
- *
360
- * @static
361
- *
362
- * @example
363
- *
364
- * var instance = MyType.create();
365
- */
366
- create: function() {
367
- var instance2 = this.extend();
368
- instance2.init.apply(instance2, arguments);
369
- return instance2;
370
- },
371
- /**
372
- * Initializes a newly created object.
373
- * Override this method to add some logic when your objects are created.
374
- *
375
- * @example
376
- *
377
- * var MyType = CryptoJS.lib.Base.extend({
378
- * init: function () {
379
- * // ...
380
- * }
381
- * });
382
- */
383
- init: function() {
384
- },
385
- /**
386
- * Copies properties into this object.
387
- *
388
- * @param {Object} properties The properties to mix in.
389
- *
390
- * @example
391
- *
392
- * MyType.mixIn({
393
- * field: 'value'
394
- * });
395
- */
396
- mixIn: function(properties) {
397
- for (var propertyName in properties) {
398
- if (properties.hasOwnProperty(propertyName)) {
399
- this[propertyName] = properties[propertyName];
400
- }
401
- }
402
- if (properties.hasOwnProperty("toString")) {
403
- this.toString = properties.toString;
404
- }
405
- },
406
- /**
407
- * Creates a copy of this object.
408
- *
409
- * @return {Object} The clone.
410
- *
411
- * @example
412
- *
413
- * var clone = instance.clone();
414
- */
415
- clone: function() {
416
- return this.init.prototype.extend(this);
417
- }
418
- };
419
- }();
420
- var WordArray = C_lib.WordArray = Base.extend({
421
- /**
422
- * Initializes a newly created word array.
423
- *
424
- * @param {Array} words (Optional) An array of 32-bit words.
425
- * @param {number} sigBytes (Optional) The number of significant bytes in the words.
426
- *
427
- * @example
428
- *
429
- * var wordArray = CryptoJS.lib.WordArray.create();
430
- * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
431
- * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
432
- */
433
- init: function(words, sigBytes) {
434
- words = this.words = words || [];
435
- if (sigBytes != undefined2) {
436
- this.sigBytes = sigBytes;
437
- } else {
438
- this.sigBytes = words.length * 4;
439
- }
440
- },
441
- /**
442
- * Converts this word array to a string.
443
- *
444
- * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
445
- *
446
- * @return {string} The stringified word array.
447
- *
448
- * @example
449
- *
450
- * var string = wordArray + '';
451
- * var string = wordArray.toString();
452
- * var string = wordArray.toString(CryptoJS.enc.Utf8);
453
- */
454
- toString: function(encoder) {
455
- return (encoder || Hex).stringify(this);
456
- },
457
- /**
458
- * Concatenates a word array to this word array.
459
- *
460
- * @param {WordArray} wordArray The word array to append.
461
- *
462
- * @return {WordArray} This word array.
463
- *
464
- * @example
465
- *
466
- * wordArray1.concat(wordArray2);
467
- */
468
- concat: function(wordArray) {
469
- var thisWords = this.words;
470
- var thatWords = wordArray.words;
471
- var thisSigBytes = this.sigBytes;
472
- var thatSigBytes = wordArray.sigBytes;
473
- this.clamp();
474
- if (thisSigBytes % 4) {
475
- for (var i = 0; i < thatSigBytes; i++) {
476
- var thatByte = thatWords[i >>> 2] >>> 24 - i % 4 * 8 & 255;
477
- thisWords[thisSigBytes + i >>> 2] |= thatByte << 24 - (thisSigBytes + i) % 4 * 8;
478
- }
479
- } else {
480
- for (var j = 0; j < thatSigBytes; j += 4) {
481
- thisWords[thisSigBytes + j >>> 2] = thatWords[j >>> 2];
482
- }
483
- }
484
- this.sigBytes += thatSigBytes;
485
- return this;
486
- },
487
- /**
488
- * Removes insignificant bits.
489
- *
490
- * @example
491
- *
492
- * wordArray.clamp();
493
- */
494
- clamp: function() {
495
- var words = this.words;
496
- var sigBytes = this.sigBytes;
497
- words[sigBytes >>> 2] &= 4294967295 << 32 - sigBytes % 4 * 8;
498
- words.length = Math2.ceil(sigBytes / 4);
499
- },
500
- /**
501
- * Creates a copy of this word array.
502
- *
503
- * @return {WordArray} The clone.
504
- *
505
- * @example
506
- *
507
- * var clone = wordArray.clone();
508
- */
509
- clone: function() {
510
- var clone = Base.clone.call(this);
511
- clone.words = this.words.slice(0);
512
- return clone;
513
- },
514
- /**
515
- * Creates a word array filled with random bytes.
516
- *
517
- * @param {number} nBytes The number of random bytes to generate.
518
- *
519
- * @return {WordArray} The random word array.
520
- *
521
- * @static
522
- *
523
- * @example
524
- *
525
- * var wordArray = CryptoJS.lib.WordArray.random(16);
526
- */
527
- random: function(nBytes) {
528
- var words = [];
529
- for (var i = 0; i < nBytes; i += 4) {
530
- words.push(cryptoSecureRandomInt());
531
- }
532
- return new WordArray.init(words, nBytes);
533
- }
534
- });
535
- var C_enc = C.enc = {};
536
- var Hex = C_enc.Hex = {
537
- /**
538
- * Converts a word array to a hex string.
539
- *
540
- * @param {WordArray} wordArray The word array.
541
- *
542
- * @return {string} The hex string.
543
- *
544
- * @static
545
- *
546
- * @example
547
- *
548
- * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
549
- */
550
- stringify: function(wordArray) {
551
- var words = wordArray.words;
552
- var sigBytes = wordArray.sigBytes;
553
- var hexChars = [];
554
- for (var i = 0; i < sigBytes; i++) {
555
- var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
556
- hexChars.push((bite >>> 4).toString(16));
557
- hexChars.push((bite & 15).toString(16));
558
- }
559
- return hexChars.join("");
560
- },
561
- /**
562
- * Converts a hex string to a word array.
563
- *
564
- * @param {string} hexStr The hex string.
565
- *
566
- * @return {WordArray} The word array.
567
- *
568
- * @static
569
- *
570
- * @example
571
- *
572
- * var wordArray = CryptoJS.enc.Hex.parse(hexString);
573
- */
574
- parse: function(hexStr) {
575
- var hexStrLength = hexStr.length;
576
- var words = [];
577
- for (var i = 0; i < hexStrLength; i += 2) {
578
- words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << 24 - i % 8 * 4;
579
- }
580
- return new WordArray.init(words, hexStrLength / 2);
581
- }
582
- };
583
- var Latin1 = C_enc.Latin1 = {
584
- /**
585
- * Converts a word array to a Latin1 string.
586
- *
587
- * @param {WordArray} wordArray The word array.
588
- *
589
- * @return {string} The Latin1 string.
590
- *
591
- * @static
592
- *
593
- * @example
594
- *
595
- * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
596
- */
597
- stringify: function(wordArray) {
598
- var words = wordArray.words;
599
- var sigBytes = wordArray.sigBytes;
600
- var latin1Chars = [];
601
- for (var i = 0; i < sigBytes; i++) {
602
- var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
603
- latin1Chars.push(String.fromCharCode(bite));
604
- }
605
- return latin1Chars.join("");
606
- },
607
- /**
608
- * Converts a Latin1 string to a word array.
609
- *
610
- * @param {string} latin1Str The Latin1 string.
611
- *
612
- * @return {WordArray} The word array.
613
- *
614
- * @static
615
- *
616
- * @example
617
- *
618
- * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
619
- */
620
- parse: function(latin1Str) {
621
- var latin1StrLength = latin1Str.length;
622
- var words = [];
623
- for (var i = 0; i < latin1StrLength; i++) {
624
- words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
625
- }
626
- return new WordArray.init(words, latin1StrLength);
627
- }
628
- };
629
- var Utf8 = C_enc.Utf8 = {
630
- /**
631
- * Converts a word array to a UTF-8 string.
632
- *
633
- * @param {WordArray} wordArray The word array.
634
- *
635
- * @return {string} The UTF-8 string.
636
- *
637
- * @static
638
- *
639
- * @example
640
- *
641
- * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
642
- */
643
- stringify: function(wordArray) {
644
- try {
645
- return decodeURIComponent(escape(Latin1.stringify(wordArray)));
646
- } catch (e) {
647
- throw new Error("Malformed UTF-8 data");
648
- }
649
- },
650
- /**
651
- * Converts a UTF-8 string to a word array.
652
- *
653
- * @param {string} utf8Str The UTF-8 string.
654
- *
655
- * @return {WordArray} The word array.
656
- *
657
- * @static
658
- *
659
- * @example
660
- *
661
- * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
662
- */
663
- parse: function(utf8Str) {
664
- return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
665
- }
666
- };
667
- var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
668
- /**
669
- * Resets this block algorithm's data buffer to its initial state.
670
- *
671
- * @example
672
- *
673
- * bufferedBlockAlgorithm.reset();
674
- */
675
- reset: function() {
676
- this._data = new WordArray.init();
677
- this._nDataBytes = 0;
678
- },
679
- /**
680
- * Adds new data to this block algorithm's buffer.
681
- *
682
- * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
683
- *
684
- * @example
685
- *
686
- * bufferedBlockAlgorithm._append('data');
687
- * bufferedBlockAlgorithm._append(wordArray);
688
- */
689
- _append: function(data) {
690
- if (typeof data == "string") {
691
- data = Utf8.parse(data);
692
- }
693
- this._data.concat(data);
694
- this._nDataBytes += data.sigBytes;
695
- },
696
- /**
697
- * Processes available data blocks.
698
- *
699
- * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
700
- *
701
- * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
702
- *
703
- * @return {WordArray} The processed data.
704
- *
705
- * @example
706
- *
707
- * var processedData = bufferedBlockAlgorithm._process();
708
- * var processedData = bufferedBlockAlgorithm._process(!!'flush');
709
- */
710
- _process: function(doFlush) {
711
- var processedWords;
712
- var data = this._data;
713
- var dataWords = data.words;
714
- var dataSigBytes = data.sigBytes;
715
- var blockSize = this.blockSize;
716
- var blockSizeBytes = blockSize * 4;
717
- var nBlocksReady = dataSigBytes / blockSizeBytes;
718
- if (doFlush) {
719
- nBlocksReady = Math2.ceil(nBlocksReady);
720
- } else {
721
- nBlocksReady = Math2.max((nBlocksReady | 0) - this._minBufferSize, 0);
722
- }
723
- var nWordsReady = nBlocksReady * blockSize;
724
- var nBytesReady = Math2.min(nWordsReady * 4, dataSigBytes);
725
- if (nWordsReady) {
726
- for (var offset = 0; offset < nWordsReady; offset += blockSize) {
727
- this._doProcessBlock(dataWords, offset);
728
- }
729
- processedWords = dataWords.splice(0, nWordsReady);
730
- data.sigBytes -= nBytesReady;
731
- }
732
- return new WordArray.init(processedWords, nBytesReady);
733
- },
734
- /**
735
- * Creates a copy of this object.
736
- *
737
- * @return {Object} The clone.
738
- *
739
- * @example
740
- *
741
- * var clone = bufferedBlockAlgorithm.clone();
742
- */
743
- clone: function() {
744
- var clone = Base.clone.call(this);
745
- clone._data = this._data.clone();
746
- return clone;
747
- },
748
- _minBufferSize: 0
749
- });
750
- var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
751
- /**
752
- * Configuration options.
753
- */
754
- cfg: Base.extend(),
755
- /**
756
- * Initializes a newly created hasher.
757
- *
758
- * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
759
- *
760
- * @example
761
- *
762
- * var hasher = CryptoJS.algo.SHA256.create();
763
- */
764
- init: function(cfg) {
765
- this.cfg = this.cfg.extend(cfg);
766
- this.reset();
767
- },
768
- /**
769
- * Resets this hasher to its initial state.
770
- *
771
- * @example
772
- *
773
- * hasher.reset();
774
- */
775
- reset: function() {
776
- BufferedBlockAlgorithm.reset.call(this);
777
- this._doReset();
778
- },
779
- /**
780
- * Updates this hasher with a message.
781
- *
782
- * @param {WordArray|string} messageUpdate The message to append.
783
- *
784
- * @return {Hasher} This hasher.
785
- *
786
- * @example
787
- *
788
- * hasher.update('message');
789
- * hasher.update(wordArray);
790
- */
791
- update: function(messageUpdate) {
792
- this._append(messageUpdate);
793
- this._process();
794
- return this;
795
- },
796
- /**
797
- * Finalizes the hash computation.
798
- * Note that the finalize operation is effectively a destructive, read-once operation.
799
- *
800
- * @param {WordArray|string} messageUpdate (Optional) A final message update.
801
- *
802
- * @return {WordArray} The hash.
803
- *
804
- * @example
805
- *
806
- * var hash = hasher.finalize();
807
- * var hash = hasher.finalize('message');
808
- * var hash = hasher.finalize(wordArray);
809
- */
810
- finalize: function(messageUpdate) {
811
- if (messageUpdate) {
812
- this._append(messageUpdate);
813
- }
814
- var hash = this._doFinalize();
815
- return hash;
816
- },
817
- blockSize: 512 / 32,
818
- /**
819
- * Creates a shortcut function to a hasher's object interface.
820
- *
821
- * @param {Hasher} hasher The hasher to create a helper for.
822
- *
823
- * @return {Function} The shortcut function.
824
- *
825
- * @static
826
- *
827
- * @example
828
- *
829
- * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
830
- */
831
- _createHelper: function(hasher) {
832
- return function(message, cfg) {
833
- return new hasher.init(cfg).finalize(message);
834
- };
835
- },
836
- /**
837
- * Creates a shortcut function to the HMAC's object interface.
838
- *
839
- * @param {Hasher} hasher The hasher to use in this HMAC helper.
840
- *
841
- * @return {Function} The shortcut function.
842
- *
843
- * @static
844
- *
845
- * @example
846
- *
847
- * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
848
- */
849
- _createHmacHelper: function(hasher) {
850
- return function(message, key) {
851
- return new C_algo.HMAC.init(hasher, key).finalize(message);
852
- };
853
- }
854
- });
855
- var C_algo = C.algo = {};
856
- return C;
857
- }(Math);
858
- return CryptoJS;
859
- });
860
- }
861
- });
862
-
863
- // node_modules/crypto-js/sha256.js
864
- var require_sha256 = __commonJS({
865
- "node_modules/crypto-js/sha256.js"(exports, module) {
866
- (function(root, factory) {
867
- if (typeof exports === "object") {
868
- module.exports = exports = factory(require_core());
869
- } else if (typeof define === "function" && define.amd) {
870
- define(["./core"], factory);
871
- } else {
872
- factory(root.CryptoJS);
873
- }
874
- })(exports, function(CryptoJS) {
875
- (function(Math2) {
876
- var C = CryptoJS;
877
- var C_lib = C.lib;
878
- var WordArray = C_lib.WordArray;
879
- var Hasher = C_lib.Hasher;
880
- var C_algo = C.algo;
881
- var H = [];
882
- var K = [];
883
- (function() {
884
- function isPrime(n2) {
885
- var sqrtN = Math2.sqrt(n2);
886
- for (var factor = 2; factor <= sqrtN; factor++) {
887
- if (!(n2 % factor)) {
888
- return false;
889
- }
890
- }
891
- return true;
892
- }
893
- function getFractionalBits(n2) {
894
- return (n2 - (n2 | 0)) * 4294967296 | 0;
895
- }
896
- var n = 2;
897
- var nPrime = 0;
898
- while (nPrime < 64) {
899
- if (isPrime(n)) {
900
- if (nPrime < 8) {
901
- H[nPrime] = getFractionalBits(Math2.pow(n, 1 / 2));
902
- }
903
- K[nPrime] = getFractionalBits(Math2.pow(n, 1 / 3));
904
- nPrime++;
905
- }
906
- n++;
907
- }
908
- })();
909
- var W = [];
910
- var SHA256 = C_algo.SHA256 = Hasher.extend({
911
- _doReset: function() {
912
- this._hash = new WordArray.init(H.slice(0));
913
- },
914
- _doProcessBlock: function(M, offset) {
915
- var H2 = this._hash.words;
916
- var a = H2[0];
917
- var b = H2[1];
918
- var c = H2[2];
919
- var d = H2[3];
920
- var e = H2[4];
921
- var f = H2[5];
922
- var g = H2[6];
923
- var h = H2[7];
924
- for (var i = 0; i < 64; i++) {
925
- if (i < 16) {
926
- W[i] = M[offset + i] | 0;
927
- } else {
928
- var gamma0x = W[i - 15];
929
- var gamma0 = (gamma0x << 25 | gamma0x >>> 7) ^ (gamma0x << 14 | gamma0x >>> 18) ^ gamma0x >>> 3;
930
- var gamma1x = W[i - 2];
931
- var gamma1 = (gamma1x << 15 | gamma1x >>> 17) ^ (gamma1x << 13 | gamma1x >>> 19) ^ gamma1x >>> 10;
932
- W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
933
- }
934
- var ch = e & f ^ ~e & g;
935
- var maj = a & b ^ a & c ^ b & c;
936
- var sigma0 = (a << 30 | a >>> 2) ^ (a << 19 | a >>> 13) ^ (a << 10 | a >>> 22);
937
- var sigma1 = (e << 26 | e >>> 6) ^ (e << 21 | e >>> 11) ^ (e << 7 | e >>> 25);
938
- var t1 = h + sigma1 + ch + K[i] + W[i];
939
- var t2 = sigma0 + maj;
940
- h = g;
941
- g = f;
942
- f = e;
943
- e = d + t1 | 0;
944
- d = c;
945
- c = b;
946
- b = a;
947
- a = t1 + t2 | 0;
948
- }
949
- H2[0] = H2[0] + a | 0;
950
- H2[1] = H2[1] + b | 0;
951
- H2[2] = H2[2] + c | 0;
952
- H2[3] = H2[3] + d | 0;
953
- H2[4] = H2[4] + e | 0;
954
- H2[5] = H2[5] + f | 0;
955
- H2[6] = H2[6] + g | 0;
956
- H2[7] = H2[7] + h | 0;
957
- },
958
- _doFinalize: function() {
959
- var data = this._data;
960
- var dataWords = data.words;
961
- var nBitsTotal = this._nDataBytes * 8;
962
- var nBitsLeft = data.sigBytes * 8;
963
- dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
964
- dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math2.floor(nBitsTotal / 4294967296);
965
- dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
966
- data.sigBytes = dataWords.length * 4;
967
- this._process();
968
- return this._hash;
969
- },
970
- clone: function() {
971
- var clone = Hasher.clone.call(this);
972
- clone._hash = this._hash.clone();
973
- return clone;
974
- }
975
- });
976
- C.SHA256 = Hasher._createHelper(SHA256);
977
- C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
978
- })(Math);
979
- return CryptoJS.SHA256;
980
- });
981
- }
982
- });
983
-
984
- // node_modules/crypto-js/hmac.js
985
- var require_hmac = __commonJS({
986
- "node_modules/crypto-js/hmac.js"(exports, module) {
987
- (function(root, factory) {
988
- if (typeof exports === "object") {
989
- module.exports = exports = factory(require_core());
990
- } else if (typeof define === "function" && define.amd) {
991
- define(["./core"], factory);
992
- } else {
993
- factory(root.CryptoJS);
994
- }
995
- })(exports, function(CryptoJS) {
996
- (function() {
997
- var C = CryptoJS;
998
- var C_lib = C.lib;
999
- var Base = C_lib.Base;
1000
- var C_enc = C.enc;
1001
- var Utf8 = C_enc.Utf8;
1002
- var C_algo = C.algo;
1003
- var HMAC = C_algo.HMAC = Base.extend({
1004
- /**
1005
- * Initializes a newly created HMAC.
1006
- *
1007
- * @param {Hasher} hasher The hash algorithm to use.
1008
- * @param {WordArray|string} key The secret key.
1009
- *
1010
- * @example
1011
- *
1012
- * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
1013
- */
1014
- init: function(hasher, key) {
1015
- hasher = this._hasher = new hasher.init();
1016
- if (typeof key == "string") {
1017
- key = Utf8.parse(key);
1018
- }
1019
- var hasherBlockSize = hasher.blockSize;
1020
- var hasherBlockSizeBytes = hasherBlockSize * 4;
1021
- if (key.sigBytes > hasherBlockSizeBytes) {
1022
- key = hasher.finalize(key);
1023
- }
1024
- key.clamp();
1025
- var oKey = this._oKey = key.clone();
1026
- var iKey = this._iKey = key.clone();
1027
- var oKeyWords = oKey.words;
1028
- var iKeyWords = iKey.words;
1029
- for (var i = 0; i < hasherBlockSize; i++) {
1030
- oKeyWords[i] ^= 1549556828;
1031
- iKeyWords[i] ^= 909522486;
1032
- }
1033
- oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
1034
- this.reset();
1035
- },
1036
- /**
1037
- * Resets this HMAC to its initial state.
1038
- *
1039
- * @example
1040
- *
1041
- * hmacHasher.reset();
1042
- */
1043
- reset: function() {
1044
- var hasher = this._hasher;
1045
- hasher.reset();
1046
- hasher.update(this._iKey);
1047
- },
1048
- /**
1049
- * Updates this HMAC with a message.
1050
- *
1051
- * @param {WordArray|string} messageUpdate The message to append.
1052
- *
1053
- * @return {HMAC} This HMAC instance.
1054
- *
1055
- * @example
1056
- *
1057
- * hmacHasher.update('message');
1058
- * hmacHasher.update(wordArray);
1059
- */
1060
- update: function(messageUpdate) {
1061
- this._hasher.update(messageUpdate);
1062
- return this;
1063
- },
1064
- /**
1065
- * Finalizes the HMAC computation.
1066
- * Note that the finalize operation is effectively a destructive, read-once operation.
1067
- *
1068
- * @param {WordArray|string} messageUpdate (Optional) A final message update.
1069
- *
1070
- * @return {WordArray} The HMAC.
1071
- *
1072
- * @example
1073
- *
1074
- * var hmac = hmacHasher.finalize();
1075
- * var hmac = hmacHasher.finalize('message');
1076
- * var hmac = hmacHasher.finalize(wordArray);
1077
- */
1078
- finalize: function(messageUpdate) {
1079
- var hasher = this._hasher;
1080
- var innerHash = hasher.finalize(messageUpdate);
1081
- hasher.reset();
1082
- var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
1083
- return hmac;
1084
- }
1085
- });
1086
- })();
1087
- });
1088
- }
1089
- });
1090
-
1091
- // node_modules/crypto-js/pbkdf2.js
1092
- var require_pbkdf2 = __commonJS({
1093
- "node_modules/crypto-js/pbkdf2.js"(exports, module) {
1094
- (function(root, factory, undef) {
1095
- if (typeof exports === "object") {
1096
- module.exports = exports = factory(require_core(), require_sha256(), require_hmac());
1097
- } else if (typeof define === "function" && define.amd) {
1098
- define(["./core", "./sha256", "./hmac"], factory);
1099
- } else {
1100
- factory(root.CryptoJS);
1101
- }
1102
- })(exports, function(CryptoJS) {
1103
- (function() {
1104
- var C = CryptoJS;
1105
- var C_lib = C.lib;
1106
- var Base = C_lib.Base;
1107
- var WordArray = C_lib.WordArray;
1108
- var C_algo = C.algo;
1109
- var SHA256 = C_algo.SHA256;
1110
- var HMAC = C_algo.HMAC;
1111
- var PBKDF22 = C_algo.PBKDF2 = Base.extend({
1112
- /**
1113
- * Configuration options.
1114
- *
1115
- * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
1116
- * @property {Hasher} hasher The hasher to use. Default: SHA256
1117
- * @property {number} iterations The number of iterations to perform. Default: 250000
1118
- */
1119
- cfg: Base.extend({
1120
- keySize: 128 / 32,
1121
- hasher: SHA256,
1122
- iterations: 25e4
1123
- }),
1124
- /**
1125
- * Initializes a newly created key derivation function.
1126
- *
1127
- * @param {Object} cfg (Optional) The configuration options to use for the derivation.
1128
- *
1129
- * @example
1130
- *
1131
- * var kdf = CryptoJS.algo.PBKDF2.create();
1132
- * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
1133
- * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
1134
- */
1135
- init: function(cfg) {
1136
- this.cfg = this.cfg.extend(cfg);
1137
- },
1138
- /**
1139
- * Computes the Password-Based Key Derivation Function 2.
1140
- *
1141
- * @param {WordArray|string} password The password.
1142
- * @param {WordArray|string} salt A salt.
1143
- *
1144
- * @return {WordArray} The derived key.
1145
- *
1146
- * @example
1147
- *
1148
- * var key = kdf.compute(password, salt);
1149
- */
1150
- compute: function(password, salt) {
1151
- var cfg = this.cfg;
1152
- var hmac = HMAC.create(cfg.hasher, password);
1153
- var derivedKey = WordArray.create();
1154
- var blockIndex = WordArray.create([1]);
1155
- var derivedKeyWords = derivedKey.words;
1156
- var blockIndexWords = blockIndex.words;
1157
- var keySize = cfg.keySize;
1158
- var iterations = cfg.iterations;
1159
- while (derivedKeyWords.length < keySize) {
1160
- var block = hmac.update(salt).finalize(blockIndex);
1161
- hmac.reset();
1162
- var blockWords = block.words;
1163
- var blockWordsLength = blockWords.length;
1164
- var intermediate = block;
1165
- for (var i = 1; i < iterations; i++) {
1166
- intermediate = hmac.finalize(intermediate);
1167
- hmac.reset();
1168
- var intermediateWords = intermediate.words;
1169
- for (var j = 0; j < blockWordsLength; j++) {
1170
- blockWords[j] ^= intermediateWords[j];
1171
- }
1172
- }
1173
- derivedKey.concat(block);
1174
- blockIndexWords[0]++;
1175
- }
1176
- derivedKey.sigBytes = keySize * 4;
1177
- return derivedKey;
1178
- }
1179
- });
1180
- C.PBKDF2 = function(password, salt, cfg) {
1181
- return PBKDF22.create(cfg).compute(password, salt);
1182
- };
1183
- })();
1184
- return CryptoJS.PBKDF2;
1185
- });
1186
- }
1187
- });
1188
-
1189
- // node_modules/crypto-js/enc-base64.js
1190
- var require_enc_base64 = __commonJS({
1191
- "node_modules/crypto-js/enc-base64.js"(exports, module) {
1192
- (function(root, factory) {
1193
- if (typeof exports === "object") {
1194
- module.exports = exports = factory(require_core());
1195
- } else if (typeof define === "function" && define.amd) {
1196
- define(["./core"], factory);
1197
- } else {
1198
- factory(root.CryptoJS);
1199
- }
1200
- })(exports, function(CryptoJS) {
1201
- (function() {
1202
- var C = CryptoJS;
1203
- var C_lib = C.lib;
1204
- var WordArray = C_lib.WordArray;
1205
- var C_enc = C.enc;
1206
- var Base642 = C_enc.Base64 = {
1207
- /**
1208
- * Converts a word array to a Base64 string.
1209
- *
1210
- * @param {WordArray} wordArray The word array.
1211
- *
1212
- * @return {string} The Base64 string.
1213
- *
1214
- * @static
1215
- *
1216
- * @example
1217
- *
1218
- * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
1219
- */
1220
- stringify: function(wordArray) {
1221
- var words = wordArray.words;
1222
- var sigBytes = wordArray.sigBytes;
1223
- var map = this._map;
1224
- wordArray.clamp();
1225
- var base64Chars = [];
1226
- for (var i = 0; i < sigBytes; i += 3) {
1227
- var byte1 = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
1228
- var byte2 = words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255;
1229
- var byte3 = words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255;
1230
- var triplet = byte1 << 16 | byte2 << 8 | byte3;
1231
- for (var j = 0; j < 4 && i + j * 0.75 < sigBytes; j++) {
1232
- base64Chars.push(map.charAt(triplet >>> 6 * (3 - j) & 63));
1233
- }
1234
- }
1235
- var paddingChar = map.charAt(64);
1236
- if (paddingChar) {
1237
- while (base64Chars.length % 4) {
1238
- base64Chars.push(paddingChar);
1239
- }
1240
- }
1241
- return base64Chars.join("");
1242
- },
1243
- /**
1244
- * Converts a Base64 string to a word array.
1245
- *
1246
- * @param {string} base64Str The Base64 string.
1247
- *
1248
- * @return {WordArray} The word array.
1249
- *
1250
- * @static
1251
- *
1252
- * @example
1253
- *
1254
- * var wordArray = CryptoJS.enc.Base64.parse(base64String);
1255
- */
1256
- parse: function(base64Str) {
1257
- var base64StrLength = base64Str.length;
1258
- var map = this._map;
1259
- var reverseMap = this._reverseMap;
1260
- if (!reverseMap) {
1261
- reverseMap = this._reverseMap = [];
1262
- for (var j = 0; j < map.length; j++) {
1263
- reverseMap[map.charCodeAt(j)] = j;
1264
- }
1265
- }
1266
- var paddingChar = map.charAt(64);
1267
- if (paddingChar) {
1268
- var paddingIndex = base64Str.indexOf(paddingChar);
1269
- if (paddingIndex !== -1) {
1270
- base64StrLength = paddingIndex;
1271
- }
1272
- }
1273
- return parseLoop(base64Str, base64StrLength, reverseMap);
1274
- },
1275
- _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
1276
- };
1277
- function parseLoop(base64Str, base64StrLength, reverseMap) {
1278
- var words = [];
1279
- var nBytes = 0;
1280
- for (var i = 0; i < base64StrLength; i++) {
1281
- if (i % 4) {
1282
- var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << i % 4 * 2;
1283
- var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> 6 - i % 4 * 2;
1284
- var bitsCombined = bits1 | bits2;
1285
- words[nBytes >>> 2] |= bitsCombined << 24 - nBytes % 4 * 8;
1286
- nBytes++;
1287
- }
1288
- }
1289
- return WordArray.create(words, nBytes);
1290
- }
1291
- })();
1292
- return CryptoJS.enc.Base64;
1293
- });
1294
- }
1295
- });
1296
-
1297
- // node_modules/crypto-js/x64-core.js
1298
- var require_x64_core = __commonJS({
1299
- "node_modules/crypto-js/x64-core.js"(exports, module) {
1300
- (function(root, factory) {
1301
- if (typeof exports === "object") {
1302
- module.exports = exports = factory(require_core());
1303
- } else if (typeof define === "function" && define.amd) {
1304
- define(["./core"], factory);
1305
- } else {
1306
- factory(root.CryptoJS);
1307
- }
1308
- })(exports, function(CryptoJS) {
1309
- (function(undefined2) {
1310
- var C = CryptoJS;
1311
- var C_lib = C.lib;
1312
- var Base = C_lib.Base;
1313
- var X32WordArray = C_lib.WordArray;
1314
- var C_x64 = C.x64 = {};
1315
- var X64Word = C_x64.Word = Base.extend({
1316
- /**
1317
- * Initializes a newly created 64-bit word.
1318
- *
1319
- * @param {number} high The high 32 bits.
1320
- * @param {number} low The low 32 bits.
1321
- *
1322
- * @example
1323
- *
1324
- * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
1325
- */
1326
- init: function(high, low) {
1327
- this.high = high;
1328
- this.low = low;
1329
- }
1330
- /**
1331
- * Bitwise NOTs this word.
1332
- *
1333
- * @return {X64Word} A new x64-Word object after negating.
1334
- *
1335
- * @example
1336
- *
1337
- * var negated = x64Word.not();
1338
- */
1339
- // not: function () {
1340
- // var high = ~this.high;
1341
- // var low = ~this.low;
1342
- // return X64Word.create(high, low);
1343
- // },
1344
- /**
1345
- * Bitwise ANDs this word with the passed word.
1346
- *
1347
- * @param {X64Word} word The x64-Word to AND with this word.
1348
- *
1349
- * @return {X64Word} A new x64-Word object after ANDing.
1350
- *
1351
- * @example
1352
- *
1353
- * var anded = x64Word.and(anotherX64Word);
1354
- */
1355
- // and: function (word) {
1356
- // var high = this.high & word.high;
1357
- // var low = this.low & word.low;
1358
- // return X64Word.create(high, low);
1359
- // },
1360
- /**
1361
- * Bitwise ORs this word with the passed word.
1362
- *
1363
- * @param {X64Word} word The x64-Word to OR with this word.
1364
- *
1365
- * @return {X64Word} A new x64-Word object after ORing.
1366
- *
1367
- * @example
1368
- *
1369
- * var ored = x64Word.or(anotherX64Word);
1370
- */
1371
- // or: function (word) {
1372
- // var high = this.high | word.high;
1373
- // var low = this.low | word.low;
1374
- // return X64Word.create(high, low);
1375
- // },
1376
- /**
1377
- * Bitwise XORs this word with the passed word.
1378
- *
1379
- * @param {X64Word} word The x64-Word to XOR with this word.
1380
- *
1381
- * @return {X64Word} A new x64-Word object after XORing.
1382
- *
1383
- * @example
1384
- *
1385
- * var xored = x64Word.xor(anotherX64Word);
1386
- */
1387
- // xor: function (word) {
1388
- // var high = this.high ^ word.high;
1389
- // var low = this.low ^ word.low;
1390
- // return X64Word.create(high, low);
1391
- // },
1392
- /**
1393
- * Shifts this word n bits to the left.
1394
- *
1395
- * @param {number} n The number of bits to shift.
1396
- *
1397
- * @return {X64Word} A new x64-Word object after shifting.
1398
- *
1399
- * @example
1400
- *
1401
- * var shifted = x64Word.shiftL(25);
1402
- */
1403
- // shiftL: function (n) {
1404
- // if (n < 32) {
1405
- // var high = (this.high << n) | (this.low >>> (32 - n));
1406
- // var low = this.low << n;
1407
- // } else {
1408
- // var high = this.low << (n - 32);
1409
- // var low = 0;
1410
- // }
1411
- // return X64Word.create(high, low);
1412
- // },
1413
- /**
1414
- * Shifts this word n bits to the right.
1415
- *
1416
- * @param {number} n The number of bits to shift.
1417
- *
1418
- * @return {X64Word} A new x64-Word object after shifting.
1419
- *
1420
- * @example
1421
- *
1422
- * var shifted = x64Word.shiftR(7);
1423
- */
1424
- // shiftR: function (n) {
1425
- // if (n < 32) {
1426
- // var low = (this.low >>> n) | (this.high << (32 - n));
1427
- // var high = this.high >>> n;
1428
- // } else {
1429
- // var low = this.high >>> (n - 32);
1430
- // var high = 0;
1431
- // }
1432
- // return X64Word.create(high, low);
1433
- // },
1434
- /**
1435
- * Rotates this word n bits to the left.
1436
- *
1437
- * @param {number} n The number of bits to rotate.
1438
- *
1439
- * @return {X64Word} A new x64-Word object after rotating.
1440
- *
1441
- * @example
1442
- *
1443
- * var rotated = x64Word.rotL(25);
1444
- */
1445
- // rotL: function (n) {
1446
- // return this.shiftL(n).or(this.shiftR(64 - n));
1447
- // },
1448
- /**
1449
- * Rotates this word n bits to the right.
1450
- *
1451
- * @param {number} n The number of bits to rotate.
1452
- *
1453
- * @return {X64Word} A new x64-Word object after rotating.
1454
- *
1455
- * @example
1456
- *
1457
- * var rotated = x64Word.rotR(7);
1458
- */
1459
- // rotR: function (n) {
1460
- // return this.shiftR(n).or(this.shiftL(64 - n));
1461
- // },
1462
- /**
1463
- * Adds this word with the passed word.
1464
- *
1465
- * @param {X64Word} word The x64-Word to add with this word.
1466
- *
1467
- * @return {X64Word} A new x64-Word object after adding.
1468
- *
1469
- * @example
1470
- *
1471
- * var added = x64Word.add(anotherX64Word);
1472
- */
1473
- // add: function (word) {
1474
- // var low = (this.low + word.low) | 0;
1475
- // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
1476
- // var high = (this.high + word.high + carry) | 0;
1477
- // return X64Word.create(high, low);
1478
- // }
1479
- });
1480
- var X64WordArray = C_x64.WordArray = Base.extend({
1481
- /**
1482
- * Initializes a newly created word array.
1483
- *
1484
- * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
1485
- * @param {number} sigBytes (Optional) The number of significant bytes in the words.
1486
- *
1487
- * @example
1488
- *
1489
- * var wordArray = CryptoJS.x64.WordArray.create();
1490
- *
1491
- * var wordArray = CryptoJS.x64.WordArray.create([
1492
- * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
1493
- * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
1494
- * ]);
1495
- *
1496
- * var wordArray = CryptoJS.x64.WordArray.create([
1497
- * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
1498
- * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
1499
- * ], 10);
1500
- */
1501
- init: function(words, sigBytes) {
1502
- words = this.words = words || [];
1503
- if (sigBytes != undefined2) {
1504
- this.sigBytes = sigBytes;
1505
- } else {
1506
- this.sigBytes = words.length * 8;
1507
- }
1508
- },
1509
- /**
1510
- * Converts this 64-bit word array to a 32-bit word array.
1511
- *
1512
- * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
1513
- *
1514
- * @example
1515
- *
1516
- * var x32WordArray = x64WordArray.toX32();
1517
- */
1518
- toX32: function() {
1519
- var x64Words = this.words;
1520
- var x64WordsLength = x64Words.length;
1521
- var x32Words = [];
1522
- for (var i = 0; i < x64WordsLength; i++) {
1523
- var x64Word = x64Words[i];
1524
- x32Words.push(x64Word.high);
1525
- x32Words.push(x64Word.low);
1526
- }
1527
- return X32WordArray.create(x32Words, this.sigBytes);
1528
- },
1529
- /**
1530
- * Creates a copy of this word array.
1531
- *
1532
- * @return {X64WordArray} The clone.
1533
- *
1534
- * @example
1535
- *
1536
- * var clone = x64WordArray.clone();
1537
- */
1538
- clone: function() {
1539
- var clone = Base.clone.call(this);
1540
- var words = clone.words = this.words.slice(0);
1541
- var wordsLength = words.length;
1542
- for (var i = 0; i < wordsLength; i++) {
1543
- words[i] = words[i].clone();
1544
- }
1545
- return clone;
1546
- }
1547
- });
1548
- })();
1549
- return CryptoJS;
1550
- });
1551
- }
1552
- });
1553
-
1554
- // node_modules/crypto-js/sha512.js
1555
- var require_sha512 = __commonJS({
1556
- "node_modules/crypto-js/sha512.js"(exports, module) {
1557
- (function(root, factory, undef) {
1558
- if (typeof exports === "object") {
1559
- module.exports = exports = factory(require_core(), require_x64_core());
1560
- } else if (typeof define === "function" && define.amd) {
1561
- define(["./core", "./x64-core"], factory);
1562
- } else {
1563
- factory(root.CryptoJS);
1564
- }
1565
- })(exports, function(CryptoJS) {
1566
- (function() {
1567
- var C = CryptoJS;
1568
- var C_lib = C.lib;
1569
- var Hasher = C_lib.Hasher;
1570
- var C_x64 = C.x64;
1571
- var X64Word = C_x64.Word;
1572
- var X64WordArray = C_x64.WordArray;
1573
- var C_algo = C.algo;
1574
- function X64Word_create() {
1575
- return X64Word.create.apply(X64Word, arguments);
1576
- }
1577
- var K = [
1578
- X64Word_create(1116352408, 3609767458),
1579
- X64Word_create(1899447441, 602891725),
1580
- X64Word_create(3049323471, 3964484399),
1581
- X64Word_create(3921009573, 2173295548),
1582
- X64Word_create(961987163, 4081628472),
1583
- X64Word_create(1508970993, 3053834265),
1584
- X64Word_create(2453635748, 2937671579),
1585
- X64Word_create(2870763221, 3664609560),
1586
- X64Word_create(3624381080, 2734883394),
1587
- X64Word_create(310598401, 1164996542),
1588
- X64Word_create(607225278, 1323610764),
1589
- X64Word_create(1426881987, 3590304994),
1590
- X64Word_create(1925078388, 4068182383),
1591
- X64Word_create(2162078206, 991336113),
1592
- X64Word_create(2614888103, 633803317),
1593
- X64Word_create(3248222580, 3479774868),
1594
- X64Word_create(3835390401, 2666613458),
1595
- X64Word_create(4022224774, 944711139),
1596
- X64Word_create(264347078, 2341262773),
1597
- X64Word_create(604807628, 2007800933),
1598
- X64Word_create(770255983, 1495990901),
1599
- X64Word_create(1249150122, 1856431235),
1600
- X64Word_create(1555081692, 3175218132),
1601
- X64Word_create(1996064986, 2198950837),
1602
- X64Word_create(2554220882, 3999719339),
1603
- X64Word_create(2821834349, 766784016),
1604
- X64Word_create(2952996808, 2566594879),
1605
- X64Word_create(3210313671, 3203337956),
1606
- X64Word_create(3336571891, 1034457026),
1607
- X64Word_create(3584528711, 2466948901),
1608
- X64Word_create(113926993, 3758326383),
1609
- X64Word_create(338241895, 168717936),
1610
- X64Word_create(666307205, 1188179964),
1611
- X64Word_create(773529912, 1546045734),
1612
- X64Word_create(1294757372, 1522805485),
1613
- X64Word_create(1396182291, 2643833823),
1614
- X64Word_create(1695183700, 2343527390),
1615
- X64Word_create(1986661051, 1014477480),
1616
- X64Word_create(2177026350, 1206759142),
1617
- X64Word_create(2456956037, 344077627),
1618
- X64Word_create(2730485921, 1290863460),
1619
- X64Word_create(2820302411, 3158454273),
1620
- X64Word_create(3259730800, 3505952657),
1621
- X64Word_create(3345764771, 106217008),
1622
- X64Word_create(3516065817, 3606008344),
1623
- X64Word_create(3600352804, 1432725776),
1624
- X64Word_create(4094571909, 1467031594),
1625
- X64Word_create(275423344, 851169720),
1626
- X64Word_create(430227734, 3100823752),
1627
- X64Word_create(506948616, 1363258195),
1628
- X64Word_create(659060556, 3750685593),
1629
- X64Word_create(883997877, 3785050280),
1630
- X64Word_create(958139571, 3318307427),
1631
- X64Word_create(1322822218, 3812723403),
1632
- X64Word_create(1537002063, 2003034995),
1633
- X64Word_create(1747873779, 3602036899),
1634
- X64Word_create(1955562222, 1575990012),
1635
- X64Word_create(2024104815, 1125592928),
1636
- X64Word_create(2227730452, 2716904306),
1637
- X64Word_create(2361852424, 442776044),
1638
- X64Word_create(2428436474, 593698344),
1639
- X64Word_create(2756734187, 3733110249),
1640
- X64Word_create(3204031479, 2999351573),
1641
- X64Word_create(3329325298, 3815920427),
1642
- X64Word_create(3391569614, 3928383900),
1643
- X64Word_create(3515267271, 566280711),
1644
- X64Word_create(3940187606, 3454069534),
1645
- X64Word_create(4118630271, 4000239992),
1646
- X64Word_create(116418474, 1914138554),
1647
- X64Word_create(174292421, 2731055270),
1648
- X64Word_create(289380356, 3203993006),
1649
- X64Word_create(460393269, 320620315),
1650
- X64Word_create(685471733, 587496836),
1651
- X64Word_create(852142971, 1086792851),
1652
- X64Word_create(1017036298, 365543100),
1653
- X64Word_create(1126000580, 2618297676),
1654
- X64Word_create(1288033470, 3409855158),
1655
- X64Word_create(1501505948, 4234509866),
1656
- X64Word_create(1607167915, 987167468),
1657
- X64Word_create(1816402316, 1246189591)
1658
- ];
1659
- var W = [];
1660
- (function() {
1661
- for (var i = 0; i < 80; i++) {
1662
- W[i] = X64Word_create();
1663
- }
1664
- })();
1665
- var SHA512 = C_algo.SHA512 = Hasher.extend({
1666
- _doReset: function() {
1667
- this._hash = new X64WordArray.init([
1668
- new X64Word.init(1779033703, 4089235720),
1669
- new X64Word.init(3144134277, 2227873595),
1670
- new X64Word.init(1013904242, 4271175723),
1671
- new X64Word.init(2773480762, 1595750129),
1672
- new X64Word.init(1359893119, 2917565137),
1673
- new X64Word.init(2600822924, 725511199),
1674
- new X64Word.init(528734635, 4215389547),
1675
- new X64Word.init(1541459225, 327033209)
1676
- ]);
1677
- },
1678
- _doProcessBlock: function(M, offset) {
1679
- var H = this._hash.words;
1680
- var H0 = H[0];
1681
- var H1 = H[1];
1682
- var H2 = H[2];
1683
- var H3 = H[3];
1684
- var H4 = H[4];
1685
- var H5 = H[5];
1686
- var H6 = H[6];
1687
- var H7 = H[7];
1688
- var H0h = H0.high;
1689
- var H0l = H0.low;
1690
- var H1h = H1.high;
1691
- var H1l = H1.low;
1692
- var H2h = H2.high;
1693
- var H2l = H2.low;
1694
- var H3h = H3.high;
1695
- var H3l = H3.low;
1696
- var H4h = H4.high;
1697
- var H4l = H4.low;
1698
- var H5h = H5.high;
1699
- var H5l = H5.low;
1700
- var H6h = H6.high;
1701
- var H6l = H6.low;
1702
- var H7h = H7.high;
1703
- var H7l = H7.low;
1704
- var ah = H0h;
1705
- var al = H0l;
1706
- var bh = H1h;
1707
- var bl = H1l;
1708
- var ch = H2h;
1709
- var cl = H2l;
1710
- var dh = H3h;
1711
- var dl = H3l;
1712
- var eh = H4h;
1713
- var el = H4l;
1714
- var fh = H5h;
1715
- var fl = H5l;
1716
- var gh = H6h;
1717
- var gl = H6l;
1718
- var hh = H7h;
1719
- var hl = H7l;
1720
- for (var i = 0; i < 80; i++) {
1721
- var Wil;
1722
- var Wih;
1723
- var Wi = W[i];
1724
- if (i < 16) {
1725
- Wih = Wi.high = M[offset + i * 2] | 0;
1726
- Wil = Wi.low = M[offset + i * 2 + 1] | 0;
1727
- } else {
1728
- var gamma0x = W[i - 15];
1729
- var gamma0xh = gamma0x.high;
1730
- var gamma0xl = gamma0x.low;
1731
- var gamma0h = (gamma0xh >>> 1 | gamma0xl << 31) ^ (gamma0xh >>> 8 | gamma0xl << 24) ^ gamma0xh >>> 7;
1732
- var gamma0l = (gamma0xl >>> 1 | gamma0xh << 31) ^ (gamma0xl >>> 8 | gamma0xh << 24) ^ (gamma0xl >>> 7 | gamma0xh << 25);
1733
- var gamma1x = W[i - 2];
1734
- var gamma1xh = gamma1x.high;
1735
- var gamma1xl = gamma1x.low;
1736
- var gamma1h = (gamma1xh >>> 19 | gamma1xl << 13) ^ (gamma1xh << 3 | gamma1xl >>> 29) ^ gamma1xh >>> 6;
1737
- var gamma1l = (gamma1xl >>> 19 | gamma1xh << 13) ^ (gamma1xl << 3 | gamma1xh >>> 29) ^ (gamma1xl >>> 6 | gamma1xh << 26);
1738
- var Wi7 = W[i - 7];
1739
- var Wi7h = Wi7.high;
1740
- var Wi7l = Wi7.low;
1741
- var Wi16 = W[i - 16];
1742
- var Wi16h = Wi16.high;
1743
- var Wi16l = Wi16.low;
1744
- Wil = gamma0l + Wi7l;
1745
- Wih = gamma0h + Wi7h + (Wil >>> 0 < gamma0l >>> 0 ? 1 : 0);
1746
- Wil = Wil + gamma1l;
1747
- Wih = Wih + gamma1h + (Wil >>> 0 < gamma1l >>> 0 ? 1 : 0);
1748
- Wil = Wil + Wi16l;
1749
- Wih = Wih + Wi16h + (Wil >>> 0 < Wi16l >>> 0 ? 1 : 0);
1750
- Wi.high = Wih;
1751
- Wi.low = Wil;
1752
- }
1753
- var chh = eh & fh ^ ~eh & gh;
1754
- var chl = el & fl ^ ~el & gl;
1755
- var majh = ah & bh ^ ah & ch ^ bh & ch;
1756
- var majl = al & bl ^ al & cl ^ bl & cl;
1757
- var sigma0h = (ah >>> 28 | al << 4) ^ (ah << 30 | al >>> 2) ^ (ah << 25 | al >>> 7);
1758
- var sigma0l = (al >>> 28 | ah << 4) ^ (al << 30 | ah >>> 2) ^ (al << 25 | ah >>> 7);
1759
- var sigma1h = (eh >>> 14 | el << 18) ^ (eh >>> 18 | el << 14) ^ (eh << 23 | el >>> 9);
1760
- var sigma1l = (el >>> 14 | eh << 18) ^ (el >>> 18 | eh << 14) ^ (el << 23 | eh >>> 9);
1761
- var Ki = K[i];
1762
- var Kih = Ki.high;
1763
- var Kil = Ki.low;
1764
- var t1l = hl + sigma1l;
1765
- var t1h = hh + sigma1h + (t1l >>> 0 < hl >>> 0 ? 1 : 0);
1766
- var t1l = t1l + chl;
1767
- var t1h = t1h + chh + (t1l >>> 0 < chl >>> 0 ? 1 : 0);
1768
- var t1l = t1l + Kil;
1769
- var t1h = t1h + Kih + (t1l >>> 0 < Kil >>> 0 ? 1 : 0);
1770
- var t1l = t1l + Wil;
1771
- var t1h = t1h + Wih + (t1l >>> 0 < Wil >>> 0 ? 1 : 0);
1772
- var t2l = sigma0l + majl;
1773
- var t2h = sigma0h + majh + (t2l >>> 0 < sigma0l >>> 0 ? 1 : 0);
1774
- hh = gh;
1775
- hl = gl;
1776
- gh = fh;
1777
- gl = fl;
1778
- fh = eh;
1779
- fl = el;
1780
- el = dl + t1l | 0;
1781
- eh = dh + t1h + (el >>> 0 < dl >>> 0 ? 1 : 0) | 0;
1782
- dh = ch;
1783
- dl = cl;
1784
- ch = bh;
1785
- cl = bl;
1786
- bh = ah;
1787
- bl = al;
1788
- al = t1l + t2l | 0;
1789
- ah = t1h + t2h + (al >>> 0 < t1l >>> 0 ? 1 : 0) | 0;
1790
- }
1791
- H0l = H0.low = H0l + al;
1792
- H0.high = H0h + ah + (H0l >>> 0 < al >>> 0 ? 1 : 0);
1793
- H1l = H1.low = H1l + bl;
1794
- H1.high = H1h + bh + (H1l >>> 0 < bl >>> 0 ? 1 : 0);
1795
- H2l = H2.low = H2l + cl;
1796
- H2.high = H2h + ch + (H2l >>> 0 < cl >>> 0 ? 1 : 0);
1797
- H3l = H3.low = H3l + dl;
1798
- H3.high = H3h + dh + (H3l >>> 0 < dl >>> 0 ? 1 : 0);
1799
- H4l = H4.low = H4l + el;
1800
- H4.high = H4h + eh + (H4l >>> 0 < el >>> 0 ? 1 : 0);
1801
- H5l = H5.low = H5l + fl;
1802
- H5.high = H5h + fh + (H5l >>> 0 < fl >>> 0 ? 1 : 0);
1803
- H6l = H6.low = H6l + gl;
1804
- H6.high = H6h + gh + (H6l >>> 0 < gl >>> 0 ? 1 : 0);
1805
- H7l = H7.low = H7l + hl;
1806
- H7.high = H7h + hh + (H7l >>> 0 < hl >>> 0 ? 1 : 0);
1807
- },
1808
- _doFinalize: function() {
1809
- var data = this._data;
1810
- var dataWords = data.words;
1811
- var nBitsTotal = this._nDataBytes * 8;
1812
- var nBitsLeft = data.sigBytes * 8;
1813
- dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
1814
- dataWords[(nBitsLeft + 128 >>> 10 << 5) + 30] = Math.floor(nBitsTotal / 4294967296);
1815
- dataWords[(nBitsLeft + 128 >>> 10 << 5) + 31] = nBitsTotal;
1816
- data.sigBytes = dataWords.length * 4;
1817
- this._process();
1818
- var hash = this._hash.toX32();
1819
- return hash;
1820
- },
1821
- clone: function() {
1822
- var clone = Hasher.clone.call(this);
1823
- clone._hash = this._hash.clone();
1824
- return clone;
1825
- },
1826
- blockSize: 1024 / 32
1827
- });
1828
- C.SHA512 = Hasher._createHelper(SHA512);
1829
- C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
1830
- })();
1831
- return CryptoJS.SHA512;
1832
- });
1833
- }
1834
- });
1835
-
1836
238
  // packages/create/space/category/categoryActions.ts
1837
239
  import { ulid as ulid2 } from "ulid";
1838
240
 
@@ -2848,7 +1250,7 @@ var _entityMap = {
2848
1250
  "'": "&#39;",
2849
1251
  "/": "&#x2F;"
2850
1252
  };
2851
- var escape2 = (data) => {
1253
+ var escape = (data) => {
2852
1254
  if (isString(data)) {
2853
1255
  return data.replace(/[&<>"'\/]/g, (s) => _entityMap[s]);
2854
1256
  }
@@ -4004,7 +2406,7 @@ var Interpolator = class {
4004
2406
  maxReplaces,
4005
2407
  alwaysFormat
4006
2408
  } = options.interpolation;
4007
- this.escape = escape$1 !== void 0 ? escape$1 : escape2;
2409
+ this.escape = escape$1 !== void 0 ? escape$1 : escape;
4008
2410
  this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
4009
2411
  this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
4010
2412
  this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || "{{";
@@ -5138,7 +3540,7 @@ var htmlEntities = {
5138
3540
  "&#47;": "/"
5139
3541
  };
5140
3542
  var unescapeHtmlEntity = (m) => htmlEntities[m];
5141
- var unescape2 = (text) => text.replace(matchHtmlEntity, unescapeHtmlEntity);
3543
+ var unescape = (text) => text.replace(matchHtmlEntity, unescapeHtmlEntity);
5142
3544
 
5143
3545
  // node_modules/react-i18next/dist/es/defaults.js
5144
3546
  var defaultOptions = {
@@ -5149,7 +3551,7 @@ var defaultOptions = {
5149
3551
  transWrapTextNodes: "",
5150
3552
  transKeepBasicHtmlNodesFor: ["br", "strong", "i", "p"],
5151
3553
  useSuspense: true,
5152
- unescape: unescape2
3554
+ unescape
5153
3555
  };
5154
3556
  var setDefaults = function() {
5155
3557
  let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
@@ -6257,11 +4659,11 @@ var ENTITY_DELETE_STRATEGIES = {
6257
4659
  await dispatch(deleteTable({ dbKey: key })).unwrap();
6258
4660
  },
6259
4661
  file: async (key, { thunkAPI }) => {
6260
- const { deleteFileAction } = await import("./deleteFile-XQXPBFFB.js");
4662
+ const { deleteFileAction } = await import("./deleteFile-NPZ64DFN.js");
6261
4663
  await deleteFileAction(key, thunkAPI);
6262
4664
  },
6263
4665
  image: async (key, { thunkAPI }) => {
6264
- const { deleteFileAction } = await import("./deleteFile-XQXPBFFB.js");
4666
+ const { deleteFileAction } = await import("./deleteFile-NPZ64DFN.js");
6265
4667
  await deleteFileAction(key, thunkAPI);
6266
4668
  },
6267
4669
  agent: async (key, { dispatch, userId, sourceServerOrigin }) => {
@@ -8122,1037 +6524,6 @@ var import_react14 = __toESM(require_react());
8122
6524
  // packages/app/sessionSnapshot.ts
8123
6525
  var import_react12 = __toESM(require_react());
8124
6526
 
8125
- // packages/core/generateMainKey.ts
8126
- import nacl from "tweetnacl";
8127
- var generateUserIdV1 = (publicKey, username, language, extra = "") => {
8128
- const text = publicKey + username + language + extra;
8129
- const encodedText = new TextEncoder().encode(text);
8130
- const hash = nacl.hash(encodedText);
8131
- const hexString = Array.from(hash).map((b) => b.toString(16).padStart(2, "0")).join("");
8132
- return hexString.slice(0, 10);
8133
- };
8134
-
8135
- // packages/core/generateKeyPairFromSeedV1.ts
8136
- import nacl2 from "tweetnacl";
8137
-
8138
- // node_modules/js-base64/base64.mjs
8139
- var version4 = "3.9.3";
8140
- var VERSION = version4;
8141
- var _TD = typeof TextDecoder === "function" ? new TextDecoder("utf-8", { ignoreBOM: true }) : void 0;
8142
- var _TE = typeof TextEncoder === "function" ? new TextEncoder() : void 0;
8143
- var b64ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
8144
- var b64chs = Array.prototype.slice.call(b64ch);
8145
- var b64tab = ((a) => {
8146
- let tab = {};
8147
- a.forEach((c, i) => tab[c] = i);
8148
- return tab;
8149
- })(b64chs);
8150
- var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
8151
- var _fromCC = String.fromCharCode.bind(String);
8152
- var _U8Afrom = typeof Uint8Array.from === "function" ? Uint8Array.from.bind(Uint8Array) : (it) => new Uint8Array(Array.prototype.slice.call(it, 0));
8153
- var _mkUriSafe = (src) => src.replace(/=/g, "").replace(/[+\/]/g, (m0) => m0 == "+" ? "-" : "_");
8154
- var _tidyB64 = (s) => s.replace(/[^A-Za-z0-9\+\/]/g, "");
8155
- var btoaPolyfill = (bin) => {
8156
- let u32, c0, c1, c2, asc = "";
8157
- const pad = bin.length % 3;
8158
- for (let i = 0; i < bin.length; ) {
8159
- if ((c0 = bin.charCodeAt(i++)) > 255 || (c1 = bin.charCodeAt(i++)) > 255 || (c2 = bin.charCodeAt(i++)) > 255)
8160
- throw new TypeError("invalid character found");
8161
- u32 = c0 << 16 | c1 << 8 | c2;
8162
- asc += b64chs[u32 >> 18 & 63] + b64chs[u32 >> 12 & 63] + b64chs[u32 >> 6 & 63] + b64chs[u32 & 63];
8163
- }
8164
- return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
8165
- };
8166
- var _btoa = typeof btoa === "function" ? (bin) => btoa(bin) : btoaPolyfill;
8167
- var _fromUint8Array = typeof Uint8Array.prototype.toBase64 === "function" ? (u8a) => u8a.toBase64() : (u8a) => {
8168
- const maxargs = 4096;
8169
- let strs = [];
8170
- for (let i = 0, l = u8a.length; i < l; i += maxargs) {
8171
- strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
8172
- }
8173
- return _btoa(strs.join(""));
8174
- };
8175
- var fromUint8Array = (u8a, urlsafe = false) => urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a);
8176
- var cb_utob = (c) => {
8177
- if (c.length < 2) {
8178
- var cc = c.charCodeAt(0);
8179
- return cc < 128 ? c : cc < 2048 ? _fromCC(192 | cc >>> 6) + _fromCC(128 | cc & 63) : _fromCC(224 | cc >>> 12 & 15) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
8180
- } else {
8181
- var cc = 65536 + (c.charCodeAt(0) - 55296) * 1024 + (c.charCodeAt(1) - 56320);
8182
- return _fromCC(240 | cc >>> 18 & 7) + _fromCC(128 | cc >>> 12 & 63) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
8183
- }
8184
- };
8185
- var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\x00-\x7F]/g;
8186
- var utob = (u) => u.replace(re_utob, cb_utob);
8187
- var _encode = _TE ? (s) => _fromUint8Array(_TE.encode(s)) : (s) => _btoa(utob(s));
8188
- var encode = (src, urlsafe = false) => urlsafe ? _mkUriSafe(_encode(src)) : _encode(src);
8189
- var encodeURI = (src) => encode(src, true);
8190
- var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
8191
- var cb_btou = (cccc) => {
8192
- switch (cccc.length) {
8193
- case 4:
8194
- var cp = (7 & cccc.charCodeAt(0)) << 18 | (63 & cccc.charCodeAt(1)) << 12 | (63 & cccc.charCodeAt(2)) << 6 | 63 & cccc.charCodeAt(3), offset = cp - 65536;
8195
- return _fromCC((offset >>> 10) + 55296) + _fromCC((offset & 1023) + 56320);
8196
- case 3:
8197
- return _fromCC((15 & cccc.charCodeAt(0)) << 12 | (63 & cccc.charCodeAt(1)) << 6 | 63 & cccc.charCodeAt(2));
8198
- default:
8199
- return _fromCC((31 & cccc.charCodeAt(0)) << 6 | 63 & cccc.charCodeAt(1));
8200
- }
8201
- };
8202
- var btou = (b) => b.replace(re_btou, cb_btou);
8203
- var atobPolyfill = (asc) => {
8204
- asc = asc.replace(/\s+/g, "");
8205
- if (!b64re.test(asc))
8206
- throw new TypeError("malformed base64.");
8207
- asc += "==".slice(2 - (asc.length & 3));
8208
- let u24, r1, r2;
8209
- let binArray = [];
8210
- for (let i = 0; i < asc.length; ) {
8211
- u24 = b64tab[asc.charAt(i++)] << 18 | b64tab[asc.charAt(i++)] << 12 | (r1 = b64tab[asc.charAt(i++)]) << 6 | (r2 = b64tab[asc.charAt(i++)]);
8212
- if (r1 === 64) {
8213
- binArray.push(_fromCC(u24 >> 16 & 255));
8214
- } else if (r2 === 64) {
8215
- binArray.push(_fromCC(u24 >> 16 & 255, u24 >> 8 & 255));
8216
- } else {
8217
- binArray.push(_fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255));
8218
- }
8219
- }
8220
- return binArray.join("");
8221
- };
8222
- var _atob = typeof atob === "function" ? (asc) => atob(_tidyB64(asc)) : atobPolyfill;
8223
- var _toUint8Array = typeof Uint8Array.fromBase64 === "function" ? (a) => Uint8Array.fromBase64(a) : (a) => _U8Afrom(_atob(a).split("").map((c) => c.charCodeAt(0)));
8224
- var toUint8Array = (a) => _toUint8Array(_unURI(a));
8225
- var _decode = _TD ? (a) => _TD.decode(_toUint8Array(a)) : (a) => btou(_atob(a));
8226
- var _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == "-" ? "+" : "/"));
8227
- var decode = (src) => _decode(_unURI(src));
8228
- var isValid = (src) => {
8229
- if (typeof src !== "string")
8230
- return false;
8231
- const s = src.replace(/\s+/g, "").replace(/={0,2}$/, "");
8232
- return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s);
8233
- };
8234
- var _noEnum = (v) => {
8235
- return {
8236
- value: v,
8237
- enumerable: false,
8238
- writable: true,
8239
- configurable: true
8240
- };
8241
- };
8242
- var extendString = function() {
8243
- const _add = (name, body) => Object.defineProperty(String.prototype, name, _noEnum(body));
8244
- _add("fromBase64", function() {
8245
- return decode(this);
8246
- });
8247
- _add("toBase64", function(urlsafe) {
8248
- return encode(this, urlsafe);
8249
- });
8250
- _add("toBase64URI", function() {
8251
- return encode(this, true);
8252
- });
8253
- _add("toBase64URL", function() {
8254
- return encode(this, true);
8255
- });
8256
- _add("toUint8Array", function() {
8257
- return toUint8Array(this);
8258
- });
8259
- };
8260
- var extendUint8Array = function() {
8261
- const _add = (name, body) => Object.defineProperty(Uint8Array.prototype, name, _noEnum(body));
8262
- _add("toBase64", function(urlsafe) {
8263
- return fromUint8Array(this, urlsafe);
8264
- });
8265
- _add("toBase64URI", function() {
8266
- return fromUint8Array(this, true);
8267
- });
8268
- _add("toBase64URL", function() {
8269
- return fromUint8Array(this, true);
8270
- });
8271
- };
8272
- var extendBuiltins = () => {
8273
- extendString();
8274
- extendUint8Array();
8275
- };
8276
- var gBase64 = {
8277
- version: version4,
8278
- VERSION,
8279
- atob: _atob,
8280
- atobPolyfill,
8281
- btoa: _btoa,
8282
- btoaPolyfill,
8283
- fromBase64: decode,
8284
- toBase64: encode,
8285
- encode,
8286
- encodeURI,
8287
- encodeURL: encodeURI,
8288
- utob,
8289
- btou,
8290
- decode,
8291
- isValid,
8292
- fromUint8Array,
8293
- toUint8Array,
8294
- extendString,
8295
- extendUint8Array,
8296
- extendBuiltins
8297
- };
8298
-
8299
- // packages/core/generateKeyPairFromSeedV1.ts
8300
- var generateKeyPairFromSeedV1 = (seedData) => {
8301
- const seed = new TextEncoder().encode(seedData);
8302
- const hashSeed = nacl2.hash(seed);
8303
- const seed32 = hashSeed.slice(0, 32);
8304
- const keyPair = nacl2.sign.keyPair.fromSeed(seed32);
8305
- return {
8306
- publicKey: gBase64.fromUint8Array(keyPair.publicKey, true),
8307
- secretKey: gBase64.fromUint8Array(keyPair.secretKey, true)
8308
- };
8309
- };
8310
-
8311
- // packages/core/password.ts
8312
- var import_pbkdf2 = __toESM(require_pbkdf2(), 1);
8313
- var import_enc_base64 = __toESM(require_enc_base64(), 1);
8314
- var import_sha512 = __toESM(require_sha512(), 1);
8315
- var import_core = __toESM(require_core(), 1);
8316
-
8317
- // packages/core/config.ts
8318
- var providerName = "nolotus";
8319
- var slogonforYou = "The goodness or badness of this world concerns every individual.";
8320
- var AUTH_VERSION = {
8321
- "1": {
8322
- iterations: 1e4,
8323
- salt: providerName + slogonforYou,
8324
- keylen: 32
8325
- }
8326
- };
8327
- var SALT = AUTH_VERSION[1].salt;
8328
-
8329
- // packages/core/password.ts
8330
- var SHA512Algo = import_core.default.algo.SHA512;
8331
- if (!SHA512Algo) {
8332
- throw new Error(
8333
- "crypto-js/sha512 not registered; subpath import order broken"
8334
- );
8335
- }
8336
- var hashPasswordV1 = async (password) => {
8337
- const hash = (0, import_pbkdf2.default)(password, SALT, {
8338
- keySize: 256 / AUTH_VERSION[1].keylen,
8339
- iterations: AUTH_VERSION[1].iterations,
8340
- hasher: SHA512Algo
8341
- });
8342
- return hash.toString(import_enc_base64.default);
8343
- };
8344
-
8345
- // packages/chat/dialog/composerImageDraftStore.ts
8346
- var draftsByDialogKey = {};
8347
- function clearComposerImageDraft(dialogKey) {
8348
- if (!dialogKey) return;
8349
- const existing = draftsByDialogKey[dialogKey];
8350
- if (existing) {
8351
- for (const item of existing.items) {
8352
- if (item.previewUrl.startsWith("blob:") && typeof URL !== "undefined" && typeof URL.revokeObjectURL === "function") {
8353
- URL.revokeObjectURL(item.previewUrl);
8354
- }
8355
- }
8356
- }
8357
- delete draftsByDialogKey[dialogKey];
8358
- }
8359
- function clearAllComposerImageDrafts() {
8360
- for (const key of Object.keys(draftsByDialogKey)) {
8361
- clearComposerImageDraft(key);
8362
- }
8363
- }
8364
-
8365
- // packages/database/sync/syncJobRegistry.ts
8366
- var normalizeId = (value) => asTrimmedString(value);
8367
- var nextJobSeq = 0;
8368
- var allocateJobId = () => {
8369
- nextJobSeq += 1;
8370
- return `sync-job-${nextJobSeq}`;
8371
- };
8372
- var toPublicJob = (job) => ({
8373
- id: job.id,
8374
- accountUserId: job.accountUserId,
8375
- label: job.label,
8376
- startedAt: job.startedAt,
8377
- signal: job.controller.signal,
8378
- abort: (reason) => {
8379
- if (!job.controller.signal.aborted) {
8380
- job.controller.abort(reason);
8381
- }
8382
- }
8383
- });
8384
- var toRegistration = (job) => ({
8385
- id: job.id,
8386
- accountUserId: job.accountUserId,
8387
- label: job.label,
8388
- startedAt: job.startedAt,
8389
- signal: job.controller.signal
8390
- });
8391
- function createSyncJobRegistry(options) {
8392
- const now = options?.now ?? Date.now;
8393
- const jobs = /* @__PURE__ */ new Map();
8394
- const drop = (id) => {
8395
- const job = jobs.get(id);
8396
- if (!job) return;
8397
- job.controller.signal.removeEventListener("abort", job.onAbort);
8398
- jobs.delete(id);
8399
- };
8400
- return {
8401
- register(input = {}) {
8402
- const requestedId = normalizeId(input.id);
8403
- const id = requestedId || allocateJobId();
8404
- if (jobs.has(id)) {
8405
- throw new Error(`sync job already registered: ${id}`);
8406
- }
8407
- const ownsController = !input.controller;
8408
- const controller = input.controller ?? new AbortController();
8409
- const accountUserId = normalizeId(input.accountUserId) || void 0;
8410
- const label = normalizeId(input.label) || void 0;
8411
- const internal = {
8412
- id,
8413
- accountUserId,
8414
- label,
8415
- startedAt: now(),
8416
- controller,
8417
- ownsController,
8418
- onAbort: () => {
8419
- drop(id);
8420
- }
8421
- };
8422
- controller.signal.addEventListener("abort", internal.onAbort, { once: true });
8423
- if (controller.signal.aborted) {
8424
- return toPublicJob(internal);
8425
- }
8426
- jobs.set(id, internal);
8427
- return toPublicJob(internal);
8428
- },
8429
- get(id) {
8430
- const key = normalizeId(id);
8431
- if (!key) return null;
8432
- const job = jobs.get(key);
8433
- return job ? toPublicJob(job) : null;
8434
- },
8435
- list(filter) {
8436
- const accountUserId = normalizeId(filter?.accountUserId);
8437
- return Array.from(jobs.values()).filter((job) => {
8438
- if (!accountUserId) return true;
8439
- return job.accountUserId === accountUserId;
8440
- }).map(toRegistration).sort(
8441
- (left, right) => left.startedAt - right.startedAt || left.id.localeCompare(right.id)
8442
- );
8443
- },
8444
- cancel(id, reason) {
8445
- const key = normalizeId(id);
8446
- if (!key) return false;
8447
- const job = jobs.get(key);
8448
- if (!job) return false;
8449
- if (!job.controller.signal.aborted) {
8450
- job.controller.abort(reason ?? new Error("sync job cancelled"));
8451
- } else {
8452
- drop(key);
8453
- }
8454
- return true;
8455
- },
8456
- cancelByAccountUserId(accountUserId, reason) {
8457
- const key = normalizeId(accountUserId);
8458
- if (!key) return 0;
8459
- const ids = Array.from(jobs.values()).filter((job) => job.accountUserId === key).map((job) => job.id);
8460
- let cancelled = 0;
8461
- for (const id of ids) {
8462
- if (this.cancel(id, reason)) cancelled += 1;
8463
- }
8464
- return cancelled;
8465
- },
8466
- cancelAll(reason) {
8467
- const ids = Array.from(jobs.keys());
8468
- let cancelled = 0;
8469
- for (const id of ids) {
8470
- if (this.cancel(id, reason)) cancelled += 1;
8471
- }
8472
- return cancelled;
8473
- },
8474
- unregister(id) {
8475
- const key = normalizeId(id);
8476
- if (!key) return false;
8477
- if (!jobs.has(key)) return false;
8478
- drop(key);
8479
- return true;
8480
- },
8481
- size() {
8482
- return jobs.size;
8483
- }
8484
- };
8485
- }
8486
- var defaultSyncJobRegistry = createSyncJobRegistry();
8487
- function cancelAllSyncJobs(reason) {
8488
- return defaultSyncJobRegistry.cancelAll(
8489
- reason ?? new Error("auth-scoped sync cancelled")
8490
- );
8491
- }
8492
-
8493
- // packages/auth/resetAuthScopedClientState.ts
8494
- var resetAuthScopedClientState = async (dispatch) => {
8495
- cancelAllSyncJobs();
8496
- clearSyncMappings();
8497
- await dispatch(abortAllMessages({ all: true })).unwrap();
8498
- clearPendingAttachments({ all: true });
8499
- clearAllComposerImageDrafts();
8500
- dispatch(clearDialogState());
8501
- clearPendingUserInputQueue({ all: true });
8502
- dispatch(resetMsgs({ all: true }));
8503
- clearWorkflow();
8504
- resetFavorites();
8505
- dispatch(resetSpace());
8506
- };
8507
-
8508
- // packages/core/crypto.ts
8509
- import nacl3 from "tweetnacl";
8510
- var verifySignedMessage = (signedMessageBase64, publicKeyBase64) => {
8511
- const message = nacl3.sign.open(
8512
- gBase64.toUint8Array(signedMessageBase64),
8513
- gBase64.toUint8Array(publicKeyBase64)
8514
- );
8515
- if (!message) throw new Error("Decoding failed");
8516
- return new TextDecoder().decode(message);
8517
- };
8518
- var detachedSign = (message, secretKeyBase64) => {
8519
- const signature = nacl3.sign.detached(
8520
- new TextEncoder().encode(message),
8521
- gBase64.toUint8Array(secretKeyBase64)
8522
- );
8523
- return gBase64.fromUint8Array(signature, true);
8524
- };
8525
-
8526
- // packages/core/authToken.ts
8527
- var buildPersistentAuthTokenPayload = (payload, nowSec = Math.floor(Date.now() / 1e3)) => ({
8528
- ...payload,
8529
- iat: nowSec,
8530
- nbf: nowSec
8531
- });
8532
- var signToken = (payload, secretKey) => {
8533
- const encodedPayload = gBase64.encode(JSON.stringify(payload));
8534
- const signature = detachedSign(encodedPayload, secretKey);
8535
- return `${encodedPayload}.${signature}`;
8536
- };
8537
- var parseToken = (token) => {
8538
- try {
8539
- const [payloadBase64] = token.split(".");
8540
- return JSON.parse(gBase64.decode(payloadBase64));
8541
- } catch {
8542
- return null;
8543
- }
8544
- };
8545
-
8546
- // packages/auth/action/signUpAction.ts
8547
- var TIMEOUT = 5e3;
8548
- var getSignUpErrorMessage = async (response) => {
8549
- try {
8550
- const payload = await response.clone().json();
8551
- if (typeof payload?.error === "string" && payload.error.trim()) {
8552
- return payload.error;
8553
- }
8554
- if (typeof payload?.message === "string" && payload.message.trim()) {
8555
- return payload.message;
8556
- }
8557
- } catch {
8558
- }
8559
- try {
8560
- const text = (await response.text()).trim();
8561
- if (text) return text;
8562
- } catch {
8563
- }
8564
- return `\u6CE8\u518C\u5931\u8D25\uFF0C\u670D\u52A1\u5668\u54CD\u5E94\u72B6\u6001\u7801\uFF1A${response.status}`;
8565
- };
8566
- var getPublicIp = async () => {
8567
- try {
8568
- const controller = new AbortController();
8569
- const timer = setTimeout(() => controller.abort(), 1500);
8570
- const res = await fetch("https://api.ipify.org?format=json", {
8571
- signal: controller.signal
8572
- });
8573
- clearTimeout(timer);
8574
- if (!res.ok) return null;
8575
- const data = await res.json();
8576
- return data?.ip || null;
8577
- } catch {
8578
- return null;
8579
- }
8580
- };
8581
- var signUpToServer = async (server, sendData, nolotusPubKey, signal) => {
8582
- const response = await fetch(`${server}${API_VERSION}/users/signup`, {
8583
- method: "POST",
8584
- headers: {
8585
- "Content-Type": "application/json",
8586
- ...sendData?.clientIp ? { "X-Client-IP": String(sendData.clientIp) } : {}
8587
- },
8588
- body: JSON.stringify(sendData),
8589
- signal
8590
- });
8591
- if (!response.ok) {
8592
- throw new Error(await getSignUpErrorMessage(response));
8593
- }
8594
- const { encryptedData } = await response.json();
8595
- const decryptedData = await verifySignedMessage(
8596
- encryptedData,
8597
- nolotusPubKey
8598
- );
8599
- const result = JSON.parse(decryptedData);
8600
- return result;
8601
- };
8602
- var signUpToBackupServers = (servers, sendData, nolotusPubKey) => {
8603
- servers.forEach((server) => {
8604
- const abortController = new AbortController();
8605
- const timeoutId = setTimeout(
8606
- () => abortController.abort(),
8607
- TIMEOUT
8608
- );
8609
- signUpToServer(server, sendData, nolotusPubKey, abortController.signal).then((result) => {
8610
- clearTimeout(timeoutId);
8611
- if (!result) {
8612
- }
8613
- }).catch(() => {
8614
- clearTimeout(timeoutId);
8615
- });
8616
- });
8617
- };
8618
- var signUpAction = async (user, thunkAPI) => {
8619
- const { username, locale, password, email, inviterId } = user;
8620
- const state6 = thunkAPI.getState();
8621
- const tokenManager = thunkAPI.extra.tokenManager;
8622
- const encryptionKey = await hashPasswordV1(password);
8623
- const { publicKey, secretKey } = generateKeyPairFromSeedV1(
8624
- username + encryptionKey + locale
8625
- );
8626
- const clientIp = await getPublicIp();
8627
- const sendData = {
8628
- username,
8629
- publicKey,
8630
- locale,
8631
- email,
8632
- inviterId,
8633
- clientIp
8634
- };
8635
- const nolotusPubKey = "pqjbGua2Rp-wkh3Vip1EBV6p4ggZWtWvGyNC37kKPus";
8636
- const currentServer = selectRemoteServer(state6);
8637
- const configuredSyncServers = selectRemoteSyncServers(state6) ?? [];
8638
- const mainServers = getAllServers(currentServer, []);
8639
- const mainServer = mainServers[0];
8640
- if (!mainServer) {
8641
- throw new Error("No available server for sign up (possibly offline).");
8642
- }
8643
- const mainAbortController = new AbortController();
8644
- const mainTimeoutId = setTimeout(() => mainAbortController.abort(), TIMEOUT);
8645
- let remoteData;
8646
- try {
8647
- remoteData = await signUpToServer(
8648
- mainServer,
8649
- sendData,
8650
- nolotusPubKey,
8651
- mainAbortController.signal
8652
- );
8653
- } finally {
8654
- clearTimeout(mainTimeoutId);
8655
- }
8656
- if (!remoteData) {
8657
- throw new Error("Failed to register on current server");
8658
- }
8659
- const localUserId = generateUserIdV1(publicKey, username, locale);
8660
- const isValid2 = remoteData.publicKey === publicKey && remoteData.username === username && remoteData.userId === localUserId;
8661
- if (!isValid2) {
8662
- throw new Error("Server data does not match local data");
8663
- }
8664
- const backupCandidates = getAllServers(void 0, configuredSyncServers);
8665
- const backupServers = backupCandidates.filter((s) => s !== mainServer);
8666
- if (backupServers.length > 0) {
8667
- Promise.resolve().then(() => {
8668
- signUpToBackupServers(backupServers, sendData, nolotusPubKey);
8669
- });
8670
- }
8671
- const nowSec = Math.floor(Date.now() / 1e3);
8672
- const token = signToken(
8673
- buildPersistentAuthTokenPayload(
8674
- {
8675
- userId: localUserId,
8676
- username,
8677
- publicKey,
8678
- tokenVersion: Math.max(
8679
- 0,
8680
- Math.floor(asOptionalFiniteNumber(remoteData.tokenVersion) ?? 0)
8681
- )
8682
- },
8683
- nowSec
8684
- ),
8685
- secretKey
8686
- );
8687
- await resetAuthScopedClientState(thunkAPI.dispatch);
8688
- await tokenManager.storeToken(token);
8689
- const parsedUser = parseToken(token);
8690
- return { user: parsedUser, token };
8691
- };
8692
-
8693
- // packages/auth/client/loginRequest.ts
8694
- var loginRequest = async (currentServer, data) => {
8695
- const path = authRoutes.login.createPath();
8696
- const fullUrl = `${currentServer}${path}`;
8697
- console.log(`[Auth] loginRequest \u2192 ${fullUrl}`, {
8698
- userId: data?.userId,
8699
- hasToken: Boolean(data?.token)
8700
- });
8701
- try {
8702
- const response = await fetch(fullUrl, {
8703
- method: authRoutes.login.method,
8704
- headers: {
8705
- "Content-Type": "application/json"
8706
- },
8707
- body: JSON.stringify(data)
8708
- });
8709
- console.log(`[Auth] loginRequest \u2190 ${response.status} ${response.statusText} from ${fullUrl}`);
8710
- return response;
8711
- } catch (error) {
8712
- console.error(`[Auth] loginRequest \u2717 network error from ${fullUrl}:`, error?.message || error);
8713
- throw error;
8714
- }
8715
- };
8716
-
8717
- // packages/auth/authSlice.ts
8718
- var getLoginErrorMessage = async (response) => {
8719
- try {
8720
- const payload = await response.clone().json();
8721
- if (typeof payload?.error === "string" && payload.error.trim()) {
8722
- return payload.error;
8723
- }
8724
- if (typeof payload?.message === "string" && payload.message.trim()) {
8725
- return payload.message;
8726
- }
8727
- } catch {
8728
- }
8729
- try {
8730
- const text = (await response.text()).trim();
8731
- if (text) return text;
8732
- } catch {
8733
- }
8734
- return `\u670D\u52A1\u5668\u54CD\u5E94\u72B6\u6001\u7801\uFF1A${response.status}`;
8735
- };
8736
- var initialState2 = {
8737
- currentUser: null,
8738
- users: [],
8739
- isLoggedIn: false,
8740
- currentToken: null,
8741
- isLoading: false,
8742
- isInitialized: false
8743
- };
8744
- var isUser = (value) => typeof value === "object" && value !== null && typeof value.userId === "string";
8745
- var parseUserToken = (token) => {
8746
- const parsed = parseToken(token);
8747
- return isUser(parsed) ? parsed : null;
8748
- };
8749
- var parseStoredTokenEntries = (tokens) => {
8750
- const seenUserIds = /* @__PURE__ */ new Set();
8751
- return tokens.flatMap((token) => {
8752
- const user = parseUserToken(token);
8753
- if (user && seenUserIds.has(user.userId)) return [];
8754
- if (user) seenUserIds.add(user.userId);
8755
- return user ? [{ token, user }] : [];
8756
- });
8757
- };
8758
- var compactUsers = (users) => users.filter(isUser);
8759
- var compactUniqueUsers = (users) => {
8760
- const seenUserIds = /* @__PURE__ */ new Set();
8761
- return compactUsers(users).filter((user) => {
8762
- if (seenUserIds.has(user.userId)) return false;
8763
- seenUserIds.add(user.userId);
8764
- return true;
8765
- });
8766
- };
8767
- function mergeUserState(existingUser, nextUser) {
8768
- if (!existingUser || existingUser.userId !== nextUser.userId) {
8769
- return nextUser;
8770
- }
8771
- return {
8772
- ...existingUser,
8773
- ...nextUser
8774
- };
8775
- }
8776
- var createSliceWithThunks2 = buildCreateSlice({
8777
- creators: { asyncThunk: asyncThunkCreator }
8778
- });
8779
- var authSlice = createSliceWithThunks2({
8780
- name: "auth",
8781
- initialState: initialState2,
8782
- reducers: (create) => ({
8783
- signIn: create.asyncThunk(
8784
- async (input, thunkAPI) => {
8785
- const { tokenManager } = thunkAPI.extra;
8786
- const state6 = thunkAPI.getState();
8787
- const startTime = Date.now();
8788
- console.log("[Auth] signIn thunk started");
8789
- try {
8790
- const { username, locale, localeCandidates: rawLocaleCandidates, password } = input;
8791
- const hashStart = Date.now();
8792
- const encryptionKey = await hashPasswordV1(password);
8793
- console.log(`[Auth] hashPasswordV1 took ${Date.now() - hashStart}ms`);
8794
- const nowSec = Math.floor(Date.now() / 1e3);
8795
- const currentServer = selectRemoteServer(state6);
8796
- console.log(`[Auth] currentServer resolved to: ${currentServer}`);
8797
- const localeCandidates = [
8798
- ...new Set(
8799
- asTrimmedNonEmptyStringArray(
8800
- Array.isArray(rawLocaleCandidates) && rawLocaleCandidates.length > 0 ? rawLocaleCandidates : [locale]
8801
- )
8802
- )
8803
- ];
8804
- console.log(`[Auth] localeCandidates: [${localeCandidates.join(", ")}]`);
8805
- let matchedPublicKey = null;
8806
- let matchedSecretKey = null;
8807
- let matchedUserId = null;
8808
- let res = null;
8809
- let preferredErrorMessage = null;
8810
- let notFoundErrorMessage = null;
8811
- for (const loginLocale of localeCandidates) {
8812
- const keyGenStart = Date.now();
8813
- const { publicKey, secretKey } = generateKeyPairFromSeedV1(
8814
- username + encryptionKey + loginLocale
8815
- );
8816
- console.log(
8817
- `[Auth] generateKeyPairFromSeedV1 took ${Date.now() - keyGenStart}ms for locale ${loginLocale}`
8818
- );
8819
- const userId = generateUserIdV1(publicKey, username, loginLocale);
8820
- console.log(`[Auth] generated userId=${userId} (username=${username}, locale=${loginLocale})`);
8821
- const loginToken = signToken(
8822
- buildPersistentAuthTokenPayload({ userId, publicKey, username }, nowSec),
8823
- secretKey
8824
- );
8825
- console.log(`[Auth] Sending loginRequest to: ${currentServer} (locale=${loginLocale})`);
8826
- const networkStart = Date.now();
8827
- const attemptResponse = await loginRequest(currentServer, { userId, token: loginToken });
8828
- console.log(
8829
- `[Auth] loginRequest took ${Date.now() - networkStart}ms, status: ${attemptResponse.status}, locale=${loginLocale}`
8830
- );
8831
- if (attemptResponse.status === 200) {
8832
- matchedPublicKey = publicKey;
8833
- matchedSecretKey = secretKey;
8834
- matchedUserId = userId;
8835
- res = attemptResponse;
8836
- break;
8837
- }
8838
- const errorMessage = await getLoginErrorMessage(attemptResponse);
8839
- if (attemptResponse.status === 404) {
8840
- notFoundErrorMessage = errorMessage;
8841
- continue;
8842
- }
8843
- preferredErrorMessage = errorMessage;
8844
- }
8845
- if (!res || !matchedPublicKey || !matchedSecretKey || !matchedUserId) {
8846
- return thunkAPI.rejectWithValue(
8847
- preferredErrorMessage || notFoundErrorMessage || "\u767B\u5F55\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u8D26\u53F7\u4FE1\u606F\u540E\u91CD\u8BD5\u3002"
8848
- );
8849
- }
8850
- const result = await res.json();
8851
- const tokenVersion = Math.max(
8852
- 0,
8853
- Math.floor(asOptionalFiniteNumber(result?.tokenVersion) ?? 0)
8854
- );
8855
- const token = signToken(
8856
- buildPersistentAuthTokenPayload(
8857
- { userId: matchedUserId, publicKey: matchedPublicKey, username, tokenVersion },
8858
- Math.floor(Date.now() / 1e3)
8859
- ),
8860
- matchedSecretKey
8861
- );
8862
- const storageStart = Date.now();
8863
- await resetAuthScopedClientState(thunkAPI.dispatch);
8864
- await tokenManager.storeToken(token);
8865
- const parsedUser = parseUserToken(token);
8866
- if (!parsedUser) {
8867
- return thunkAPI.rejectWithValue("\u767B\u5F55\u72B6\u6001\u89E3\u6790\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002");
8868
- }
8869
- console.log(`[Auth] token storage took ${Date.now() - storageStart}ms`);
8870
- console.log(`[Auth] Total signIn thunk took ${Date.now() - startTime}ms`);
8871
- return { token };
8872
- } catch (error) {
8873
- console.error("[Auth] signIn thunk error:", error);
8874
- return thunkAPI.rejectWithValue(toErrorMessage(error));
8875
- }
8876
- },
8877
- {
8878
- pending: (state6) => {
8879
- state6.isLoading = true;
8880
- },
8881
- rejected: (state6) => {
8882
- state6.isLoading = false;
8883
- },
8884
- fulfilled: (state6, action) => {
8885
- const { token } = action.payload;
8886
- const user = parseUserToken(token);
8887
- if (!user) {
8888
- state6.isLoading = false;
8889
- return;
8890
- }
8891
- const existingUsers = compactUniqueUsers(state6.users);
8892
- state6.currentUser = mergeUserState(state6.currentUser, user);
8893
- state6.currentToken = token;
8894
- state6.isLoggedIn = true;
8895
- state6.users = [user, ...existingUsers.filter((item) => item.userId !== user.userId)];
8896
- state6.isLoading = false;
8897
- }
8898
- }
8899
- ),
8900
- signUp: create.asyncThunk(signUpAction, {
8901
- /* ... signUp implementation ... */
8902
- fulfilled: (state6, action) => {
8903
- const { user, token } = action.payload;
8904
- state6.currentUser = user;
8905
- state6.isLoggedIn = true;
8906
- state6.users.unshift(user);
8907
- state6.currentToken = token;
8908
- }
8909
- }),
8910
- initializeAuth: create.asyncThunk(
8911
- /* ... initializeAuth implementation ... */
8912
- async (_, thunkAPI) => {
8913
- const { tokenManager } = thunkAPI.extra;
8914
- const tokens = await tokenManager.initTokens();
8915
- const tokenEntries = parseStoredTokenEntries(tokens ?? []);
8916
- if (tokenEntries.length !== (tokens?.length ?? 0)) {
8917
- const invalidTokens = (tokens ?? []).filter(
8918
- (token) => !tokenEntries.some((entry) => entry.token === token)
8919
- );
8920
- for (const invalidToken of invalidTokens) {
8921
- await tokenManager.removeToken(invalidToken);
8922
- }
8923
- }
8924
- if (tokenEntries.length > 0) {
8925
- return {
8926
- tokens: tokenEntries.map((entry) => entry.token),
8927
- user: tokenEntries[0]?.user ?? null
8928
- };
8929
- }
8930
- return { tokens: [], user: null };
8931
- },
8932
- {
8933
- // 不设 pending:initialState 已是 false;运行中若重复 dispatch
8934
- // (热更新/重连)会把已 true 的状态打回 false 导致已展示页面闪回
8935
- // PageLoading。只在 fulfilled/rejected 设 true。
8936
- rejected: (state6) => {
8937
- state6.isInitialized = true;
8938
- },
8939
- fulfilled: (state6, action) => {
8940
- const { tokens, user } = action.payload;
8941
- if (user) {
8942
- state6.currentUser = user;
8943
- state6.isLoggedIn = true;
8944
- }
8945
- if (tokens && tokens.length > 0) {
8946
- state6.currentToken = tokens[0];
8947
- state6.users = parseStoredTokenEntries(tokens).map((entry) => entry.user);
8948
- }
8949
- state6.isInitialized = true;
8950
- }
8951
- }
8952
- ),
8953
- signOut: create.asyncThunk(
8954
- /* ... signOut implementation ... */
8955
- async (_, thunkAPI) => {
8956
- const { tokenManager } = thunkAPI.extra;
8957
- const state6 = thunkAPI.getState();
8958
- const token = selectCurrentToken(state6);
8959
- await resetAuthScopedClientState(thunkAPI.dispatch);
8960
- if (token) {
8961
- await tokenManager.removeToken(token);
8962
- }
8963
- const remainingTokens = await tokenManager.getTokens();
8964
- return { tokens: remainingTokens };
8965
- },
8966
- {
8967
- fulfilled: (state6, action) => {
8968
- const { tokens } = action.payload;
8969
- const otherUsers = compactUniqueUsers(state6.users).filter(
8970
- (user) => user.userId !== state6.currentUser?.userId
8971
- );
8972
- if (otherUsers.length > 0) {
8973
- const nextUser = otherUsers[0];
8974
- const nextToken = tokens.find((t2) => parseUserToken(t2)?.userId === nextUser.userId) || null;
8975
- state6.currentUser = nextUser;
8976
- state6.users = otherUsers;
8977
- state6.currentToken = nextToken;
8978
- } else {
8979
- state6.isLoggedIn = false;
8980
- state6.currentUser = null;
8981
- state6.users = [];
8982
- state6.currentToken = null;
8983
- }
8984
- }
8985
- }
8986
- ),
8987
- replaceCurrentToken: create.asyncThunk(
8988
- async (input, thunkAPI) => {
8989
- const { tokenManager } = thunkAPI.extra;
8990
- const state6 = thunkAPI.getState();
8991
- const currentToken = selectCurrentToken(state6);
8992
- if (currentToken) {
8993
- await tokenManager.removeToken(currentToken);
8994
- }
8995
- await tokenManager.storeToken(input.token);
8996
- return { token: input.token };
8997
- },
8998
- {
8999
- fulfilled: (state6, action) => {
9000
- const nextUser = parseUserToken(action.payload.token);
9001
- if (!nextUser) {
9002
- return;
9003
- }
9004
- const existingUsers = compactUniqueUsers(state6.users);
9005
- state6.currentToken = action.payload.token;
9006
- state6.currentUser = mergeUserState(state6.currentUser, nextUser);
9007
- state6.users = [
9008
- mergeUserState(
9009
- existingUsers.find((item) => item.userId === nextUser.userId),
9010
- nextUser
9011
- ),
9012
- ...existingUsers.filter((item) => item.userId !== nextUser.userId)
9013
- ];
9014
- state6.isLoggedIn = true;
9015
- }
9016
- }
9017
- ),
9018
- changeUser: create.asyncThunk(
9019
- /* ... changeUser implementation ... */
9020
- async (user, thunkAPI) => {
9021
- const { tokenManager } = thunkAPI.extra;
9022
- const { dispatch } = thunkAPI;
9023
- try {
9024
- await resetAuthScopedClientState(dispatch);
9025
- await dispatch(fetchUserSpaceMemberships(user.userId)).unwrap();
9026
- } catch (error) {
9027
- console.warn("Failed to initialize user settings:", error);
9028
- }
9029
- const tokens = await tokenManager.getTokens();
9030
- const updatedToken = tokens.find(
9031
- (t2) => parseUserToken(t2)?.userId === user.userId
9032
- );
9033
- if (!updatedToken) {
9034
- return thunkAPI.rejectWithValue("Token not found for user");
9035
- }
9036
- await tokenManager.removeToken(updatedToken);
9037
- await tokenManager.storeToken(updatedToken);
9038
- return { user, token: updatedToken };
9039
- },
9040
- {
9041
- pending: (state6) => {
9042
- state6.isInitialized = false;
9043
- state6.currentUser = null;
9044
- },
9045
- fulfilled: (state6, action) => {
9046
- const { user, token } = action.payload;
9047
- state6.currentUser = user;
9048
- state6.currentToken = token;
9049
- state6.isInitialized = true;
9050
- state6.isLoggedIn = true;
9051
- },
9052
- rejected: (state6) => {
9053
- state6.isInitialized = true;
9054
- state6.isLoggedIn = false;
9055
- state6.currentToken = null;
9056
- }
9057
- }
9058
- ),
9059
- fetchUserProfile: create.asyncThunk(
9060
- /* ... fetchUserProfile implementation ... */
9061
- async (_, thunkAPI) => {
9062
- const state6 = thunkAPI.getState();
9063
- const serverUrl = selectRemoteServer(state6);
9064
- const token = selectCurrentToken(state6);
9065
- const currentUser = selectCurrentUser(state6);
9066
- console.log("[Auth] fetchUserProfile thunk started. User:", currentUser?.userId);
9067
- if (!serverUrl || !token || !currentUser?.userId) {
9068
- return thunkAPI.rejectWithValue(
9069
- "\u65E0\u6CD5\u83B7\u53D6\u7528\u6237\u4FE1\u606F\uFF1A\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570\uFF08\u670D\u52A1\u5668\u5730\u5740\u3001Token\u6216\u7528\u6237ID\uFF09"
9070
- );
9071
- }
9072
- const { userId } = currentUser;
9073
- const path = authRoutes.users.detail.createPath({ userId });
9074
- const url = `${serverUrl}${path}`;
9075
- try {
9076
- const response = await fetchWithTransientReadRetry(url, {
9077
- method: authRoutes.users.detail.method,
9078
- headers: {
9079
- Authorization: `Bearer ${token}`
9080
- }
9081
- });
9082
- if (!response.ok) {
9083
- const errorText = await response.text();
9084
- return thunkAPI.rejectWithValue(
9085
- `\u8BF7\u6C42\u5931\u8D25: ${response.status} ${errorText}`
9086
- );
9087
- }
9088
- const profileData = await response.json();
9089
- return {
9090
- userId,
9091
- balance: profileData.balance,
9092
- gptProAccess: profileData.gptProAccess,
9093
- adminPermissions: profileData.adminPermissions
9094
- };
9095
- } catch (error) {
9096
- return thunkAPI.rejectWithValue(
9097
- error.message || "\u83B7\u53D6\u7528\u6237\u4FE1\u606F\u65F6\u53D1\u751F\u672A\u77E5\u9519\u8BEF"
9098
- );
9099
- }
9100
- },
9101
- {
9102
- rejected: (state6, action) => {
9103
- console.error("\u83B7\u53D6\u7528\u6237 Profile \u5931\u8D25:", action.payload);
9104
- },
9105
- fulfilled: (state6, action) => {
9106
- const { userId, balance, gptProAccess, adminPermissions } = action.payload;
9107
- if (state6.currentUser && state6.currentUser.userId === userId) {
9108
- state6.currentUser.balance = balance;
9109
- state6.currentUser.gptProAccess = gptProAccess;
9110
- state6.currentUser.adminPermissions = adminPermissions;
9111
- }
9112
- const userIndex = state6.users.findIndex(
9113
- (user) => user.userId === userId
9114
- );
9115
- if (userIndex !== -1) {
9116
- state6.users[userIndex].balance = balance;
9117
- state6.users[userIndex].gptProAccess = gptProAccess;
9118
- state6.users[userIndex].adminPermissions = adminPermissions;
9119
- }
9120
- }
9121
- }
9122
- ),
9123
- // 前端临时扣款: 接收一个 cost 数值,从当前用户的余额中扣除。
9124
- // 这可以让 UI 实时显示余额变化,而无需等待下一次从服务器完整刷新。
9125
- deductBalance: create.reducer((state6, action) => {
9126
- const cost = action.payload;
9127
- if (state6.currentUser && typeof state6.currentUser.balance === "number") {
9128
- state6.currentUser.balance -= cost;
9129
- }
9130
- if (state6.currentUser) {
9131
- const userInArray = state6.users.find(
9132
- (u) => u.userId === state6.currentUser.userId
9133
- );
9134
- if (userInArray && typeof userInArray.balance === "number") {
9135
- userInArray.balance -= cost;
9136
- }
9137
- }
9138
- })
9139
- })
9140
- });
9141
- var {
9142
- signIn,
9143
- signUp,
9144
- signOut,
9145
- replaceCurrentToken,
9146
- changeUser,
9147
- initializeAuth,
9148
- fetchUserProfile,
9149
- deductBalance
9150
- // 导出新的 action
9151
- } = authSlice.actions;
9152
- var authSlice_default = authSlice.reducer;
9153
- var selectCurrentUser = (state6) => state6.auth?.currentUser;
9154
- var selectCurrentToken = (state6) => state6.auth?.currentToken ?? null;
9155
-
9156
6527
  // packages/app/hooks/useHasMounted.ts
9157
6528
  var import_react13 = __toESM(require_react());
9158
6529
 
@@ -9167,9 +6538,9 @@ var createInitialState4 = () => ({
9167
6538
  });
9168
6539
  var state4 = createInitialState4();
9169
6540
  var listeners4 = /* @__PURE__ */ new Set();
9170
- var version5 = 0;
6541
+ var version4 = 0;
9171
6542
  var notify4 = () => {
9172
- version5 += 1;
6543
+ version4 += 1;
9173
6544
  for (const listener of listeners4) {
9174
6545
  try {
9175
6546
  listener();
@@ -9177,10 +6548,6 @@ var notify4 = () => {
9177
6548
  }
9178
6549
  }
9179
6550
  };
9180
- function resetFavorites() {
9181
- state4 = createInitialState4();
9182
- notify4();
9183
- }
9184
6551
  function removeFavoriteLocally(payload) {
9185
6552
  const { targetType, id } = payload;
9186
6553
  if (targetType === "agent") {
@@ -9686,7 +7053,7 @@ var fetchSpaceAction = async (input, thunkAPI) => {
9686
7053
  const spaceKey = createSpaceKey.space(spaceId);
9687
7054
  const readSpace = async (dbKey) => {
9688
7055
  try {
9689
- const { read: read2, readAndWait: readAndWait2 } = await import("./dbSlice-UI2VCBLG.js");
7056
+ const { read: read2, readAndWait: readAndWait2 } = await import("./dbSlice-PIQGICNM.js");
9690
7057
  if (fresh) {
9691
7058
  return await dispatch(readAndWait2(dbKey)).unwrap();
9692
7059
  }
@@ -9998,9 +7365,9 @@ var createInitialState5 = () => ({
9998
7365
  });
9999
7366
  var state5 = createInitialState5();
10000
7367
  var listeners5 = /* @__PURE__ */ new Set();
10001
- var version6 = 0;
7368
+ var version5 = 0;
10002
7369
  var notify5 = () => {
10003
- version6 += 1;
7370
+ version5 += 1;
10004
7371
  for (const listener of listeners5) {
10005
7372
  try {
10006
7373
  listener();
@@ -10070,13 +7437,13 @@ function getCurrentSpace(entities) {
10070
7437
  }
10071
7438
 
10072
7439
  // packages/create/space/spaceSlice.ts
10073
- var createSliceWithThunks3 = buildCreateSlice({
7440
+ var createSliceWithThunks2 = buildCreateSlice({
10074
7441
  creators: { asyncThunk: asyncThunkCreator }
10075
7442
  });
10076
- var initialState3 = {};
10077
- var spaceSlice = createSliceWithThunks3({
7443
+ var initialState2 = {};
7444
+ var spaceSlice = createSliceWithThunks2({
10078
7445
  name: "space",
10079
- initialState: initialState3,
7446
+ initialState: initialState2,
10080
7447
  reducers: (create) => ({
10081
7448
  ...createSpaceThunks(create),
10082
7449
  ...createCategoryActions(create),
@@ -10100,7 +7467,7 @@ var spaceSlice = createSliceWithThunks3({
10100
7467
  markDialogRead: create.asyncThunk(
10101
7468
  async (payload, thunkAPI) => {
10102
7469
  if (payload.dialogKey) {
10103
- const { patch: patch2 } = await import("./dbSlice-UI2VCBLG.js");
7470
+ const { patch: patch2 } = await import("./dbSlice-PIQGICNM.js");
10104
7471
  try {
10105
7472
  await thunkAPI.dispatch(
10106
7473
  patch2({ dbKey: payload.dialogKey, changes: { unreadAt: null } })