@bquery/bquery 1.5.0 → 1.6.0
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/README.md +586 -546
- package/dist/component/component.d.ts +13 -5
- package/dist/component/component.d.ts.map +1 -1
- package/dist/component/html.d.ts +40 -3
- package/dist/component/html.d.ts.map +1 -1
- package/dist/component/index.d.ts +2 -2
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/library.d.ts.map +1 -1
- package/dist/component/types.d.ts +131 -16
- package/dist/component/types.d.ts.map +1 -1
- package/dist/component-BEQgt5hl.js +600 -0
- package/dist/component-BEQgt5hl.js.map +1 -0
- package/dist/component.es.mjs +7 -6
- package/dist/config-DRmZZno3.js.map +1 -1
- package/dist/core-BGQJVw0-.js +35 -0
- package/dist/core-BGQJVw0-.js.map +1 -0
- package/dist/{core-CK2Mfpf4.js → core-CCEabVHl.js} +2 -2
- package/dist/{core-CK2Mfpf4.js.map → core-CCEabVHl.js.map} +1 -1
- package/dist/core.es.mjs +1 -1
- package/dist/effect-AFRW_Plg.js +84 -0
- package/dist/effect-AFRW_Plg.js.map +1 -0
- package/dist/full.d.ts +4 -4
- package/dist/full.d.ts.map +1 -1
- package/dist/full.es.mjs +98 -94
- package/dist/full.iife.js +14 -14
- package/dist/full.iife.js.map +1 -1
- package/dist/full.umd.js +14 -14
- package/dist/full.umd.js.map +1 -1
- package/dist/index.es.mjs +143 -139
- package/dist/{motion-C5DRdPnO.js → motion-D9TcHxOF.js} +1 -1
- package/dist/{motion-C5DRdPnO.js.map → motion-D9TcHxOF.js.map} +1 -1
- package/dist/motion.es.mjs +1 -1
- package/dist/{platform-B7JhGBc7.js → platform-Dr9b6fsq.js} +21 -20
- package/dist/platform-Dr9b6fsq.js.map +1 -0
- package/dist/platform.es.mjs +1 -1
- package/dist/{reactive-BDya-ia8.js → reactive-DSkct0dO.js} +51 -50
- package/dist/reactive-DSkct0dO.js.map +1 -0
- package/dist/reactive.es.mjs +19 -17
- package/dist/{router-CijiICxt.js → router-CbDhl8rS.js} +3 -3
- package/dist/{router-CijiICxt.js.map → router-CbDhl8rS.js.map} +1 -1
- package/dist/router.es.mjs +1 -1
- package/dist/{sanitize-jyJ2ryE2.js → sanitize-Bs2dkMby.js} +94 -83
- package/dist/sanitize-Bs2dkMby.js.map +1 -0
- package/dist/security/index.d.ts +4 -2
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/sanitize.d.ts +4 -1
- package/dist/security/sanitize.d.ts.map +1 -1
- package/dist/security/trusted-html.d.ts +53 -0
- package/dist/security/trusted-html.d.ts.map +1 -0
- package/dist/security.es.mjs +10 -9
- package/dist/store/define-store.d.ts +1 -1
- package/dist/store/define-store.d.ts.map +1 -1
- package/dist/store/mapping.d.ts +1 -1
- package/dist/store/mapping.d.ts.map +1 -1
- package/dist/store/persisted.d.ts +1 -1
- package/dist/store/persisted.d.ts.map +1 -1
- package/dist/store/types.d.ts +2 -2
- package/dist/store/types.d.ts.map +1 -1
- package/dist/store/watch.d.ts +1 -1
- package/dist/store/watch.d.ts.map +1 -1
- package/dist/{store-CPK9E62U.js → store-BwDvI45q.js} +49 -48
- package/dist/{store-CPK9E62U.js.map → store-BwDvI45q.js.map} +1 -1
- package/dist/store.es.mjs +1 -1
- package/dist/storybook/index.d.ts +37 -0
- package/dist/storybook/index.d.ts.map +1 -0
- package/dist/storybook.es.mjs +151 -0
- package/dist/storybook.es.mjs.map +1 -0
- package/dist/untrack-B0rVscTc.js +7 -0
- package/dist/untrack-B0rVscTc.js.map +1 -0
- package/dist/{view-Cdi0g-qo.js → view-C70lA3vf.js} +29 -28
- package/dist/{view-Cdi0g-qo.js.map → view-C70lA3vf.js.map} +1 -1
- package/dist/view.es.mjs +9 -8
- package/package.json +141 -136
- package/src/component/component.ts +259 -54
- package/src/component/html.ts +153 -53
- package/src/component/index.ts +10 -2
- package/src/component/library.ts +42 -28
- package/src/component/types.ts +184 -19
- package/src/full.ts +8 -2
- package/src/motion/transition.ts +97 -97
- package/src/motion/types.ts +208 -208
- package/src/platform/announcer.ts +208 -208
- package/src/platform/config.ts +163 -163
- package/src/platform/cookies.ts +165 -165
- package/src/platform/index.ts +39 -39
- package/src/platform/meta.ts +168 -168
- package/src/reactive/async-data.ts +486 -486
- package/src/reactive/index.ts +37 -37
- package/src/reactive/signal.ts +29 -29
- package/src/security/constants.ts +211 -211
- package/src/security/index.ts +17 -10
- package/src/security/sanitize.ts +70 -66
- package/src/security/trusted-html.ts +71 -0
- package/src/store/define-store.ts +49 -48
- package/src/store/mapping.ts +74 -73
- package/src/store/persisted.ts +62 -61
- package/src/store/types.ts +92 -94
- package/src/store/watch.ts +53 -52
- package/src/storybook/index.ts +479 -0
- package/dist/component-CY5MVoYN.js +0 -531
- package/dist/component-CY5MVoYN.js.map +0 -1
- package/dist/core-DPdbItcq.js +0 -112
- package/dist/core-DPdbItcq.js.map +0 -1
- package/dist/platform-B7JhGBc7.js.map +0 -1
- package/dist/reactive-BDya-ia8.js.map +0 -1
- package/dist/sanitize-jyJ2ryE2.js.map +0 -1
package/src/reactive/index.ts
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reactive module providing fine-grained reactivity primitives.
|
|
3
|
-
*
|
|
4
|
-
* @module bquery/reactive
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
Computed,
|
|
9
|
-
Signal,
|
|
10
|
-
batch,
|
|
11
|
-
computed,
|
|
12
|
-
createUseFetch,
|
|
13
|
-
effect,
|
|
14
|
-
isComputed,
|
|
15
|
-
isSignal,
|
|
16
|
-
linkedSignal,
|
|
17
|
-
persistedSignal,
|
|
18
|
-
readonly,
|
|
19
|
-
signal,
|
|
20
|
-
useAsyncData,
|
|
21
|
-
useFetch,
|
|
22
|
-
untrack,
|
|
23
|
-
watch,
|
|
24
|
-
} from './signal';
|
|
25
|
-
|
|
26
|
-
export type {
|
|
27
|
-
AsyncDataState,
|
|
28
|
-
AsyncDataStatus,
|
|
29
|
-
AsyncWatchSource,
|
|
30
|
-
CleanupFn,
|
|
31
|
-
FetchInput,
|
|
32
|
-
LinkedSignal,
|
|
33
|
-
Observer,
|
|
34
|
-
ReadonlySignal,
|
|
35
|
-
UseAsyncDataOptions,
|
|
36
|
-
UseFetchOptions,
|
|
37
|
-
} from './signal';
|
|
1
|
+
/**
|
|
2
|
+
* Reactive module providing fine-grained reactivity primitives.
|
|
3
|
+
*
|
|
4
|
+
* @module bquery/reactive
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
Computed,
|
|
9
|
+
Signal,
|
|
10
|
+
batch,
|
|
11
|
+
computed,
|
|
12
|
+
createUseFetch,
|
|
13
|
+
effect,
|
|
14
|
+
isComputed,
|
|
15
|
+
isSignal,
|
|
16
|
+
linkedSignal,
|
|
17
|
+
persistedSignal,
|
|
18
|
+
readonly,
|
|
19
|
+
signal,
|
|
20
|
+
useAsyncData,
|
|
21
|
+
useFetch,
|
|
22
|
+
untrack,
|
|
23
|
+
watch,
|
|
24
|
+
} from './signal';
|
|
25
|
+
|
|
26
|
+
export type {
|
|
27
|
+
AsyncDataState,
|
|
28
|
+
AsyncDataStatus,
|
|
29
|
+
AsyncWatchSource,
|
|
30
|
+
CleanupFn,
|
|
31
|
+
FetchInput,
|
|
32
|
+
LinkedSignal,
|
|
33
|
+
Observer,
|
|
34
|
+
ReadonlySignal,
|
|
35
|
+
UseAsyncDataOptions,
|
|
36
|
+
UseFetchOptions,
|
|
37
|
+
} from './signal';
|
package/src/reactive/signal.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reactive primitives inspired by fine-grained reactivity.
|
|
3
|
-
*
|
|
4
|
-
* @module bquery/reactive
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export { batch } from './batch';
|
|
8
|
-
export { createUseFetch, useAsyncData, useFetch } from './async-data';
|
|
9
|
-
export { Computed, computed } from './computed';
|
|
10
|
-
export { Signal, signal } from './core';
|
|
11
|
-
export { effect } from './effect';
|
|
12
|
-
export { linkedSignal } from './linked';
|
|
13
|
-
export { persistedSignal } from './persisted';
|
|
14
|
-
export { readonly } from './readonly';
|
|
15
|
-
export { isComputed, isSignal } from './type-guards';
|
|
16
|
-
export { untrack } from './untrack';
|
|
17
|
-
export { watch } from './watch';
|
|
18
|
-
|
|
19
|
-
export type { CleanupFn, Observer } from './internals';
|
|
20
|
-
export type {
|
|
21
|
-
AsyncDataState,
|
|
22
|
-
AsyncDataStatus,
|
|
23
|
-
AsyncWatchSource,
|
|
24
|
-
FetchInput,
|
|
25
|
-
UseAsyncDataOptions,
|
|
26
|
-
UseFetchOptions,
|
|
27
|
-
} from './async-data';
|
|
28
|
-
export type { LinkedSignal } from './linked';
|
|
29
|
-
export type { ReadonlySignal } from './readonly';
|
|
1
|
+
/**
|
|
2
|
+
* Reactive primitives inspired by fine-grained reactivity.
|
|
3
|
+
*
|
|
4
|
+
* @module bquery/reactive
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { batch } from './batch';
|
|
8
|
+
export { createUseFetch, useAsyncData, useFetch } from './async-data';
|
|
9
|
+
export { Computed, computed } from './computed';
|
|
10
|
+
export { Signal, signal } from './core';
|
|
11
|
+
export { effect } from './effect';
|
|
12
|
+
export { linkedSignal } from './linked';
|
|
13
|
+
export { persistedSignal } from './persisted';
|
|
14
|
+
export { readonly } from './readonly';
|
|
15
|
+
export { isComputed, isSignal } from './type-guards';
|
|
16
|
+
export { untrack } from './untrack';
|
|
17
|
+
export { watch } from './watch';
|
|
18
|
+
|
|
19
|
+
export type { CleanupFn, Observer } from './internals';
|
|
20
|
+
export type {
|
|
21
|
+
AsyncDataState,
|
|
22
|
+
AsyncDataStatus,
|
|
23
|
+
AsyncWatchSource,
|
|
24
|
+
FetchInput,
|
|
25
|
+
UseAsyncDataOptions,
|
|
26
|
+
UseFetchOptions,
|
|
27
|
+
} from './async-data';
|
|
28
|
+
export type { LinkedSignal } from './linked';
|
|
29
|
+
export type { ReadonlySignal } from './readonly';
|
|
@@ -1,211 +1,211 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Security constants and safe lists.
|
|
3
|
-
*
|
|
4
|
-
* @module bquery/security
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Trusted Types policy name.
|
|
9
|
-
*/
|
|
10
|
-
export const POLICY_NAME = 'bquery-sanitizer';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Default allowed HTML tags considered safe.
|
|
14
|
-
*/
|
|
15
|
-
export const DEFAULT_ALLOWED_TAGS = new Set([
|
|
16
|
-
'a',
|
|
17
|
-
'abbr',
|
|
18
|
-
'address',
|
|
19
|
-
'article',
|
|
20
|
-
'aside',
|
|
21
|
-
'b',
|
|
22
|
-
'bdi',
|
|
23
|
-
'bdo',
|
|
24
|
-
'blockquote',
|
|
25
|
-
'br',
|
|
26
|
-
'button',
|
|
27
|
-
'caption',
|
|
28
|
-
'cite',
|
|
29
|
-
'code',
|
|
30
|
-
'col',
|
|
31
|
-
'colgroup',
|
|
32
|
-
'data',
|
|
33
|
-
'dd',
|
|
34
|
-
'del',
|
|
35
|
-
'details',
|
|
36
|
-
'dfn',
|
|
37
|
-
'div',
|
|
38
|
-
'dl',
|
|
39
|
-
'dt',
|
|
40
|
-
'em',
|
|
41
|
-
'figcaption',
|
|
42
|
-
'figure',
|
|
43
|
-
'footer',
|
|
44
|
-
'form',
|
|
45
|
-
'h1',
|
|
46
|
-
'h2',
|
|
47
|
-
'h3',
|
|
48
|
-
'h4',
|
|
49
|
-
'h5',
|
|
50
|
-
'h6',
|
|
51
|
-
'header',
|
|
52
|
-
'hgroup',
|
|
53
|
-
'hr',
|
|
54
|
-
'i',
|
|
55
|
-
'img',
|
|
56
|
-
'input',
|
|
57
|
-
'ins',
|
|
58
|
-
'kbd',
|
|
59
|
-
'label',
|
|
60
|
-
'legend',
|
|
61
|
-
'li',
|
|
62
|
-
'main',
|
|
63
|
-
'mark',
|
|
64
|
-
'nav',
|
|
65
|
-
'ol',
|
|
66
|
-
'optgroup',
|
|
67
|
-
'option',
|
|
68
|
-
'p',
|
|
69
|
-
'picture',
|
|
70
|
-
'pre',
|
|
71
|
-
'progress',
|
|
72
|
-
'q',
|
|
73
|
-
'rp',
|
|
74
|
-
'rt',
|
|
75
|
-
'ruby',
|
|
76
|
-
's',
|
|
77
|
-
'samp',
|
|
78
|
-
'section',
|
|
79
|
-
'select',
|
|
80
|
-
'small',
|
|
81
|
-
'source',
|
|
82
|
-
'span',
|
|
83
|
-
'strong',
|
|
84
|
-
'sub',
|
|
85
|
-
'summary',
|
|
86
|
-
'sup',
|
|
87
|
-
'table',
|
|
88
|
-
'tbody',
|
|
89
|
-
'td',
|
|
90
|
-
'textarea',
|
|
91
|
-
'tfoot',
|
|
92
|
-
'th',
|
|
93
|
-
'thead',
|
|
94
|
-
'time',
|
|
95
|
-
'tr',
|
|
96
|
-
'u',
|
|
97
|
-
'ul',
|
|
98
|
-
'var',
|
|
99
|
-
'wbr',
|
|
100
|
-
]);
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Explicitly dangerous tags that should never be allowed.
|
|
104
|
-
* These are checked even if somehow added to allowTags.
|
|
105
|
-
*/
|
|
106
|
-
export const DANGEROUS_TAGS = new Set([
|
|
107
|
-
'script',
|
|
108
|
-
'iframe',
|
|
109
|
-
'frame',
|
|
110
|
-
'frameset',
|
|
111
|
-
'object',
|
|
112
|
-
'embed',
|
|
113
|
-
'applet',
|
|
114
|
-
'link',
|
|
115
|
-
'meta',
|
|
116
|
-
'style',
|
|
117
|
-
'base',
|
|
118
|
-
'template',
|
|
119
|
-
// 'slot' is intentionally excluded here so component shadow markup can opt in
|
|
120
|
-
// via sanitizeHtml(..., { allowTags: ['slot'] }). It remains disallowed by default
|
|
121
|
-
// for general HTML writes, because DEFAULT_ALLOWED_TAGS does not include it.
|
|
122
|
-
'math',
|
|
123
|
-
'svg',
|
|
124
|
-
'foreignobject',
|
|
125
|
-
'noscript',
|
|
126
|
-
]);
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Reserved IDs that could cause DOM clobbering attacks.
|
|
130
|
-
* These are prevented to avoid overwriting global browser objects.
|
|
131
|
-
*/
|
|
132
|
-
export const RESERVED_IDS = new Set([
|
|
133
|
-
// Global objects
|
|
134
|
-
'document',
|
|
135
|
-
'window',
|
|
136
|
-
'location',
|
|
137
|
-
'top',
|
|
138
|
-
'self',
|
|
139
|
-
'parent',
|
|
140
|
-
'frames',
|
|
141
|
-
'history',
|
|
142
|
-
'navigator',
|
|
143
|
-
'screen',
|
|
144
|
-
// Dangerous functions
|
|
145
|
-
'alert',
|
|
146
|
-
'confirm',
|
|
147
|
-
'prompt',
|
|
148
|
-
'eval',
|
|
149
|
-
'function',
|
|
150
|
-
// Document properties
|
|
151
|
-
'cookie',
|
|
152
|
-
'domain',
|
|
153
|
-
'referrer',
|
|
154
|
-
'body',
|
|
155
|
-
'head',
|
|
156
|
-
'forms',
|
|
157
|
-
'images',
|
|
158
|
-
'links',
|
|
159
|
-
'scripts',
|
|
160
|
-
// DOM traversal properties
|
|
161
|
-
'children',
|
|
162
|
-
'parentnode',
|
|
163
|
-
'firstchild',
|
|
164
|
-
'lastchild',
|
|
165
|
-
// Content manipulation
|
|
166
|
-
'innerhtml',
|
|
167
|
-
'outerhtml',
|
|
168
|
-
'textcontent',
|
|
169
|
-
]);
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Default allowed attributes considered safe.
|
|
173
|
-
* Note: 'style' is excluded by default because inline CSS can be abused for:
|
|
174
|
-
* - UI redressing attacks
|
|
175
|
-
* - Data exfiltration via url() in CSS
|
|
176
|
-
* - CSS injection vectors
|
|
177
|
-
* If you need to allow inline styles, add 'style' to allowAttributes in your
|
|
178
|
-
* sanitizeHtml options, but ensure you implement proper CSS value validation.
|
|
179
|
-
*/
|
|
180
|
-
export const DEFAULT_ALLOWED_ATTRIBUTES = new Set([
|
|
181
|
-
'alt',
|
|
182
|
-
'class',
|
|
183
|
-
'dir',
|
|
184
|
-
'height',
|
|
185
|
-
'hidden',
|
|
186
|
-
'href',
|
|
187
|
-
'id',
|
|
188
|
-
'lang',
|
|
189
|
-
'loading',
|
|
190
|
-
'name',
|
|
191
|
-
'rel',
|
|
192
|
-
'role',
|
|
193
|
-
'src',
|
|
194
|
-
'srcset',
|
|
195
|
-
'tabindex',
|
|
196
|
-
'target',
|
|
197
|
-
'title',
|
|
198
|
-
'type',
|
|
199
|
-
'width',
|
|
200
|
-
'aria-*',
|
|
201
|
-
]);
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Dangerous attribute prefixes to always remove.
|
|
205
|
-
*/
|
|
206
|
-
export const DANGEROUS_ATTR_PREFIXES = ['on', 'formaction', 'xlink:', 'xmlns:'];
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Dangerous URL protocols to block.
|
|
210
|
-
*/
|
|
211
|
-
export const DANGEROUS_PROTOCOLS = ['javascript:', 'data:', 'vbscript:', 'file:'];
|
|
1
|
+
/**
|
|
2
|
+
* Security constants and safe lists.
|
|
3
|
+
*
|
|
4
|
+
* @module bquery/security
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Trusted Types policy name.
|
|
9
|
+
*/
|
|
10
|
+
export const POLICY_NAME = 'bquery-sanitizer';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Default allowed HTML tags considered safe.
|
|
14
|
+
*/
|
|
15
|
+
export const DEFAULT_ALLOWED_TAGS = new Set([
|
|
16
|
+
'a',
|
|
17
|
+
'abbr',
|
|
18
|
+
'address',
|
|
19
|
+
'article',
|
|
20
|
+
'aside',
|
|
21
|
+
'b',
|
|
22
|
+
'bdi',
|
|
23
|
+
'bdo',
|
|
24
|
+
'blockquote',
|
|
25
|
+
'br',
|
|
26
|
+
'button',
|
|
27
|
+
'caption',
|
|
28
|
+
'cite',
|
|
29
|
+
'code',
|
|
30
|
+
'col',
|
|
31
|
+
'colgroup',
|
|
32
|
+
'data',
|
|
33
|
+
'dd',
|
|
34
|
+
'del',
|
|
35
|
+
'details',
|
|
36
|
+
'dfn',
|
|
37
|
+
'div',
|
|
38
|
+
'dl',
|
|
39
|
+
'dt',
|
|
40
|
+
'em',
|
|
41
|
+
'figcaption',
|
|
42
|
+
'figure',
|
|
43
|
+
'footer',
|
|
44
|
+
'form',
|
|
45
|
+
'h1',
|
|
46
|
+
'h2',
|
|
47
|
+
'h3',
|
|
48
|
+
'h4',
|
|
49
|
+
'h5',
|
|
50
|
+
'h6',
|
|
51
|
+
'header',
|
|
52
|
+
'hgroup',
|
|
53
|
+
'hr',
|
|
54
|
+
'i',
|
|
55
|
+
'img',
|
|
56
|
+
'input',
|
|
57
|
+
'ins',
|
|
58
|
+
'kbd',
|
|
59
|
+
'label',
|
|
60
|
+
'legend',
|
|
61
|
+
'li',
|
|
62
|
+
'main',
|
|
63
|
+
'mark',
|
|
64
|
+
'nav',
|
|
65
|
+
'ol',
|
|
66
|
+
'optgroup',
|
|
67
|
+
'option',
|
|
68
|
+
'p',
|
|
69
|
+
'picture',
|
|
70
|
+
'pre',
|
|
71
|
+
'progress',
|
|
72
|
+
'q',
|
|
73
|
+
'rp',
|
|
74
|
+
'rt',
|
|
75
|
+
'ruby',
|
|
76
|
+
's',
|
|
77
|
+
'samp',
|
|
78
|
+
'section',
|
|
79
|
+
'select',
|
|
80
|
+
'small',
|
|
81
|
+
'source',
|
|
82
|
+
'span',
|
|
83
|
+
'strong',
|
|
84
|
+
'sub',
|
|
85
|
+
'summary',
|
|
86
|
+
'sup',
|
|
87
|
+
'table',
|
|
88
|
+
'tbody',
|
|
89
|
+
'td',
|
|
90
|
+
'textarea',
|
|
91
|
+
'tfoot',
|
|
92
|
+
'th',
|
|
93
|
+
'thead',
|
|
94
|
+
'time',
|
|
95
|
+
'tr',
|
|
96
|
+
'u',
|
|
97
|
+
'ul',
|
|
98
|
+
'var',
|
|
99
|
+
'wbr',
|
|
100
|
+
]);
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Explicitly dangerous tags that should never be allowed.
|
|
104
|
+
* These are checked even if somehow added to allowTags.
|
|
105
|
+
*/
|
|
106
|
+
export const DANGEROUS_TAGS = new Set([
|
|
107
|
+
'script',
|
|
108
|
+
'iframe',
|
|
109
|
+
'frame',
|
|
110
|
+
'frameset',
|
|
111
|
+
'object',
|
|
112
|
+
'embed',
|
|
113
|
+
'applet',
|
|
114
|
+
'link',
|
|
115
|
+
'meta',
|
|
116
|
+
'style',
|
|
117
|
+
'base',
|
|
118
|
+
'template',
|
|
119
|
+
// 'slot' is intentionally excluded here so component shadow markup can opt in
|
|
120
|
+
// via sanitizeHtml(..., { allowTags: ['slot'] }). It remains disallowed by default
|
|
121
|
+
// for general HTML writes, because DEFAULT_ALLOWED_TAGS does not include it.
|
|
122
|
+
'math',
|
|
123
|
+
'svg',
|
|
124
|
+
'foreignobject',
|
|
125
|
+
'noscript',
|
|
126
|
+
]);
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Reserved IDs that could cause DOM clobbering attacks.
|
|
130
|
+
* These are prevented to avoid overwriting global browser objects.
|
|
131
|
+
*/
|
|
132
|
+
export const RESERVED_IDS = new Set([
|
|
133
|
+
// Global objects
|
|
134
|
+
'document',
|
|
135
|
+
'window',
|
|
136
|
+
'location',
|
|
137
|
+
'top',
|
|
138
|
+
'self',
|
|
139
|
+
'parent',
|
|
140
|
+
'frames',
|
|
141
|
+
'history',
|
|
142
|
+
'navigator',
|
|
143
|
+
'screen',
|
|
144
|
+
// Dangerous functions
|
|
145
|
+
'alert',
|
|
146
|
+
'confirm',
|
|
147
|
+
'prompt',
|
|
148
|
+
'eval',
|
|
149
|
+
'function',
|
|
150
|
+
// Document properties
|
|
151
|
+
'cookie',
|
|
152
|
+
'domain',
|
|
153
|
+
'referrer',
|
|
154
|
+
'body',
|
|
155
|
+
'head',
|
|
156
|
+
'forms',
|
|
157
|
+
'images',
|
|
158
|
+
'links',
|
|
159
|
+
'scripts',
|
|
160
|
+
// DOM traversal properties
|
|
161
|
+
'children',
|
|
162
|
+
'parentnode',
|
|
163
|
+
'firstchild',
|
|
164
|
+
'lastchild',
|
|
165
|
+
// Content manipulation
|
|
166
|
+
'innerhtml',
|
|
167
|
+
'outerhtml',
|
|
168
|
+
'textcontent',
|
|
169
|
+
]);
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Default allowed attributes considered safe.
|
|
173
|
+
* Note: 'style' is excluded by default because inline CSS can be abused for:
|
|
174
|
+
* - UI redressing attacks
|
|
175
|
+
* - Data exfiltration via url() in CSS
|
|
176
|
+
* - CSS injection vectors
|
|
177
|
+
* If you need to allow inline styles, add 'style' to allowAttributes in your
|
|
178
|
+
* sanitizeHtml options, but ensure you implement proper CSS value validation.
|
|
179
|
+
*/
|
|
180
|
+
export const DEFAULT_ALLOWED_ATTRIBUTES = new Set([
|
|
181
|
+
'alt',
|
|
182
|
+
'class',
|
|
183
|
+
'dir',
|
|
184
|
+
'height',
|
|
185
|
+
'hidden',
|
|
186
|
+
'href',
|
|
187
|
+
'id',
|
|
188
|
+
'lang',
|
|
189
|
+
'loading',
|
|
190
|
+
'name',
|
|
191
|
+
'rel',
|
|
192
|
+
'role',
|
|
193
|
+
'src',
|
|
194
|
+
'srcset',
|
|
195
|
+
'tabindex',
|
|
196
|
+
'target',
|
|
197
|
+
'title',
|
|
198
|
+
'type',
|
|
199
|
+
'width',
|
|
200
|
+
'aria-*',
|
|
201
|
+
]);
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Dangerous attribute prefixes to always remove.
|
|
205
|
+
*/
|
|
206
|
+
export const DANGEROUS_ATTR_PREFIXES = ['on', 'formaction', 'xlink:', 'xmlns:'];
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Dangerous URL protocols to block.
|
|
210
|
+
*/
|
|
211
|
+
export const DANGEROUS_PROTOCOLS = ['javascript:', 'data:', 'vbscript:', 'file:'];
|
package/src/security/index.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Security module providing sanitization, CSP compatibility, and Trusted Types.
|
|
3
|
-
*
|
|
4
|
-
* @module bquery/security
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export { generateNonce, hasCSPDirective } from './csp';
|
|
8
|
-
export {
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Security module providing sanitization, CSP compatibility, and Trusted Types.
|
|
3
|
+
*
|
|
4
|
+
* @module bquery/security
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { generateNonce, hasCSPDirective } from './csp';
|
|
8
|
+
export {
|
|
9
|
+
escapeHtml,
|
|
10
|
+
sanitizeHtml as sanitize,
|
|
11
|
+
sanitizeHtml,
|
|
12
|
+
stripTags,
|
|
13
|
+
} from './sanitize';
|
|
14
|
+
export { trusted } from './trusted-html';
|
|
15
|
+
export { createTrustedHtml, getTrustedTypesPolicy, isTrustedTypesSupported } from './trusted-types';
|
|
16
|
+
export type { SanitizedHtml, TrustedHtml } from './trusted-html';
|
|
17
|
+
export type { SanitizeOptions } from './sanitize';
|