sa2kit 2.0.4 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. package/dist/{UniversalFileService-GsP6D3Rc.d.ts → UniversalFileService-CC4d3wkc.d.ts} +2 -2
  2. package/dist/{UniversalFileService-BpvbZitV.d.mts → UniversalFileService-CzAE_G4V.d.mts} +2 -2
  3. package/dist/auth/client/index.d.mts +8 -27
  4. package/dist/auth/client/index.d.ts +8 -27
  5. package/dist/auth/client/index.js +9 -4
  6. package/dist/auth/client/index.mjs +2 -1
  7. package/dist/auth/components/index.d.mts +8 -225
  8. package/dist/auth/components/index.d.ts +8 -225
  9. package/dist/auth/components/index.js +62 -319
  10. package/dist/auth/components/index.js.map +1 -1
  11. package/dist/auth/components/index.mjs +6 -316
  12. package/dist/auth/components/index.mjs.map +1 -1
  13. package/dist/auth/hooks/index.d.mts +11 -29
  14. package/dist/auth/hooks/index.d.ts +11 -29
  15. package/dist/auth/hooks/index.js +14 -3
  16. package/dist/auth/hooks/index.mjs +4 -1
  17. package/dist/auth/index.d.mts +17 -14
  18. package/dist/auth/index.d.ts +17 -14
  19. package/dist/auth/index.js +51 -90
  20. package/dist/auth/index.mjs +8 -7
  21. package/dist/auth/rn/index.d.mts +3087 -18
  22. package/dist/auth/rn/index.d.ts +3087 -18
  23. package/dist/auth/rn/index.js +396 -477
  24. package/dist/auth/rn/index.js.map +1 -1
  25. package/dist/auth/rn/index.mjs +384 -475
  26. package/dist/auth/rn/index.mjs.map +1 -1
  27. package/dist/auth/schema/index.d.mts +3 -788
  28. package/dist/auth/schema/index.d.ts +3 -788
  29. package/dist/auth/schema/index.js +17 -9
  30. package/dist/auth/schema/index.mjs +1 -1
  31. package/dist/auth/services/index.d.mts +1 -48
  32. package/dist/auth/services/index.d.ts +1 -48
  33. package/dist/auth/services/index.js +3 -20
  34. package/dist/auth/services/index.mjs +1 -2
  35. package/dist/{base-api-client-B3wZZoaH.d.ts → base-api-client-BpmcQt4Q.d.ts} +1 -1
  36. package/dist/{base-api-client-ACKKt13v.d.mts → base-api-client-CFIhZK4C.d.mts} +1 -1
  37. package/dist/{base-api-client-ACKKt13v.d.ts → base-api-client-CFIhZK4C.d.ts} +1 -1
  38. package/dist/{base-api-client-DrL35Ea2.d.mts → base-api-client-DXLsq2yz.d.mts} +1 -1
  39. package/dist/business/index.d.mts +1 -5
  40. package/dist/business/index.d.ts +1 -5
  41. package/dist/business/index.js +34 -1135
  42. package/dist/business/index.js.map +1 -1
  43. package/dist/business/index.mjs +5 -1105
  44. package/dist/business/index.mjs.map +1 -1
  45. package/dist/calendar/routes/index.d.mts +74 -1
  46. package/dist/calendar/routes/index.d.ts +74 -1
  47. package/dist/calendar/routes/index.js +186 -97
  48. package/dist/calendar/routes/index.js.map +1 -1
  49. package/dist/calendar/routes/index.mjs +178 -99
  50. package/dist/calendar/routes/index.mjs.map +1 -1
  51. package/dist/{chunk-IIVNHQEI.mjs → chunk-5GBDDXYL.mjs} +4 -3
  52. package/dist/chunk-5GBDDXYL.mjs.map +1 -0
  53. package/dist/chunk-7E3J7VAD.mjs +3 -0
  54. package/dist/chunk-7E3J7VAD.mjs.map +1 -0
  55. package/dist/chunk-B3CZ3HXJ.mjs +126 -0
  56. package/dist/chunk-B3CZ3HXJ.mjs.map +1 -0
  57. package/dist/chunk-CAYOQDBR.js +78 -0
  58. package/dist/chunk-CAYOQDBR.js.map +1 -0
  59. package/dist/{chunk-PTMSDNGO.mjs → chunk-CX2GHCAI.mjs} +4 -75
  60. package/dist/chunk-CX2GHCAI.mjs.map +1 -0
  61. package/dist/chunk-EBHPTFG6.mjs +82 -0
  62. package/dist/chunk-EBHPTFG6.mjs.map +1 -0
  63. package/dist/chunk-FOQEQWX5.js +4 -0
  64. package/dist/chunk-FOQEQWX5.js.map +1 -0
  65. package/dist/{chunk-YGI7UU2D.mjs → chunk-G4NFB2QA.mjs} +2 -2
  66. package/dist/chunk-G4NFB2QA.mjs.map +1 -0
  67. package/dist/chunk-G5HJGXGC.mjs +39 -0
  68. package/dist/chunk-G5HJGXGC.mjs.map +1 -0
  69. package/dist/{chunk-GSNGCENJ.js → chunk-GQZHGSRR.js} +2 -39
  70. package/dist/chunk-GQZHGSRR.js.map +1 -0
  71. package/dist/chunk-GS7XLKET.js +41 -0
  72. package/dist/chunk-GS7XLKET.js.map +1 -0
  73. package/dist/{chunk-7B5SI4OF.mjs → chunk-IBWDBBX5.mjs} +4 -3
  74. package/dist/chunk-IBWDBBX5.mjs.map +1 -0
  75. package/dist/chunk-IS7O4LPI.js +146 -0
  76. package/dist/chunk-IS7O4LPI.js.map +1 -0
  77. package/dist/chunk-LGHUCQIU.js +93 -0
  78. package/dist/chunk-LGHUCQIU.js.map +1 -0
  79. package/dist/chunk-LHJKLUM7.mjs +18 -0
  80. package/dist/chunk-LHJKLUM7.mjs.map +1 -0
  81. package/dist/chunk-LKBIVQBT.mjs +34 -0
  82. package/dist/chunk-LKBIVQBT.mjs.map +1 -0
  83. package/dist/chunk-MIDXG6LS.js +32 -0
  84. package/dist/chunk-MIDXG6LS.js.map +1 -0
  85. package/dist/chunk-MWSAH7ZG.mjs +42 -0
  86. package/dist/chunk-MWSAH7ZG.mjs.map +1 -0
  87. package/dist/{chunk-HCI6JQOU.mjs → chunk-MZOGYD4N.mjs} +7 -4
  88. package/dist/chunk-MZOGYD4N.mjs.map +1 -0
  89. package/dist/chunk-NDGHXVGS.js +25 -0
  90. package/dist/chunk-NDGHXVGS.js.map +1 -0
  91. package/dist/chunk-Q5VFBPMG.mjs +76 -0
  92. package/dist/chunk-Q5VFBPMG.mjs.map +1 -0
  93. package/dist/chunk-QDUBO567.js +1148 -0
  94. package/dist/chunk-QDUBO567.js.map +1 -0
  95. package/dist/{chunk-3CSCIRQY.js → chunk-QP5N3ER6.js} +6 -5
  96. package/dist/chunk-QP5N3ER6.js.map +1 -0
  97. package/dist/chunk-RWCD2CAD.mjs +1132 -0
  98. package/dist/chunk-RWCD2CAD.mjs.map +1 -0
  99. package/dist/{chunk-VQ54PUQV.js → chunk-S37OK2QG.js} +2 -2
  100. package/dist/chunk-S37OK2QG.js.map +1 -0
  101. package/dist/chunk-S3PUP7N4.js +20 -0
  102. package/dist/chunk-S3PUP7N4.js.map +1 -0
  103. package/dist/{chunk-QQ2WFYOD.js → chunk-S6YSGVWD.js} +4 -76
  104. package/dist/chunk-S6YSGVWD.js.map +1 -0
  105. package/dist/chunk-SFDJNKWC.js +22 -0
  106. package/dist/chunk-SFDJNKWC.js.map +1 -0
  107. package/dist/chunk-TTYCVBIQ.mjs +144 -0
  108. package/dist/chunk-TTYCVBIQ.mjs.map +1 -0
  109. package/dist/{chunk-HBF4HPRK.js → chunk-TXMX6PZR.js} +7 -3
  110. package/dist/chunk-TXMX6PZR.js.map +1 -0
  111. package/dist/chunk-VHN7PF5I.js +20 -0
  112. package/dist/chunk-VHN7PF5I.js.map +1 -0
  113. package/dist/chunk-VJNDOYEC.js +41 -0
  114. package/dist/chunk-VJNDOYEC.js.map +1 -0
  115. package/dist/chunk-XBZIS3MV.mjs +13 -0
  116. package/dist/chunk-XBZIS3MV.mjs.map +1 -0
  117. package/dist/chunk-XFOZ56FB.mjs +20 -0
  118. package/dist/chunk-XFOZ56FB.mjs.map +1 -0
  119. package/dist/chunk-Z23HAXHL.js +136 -0
  120. package/dist/chunk-Z23HAXHL.js.map +1 -0
  121. package/dist/chunk-ZF7DKR5A.mjs +26 -0
  122. package/dist/chunk-ZF7DKR5A.mjs.map +1 -0
  123. package/dist/common/auth/client/index.d.mts +3239 -0
  124. package/dist/common/auth/client/index.d.ts +3239 -0
  125. package/dist/common/auth/client/index.js +26 -0
  126. package/dist/common/auth/client/index.mjs +5 -0
  127. package/dist/common/auth/components/index.d.mts +374 -0
  128. package/dist/common/auth/components/index.d.ts +374 -0
  129. package/dist/common/auth/components/index.js +70 -0
  130. package/dist/common/auth/components/index.mjs +9 -0
  131. package/dist/common/auth/hooks/index.d.mts +75 -0
  132. package/dist/common/auth/hooks/index.d.ts +75 -0
  133. package/dist/common/auth/hooks/index.js +28 -0
  134. package/dist/common/auth/hooks/index.js.map +1 -0
  135. package/dist/common/auth/hooks/index.mjs +7 -0
  136. package/dist/common/auth/hooks/index.mjs.map +1 -0
  137. package/dist/common/auth/index.d.mts +14 -6
  138. package/dist/common/auth/index.d.ts +14 -6
  139. package/dist/common/auth/index.js +17 -8
  140. package/dist/common/auth/index.mjs +4 -3
  141. package/dist/common/auth/react/index.d.mts +3056 -0
  142. package/dist/common/auth/react/index.d.ts +3056 -0
  143. package/dist/common/auth/react/index.js +31 -0
  144. package/dist/common/auth/react/index.js.map +1 -0
  145. package/dist/common/auth/react/index.mjs +21 -0
  146. package/dist/common/auth/react/index.mjs.map +1 -0
  147. package/dist/common/auth/rn/index.d.mts +3138 -0
  148. package/dist/common/auth/rn/index.d.ts +3138 -0
  149. package/dist/common/auth/rn/index.js +348 -0
  150. package/dist/common/auth/rn/index.js.map +1 -0
  151. package/dist/common/auth/rn/index.mjs +327 -0
  152. package/dist/common/auth/rn/index.mjs.map +1 -0
  153. package/dist/common/auth/schema/index.d.mts +1479 -0
  154. package/dist/common/auth/schema/index.d.ts +1479 -0
  155. package/dist/common/auth/schema/index.js +49 -0
  156. package/dist/common/auth/schema/index.js.map +1 -0
  157. package/dist/common/auth/schema/index.mjs +4 -0
  158. package/dist/common/auth/schema/index.mjs.map +1 -0
  159. package/dist/common/auth/server/index.d.mts +7 -30
  160. package/dist/common/auth/server/index.d.ts +7 -30
  161. package/dist/common/auth/server/index.js +36 -79
  162. package/dist/common/auth/server/index.mjs +2 -5
  163. package/dist/common/auth/services/index.d.mts +14 -0
  164. package/dist/common/auth/services/index.d.ts +14 -0
  165. package/dist/common/auth/services/index.js +17 -0
  166. package/dist/common/auth/services/index.js.map +1 -0
  167. package/dist/common/auth/services/index.mjs +4 -0
  168. package/dist/common/auth/services/index.mjs.map +1 -0
  169. package/dist/common/index.d.mts +13 -5
  170. package/dist/common/index.d.ts +13 -5
  171. package/dist/common/index.js +19 -16
  172. package/dist/common/index.mjs +11 -8
  173. package/dist/common/request/index.js +5 -4
  174. package/dist/common/request/index.mjs +3 -2
  175. package/dist/common/storage/index.js +13 -12
  176. package/dist/common/storage/index.mjs +3 -2
  177. package/dist/festivalCard/index.d.mts +3 -3
  178. package/dist/festivalCard/index.d.ts +3 -3
  179. package/dist/festivalCard/routes/index.d.mts +1 -1
  180. package/dist/festivalCard/routes/index.d.ts +1 -1
  181. package/dist/festivalCard/server/index.d.mts +2 -2
  182. package/dist/festivalCard/server/index.d.ts +2 -2
  183. package/dist/{festivalCardService-BFCRhJrq.d.ts → festivalCardService-B3GsnNpV.d.ts} +1 -1
  184. package/dist/{festivalCardService-GriR2VMc.d.mts → festivalCardService-CWhrLNE9.d.mts} +1 -1
  185. package/dist/{index-DPYkrKZf.d.mts → index-BcjDRcKp.d.mts} +11 -6
  186. package/dist/{index-Bnh6VqFv.d.ts → index-BlpXrrTy.d.ts} +11 -6
  187. package/dist/{index-1Ag7IBXN.d.ts → index-DZ5iJtNO.d.mts} +2 -44
  188. package/dist/{index-DdeZSeTJ.d.mts → index-DZ5iJtNO.d.ts} +2 -44
  189. package/dist/index.d.mts +6296 -40
  190. package/dist/index.d.ts +6296 -40
  191. package/dist/index.js +1378 -2508
  192. package/dist/index.js.map +1 -1
  193. package/dist/index.mjs +1073 -2203
  194. package/dist/index.mjs.map +1 -1
  195. package/dist/mmd/admin/index.d.mts +1 -1
  196. package/dist/mmd/admin/index.d.ts +1 -1
  197. package/dist/mmd/index.d.mts +1 -1
  198. package/dist/mmd/index.d.ts +1 -1
  199. package/dist/mmd/server/index.d.mts +3 -3
  200. package/dist/mmd/server/index.d.ts +3 -3
  201. package/dist/request/index.js +4 -3
  202. package/dist/request/index.mjs +2 -1
  203. package/dist/session-BCXvGCnm.d.mts +81 -0
  204. package/dist/session-BCXvGCnm.d.ts +81 -0
  205. package/dist/storage/index.js +12 -11
  206. package/dist/storage/index.mjs +2 -1
  207. package/dist/{types-DyG3ZV9V.d.mts → types-B6B210gX.d.mts} +1 -1
  208. package/dist/{types-DyG3ZV9V.d.ts → types-B6B210gX.d.ts} +1 -1
  209. package/dist/{types-BTiaMsBz.d.mts → types-Bdnte5EN.d.mts} +1 -1
  210. package/dist/{types-tQfupO6d.d.mts → types-Cs0CLvrH.d.mts} +1 -1
  211. package/dist/{types-tQfupO6d.d.ts → types-Cs0CLvrH.d.ts} +1 -1
  212. package/dist/{types-ERmJyjx8.d.ts → types-_rFX1atk.d.ts} +1 -1
  213. package/dist/types.legacy-J-j-_ig_.d.mts +25 -0
  214. package/dist/types.legacy-J-j-_ig_.d.ts +25 -0
  215. package/dist/useAuthActions-7S5dL7Oh.d.mts +77 -0
  216. package/dist/useAuthActions-7S5dL7Oh.d.ts +77 -0
  217. package/dist/vocaloidBooth/server/index.d.mts +3 -3
  218. package/dist/vocaloidBooth/server/index.d.ts +3 -3
  219. package/package.json +44 -76
  220. package/dist/auth/legacy/core/index.d.mts +0 -42
  221. package/dist/auth/legacy/core/index.d.ts +0 -42
  222. package/dist/auth/legacy/core/index.js +0 -242
  223. package/dist/auth/legacy/core/index.js.map +0 -1
  224. package/dist/auth/legacy/core/index.mjs +0 -226
  225. package/dist/auth/legacy/core/index.mjs.map +0 -1
  226. package/dist/auth/legacy/db/index.d.mts +0 -5
  227. package/dist/auth/legacy/db/index.d.ts +0 -5
  228. package/dist/auth/legacy/db/index.js +0 -261
  229. package/dist/auth/legacy/db/index.js.map +0 -1
  230. package/dist/auth/legacy/db/index.mjs +0 -250
  231. package/dist/auth/legacy/db/index.mjs.map +0 -1
  232. package/dist/auth/legacy/index.d.mts +0 -5
  233. package/dist/auth/legacy/index.d.ts +0 -5
  234. package/dist/auth/legacy/index.js +0 -1107
  235. package/dist/auth/legacy/index.js.map +0 -1
  236. package/dist/auth/legacy/index.mjs +0 -1086
  237. package/dist/auth/legacy/index.mjs.map +0 -1
  238. package/dist/auth/legacy/logic/index.d.mts +0 -9
  239. package/dist/auth/legacy/logic/index.d.ts +0 -9
  240. package/dist/auth/legacy/logic/index.js +0 -194
  241. package/dist/auth/legacy/logic/index.js.map +0 -1
  242. package/dist/auth/legacy/logic/index.mjs +0 -187
  243. package/dist/auth/legacy/logic/index.mjs.map +0 -1
  244. package/dist/auth/legacy/miniapp/index.d.mts +0 -5
  245. package/dist/auth/legacy/miniapp/index.d.ts +0 -5
  246. package/dist/auth/legacy/miniapp/index.js +0 -506
  247. package/dist/auth/legacy/miniapp/index.js.map +0 -1
  248. package/dist/auth/legacy/miniapp/index.mjs +0 -487
  249. package/dist/auth/legacy/miniapp/index.mjs.map +0 -1
  250. package/dist/auth/legacy/routes/index.d.mts +0 -53
  251. package/dist/auth/legacy/routes/index.d.ts +0 -53
  252. package/dist/auth/legacy/routes/index.js +0 -278
  253. package/dist/auth/legacy/routes/index.js.map +0 -1
  254. package/dist/auth/legacy/routes/index.mjs +0 -271
  255. package/dist/auth/legacy/routes/index.mjs.map +0 -1
  256. package/dist/auth/legacy/schema/index.d.mts +0 -401
  257. package/dist/auth/legacy/schema/index.d.ts +0 -401
  258. package/dist/auth/legacy/schema/index.js +0 -50
  259. package/dist/auth/legacy/schema/index.js.map +0 -1
  260. package/dist/auth/legacy/schema/index.mjs +0 -44
  261. package/dist/auth/legacy/schema/index.mjs.map +0 -1
  262. package/dist/auth/legacy/server/index.d.mts +0 -13
  263. package/dist/auth/legacy/server/index.d.ts +0 -13
  264. package/dist/auth/legacy/server/index.js +0 -21
  265. package/dist/auth/legacy/server/index.js.map +0 -1
  266. package/dist/auth/legacy/server/index.mjs +0 -19
  267. package/dist/auth/legacy/server/index.mjs.map +0 -1
  268. package/dist/auth/legacy/services/index.d.mts +0 -40
  269. package/dist/auth/legacy/services/index.d.ts +0 -40
  270. package/dist/auth/legacy/services/index.js +0 -258
  271. package/dist/auth/legacy/services/index.js.map +0 -1
  272. package/dist/auth/legacy/services/index.mjs +0 -252
  273. package/dist/auth/legacy/services/index.mjs.map +0 -1
  274. package/dist/auth/legacy/ui/miniapp/index.d.mts +0 -10
  275. package/dist/auth/legacy/ui/miniapp/index.d.ts +0 -10
  276. package/dist/auth/legacy/ui/miniapp/index.js +0 -298
  277. package/dist/auth/legacy/ui/miniapp/index.js.map +0 -1
  278. package/dist/auth/legacy/ui/miniapp/index.mjs +0 -290
  279. package/dist/auth/legacy/ui/miniapp/index.mjs.map +0 -1
  280. package/dist/auth/legacy/ui/web/index.d.mts +0 -22
  281. package/dist/auth/legacy/ui/web/index.d.ts +0 -22
  282. package/dist/auth/legacy/ui/web/index.js +0 -899
  283. package/dist/auth/legacy/ui/web/index.js.map +0 -1
  284. package/dist/auth/legacy/ui/web/index.mjs +0 -889
  285. package/dist/auth/legacy/ui/web/index.mjs.map +0 -1
  286. package/dist/auth/legacy/web/index.d.mts +0 -5
  287. package/dist/auth/legacy/web/index.d.ts +0 -5
  288. package/dist/auth/legacy/web/index.js +0 -1107
  289. package/dist/auth/legacy/web/index.js.map +0 -1
  290. package/dist/auth/legacy/web/index.mjs +0 -1086
  291. package/dist/auth/legacy/web/index.mjs.map +0 -1
  292. package/dist/auth/middleware/index.d.mts +0 -75
  293. package/dist/auth/middleware/index.d.ts +0 -75
  294. package/dist/auth/middleware/index.js +0 -15
  295. package/dist/auth/middleware/index.mjs +0 -6
  296. package/dist/auth/routes/index.d.mts +0 -261
  297. package/dist/auth/routes/index.d.ts +0 -261
  298. package/dist/auth/routes/index.js +0 -59
  299. package/dist/auth/routes/index.mjs +0 -6
  300. package/dist/chunk-37HYTHEC.mjs +0 -90
  301. package/dist/chunk-37HYTHEC.mjs.map +0 -1
  302. package/dist/chunk-3CSCIRQY.js.map +0 -1
  303. package/dist/chunk-5WV35FPV.js +0 -131
  304. package/dist/chunk-5WV35FPV.js.map +0 -1
  305. package/dist/chunk-7B5SI4OF.mjs.map +0 -1
  306. package/dist/chunk-DCRD5CZB.js +0 -573
  307. package/dist/chunk-DCRD5CZB.js.map +0 -1
  308. package/dist/chunk-DDX4JKFS.js +0 -19
  309. package/dist/chunk-DDX4JKFS.js.map +0 -1
  310. package/dist/chunk-DV6M7MFP.js +0 -283
  311. package/dist/chunk-DV6M7MFP.js.map +0 -1
  312. package/dist/chunk-EQXPL7TN.mjs +0 -78
  313. package/dist/chunk-EQXPL7TN.mjs.map +0 -1
  314. package/dist/chunk-GSNGCENJ.js.map +0 -1
  315. package/dist/chunk-HBF4HPRK.js.map +0 -1
  316. package/dist/chunk-HCI6JQOU.mjs.map +0 -1
  317. package/dist/chunk-I44HXJ3X.mjs +0 -17
  318. package/dist/chunk-I44HXJ3X.mjs.map +0 -1
  319. package/dist/chunk-IIVNHQEI.mjs.map +0 -1
  320. package/dist/chunk-IJ4YYWE3.mjs +0 -122
  321. package/dist/chunk-IJ4YYWE3.mjs.map +0 -1
  322. package/dist/chunk-J4BEIZUC.js +0 -92
  323. package/dist/chunk-J4BEIZUC.js.map +0 -1
  324. package/dist/chunk-OKPWFVXC.js +0 -24
  325. package/dist/chunk-OKPWFVXC.js.map +0 -1
  326. package/dist/chunk-PNOTQAYK.mjs +0 -560
  327. package/dist/chunk-PNOTQAYK.mjs.map +0 -1
  328. package/dist/chunk-PTMSDNGO.mjs.map +0 -1
  329. package/dist/chunk-Q2IAL7YV.js +0 -36
  330. package/dist/chunk-Q2IAL7YV.js.map +0 -1
  331. package/dist/chunk-QQ2WFYOD.js.map +0 -1
  332. package/dist/chunk-VQ54PUQV.js.map +0 -1
  333. package/dist/chunk-W5JEGA76.mjs +0 -33
  334. package/dist/chunk-W5JEGA76.mjs.map +0 -1
  335. package/dist/chunk-YGI7UU2D.mjs.map +0 -1
  336. package/dist/chunk-ZCLQSI5F.mjs +0 -271
  337. package/dist/chunk-ZCLQSI5F.mjs.map +0 -1
  338. package/dist/drizzle-auth-service-D-pljzCD.d.mts +0 -145
  339. package/dist/drizzle-auth-service-D3qryE_I.d.ts +0 -145
  340. package/dist/index-DNKZ7-R_.d.mts +0 -184
  341. package/dist/index-DNKZ7-R_.d.ts +0 -184
  342. package/dist/types-C5vUWf9u.d.ts +0 -70
  343. package/dist/types-IYCqCk2g.d.mts +0 -70
  344. /package/dist/{auth/middleware → common/auth/client}/index.js.map +0 -0
  345. /package/dist/{auth/middleware → common/auth/client}/index.mjs.map +0 -0
  346. /package/dist/{auth/routes → common/auth/components}/index.js.map +0 -0
  347. /package/dist/{auth/routes → common/auth/components}/index.mjs.map +0 -0
@@ -1,4 +1,6 @@
1
- import React2, { useState, useEffect, useCallback } from 'react';
1
+ import { createAuthClient } from 'better-auth/react';
2
+ import { emailOTPClient, phoneNumberClient } from 'better-auth/client/plugins';
3
+ import React, { useState, useEffect, useCallback } from 'react';
2
4
 
3
5
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
4
6
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -7,6 +9,383 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
7
9
  throw Error('Dynamic require of "' + x + '" is not supported');
8
10
  });
9
11
 
12
+ // src/storage/adapters/react-native-adapter.ts
13
+ var AsyncStorage = null;
14
+ try {
15
+ AsyncStorage = __require("@react-native-async-storage/async-storage").default;
16
+ } catch (e) {
17
+ }
18
+ var ReactNativeStorageAdapter = class {
19
+ constructor() {
20
+ this.listeners = /* @__PURE__ */ new Map();
21
+ }
22
+ async getItem(key) {
23
+ if (!AsyncStorage) return null;
24
+ try {
25
+ return await AsyncStorage.getItem(key);
26
+ } catch (error) {
27
+ console.error('[ReactNativeStorage] Error getting item "' + key + '":', error);
28
+ return null;
29
+ }
30
+ }
31
+ async setItem(key, value) {
32
+ if (!AsyncStorage) {
33
+ throw new Error("AsyncStorage is not available");
34
+ }
35
+ try {
36
+ await AsyncStorage.setItem(key, value);
37
+ this.notifyListeners(key, value);
38
+ } catch (error) {
39
+ console.error('[ReactNativeStorage] Error setting item "' + key + '":', error);
40
+ throw error;
41
+ }
42
+ }
43
+ async removeItem(key) {
44
+ if (!AsyncStorage) {
45
+ throw new Error("AsyncStorage is not available");
46
+ }
47
+ try {
48
+ await AsyncStorage.removeItem(key);
49
+ this.notifyListeners(key, null);
50
+ } catch (error) {
51
+ console.error('[ReactNativeStorage] Error removing item "' + key + '":', error);
52
+ throw error;
53
+ }
54
+ }
55
+ async clear() {
56
+ if (!AsyncStorage) {
57
+ throw new Error("AsyncStorage is not available");
58
+ }
59
+ try {
60
+ await AsyncStorage.clear();
61
+ } catch (error) {
62
+ console.error("[ReactNativeStorage] Error clearing storage:", error);
63
+ throw error;
64
+ }
65
+ }
66
+ addChangeListener(callback) {
67
+ if (!this.listeners.has("*")) {
68
+ this.listeners.set("*", /* @__PURE__ */ new Set());
69
+ }
70
+ this.listeners.get("*").add(callback);
71
+ return () => {
72
+ this.listeners.get("*")?.delete(callback);
73
+ };
74
+ }
75
+ notifyListeners(key, value) {
76
+ const globalListeners = this.listeners.get("*");
77
+ if (globalListeners) {
78
+ globalListeners.forEach((callback) => callback(key, value));
79
+ }
80
+ }
81
+ };
82
+
83
+ // src/common/auth/rn/token-storage.ts
84
+ var RN_BEARER_TOKEN_KEY = "sa2kit_auth_bearer_token";
85
+ var storageOverride = null;
86
+ var defaultStorage = new ReactNativeStorageAdapter();
87
+ function storage() {
88
+ return storageOverride ?? defaultStorage;
89
+ }
90
+ function setRnBearerTokenStorage(next) {
91
+ storageOverride = next;
92
+ }
93
+ async function getRnBearerToken() {
94
+ return storage().getItem(RN_BEARER_TOKEN_KEY);
95
+ }
96
+ async function setRnBearerToken(token) {
97
+ await storage().setItem(RN_BEARER_TOKEN_KEY, token);
98
+ }
99
+ async function clearRnBearerToken() {
100
+ await storage().removeItem(RN_BEARER_TOKEN_KEY);
101
+ }
102
+
103
+ // src/common/auth/rn/create-rn-auth-client.ts
104
+ function normalizeRnAuthBaseUrl(authApiBase) {
105
+ const trimmed = authApiBase.replace(/\/+$/, "");
106
+ if (trimmed.endsWith("/api/auth")) {
107
+ return {
108
+ baseURL: trimmed.slice(0, -"/api/auth".length),
109
+ basePath: "/api/auth"
110
+ };
111
+ }
112
+ if (trimmed.endsWith("/api")) {
113
+ return {
114
+ baseURL: trimmed.slice(0, -"/api".length),
115
+ basePath: "/api/auth"
116
+ };
117
+ }
118
+ return {
119
+ baseURL: trimmed,
120
+ basePath: "/api/auth"
121
+ };
122
+ }
123
+ function buildSa2kitRnAuthClient(options) {
124
+ return createAuthClient({
125
+ baseURL: options.baseURL.replace(/\/+$/, ""),
126
+ basePath: options.basePath ?? "/api/auth",
127
+ plugins: [emailOTPClient(), phoneNumberClient()],
128
+ disableDefaultFetchPlugins: false,
129
+ fetchOptions: {
130
+ credentials: "omit",
131
+ onRequest: async (ctx) => {
132
+ const token = await getRnBearerToken();
133
+ if (token) {
134
+ ctx.headers.set("Authorization", `Bearer ${token}`);
135
+ }
136
+ return ctx;
137
+ },
138
+ onResponse: async (ctx) => {
139
+ const token = ctx.response.headers.get("set-auth-token");
140
+ if (token) {
141
+ await setRnBearerToken(token);
142
+ }
143
+ return ctx;
144
+ }
145
+ }
146
+ });
147
+ }
148
+ var cachedClient = null;
149
+ var cachedKey = "";
150
+ function cacheKey(options) {
151
+ return `${options.baseURL}|${options.basePath ?? "/api/auth"}`;
152
+ }
153
+ function createSa2kitRnAuthClient(options) {
154
+ const key = cacheKey(options);
155
+ if (cachedClient && cachedKey === key) {
156
+ return cachedClient;
157
+ }
158
+ cachedClient = buildSa2kitRnAuthClient(options);
159
+ cachedKey = key;
160
+ return cachedClient;
161
+ }
162
+ function createSa2kitRnAuthClientFromApiBase(authApiBase) {
163
+ const { baseURL, basePath } = normalizeRnAuthBaseUrl(authApiBase);
164
+ return createSa2kitRnAuthClient({ baseURL, basePath });
165
+ }
166
+ async function initSa2kitRnAuthClient(options) {
167
+ const client = typeof options === "string" ? createSa2kitRnAuthClientFromApiBase(options) : createSa2kitRnAuthClient(options);
168
+ const token = await getRnBearerToken();
169
+ if (token) {
170
+ try {
171
+ await client.getSession();
172
+ } catch {
173
+ await clearRnBearerToken();
174
+ }
175
+ }
176
+ return client;
177
+ }
178
+ async function signOutSa2kitRnAuthClient(client) {
179
+ try {
180
+ await client.signOut();
181
+ } finally {
182
+ await clearRnBearerToken();
183
+ }
184
+ }
185
+ function resetSa2kitRnAuthClientCache() {
186
+ cachedClient = null;
187
+ cachedKey = "";
188
+ }
189
+
190
+ // src/common/auth/components/utils.ts
191
+ function validatePhoneNumber(phone) {
192
+ return /^1[3-9]\d{9}$/.test(phone.trim());
193
+ }
194
+ function validateEmail(email) {
195
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.trim());
196
+ }
197
+ function getAuthClientError(result, fallback) {
198
+ const r = result;
199
+ if (!r?.error) return null;
200
+ return r.error.message ?? r.error.statusText ?? fallback;
201
+ }
202
+ function errorMessage(error, fallback) {
203
+ if (error instanceof Error && error.message) return error.message;
204
+ if (typeof error === "string") return error;
205
+ return fallback;
206
+ }
207
+
208
+ // src/common/auth/rn/sign-in.ts
209
+ function clientApi(client) {
210
+ return client;
211
+ }
212
+ async function signInWithRnAuthClient(authClient, account, password) {
213
+ const trimmed = account.trim();
214
+ try {
215
+ if (validatePhoneNumber(trimmed)) {
216
+ const result = await clientApi(authClient).signIn.phoneNumber({
217
+ phoneNumber: trimmed,
218
+ password
219
+ });
220
+ const err = getAuthClientError(result, "\u767B\u5F55\u5931\u8D25");
221
+ return err ? { success: false, error: err } : { success: true };
222
+ }
223
+ if (validateEmail(trimmed)) {
224
+ const result = await clientApi(authClient).signIn.email({
225
+ email: trimmed,
226
+ password
227
+ });
228
+ const err = getAuthClientError(result, "\u767B\u5F55\u5931\u8D25");
229
+ return err ? { success: false, error: err } : { success: true };
230
+ }
231
+ return { success: false, error: "\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7\u6216\u90AE\u7BB1" };
232
+ } catch (e) {
233
+ return { success: false, error: errorMessage(e, "\u767B\u5F55\u5931\u8D25") };
234
+ }
235
+ }
236
+ var ReactNative = __require("react-native");
237
+ var { ActivityIndicator, Pressable, Text, TextInput, View, StyleSheet } = ReactNative;
238
+ var defaultStyles = StyleSheet.create({
239
+ label: { fontSize: 12, color: "#8b98a5", marginBottom: 6, marginTop: 12 },
240
+ input: {
241
+ borderWidth: 1,
242
+ borderColor: "rgba(255,255,255,0.12)",
243
+ borderRadius: 10,
244
+ paddingHorizontal: 12,
245
+ paddingVertical: 10,
246
+ color: "#e8edf2",
247
+ backgroundColor: "rgba(0,0,0,0.2)",
248
+ fontSize: 15
249
+ },
250
+ err: { color: "#f87171", marginTop: 10, fontSize: 14 },
251
+ btn: {
252
+ marginTop: 14,
253
+ paddingVertical: 12,
254
+ borderRadius: 10,
255
+ alignItems: "center",
256
+ borderWidth: 1,
257
+ borderColor: "rgba(255,255,255,0.12)",
258
+ backgroundColor: "rgba(255,255,255,0.08)"
259
+ },
260
+ primary: { backgroundColor: "#3d9eff", borderColor: "transparent" },
261
+ disabled: { opacity: 0.6 },
262
+ btnTextPrimary: { color: "#fff", fontSize: 15, fontWeight: "600" },
263
+ centerInline: { paddingVertical: 24, alignItems: "center" }
264
+ });
265
+ var DEFAULT_LABELS = {
266
+ authApiBase: "\u8BA4\u8BC1 API \u6839\u5730\u5740\uFF08\u542B /api\uFF09",
267
+ account: "\u624B\u673A\u53F7 / \u90AE\u7BB1",
268
+ password: "\u5BC6\u7801",
269
+ submit: "\u767B\u5F55"
270
+ };
271
+ function RnAccountLoginForm({
272
+ authApiBase,
273
+ defaultAuthApiBase = "",
274
+ onAuthApiBaseChange,
275
+ submitting = false,
276
+ error = "",
277
+ onError,
278
+ onSuccess,
279
+ theme,
280
+ labels: labelsProp,
281
+ placeholders
282
+ }) {
283
+ const labels = {
284
+ ...DEFAULT_LABELS,
285
+ account: labelsProp?.account ?? labelsProp?.phone ?? labelsProp?.email ?? DEFAULT_LABELS.account,
286
+ ...labelsProp
287
+ };
288
+ const [authClient, setAuthClient] = useState(null);
289
+ const [account, setAccount] = useState("");
290
+ const [password, setPassword] = useState("");
291
+ const [loading, setLoading] = useState(false);
292
+ useEffect(() => {
293
+ let cancelled = false;
294
+ const base = authApiBase.trim() || defaultAuthApiBase;
295
+ if (!base) {
296
+ setAuthClient(null);
297
+ return;
298
+ }
299
+ resetSa2kitRnAuthClientCache();
300
+ initSa2kitRnAuthClient(base).then((client) => {
301
+ if (!cancelled) setAuthClient(client);
302
+ });
303
+ return () => {
304
+ cancelled = true;
305
+ };
306
+ }, [authApiBase, defaultAuthApiBase]);
307
+ const handleSubmit = useCallback(async () => {
308
+ if (!authClient) return;
309
+ onError?.("");
310
+ setLoading(true);
311
+ try {
312
+ const trimmedAccount = account.trim();
313
+ if (!trimmedAccount || !password) {
314
+ onError?.("\u8BF7\u586B\u5199\u8D26\u53F7\u548C\u5BC6\u7801");
315
+ return;
316
+ }
317
+ const result = await signInWithRnAuthClient(authClient, trimmedAccount, password);
318
+ if (!result.success) {
319
+ onError?.(result.error);
320
+ return;
321
+ }
322
+ const token = await getRnBearerToken();
323
+ if (!token) {
324
+ onError?.("\u767B\u5F55\u6210\u529F\u4F46\u672A\u83B7\u53D6\u5230 Bearer token");
325
+ return;
326
+ }
327
+ await onSuccess(token);
328
+ } finally {
329
+ setLoading(false);
330
+ }
331
+ }, [account, authClient, onError, onSuccess, password]);
332
+ const authApiField = onAuthApiBaseChange ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Text, { style: [defaultStyles.label, theme?.label] }, labels.authApiBase), /* @__PURE__ */ React.createElement(
333
+ TextInput,
334
+ {
335
+ style: [defaultStyles.input, theme?.input, theme?.inputContainer],
336
+ value: authApiBase,
337
+ onChangeText: onAuthApiBaseChange,
338
+ autoCapitalize: "none",
339
+ autoCorrect: false,
340
+ placeholder: placeholders?.authApiBase ?? defaultAuthApiBase,
341
+ placeholderTextColor: "#6b7a8a"
342
+ }
343
+ )) : null;
344
+ if (!authClient) {
345
+ return /* @__PURE__ */ React.createElement(View, { style: [defaultStyles.centerInline, theme?.loadingContainer] }, /* @__PURE__ */ React.createElement(ActivityIndicator, null));
346
+ }
347
+ const busy = loading || submitting;
348
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, authApiField, /* @__PURE__ */ React.createElement(Text, { style: [defaultStyles.label, theme?.label] }, labels.account), /* @__PURE__ */ React.createElement(
349
+ TextInput,
350
+ {
351
+ style: [defaultStyles.input, theme?.input, theme?.inputContainer],
352
+ value: account,
353
+ onChangeText: setAccount,
354
+ keyboardType: "email-address",
355
+ autoCapitalize: "none",
356
+ autoCorrect: false,
357
+ placeholder: placeholders?.account ?? placeholders?.phone ?? "\u624B\u673A\u53F7\u6216\u90AE\u7BB1",
358
+ placeholderTextColor: "#6b7a8a"
359
+ }
360
+ ), /* @__PURE__ */ React.createElement(Text, { style: [defaultStyles.label, theme?.label] }, labels.password), /* @__PURE__ */ React.createElement(
361
+ TextInput,
362
+ {
363
+ style: [defaultStyles.input, theme?.input, theme?.inputContainer],
364
+ value: password,
365
+ onChangeText: setPassword,
366
+ secureTextEntry: true,
367
+ autoCapitalize: "none",
368
+ autoCorrect: false,
369
+ placeholder: placeholders?.password ?? "\u5BC6\u7801",
370
+ placeholderTextColor: "#6b7a8a"
371
+ }
372
+ ), error ? /* @__PURE__ */ React.createElement(Text, { style: [defaultStyles.err, theme?.error] }, error) : null, /* @__PURE__ */ React.createElement(
373
+ Pressable,
374
+ {
375
+ style: [
376
+ defaultStyles.btn,
377
+ defaultStyles.primary,
378
+ theme?.button,
379
+ theme?.buttonPrimary,
380
+ busy && (theme?.buttonDisabled ?? defaultStyles.disabled)
381
+ ],
382
+ onPress: () => void handleSubmit(),
383
+ disabled: busy
384
+ },
385
+ busy ? /* @__PURE__ */ React.createElement(ActivityIndicator, { color: "#fff" }) : /* @__PURE__ */ React.createElement(Text, { style: [defaultStyles.btnTextPrimary, theme?.buttonTextPrimary] }, labels.submit)
386
+ ));
387
+ }
388
+
10
389
  // src/common/auth/client/types.ts
11
390
  var STORAGE_KEYS = {
12
391
  AUTH_TOKEN: "auth_token",
@@ -23,8 +402,8 @@ var API_ROUTES = {
23
402
 
24
403
  // src/common/auth/client/base-api-client.ts
25
404
  var BaseApiClient = class {
26
- constructor(storage, request, baseUrl) {
27
- this.storage = storage;
405
+ constructor(storage2, request, baseUrl) {
406
+ this.storage = storage2;
28
407
  this.request = request;
29
408
  this.baseUrl = baseUrl;
30
409
  this.token = null;
@@ -216,77 +595,6 @@ var BaseApiClient = class {
216
595
  }
217
596
  };
218
597
 
219
- // src/storage/adapters/react-native-adapter.ts
220
- var AsyncStorage = null;
221
- try {
222
- AsyncStorage = __require("@react-native-async-storage/async-storage").default;
223
- } catch (e) {
224
- }
225
- var ReactNativeStorageAdapter = class {
226
- constructor() {
227
- this.listeners = /* @__PURE__ */ new Map();
228
- }
229
- async getItem(key) {
230
- if (!AsyncStorage) return null;
231
- try {
232
- return await AsyncStorage.getItem(key);
233
- } catch (error) {
234
- console.error('[ReactNativeStorage] Error getting item "' + key + '":', error);
235
- return null;
236
- }
237
- }
238
- async setItem(key, value) {
239
- if (!AsyncStorage) {
240
- throw new Error("AsyncStorage is not available");
241
- }
242
- try {
243
- await AsyncStorage.setItem(key, value);
244
- this.notifyListeners(key, value);
245
- } catch (error) {
246
- console.error('[ReactNativeStorage] Error setting item "' + key + '":', error);
247
- throw error;
248
- }
249
- }
250
- async removeItem(key) {
251
- if (!AsyncStorage) {
252
- throw new Error("AsyncStorage is not available");
253
- }
254
- try {
255
- await AsyncStorage.removeItem(key);
256
- this.notifyListeners(key, null);
257
- } catch (error) {
258
- console.error('[ReactNativeStorage] Error removing item "' + key + '":', error);
259
- throw error;
260
- }
261
- }
262
- async clear() {
263
- if (!AsyncStorage) {
264
- throw new Error("AsyncStorage is not available");
265
- }
266
- try {
267
- await AsyncStorage.clear();
268
- } catch (error) {
269
- console.error("[ReactNativeStorage] Error clearing storage:", error);
270
- throw error;
271
- }
272
- }
273
- addChangeListener(callback) {
274
- if (!this.listeners.has("*")) {
275
- this.listeners.set("*", /* @__PURE__ */ new Set());
276
- }
277
- this.listeners.get("*").add(callback);
278
- return () => {
279
- this.listeners.get("*")?.delete(callback);
280
- };
281
- }
282
- notifyListeners(key, value) {
283
- const globalListeners = this.listeners.get("*");
284
- if (globalListeners) {
285
- globalListeners.forEach((callback) => callback(key, value));
286
- }
287
- }
288
- };
289
-
290
598
  // src/request/adapters/react-native-adapter.ts
291
599
  var ReactNativeRequestAdapter = class {
292
600
  async request(config) {
@@ -323,7 +631,7 @@ var ReactNativeRequestAdapter = class {
323
631
  }
324
632
  };
325
633
 
326
- // src/common/auth/rn/client.ts
634
+ // src/common/auth/rn/legacy-client.ts
327
635
  var cached = null;
328
636
  var cachedBase = "";
329
637
  function createRnAuthClient(authApiBase) {
@@ -350,405 +658,6 @@ function resetRnAuthClientCache() {
350
658
  cachedBase = "";
351
659
  }
352
660
 
353
- // src/business/auth-legacy/utils/authUtils.ts
354
- function validatePhoneNumber(phone) {
355
- return /^1[3-9]\d{9}$/.test(phone);
356
- }
357
-
358
- // src/business/auth-legacy/rn/legacy-login.ts
359
- async function loginWithLegacyPhone(authApiBase, phone, password) {
360
- const trimmedPhone = phone.trim();
361
- if (!trimmedPhone || !password) {
362
- return { success: false, message: "\u8BF7\u586B\u5199\u624B\u673A\u53F7\u548C\u5BC6\u7801" };
363
- }
364
- if (!validatePhoneNumber(trimmedPhone)) {
365
- return { success: false, message: "\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7" };
366
- }
367
- const base = authApiBase.replace(/\/+$/, "");
368
- const adapter = new ReactNativeRequestAdapter();
369
- const data = await adapter.request({
370
- url: `${base}/auth/login`,
371
- method: "POST",
372
- body: { phone: trimmedPhone, password }
373
- });
374
- if (!data.success) {
375
- return {
376
- success: false,
377
- message: data.message ?? "\u767B\u5F55\u5931\u8D25"
378
- };
379
- }
380
- const token = data.sessionToken ?? data.data?.sessionToken;
381
- if (!token || token.length < 8) {
382
- return { success: false, message: "\u767B\u5F55\u6210\u529F\u4F46\u672A\u8FD4\u56DE\u6709\u6548\u4F1A\u8BDD\u4EE4\u724C" };
383
- }
384
- return { success: true, token };
385
- }
386
- function isPhoneAccount(account) {
387
- return validatePhoneNumber(account.trim());
388
- }
389
- function useAuth(apiClient) {
390
- const [user, setUser] = useState(null);
391
- const [isLoggedIn, setIsLoggedIn] = useState(false);
392
- const [loading, setLoading] = useState(false);
393
- const [checkingAuth, setCheckingAuth] = useState(true);
394
- const [error, setError] = useState(null);
395
- const checkAuthStatus = useCallback(async () => {
396
- try {
397
- setCheckingAuth(true);
398
- setError(null);
399
- const isAuth = await apiClient.isAuthenticated();
400
- if (isAuth) {
401
- const response = await apiClient.getCurrentUser();
402
- if (response.success && response.data) {
403
- setUser(response.data);
404
- setIsLoggedIn(true);
405
- } else {
406
- await apiClient.clearUserData();
407
- setUser(null);
408
- setIsLoggedIn(false);
409
- }
410
- } else {
411
- setUser(null);
412
- setIsLoggedIn(false);
413
- }
414
- } catch (err) {
415
- console.error("\u68C0\u67E5\u767B\u5F55\u72B6\u6001\u5931\u8D25:", err);
416
- setError(err instanceof Error ? err.message : "\u68C0\u67E5\u767B\u5F55\u72B6\u6001\u5931\u8D25");
417
- setUser(null);
418
- setIsLoggedIn(false);
419
- } finally {
420
- setCheckingAuth(false);
421
- }
422
- }, [apiClient]);
423
- const login = useCallback(
424
- async (email, password) => {
425
- setLoading(true);
426
- setError(null);
427
- try {
428
- const response = await apiClient.login(email, password);
429
- if (response.success && response.data) {
430
- setUser(response.data.user);
431
- setIsLoggedIn(true);
432
- return { success: true };
433
- } else {
434
- const errorMsg = response.error || "\u767B\u5F55\u5931\u8D25";
435
- setError(errorMsg);
436
- return { success: false, error: errorMsg };
437
- }
438
- } catch (err) {
439
- const errorMsg = err instanceof Error ? err.message : "\u767B\u5F55\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";
440
- setError(errorMsg);
441
- return { success: false, error: errorMsg };
442
- } finally {
443
- setLoading(false);
444
- }
445
- },
446
- [apiClient]
447
- );
448
- const register = useCallback(
449
- async (email, password, username) => {
450
- setLoading(true);
451
- setError(null);
452
- try {
453
- const response = await apiClient.register(email, password, username);
454
- if (response.success && response.data) {
455
- setUser(response.data.user);
456
- setIsLoggedIn(true);
457
- return { success: true };
458
- } else {
459
- const errorMsg = response.error || "\u6CE8\u518C\u5931\u8D25";
460
- setError(errorMsg);
461
- return { success: false, error: errorMsg };
462
- }
463
- } catch (err) {
464
- const errorMsg = err instanceof Error ? err.message : "\u6CE8\u518C\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5";
465
- setError(errorMsg);
466
- return { success: false, error: errorMsg };
467
- } finally {
468
- setLoading(false);
469
- }
470
- },
471
- [apiClient]
472
- );
473
- const logout = useCallback(async () => {
474
- setLoading(true);
475
- setError(null);
476
- try {
477
- await apiClient.logout();
478
- setUser(null);
479
- setIsLoggedIn(false);
480
- } catch (err) {
481
- console.error("\u767B\u51FA\u5931\u8D25:", err);
482
- setError(err instanceof Error ? err.message : "\u767B\u51FA\u5931\u8D25");
483
- setUser(null);
484
- setIsLoggedIn(false);
485
- } finally {
486
- setLoading(false);
487
- }
488
- }, [apiClient]);
489
- const clearError = useCallback(() => {
490
- setError(null);
491
- }, []);
492
- useEffect(() => {
493
- checkAuthStatus();
494
- }, [checkAuthStatus]);
495
- return {
496
- // 状态
497
- user,
498
- isLoggedIn,
499
- loading,
500
- checkingAuth,
501
- error,
502
- // 操作方法
503
- login,
504
- register,
505
- logout,
506
- refresh: checkAuthStatus,
507
- clearError
508
- };
509
- }
510
-
511
- // src/common/auth/components/LoginForm.tsx
512
- function LoginForm({ apiClient, onSuccess, onError, children }) {
513
- const { login, loading, error: authError, clearError } = useAuth(apiClient);
514
- const [email, setEmail] = useState("");
515
- const [password, setPassword] = useState("");
516
- const handleSubmit = async (e) => {
517
- if (e) {
518
- e.preventDefault();
519
- }
520
- clearError();
521
- const result = await login(email, password);
522
- if (result.success) {
523
- const currentUser = apiClient.getUser();
524
- if (currentUser) {
525
- onSuccess?.(currentUser);
526
- }
527
- } else {
528
- onError?.(result.error || "\u767B\u5F55\u5931\u8D25");
529
- }
530
- };
531
- const state = {
532
- email,
533
- password,
534
- loading,
535
- error: authError,
536
- handleEmailChange: setEmail,
537
- handlePasswordChange: setPassword,
538
- handleSubmit
539
- };
540
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, children(state));
541
- }
542
-
543
- // src/business/auth-legacy/rn/components/AccountLoginForm.tsx
544
- var ReactNative = __require("react-native");
545
- var { ActivityIndicator, Pressable, Text, TextInput, View, StyleSheet } = ReactNative;
546
- var defaultStyles = StyleSheet.create({
547
- label: { fontSize: 12, color: "#8b98a5", marginBottom: 6, marginTop: 12 },
548
- input: {
549
- borderWidth: 1,
550
- borderColor: "rgba(255,255,255,0.12)",
551
- borderRadius: 10,
552
- paddingHorizontal: 12,
553
- paddingVertical: 10,
554
- color: "#e8edf2",
555
- backgroundColor: "rgba(0,0,0,0.2)",
556
- fontSize: 15
557
- },
558
- err: { color: "#f87171", marginTop: 10, fontSize: 14 },
559
- btn: {
560
- marginTop: 14,
561
- paddingVertical: 12,
562
- borderRadius: 10,
563
- alignItems: "center",
564
- borderWidth: 1,
565
- borderColor: "rgba(255,255,255,0.12)",
566
- backgroundColor: "rgba(255,255,255,0.08)"
567
- },
568
- primary: { backgroundColor: "#3d9eff", borderColor: "transparent" },
569
- disabled: { opacity: 0.6 },
570
- btnTextPrimary: { color: "#fff", fontSize: 15, fontWeight: "600" },
571
- centerInline: { paddingVertical: 24, alignItems: "center" }
572
- });
573
- var DEFAULT_LABELS = {
574
- authApiBase: "\u8BA4\u8BC1 API \u6839\u5730\u5740\uFF08\u542B /api\uFF09",
575
- phone: "\u624B\u673A\u53F7",
576
- email: "\u90AE\u7BB1",
577
- password: "\u5BC6\u7801",
578
- submit: "\u767B\u5F55"
579
- };
580
- function RnAccountLoginForm({
581
- authApiBase,
582
- defaultAuthApiBase = "",
583
- onAuthApiBaseChange,
584
- submitting = false,
585
- error = "",
586
- onError,
587
- onSuccess,
588
- theme,
589
- labels: labelsProp,
590
- placeholders
591
- }) {
592
- const labels = { ...DEFAULT_LABELS, ...labelsProp };
593
- const [apiClient, setApiClient] = useState(null);
594
- const [account, setAccount] = useState("");
595
- const [password, setPassword] = useState("");
596
- const [useLegacyPhone, setUseLegacyPhone] = useState(true);
597
- useEffect(() => {
598
- let cancelled = false;
599
- const base = authApiBase.trim() || defaultAuthApiBase;
600
- if (!base) {
601
- setApiClient(null);
602
- return;
603
- }
604
- resetRnAuthClientCache();
605
- initRnAuthClient(base).then((c) => {
606
- if (!cancelled) {
607
- setApiClient(c);
608
- }
609
- });
610
- return () => {
611
- cancelled = true;
612
- };
613
- }, [authApiBase, defaultAuthApiBase]);
614
- useEffect(() => {
615
- const trimmed = account.trim();
616
- if (!trimmed) {
617
- setUseLegacyPhone(true);
618
- return;
619
- }
620
- setUseLegacyPhone(isPhoneAccount(trimmed));
621
- }, [account]);
622
- const handleLegacySubmit = useCallback(async () => {
623
- const base = authApiBase.trim() || defaultAuthApiBase;
624
- onError?.("");
625
- const result = await loginWithLegacyPhone(base, account, password);
626
- if (!result.success || !result.token) {
627
- onError?.(result.message ?? "\u767B\u5F55\u5931\u8D25");
628
- return;
629
- }
630
- await onSuccess(result.token);
631
- }, [account, authApiBase, defaultAuthApiBase, onError, onSuccess, password]);
632
- const authApiField = onAuthApiBaseChange ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Text, { style: [defaultStyles.label, theme?.label] }, labels.authApiBase), /* @__PURE__ */ React2.createElement(
633
- TextInput,
634
- {
635
- style: [defaultStyles.input, theme?.input, theme?.inputContainer],
636
- value: authApiBase,
637
- onChangeText: onAuthApiBaseChange,
638
- autoCapitalize: "none",
639
- autoCorrect: false,
640
- placeholder: placeholders?.authApiBase ?? defaultAuthApiBase,
641
- placeholderTextColor: "#6b7a8a"
642
- }
643
- )) : null;
644
- if (!apiClient) {
645
- return /* @__PURE__ */ React2.createElement(View, { style: [defaultStyles.centerInline, theme?.loadingContainer] }, /* @__PURE__ */ React2.createElement(ActivityIndicator, null));
646
- }
647
- if (useLegacyPhone) {
648
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, authApiField, /* @__PURE__ */ React2.createElement(Text, { style: [defaultStyles.label, theme?.label] }, labels.phone), /* @__PURE__ */ React2.createElement(
649
- TextInput,
650
- {
651
- style: [defaultStyles.input, theme?.input, theme?.inputContainer],
652
- value: account,
653
- onChangeText: setAccount,
654
- keyboardType: "phone-pad",
655
- autoCapitalize: "none",
656
- autoCorrect: false,
657
- placeholder: placeholders?.phone ?? "13800138000",
658
- placeholderTextColor: "#6b7a8a"
659
- }
660
- ), /* @__PURE__ */ React2.createElement(Text, { style: [defaultStyles.label, theme?.label] }, labels.password), /* @__PURE__ */ React2.createElement(
661
- TextInput,
662
- {
663
- style: [defaultStyles.input, theme?.input, theme?.inputContainer],
664
- value: password,
665
- onChangeText: setPassword,
666
- secureTextEntry: true,
667
- autoCapitalize: "none",
668
- autoCorrect: false,
669
- placeholder: placeholders?.password ?? "\u5BC6\u7801",
670
- placeholderTextColor: "#6b7a8a"
671
- }
672
- ), error ? /* @__PURE__ */ React2.createElement(Text, { style: [defaultStyles.err, theme?.error] }, error) : null, /* @__PURE__ */ React2.createElement(
673
- Pressable,
674
- {
675
- style: [
676
- defaultStyles.btn,
677
- defaultStyles.primary,
678
- theme?.button,
679
- theme?.buttonPrimary,
680
- submitting && (theme?.buttonDisabled ?? defaultStyles.disabled)
681
- ],
682
- onPress: handleLegacySubmit,
683
- disabled: submitting
684
- },
685
- submitting ? /* @__PURE__ */ React2.createElement(ActivityIndicator, { color: "#fff" }) : /* @__PURE__ */ React2.createElement(Text, { style: [defaultStyles.btnTextPrimary, theme?.buttonTextPrimary] }, labels.submit)
686
- ));
687
- }
688
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, authApiField, /* @__PURE__ */ React2.createElement(
689
- LoginForm,
690
- {
691
- apiClient,
692
- onSuccess: () => {
693
- const tok = apiClient.getToken();
694
- if (tok) {
695
- void onSuccess(tok);
696
- } else {
697
- onError?.("\u767B\u5F55\u6210\u529F\u4F46\u672A\u83B7\u53D6\u5230\u4EE4\u724C");
698
- }
699
- },
700
- onError: (msg) => onError?.(msg)
701
- },
702
- ({
703
- email,
704
- password: pwd,
705
- loading,
706
- error: formErr,
707
- handleEmailChange,
708
- handlePasswordChange,
709
- handleSubmit
710
- }) => /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Text, { style: [defaultStyles.label, theme?.label] }, labels.email), /* @__PURE__ */ React2.createElement(
711
- TextInput,
712
- {
713
- style: [defaultStyles.input, theme?.input, theme?.inputContainer],
714
- value: email,
715
- onChangeText: handleEmailChange,
716
- keyboardType: "email-address",
717
- autoCapitalize: "none",
718
- autoCorrect: false,
719
- placeholder: placeholders?.email ?? "user@example.com",
720
- placeholderTextColor: "#6b7a8a"
721
- }
722
- ), /* @__PURE__ */ React2.createElement(Text, { style: [defaultStyles.label, theme?.label] }, labels.password), /* @__PURE__ */ React2.createElement(
723
- TextInput,
724
- {
725
- style: [defaultStyles.input, theme?.input, theme?.inputContainer],
726
- value: pwd,
727
- onChangeText: handlePasswordChange,
728
- secureTextEntry: true,
729
- autoCapitalize: "none",
730
- autoCorrect: false,
731
- placeholder: placeholders?.password ?? "\u5BC6\u7801",
732
- placeholderTextColor: "#6b7a8a"
733
- }
734
- ), formErr || error ? /* @__PURE__ */ React2.createElement(Text, { style: [defaultStyles.err, theme?.error] }, formErr ?? error) : null, /* @__PURE__ */ React2.createElement(
735
- Pressable,
736
- {
737
- style: [
738
- defaultStyles.btn,
739
- defaultStyles.primary,
740
- theme?.button,
741
- theme?.buttonPrimary,
742
- (loading || submitting) && (theme?.buttonDisabled ?? defaultStyles.disabled)
743
- ],
744
- onPress: () => handleSubmit(),
745
- disabled: loading || submitting
746
- },
747
- loading || submitting ? /* @__PURE__ */ React2.createElement(ActivityIndicator, { color: "#fff" }) : /* @__PURE__ */ React2.createElement(Text, { style: [defaultStyles.btnTextPrimary, theme?.buttonTextPrimary] }, labels.submit)
748
- ))
749
- ));
750
- }
751
-
752
- export { RnAccountLoginForm, createRnAuthClient, initRnAuthClient, isPhoneAccount, loginWithLegacyPhone, resetRnAuthClientCache };
661
+ export { RN_BEARER_TOKEN_KEY, RnAccountLoginForm, clearRnBearerToken, createRnAuthClient, createSa2kitRnAuthClient, createSa2kitRnAuthClientFromApiBase, getRnBearerToken, initRnAuthClient, initSa2kitRnAuthClient, normalizeRnAuthBaseUrl, resetRnAuthClientCache, resetSa2kitRnAuthClientCache, setRnBearerToken, setRnBearerTokenStorage, signInWithRnAuthClient, signOutSa2kitRnAuthClient };
753
662
  //# sourceMappingURL=index.mjs.map
754
663
  //# sourceMappingURL=index.mjs.map