@yhgale/shared 0.1.0 → 0.1.2

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 (123) hide show
  1. package/dist/chunk-DWPSHK7F.js +68 -0
  2. package/dist/chunk-Y75EVVGQ.js +108 -0
  3. package/dist/errors/index.d.ts +29 -10
  4. package/dist/errors/index.js +24 -52
  5. package/dist/index.d.ts +472 -14
  6. package/dist/index.js +2295 -14
  7. package/dist/react/index.d.ts +2 -1
  8. package/dist/react/index.js +0 -4
  9. package/dist/types/index.d.ts +705 -10
  10. package/dist/types/index.js +12 -10
  11. package/package.json +20 -39
  12. package/dist/__tests__/aiGuide.spec.d.ts +0 -2
  13. package/dist/__tests__/aiGuide.spec.d.ts.map +0 -1
  14. package/dist/__tests__/aiGuide.spec.js +0 -93
  15. package/dist/__tests__/aiGuide.spec.js.map +0 -1
  16. package/dist/__tests__/aiNavigation.spec.d.ts +0 -2
  17. package/dist/__tests__/aiNavigation.spec.d.ts.map +0 -1
  18. package/dist/__tests__/aiNavigation.spec.js +0 -20
  19. package/dist/__tests__/aiNavigation.spec.js.map +0 -1
  20. package/dist/__tests__/keys.spec.d.ts +0 -2
  21. package/dist/__tests__/keys.spec.d.ts.map +0 -1
  22. package/dist/__tests__/keys.spec.js +0 -29
  23. package/dist/__tests__/keys.spec.js.map +0 -1
  24. package/dist/aiGuide.d.ts +0 -50
  25. package/dist/aiGuide.d.ts.map +0 -1
  26. package/dist/aiGuide.js +0 -123
  27. package/dist/aiGuide.js.map +0 -1
  28. package/dist/aiNavigation.d.ts +0 -7
  29. package/dist/aiNavigation.d.ts.map +0 -1
  30. package/dist/aiNavigation.js +0 -34
  31. package/dist/aiNavigation.js.map +0 -1
  32. package/dist/defaults.d.ts +0 -19
  33. package/dist/defaults.d.ts.map +0 -1
  34. package/dist/defaults.js +0 -45
  35. package/dist/defaults.js.map +0 -1
  36. package/dist/domain.d.ts +0 -27
  37. package/dist/domain.d.ts.map +0 -1
  38. package/dist/domain.js +0 -77
  39. package/dist/domain.js.map +0 -1
  40. package/dist/email/defaults.d.ts +0 -13
  41. package/dist/email/defaults.d.ts.map +0 -1
  42. package/dist/email/defaults.js +0 -52
  43. package/dist/email/defaults.js.map +0 -1
  44. package/dist/email/markdown.d.ts +0 -6
  45. package/dist/email/markdown.d.ts.map +0 -1
  46. package/dist/email/markdown.js +0 -14
  47. package/dist/email/markdown.js.map +0 -1
  48. package/dist/email/slugs.d.ts +0 -17
  49. package/dist/email/slugs.d.ts.map +0 -1
  50. package/dist/email/slugs.js +0 -28
  51. package/dist/email/slugs.js.map +0 -1
  52. package/dist/errors/fapi.d.ts +0 -18
  53. package/dist/errors/fapi.d.ts.map +0 -1
  54. package/dist/errors/fapi.js +0 -62
  55. package/dist/errors/fapi.js.map +0 -1
  56. package/dist/errors/index.d.ts.map +0 -1
  57. package/dist/errors/index.js.map +0 -1
  58. package/dist/index.d.ts.map +0 -1
  59. package/dist/index.js.map +0 -1
  60. package/dist/keys.d.ts +0 -35
  61. package/dist/keys.d.ts.map +0 -1
  62. package/dist/keys.js +0 -128
  63. package/dist/keys.js.map +0 -1
  64. package/dist/oauth/catalog.d.ts +0 -141
  65. package/dist/oauth/catalog.d.ts.map +0 -1
  66. package/dist/oauth/catalog.js +0 -166
  67. package/dist/oauth/catalog.js.map +0 -1
  68. package/dist/oauth/china.d.ts +0 -7
  69. package/dist/oauth/china.d.ts.map +0 -1
  70. package/dist/oauth/china.js +0 -487
  71. package/dist/oauth/china.js.map +0 -1
  72. package/dist/oauth/gitee.d.ts +0 -21
  73. package/dist/oauth/gitee.d.ts.map +0 -1
  74. package/dist/oauth/gitee.js +0 -156
  75. package/dist/oauth/gitee.js.map +0 -1
  76. package/dist/oauth/github.d.ts +0 -21
  77. package/dist/oauth/github.d.ts.map +0 -1
  78. package/dist/oauth/github.js +0 -140
  79. package/dist/oauth/github.js.map +0 -1
  80. package/dist/oauth/google.d.ts +0 -17
  81. package/dist/oauth/google.d.ts.map +0 -1
  82. package/dist/oauth/google.js +0 -108
  83. package/dist/oauth/google.js.map +0 -1
  84. package/dist/oauth/index.d.ts +0 -28
  85. package/dist/oauth/index.d.ts.map +0 -1
  86. package/dist/oauth/index.js +0 -53
  87. package/dist/oauth/index.js.map +0 -1
  88. package/dist/oauth/microsoft.d.ts +0 -17
  89. package/dist/oauth/microsoft.d.ts.map +0 -1
  90. package/dist/oauth/microsoft.js +0 -118
  91. package/dist/oauth/microsoft.js.map +0 -1
  92. package/dist/oauth/wechat.d.ts +0 -4
  93. package/dist/oauth/wechat.d.ts.map +0 -1
  94. package/dist/oauth/wechat.js +0 -161
  95. package/dist/oauth/wechat.js.map +0 -1
  96. package/dist/oauth/wecom.d.ts +0 -4
  97. package/dist/oauth/wecom.d.ts.map +0 -1
  98. package/dist/oauth/wecom.js +0 -250
  99. package/dist/oauth/wecom.js.map +0 -1
  100. package/dist/parsers.d.ts +0 -44
  101. package/dist/parsers.d.ts.map +0 -1
  102. package/dist/parsers.js +0 -188
  103. package/dist/parsers.js.map +0 -1
  104. package/dist/react/index.d.ts.map +0 -1
  105. package/dist/react/index.js.map +0 -1
  106. package/dist/types/authConfig.d.ts +0 -70
  107. package/dist/types/authConfig.d.ts.map +0 -1
  108. package/dist/types/authConfig.js +0 -49
  109. package/dist/types/authConfig.js.map +0 -1
  110. package/dist/types/captcha.d.ts +0 -36
  111. package/dist/types/captcha.d.ts.map +0 -1
  112. package/dist/types/captcha.js +0 -13
  113. package/dist/types/captcha.js.map +0 -1
  114. package/dist/types/fapi.d.ts +0 -506
  115. package/dist/types/fapi.d.ts.map +0 -1
  116. package/dist/types/fapi.js +0 -24
  117. package/dist/types/fapi.js.map +0 -1
  118. package/dist/types/index.d.ts.map +0 -1
  119. package/dist/types/index.js.map +0 -1
  120. package/dist/types/oauthProviders.d.ts +0 -86
  121. package/dist/types/oauthProviders.d.ts.map +0 -1
  122. package/dist/types/oauthProviders.js +0 -15
  123. package/dist/types/oauthProviders.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,14 +1,472 @@
1
- export * from './types/index';
2
- export * from './errors/index';
3
- export * from './defaults';
4
- export * from './domain';
5
- export * from './parsers';
6
- export * from './oauth/index';
7
- export * from './email/slugs';
8
- export * from './email/defaults';
9
- export * from './email/markdown';
10
- export declare const GALE_VERSION = "0.0.0";
11
- export * from './keys';
12
- export * from './aiGuide';
13
- export * from './aiNavigation';
14
- //# sourceMappingURL=index.d.ts.map
1
+ import { IdentityJSON, IdentityResource, MeJSON, UserResource, SessionResource, OrganizationJSON, OrganizationResource, OrganizationMembershipJSON, OrganizationMembershipResource, SessionJSON, SignInAttemptJSON, SignInAttemptResource, SignInResponseJSON, SignUpAttemptJSON, SignUpAttemptResource, SignUpResponseJSON, TokenJSON, TokenResource, UserJSON, OauthProviderAdapter } from './types/index.js';
2
+ export { AcceptInvitationResponseJSON, AcceptedMembershipJSON, AccountPortalAppearanceConfig, AccountPortalConfig, AccountPortalPathConfig, AccountPortalRedirectConfig, AuthAttributeConfig, AuthConfigData, AvatarConfig, BackupCodesDisableResultJSON, BackupCodesGenerateResultJSON, BackupCodesStatusJSON, BeginPasskeyEnrollmentResponseJSON, BuildAuthorizeUrlInput, CaptchaProvider, CaptchaProviderId, CaptchaSettings, CaptchaVerifyParams, CaptchaVerifyResult, CaptchaWidgetType, ClientJSON, DEFAULT_AUTH_CONFIG, DEFAULT_CAPTCHA_SETTINGS, DeletePasskeyResponseJSON, ExchangeCodeInput, FapiErrorEnvelope, FapiErrorPayload, FetchProfileInput, FinishPasskeyEnrollmentResponseJSON, GaleEnvironment, GaleId, GaleResourceJSON, IdentityType, InstanceSummary, InvitationJSON, ListMyInvitationsResponseJSON, ListPasskeysResponseJSON, MfaResponseJSON, MfaStatusJSON, OauthProfile, OauthTokenSet, OrgRole, PageJSON, PasskeyJSON, PasskeyLoginOptionsResponseJSON, PasswordPolicyConfig, PreparePasskeySecondFactorResponseJSON, RenamePasskeyResponseJSON, SessionStatus, SignInStatus, SignUpStatus, SignUpVerificationsJSON, TotpConfirmResultJSON, TotpDisableResultJSON, TotpEnrollResultJSON, UUID_V7_REGEX, VerificationJSON, isUuidV7 } from './types/index.js';
3
+ export { GaleAuthError, GaleConflictError, GaleError, GaleErrorPayload, GaleNotFoundError, GalePermissionError, GaleRateLimitError, GaleValidationError, fapiErrorToGaleError, isFapiErrorEnvelope, networkErrorToGaleError } from './errors/index.js';
4
+
5
+ /**
6
+ * 全栈共享默认值 — 整个项目的权威来源。
7
+ *
8
+ * 每个常量只在这里定义一次,所有包从 `@yhgale/shared` 导入。
9
+ * 需要修改默认值时只改这一个文件。
10
+ */
11
+ declare const DEFAULT_ROOT_DOMAIN = "onered.net";
12
+ /** 同构读取 GALE_ROOT_DOMAIN 环境变量(SSR + Client 均可用) */
13
+ declare function getDefaultRootDomain(): string;
14
+ declare const DEFAULT_FAPI_PORT = 3001;
15
+ declare const DEFAULT_BAPI_PORT = 3002;
16
+ declare const DEFAULT_DATABASE_URL = "postgresql://gale:gale@localhost:5432/gale";
17
+ declare const DEFAULT_REDIS_URL = "redis://localhost:6379";
18
+ declare const DEFAULT_JWT_AUDIENCE = "gale";
19
+ declare const DEFAULT_EMAIL_FROM = "noreply@onered.net";
20
+ declare function getDefaultFapiHost(): string;
21
+ declare function getDefaultBapiHost(): string;
22
+ declare function getDefaultDapiHost(): string;
23
+
24
+ /**
25
+ * 域名工具 —— 从 GALE_ROOT_DOMAIN 派生所有子域名。
26
+ * 移自 @yhgale/apicore/config/domain.ts,零内部依赖。
27
+ */
28
+ declare function getRootDomain(): string;
29
+ declare function extractFapiPrefix(hostname: string): string | null;
30
+ interface DefaultInstanceHostParts {
31
+ slug: string;
32
+ environmentType: 'development' | 'production';
33
+ service: 'fapi' | 'accounts';
34
+ }
35
+ declare function parseDefaultInstanceHost(hostname: string): DefaultInstanceHostParts | null;
36
+ declare function buildFapiHost(prefix: string): string;
37
+ declare function buildDevFapiPrefix(slug: string): string;
38
+ declare function buildProdFapiPrefix(slug: string): string;
39
+ declare function buildDevFapiHost(slug: string): string;
40
+ declare function buildProdFapiHost(slug: string): string;
41
+ declare function buildDevAccountsPrefix(slug: string): string;
42
+ declare function buildProdAccountsPrefix(slug: string): string;
43
+ declare function buildDevAccountsHost(slug: string): string;
44
+ declare function buildProdAccountsHost(slug: string): string;
45
+ declare function buildBapiHost(): string;
46
+ declare function buildDashboardHost(): string;
47
+ declare function buildDashboardFapiHost(): string;
48
+ declare function buildDapiHost(): string;
49
+ declare function _resetDomainCache(): void;
50
+
51
+ /**
52
+ * Wire (camelCase) → Resource (camelCase + 强类型) 转换器。
53
+ *
54
+ * **职责**
55
+ * - 时间字段规范化:fapi 可能返回 number(ms) / number(s) / ISO string,
56
+ * 本模块统一转成 epoch ms(number)。ISO 字符串走 Date.parse;
57
+ * 秒级(数值 < 10^11)×1000 升到 ms。返回值始终是 number 或 null。
58
+ * - 兜底默认值:把 null/undefined 的 metadata 收成 `{}`,identities 收成 `[]`,
59
+ * 避免使用方写一堆 `?? {}`。
60
+ * - 派生便利字段:`primaryIdentity`、`primaryEmail`,UI 直接消费。
61
+ *
62
+ * fapi 字段命名规则:所有接口一律 camelCase(与 DB snake_case 解耦)。
63
+ */
64
+
65
+ declare function parseIdentity(json: IdentityJSON): IdentityResource;
66
+ declare function parseUser(json: UserJSON): UserResource;
67
+ /**
68
+ * `/v1/me` 响应解析。返回 `{ user, session }`,其中 session 仅含轻量摘要
69
+ * (无 expiresAt / lastActiveAt 等字段,省掉服务端 N+1 查询)。dashboard /
70
+ * accounts 拿到 sessionId 后即可用 useSession.getToken() 调 BAPI。
71
+ */
72
+ declare function parseMe(json: MeJSON): {
73
+ user: UserResource;
74
+ session: Pick<SessionResource, 'object' | 'id' | 'status' | 'activeOrganizationId'> | null;
75
+ };
76
+ declare function parseSession(json: SessionJSON): SessionResource;
77
+ declare function parseToken(json: TokenJSON): TokenResource;
78
+ declare function parseSignInAttempt(json: SignInAttemptJSON): SignInAttemptResource;
79
+ /** Envelope `{ client, response: <attempt> }` → `{ clientId, attempt }` */
80
+ declare function parseSignInResponse(json: SignInResponseJSON): {
81
+ clientId: string | null;
82
+ attempt: SignInAttemptResource;
83
+ clientSafeRefreshToken: string | null;
84
+ };
85
+ declare function parseSignUpAttempt(json: SignUpAttemptJSON): SignUpAttemptResource;
86
+ /** Envelope `{ client, response: <sign_up_attempt> }` → `{ clientId, attempt }` */
87
+ declare function parseSignUpResponse(json: SignUpResponseJSON): {
88
+ clientId: string | null;
89
+ attempt: SignUpAttemptResource;
90
+ clientSafeRefreshToken: string | null;
91
+ };
92
+ declare function parseOrganization(json: OrganizationJSON): OrganizationResource;
93
+ declare function parseOrganizationMembership(json: OrganizationMembershipJSON): OrganizationMembershipResource;
94
+
95
+ /**
96
+ * GitHub OAuth Adapter
97
+ *
98
+ * 端点
99
+ * - authorize: https://github.com/login/oauth/authorize
100
+ * - token: https://github.com/login/oauth/access_token
101
+ * - userinfo: https://api.github.com/user
102
+ * - emails: https://api.github.com/user/emails (拿主邮箱 + verified flag)
103
+ *
104
+ * GitHub OAuth App **不支持** refresh_token(GitHub Apps 才支持);access_token
105
+ * 没有 expires_in。所以 OauthTokenSet 上 `refreshToken=null` / `expiresInSec=null`。
106
+ *
107
+ * Enterprise 支持
108
+ * - 可通过 OauthProviderConfig.config.enterpriseHost 覆盖(例 "github.acme.com")
109
+ * - 命中时 authorize / token 走 https://<host>/login/oauth/...
110
+ * userinfo / emails 走 https://<host>/api/v3/...
111
+ */
112
+
113
+ declare const githubAdapter: OauthProviderAdapter;
114
+
115
+ /**
116
+ * Gitee OAuth Adapter
117
+ *
118
+ * 端点
119
+ * - authorize: https://gitee.com/oauth/authorize
120
+ * - token: https://gitee.com/oauth/token
121
+ * - userinfo: https://gitee.com/api/v5/user
122
+ *
123
+ * 与 GitHub 差异
124
+ * - Gitee 返回 expires_in (86400s) + refresh_token
125
+ * - 邮箱需调 /api/v5/emails(/user 不返回 email 字段)
126
+ * - 用 user_info + emails scope 授权
127
+ *
128
+ * 企业版支持
129
+ * - OauthProviderConfig.config.enterpriseHost 覆写 host(如 "gitee.example.com")
130
+ * - 命中时 authorize / token 走 https://<host>/oauth/...
131
+ * userinfo 走 https://<host>/api/v5/user
132
+ */
133
+
134
+ declare const giteeAdapter: OauthProviderAdapter;
135
+
136
+ /**
137
+ * Google OAuth 2.0 / OIDC Adapter
138
+ *
139
+ * 端点
140
+ * - authorize: https://accounts.google.com/o/oauth2/v2/auth
141
+ * - token: https://oauth2.googleapis.com/token
142
+ * - userinfo: https://openidconnect.googleapis.com/v1/userinfo
143
+ *
144
+ * Google 在 scope 含 openid 时同时返回 access_token + id_token。
145
+ * refresh_token 通过 access_type=offline + prompt=consent 确保每次颁发。
146
+ * 注意:Google 限制每个 client/user 最多 50 个活跃 refresh_token,超出自动撤销最旧的。
147
+ *
148
+ * enterprise 无变体(不需要 enterprise host 重写;openid-config discovery 未来可做)。
149
+ */
150
+
151
+ declare const googleAdapter: OauthProviderAdapter;
152
+
153
+ /**
154
+ * Microsoft OAuth 2.0 / OIDC Adapter(Microsoft Identity Platform v2.0)
155
+ *
156
+ * 端点(common tenant —— 同时接受个人 + 工作/学校账户)
157
+ * - authorize: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
158
+ * - token: https://login.microsoftonline.com/common/oauth2/v2.0/token
159
+ * - userinfo: https://graph.microsoft.com/v1.0/me
160
+ *
161
+ * 用 common tenant 覆盖个人账户(Outlook/Hotmail) + Azure AD 账户。
162
+ * 未来如需限制特定 tenant:通过 extraConfig.tenant 覆盖(与 GitHub Enterprise 同理)。
163
+ *
164
+ * 头像暂不做:MS Graph /me/photo/$value 返回二进制 JPEG,在 OAuth callback
165
+ * 关键路径上不适合抓取。avatarUrl 设为 null。
166
+ */
167
+
168
+ declare const microsoftAdapter: OauthProviderAdapter;
169
+
170
+ declare const wechatWebAdapter: OauthProviderAdapter;
171
+ declare const wechatOfficialAccountAdapter: OauthProviderAdapter;
172
+
173
+ declare function clearWeComSuiteAccessTokenCacheForTests(): void;
174
+ declare const wecomAdapter: OauthProviderAdapter;
175
+
176
+ declare const qqAdapter: OauthProviderAdapter;
177
+ declare const weiboAdapter: OauthProviderAdapter;
178
+ declare const baiduAdapter: OauthProviderAdapter;
179
+ declare const dingtalkAdapter: OauthProviderAdapter;
180
+ declare const larkAdapter: OauthProviderAdapter;
181
+
182
+ declare const IMPLEMENTED_OAUTH_PROVIDER_IDS: readonly ["github", "gitee", "google", "microsoft", "wechat_web", "wechat_official_account", "wechat_miniprogram", "wecom", "alipay", "qq", "dingtalk", "lark", "weibo", "baidu"];
183
+ type ImplementedOauthProviderName = (typeof IMPLEMENTED_OAUTH_PROVIDER_IDS)[number];
184
+ type OauthProviderName = ImplementedOauthProviderName | 'wechat_web' | 'wechat_official_account' | 'wechat_miniprogram' | 'wecom' | 'alipay' | 'qq' | 'dingtalk' | 'lark' | 'weibo' | 'baidu';
185
+ type OauthProviderStatus = 'implemented' | 'planned';
186
+ type OauthProviderCategory = 'global' | 'china' | 'enterprise';
187
+ type OauthProviderFamily = 'github' | 'gitee' | 'google' | 'microsoft' | 'wechat' | 'wecom' | 'alipay' | 'qq' | 'dingtalk' | 'lark' | 'weibo' | 'baidu';
188
+ interface OauthProviderCatalogEntry {
189
+ provider: OauthProviderName;
190
+ displayName: string;
191
+ family: OauthProviderFamily;
192
+ category: OauthProviderCategory;
193
+ status: OauthProviderStatus;
194
+ defaultScopes: readonly string[];
195
+ browserVisible: boolean;
196
+ notes?: string;
197
+ }
198
+ declare const OAUTH_PROVIDER_CATALOG: readonly [{
199
+ readonly provider: "github";
200
+ readonly displayName: "GitHub";
201
+ readonly family: "github";
202
+ readonly category: "global";
203
+ readonly status: "implemented";
204
+ readonly defaultScopes: readonly ["user:email"];
205
+ readonly browserVisible: true;
206
+ }, {
207
+ readonly provider: "gitee";
208
+ readonly displayName: "Gitee";
209
+ readonly family: "gitee";
210
+ readonly category: "china";
211
+ readonly status: "implemented";
212
+ readonly defaultScopes: readonly [];
213
+ readonly browserVisible: true;
214
+ }, {
215
+ readonly provider: "google";
216
+ readonly displayName: "Google";
217
+ readonly family: "google";
218
+ readonly category: "global";
219
+ readonly status: "implemented";
220
+ readonly defaultScopes: readonly ["openid", "email", "profile"];
221
+ readonly browserVisible: true;
222
+ }, {
223
+ readonly provider: "microsoft";
224
+ readonly displayName: "Microsoft";
225
+ readonly family: "microsoft";
226
+ readonly category: "global";
227
+ readonly status: "implemented";
228
+ readonly defaultScopes: readonly ["openid", "email", "profile"];
229
+ readonly browserVisible: true;
230
+ }, {
231
+ readonly provider: "wechat_web";
232
+ readonly displayName: "WeChat Web";
233
+ readonly family: "wechat";
234
+ readonly category: "china";
235
+ readonly status: "implemented";
236
+ readonly defaultScopes: readonly ["snsapi_login"];
237
+ readonly browserVisible: true;
238
+ readonly notes: "WeChat Open Platform website QR login.";
239
+ }, {
240
+ readonly provider: "wechat_official_account";
241
+ readonly displayName: "WeChat Official Account";
242
+ readonly family: "wechat";
243
+ readonly category: "china";
244
+ readonly status: "implemented";
245
+ readonly defaultScopes: readonly ["snsapi_userinfo"];
246
+ readonly browserVisible: true;
247
+ readonly notes: "Visible only in WeChat in-app browser once implemented.";
248
+ }, {
249
+ readonly provider: "wechat_miniprogram";
250
+ readonly displayName: "WeChat Mini Program";
251
+ readonly family: "wechat";
252
+ readonly category: "china";
253
+ readonly status: "implemented";
254
+ readonly defaultScopes: readonly [];
255
+ readonly browserVisible: false;
256
+ readonly notes: "Native wx.login code-to-session flow; not shown in browser OAuth UI.";
257
+ }, {
258
+ readonly provider: "wecom";
259
+ readonly displayName: "WeCom";
260
+ readonly family: "wecom";
261
+ readonly category: "enterprise";
262
+ readonly status: "implemented";
263
+ readonly defaultScopes: readonly ["snsapi_privateinfo"];
264
+ readonly browserVisible: true;
265
+ readonly notes: "Supports internal app OAuth and third-party suite member OAuth.";
266
+ }, {
267
+ readonly provider: "alipay";
268
+ readonly displayName: "Alipay";
269
+ readonly family: "alipay";
270
+ readonly category: "china";
271
+ readonly status: "implemented";
272
+ readonly defaultScopes: readonly ["auth_user"];
273
+ readonly browserVisible: true;
274
+ readonly notes: "Server-side adapter lives in @yhgale/apicore because RSA2 signing is server-only.";
275
+ }, {
276
+ readonly provider: "qq";
277
+ readonly displayName: "QQ";
278
+ readonly family: "qq";
279
+ readonly category: "china";
280
+ readonly status: "implemented";
281
+ readonly defaultScopes: readonly ["get_user_info"];
282
+ readonly browserVisible: true;
283
+ }, {
284
+ readonly provider: "dingtalk";
285
+ readonly displayName: "DingTalk";
286
+ readonly family: "dingtalk";
287
+ readonly category: "enterprise";
288
+ readonly status: "implemented";
289
+ readonly defaultScopes: readonly ["openid"];
290
+ readonly browserVisible: true;
291
+ }, {
292
+ readonly provider: "lark";
293
+ readonly displayName: "Lark";
294
+ readonly family: "lark";
295
+ readonly category: "enterprise";
296
+ readonly status: "implemented";
297
+ readonly defaultScopes: readonly ["contact:user.base:readonly"];
298
+ readonly browserVisible: true;
299
+ }, {
300
+ readonly provider: "weibo";
301
+ readonly displayName: "Weibo";
302
+ readonly family: "weibo";
303
+ readonly category: "china";
304
+ readonly status: "implemented";
305
+ readonly defaultScopes: readonly [];
306
+ readonly browserVisible: true;
307
+ }, {
308
+ readonly provider: "baidu";
309
+ readonly displayName: "Baidu";
310
+ readonly family: "baidu";
311
+ readonly category: "china";
312
+ readonly status: "implemented";
313
+ readonly defaultScopes: readonly ["basic"];
314
+ readonly browserVisible: true;
315
+ }];
316
+ declare function getOauthProviderCatalogEntry(provider: string): OauthProviderCatalogEntry | undefined;
317
+ declare function listOauthProviderCatalog(options?: {
318
+ implementedOnly?: boolean;
319
+ browserVisibleOnly?: boolean;
320
+ }): readonly OauthProviderCatalogEntry[];
321
+ declare function isImplementedOauthProvider(provider: string): provider is ImplementedOauthProviderName;
322
+
323
+ /**
324
+ * Provider adapter registry —— 按 provider id 查表。
325
+ *
326
+ * 当前支持:
327
+ * - github(GitHub.com + GitHub Enterprise)
328
+ * - gitee(Gitee.com + Gitee Enterprise)
329
+ * - google(Google OAuth 2.0 / OIDC)
330
+ * - microsoft(Microsoft Identity Platform v2.0)
331
+ * - wechat_web / wechat_official_account / wecom
332
+ * - qq / dingtalk / lark / weibo / baidu
333
+ * 计划项见 catalog.ts(如 alipay 等 server-only/native provider)。
334
+ */
335
+
336
+ declare function getOauthProviderAdapter(provider: string): OauthProviderAdapter;
337
+ declare function listSupportedOauthProviders(): readonly OauthProviderAdapter[];
338
+
339
+ /** shared 包内可执行 adapter 的 provider id 列表;server-only adapter 由 apicore 扩展。 */
340
+ declare const SUPPORTED_OAUTH_PROVIDERS: string[];
341
+
342
+ /**
343
+ * 邮件模板 slug 常量 + purpose→slug 映射。
344
+ *
345
+ * 移自 @yhgale/apicore/email/slugs.ts。与 DB EmailTemplate.slug 列对齐。
346
+ */
347
+ declare const EMAIL_TEMPLATE_SLUGS: {
348
+ readonly signUpVerification: "sign_up_verification_code";
349
+ readonly signInCode: "sign_in_code";
350
+ readonly resetPassword: "reset_password_code";
351
+ readonly emailChange: "email_change_code";
352
+ readonly organizationInvitation: "organization_invitation";
353
+ readonly emailVerification: "email_verification";
354
+ };
355
+ type EmailTemplateSlug = (typeof EMAIL_TEMPLATE_SLUGS)[keyof typeof EMAIL_TEMPLATE_SLUGS];
356
+ /** purpose → slug 映射 */
357
+ declare function purposeToSlug(purpose: string): EmailTemplateSlug | null;
358
+
359
+ /**
360
+ * 内置默认邮件模板。
361
+ *
362
+ * 移自 @yhgale/apicore/email/defaults.ts。
363
+ * `resolveEmailTemplate` 在 DB 无匹配行时回退到这里。
364
+ */
365
+ interface BuiltInEmailTemplate {
366
+ subject: string;
367
+ bodyMarkdown: string;
368
+ }
369
+ declare const DEFAULT_EMAIL_TEMPLATES: Record<string, BuiltInEmailTemplate>;
370
+ declare function getDefaultEmailTemplate(slug: string): BuiltInEmailTemplate;
371
+
372
+ /**
373
+ * 邮件工具 —— 移自 @yhgale/apicore/email/markdown.ts。
374
+ * 仅 escapeHtml(纯函数,零依赖),完整渲染器(marked + DOMPurify)留在 apicore。
375
+ */
376
+ declare function escapeHtml(value: string): string;
377
+
378
+ interface PublishableKey {
379
+ frontendApiHost: string;
380
+ instanceType: 'development' | 'production';
381
+ instanceId?: string;
382
+ environmentType?: 'development' | 'production';
383
+ keyVersion: number;
384
+ slug?: string;
385
+ publicPrefix?: string;
386
+ }
387
+ interface PublishableKeyPayloadV1 {
388
+ v: 1;
389
+ instanceId: string;
390
+ slug?: string;
391
+ /** Compatibility-only network hint. Instance identity must not depend on it. */
392
+ fapiHost?: string;
393
+ }
394
+ interface PublishableKeyPayloadV2 {
395
+ keyVersion: 2;
396
+ instanceId: string;
397
+ environmentType: 'development' | 'production';
398
+ publicPrefix?: string;
399
+ frontendApiHost?: string;
400
+ }
401
+ type BuildPublishableKeyInput = {
402
+ instanceId: string;
403
+ environmentType: 'development' | 'production';
404
+ slug?: string;
405
+ /** Deprecated compatibility hint. Prefer explicit apiUrl or platform defaults. */
406
+ frontendApiHost?: string;
407
+ publicPrefix?: string;
408
+ } | string;
409
+ declare function buildPublishableKey(input: BuildPublishableKeyInput, instanceType?: 'development' | 'production'): string;
410
+ declare function parsePublishableKey(key: string | undefined): PublishableKey | null;
411
+ declare function isPublishableKey(key: string): boolean;
412
+
413
+ /**
414
+ * AI 配置助手 —— 页面引导/代填(guide)契约。
415
+ *
416
+ * **职责**:钉死「AI 生成引导/代填草稿 → dashboard 页面表单应用」的跨端协议。
417
+ * 后端(apicore 工具 + DAPI SSE)与 dashboard(SSE 解析 + 页面注册表 + form bridge)
418
+ * 共用这一份白名单与校验,任何一端收到不在白名单内的 pageKey/fieldKey 都必须拒绝。
419
+ *
420
+ * 约束:
421
+ * - pageKey / fieldKey 全部白名单制,AI 不能生成任意 URL 或字段名;
422
+ * - `sensitive: true` 的字段(如 accessKeySecret)只能由用户在表单手填,
423
+ * 绝不进入 guide values、AI 会话历史或审计文本;
424
+ * - guide 草稿只是"草稿":fill 模式也只写表单 state,保存始终走页面原保存按钮。
425
+ */
426
+ /** guide 模式:guide=仅定位/高亮/解释(不改表单);fill=跳转并把草稿写入表单 */
427
+ declare const AI_GUIDE_MODES: readonly ["guide", "fill"];
428
+ type AiGuideMode = (typeof AI_GUIDE_MODES)[number];
429
+ type AiGuideFieldType = 'string' | 'boolean';
430
+ interface AiGuideFieldSpec {
431
+ key: string;
432
+ type: AiGuideFieldType;
433
+ /** 敏感字段:只允许用户手动输入,禁止出现在 guide values 中 */
434
+ sensitive?: boolean;
435
+ }
436
+ interface AiGuidePageSpec {
437
+ pageKey: string;
438
+ fields: readonly AiGuideFieldSpec[];
439
+ }
440
+ type AiGuideValue = string | boolean;
441
+ /**
442
+ * 一份引导/代填草稿。values 的键必须全部属于 pageKey 白名单内的非敏感字段;
443
+ * focusFields 用于 guide 模式指定要定位/高亮的字段(缺省时高亮 values 的键)。
444
+ */
445
+ interface AiGuideDraft {
446
+ pageKey: string;
447
+ mode: AiGuideMode;
448
+ values: Record<string, AiGuideValue>;
449
+ focusFields?: string[];
450
+ /** 给管理员看的补充说明(如"签名需先在阿里云审核通过") */
451
+ note?: string;
452
+ }
453
+ declare const AI_GUIDE_PAGES: readonly AiGuidePageSpec[];
454
+ declare function getAiGuidePageSpec(pageKey: string): AiGuidePageSpec | undefined;
455
+ /** 页面敏感字段键列表(UI 用于提示"需手动填写";这些键不得出现在 values 里) */
456
+ declare function listAiGuideSensitiveFieldKeys(pageKey: string): string[];
457
+ /**
458
+ * 严格校验一份 guide 草稿:未知 pageKey / 未知或敏感 fieldKey / 类型不匹配 /
459
+ * fill 模式空 values 一律返回 null(调用方按"草稿无效"处理,不得部分应用)。
460
+ */
461
+ declare function parseAiGuideDraft(input: unknown): AiGuideDraft | null;
462
+
463
+ declare const AI_NAVIGATION_PAGE_KEYS: readonly ["workspace.workspaces", "workspace.applications", "workspace.team", "workspace.settings", "application.instances", "application.settings", "instance.overview", "instance.users", "instance.organizations", "instance.logs", "instance.settings", "instance.auth", "instance.multiFactor", "instance.sso", "instance.sms", "instance.smtp", "instance.apiKeys", "instance.domains", "instance.webhooks", "instance.sessions", "instance.accountPortal"];
464
+ type AiNavigationPageKey = (typeof AI_NAVIGATION_PAGE_KEYS)[number];
465
+ interface AiNavigationTarget {
466
+ pageKey: AiNavigationPageKey;
467
+ }
468
+ declare function parseAiNavigationTarget(input: unknown): AiNavigationTarget | null;
469
+
470
+ declare const GALE_VERSION = "0.0.0";
471
+
472
+ export { AI_GUIDE_MODES, AI_GUIDE_PAGES, AI_NAVIGATION_PAGE_KEYS, type AiGuideDraft, type AiGuideFieldSpec, type AiGuideFieldType, type AiGuideMode, type AiGuidePageSpec, type AiGuideValue, type AiNavigationPageKey, type AiNavigationTarget, type BuildPublishableKeyInput, type BuiltInEmailTemplate, DEFAULT_BAPI_PORT, DEFAULT_DATABASE_URL, DEFAULT_EMAIL_FROM, DEFAULT_EMAIL_TEMPLATES, DEFAULT_FAPI_PORT, DEFAULT_JWT_AUDIENCE, DEFAULT_REDIS_URL, DEFAULT_ROOT_DOMAIN, type DefaultInstanceHostParts, EMAIL_TEMPLATE_SLUGS, type EmailTemplateSlug, GALE_VERSION, IMPLEMENTED_OAUTH_PROVIDER_IDS, IdentityJSON, IdentityResource, type ImplementedOauthProviderName, MeJSON, OAUTH_PROVIDER_CATALOG, OauthProviderAdapter, type OauthProviderCatalogEntry, type OauthProviderCategory, type OauthProviderFamily, type OauthProviderName, type OauthProviderStatus, OrganizationJSON, OrganizationMembershipJSON, OrganizationMembershipResource, OrganizationResource, type PublishableKey, type PublishableKeyPayloadV1, type PublishableKeyPayloadV2, SUPPORTED_OAUTH_PROVIDERS, SessionJSON, SessionResource, SignInAttemptJSON, SignInAttemptResource, SignInResponseJSON, SignUpAttemptJSON, SignUpAttemptResource, SignUpResponseJSON, TokenJSON, TokenResource, UserJSON, UserResource, _resetDomainCache, baiduAdapter, buildBapiHost, buildDapiHost, buildDashboardFapiHost, buildDashboardHost, buildDevAccountsHost, buildDevAccountsPrefix, buildDevFapiHost, buildDevFapiPrefix, buildFapiHost, buildProdAccountsHost, buildProdAccountsPrefix, buildProdFapiHost, buildProdFapiPrefix, buildPublishableKey, clearWeComSuiteAccessTokenCacheForTests, dingtalkAdapter, escapeHtml, extractFapiPrefix, getAiGuidePageSpec, getDefaultBapiHost, getDefaultDapiHost, getDefaultEmailTemplate, getDefaultFapiHost, getDefaultRootDomain, getOauthProviderAdapter, getOauthProviderCatalogEntry, getRootDomain, giteeAdapter, githubAdapter, googleAdapter, isImplementedOauthProvider, isPublishableKey, larkAdapter, listAiGuideSensitiveFieldKeys, listOauthProviderCatalog, listSupportedOauthProviders, microsoftAdapter, parseAiGuideDraft, parseAiNavigationTarget, parseDefaultInstanceHost, parseIdentity, parseMe, parseOrganization, parseOrganizationMembership, parsePublishableKey, parseSession, parseSignInAttempt, parseSignInResponse, parseSignUpAttempt, parseSignUpResponse, parseToken, parseUser, purposeToSlug, qqAdapter, wechatOfficialAccountAdapter, wechatWebAdapter, wecomAdapter, weiboAdapter };