-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
32 lines (26 loc) · 748 Bytes
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
export interface CSPParserResult {
[key: string]: Source[]
}
export type Source = HashSource | HostSource | KeywordSource | NonceSource | SchemeSource;
export interface HashSource extends BaseSource<"hash"> {
algorithm: string
}
export type HostSource = BaseSource<"host">;
export type KeywordSource = BaseSource<"keyword">;
export type NonceSource = BaseSource<"nonce">;
export type SchemeSource = BaseSource<"scheme">;
export interface BaseSource<T extends string> {
type: T,
value: string
}
export function parse(
payload: string,
parser?: (payload: string) => CSPParserResult
): CSPParserResult {
return {} as CSPParserResult;
}
export function serialize(
csp: CSPParserResult,
): string {
return "";
}