11import config from "./data/config" ;
22import Logger from "./utils/logger" ;
3- import { SecType , ClientSession , HashName } from "./types/secure" ;
3+ import { SecType , ClientSession , HashName , SecYaHeaders } from "./types/secure" ;
44
55const { componentVersion } = config ;
66
@@ -38,12 +38,12 @@ export async function getSignature(body: Uint8Array) {
3838 ) ;
3939}
4040
41- export async function getSecYaHeaders (
42- secType : SecType ,
41+ export async function getSecYaHeaders < T extends SecType > (
42+ secType : T ,
4343 session : ClientSession ,
4444 body : Uint8Array ,
4545 path : string ,
46- ) {
46+ ) : Promise < SecYaHeaders < T > > {
4747 const { secretKey, uuid } = session ;
4848 const sign = await getSignature ( body ) ;
4949
@@ -56,7 +56,7 @@ export async function getSecYaHeaders(
5656 [ `${ secType } -Signature` ] : sign ,
5757 [ `Sec-${ secType } -Sk` ] : secretKey ,
5858 [ `Sec-${ secType } -Token` ] : `${ tokenSign } :${ token } ` ,
59- } ;
59+ } as SecYaHeaders < T > ;
6060}
6161
6262// yandex uuid
@@ -87,4 +87,4 @@ export const browserSecHeaders = {
8787 "sec-ch-ua" : `"Chromium";v="130", "YaBrowser";v="${ componentVersion . slice ( 0 , 5 ) } ", "Not?A_Brand";v="99", "Yowser";v="2.5"` ,
8888 "sec-ch-ua-full-version-list" : `"Chromium";v="130.0.6723.152", "YaBrowser";v="${ componentVersion } ", "Not?A_Brand";v="99.0.0.0", "Yowser";v="2.5"` ,
8989 "Sec-Fetch-Mode" : "no-cors" ,
90- } ;
90+ } as const ;
0 commit comments