@seaverse/auth-sdk 0.1.1 → 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.
- package/README.md +24 -6
- package/dist/index.cjs +135 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +97 -2
- package/dist/index.js +133 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -631,17 +631,112 @@ declare namespace models {
|
|
|
631
631
|
export type { models_ApiError as ApiError, models_ApiServiceTokenResponse as ApiServiceTokenResponse, models_CodeToTokenRequest as CodeToTokenRequest, models_CodeToTokenResponse as CodeToTokenResponse, models_Container as Container, models_ContainerDetailResponse as ContainerDetailResponse, models_ContainerListResponse as ContainerListResponse, models_ContainerStatsResponse as ContainerStatsResponse, models_ConversationStatus as ConversationStatus, models_CreateMarketplaceSkillRequest as CreateMarketplaceSkillRequest, models_CreateVideoShareRequest as CreateVideoShareRequest, models_CreateVideoShareResponse as CreateVideoShareResponse, models_ForgotPasswordRequest as ForgotPasswordRequest, models_ForkProjectRequest as ForkProjectRequest, models_ForkProjectResponse as ForkProjectResponse, models_HealthResponse as HealthResponse, models_HubProject as HubProject, models_HubProjectsListResponse as HubProjectsListResponse, models_InviteApplication as InviteApplication, models_InviteApplicationListResponse as InviteApplicationListResponse, models_InviteCodeBindRequest as InviteCodeBindRequest, models_InviteCodeGenerateResponse as InviteCodeGenerateResponse, models_InviteCodeVerifyResponse as InviteCodeVerifyResponse, models_LoginRequest as LoginRequest, models_LoginResponse as LoginResponse, models_MarketplaceSkill as MarketplaceSkill, models_MarketplaceSkillsListResponse as MarketplaceSkillsListResponse, models_PublishProjectRequest as PublishProjectRequest, models_PublishSkillRequest as PublishSkillRequest, models_RegisterContainerRequest as RegisterContainerRequest, models_RegisterContainerResponse as RegisterContainerResponse, models_RegisterRequest as RegisterRequest, models_RegisterResponse as RegisterResponse, models_ResetPasswordRequest as ResetPasswordRequest, models_SocialMediaLink as SocialMediaLink, models_SocialMediaLinksResponse as SocialMediaLinksResponse, models_SpeechTokenResponse as SpeechTokenResponse, models_SubmitInviteApplicationRequest as SubmitInviteApplicationRequest, models_SuccessResponse as SuccessResponse, models_TrackAppTypeRequest as TrackAppTypeRequest, models_User as User, models_UserInstalledSkill as UserInstalledSkill, models_UserInstalledSkillsListResponse as UserInstalledSkillsListResponse, models_VideoDetails as VideoDetails };
|
|
632
632
|
}
|
|
633
633
|
|
|
634
|
+
/**
|
|
635
|
+
* Environment Configuration for SeaVerse SDK
|
|
636
|
+
* 环境配置模块 - 支持多环境部署
|
|
637
|
+
*/
|
|
638
|
+
/**
|
|
639
|
+
* 支持的环境类型
|
|
640
|
+
*/
|
|
641
|
+
type Environment = 'production' | 'staging' | 'development' | 'local';
|
|
642
|
+
/**
|
|
643
|
+
* 环境配置接口
|
|
644
|
+
*/
|
|
645
|
+
interface EnvironmentConfig {
|
|
646
|
+
/** 环境名称 */
|
|
647
|
+
name: Environment;
|
|
648
|
+
/** API Base URL */
|
|
649
|
+
baseURL: string;
|
|
650
|
+
/** WebSocket URL (可选,未来扩展) */
|
|
651
|
+
wsURL?: string;
|
|
652
|
+
/** 是否为生产环境 */
|
|
653
|
+
isProduction: boolean;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* 预定义的环境配置
|
|
657
|
+
*
|
|
658
|
+
* 使用说明:
|
|
659
|
+
* - production: 正式生产环境
|
|
660
|
+
* - staging: 预发布环境(当前默认)
|
|
661
|
+
* - development: 开发测试环境
|
|
662
|
+
* - local: 本地开发环境
|
|
663
|
+
*/
|
|
664
|
+
declare const ENVIRONMENT_CONFIGS: Record<Environment, EnvironmentConfig>;
|
|
665
|
+
/**
|
|
666
|
+
* 根据当前运行环境自动检测应该使用的环境配置
|
|
667
|
+
*
|
|
668
|
+
* 检测规则:
|
|
669
|
+
* 1. localhost/127.0.0.1 → local
|
|
670
|
+
* 2. 包含 -dev 或 .dev → development
|
|
671
|
+
* 3. 包含 staging → staging
|
|
672
|
+
* 4. 其他 → production (默认)
|
|
673
|
+
*
|
|
674
|
+
* @returns 检测到的环境类型
|
|
675
|
+
*/
|
|
676
|
+
declare function detectEnvironment(): Environment;
|
|
677
|
+
/**
|
|
678
|
+
* 获取环境配置
|
|
679
|
+
*
|
|
680
|
+
* @param env 环境类型,如果不提供则自动检测
|
|
681
|
+
* @returns 环境配置对象
|
|
682
|
+
*/
|
|
683
|
+
declare function getEnvironmentConfig(env?: Environment): EnvironmentConfig;
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* SeaVerse Backend API Client 配置选项
|
|
687
|
+
*/
|
|
634
688
|
interface SeaVerseBackendAPIClientOptions {
|
|
689
|
+
/**
|
|
690
|
+
* API Base URL
|
|
691
|
+
* 如果提供,将覆盖 environment 配置
|
|
692
|
+
* @example 'https://api.seaverse.com'
|
|
693
|
+
*/
|
|
635
694
|
baseURL?: string;
|
|
695
|
+
/**
|
|
696
|
+
* 环境类型
|
|
697
|
+
* 如果不提供 baseURL,将使用此环境的预设配置
|
|
698
|
+
* 如果也不提供此参数,将自动检测当前环境
|
|
699
|
+
* @example 'production' | 'staging' | 'development' | 'local'
|
|
700
|
+
*/
|
|
701
|
+
environment?: Environment;
|
|
702
|
+
/**
|
|
703
|
+
* 请求超时时间(毫秒)
|
|
704
|
+
*/
|
|
636
705
|
timeout?: number;
|
|
706
|
+
/**
|
|
707
|
+
* 自定义请求头
|
|
708
|
+
*/
|
|
637
709
|
headers?: Record<string, string>;
|
|
710
|
+
/**
|
|
711
|
+
* 认证提供者
|
|
712
|
+
*/
|
|
638
713
|
auth?: AuthProvider;
|
|
714
|
+
/**
|
|
715
|
+
* Hook 配置
|
|
716
|
+
*/
|
|
639
717
|
hooks?: HookManagerOptions;
|
|
640
718
|
}
|
|
641
719
|
/**
|
|
642
720
|
* SeaVerse Backend API Client
|
|
643
721
|
* SeaVerse Dispatcher API - 云原生 AI Agent 平台的统一网关服务
|
|
722
|
+
*
|
|
644
723
|
* @version 2.0.0
|
|
724
|
+
*
|
|
725
|
+
* @example
|
|
726
|
+
* // 方式 1: 自动检测环境(推荐本地开发)
|
|
727
|
+
* const client = new SeaVerseBackendAPIClient();
|
|
728
|
+
*
|
|
729
|
+
* @example
|
|
730
|
+
* // 方式 2: 指定环境(推荐生产部署)
|
|
731
|
+
* const client = new SeaVerseBackendAPIClient({
|
|
732
|
+
* environment: 'production',
|
|
733
|
+
* });
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* // 方式 3: 自定义 URL(特殊需求)
|
|
737
|
+
* const client = new SeaVerseBackendAPIClient({
|
|
738
|
+
* baseURL: 'https://custom-api.example.com',
|
|
739
|
+
* });
|
|
645
740
|
*/
|
|
646
741
|
declare class SeaVerseBackendAPIClient {
|
|
647
742
|
private httpClient;
|
|
@@ -899,5 +994,5 @@ declare class AuthModal {
|
|
|
899
994
|
*/
|
|
900
995
|
declare function createAuthModal(options: AuthModalOptions): AuthModal;
|
|
901
996
|
|
|
902
|
-
export { AuthFactory, AuthModal, AuthProvider, BuiltInHooks, SeaVerseBackendAPIClient, createAuthModal, models };
|
|
903
|
-
export type { ApiError, ApiServiceTokenResponse, AuthModalOptions, AuthModalResult, CodeToTokenRequest, CodeToTokenResponse, Container, ContainerDetailResponse, ContainerListResponse, ContainerStatsResponse, ConversationStatus, CreateMarketplaceSkillRequest, CreateVideoShareRequest, CreateVideoShareResponse, ForgotPasswordRequest, ForkProjectRequest, ForkProjectResponse, HealthResponse, HubProject, HubProjectsListResponse, InviteApplication, InviteApplicationListResponse, InviteCodeBindRequest, InviteCodeGenerateResponse, InviteCodeVerifyResponse, LoginRequest, LoginResponse, MarketplaceSkill, MarketplaceSkillsListResponse, OAuthConfig, PublishProjectRequest, PublishSkillRequest, RegisterContainerRequest, RegisterContainerResponse, RegisterRequest, RegisterResponse, ResetPasswordRequest, SeaVerseBackendAPIClientOptions, SocialMediaLink, SocialMediaLinksResponse, SpeechTokenResponse, SubmitInviteApplicationRequest, SuccessResponse, TrackAppTypeRequest, User, UserInstalledSkill, UserInstalledSkillsListResponse, VideoDetails };
|
|
997
|
+
export { AuthFactory, AuthModal, AuthProvider, BuiltInHooks, ENVIRONMENT_CONFIGS, SeaVerseBackendAPIClient, createAuthModal, detectEnvironment, getEnvironmentConfig, models };
|
|
998
|
+
export type { ApiError, ApiServiceTokenResponse, AuthModalOptions, AuthModalResult, CodeToTokenRequest, CodeToTokenResponse, Container, ContainerDetailResponse, ContainerListResponse, ContainerStatsResponse, ConversationStatus, CreateMarketplaceSkillRequest, CreateVideoShareRequest, CreateVideoShareResponse, Environment, EnvironmentConfig, ForgotPasswordRequest, ForkProjectRequest, ForkProjectResponse, HealthResponse, HubProject, HubProjectsListResponse, InviteApplication, InviteApplicationListResponse, InviteCodeBindRequest, InviteCodeGenerateResponse, InviteCodeVerifyResponse, LoginRequest, LoginResponse, MarketplaceSkill, MarketplaceSkillsListResponse, OAuthConfig, PublishProjectRequest, PublishSkillRequest, RegisterContainerRequest, RegisterContainerResponse, RegisterRequest, RegisterResponse, ResetPasswordRequest, SeaVerseBackendAPIClientOptions, SocialMediaLink, SocialMediaLinksResponse, SpeechTokenResponse, SubmitInviteApplicationRequest, SuccessResponse, TrackAppTypeRequest, User, UserInstalledSkill, UserInstalledSkillsListResponse, VideoDetails };
|
package/dist/index.js
CHANGED
|
@@ -1003,6 +1003,112 @@ class AuthFactory {
|
|
|
1003
1003
|
}
|
|
1004
1004
|
}
|
|
1005
1005
|
|
|
1006
|
+
/**
|
|
1007
|
+
* Environment Configuration for SeaVerse SDK
|
|
1008
|
+
* 环境配置模块 - 支持多环境部署
|
|
1009
|
+
*/
|
|
1010
|
+
/**
|
|
1011
|
+
* 预定义的环境配置
|
|
1012
|
+
*
|
|
1013
|
+
* 使用说明:
|
|
1014
|
+
* - production: 正式生产环境
|
|
1015
|
+
* - staging: 预发布环境(当前默认)
|
|
1016
|
+
* - development: 开发测试环境
|
|
1017
|
+
* - local: 本地开发环境
|
|
1018
|
+
*/
|
|
1019
|
+
const ENVIRONMENT_CONFIGS = {
|
|
1020
|
+
production: {
|
|
1021
|
+
name: 'production',
|
|
1022
|
+
baseURL: 'https://api.seaverse.com',
|
|
1023
|
+
wsURL: 'wss://api.seaverse.com',
|
|
1024
|
+
isProduction: true,
|
|
1025
|
+
},
|
|
1026
|
+
staging: {
|
|
1027
|
+
name: 'staging',
|
|
1028
|
+
baseURL: 'https://account-hub.sg.seaverse.dev',
|
|
1029
|
+
wsURL: 'wss://account-hub.sg.seaverse.dev',
|
|
1030
|
+
isProduction: false,
|
|
1031
|
+
},
|
|
1032
|
+
development: {
|
|
1033
|
+
name: 'development',
|
|
1034
|
+
baseURL: 'https://api-dev.seaverse.dev',
|
|
1035
|
+
wsURL: 'wss://api-dev.seaverse.dev',
|
|
1036
|
+
isProduction: false,
|
|
1037
|
+
},
|
|
1038
|
+
local: {
|
|
1039
|
+
name: 'local',
|
|
1040
|
+
baseURL: 'http://localhost:8001',
|
|
1041
|
+
wsURL: 'ws://localhost:8000',
|
|
1042
|
+
isProduction: false,
|
|
1043
|
+
},
|
|
1044
|
+
};
|
|
1045
|
+
/**
|
|
1046
|
+
* 根据当前运行环境自动检测应该使用的环境配置
|
|
1047
|
+
*
|
|
1048
|
+
* 检测规则:
|
|
1049
|
+
* 1. localhost/127.0.0.1 → local
|
|
1050
|
+
* 2. 包含 -dev 或 .dev → development
|
|
1051
|
+
* 3. 包含 staging → staging
|
|
1052
|
+
* 4. 其他 → production (默认)
|
|
1053
|
+
*
|
|
1054
|
+
* @returns 检测到的环境类型
|
|
1055
|
+
*/
|
|
1056
|
+
function detectEnvironment() {
|
|
1057
|
+
// Node.js 环境或非浏览器环境,默认返回 staging(安全起见)
|
|
1058
|
+
if (typeof window === 'undefined' || typeof window.location === 'undefined') {
|
|
1059
|
+
return 'staging';
|
|
1060
|
+
}
|
|
1061
|
+
const hostname = window.location.hostname.toLowerCase();
|
|
1062
|
+
// 本地开发环境
|
|
1063
|
+
if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '0.0.0.0') {
|
|
1064
|
+
return 'local';
|
|
1065
|
+
}
|
|
1066
|
+
// 开发环境 (包含 -dev 或 .dev)
|
|
1067
|
+
if (hostname.includes('-dev.') || hostname.includes('.dev') || hostname.endsWith('.dev')) {
|
|
1068
|
+
return 'development';
|
|
1069
|
+
}
|
|
1070
|
+
// Staging 环境
|
|
1071
|
+
if (hostname.includes('-staging.') || hostname.includes('staging.')) {
|
|
1072
|
+
return 'staging';
|
|
1073
|
+
}
|
|
1074
|
+
// 默认使用 production
|
|
1075
|
+
return 'production';
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* 获取环境配置
|
|
1079
|
+
*
|
|
1080
|
+
* @param env 环境类型,如果不提供则自动检测
|
|
1081
|
+
* @returns 环境配置对象
|
|
1082
|
+
*/
|
|
1083
|
+
function getEnvironmentConfig(env) {
|
|
1084
|
+
const targetEnv = env || detectEnvironment();
|
|
1085
|
+
return ENVIRONMENT_CONFIGS[targetEnv];
|
|
1086
|
+
}
|
|
1087
|
+
/**
|
|
1088
|
+
* 解析用户配置,返回最终的 baseURL
|
|
1089
|
+
*
|
|
1090
|
+
* 优先级:
|
|
1091
|
+
* 1. 显式传入的 baseURL(最高优先级)
|
|
1092
|
+
* 2. environment 参数指定的环境
|
|
1093
|
+
* 3. 自动检测环境(最低优先级)
|
|
1094
|
+
*
|
|
1095
|
+
* @param options 用户配置选项
|
|
1096
|
+
* @returns 最终使用的 baseURL
|
|
1097
|
+
*/
|
|
1098
|
+
function resolveBaseURL(options) {
|
|
1099
|
+
// 优先级 1: 显式传入的 baseURL
|
|
1100
|
+
if (options.baseURL) {
|
|
1101
|
+
return options.baseURL;
|
|
1102
|
+
}
|
|
1103
|
+
// 优先级 2: environment 参数
|
|
1104
|
+
if (options.environment) {
|
|
1105
|
+
return ENVIRONMENT_CONFIGS[options.environment].baseURL;
|
|
1106
|
+
}
|
|
1107
|
+
// 优先级 3: 自动检测
|
|
1108
|
+
const detectedEnv = detectEnvironment();
|
|
1109
|
+
return ENVIRONMENT_CONFIGS[detectedEnv].baseURL;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1006
1112
|
/**
|
|
1007
1113
|
* Type definitions for SeaVerse Dispatcher API
|
|
1008
1114
|
* Generated from auth.yaml OpenAPI specification
|
|
@@ -1015,12 +1121,37 @@ var models = /*#__PURE__*/Object.freeze({
|
|
|
1015
1121
|
/**
|
|
1016
1122
|
* SeaVerse Backend API Client
|
|
1017
1123
|
* SeaVerse Dispatcher API - 云原生 AI Agent 平台的统一网关服务
|
|
1124
|
+
*
|
|
1018
1125
|
* @version 2.0.0
|
|
1126
|
+
*
|
|
1127
|
+
* @example
|
|
1128
|
+
* // 方式 1: 自动检测环境(推荐本地开发)
|
|
1129
|
+
* const client = new SeaVerseBackendAPIClient();
|
|
1130
|
+
*
|
|
1131
|
+
* @example
|
|
1132
|
+
* // 方式 2: 指定环境(推荐生产部署)
|
|
1133
|
+
* const client = new SeaVerseBackendAPIClient({
|
|
1134
|
+
* environment: 'production',
|
|
1135
|
+
* });
|
|
1136
|
+
*
|
|
1137
|
+
* @example
|
|
1138
|
+
* // 方式 3: 自定义 URL(特殊需求)
|
|
1139
|
+
* const client = new SeaVerseBackendAPIClient({
|
|
1140
|
+
* baseURL: 'https://custom-api.example.com',
|
|
1141
|
+
* });
|
|
1019
1142
|
*/
|
|
1020
1143
|
class SeaVerseBackendAPIClient {
|
|
1021
1144
|
constructor(options = {}) {
|
|
1145
|
+
// 使用智能配置解析,支持三种优先级:
|
|
1146
|
+
// 1. 显式 baseURL(最高)
|
|
1147
|
+
// 2. environment 参数
|
|
1148
|
+
// 3. 自动检测(默认)
|
|
1149
|
+
const finalBaseURL = resolveBaseURL({
|
|
1150
|
+
baseURL: options.baseURL,
|
|
1151
|
+
environment: options.environment,
|
|
1152
|
+
});
|
|
1022
1153
|
const httpOptions = {
|
|
1023
|
-
baseURL:
|
|
1154
|
+
baseURL: finalBaseURL,
|
|
1024
1155
|
timeout: options.timeout,
|
|
1025
1156
|
headers: options.headers,
|
|
1026
1157
|
auth: options.auth || this.getDefaultAuth(),
|
|
@@ -2399,5 +2530,5 @@ function createAuthModal(options) {
|
|
|
2399
2530
|
return new AuthModal(options);
|
|
2400
2531
|
}
|
|
2401
2532
|
|
|
2402
|
-
export { AuthFactory, AuthModal, AuthProvider, BuiltInHooks, SeaVerseBackendAPIClient, createAuthModal, models };
|
|
2533
|
+
export { AuthFactory, AuthModal, AuthProvider, BuiltInHooks, ENVIRONMENT_CONFIGS, SeaVerseBackendAPIClient, createAuthModal, detectEnvironment, getEnvironmentConfig, models };
|
|
2403
2534
|
//# sourceMappingURL=index.js.map
|