url-sanitizer 5.2.0 → 5.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types/index.d.ts CHANGED
@@ -6,10 +6,30 @@
6
6
  * @see {@link https://github.com/asamuzaK/urlSanitizer/blob/main/LICENSE}
7
7
  */
8
8
  import { URLSanitizer } from './mjs/sanitize.js';
9
- export type InspectedURLResult = import('./mjs/sanitize.js').InspectedURLResult;
10
- export { URLSanitizer };
11
- declare const sanitizer: URLSanitizer;
12
- export declare const sanitizeURL: (url: string, opt?: {
9
+ export type InspectedDataURL = {
10
+ base64: boolean;
11
+ data: string;
12
+ mime: string;
13
+ };
14
+ export type InspectedURLResult = {
15
+ input: string;
16
+ valid: boolean;
17
+ href: string | null;
18
+ relative?: boolean;
19
+ reason?: string;
20
+ data?: InspectedDataURL | null;
21
+ origin?: string;
22
+ protocol?: string;
23
+ username?: string;
24
+ password?: string;
25
+ host?: string;
26
+ hostname?: string;
27
+ port?: string;
28
+ pathname?: string;
29
+ search?: string;
30
+ hash?: string;
31
+ };
32
+ export type SanitizeOptions = {
13
33
  allow?: string[];
14
34
  deny?: string[];
15
35
  only?: string[];
@@ -18,16 +38,11 @@ export declare const sanitizeURL: (url: string, opt?: {
18
38
  revokeObjectURL?: boolean;
19
39
  maxBlobSize?: number;
20
40
  maxLength?: number;
21
- }) => Promise<string | null>;
22
- export declare const sanitizeURLSync: (url: string, opt?: {
23
- allow?: string[];
24
- deny?: string[];
25
- only?: string[];
26
- allowRelative?: boolean;
27
- debug?: boolean;
28
- revokeObjectURL?: boolean;
29
- maxLength?: number;
30
- }) => string | null;
41
+ };
42
+ export { URLSanitizer };
43
+ declare const sanitizer: URLSanitizer;
44
+ export declare const sanitizeURL: (url: string, opt?: SanitizeOptions) => Promise<string | null>;
45
+ export declare const sanitizeURLSync: (url: string, opt?: SanitizeOptions) => string | null;
31
46
  export declare const inspectURL: (url: string) => Promise<InspectedURLResult>;
32
47
  export declare const isValidURI: (uri: string) => boolean;
33
48
  export declare const isURISync: (uri: string) => boolean;
@@ -9,3 +9,4 @@ export declare const TRUNCATE_LENGTH: number;
9
9
  export declare const TYPE_FROM: number;
10
10
  export declare const TYPE_TO: number;
11
11
  export declare const DUMMY_BASE: string;
12
+ export declare const DEFAULT_OPTS: import('./sanitize.js').InternalSanitizeOptions;
@@ -1,14 +1,18 @@
1
+ export type DOMPurify = import('dompurify').DOMPurify;
2
+ export type InspectedDataURL = import('../index.js').InspectedDataURL;
3
+ export type InspectedURLResult = import('../index.js').InspectedURLResult;
4
+ export type SanitizeOptions = import('../index.js').SanitizeOptions;
5
+ export type InternalSanitizeOptions = import('./sanitize.js').InternalSanitizeOptions;
1
6
  export declare class SanitizeContext {
2
7
  #private;
3
- domPurify: object;
8
+ domPurify: import("dompurify").DOMPurify;
4
9
  nest: number;
5
10
  recurse: Set<any>;
6
11
  restrictScheme: boolean;
7
12
  schemeMap: Map<string, boolean>;
8
13
  allowRelative: boolean | undefined;
9
14
  debug: boolean | undefined;
10
- schemes: Set<any> | undefined;
11
- constructor(opt: object, domPurifyInstance: object);
15
+ constructor(domPurifyInstance: DOMPurify, opt?: InternalSanitizeOptions);
12
16
  private #compileRules;
13
17
  private #registerScheme;
14
18
  enter(url: string): boolean;
@@ -16,13 +20,13 @@ export declare class SanitizeContext {
16
20
  }
17
21
  export declare class SanitizeFilter {
18
22
  #private;
19
- constructor(options: object);
23
+ constructor(opt?: InternalSanitizeOptions);
20
24
  private #process;
21
25
  private #sanitizeDataURL;
22
26
  private #purify;
23
27
  private #handleSanitizeAttribute;
24
28
  private #sanitizeStandardURL;
25
- sanitize(url: string, options?: object): string | null;
26
- sanitizeBuffer(buffer: ArrayBuffer, mimeType: string, options?: object): Promise<string | null>;
27
- sanitizeDataURL(url: string, options?: object): Promise<string | null>;
29
+ sanitize(url: string, opt?: InternalSanitizeOptions): string | null;
30
+ sanitizeBuffer(buffer: ArrayBuffer, mimeType: string, opt?: InternalSanitizeOptions): Promise<string | null>;
31
+ sanitizeDataURL(url: string, opt?: InternalSanitizeOptions): Promise<string | null>;
28
32
  }
@@ -1,26 +1,9 @@
1
1
  import { URISchemes } from './scheme.js';
2
- export type InspectedDataURL = {
3
- base64: boolean;
4
- data: string;
5
- mime: string;
6
- };
7
- export type InspectedURLResult = {
8
- input: string;
9
- valid: boolean;
10
- href: string | null;
11
- relative?: boolean;
12
- reason?: string;
13
- data?: InspectedDataURL | null;
14
- origin?: string;
15
- protocol?: string;
16
- username?: string;
17
- password?: string;
18
- host?: string;
19
- hostname?: string;
20
- port?: string;
21
- pathname?: string;
22
- search?: string;
23
- hash?: string;
2
+ export type InspectedDataURL = import('../index.js').InspectedDataURL;
3
+ export type InspectedURLResult = import('../index.js').InspectedURLResult;
4
+ export type SanitizeOptions = import('../index.js').SanitizeOptions;
5
+ export type InternalSanitizeOptions = SanitizeOptions & {
6
+ schemes?: Set<string>;
24
7
  };
25
8
  export declare class URLSanitizer extends URISchemes {
26
9
  #private;
@@ -33,25 +16,8 @@ export declare class URLSanitizer extends URISchemes {
33
16
  add(scheme: string): string[];
34
17
  remove(scheme: string): boolean;
35
18
  reset(): void;
36
- sanitizeURL(url: string, opt?: {
37
- allow?: string[];
38
- deny?: string[];
39
- only?: string[];
40
- allowRelative?: boolean;
41
- debug?: boolean;
42
- revokeObjectURL?: boolean;
43
- maxBlobSize?: number;
44
- maxLength?: number;
45
- }): Promise<string | null>;
46
- sanitizeURLSync(url: string, opt?: {
47
- allow?: string[];
48
- deny?: string[];
49
- only?: string[];
50
- allowRelative?: boolean;
51
- debug?: boolean;
52
- revokeObjectURL?: boolean;
53
- maxLength?: number;
54
- }): string | null;
19
+ sanitizeURL(url: string, opt?: SanitizeOptions): Promise<string | null>;
20
+ sanitizeURLSync(url: string, opt?: SanitizeOptions): string | null;
55
21
  inspectURL(url: string): Promise<InspectedURLResult>;
56
22
  isValidURI(uri: string): boolean;
57
23
  }