@volcengine/avatar-web-sdk
Advanced tools
+36
-9
@@ -8,4 +8,12 @@ import { AvatarSDKConfig, AvatarSessionConfig } from "../types"; | ||
| * @note Best practice: Create one instance per application process lifecycle and use it as a singleton. | ||
| * @warning Structural config (appKey, environment, etc.) is immutable after initialization. | ||
| * Tokens (stsToken, wssToken) can be updated via updateStsToken/updateWssToken methods. | ||
| * @warning Most config properties are immutable after initialization. | ||
| * Only authentication credentials can be updated via dedicated methods. | ||
| * | ||
| * SDK supports three authentication methods: | ||
| * 1. Permanent AK/SK: Set appKey and secretKey only. No refresh needed. | ||
| * 2. Temporary AK/SK + STS: Set appKey, secretKey, and stsToken. | ||
| * All three need to be refreshed together via updateTempAKSK(). | ||
| * 3. WSS Token: Set wssToken only. Refresh via updateWssToken(). | ||
| * | ||
| * Authentication priority: AK/SK > WSS Token | ||
| */ | ||
@@ -17,2 +25,4 @@ export declare class AvatarSDK { | ||
| private _config; | ||
| private _appKey; | ||
| private _secretKey; | ||
| private _stsToken; | ||
@@ -25,2 +35,14 @@ private _wssToken; | ||
| * @throws Error if no valid authentication method is provided | ||
| * | ||
| * @note Best practice: Create one instance per application process lifecycle and use it as a singleton. | ||
| * @warning Most config properties are immutable after initialization. | ||
| * Only authentication credentials can be updated via dedicated methods. | ||
| * | ||
| * SDK supports three authentication methods: | ||
| * 1. Permanent AK/SK: Set appKey and secretKey only. No refresh needed. | ||
| * 2. Temporary AK/SK + STS: Set appKey, secretKey, and stsToken. | ||
| * All three need to be refreshed together via updateTempAKSK(). | ||
| * 3. WSS Token: Set wssToken only. Refresh via updateWssToken(). | ||
| * | ||
| * Authentication priority: AK/SK > WSS Token | ||
| */ | ||
@@ -33,11 +55,16 @@ constructor(config: AvatarSDKConfig); | ||
| /** | ||
| * Update STS Token | ||
| * @param stsToken - New STS Token, pass null to clear | ||
| * @note Updated token takes effect on next connection, does not affect current connection | ||
| * Update temporary AK/SK credentials along with STS Token. | ||
| * Use this method when your AK/SK credentials are temporary and need to be refreshed together with STS Token. | ||
| * @param appKey - The new App Key for temporary AK/SK authentication | ||
| * @param secretKey - The new Secret Key for temporary AK/SK authentication | ||
| * @param stsToken - The new STS Token for temporary AK/SK authentication | ||
| * @note The updated credentials will take effect on the next connection attempt. | ||
| * @note This method is for temporary AK/SK scenarios. For permanent AK/SK, no refresh is needed. | ||
| */ | ||
| updateStsToken(stsToken: string | null): void; | ||
| updateTempAKSK(appKey: string | null, secretKey: string | null, stsToken: string | null): void; | ||
| /** | ||
| * Update WSS Token | ||
| * @param wssToken - New WSS Token, pass null to clear | ||
| * @note Updated token takes effect on next connection, does not affect current connection | ||
| * Update WSS Token for WebSocket authentication. | ||
| * Use this method when using WSS Token authentication (without AK/SK). | ||
| * @param wssToken - The new WSS token. Pass null to clear. | ||
| * @note The updated token will take effect on the next connection attempt. | ||
| */ | ||
@@ -44,0 +71,0 @@ updateWssToken(wssToken: string | null): void; |
+1
-1
| { | ||
| "name": "@volcengine/avatar-web-sdk", | ||
| "version": "1.0.1-beta.4", | ||
| "version": "1.0.1-beta.5", | ||
| "type": "module", | ||
@@ -5,0 +5,0 @@ "main": "./avatar-web-sdk.es.js", |
+30
-4
@@ -13,11 +13,37 @@ export * from "./errors"; | ||
| * AvatarSDK configuration interface | ||
| * | ||
| * SDK supports three authentication methods: | ||
| * 1. Permanent AK/SK: Set appKey and secretKey only. No refresh needed. | ||
| * 2. Temporary AK/SK + STS: Set appKey, secretKey, and stsToken. | ||
| * All three need to be refreshed together via updateTempAKSK(). | ||
| * 3. WSS Token: Set wssToken only. Refresh via updateWssToken(). | ||
| * | ||
| * Authentication priority: AK/SK > WSS Token | ||
| * | ||
| * @note Structural config properties (environment, logEnabled, etc.) are immutable after initialization. | ||
| * Only authentication credentials can be updated via dedicated methods. | ||
| */ | ||
| export interface AvatarSDKConfig { | ||
| /** App Key (Optional, required for AK/SK authentication) */ | ||
| /** | ||
| * App Key (Optional, required for AK/SK authentication) | ||
| * Use with secretKey for permanent or temporary AK/SK authentication. | ||
| */ | ||
| appKey?: string; | ||
| /** Secret Key (Optional, required for AK/SK authentication) */ | ||
| /** | ||
| * Secret Key (Optional, required for AK/SK authentication) | ||
| * Use with appKey for permanent or temporary AK/SK authentication. | ||
| */ | ||
| secretKey?: string; | ||
| /** STS Token (Optional) */ | ||
| /** | ||
| * STS Token (Optional) | ||
| * Required for temporary AK/SK + STS authentication. | ||
| * Must be used together with appKey and secretKey. | ||
| * Refresh all three via updateTempAKSK(). | ||
| */ | ||
| stsToken?: string | null; | ||
| /** WSS Token (Optional) */ | ||
| /** | ||
| * WSS Token (Optional) | ||
| * Use for WSS Token authentication (without AK/SK). | ||
| * Refresh via updateWssToken(). | ||
| */ | ||
| wssToken?: string | null; | ||
@@ -24,0 +50,0 @@ /** Enable logging (Optional), default is true */ |
Sorry, the diff of this file is too big to display
1617983
0.25%22516
0.33%