mirror of
https://github.com/kou029w/websri.git
synced 2025-02-22 16:55:58 +00:00
change IIntegrityMetadata
interface to IntegrityMetadataLike
type
This commit is contained in:
parent
beff4e49d5
commit
b8f8c3d209
1 changed files with 7 additions and 7 deletions
14
src/index.ts
14
src/index.ts
|
@ -30,15 +30,15 @@ export const IntegrityMetadataRegex =
|
|||
|
||||
export const SeparatorRegex = /[^\x21-\x7e]+/;
|
||||
|
||||
/** Integrity Metadata */
|
||||
export interface IIntegrityMetadata {
|
||||
/** Integrity Metadata Like */
|
||||
export type IntegrityMetadataLike = {
|
||||
alg: PrioritizedHashAlgorithm;
|
||||
val: string;
|
||||
opt?: string[];
|
||||
}
|
||||
};
|
||||
|
||||
/** Integrity Metadata */
|
||||
export class IntegrityMetadata implements IIntegrityMetadata {
|
||||
export class IntegrityMetadata implements IntegrityMetadataLike {
|
||||
alg: PrioritizedHashAlgorithm;
|
||||
val: string;
|
||||
opt: string[];
|
||||
|
@ -57,7 +57,7 @@ export class IntegrityMetadata implements IIntegrityMetadata {
|
|||
});
|
||||
}
|
||||
|
||||
match({ alg, val }: IIntegrityMetadata): boolean {
|
||||
match({ alg, val }: IntegrityMetadataLike): boolean {
|
||||
return alg === this.alg && val === this.val;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ export class IntegrityMetadata implements IIntegrityMetadata {
|
|||
return this.toString();
|
||||
}
|
||||
|
||||
static stringify({ alg, val, opt = [] }: IIntegrityMetadata): string {
|
||||
static stringify({ alg, val, opt = [] }: IntegrityMetadataLike): string {
|
||||
if (!alg) return "";
|
||||
if (!val) return "";
|
||||
if (!(alg in supportedHashAlgorithms)) return "";
|
||||
|
@ -147,7 +147,7 @@ export class IntegrityMetadataSet extends Map<
|
|||
return this.get(hashAlgorithm) ?? new IntegrityMetadata("");
|
||||
}
|
||||
|
||||
match(integrityMetadata: IIntegrityMetadata): boolean {
|
||||
match(integrityMetadata: IntegrityMetadataLike): boolean {
|
||||
return this.strongest.match(integrityMetadata);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue