@autional/shared 0.1.0-rc.49 → 0.1.0-rc.51

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autional/shared",
3
- "version": "0.1.0-rc.49",
3
+ "version": "0.1.0-rc.51",
4
4
  "description": "Autional shared layer — API client, auth, types, hooks, utils",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "./src/index.ts",
@@ -123,6 +123,18 @@ describe('buildLoginUrl', () => {
123
123
  );
124
124
  });
125
125
 
126
+ // 回归锁(2026-11-08):/activity 与 /security 是 auth 站裸路由,
127
+ // 缺登记会被当成租户 slug → /activity/login、/security/login(未知租户页)。
128
+ it('treats /activity and /security as reserved auth routes', () => {
129
+ for (const route of ['activity', 'security']) {
130
+ mockWindow('auth.autional.local', 'https:', 'https://auth.autional.local', AUTH_CONFIG);
131
+ const target = `https://auth.autional.local/${route}`;
132
+ expect(buildLoginUrl(target)).toBe(
133
+ 'https://auth.autional.local?redirect=' + encodeURIComponent(target),
134
+ );
135
+ }
136
+ });
137
+
126
138
  it('preserves cross-domain returnUrl behavior (app domain)', () => {
127
139
  mockWindow('auth.autional.local', 'https:', 'https://auth.autional.local', AUTH_CONFIG);
128
140
  const url = buildLoginUrl('https://app.autional.com/admin');
package/src/auth/roles.ts CHANGED
@@ -36,6 +36,10 @@ const AUTH_ROUTE_RESERVED = new Set([
36
36
  'recover-account',
37
37
  'account-deletion',
38
38
  'verify-identity',
39
+ // auth 站裸路由:/activity(活动页,原 /security 改名)与 /security(旧路径重定向)。
40
+ // 缺这两段会把首段当租户 slug,生成 /activity/login、/security/login(未知租户页)。
41
+ 'activity',
42
+ 'security',
39
43
  ]);
40
44
 
41
45
  /**
@@ -4552,15 +4552,6 @@ export async function adminRoleActivations(params?: {
4552
4552
  return res.data;
4553
4553
  }
4554
4554
 
4555
- /**
4556
- * 批准角色激活
4557
- * 管理员批准待处理的角色激活请求
4558
- */
4559
- export async function adminRoleActivationsApproveByRoleActivationsPost(roleActivationId: string) {
4560
- const res = await api.post(`/identity/api/v1/admin/role-activations/${roleActivationId}/approve`);
4561
- return res.data;
4562
- }
4563
-
4564
4555
  /**
4565
4556
  * 撤销角色激活
4566
4557
  * 管理员撤销正在生效的角色激活,立即移除用户的提权权限
@@ -5151,15 +5142,6 @@ export async function authLogoutPost() {
5151
5142
  return res.data;
5152
5143
  }
5153
5144
 
5154
- /**
5155
- * 发送魔法链接
5156
- * 接收邮箱,生成一次性 magic link token 并发送到用户邮箱(dev模式打印到日志)
5157
- */
5158
- export async function authMagicLinkPost(data: MagicLinkRequest) {
5159
- const res = await api.post(`/identity/api/v1/auth/magic-link`, data);
5160
- return res.data;
5161
- }
5162
-
5163
5145
  /**
5164
5146
  * 魔法链接回调 (GET→POST 双步跳转)
5165
5147
  * GET: 渲染中转HTML页面 (无泄露), POST: 验证token生成JWT
@@ -5182,17 +5164,6 @@ export async function authMagicLinkCallbackPost(params?: {
5182
5164
  return res.data;
5183
5165
  }
5184
5166
 
5185
- /**
5186
- * 验证魔法链接
5187
- * 验证 token 有效性,返回 JWT 令牌和用户信息
5188
- */
5189
- export async function authMagicLinkConfirm(params?: {
5190
- token: string; // 魔法链接令牌
5191
- }) {
5192
- const res = await api.get(`/identity/api/v1/auth/magic-link/confirm`, { params });
5193
- return res.data;
5194
- }
5195
-
5196
5167
  /**
5197
5168
  * 请求发送魔法链接
5198
5169
  * 验证邮箱并发送包含魔法链接的邮件。无论邮箱是否注册均返回成功(防枚举)。
@@ -6970,62 +6941,6 @@ export async function mfaTrustedDevicesByTrustedDevices(trustedDeviceId: string)
6970
6941
  return res.data;
6971
6942
  }
6972
6943
 
6973
- /**
6974
- * 列出WebAuthn凭证
6975
- * 列出用户所有已注册的WebAuthn/通行密钥凭证,包含名称和最后使用时间。参考:W3C WebAuthn Level 2、FIDO2 CTAP 2.1。
6976
- */
6977
- export async function mfaWebauthnCredentials(params?: {
6978
- page?: number; // 页码
6979
- page_size?: number; // 每页条数
6980
- }) {
6981
- const res = await api.get(`/mfa/api/v1/mfa/webauthn/credentials`, { params });
6982
- return res.data;
6983
- }
6984
-
6985
- /**
6986
- * 开始WebAuthn凭证注册
6987
- * 生成 WebAuthn credential creation options (challenge, rp, user, pubKeyCredParams)
6988
- */
6989
- export async function mfaWebauthnCredentialsRegisterPost(data: BeginWebAuthnRegistrationRequest) {
6990
- const res = await api.post(`/mfa/api/v1/mfa/webauthn/credentials/register`, data);
6991
- return res.data;
6992
- }
6993
-
6994
- /**
6995
- * 完成WebAuthn凭证注册
6996
- * 验证 attestation 响应并存储凭证。需要先调用 /mfa/webauthn/credentials/register 获取 creation options。
6997
- */
6998
- export async function mfaWebauthnCredentialsRegisterVerifyPost(data: FinishWebAuthnRegistrationRequest) {
6999
- const res = await api.post(`/mfa/api/v1/mfa/webauthn/credentials/register/verify`, data);
7000
- return res.data;
7001
- }
7002
-
7003
- /**
7004
- * 删除WebAuthn凭证
7005
- * 删除指定WebAuthn凭证。参考:W3C WebAuthn Level 2、FIDO2 CTAP 2.1。
7006
- */
7007
- export async function mfaWebauthnCredentialsByCredentialsDelete(webauthnCredentialId: string) {
7008
- await api.delete(`/mfa/api/v1/mfa/webauthn/credentials/${webauthnCredentialId}`);
7009
- }
7010
-
7011
- /**
7012
- * 获取WebAuthn凭证详情
7013
- * 根据ID获取指定WebAuthn凭证的详细信息。参考:W3C WebAuthn Level 2、FIDO2 CTAP 2.1。
7014
- */
7015
- export async function mfaWebauthnCredentialsByCredentials(webauthnCredentialId: string) {
7016
- const res = await api.get(`/mfa/api/v1/mfa/webauthn/credentials/${webauthnCredentialId}`);
7017
- return res.data;
7018
- }
7019
-
7020
- /**
7021
- * 重命名WebAuthn凭证
7022
- * 重命名指定WebAuthn凭证的设备名称。参考:W3C WebAuthn Level 2、FIDO2 CTAP 2.1。
7023
- */
7024
- export async function mfaWebauthnCredentialsByCredentialsPut(webauthnCredentialId: string, data: UpdateWebAuthnCredentialRequest) {
7025
- const res = await api.put(`/mfa/api/v1/mfa/webauthn/credentials/${webauthnCredentialId}`, data);
7026
- return res.data;
7027
- }
7028
-
7029
6944
  // ============================================================
7030
6945
  // Notification Service
7031
6946
  // ============================================================
@@ -1,7 +1,7 @@
1
1
  // GENERATED FILE — DO NOT EDIT.
2
2
  // Source: contracts/errors.semantics.json(@autional/shared 仓内镜像,源 = service-core base/error/testdata/errors.semantics.json)
3
3
  // Regenerate: pnpm gen:errors · Verify: pnpm gen:errors:check
4
- // rows: 798 · source sha256: e82f038da18dc0935623718a7516ede07d741ed071275aad4ca1610db00a8d5d
4
+ // rows: 801 · source sha256: 812f1ec64dade2b940ae6f12af43fb170e9f0f7f658b707fc29f1f0fd48c50b5
5
5
  //
6
6
  // 单一真源链:service-core/base/error/semantics.go(Go)→ errors.semantics.json → 本文件。
7
7
  // ⚠️ 禁止在本文件或页面里手抄错误码分支:请消费 ERROR_SEMANTICS / UNPROVISIONED_CODES。
@@ -177,6 +177,9 @@ export const ERROR_SEMANTICS: Readonly<Record<number, ErrorSemantics>> = {
177
177
  20600007: { code: 20600007, httpStatus: 400, class: 'invalid', absence: '', uiObservation: 'form_error', retryable: false, docsPath: '/errors/20600007' },
178
178
  20600008: { code: 20600008, httpStatus: 400, class: 'invalid', absence: '', uiObservation: 'form_error', retryable: false, docsPath: '/errors/20600008' },
179
179
  20800004: { code: 20800004, httpStatus: 404, class: 'not_found', absence: 'entity', uiObservation: 'not_found_page', retryable: false, docsPath: '/errors/20800004' },
180
+ 20900001: { code: 20900001, httpStatus: 503, class: 'unavailable', absence: '', uiObservation: 'transient', retryable: true, docsPath: '/errors/20900001' },
181
+ 20900002: { code: 20900002, httpStatus: 503, class: 'unavailable', absence: '', uiObservation: 'transient', retryable: true, docsPath: '/errors/20900002' },
182
+ 21000002: { code: 21000002, httpStatus: 503, class: 'unavailable', absence: '', uiObservation: 'transient', retryable: true, docsPath: '/errors/21000002' },
180
183
  21000004: { code: 21000004, httpStatus: 503, class: 'unavailable', absence: '', uiObservation: 'transient', retryable: true, docsPath: '/errors/21000004' },
181
184
  21100004: { code: 21100004, httpStatus: 500, class: 'internal', absence: '', uiObservation: 'unexpected', retryable: false, docsPath: '/errors/21100004' },
182
185
  21100006: { code: 21100006, httpStatus: 404, class: 'not_found', absence: 'entity', uiObservation: 'not_found_page', retryable: false, docsPath: '/errors/21100006' },
@@ -859,8 +862,8 @@ export const UNPROVISIONED_CODES: ReadonlySet<number> = new Set([]);
859
862
  export const EMPTY_STATE_CODES: ReadonlySet<number> = new Set([]);
860
863
 
861
864
  export const ERROR_SEMANTICS_META = {
862
- rowCount: 798,
863
- sourceSha256: 'e82f038da18dc0935623718a7516ede07d741ed071275aad4ca1610db00a8d5d',
865
+ rowCount: 801,
866
+ sourceSha256: '812f1ec64dade2b940ae6f12af43fb170e9f0f7f658b707fc29f1f0fd48c50b5',
864
867
  } as const;
865
868
 
866
869
  /** 具名错误码常量(契约 name → code)。页面只消费常量,不写数字字面量。 */
@@ -2157,14 +2157,6 @@ export function useAuthMagic_linkCallback(params?: any) {
2157
2157
  });
2158
2158
  }
2159
2159
 
2160
- /** 验证魔法链接 */
2161
- export function useAuthMagic_linkConfirm(params?: any) {
2162
- return useQuery({
2163
- queryKey: ['identity-service', params] as const,
2164
- queryFn: () => api.authMagicLinkConfirm(params),
2165
- });
2166
- }
2167
-
2168
2160
  /** 获取当前登录用户信息 */
2169
2161
  export function useAuthMe() {
2170
2162
  return useQuery({
@@ -2693,22 +2685,6 @@ export function useMfaTrusted_devicesByTrustedDevices(trustedDeviceId: string) {
2693
2685
  });
2694
2686
  }
2695
2687
 
2696
- /** 列出WebAuthn凭证 */
2697
- export function useMfaWebauthnCredentials(params?: any) {
2698
- return useQuery({
2699
- queryKey: ['mfa-service', params] as const,
2700
- queryFn: () => api.mfaWebauthnCredentials(params),
2701
- });
2702
- }
2703
-
2704
- /** 获取WebAuthn凭证详情 */
2705
- export function useMfaWebauthnCredentialsByCredentials(webauthnCredentialId: string) {
2706
- return useQuery({
2707
- queryKey: ['mfa-service', 'by_' + webauthnCredentialId] as const,
2708
- queryFn: () => api.mfaWebauthnCredentialsByCredentials(webauthnCredentialId),
2709
- });
2710
- }
2711
-
2712
2688
  // --- notification-service ---
2713
2689
 
2714
2690
  /** 管理端列出公告 */
@@ -7213,17 +7189,6 @@ export function usePostAdminRobotsIntentRevokeByRobots() {
7213
7189
  });
7214
7190
  }
7215
7191
 
7216
- /** 批准角色激活 */
7217
- export function usePostAdminRole_activationsApproveByRoleActivations() {
7218
- const qc = useQueryClient();
7219
- return useMutation({
7220
- mutationFn: (roleActivationId: string) => api.adminRoleActivationsApproveByRoleActivationsPost(roleActivationId),
7221
- onSuccess: () => {
7222
- qc.invalidateQueries({ queryKey: ['identity-service'] });
7223
- },
7224
- });
7225
- }
7226
-
7227
7192
  /** 撤销角色激活 */
7228
7193
  export function usePostAdminRole_activationsRevokeByRoleActivations() {
7229
7194
  const qc = useQueryClient();
@@ -7675,17 +7640,6 @@ export function usePostAuthLogout() {
7675
7640
  });
7676
7641
  }
7677
7642
 
7678
- /** 发送魔法链接 */
7679
- export function usePostAuthMagic_link() {
7680
- const qc = useQueryClient();
7681
- return useMutation({
7682
- mutationFn: (data: any) => api.authMagicLinkPost(data),
7683
- onSuccess: () => {
7684
- qc.invalidateQueries({ queryKey: ['identity-service'] });
7685
- },
7686
- });
7687
- }
7688
-
7689
7643
  /** 魔法链接回调 (GET→POST 双步跳转) */
7690
7644
  export function usePostAuthMagic_linkCallback() {
7691
7645
  const qc = useQueryClient();
@@ -9083,50 +9037,6 @@ export function useDeleteMfaTrusted_devicesByTrustedDevices() {
9083
9037
  });
9084
9038
  }
9085
9039
 
9086
- /** 开始WebAuthn凭证注册 */
9087
- export function usePostMfaWebauthnCredentialsRegister() {
9088
- const qc = useQueryClient();
9089
- return useMutation({
9090
- mutationFn: (data: any) => api.mfaWebauthnCredentialsRegisterPost(data),
9091
- onSuccess: () => {
9092
- qc.invalidateQueries({ queryKey: ['mfa-service'] });
9093
- },
9094
- });
9095
- }
9096
-
9097
- /** 完成WebAuthn凭证注册 */
9098
- export function usePostMfaWebauthnCredentialsRegisterVerify() {
9099
- const qc = useQueryClient();
9100
- return useMutation({
9101
- mutationFn: (data: any) => api.mfaWebauthnCredentialsRegisterVerifyPost(data),
9102
- onSuccess: () => {
9103
- qc.invalidateQueries({ queryKey: ['mfa-service'] });
9104
- },
9105
- });
9106
- }
9107
-
9108
- /** 删除WebAuthn凭证 */
9109
- export function useDeleteMfaWebauthnCredentialsByCredentials() {
9110
- const qc = useQueryClient();
9111
- return useMutation({
9112
- mutationFn: (webauthnCredentialId: string) => api.mfaWebauthnCredentialsByCredentialsDelete(webauthnCredentialId),
9113
- onSuccess: () => {
9114
- qc.invalidateQueries({ queryKey: ['mfa-service'] });
9115
- },
9116
- });
9117
- }
9118
-
9119
- /** 重命名WebAuthn凭证 */
9120
- export function usePutMfaWebauthnCredentialsByCredentials() {
9121
- const qc = useQueryClient();
9122
- return useMutation({
9123
- mutationFn: ({ webauthnCredentialId, data }: { webauthnCredentialId: string, data: any }) => api.mfaWebauthnCredentialsByCredentialsPut(webauthnCredentialId, data),
9124
- onSuccess: () => {
9125
- qc.invalidateQueries({ queryKey: ['mfa-service'] });
9126
- },
9127
- });
9128
- }
9129
-
9130
9040
  // --- notification-service ---
9131
9041
 
9132
9042
  /** 创建公告 */