pds-dev-kit-web-test 0.3.60 → 0.3.61

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.
@@ -5,6 +5,9 @@ export declare const EMBEDED_SAMPLES: {
5
5
  DIV: string;
6
6
  DIRTY: string;
7
7
  CLEAN: string;
8
+ SCRIPT2: string;
9
+ FACEBOOK: string;
10
+ ALERT: string;
8
11
  };
9
12
  export declare const sampleCustomsection1: {
10
13
  administrativeTitle: string;
@@ -3,11 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sampleCustomsection6 = exports.sampleCustomsection5 = exports.sampleCustomsection4 = exports.sampleCustomsection3 = exports.sampleCustomsection2 = exports.sampleCustomsection1 = exports.EMBEDED_SAMPLES = void 0;
4
4
  exports.EMBEDED_SAMPLES = {
5
5
  GOOGLE_MAPS: '<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d508.40856699559515!2d127.04604546611074!3d37.5412884534309!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x357ca484b232aab9%3A0x3016af9babd6093e!2z7ISc7Jq47Yq567OE7IucIOyEseuPmeq1rCDrmp3shKzroZwgMzE3!5e0!3m2!1sko!2skr!4v1690098445797!5m2!1sko!2skr" width="100%" height="100%" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>',
6
- GOOGLE_FORMS: '<iframe src="https://docs.google.com/forms/d/e/1FAIpQLSeXlFI2qpbGOGQ5Zvk3JkkJXo0qsznrpjjIutpk9nGfpPFCIA/viewform?embedded=true" width="300px" height="200px" frameborder="0" marginheight="0" marginwidth="0">로드 중…</iframe>',
6
+ GOOGLE_FORMS: '<iframe src="https://docs.google.com/forms/d/e/1FAIpQLSeXlFI2qpbGOGQ5Zvk3JkkJXo0qsznrpjjIutpk9nGfpPFCIA/viewform?embedded=true" width="100%" height="100%" frameborder="0" marginheight="0" marginwidth="0">로드 중…</iframe>',
7
7
  SCRIPT: '<div class="whattime-inline-widget" data-code="9WVUWfsUhi" style="min-width: 320px; height: 690px;"></div><link href="https://whattime.co.kr/widget/widget.css" rel="stylesheet"><script src="https://whattime.co.kr/widget/widget.js" type="text/javascript" async></script>',
8
8
  DIV: '<div style="background-color: black"><button>sample-button</button></div>',
9
9
  DIRTY: '<img src=x onerror=alert(1)//>',
10
- CLEAN: '<div>CLEAN</div>'
10
+ CLEAN: '<div>CLEAN</div>',
11
+ SCRIPT2: '<script src="https:/hello.js" type="text/javascript" async></script>',
12
+ FACEBOOK: '<iframe src="https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2Fsminglive%2Fposts%2Fpfbid023o4i8jNwoh9B3bdQSXKcsKZiaU7rK8FuLtgGdt2crQugFWHA7aiPJZWxPpZMqTh3l&show_text=true&width=500" width="500"height="437"style="border:none;overflow:hidden"scrolling="no"frameborder="0"allowfullscreen="true"allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share"></iframe>',
13
+ ALERT: '<script>alert("this-is-no"); console.log("hi"); </script>'
11
14
  };
12
15
  exports.sampleCustomsection1 = {
13
16
  administrativeTitle: 'UNTITLED',
@@ -2035,7 +2038,7 @@ exports.sampleCustomsection5 = {
2035
2038
  CB_CONTENT_PROP_HOVER_SPEC_MUSE: true
2036
2039
  },
2037
2040
  CB_CONTENT_PROP_CODEBLOCK: {
2038
- CB_CONTENT_PROP_CODEBLOCK_SPEC_CODE: exports.EMBEDED_SAMPLES.DIRTY
2041
+ CB_CONTENT_PROP_CODEBLOCK_SPEC_CODE: exports.EMBEDED_SAMPLES.ALERT
2039
2042
  },
2040
2043
  CB_CONTENT_PROP_VISIBILITY: {
2041
2044
  CB_CONTENT_PROP_VISIBILITY_SPEC_DESKTOP: true,
@@ -2414,9 +2417,9 @@ exports.sampleCustomsection5 = {
2414
2417
  'CB_EFFECT_PROP_ENTANIM_SPEC_TFUNC:MOBILE': null
2415
2418
  },
2416
2419
  CB_LAYOUT_PROP_ARRANGE: {
2417
- CB_LAYOUT_PROP_ARRANGE_SPEC_HORIZONTAL: 'CENTER',
2420
+ CB_LAYOUT_PROP_ARRANGE_SPEC_HORIZONTAL: 'LEFT',
2418
2421
  'CB_LAYOUT_PROP_ARRANGE_SPEC_HORIZONTAL:MOBILE': 'MIDDLE',
2419
- CB_LAYOUT_PROP_ARRANGE_SPEC_VERTICAL: 'MIDDLE',
2422
+ CB_LAYOUT_PROP_ARRANGE_SPEC_VERTICAL: 'TOP',
2420
2423
  'CB_LAYOUT_PROP_ARRANGE_SPEC_VERTICAL:MOBILE': null
2421
2424
  },
2422
2425
  CB_LAYOUT_PROP_PADDING: {
@@ -2431,11 +2434,11 @@ exports.sampleCustomsection5 = {
2431
2434
  'CB_LAYOUT_PROP_PADDING_SPEC_PADDING:MOBILE': null
2432
2435
  },
2433
2436
  CB_PLACEMENT_PROP_PLACEMENT: {
2434
- CB_PLACEMENT_PROP_PLACEMENT_SPEC_COLS: 10,
2437
+ CB_PLACEMENT_PROP_PLACEMENT_SPEC_COLS: 15,
2435
2438
  'CB_PLACEMENT_PROP_PLACEMENT_SPEC_COLS:MOBILE': 8,
2436
2439
  CB_PLACEMENT_PROP_PLACEMENT_SPEC_ROWS: 20,
2437
2440
  'CB_PLACEMENT_PROP_PLACEMENT_SPEC_ROWS:MOBILE': 20,
2438
- CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTX: 10,
2441
+ CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTX: 0,
2439
2442
  'CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTX:MOBILE': 0,
2440
2443
  CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTY: 0,
2441
2444
  'CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTY:MOBILE': 0,
@@ -21,7 +21,7 @@ var hooks_1 = require("../../../../hooks");
21
21
  var util_1 = require("../../../../util");
22
22
  var S_CB_AnimationObserverBox_1 = require("../components/S_CB_AnimationObserverBox");
23
23
  var S_CB_BoxWithShadow_1 = require("../components/S_CB_BoxWithShadow");
24
- var EmbedCore_1 = __importDefault(require("./EmbedCore"));
24
+ var EmbedIframe_1 = __importDefault(require("./EmbedIframe"));
25
25
  function Embed(props) {
26
26
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
27
27
  var _a = (0, react_1.useContext)(DynamicLayout_1.dynamicLayoutContext), device = _a.device, mode = _a.mode;
@@ -40,6 +40,6 @@ function Embed(props) {
40
40
  : CB_EFFECT_PROP_ENTANIM['CB_EFFECT_PROP_ENTANIM_SPEC_TYPE:MOBILE'] === 'NONE';
41
41
  var hasEffect = !isNoneEffectType;
42
42
  var effectVisibleStyle = hasEffect ? { opacity: isVisible ? 1 : 0 } : {};
43
- return ((0, jsx_runtime_1.jsx)(S_CB_AnimationObserverBox_1.S_CB_AnimationObserverBox, __assign({ ref: hasEffect ? cbRef : null, effectVisibleStyle: effectVisibleStyle }, { children: (0, jsx_runtime_1.jsx)(S_CB_BoxWithShadow_1.S_CB_BoxWithShadow, __assign({ className: "cb-layout-box", normalStyle: __assign(__assign(__assign(__assign({}, style), layout), effectCssProperties), editModeStyle), hoverStyle: hoverStyle, cbStylePropsShadowSpecs: CB_STYLE_PROP_SHADOW, device: device }, { children: (0, jsx_runtime_1.jsx)(EmbedCore_1.default, { embedCode: CB_CONTENT_PROP_CODEBLOCK_SPEC_CODE }) })) })));
43
+ return ((0, jsx_runtime_1.jsx)(S_CB_AnimationObserverBox_1.S_CB_AnimationObserverBox, __assign({ ref: hasEffect ? cbRef : null, effectVisibleStyle: effectVisibleStyle }, { children: (0, jsx_runtime_1.jsx)(S_CB_BoxWithShadow_1.S_CB_BoxWithShadow, __assign({ className: "cb-layout-box", normalStyle: __assign(__assign(__assign(__assign({}, style), layout), effectCssProperties), editModeStyle), hoverStyle: hoverStyle, cbStylePropsShadowSpecs: CB_STYLE_PROP_SHADOW, device: device }, { children: (0, jsx_runtime_1.jsx)(EmbedIframe_1.default, { embedCode: CB_CONTENT_PROP_CODEBLOCK_SPEC_CODE, mode: mode, style: layout }) })) })));
44
44
  }
45
45
  exports.default = Embed;
@@ -1,6 +1,8 @@
1
1
  /// <reference types="react" />
2
+ import type { DynamicLayoutProps } from '../../../../../../../DynamicLayout/types';
2
3
  interface EmbedCoreProps {
3
4
  embedCode: string;
5
+ mode: DynamicLayoutProps['mode'];
4
6
  }
5
7
  declare const EmbedCore: React.FC<EmbedCoreProps>;
6
8
  export default EmbedCore;
@@ -42,14 +42,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  var jsx_runtime_1 = require("react/jsx-runtime");
43
43
  var DOMPurify = __importStar(require("dompurify"));
44
44
  var styled_components_1 = __importDefault(require("styled-components"));
45
+ var constant_1 = require("./constant");
45
46
  var PURIFY_CONFIG = {
46
- ADD_TAGS: ['iframe'],
47
- ADD_ATTR: ['frameborder', 'marginheight', 'marginwidth', 'allowfullscreen', 'referrerpolicy']
47
+ ADD_TAGS: constant_1.PURIFY_BLOCK_TAGS,
48
+ ADD_ATTR: constant_1.PURIFY_BLOCK_ATTRS
48
49
  };
49
50
  var EmbedCore = function (_a) {
50
- var embedCode = _a.embedCode;
51
+ var embedCode = _a.embedCode, mode = _a.mode;
51
52
  var sanitized = DOMPurify.sanitize(embedCode, PURIFY_CONFIG);
52
- if (DOMPurify.removed.length > 0) {
53
+ DOMPurify.addHook('afterSanitizeAttributes', function (node) {
54
+ if (node.tagName === 'IFRAME') {
55
+ node.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms');
56
+ }
57
+ });
58
+ if (DOMPurify.removed.length > 0 && mode === 'EDIT') {
53
59
  var message = removedMessage(DOMPurify.removed).join("\n");
54
60
  return (0, jsx_runtime_1.jsx)(S_Error, { children: message });
55
61
  }
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { CSSProperties } from 'styled-components';
3
+ import type { DynamicLayoutProps } from '../../../../../../../DynamicLayout/types';
4
+ interface EmbedCoreProps {
5
+ embedCode: string;
6
+ mode: DynamicLayoutProps['mode'];
7
+ style: CSSProperties;
8
+ }
9
+ declare const EmbedIframe: React.FC<EmbedCoreProps>;
10
+ export default EmbedIframe;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ var jsx_runtime_1 = require("react/jsx-runtime");
11
+ var react_1 = require("react");
12
+ var styled_components_1 = __importDefault(require("styled-components"));
13
+ var EmbedIframe = function (_a) {
14
+ var embedCode = _a.embedCode, style = _a.style;
15
+ var blobUrl = (0, react_1.useMemo)(function () {
16
+ return getCodeBlobUrl(embedCode, style);
17
+ }, [embedCode]);
18
+ return ((0, jsx_runtime_1.jsx)(S_Iframe, { src: blobUrl, title: "\uD2B9\uBCC4\uD55C\uC774\uB984", sandbox: "allow-scripts allow-same-origin allow-forms" }));
19
+ };
20
+ var S_Iframe = styled_components_1.default.iframe(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border: none;\n height: 100%;\n width: 100%;\n"], ["\n border: none;\n height: 100%;\n width: 100%;\n"])));
21
+ function getCodeBlobUrl(code, style) {
22
+ var styleString = Object.entries(style).reduce(function (styleStr, _a) {
23
+ var prop = _a[0], value = _a[1];
24
+ var kebabProp = prop.replace(/([a-z0])([A-Z])/g, '$1-$2').toLowerCase();
25
+ return "".concat(styleStr).concat(kebabProp, ": ").concat(value, ";");
26
+ }, '');
27
+ var fullCode = "\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <title>\uCF54\uB4DC\uC528\uBE44</title>\n <style>\n html, body {\n margin: 0;\n padding: 0;\n width: 100%;\n height: 100%;\n ".concat(styleString, "\n }\n\n </style>\n </head>\n <body>\n ").concat(code, "\n </body>\n </html>\n ");
28
+ // Use a blob to handle potentially complex scripts and avoid encoding issues
29
+ var blob = new Blob([fullCode], { type: 'text/html' });
30
+ var url = URL.createObjectURL(blob);
31
+ return url;
32
+ }
33
+ exports.default = EmbedIframe;
34
+ var templateObject_1;
@@ -1,2 +1,4 @@
1
1
  export declare const tagBlacklist: string[];
2
2
  export declare const attrBlacklist: string[];
3
+ export declare const PURIFY_BLOCK_TAGS: string[];
4
+ export declare const PURIFY_BLOCK_ATTRS: string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.attrBlacklist = exports.tagBlacklist = void 0;
3
+ exports.PURIFY_BLOCK_ATTRS = exports.PURIFY_BLOCK_TAGS = exports.attrBlacklist = exports.tagBlacklist = void 0;
4
4
  exports.tagBlacklist = [
5
5
  // 'script',
6
6
  // 'iframe',
@@ -24,3 +24,76 @@ exports.attrBlacklist = [
24
24
  // 'style',
25
25
  'target'
26
26
  ];
27
+ exports.PURIFY_BLOCK_TAGS = [
28
+ 'applet',
29
+ 'base',
30
+ 'basefont',
31
+ 'command',
32
+ 'embed',
33
+ 'frame',
34
+ 'frameset',
35
+ 'iframe',
36
+ 'keygen',
37
+ 'link',
38
+ 'meta',
39
+ 'noframes',
40
+ 'noscript',
41
+ 'object',
42
+ 'param',
43
+ 'script',
44
+ 'title'
45
+ ];
46
+ exports.PURIFY_BLOCK_ATTRS = [
47
+ 'accept-charset',
48
+ 'accesskey',
49
+ 'allow',
50
+ 'allowfullscreen',
51
+ 'async',
52
+ 'autocapitalize',
53
+ 'autofocus',
54
+ 'autoplay',
55
+ 'buffered',
56
+ 'challenge',
57
+ 'charset',
58
+ 'code',
59
+ 'codebase',
60
+ 'content',
61
+ 'contenteditable',
62
+ 'contextmenu',
63
+ 'controls',
64
+ 'data',
65
+ 'decoding',
66
+ 'defer',
67
+ 'dirname',
68
+ 'draggable',
69
+ 'dropzone',
70
+ 'form',
71
+ 'formaction',
72
+ 'http-equiv',
73
+ 'icon',
74
+ 'importance',
75
+ 'itemprop',
76
+ 'keytype',
77
+ 'kind',
78
+ 'language',
79
+ 'lazyload',
80
+ 'manifest',
81
+ 'minlength',
82
+ 'muted',
83
+ 'ping',
84
+ 'sandbox',
85
+ 'scoped',
86
+ 'slot',
87
+ 'spellcheck',
88
+ 'srcdoc',
89
+ 'srclang',
90
+ 'start',
91
+ 'target',
92
+ 'translate',
93
+ 'wrap',
94
+ 'referrerpolicy',
95
+ 'frameborder',
96
+ 'scrolling',
97
+ 'marginheight',
98
+ 'marginwidth'
99
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pds-dev-kit-web-test",
3
- "version": "0.3.60",
3
+ "version": "0.3.61",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
package/release-note.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # pds-dev-kit-web-test Release Notes
2
- ## [v0.3.60]
2
+ ## [v0.3.61]
3
3
  ## 기준 pds-dev-kit-web 버전 @2.2.57
4
4
  ### sub
5
5
  * DynamicLayout
6
- * embed cb - dom purify 적용
6
+ * domPurify(sanitizer) 사용하지 않고 blob iframe으로 사용.
7
+ * form 을 허용가능하게 한다.