credix
Version:
Official SDK for Credix Credit Management System
85 lines • 1.95 kB
TypeScript
/**
* APIキータイプ
*/
export type ApiKeyType = 'live' | 'test';
/**
* APIキー情報
*/
export interface ApiKeyInfo {
type: ApiKeyType;
projectId: string;
isValid: boolean;
prefix: string;
createdAt?: string;
}
/**
* 認証設定
*/
export interface AuthConfig {
apiKey: string;
secretKey: string;
}
/**
* 認証ユーティリティクラス
*/
export declare class AuthManager {
private apiKey;
private secretKey;
constructor(config: AuthConfig);
/**
* APIキーとシークレットキーを検証
*/
private validateKeys;
/**
* APIキーから環境タイプを抽出
*/
private extractKeyType;
/**
* APIキー情報を取得
*/
getKeyInfo(): ApiKeyInfo;
/**
* 認証ヘッダーを生成
*/
getAuthHeaders(): Record<string, string>;
/**
* テスト環境かどうかを判定
*/
isTestMode(): boolean;
/**
* 本番環境かどうかを判定
*/
isLiveMode(): boolean;
/**
* APIキーを再生成(サーバーサイドのみ)
*/
static generateApiKey(): string;
/**
* シークレットキーを再生成(サーバーサイドのみ)
* 64文字の完全ランダム文字列を生成
*/
static generateSecretKey(): string;
/**
* キーペアを生成(サーバーサイドのみ)
*/
static generateKeyPair(): {
apiKey: string;
secretKey: string;
};
/**
* キーをマスク(表示用)
*/
static maskKey(_key: string): string;
/**
* キーの有効期限をチェック(将来の拡張用)
*/
checkKeyExpiration(): {
isExpired: boolean;
expiresAt?: string;
};
/**
* キーのローテーション推奨をチェック
*/
shouldRotateKeys(lastRotatedAt?: Date): boolean;
}
//# sourceMappingURL=auth.d.ts.map