@nihplod/sso-sdk 1.4.0 → 1.5.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.
- package/README.md +90 -8
- package/dist/index.d.mts +27 -3
- package/dist/index.d.ts +27 -3
- package/dist/index.js +169 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +169 -38
- package/dist/index.mjs.map +1 -1
- package/dist/next/index.d.mts +50 -0
- package/dist/next/index.d.ts +50 -0
- package/dist/next/index.js +320 -103
- package/dist/next/index.js.map +1 -1
- package/dist/next/index.mjs +320 -103
- package/dist/next/index.mjs.map +1 -1
- package/dist/react/index.d.mts +25 -1
- package/dist/react/index.d.ts +25 -1
- package/dist/react/index.js +329 -71
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +329 -71
- package/dist/react/index.mjs.map +1 -1
- package/package.json +9 -3
package/dist/react/index.d.mts
CHANGED
|
@@ -62,6 +62,11 @@ interface SsoClientConfig {
|
|
|
62
62
|
scopes?: string;
|
|
63
63
|
/** RP-Initiated Logout 返回地址(可选)。不传时回退到 redirectUri */
|
|
64
64
|
postLogoutRedirectUri?: string;
|
|
65
|
+
/**
|
|
66
|
+
* 调试日志开关(默认 false)。开启后输出登录/回调/刷新/登出等关键流程日志,
|
|
67
|
+
* 便于接入方定位问题(生产默认关闭,避免日志噪音)。
|
|
68
|
+
*/
|
|
69
|
+
debug?: boolean;
|
|
65
70
|
/**
|
|
66
71
|
* 服务端到服务端调用的内网地址(可选,如 http://127.0.0.1:3000)。
|
|
67
72
|
* 仅用于 discovery / token / userinfo / revocation 等服务器间请求;
|
|
@@ -128,6 +133,12 @@ declare class SsoClient {
|
|
|
128
133
|
/** Discovery fetch 超时(10 秒) */
|
|
129
134
|
private static readonly DISCOVERY_TIMEOUT_MS;
|
|
130
135
|
constructor(config: SsoClientConfig);
|
|
136
|
+
/**
|
|
137
|
+
* 调试日志(config.debug=true 时输出,前缀 [SSO SDK]):
|
|
138
|
+
* 覆盖登录发起 / 回调结果 / 刷新失败 / 登出等关键节点,便于接入方定位问题。
|
|
139
|
+
* 不会输出 token/授权码等敏感值。
|
|
140
|
+
*/
|
|
141
|
+
debugLog(...args: unknown[]): void;
|
|
131
142
|
/**
|
|
132
143
|
* 获取 OIDC Discovery 文档(带缓存 + 超时)
|
|
133
144
|
*
|
|
@@ -339,6 +350,12 @@ interface SsoContextValue {
|
|
|
339
350
|
refreshUser: () => Promise<void>;
|
|
340
351
|
/** 获取 access_token(自动刷新过期 token) */
|
|
341
352
|
getAccessToken: () => Promise<string | null>;
|
|
353
|
+
/**
|
|
354
|
+
* 会话已失效(refresh_token 被撤销/过期),需要用户重新登录。
|
|
355
|
+
* 与 `error` 不同:该标志在 loadUser 拿到"无 token"时不会被清空,
|
|
356
|
+
* 登录成功后才复位,便于子站稳定展示"登录已过期"提示。
|
|
357
|
+
*/
|
|
358
|
+
sessionExpired: boolean;
|
|
342
359
|
/** SsoClient 实例(高级用法) */
|
|
343
360
|
client: SsoClient;
|
|
344
361
|
}
|
|
@@ -359,8 +376,13 @@ interface SsoProviderProps {
|
|
|
359
376
|
* SDK 不会据此自动重试先前失败的 API 请求,重试需由调用方自行实现。
|
|
360
377
|
*/
|
|
361
378
|
onTokenRefreshed?: (token: string) => void;
|
|
379
|
+
/**
|
|
380
|
+
* 会话失效回调(可选)。refresh_token 被撤销/过期时触发一次,
|
|
381
|
+
* 子站可据此展示"登录已过期,请重新登录"或埋点上报。
|
|
382
|
+
*/
|
|
383
|
+
onSessionExpired?: (error: SsoError) => void;
|
|
362
384
|
}
|
|
363
|
-
declare function SsoProvider({ config, children, refreshThreshold, onTokenRefreshed, }: SsoProviderProps): React.FunctionComponentElement<React.ProviderProps<SsoContextValue | null>>;
|
|
385
|
+
declare function SsoProvider({ config, children, refreshThreshold, onTokenRefreshed, onSessionExpired, }: SsoProviderProps): React.FunctionComponentElement<React.ProviderProps<SsoContextValue | null>>;
|
|
364
386
|
/**
|
|
365
387
|
* useSso Hook
|
|
366
388
|
*
|
|
@@ -481,6 +503,8 @@ declare function DefaultCallbackError({ error }: {
|
|
|
481
503
|
justifyContent: "center";
|
|
482
504
|
minHeight: string;
|
|
483
505
|
fontFamily: "system-ui, sans-serif";
|
|
506
|
+
padding: string;
|
|
507
|
+
textAlign: "center";
|
|
484
508
|
};
|
|
485
509
|
}, HTMLElement>;
|
|
486
510
|
declare function CallbackPage({ onSuccess, onError, renderError }?: CallbackPageProps): React.FunctionComponentElement<React.FragmentProps> | React.FunctionComponentElement<{
|
package/dist/react/index.d.ts
CHANGED
|
@@ -62,6 +62,11 @@ interface SsoClientConfig {
|
|
|
62
62
|
scopes?: string;
|
|
63
63
|
/** RP-Initiated Logout 返回地址(可选)。不传时回退到 redirectUri */
|
|
64
64
|
postLogoutRedirectUri?: string;
|
|
65
|
+
/**
|
|
66
|
+
* 调试日志开关(默认 false)。开启后输出登录/回调/刷新/登出等关键流程日志,
|
|
67
|
+
* 便于接入方定位问题(生产默认关闭,避免日志噪音)。
|
|
68
|
+
*/
|
|
69
|
+
debug?: boolean;
|
|
65
70
|
/**
|
|
66
71
|
* 服务端到服务端调用的内网地址(可选,如 http://127.0.0.1:3000)。
|
|
67
72
|
* 仅用于 discovery / token / userinfo / revocation 等服务器间请求;
|
|
@@ -128,6 +133,12 @@ declare class SsoClient {
|
|
|
128
133
|
/** Discovery fetch 超时(10 秒) */
|
|
129
134
|
private static readonly DISCOVERY_TIMEOUT_MS;
|
|
130
135
|
constructor(config: SsoClientConfig);
|
|
136
|
+
/**
|
|
137
|
+
* 调试日志(config.debug=true 时输出,前缀 [SSO SDK]):
|
|
138
|
+
* 覆盖登录发起 / 回调结果 / 刷新失败 / 登出等关键节点,便于接入方定位问题。
|
|
139
|
+
* 不会输出 token/授权码等敏感值。
|
|
140
|
+
*/
|
|
141
|
+
debugLog(...args: unknown[]): void;
|
|
131
142
|
/**
|
|
132
143
|
* 获取 OIDC Discovery 文档(带缓存 + 超时)
|
|
133
144
|
*
|
|
@@ -339,6 +350,12 @@ interface SsoContextValue {
|
|
|
339
350
|
refreshUser: () => Promise<void>;
|
|
340
351
|
/** 获取 access_token(自动刷新过期 token) */
|
|
341
352
|
getAccessToken: () => Promise<string | null>;
|
|
353
|
+
/**
|
|
354
|
+
* 会话已失效(refresh_token 被撤销/过期),需要用户重新登录。
|
|
355
|
+
* 与 `error` 不同:该标志在 loadUser 拿到"无 token"时不会被清空,
|
|
356
|
+
* 登录成功后才复位,便于子站稳定展示"登录已过期"提示。
|
|
357
|
+
*/
|
|
358
|
+
sessionExpired: boolean;
|
|
342
359
|
/** SsoClient 实例(高级用法) */
|
|
343
360
|
client: SsoClient;
|
|
344
361
|
}
|
|
@@ -359,8 +376,13 @@ interface SsoProviderProps {
|
|
|
359
376
|
* SDK 不会据此自动重试先前失败的 API 请求,重试需由调用方自行实现。
|
|
360
377
|
*/
|
|
361
378
|
onTokenRefreshed?: (token: string) => void;
|
|
379
|
+
/**
|
|
380
|
+
* 会话失效回调(可选)。refresh_token 被撤销/过期时触发一次,
|
|
381
|
+
* 子站可据此展示"登录已过期,请重新登录"或埋点上报。
|
|
382
|
+
*/
|
|
383
|
+
onSessionExpired?: (error: SsoError) => void;
|
|
362
384
|
}
|
|
363
|
-
declare function SsoProvider({ config, children, refreshThreshold, onTokenRefreshed, }: SsoProviderProps): React.FunctionComponentElement<React.ProviderProps<SsoContextValue | null>>;
|
|
385
|
+
declare function SsoProvider({ config, children, refreshThreshold, onTokenRefreshed, onSessionExpired, }: SsoProviderProps): React.FunctionComponentElement<React.ProviderProps<SsoContextValue | null>>;
|
|
364
386
|
/**
|
|
365
387
|
* useSso Hook
|
|
366
388
|
*
|
|
@@ -481,6 +503,8 @@ declare function DefaultCallbackError({ error }: {
|
|
|
481
503
|
justifyContent: "center";
|
|
482
504
|
minHeight: string;
|
|
483
505
|
fontFamily: "system-ui, sans-serif";
|
|
506
|
+
padding: string;
|
|
507
|
+
textAlign: "center";
|
|
484
508
|
};
|
|
485
509
|
}, HTMLElement>;
|
|
486
510
|
declare function CallbackPage({ onSuccess, onError, renderError }?: CallbackPageProps): React.FunctionComponentElement<React.FragmentProps> | React.FunctionComponentElement<{
|