@bstage-sdk/bridge 0.14.2 → 0.15.1
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 +35 -2
- package/dist/{chunk-5OWBSJ6E.js → chunk-QMYFZ7I6.js} +577 -3
- package/dist/frame.d.cts +1 -1
- package/dist/frame.d.ts +1 -1
- package/dist/host.cjs +1110 -141
- package/dist/host.d.cts +83 -4
- package/dist/host.d.ts +83 -4
- package/dist/host.js +531 -136
- package/dist/index.cjs +581 -3
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -1
- package/dist/{messages-Cdjpvu2S.d.cts → messages-_p1yCNj9.d.cts} +91 -4
- package/dist/{messages-Cdjpvu2S.d.ts → messages-_p1yCNj9.d.ts} +91 -4
- package/package.json +3 -2
package/dist/host.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/host/index.ts
|
|
21
21
|
var host_exports = {};
|
|
22
22
|
__export(host_exports, {
|
|
23
|
+
ACCOUNT_SESSION_CAPABILITY: () => ACCOUNT_SESSION_CAPABILITY,
|
|
23
24
|
ALLOWED_METHODS: () => ALLOWED_METHODS,
|
|
24
25
|
ALLOWED_REQUEST_HEADERS: () => ALLOWED_REQUEST_HEADERS,
|
|
25
26
|
BRIDGE_SURFACES: () => BRIDGE_SURFACES,
|
|
@@ -28,18 +29,24 @@ __export(host_exports, {
|
|
|
28
29
|
DEFAULT_POLICY: () => DEFAULT_POLICY,
|
|
29
30
|
HOST_ONLY_HEADERS: () => HOST_ONLY_HEADERS,
|
|
30
31
|
IFRAME_ATTRIBUTES: () => IFRAME_ATTRIBUTES,
|
|
32
|
+
LOGIN_BINDING_MS: () => LOGIN_BINDING_MS,
|
|
31
33
|
MAX_DECODE_PASSES: () => MAX_DECODE_PASSES,
|
|
32
34
|
MAX_PARTNER_ORIGINS: () => MAX_PARTNER_ORIGINS,
|
|
33
35
|
MAX_PASS_THROUGH_HEADERS: () => MAX_PASS_THROUGH_HEADERS,
|
|
36
|
+
OTP_SEND_PER_MINUTE: () => OTP_SEND_PER_MINUTE,
|
|
37
|
+
OTP_VERIFY_PER_MINUTE: () => OTP_VERIFY_PER_MINUTE,
|
|
34
38
|
REPORTS_PER_SESSION: () => REPORTS_PER_SESSION,
|
|
35
39
|
ROUTING_HEADERS: () => ROUTING_HEADERS,
|
|
36
40
|
ROUTING_HEADER_PREFIXES: () => ROUTING_HEADER_PREFIXES,
|
|
41
|
+
SESSION_PER_FRAME: () => SESSION_PER_FRAME,
|
|
42
|
+
SESSION_PER_MINUTE: () => SESSION_PER_MINUTE,
|
|
37
43
|
checkPath: () => checkPath,
|
|
38
44
|
classifyDestination: () => classifyDestination,
|
|
39
45
|
createBridgeHost: () => createBridgeHost,
|
|
40
46
|
createNonce: () => createNonce,
|
|
41
47
|
createSession: () => createSession,
|
|
42
48
|
createSrcdoc: () => createSrcdoc,
|
|
49
|
+
hasAccountCapability: () => hasAccountCapability,
|
|
43
50
|
isAllowedGatewayPath: () => isAllowedGatewayPath,
|
|
44
51
|
isBridgeSurface: () => isBridgeSurface,
|
|
45
52
|
isValidSession: () => isValidSession,
|
|
@@ -47,7 +54,8 @@ __export(host_exports, {
|
|
|
47
54
|
normalizePinnedHeaders: () => normalizePinnedHeaders,
|
|
48
55
|
prepareFetch: () => prepareFetch,
|
|
49
56
|
resolveDestination: () => resolveDestination,
|
|
50
|
-
resolvePolicy: () => resolvePolicy
|
|
57
|
+
resolvePolicy: () => resolvePolicy,
|
|
58
|
+
stripTokenKeys: () => stripTokenKeys
|
|
51
59
|
});
|
|
52
60
|
module.exports = __toCommonJS(host_exports);
|
|
53
61
|
|
|
@@ -81,7 +89,9 @@ var BRIDGE_ERROR_CODES = [
|
|
|
81
89
|
"BAD_REQUEST",
|
|
82
90
|
"TIMEOUT",
|
|
83
91
|
"NETWORK_ERROR",
|
|
84
|
-
"UNSUPPORTED"
|
|
92
|
+
"UNSUPPORTED",
|
|
93
|
+
// 권한(capability) 없는 배치의 계정 요청, 또는 결속 조건을 벗어난 세션 요청.
|
|
94
|
+
"NOT_ALLOWED"
|
|
85
95
|
];
|
|
86
96
|
var BridgeError = class extends Error {
|
|
87
97
|
constructor(code, message) {
|
|
@@ -108,7 +118,9 @@ var REQUEST_TYPES = [
|
|
|
108
118
|
"track",
|
|
109
119
|
"storage",
|
|
110
120
|
"log",
|
|
111
|
-
"report"
|
|
121
|
+
"report",
|
|
122
|
+
"session",
|
|
123
|
+
"otp"
|
|
112
124
|
];
|
|
113
125
|
var HOST_EVENT_TYPES = ["slot.context", "locale", "member", "theme", "visibility"];
|
|
114
126
|
var READY_EVENT = "ready";
|
|
@@ -118,6 +130,15 @@ var BRIDGE_SURFACES = ["page", "slot"];
|
|
|
118
130
|
function isBridgeSurface(value) {
|
|
119
131
|
return BRIDGE_SURFACES.includes(value);
|
|
120
132
|
}
|
|
133
|
+
var ACCOUNT_SESSION_CAPABILITY = "account-session";
|
|
134
|
+
var KNOWN_CAPABILITIES = [ACCOUNT_SESSION_CAPABILITY];
|
|
135
|
+
var SESSION_OPS = ["signup", "signupSocial", "loginAfterSignup", "phoneReverify"];
|
|
136
|
+
var OTP_OPS = [
|
|
137
|
+
"sendSignup",
|
|
138
|
+
"sendPhoneChange",
|
|
139
|
+
"verifySignup",
|
|
140
|
+
"verifyPhoneChange"
|
|
141
|
+
];
|
|
121
142
|
var TEMPLATE_REPORT_KINDS = ["error", "rejection", "load"];
|
|
122
143
|
var REPORT_MESSAGE_MAX_LENGTH = 300;
|
|
123
144
|
var REPORT_MAX_FRAMES = 10;
|
|
@@ -185,10 +206,10 @@ function hasDotSegment(form) {
|
|
|
185
206
|
function checkPath(pathname, options = {}) {
|
|
186
207
|
const forms = decodeStages(pathname);
|
|
187
208
|
if (!forms) return REJECT;
|
|
188
|
-
const
|
|
209
|
+
const bad2 = forms.some(
|
|
189
210
|
(form) => UNSAFE_CHARS_RE.test(form) || hasDotSegment(form) || options.forbidDoubleSlash === true && form.includes("//")
|
|
190
211
|
);
|
|
191
|
-
return
|
|
212
|
+
return bad2 ? REJECT : { ok: true, forms: Object.freeze(forms) };
|
|
192
213
|
}
|
|
193
214
|
|
|
194
215
|
// src/host/policy.ts
|
|
@@ -498,36 +519,516 @@ function prepareFetch(payload, ctx) {
|
|
|
498
519
|
// src/host/rateLimiter.ts
|
|
499
520
|
var DEFAULT_WINDOW_MS = 6e4;
|
|
500
521
|
function createRateLimiter(max, windowMs = DEFAULT_WINDOW_MS) {
|
|
501
|
-
let
|
|
522
|
+
let stamps2 = [];
|
|
502
523
|
return {
|
|
503
524
|
take(now = Date.now()) {
|
|
504
|
-
const recent =
|
|
525
|
+
const recent = stamps2.filter((t) => now - t < windowMs);
|
|
505
526
|
if (recent.length >= max) {
|
|
506
|
-
|
|
527
|
+
stamps2 = recent;
|
|
507
528
|
return false;
|
|
508
529
|
}
|
|
509
|
-
|
|
530
|
+
stamps2 = [...recent, now];
|
|
510
531
|
return true;
|
|
511
532
|
}
|
|
512
533
|
};
|
|
513
534
|
}
|
|
514
535
|
|
|
515
|
-
// src/host/
|
|
536
|
+
// src/host/validators.ts
|
|
537
|
+
var MAX_PATH_LENGTH = 2048;
|
|
538
|
+
var TOAST_MAX_LENGTH = 500;
|
|
539
|
+
var TRACK_NAME_MAX_LENGTH = 100;
|
|
540
|
+
var TRACK_PARAMS_MAX_BYTES = 4096;
|
|
541
|
+
var RESIZE_MAX_HEIGHT = 2e5;
|
|
542
|
+
var LOG_MAX_LENGTH = 2e3;
|
|
543
|
+
var UNSAFE_KEYS = ["__proto__", "constructor", "prototype"];
|
|
544
|
+
var TOAST_KINDS = ["info", "success", "warning", "error"];
|
|
545
|
+
var LOG_LEVELS = ["debug", "info", "warn", "error"];
|
|
546
|
+
function field(payload, key) {
|
|
547
|
+
return typeof payload === "object" && payload !== null ? payload[key] : void 0;
|
|
548
|
+
}
|
|
549
|
+
function validatePath(payload, hostOrigin) {
|
|
550
|
+
const path = field(payload, "path");
|
|
551
|
+
if (typeof path !== "string" || path.length === 0 || path.length > MAX_PATH_LENGTH || !path.startsWith("/") || path.startsWith("//") || // eslint-disable-next-line no-control-regex -- 제어문자를 거르는 것이 목적이다
|
|
552
|
+
/[\s\\\u0000-\u001f\u007f]/.test(path)) {
|
|
553
|
+
throw new BridgeError("BAD_REQUEST", "invalid path");
|
|
554
|
+
}
|
|
555
|
+
let resolved;
|
|
556
|
+
try {
|
|
557
|
+
resolved = new URL(path, hostOrigin);
|
|
558
|
+
} catch {
|
|
559
|
+
throw new BridgeError("BAD_REQUEST", "invalid path");
|
|
560
|
+
}
|
|
561
|
+
if (resolved.origin !== new URL(hostOrigin).origin || resolved.pathname.startsWith("//")) {
|
|
562
|
+
throw new BridgeError("BAD_REQUEST", "invalid path");
|
|
563
|
+
}
|
|
564
|
+
if (!checkPath(resolved.pathname, { forbidDoubleSlash: true }).ok) {
|
|
565
|
+
throw new BridgeError("BAD_REQUEST", "invalid path");
|
|
566
|
+
}
|
|
567
|
+
return resolved.pathname + resolved.search + resolved.hash;
|
|
568
|
+
}
|
|
569
|
+
function validateNavigateOptions(payload) {
|
|
570
|
+
const replace = field(payload, "replace");
|
|
571
|
+
const reload = field(payload, "reload");
|
|
572
|
+
if (replace !== void 0 && typeof replace !== "boolean") {
|
|
573
|
+
throw new BridgeError("BAD_REQUEST", "invalid navigate options");
|
|
574
|
+
}
|
|
575
|
+
if (reload !== void 0 && typeof reload !== "boolean") {
|
|
576
|
+
throw new BridgeError("BAD_REQUEST", "invalid navigate options");
|
|
577
|
+
}
|
|
578
|
+
if (replace !== true && reload !== true) return void 0;
|
|
579
|
+
return { ...replace === true ? { replace } : {}, ...reload === true ? { reload } : {} };
|
|
580
|
+
}
|
|
581
|
+
function validateExternalUrl(payload) {
|
|
582
|
+
const raw = field(payload, "url");
|
|
583
|
+
if (typeof raw !== "string") throw new BridgeError("BAD_REQUEST", "invalid url");
|
|
584
|
+
let url;
|
|
585
|
+
try {
|
|
586
|
+
url = new URL(raw);
|
|
587
|
+
} catch {
|
|
588
|
+
throw new BridgeError("BAD_REQUEST", "invalid url");
|
|
589
|
+
}
|
|
590
|
+
if (url.protocol !== "https:" || url.username !== "" || url.password !== "") {
|
|
591
|
+
throw new BridgeError("FORBIDDEN_DESTINATION", "only https urls can be opened");
|
|
592
|
+
}
|
|
593
|
+
return url.href;
|
|
594
|
+
}
|
|
595
|
+
function validateToast(payload) {
|
|
596
|
+
const message = field(payload, "message");
|
|
597
|
+
if (typeof message !== "string") throw new BridgeError("BAD_REQUEST", "invalid toast");
|
|
598
|
+
const kind = field(payload, "kind");
|
|
599
|
+
const known = TOAST_KINDS.find((k) => k === kind);
|
|
600
|
+
return { message: message.slice(0, TOAST_MAX_LENGTH), ...known ? { kind: known } : {} };
|
|
601
|
+
}
|
|
602
|
+
function validateHeight(payload) {
|
|
603
|
+
const height = field(payload, "height");
|
|
604
|
+
if (typeof height !== "number" || !Number.isFinite(height)) {
|
|
605
|
+
throw new BridgeError("BAD_REQUEST", "invalid height");
|
|
606
|
+
}
|
|
607
|
+
return Math.min(RESIZE_MAX_HEIGHT, Math.max(0, Math.round(height)));
|
|
608
|
+
}
|
|
609
|
+
function validateTrack(payload) {
|
|
610
|
+
const name = field(payload, "name");
|
|
611
|
+
const params = field(payload, "params");
|
|
612
|
+
if (typeof name !== "string" || name.length === 0 || name.length > TRACK_NAME_MAX_LENGTH) {
|
|
613
|
+
throw new BridgeError("BAD_REQUEST", "invalid track name");
|
|
614
|
+
}
|
|
615
|
+
if (params === void 0) return { name };
|
|
616
|
+
if (typeof params !== "object" || params === null || Array.isArray(params)) {
|
|
617
|
+
throw new BridgeError("BAD_REQUEST", "invalid track params");
|
|
618
|
+
}
|
|
619
|
+
let serialized;
|
|
620
|
+
try {
|
|
621
|
+
serialized = JSON.stringify(params);
|
|
622
|
+
} catch {
|
|
623
|
+
throw new BridgeError("BAD_REQUEST", "invalid track params");
|
|
624
|
+
}
|
|
625
|
+
if (new TextEncoder().encode(serialized).length > TRACK_PARAMS_MAX_BYTES) {
|
|
626
|
+
throw new BridgeError("BAD_REQUEST", "track params too large");
|
|
627
|
+
}
|
|
628
|
+
return {
|
|
629
|
+
name,
|
|
630
|
+
params: JSON.parse(
|
|
631
|
+
serialized,
|
|
632
|
+
(key, value) => UNSAFE_KEYS.includes(key) ? void 0 : value
|
|
633
|
+
)
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
function validateLog(payload) {
|
|
637
|
+
const level = field(payload, "level");
|
|
638
|
+
const message = field(payload, "message");
|
|
639
|
+
const known = LOG_LEVELS.find((l) => l === level);
|
|
640
|
+
if (!known || typeof message !== "string") throw new BridgeError("BAD_REQUEST", "invalid log");
|
|
641
|
+
return { level: known, message: message.slice(0, LOG_MAX_LENGTH) };
|
|
642
|
+
}
|
|
643
|
+
function framesCopy(frames) {
|
|
644
|
+
if (!Array.isArray(frames) || frames.length > REPORT_MAX_FRAMES) return null;
|
|
645
|
+
const out = [];
|
|
646
|
+
for (let i = 0; i < frames.length; i += 1) {
|
|
647
|
+
if (!(i in frames)) return null;
|
|
648
|
+
const f = frames[i];
|
|
649
|
+
if (typeof f !== "string" || f.length > REPORT_FRAME_MAX_LENGTH) return null;
|
|
650
|
+
out.push(f);
|
|
651
|
+
}
|
|
652
|
+
return out;
|
|
653
|
+
}
|
|
654
|
+
function validateReport(payload) {
|
|
655
|
+
const kind = TEMPLATE_REPORT_KINDS.find((k) => k === field(payload, "kind"));
|
|
656
|
+
const message = field(payload, "message");
|
|
657
|
+
const frames = framesCopy(field(payload, "frames"));
|
|
658
|
+
const count = field(payload, "count");
|
|
659
|
+
if (!kind || typeof message !== "string" || message.length > REPORT_MESSAGE_MAX_LENGTH || frames === null || typeof count !== "number" || !Number.isInteger(count) || count < 1 || count > REPORT_COUNT_MAX) {
|
|
660
|
+
throw new BridgeError("BAD_REQUEST", "invalid report");
|
|
661
|
+
}
|
|
662
|
+
return Object.freeze({
|
|
663
|
+
kind,
|
|
664
|
+
message,
|
|
665
|
+
frames: Object.freeze(frames),
|
|
666
|
+
count
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// src/host/accountSession.ts
|
|
671
|
+
var SESSION_PER_MINUTE = 5;
|
|
672
|
+
var SESSION_PER_FRAME = 20;
|
|
673
|
+
var OTP_SEND_PER_MINUTE = 3;
|
|
674
|
+
var OTP_VERIFY_PER_MINUTE = 10;
|
|
675
|
+
var LOGIN_BINDING_MS = 6e4;
|
|
676
|
+
var MAX_STRING = 2048;
|
|
677
|
+
var MAX_AGREEMENTS = 50;
|
|
678
|
+
var MAX_STATUS = 64;
|
|
679
|
+
var MAX_MESSAGE = 500;
|
|
680
|
+
var MARKETING_TARGETS = ["push", "email", "sms"];
|
|
681
|
+
var SIGNUP_COMMON = {
|
|
682
|
+
agreements: "agreements",
|
|
683
|
+
nickname: "string",
|
|
684
|
+
avatarImgPath: "string",
|
|
685
|
+
birthYear: "string",
|
|
686
|
+
birthMonth: "string",
|
|
687
|
+
birthDay: "string",
|
|
688
|
+
marketingNotificationTargets: "marketing",
|
|
689
|
+
phone: "string",
|
|
690
|
+
countryCallingCode: "string",
|
|
691
|
+
name: "string",
|
|
692
|
+
gender: "string",
|
|
693
|
+
phoneVerificationToken: "string"
|
|
694
|
+
};
|
|
695
|
+
var SESSION_SPECS = {
|
|
696
|
+
signup: {
|
|
697
|
+
fields: { email: "string", password: "string", ...SIGNUP_COMMON },
|
|
698
|
+
required: ["email", "password"]
|
|
699
|
+
},
|
|
700
|
+
signupSocial: { fields: { socialType: "string", ...SIGNUP_COMMON }, required: ["socialType"] },
|
|
701
|
+
loginAfterSignup: {
|
|
702
|
+
fields: { email: "string", password: "string", turnstileToken: "string" },
|
|
703
|
+
required: ["email", "password"]
|
|
704
|
+
},
|
|
705
|
+
phoneReverify: {
|
|
706
|
+
fields: { countryCallingCode: "string", phone: "string", phoneVerificationToken: "string" },
|
|
707
|
+
required: ["countryCallingCode", "phone", "phoneVerificationToken"]
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
var OTP_SPECS = {
|
|
711
|
+
sendSignup: {
|
|
712
|
+
endpoint: "send",
|
|
713
|
+
purpose: "SIGNUP",
|
|
714
|
+
spec: { fields: { phone: "string", locale: "string" }, required: ["phone"] }
|
|
715
|
+
},
|
|
716
|
+
sendPhoneChange: {
|
|
717
|
+
endpoint: "send",
|
|
718
|
+
purpose: "PHONE_CHANGE",
|
|
719
|
+
spec: { fields: { phone: "string", locale: "string" }, required: ["phone"] }
|
|
720
|
+
},
|
|
721
|
+
verifySignup: {
|
|
722
|
+
endpoint: "verify",
|
|
723
|
+
purpose: "SIGNUP",
|
|
724
|
+
spec: {
|
|
725
|
+
fields: { phone: "string", code: "string", requestId: "string" },
|
|
726
|
+
required: ["phone", "code"]
|
|
727
|
+
}
|
|
728
|
+
},
|
|
729
|
+
verifyPhoneChange: {
|
|
730
|
+
endpoint: "verify",
|
|
731
|
+
purpose: "PHONE_CHANGE",
|
|
732
|
+
spec: {
|
|
733
|
+
fields: { phone: "string", code: "string", requestId: "string" },
|
|
734
|
+
required: ["phone", "code"]
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
var OTP_DATA_FIELDS = {
|
|
739
|
+
send: ["requestId", "expiresInSeconds", "resendAvailableInSeconds", "maskedPhone"],
|
|
740
|
+
verify: ["verificationToken", "expiresAtSeconds", "phone"]
|
|
741
|
+
};
|
|
742
|
+
function bad() {
|
|
743
|
+
throw new BridgeError("BAD_REQUEST", "invalid account request");
|
|
744
|
+
}
|
|
745
|
+
function notAllowed() {
|
|
746
|
+
throw new BridgeError("NOT_ALLOWED", "not allowed for this placement");
|
|
747
|
+
}
|
|
516
748
|
function obj(value) {
|
|
749
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
750
|
+
}
|
|
751
|
+
function str(value, max = MAX_STRING) {
|
|
752
|
+
return typeof value === "string" && value.length <= max ? value : void 0;
|
|
753
|
+
}
|
|
754
|
+
function cleanAgreements(value) {
|
|
755
|
+
if (!Array.isArray(value) || value.length > MAX_AGREEMENTS) bad();
|
|
756
|
+
return value.map((item) => {
|
|
757
|
+
const o = obj(item);
|
|
758
|
+
const termsId = str(o?.termsId);
|
|
759
|
+
if (!o || termsId === void 0) bad();
|
|
760
|
+
const termsVersion = o.termsVersion === void 0 ? void 0 : str(o.termsVersion);
|
|
761
|
+
const termsType = o.termsType === void 0 ? void 0 : str(o.termsType);
|
|
762
|
+
if (o.termsVersion !== void 0 && termsVersion === void 0) bad();
|
|
763
|
+
if (o.termsType !== void 0 && termsType === void 0) bad();
|
|
764
|
+
return {
|
|
765
|
+
termsId,
|
|
766
|
+
...termsVersion !== void 0 ? { termsVersion } : {},
|
|
767
|
+
...termsType !== void 0 ? { termsType } : {}
|
|
768
|
+
};
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
function cleanMarketing(value) {
|
|
772
|
+
if (!Array.isArray(value) || value.some((v) => !MARKETING_TARGETS.includes(v))) bad();
|
|
773
|
+
return [...value];
|
|
774
|
+
}
|
|
775
|
+
function cleanBody(raw, spec) {
|
|
776
|
+
const body = obj(raw);
|
|
777
|
+
if (!body) bad();
|
|
778
|
+
const out = {};
|
|
779
|
+
for (const [key, kind] of Object.entries(spec.fields)) {
|
|
780
|
+
if (!Object.prototype.hasOwnProperty.call(body, key) || body[key] === void 0) continue;
|
|
781
|
+
const value = body[key];
|
|
782
|
+
if (kind === "string") {
|
|
783
|
+
const s = str(value);
|
|
784
|
+
if (s === void 0) bad();
|
|
785
|
+
out[key] = s;
|
|
786
|
+
} else if (kind === "agreements") out[key] = cleanAgreements(value);
|
|
787
|
+
else out[key] = cleanMarketing(value);
|
|
788
|
+
}
|
|
789
|
+
for (const key of spec.required) {
|
|
790
|
+
if (typeof out[key] !== "string" || out[key].length === 0) bad();
|
|
791
|
+
}
|
|
792
|
+
return out;
|
|
793
|
+
}
|
|
794
|
+
function stripTokenKeys(value, depth = 0) {
|
|
795
|
+
if (depth > 8) return void 0;
|
|
796
|
+
if (Array.isArray(value)) return value.map((v) => stripTokenKeys(v, depth + 1));
|
|
797
|
+
const o = obj(value);
|
|
798
|
+
if (!o) return value;
|
|
799
|
+
return Object.fromEntries(
|
|
800
|
+
Object.entries(o).filter(([k]) => !/token/i.test(k)).map(([k, v]) => [k, stripTokenKeys(v, depth + 1)])
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
function cleanSessionResult(op, raw, hostOrigin) {
|
|
804
|
+
const r = obj(stripTokenKeys(raw)) ?? {};
|
|
805
|
+
const status = str(r.status, MAX_STATUS);
|
|
806
|
+
const message = typeof r.message === "string" ? r.message.slice(0, MAX_MESSAGE) : void 0;
|
|
807
|
+
const createdAt = op === "signup" || op === "signupSocial" ? str(r.createdAt, MAX_STATUS) : void 0;
|
|
808
|
+
let next;
|
|
809
|
+
const rawNext = obj(r.next);
|
|
810
|
+
if (r.ok === true && rawNext) {
|
|
811
|
+
try {
|
|
812
|
+
next = { path: validatePath({ path: rawNext.path }, hostOrigin), reload: true };
|
|
813
|
+
} catch {
|
|
814
|
+
next = void 0;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return {
|
|
818
|
+
ok: r.ok === true,
|
|
819
|
+
...status !== void 0 ? { status } : {},
|
|
820
|
+
...typeof r.code === "number" && Number.isFinite(r.code) ? { code: r.code } : {},
|
|
821
|
+
...message !== void 0 ? { message } : {},
|
|
822
|
+
...typeof r.httpStatus === "number" && Number.isInteger(r.httpStatus) ? { httpStatus: r.httpStatus } : {},
|
|
823
|
+
...createdAt !== void 0 ? { createdAt } : {},
|
|
824
|
+
...next ? { next } : {}
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
function cleanOtpResult(endpoint, raw) {
|
|
828
|
+
const r = obj(raw) ?? {};
|
|
829
|
+
const status = typeof r.status === "number" && Number.isInteger(r.status) ? r.status : 0;
|
|
830
|
+
const rawData = obj(r.data);
|
|
831
|
+
let data;
|
|
832
|
+
if (rawData) {
|
|
833
|
+
data = {};
|
|
834
|
+
for (const key of OTP_DATA_FIELDS[endpoint]) {
|
|
835
|
+
const v = rawData[key];
|
|
836
|
+
if (typeof v === "string" && v.length <= MAX_STRING) data[key] = v;
|
|
837
|
+
else if (typeof v === "number" && Number.isFinite(v)) data[key] = v;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
const rawError = obj(r.error);
|
|
841
|
+
let error;
|
|
842
|
+
if (rawError) {
|
|
843
|
+
const code = str(rawError.code, MAX_STATUS);
|
|
844
|
+
const m = obj(rawError.message);
|
|
845
|
+
const en = m ? str(m.en, MAX_MESSAGE) : void 0;
|
|
846
|
+
const vi = m ? str(m.vi, MAX_MESSAGE) : void 0;
|
|
847
|
+
const retry = rawError.retryAfterSeconds;
|
|
848
|
+
error = {
|
|
849
|
+
...code !== void 0 ? { code } : {},
|
|
850
|
+
...en !== void 0 || vi !== void 0 ? { message: { ...en !== void 0 ? { en } : {}, ...vi !== void 0 ? { vi } : {} } } : {},
|
|
851
|
+
...typeof retry === "number" && Number.isFinite(retry) ? { retryAfterSeconds: retry } : {}
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
return { ok: r.ok === true, status, ...data ? { data } : {}, ...error ? { error } : {} };
|
|
855
|
+
}
|
|
856
|
+
function hasAccountCapability(init) {
|
|
857
|
+
return init.surface === "page" && Array.isArray(init.capabilities) && init.capabilities.includes(ACCOUNT_SESSION_CAPABILITY);
|
|
858
|
+
}
|
|
859
|
+
var STATE_KEY = "__bstage_account_limits__";
|
|
860
|
+
var RELOAD_GRANT_MS = 6e4;
|
|
861
|
+
var WINDOW_MS = 6e4;
|
|
862
|
+
function defaultAccountStateStore(scope = "") {
|
|
863
|
+
const key = scope ? `${STATE_KEY}:${scope}` : STATE_KEY;
|
|
864
|
+
let memory = null;
|
|
865
|
+
const storage = () => {
|
|
866
|
+
try {
|
|
867
|
+
const s = globalThis.sessionStorage;
|
|
868
|
+
return s && typeof s.getItem === "function" ? s : void 0;
|
|
869
|
+
} catch {
|
|
870
|
+
return void 0;
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
return {
|
|
874
|
+
get() {
|
|
875
|
+
try {
|
|
876
|
+
return storage()?.getItem(key) ?? memory;
|
|
877
|
+
} catch {
|
|
878
|
+
return memory;
|
|
879
|
+
}
|
|
880
|
+
},
|
|
881
|
+
set(value) {
|
|
882
|
+
memory = value;
|
|
883
|
+
try {
|
|
884
|
+
storage()?.setItem(key, value);
|
|
885
|
+
} catch {
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
var EMPTY_STATE = { session: [], send: [], verify: [] };
|
|
891
|
+
function stamps(value) {
|
|
892
|
+
return Array.isArray(value) ? value.filter((t) => typeof t === "number" && Number.isFinite(t)) : [];
|
|
893
|
+
}
|
|
894
|
+
function readState(store) {
|
|
895
|
+
try {
|
|
896
|
+
const raw = store.get();
|
|
897
|
+
if (!raw) return EMPTY_STATE;
|
|
898
|
+
const v = JSON.parse(raw);
|
|
899
|
+
if (typeof v !== "object" || v === null) return EMPTY_STATE;
|
|
900
|
+
return { session: stamps(v.session), send: stamps(v.send), verify: stamps(v.verify) };
|
|
901
|
+
} catch {
|
|
902
|
+
return EMPTY_STATE;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
function createAccountSessionHandler(ctx) {
|
|
906
|
+
const store = ctx.stateStore ?? defaultAccountStateStore(ctx.scope);
|
|
907
|
+
function take(kind, max) {
|
|
908
|
+
const now = Date.now();
|
|
909
|
+
const state = readState(store);
|
|
910
|
+
const recent = state[kind].filter((t) => now - t < WINDOW_MS);
|
|
911
|
+
if (recent.length >= max) return false;
|
|
912
|
+
const next = { ...state, [kind]: [...recent, now] };
|
|
913
|
+
store.set(JSON.stringify(next));
|
|
914
|
+
return true;
|
|
915
|
+
}
|
|
916
|
+
let sessionCount = 0;
|
|
917
|
+
let reloadGrantUntil;
|
|
918
|
+
let loginBinding;
|
|
919
|
+
function gate(impl) {
|
|
920
|
+
if (!ctx.enabled) notAllowed();
|
|
921
|
+
if (!impl) throw new BridgeError("UNSUPPORTED", "not supported by host");
|
|
922
|
+
return impl;
|
|
923
|
+
}
|
|
924
|
+
return {
|
|
925
|
+
async session(payload) {
|
|
926
|
+
const impl = gate(ctx.sessionImpl);
|
|
927
|
+
const p = obj(payload) ?? {};
|
|
928
|
+
const op = p.op;
|
|
929
|
+
if (!SESSION_OPS.includes(op)) bad();
|
|
930
|
+
const body = cleanBody(p.body, SESSION_SPECS[op]);
|
|
931
|
+
if (op === "loginAfterSignup") {
|
|
932
|
+
const binding = loginBinding;
|
|
933
|
+
if (!binding || Date.now() > binding.until || binding.email !== body.email) notAllowed();
|
|
934
|
+
}
|
|
935
|
+
if (sessionCount >= SESSION_PER_FRAME || !take("session", SESSION_PER_MINUTE)) {
|
|
936
|
+
throw new BridgeError("RATE_LIMITED", "too many session requests");
|
|
937
|
+
}
|
|
938
|
+
if (op === "loginAfterSignup") loginBinding = void 0;
|
|
939
|
+
sessionCount += 1;
|
|
940
|
+
let raw;
|
|
941
|
+
try {
|
|
942
|
+
raw = await impl(op, body);
|
|
943
|
+
} catch {
|
|
944
|
+
throw new BridgeError("BAD_REQUEST", "request failed");
|
|
945
|
+
}
|
|
946
|
+
const result = cleanSessionResult(op, raw, ctx.hostOrigin);
|
|
947
|
+
if (result.ok && result.status === "SUCCESS") reloadGrantUntil = Date.now() + RELOAD_GRANT_MS;
|
|
948
|
+
if (op === "signup" && result.ok && result.status === "LOGIN_REQUIRED") {
|
|
949
|
+
loginBinding = { email: body.email, until: Date.now() + LOGIN_BINDING_MS };
|
|
950
|
+
}
|
|
951
|
+
return result;
|
|
952
|
+
},
|
|
953
|
+
takeReload() {
|
|
954
|
+
const until = reloadGrantUntil;
|
|
955
|
+
reloadGrantUntil = void 0;
|
|
956
|
+
return until !== void 0 && Date.now() <= until;
|
|
957
|
+
},
|
|
958
|
+
async otp(payload) {
|
|
959
|
+
const impl = gate(ctx.otpImpl);
|
|
960
|
+
const p = obj(payload) ?? {};
|
|
961
|
+
const op = p.op;
|
|
962
|
+
if (!OTP_OPS.includes(op)) bad();
|
|
963
|
+
const { endpoint, purpose, spec } = OTP_SPECS[op];
|
|
964
|
+
const body = cleanBody(p.body, spec);
|
|
965
|
+
const allowed = endpoint === "send" ? take("send", OTP_SEND_PER_MINUTE) : take("verify", OTP_VERIFY_PER_MINUTE);
|
|
966
|
+
if (!allowed) throw new BridgeError("RATE_LIMITED", "too many otp requests");
|
|
967
|
+
let raw;
|
|
968
|
+
try {
|
|
969
|
+
raw = await impl({ op, endpoint, purpose, body });
|
|
970
|
+
} catch {
|
|
971
|
+
throw new BridgeError("NETWORK_ERROR", "network error");
|
|
972
|
+
}
|
|
973
|
+
return cleanOtpResult(endpoint, raw);
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
function buildAccountInit(init) {
|
|
978
|
+
const capabilities = Array.isArray(init.capabilities) ? init.capabilities.filter((c) => KNOWN_CAPABILITIES.includes(c)) : [];
|
|
979
|
+
if (!hasAccountCapability(init)) {
|
|
980
|
+
return capabilities.length > 0 ? { capabilities: Object.freeze(capabilities) } : {};
|
|
981
|
+
}
|
|
982
|
+
const q = obj(init.query);
|
|
983
|
+
const socialType = q ? str(q.socialType, MAX_STATUS) : void 0;
|
|
984
|
+
const country = typeof init.country === "string" && /^[A-Za-z]{2,3}$/.test(init.country) ? init.country : void 0;
|
|
985
|
+
const s = obj(init.space);
|
|
986
|
+
const title = s ? str(s.title, 200) : void 0;
|
|
987
|
+
const corp = s ? obj(s.corporation) : void 0;
|
|
988
|
+
const corpName = corp ? str(corp.name, 200) : void 0;
|
|
989
|
+
const corpCountry = corp ? str(corp.country, 8) : void 0;
|
|
990
|
+
const r = obj(init.reverification);
|
|
991
|
+
const expiresAt = r ? str(r.expiresAt, MAX_STATUS) : void 0;
|
|
992
|
+
return {
|
|
993
|
+
capabilities: Object.freeze(capabilities),
|
|
994
|
+
query: socialType !== void 0 ? { socialType } : {},
|
|
995
|
+
...country !== void 0 ? { country } : {},
|
|
996
|
+
...s ? {
|
|
997
|
+
space: {
|
|
998
|
+
...title !== void 0 ? { title } : {},
|
|
999
|
+
...corp ? {
|
|
1000
|
+
corporation: {
|
|
1001
|
+
...corpName !== void 0 ? { name: corpName } : {},
|
|
1002
|
+
...corpCountry !== void 0 ? { country: corpCountry } : {}
|
|
1003
|
+
}
|
|
1004
|
+
} : {}
|
|
1005
|
+
}
|
|
1006
|
+
} : {},
|
|
1007
|
+
...r ? {
|
|
1008
|
+
reverification: {
|
|
1009
|
+
available: r.available === true,
|
|
1010
|
+
...expiresAt !== void 0 ? { expiresAt } : {}
|
|
1011
|
+
}
|
|
1012
|
+
} : {}
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// src/host/events.ts
|
|
1017
|
+
function obj2(value) {
|
|
517
1018
|
return typeof value === "object" && value !== null ? value : {};
|
|
518
1019
|
}
|
|
519
1020
|
function sanitizeTheme(value) {
|
|
520
|
-
return { dark:
|
|
1021
|
+
return { dark: obj2(value).dark === true };
|
|
521
1022
|
}
|
|
522
1023
|
function sanitizeMember(value) {
|
|
523
|
-
const m =
|
|
1024
|
+
const m = obj2(value);
|
|
524
1025
|
return {
|
|
525
1026
|
signedIn: m.signedIn === true,
|
|
526
1027
|
...typeof m.nickname === "string" ? { nickname: m.nickname } : {}
|
|
527
1028
|
};
|
|
528
1029
|
}
|
|
529
1030
|
function sanitizeSlot(value) {
|
|
530
|
-
const s =
|
|
1031
|
+
const s = obj2(value);
|
|
531
1032
|
return typeof s.id === "string" ? { id: s.id, context: s.context } : void 0;
|
|
532
1033
|
}
|
|
533
1034
|
function sanitizeTranslations(value) {
|
|
@@ -541,7 +1042,7 @@ function sanitizeTranslations(value) {
|
|
|
541
1042
|
);
|
|
542
1043
|
}
|
|
543
1044
|
function sanitizeEvent(type, payload) {
|
|
544
|
-
const p =
|
|
1045
|
+
const p = obj2(payload);
|
|
545
1046
|
switch (type) {
|
|
546
1047
|
case "theme":
|
|
547
1048
|
return sanitizeTheme(p);
|
|
@@ -585,7 +1086,8 @@ function buildInit(init, hostOrigin, partnerOrigins, policy) {
|
|
|
585
1086
|
maxRequestsPerMinute: policy.maxRequestsPerMinute
|
|
586
1087
|
},
|
|
587
1088
|
partnerOrigins,
|
|
588
|
-
...translations ? { translations } : {}
|
|
1089
|
+
...translations ? { translations } : {},
|
|
1090
|
+
...buildAccountInit(init)
|
|
589
1091
|
});
|
|
590
1092
|
}
|
|
591
1093
|
function applyEvent(init, type, payload) {
|
|
@@ -643,128 +1145,6 @@ function handleStorage(scope, req) {
|
|
|
643
1145
|
throw new BridgeError("BAD_REQUEST", "invalid storage op");
|
|
644
1146
|
}
|
|
645
1147
|
|
|
646
|
-
// src/host/validators.ts
|
|
647
|
-
var MAX_PATH_LENGTH = 2048;
|
|
648
|
-
var TOAST_MAX_LENGTH = 500;
|
|
649
|
-
var TRACK_NAME_MAX_LENGTH = 100;
|
|
650
|
-
var TRACK_PARAMS_MAX_BYTES = 4096;
|
|
651
|
-
var RESIZE_MAX_HEIGHT = 2e5;
|
|
652
|
-
var LOG_MAX_LENGTH = 2e3;
|
|
653
|
-
var UNSAFE_KEYS = ["__proto__", "constructor", "prototype"];
|
|
654
|
-
var TOAST_KINDS = ["info", "success", "warning", "error"];
|
|
655
|
-
var LOG_LEVELS = ["debug", "info", "warn", "error"];
|
|
656
|
-
function field(payload, key) {
|
|
657
|
-
return typeof payload === "object" && payload !== null ? payload[key] : void 0;
|
|
658
|
-
}
|
|
659
|
-
function validatePath(payload, hostOrigin) {
|
|
660
|
-
const path = field(payload, "path");
|
|
661
|
-
if (typeof path !== "string" || path.length === 0 || path.length > MAX_PATH_LENGTH || !path.startsWith("/") || path.startsWith("//") || // eslint-disable-next-line no-control-regex -- 제어문자를 거르는 것이 목적이다
|
|
662
|
-
/[\s\\\u0000-\u001f\u007f]/.test(path)) {
|
|
663
|
-
throw new BridgeError("BAD_REQUEST", "invalid path");
|
|
664
|
-
}
|
|
665
|
-
let resolved;
|
|
666
|
-
try {
|
|
667
|
-
resolved = new URL(path, hostOrigin);
|
|
668
|
-
} catch {
|
|
669
|
-
throw new BridgeError("BAD_REQUEST", "invalid path");
|
|
670
|
-
}
|
|
671
|
-
if (resolved.origin !== new URL(hostOrigin).origin || resolved.pathname.startsWith("//")) {
|
|
672
|
-
throw new BridgeError("BAD_REQUEST", "invalid path");
|
|
673
|
-
}
|
|
674
|
-
if (!checkPath(resolved.pathname, { forbidDoubleSlash: true }).ok) {
|
|
675
|
-
throw new BridgeError("BAD_REQUEST", "invalid path");
|
|
676
|
-
}
|
|
677
|
-
return resolved.pathname + resolved.search + resolved.hash;
|
|
678
|
-
}
|
|
679
|
-
function validateExternalUrl(payload) {
|
|
680
|
-
const raw = field(payload, "url");
|
|
681
|
-
if (typeof raw !== "string") throw new BridgeError("BAD_REQUEST", "invalid url");
|
|
682
|
-
let url;
|
|
683
|
-
try {
|
|
684
|
-
url = new URL(raw);
|
|
685
|
-
} catch {
|
|
686
|
-
throw new BridgeError("BAD_REQUEST", "invalid url");
|
|
687
|
-
}
|
|
688
|
-
if (url.protocol !== "https:" || url.username !== "" || url.password !== "") {
|
|
689
|
-
throw new BridgeError("FORBIDDEN_DESTINATION", "only https urls can be opened");
|
|
690
|
-
}
|
|
691
|
-
return url.href;
|
|
692
|
-
}
|
|
693
|
-
function validateToast(payload) {
|
|
694
|
-
const message = field(payload, "message");
|
|
695
|
-
if (typeof message !== "string") throw new BridgeError("BAD_REQUEST", "invalid toast");
|
|
696
|
-
const kind = field(payload, "kind");
|
|
697
|
-
const known = TOAST_KINDS.find((k) => k === kind);
|
|
698
|
-
return { message: message.slice(0, TOAST_MAX_LENGTH), ...known ? { kind: known } : {} };
|
|
699
|
-
}
|
|
700
|
-
function validateHeight(payload) {
|
|
701
|
-
const height = field(payload, "height");
|
|
702
|
-
if (typeof height !== "number" || !Number.isFinite(height)) {
|
|
703
|
-
throw new BridgeError("BAD_REQUEST", "invalid height");
|
|
704
|
-
}
|
|
705
|
-
return Math.min(RESIZE_MAX_HEIGHT, Math.max(0, Math.round(height)));
|
|
706
|
-
}
|
|
707
|
-
function validateTrack(payload) {
|
|
708
|
-
const name = field(payload, "name");
|
|
709
|
-
const params = field(payload, "params");
|
|
710
|
-
if (typeof name !== "string" || name.length === 0 || name.length > TRACK_NAME_MAX_LENGTH) {
|
|
711
|
-
throw new BridgeError("BAD_REQUEST", "invalid track name");
|
|
712
|
-
}
|
|
713
|
-
if (params === void 0) return { name };
|
|
714
|
-
if (typeof params !== "object" || params === null || Array.isArray(params)) {
|
|
715
|
-
throw new BridgeError("BAD_REQUEST", "invalid track params");
|
|
716
|
-
}
|
|
717
|
-
let serialized;
|
|
718
|
-
try {
|
|
719
|
-
serialized = JSON.stringify(params);
|
|
720
|
-
} catch {
|
|
721
|
-
throw new BridgeError("BAD_REQUEST", "invalid track params");
|
|
722
|
-
}
|
|
723
|
-
if (new TextEncoder().encode(serialized).length > TRACK_PARAMS_MAX_BYTES) {
|
|
724
|
-
throw new BridgeError("BAD_REQUEST", "track params too large");
|
|
725
|
-
}
|
|
726
|
-
return {
|
|
727
|
-
name,
|
|
728
|
-
params: JSON.parse(
|
|
729
|
-
serialized,
|
|
730
|
-
(key, value) => UNSAFE_KEYS.includes(key) ? void 0 : value
|
|
731
|
-
)
|
|
732
|
-
};
|
|
733
|
-
}
|
|
734
|
-
function validateLog(payload) {
|
|
735
|
-
const level = field(payload, "level");
|
|
736
|
-
const message = field(payload, "message");
|
|
737
|
-
const known = LOG_LEVELS.find((l) => l === level);
|
|
738
|
-
if (!known || typeof message !== "string") throw new BridgeError("BAD_REQUEST", "invalid log");
|
|
739
|
-
return { level: known, message: message.slice(0, LOG_MAX_LENGTH) };
|
|
740
|
-
}
|
|
741
|
-
function framesCopy(frames) {
|
|
742
|
-
if (!Array.isArray(frames) || frames.length > REPORT_MAX_FRAMES) return null;
|
|
743
|
-
const out = [];
|
|
744
|
-
for (let i = 0; i < frames.length; i += 1) {
|
|
745
|
-
if (!(i in frames)) return null;
|
|
746
|
-
const f = frames[i];
|
|
747
|
-
if (typeof f !== "string" || f.length > REPORT_FRAME_MAX_LENGTH) return null;
|
|
748
|
-
out.push(f);
|
|
749
|
-
}
|
|
750
|
-
return out;
|
|
751
|
-
}
|
|
752
|
-
function validateReport(payload) {
|
|
753
|
-
const kind = TEMPLATE_REPORT_KINDS.find((k) => k === field(payload, "kind"));
|
|
754
|
-
const message = field(payload, "message");
|
|
755
|
-
const frames = framesCopy(field(payload, "frames"));
|
|
756
|
-
const count = field(payload, "count");
|
|
757
|
-
if (!kind || typeof message !== "string" || message.length > REPORT_MESSAGE_MAX_LENGTH || frames === null || typeof count !== "number" || !Number.isInteger(count) || count < 1 || count > REPORT_COUNT_MAX) {
|
|
758
|
-
throw new BridgeError("BAD_REQUEST", "invalid report");
|
|
759
|
-
}
|
|
760
|
-
return Object.freeze({
|
|
761
|
-
kind,
|
|
762
|
-
message,
|
|
763
|
-
frames: Object.freeze(frames),
|
|
764
|
-
count
|
|
765
|
-
});
|
|
766
|
-
}
|
|
767
|
-
|
|
768
1148
|
// src/host/createBridgeHost.ts
|
|
769
1149
|
var OPAQUE_ORIGIN = "null";
|
|
770
1150
|
var UNLIMITED_REQUESTS = ["resize"];
|
|
@@ -860,8 +1240,13 @@ async function dispatch(ctx, type, payload) {
|
|
|
860
1240
|
return runFetch(ctx, payload);
|
|
861
1241
|
case "navigate": {
|
|
862
1242
|
const path = validatePath(payload, ctx.hostOrigin);
|
|
1243
|
+
const navOptions = validateNavigateOptions(payload);
|
|
1244
|
+
if (navOptions?.reload && !ctx.account.takeReload()) {
|
|
1245
|
+
throw new BridgeError("NOT_ALLOWED", "reload not allowed");
|
|
1246
|
+
}
|
|
863
1247
|
if (!h.navigate) unsupported();
|
|
864
|
-
h.navigate(path);
|
|
1248
|
+
if (navOptions) h.navigate(path, navOptions);
|
|
1249
|
+
else h.navigate(path);
|
|
865
1250
|
return EMPTY;
|
|
866
1251
|
}
|
|
867
1252
|
case "back":
|
|
@@ -911,6 +1296,10 @@ async function dispatch(ctx, type, payload) {
|
|
|
911
1296
|
}
|
|
912
1297
|
return EMPTY;
|
|
913
1298
|
}
|
|
1299
|
+
case "session":
|
|
1300
|
+
return ctx.account.session(payload);
|
|
1301
|
+
case "otp":
|
|
1302
|
+
return ctx.account.otp(payload);
|
|
914
1303
|
}
|
|
915
1304
|
}
|
|
916
1305
|
function failure(code, message) {
|
|
@@ -954,6 +1343,12 @@ function assertOptions(options) {
|
|
|
954
1343
|
if (options.onDispose !== void 0 && typeof options.onDispose !== "function") {
|
|
955
1344
|
throw new TypeError("[bstage-bridge] onDispose\uB294 \uD568\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4");
|
|
956
1345
|
}
|
|
1346
|
+
if (options.sessionImpl !== void 0 && typeof options.sessionImpl !== "function") {
|
|
1347
|
+
throw new TypeError("[bstage-bridge] sessionImpl\uC740 \uD568\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4");
|
|
1348
|
+
}
|
|
1349
|
+
if (options.otpImpl !== void 0 && typeof options.otpImpl !== "function") {
|
|
1350
|
+
throw new TypeError("[bstage-bridge] otpImpl\uC740 \uD568\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4");
|
|
1351
|
+
}
|
|
957
1352
|
if (options.onTemplateReport !== void 0 && typeof options.onTemplateReport !== "function") {
|
|
958
1353
|
throw new TypeError("[bstage-bridge] onTemplateReport\uB294 \uD568\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4");
|
|
959
1354
|
}
|
|
@@ -1013,7 +1408,16 @@ function createBridgeHost(options) {
|
|
|
1013
1408
|
if (reportsTaken >= REPORTS_PER_SESSION) return false;
|
|
1014
1409
|
reportsTaken += 1;
|
|
1015
1410
|
return true;
|
|
1016
|
-
}
|
|
1411
|
+
},
|
|
1412
|
+
// 권한은 생성 시점의 init으로 한 번 정한다 — 이후 send()로 바뀌지 않는다.
|
|
1413
|
+
account: createAccountSessionHandler({
|
|
1414
|
+
enabled: hasAccountCapability(options.init),
|
|
1415
|
+
hostOrigin,
|
|
1416
|
+
sessionImpl: options.sessionImpl,
|
|
1417
|
+
otpImpl: options.otpImpl,
|
|
1418
|
+
...options.accountStateStore ? { stateStore: options.accountStateStore } : {},
|
|
1419
|
+
scope: `${options.init.spaceId}\0${options.init.placementId}`
|
|
1420
|
+
})
|
|
1017
1421
|
};
|
|
1018
1422
|
function post(target, envelope) {
|
|
1019
1423
|
if (disposed) return;
|
|
@@ -1694,7 +2098,550 @@ function toScriptLiteral(value) {
|
|
|
1694
2098
|
return JSON.stringify(value).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
1695
2099
|
}
|
|
1696
2100
|
|
|
2101
|
+
// ../design/dist/user/index.js
|
|
2102
|
+
var modeColors = {
|
|
2103
|
+
"bg/base": {
|
|
2104
|
+
"dark": "#151515",
|
|
2105
|
+
"light": "#ffffff"
|
|
2106
|
+
},
|
|
2107
|
+
"bg/blue-grey": {
|
|
2108
|
+
"dark": "#1f2023",
|
|
2109
|
+
"light": "#eff1f7"
|
|
2110
|
+
},
|
|
2111
|
+
"bg/elevated": {
|
|
2112
|
+
"dark": "#232323",
|
|
2113
|
+
"light": "#ffffff"
|
|
2114
|
+
},
|
|
2115
|
+
"bg/grouped-strong": {
|
|
2116
|
+
"dark": "#000000",
|
|
2117
|
+
"light": "#f7f7f7"
|
|
2118
|
+
},
|
|
2119
|
+
"bg/grouped-weak": {
|
|
2120
|
+
"dark": "#111111",
|
|
2121
|
+
"light": "#f7f7f7"
|
|
2122
|
+
},
|
|
2123
|
+
"bg/grouped-weak-a": {
|
|
2124
|
+
"dark": "#ffffff0f",
|
|
2125
|
+
"light": "#0000000f"
|
|
2126
|
+
},
|
|
2127
|
+
"bg/highlight": {
|
|
2128
|
+
"dark": "#2f2f2f",
|
|
2129
|
+
"light": "#e6e6e6"
|
|
2130
|
+
},
|
|
2131
|
+
"bg/invert-weak-a": {
|
|
2132
|
+
"dark": "#00000026",
|
|
2133
|
+
"light": "#ffffff26"
|
|
2134
|
+
},
|
|
2135
|
+
"border/blue": {
|
|
2136
|
+
"dark": "#0090ff",
|
|
2137
|
+
"light": "#148aff"
|
|
2138
|
+
},
|
|
2139
|
+
"border/blue-weak-a": {
|
|
2140
|
+
"dark": "#0090ff4d",
|
|
2141
|
+
"light": "#148aff4d"
|
|
2142
|
+
},
|
|
2143
|
+
"border/default-a": {
|
|
2144
|
+
"dark": "#ffffff1a",
|
|
2145
|
+
"light": "#0000001a"
|
|
2146
|
+
},
|
|
2147
|
+
"border/divider-weaker": {
|
|
2148
|
+
"dark": "#0d0d0d",
|
|
2149
|
+
"light": "#f7f7f7"
|
|
2150
|
+
},
|
|
2151
|
+
"border/green": {
|
|
2152
|
+
"dark": "#0be06f",
|
|
2153
|
+
"light": "#00b84d"
|
|
2154
|
+
},
|
|
2155
|
+
"border/green-weak-a": {
|
|
2156
|
+
"dark": "#0be06f4d",
|
|
2157
|
+
"light": "#00b84d4d"
|
|
2158
|
+
},
|
|
2159
|
+
"border/grey": {
|
|
2160
|
+
"dark": "#b3b3b3",
|
|
2161
|
+
"light": "#7a7a7a"
|
|
2162
|
+
},
|
|
2163
|
+
"border/grey-weak-a": {
|
|
2164
|
+
"dark": "#b3b3b34d",
|
|
2165
|
+
"light": "#7a7a7a4d"
|
|
2166
|
+
},
|
|
2167
|
+
"border/invert": {
|
|
2168
|
+
"dark": "#0d0d0d",
|
|
2169
|
+
"light": "#ffffff"
|
|
2170
|
+
},
|
|
2171
|
+
"border/red": {
|
|
2172
|
+
"dark": "#ff4747",
|
|
2173
|
+
"light": "#ff4a40"
|
|
2174
|
+
},
|
|
2175
|
+
"border/red-weak-a": {
|
|
2176
|
+
"dark": "#ff47474d",
|
|
2177
|
+
"light": "#ff4a404d"
|
|
2178
|
+
},
|
|
2179
|
+
"border/strong-a": {
|
|
2180
|
+
"dark": "#ffffff33",
|
|
2181
|
+
"light": "#00000033"
|
|
2182
|
+
},
|
|
2183
|
+
"border/stronger": {
|
|
2184
|
+
"dark": "#eeeeee",
|
|
2185
|
+
"light": "#454545"
|
|
2186
|
+
},
|
|
2187
|
+
"border/weak-a": {
|
|
2188
|
+
"dark": "#ffffff0a",
|
|
2189
|
+
"light": "#0000000f"
|
|
2190
|
+
},
|
|
2191
|
+
"border/yellow": {
|
|
2192
|
+
"dark": "#f5b625",
|
|
2193
|
+
"light": "#f29900"
|
|
2194
|
+
},
|
|
2195
|
+
"border/yellow-weak-a": {
|
|
2196
|
+
"dark": "#f5b6254d",
|
|
2197
|
+
"light": "#f299004d"
|
|
2198
|
+
},
|
|
2199
|
+
"icon/blue": {
|
|
2200
|
+
"dark": "#0090ff",
|
|
2201
|
+
"light": "#148aff"
|
|
2202
|
+
},
|
|
2203
|
+
"icon/green": {
|
|
2204
|
+
"dark": "#0be06f",
|
|
2205
|
+
"light": "#00b84d"
|
|
2206
|
+
},
|
|
2207
|
+
"icon/grey": {
|
|
2208
|
+
"dark": "#b3b3b3",
|
|
2209
|
+
"light": "#7a7a7a"
|
|
2210
|
+
},
|
|
2211
|
+
"icon/invert": {
|
|
2212
|
+
"dark": "#0d0d0d",
|
|
2213
|
+
"light": "#ffffff"
|
|
2214
|
+
},
|
|
2215
|
+
"icon/primary": {
|
|
2216
|
+
"dark": "#ffffff",
|
|
2217
|
+
"light": "#000000"
|
|
2218
|
+
},
|
|
2219
|
+
"icon/quaternary-a": {
|
|
2220
|
+
"dark": "#ffffff4d",
|
|
2221
|
+
"light": "#0000004d"
|
|
2222
|
+
},
|
|
2223
|
+
"icon/red": {
|
|
2224
|
+
"dark": "#ff4747",
|
|
2225
|
+
"light": "#ff4a40"
|
|
2226
|
+
},
|
|
2227
|
+
"icon/secondary-a": {
|
|
2228
|
+
"dark": "#ffffffba",
|
|
2229
|
+
"light": "#000000ba"
|
|
2230
|
+
},
|
|
2231
|
+
"icon/tertiary-a": {
|
|
2232
|
+
"dark": "#ffffff80",
|
|
2233
|
+
"light": "#00000080"
|
|
2234
|
+
},
|
|
2235
|
+
"icon/yellow": {
|
|
2236
|
+
"dark": "#f5b625",
|
|
2237
|
+
"light": "#f29900"
|
|
2238
|
+
},
|
|
2239
|
+
"overlay/hover-a": {
|
|
2240
|
+
"dark": "#ffffff14",
|
|
2241
|
+
"light": "#0000001a"
|
|
2242
|
+
},
|
|
2243
|
+
"overlay/hover-grey-a": {
|
|
2244
|
+
"dark": "#4545451a",
|
|
2245
|
+
"light": "#4545451a"
|
|
2246
|
+
},
|
|
2247
|
+
"overlay/press-a": {
|
|
2248
|
+
"dark": "#ffffff33",
|
|
2249
|
+
"light": "#00000026"
|
|
2250
|
+
},
|
|
2251
|
+
"overlay/press-grey-a": {
|
|
2252
|
+
"dark": "#45454526",
|
|
2253
|
+
"light": "#45454526"
|
|
2254
|
+
},
|
|
2255
|
+
"service/live": {
|
|
2256
|
+
"dark": "#e51a42",
|
|
2257
|
+
"light": "#e2012d"
|
|
2258
|
+
},
|
|
2259
|
+
"service/live-weak-a": {
|
|
2260
|
+
"dark": "#e51a4226",
|
|
2261
|
+
"light": "#e2012d4d"
|
|
2262
|
+
},
|
|
2263
|
+
"service/membership": {
|
|
2264
|
+
"dark": "#ffbf00",
|
|
2265
|
+
"light": "#ffb010"
|
|
2266
|
+
},
|
|
2267
|
+
"service/membership-weak-a": {
|
|
2268
|
+
"dark": "#ffbf001f",
|
|
2269
|
+
"light": "#eb91001f"
|
|
2270
|
+
},
|
|
2271
|
+
"service/noti": {
|
|
2272
|
+
"dark": "#0c198b",
|
|
2273
|
+
"light": "#020f81"
|
|
2274
|
+
},
|
|
2275
|
+
"service/pop-bg": {
|
|
2276
|
+
"dark": "linear-gradient(135deg, #3b3a2d 13.08%, #232732 87.56%)",
|
|
2277
|
+
"light": "linear-gradient(135deg, #faf7de 13.08%, #e7edfd 87.56%)"
|
|
2278
|
+
},
|
|
2279
|
+
"surface/card": {
|
|
2280
|
+
"dark": "#232323",
|
|
2281
|
+
"light": "#ffffff"
|
|
2282
|
+
},
|
|
2283
|
+
"surface/display-bar-bottom": {
|
|
2284
|
+
"dark": "#151515",
|
|
2285
|
+
"light": "#fdfdfd"
|
|
2286
|
+
},
|
|
2287
|
+
"surface/display-bar-top": {
|
|
2288
|
+
"dark": "#151515",
|
|
2289
|
+
"light": "#ffffff"
|
|
2290
|
+
},
|
|
2291
|
+
"surface/display-lock": {
|
|
2292
|
+
"dark": "#2f2f2f",
|
|
2293
|
+
"light": "#bfbfbf"
|
|
2294
|
+
},
|
|
2295
|
+
"surface/form-blue": {
|
|
2296
|
+
"dark": "#0090ff",
|
|
2297
|
+
"light": "#148aff"
|
|
2298
|
+
},
|
|
2299
|
+
"surface/form-blue-weak-a": {
|
|
2300
|
+
"dark": "#0f97ff1f",
|
|
2301
|
+
"light": "#007aff26"
|
|
2302
|
+
},
|
|
2303
|
+
"surface/form-gradient-h": {
|
|
2304
|
+
"dark": "linear-gradient(90deg, #151515 0%, #15151500 100%)",
|
|
2305
|
+
"light": "linear-gradient(90deg, #ffffff 0%, #ffffff00 100%)"
|
|
2306
|
+
},
|
|
2307
|
+
"surface/form-green": {
|
|
2308
|
+
"dark": "#00cc5f",
|
|
2309
|
+
"light": "#00bf59"
|
|
2310
|
+
},
|
|
2311
|
+
"surface/form-green-weak-a": {
|
|
2312
|
+
"dark": "#0be06f14",
|
|
2313
|
+
"light": "#00b84d26"
|
|
2314
|
+
},
|
|
2315
|
+
"surface/form-grey": {
|
|
2316
|
+
"dark": "#7a7a7a",
|
|
2317
|
+
"light": "#999999"
|
|
2318
|
+
},
|
|
2319
|
+
"surface/form-grey-weak-a": {
|
|
2320
|
+
"dark": "#b3b3b314",
|
|
2321
|
+
"light": "#6666661f"
|
|
2322
|
+
},
|
|
2323
|
+
"surface/form-inverted": {
|
|
2324
|
+
"dark": "#f7f7f7",
|
|
2325
|
+
"light": "#151515"
|
|
2326
|
+
},
|
|
2327
|
+
"surface/form-inverted-deep": {
|
|
2328
|
+
"dark": "#ffffff",
|
|
2329
|
+
"light": "#000000"
|
|
2330
|
+
},
|
|
2331
|
+
"surface/form-primary-a": {
|
|
2332
|
+
"dark": "#ffffff0f",
|
|
2333
|
+
"light": "#0000000f"
|
|
2334
|
+
},
|
|
2335
|
+
"surface/form-red": {
|
|
2336
|
+
"dark": "#ff4747",
|
|
2337
|
+
"light": "#ff4a40"
|
|
2338
|
+
},
|
|
2339
|
+
"surface/form-red-weak-a": {
|
|
2340
|
+
"dark": "#ff47471f",
|
|
2341
|
+
"light": "#ff4a4026"
|
|
2342
|
+
},
|
|
2343
|
+
"surface/form-secondary-a": {
|
|
2344
|
+
"dark": "#ffffff0a",
|
|
2345
|
+
"light": "#0000000a"
|
|
2346
|
+
},
|
|
2347
|
+
"surface/form-yellow": {
|
|
2348
|
+
"dark": "#f5b625",
|
|
2349
|
+
"light": "#f29900"
|
|
2350
|
+
},
|
|
2351
|
+
"surface/form-yellow-weak-a": {
|
|
2352
|
+
"dark": "#f5b62514",
|
|
2353
|
+
"light": "#f299001f"
|
|
2354
|
+
},
|
|
2355
|
+
"text/blue": {
|
|
2356
|
+
"dark": "#0090ff",
|
|
2357
|
+
"light": "#148aff"
|
|
2358
|
+
},
|
|
2359
|
+
"text/green": {
|
|
2360
|
+
"dark": "#0be06f",
|
|
2361
|
+
"light": "#00b84d"
|
|
2362
|
+
},
|
|
2363
|
+
"text/grey": {
|
|
2364
|
+
"dark": "#b3b3b3",
|
|
2365
|
+
"light": "#666666"
|
|
2366
|
+
},
|
|
2367
|
+
"text/invert-a": {
|
|
2368
|
+
"dark": "#000000ed",
|
|
2369
|
+
"light": "#ffffffed"
|
|
2370
|
+
},
|
|
2371
|
+
"text/primary": {
|
|
2372
|
+
"dark": "#eeeeee",
|
|
2373
|
+
"light": "#151515"
|
|
2374
|
+
},
|
|
2375
|
+
"text/primary-a": {
|
|
2376
|
+
"dark": "#ffffffed",
|
|
2377
|
+
"light": "#000000ed"
|
|
2378
|
+
},
|
|
2379
|
+
"text/quaternary": {
|
|
2380
|
+
"dark": "#777777",
|
|
2381
|
+
"light": "#999999"
|
|
2382
|
+
},
|
|
2383
|
+
"text/quaternary-a": {
|
|
2384
|
+
"dark": "#ffffff80",
|
|
2385
|
+
"light": "#00000080"
|
|
2386
|
+
},
|
|
2387
|
+
"text/red": {
|
|
2388
|
+
"dark": "#ff4747",
|
|
2389
|
+
"light": "#ff4a40"
|
|
2390
|
+
},
|
|
2391
|
+
"text/secondary": {
|
|
2392
|
+
"dark": "#bababa",
|
|
2393
|
+
"light": "#454545"
|
|
2394
|
+
},
|
|
2395
|
+
"text/secondary-a": {
|
|
2396
|
+
"dark": "#ffffffba",
|
|
2397
|
+
"light": "#000000ba"
|
|
2398
|
+
},
|
|
2399
|
+
"text/tertiary": {
|
|
2400
|
+
"dark": "#999999",
|
|
2401
|
+
"light": "#666666"
|
|
2402
|
+
},
|
|
2403
|
+
"text/tertiary-a": {
|
|
2404
|
+
"dark": "#ffffff99",
|
|
2405
|
+
"light": "#00000099"
|
|
2406
|
+
},
|
|
2407
|
+
"text/yellow": {
|
|
2408
|
+
"dark": "#f5b625",
|
|
2409
|
+
"light": "#f29900"
|
|
2410
|
+
}
|
|
2411
|
+
};
|
|
2412
|
+
var flatColors = {
|
|
2413
|
+
"always/avatar-bg01": "#aa47bc",
|
|
2414
|
+
"always/avatar-bg02": "#7a1fa2",
|
|
2415
|
+
"always/avatar-bg03": "#7e57c2",
|
|
2416
|
+
"always/avatar-bg04": "#512da7",
|
|
2417
|
+
"always/avatar-bg05": "#5c6bc0",
|
|
2418
|
+
"always/avatar-bg06": "#0288d1",
|
|
2419
|
+
"always/avatar-bg07": "#00579c",
|
|
2420
|
+
"always/avatar-bg08": "#0098a6",
|
|
2421
|
+
"always/avatar-bg09": "#00887a",
|
|
2422
|
+
"always/avatar-bg10": "#689f39",
|
|
2423
|
+
"always/avatar-bg11": "#33691e",
|
|
2424
|
+
"always/avatar-bg12": "#004c3f",
|
|
2425
|
+
"always/avatar-bg13": "#ec407a",
|
|
2426
|
+
"always/avatar-bg14": "#c2175b",
|
|
2427
|
+
"always/avatar-bg15": "#bf360c",
|
|
2428
|
+
"always/avatar-bg16": "#f5511e",
|
|
2429
|
+
"always/avatar-bg17": "#ef6c00",
|
|
2430
|
+
"always/avatar-bg18": "#8c6e63",
|
|
2431
|
+
"always/avatar-bg19": "#5d4038",
|
|
2432
|
+
"always/avatar-bg20": "#78909c",
|
|
2433
|
+
"always/avatar-bg21": "#465a65",
|
|
2434
|
+
"always/black006-a": "#0000000f",
|
|
2435
|
+
"always/black010-a": "#0000001a",
|
|
2436
|
+
"always/black015-a": "#00000026",
|
|
2437
|
+
"always/black020-a": "#00000033",
|
|
2438
|
+
"always/black030-a": "#0000004d",
|
|
2439
|
+
"always/black050-a": "#00000080",
|
|
2440
|
+
"always/black060-a": "#00000099",
|
|
2441
|
+
"always/black080-a": "#000000cc",
|
|
2442
|
+
"always/black100": "#000000",
|
|
2443
|
+
"always/grey-strong": "#232323",
|
|
2444
|
+
"always/grey085": "#5c5c5c",
|
|
2445
|
+
"always/lightgrey006-a": "#9999990f",
|
|
2446
|
+
"always/lightgrey010-a": "#9999991a",
|
|
2447
|
+
"always/lightgrey015-a": "#99999926",
|
|
2448
|
+
"always/lightgrey020-a": "#99999933",
|
|
2449
|
+
"always/lightgrey030-a": "#9999994d",
|
|
2450
|
+
"always/lightgrey050-a": "#99999980",
|
|
2451
|
+
"always/lightgrey080-a": "#999999cc",
|
|
2452
|
+
"always/lightgrey100": "#999999",
|
|
2453
|
+
"always/palette05": "linear-gradient(135deg, #db2667 0%, #f4a368 100%)",
|
|
2454
|
+
"always/service-live-pop": "#df3868",
|
|
2455
|
+
"always/service-live-red": "#ff0000",
|
|
2456
|
+
"always/service-mnet": "#ff477f",
|
|
2457
|
+
"always/service-mnetapp": "#ff477f",
|
|
2458
|
+
"always/service-point": "linear-gradient(135deg, #1cac3c 0%, #1ca6bb 100%)",
|
|
2459
|
+
"always/service-pop-ing": "linear-gradient(135deg, #db2667 0%, #f4a368 100%)",
|
|
2460
|
+
"always/service-popgrey-weak-a": "#707ca00f",
|
|
2461
|
+
"always/service-post-thumb-a": "#aa89f5cc",
|
|
2462
|
+
"always/service-rankingpoll-thumb-a": "#FFADDD80",
|
|
2463
|
+
"always/service-red080-a": "#f5254acc",
|
|
2464
|
+
"always/service-survey": "#597eff",
|
|
2465
|
+
"always/service-survey-thumb-a": "#7192f5cc",
|
|
2466
|
+
"always/service-ticket": "#00bf59",
|
|
2467
|
+
"always/white006-a": "#ffffff0f",
|
|
2468
|
+
"always/white010-a": "#ffffff1a",
|
|
2469
|
+
"always/white015-a": "#ffffff26",
|
|
2470
|
+
"always/white020-a": "#ffffff33",
|
|
2471
|
+
"always/white030-a": "#ffffff4d",
|
|
2472
|
+
"always/white050-a": "#ffffff80",
|
|
2473
|
+
"always/white060-a": "#ffffff99",
|
|
2474
|
+
"always/white080-a": "#ffffffcc",
|
|
2475
|
+
"always/white100": "#ffffff",
|
|
2476
|
+
"auto/icon-primary-on-dark": "#ffffff",
|
|
2477
|
+
"auto/icon-primary-on-light": "#000000ed",
|
|
2478
|
+
"auto/icon-secondary-on-dark": "#ffffff",
|
|
2479
|
+
"auto/icon-secondary-on-light": "#000000ba",
|
|
2480
|
+
"auto/text-primary-on-dark": "#ffffff",
|
|
2481
|
+
"auto/text-primary-on-light": "#000000",
|
|
2482
|
+
"auto/text-secondary-on-dark": "#ffffffcc",
|
|
2483
|
+
"auto/text-secondary-on-light": "#000000cc",
|
|
2484
|
+
"picker/button": "#654bff",
|
|
2485
|
+
"picker/button-weak-a": "#654bff26",
|
|
2486
|
+
"picker/on-button": "#ffffff",
|
|
2487
|
+
"picker/star": "#7266ff",
|
|
2488
|
+
"pop/bg-tl01": "#c9d0ea",
|
|
2489
|
+
"pop/bg-tl02": "#f2de6f",
|
|
2490
|
+
"pop/bg-tl03": "#fca783",
|
|
2491
|
+
"pop/bg-tl04": "#a0dda6",
|
|
2492
|
+
"pop/bg-tl05": "#a2bce3",
|
|
2493
|
+
"pop/bg-tl06": "#f7b3cf",
|
|
2494
|
+
"pop/bg-tl07": "#bfa2e3",
|
|
2495
|
+
"pop/bg-tl08": "#fb8686",
|
|
2496
|
+
"pop/bg-tl09": "#eec2c2",
|
|
2497
|
+
"pop/bg-tl10": "#e2d1b0",
|
|
2498
|
+
"pop/bubble-tl01": "#7984b1",
|
|
2499
|
+
"pop/bubble-tl03": "#e3703f",
|
|
2500
|
+
"pop/bubble-tl04": "#5fac70",
|
|
2501
|
+
"pop/bubble-tl05": "#587ab1",
|
|
2502
|
+
"pop/bubble-tl06": "#ca7094",
|
|
2503
|
+
"pop/bubble-tl07": "#8067b5",
|
|
2504
|
+
"pop/bubble-tl08": "#cb4e4e",
|
|
2505
|
+
"pop/bubble-tl09": "#cb8181",
|
|
2506
|
+
"pop/bubble-tl1": "#a79272",
|
|
2507
|
+
"pop/item-gradient01": "linear-gradient(135deg, #fbf3ac 0%, #ffe1fc 100%)",
|
|
2508
|
+
"pop/item-gradient02": "linear-gradient(135deg, #cbe6ff 0%, #d5ffdf 100%)",
|
|
2509
|
+
"pop/item-gradient03": "linear-gradient(135deg, #e4ceff 0%, #ffe4cc 100%)",
|
|
2510
|
+
"pop/item-gradient04": "linear-gradient(135deg, #ffdcb3 0%, #c9f8ff 100%)",
|
|
2511
|
+
"pop/item-gradient05": "linear-gradient(135deg, #ffd0ec 0%, #d3fcff 100%)",
|
|
2512
|
+
"pop/item-gradient06": "linear-gradient(135deg, #feb5b5 0%, #d6fee1 100%)"
|
|
2513
|
+
};
|
|
2514
|
+
var shadowTokens = {
|
|
2515
|
+
"shadow/default-large": {
|
|
2516
|
+
"dark": "0px 1px 2px 0px #00000033, 0px 8px 48px 0px #00000099",
|
|
2517
|
+
"light": "0px 1px 2px 0px #1a1a1a05, 0px 8px 48px 0px #1a1a1a26"
|
|
2518
|
+
},
|
|
2519
|
+
"shadow/default-medium": {
|
|
2520
|
+
"dark": "0px 1px 2px 0px #00000033, 0px 4px 24px 0px #00000066",
|
|
2521
|
+
"light": "0px 1px 2px 0px #00000005, 0px 4px 24px 0px #1a1a1a1a"
|
|
2522
|
+
},
|
|
2523
|
+
"shadow/default-small": {
|
|
2524
|
+
"dark": "0px 1px 2px 0px #0000001a, 0px 2px 8px 0px #00000066",
|
|
2525
|
+
"light": "0px 1px 2px 0px #1a1a1a05, 0px 2px 8px 0px #1a1a1a1a"
|
|
2526
|
+
},
|
|
2527
|
+
"shadow/default-xlarge": {
|
|
2528
|
+
"dark": "0px 1px 2px 0px #00000033, 0px 16px 72px 0px #00000099",
|
|
2529
|
+
"light": "0px 1px 2px 0px #1a1a1a05, 0px 16px 72px 0px #1a1a1a26"
|
|
2530
|
+
},
|
|
2531
|
+
"shadow/default-xsmall": {
|
|
2532
|
+
"dark": "0px 1px 2px 0px #00000033, 0px 0px 4px 0px #00000066",
|
|
2533
|
+
"light": "0px 1px 2px 0px #1a1a1a05, 0px 0px 4px 0px #1a1a1a26"
|
|
2534
|
+
},
|
|
2535
|
+
"shadow/weak-large": {
|
|
2536
|
+
"dark": "0px 1px 2px 0px #0000001a, 0px 8px 48px 0px #00000066",
|
|
2537
|
+
"light": "0px 1px 2px 0px #1a1a1a05, 0px 8px 48px 0px #1a1a1a1f"
|
|
2538
|
+
},
|
|
2539
|
+
"shadow/weak-medium": {
|
|
2540
|
+
"dark": "0px 1px 2px 0px #0000001a, 0px 4px 24px 0px #00000033",
|
|
2541
|
+
"light": "0px 1px 2px 0px #00000005, 0px 4px 20px 0px #1a1a1a14"
|
|
2542
|
+
},
|
|
2543
|
+
"shadow/weak-small": {
|
|
2544
|
+
"dark": "0px 1px 2px 0px #0000001a, 0px 2px 8px 0px #00000033",
|
|
2545
|
+
"light": "0px 1px 2px 0px #1a1a1a05, 0px 2px 8px 0px #1a1a1a14"
|
|
2546
|
+
},
|
|
2547
|
+
"shadow/weak-xlarge": {
|
|
2548
|
+
"dark": "0px 1px 2px 0px #0000001a, 0px 16px 72px 0px #00000066",
|
|
2549
|
+
"light": "0px 1px 2px 0px #1a1a1a05, 0px 16px 72px 0px #1a1a1a1f"
|
|
2550
|
+
},
|
|
2551
|
+
"shadow/weak-xsmall": {
|
|
2552
|
+
"dark": "0px 1px 2px 0px #0000001a, 0px 0px 4px 0px #00000033",
|
|
2553
|
+
"light": "0px 1px 1px 0px #1a1a1a05, 0px 0px 4px 0px #1a1a1a14"
|
|
2554
|
+
}
|
|
2555
|
+
};
|
|
2556
|
+
var fontFamily = "'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'";
|
|
2557
|
+
function cssVarName(slug, prefix, kind) {
|
|
2558
|
+
const s = slug.replace(/\//g, "-");
|
|
2559
|
+
return kind === "mode" ? `--${prefix}-mode-${s}` : `--${prefix}-${s}`;
|
|
2560
|
+
}
|
|
2561
|
+
function cssVarRef(slug, prefix, kind) {
|
|
2562
|
+
return `var(${cssVarName(slug, prefix, kind)})`;
|
|
2563
|
+
}
|
|
2564
|
+
function buildColorTree(modeColors2, flatColors2, prefix) {
|
|
2565
|
+
const tree = {};
|
|
2566
|
+
const add = (slug, kind) => {
|
|
2567
|
+
const [cat, ...rest] = slug.split("/");
|
|
2568
|
+
const leaf = rest.join("/").replace(/\//g, "-") || cat;
|
|
2569
|
+
(tree[cat] ?? (tree[cat] = {}))[leaf] = cssVarRef(slug, prefix, kind);
|
|
2570
|
+
};
|
|
2571
|
+
for (const slug of Object.keys(modeColors2)) add(slug, "mode");
|
|
2572
|
+
for (const slug of Object.keys(flatColors2)) add(slug, "flat");
|
|
2573
|
+
return tree;
|
|
2574
|
+
}
|
|
2575
|
+
function buildShadowRefs(shadowTokens2, prefix) {
|
|
2576
|
+
const out = {};
|
|
2577
|
+
for (const slug of Object.keys(shadowTokens2)) {
|
|
2578
|
+
const leaf = slug.replace(/^shadow\//, "");
|
|
2579
|
+
out[leaf] = cssVarRef(slug, prefix, "mode");
|
|
2580
|
+
}
|
|
2581
|
+
return out;
|
|
2582
|
+
}
|
|
2583
|
+
function colorLines(t, prefix, mode) {
|
|
2584
|
+
return [
|
|
2585
|
+
...Object.entries(t.modeColors).map(
|
|
2586
|
+
([slug, pair]) => ` ${cssVarName(slug, prefix, "mode")}: ${pair[mode]};`
|
|
2587
|
+
),
|
|
2588
|
+
...Object.entries(t.shadowTokens).map(
|
|
2589
|
+
([slug, pair]) => ` ${cssVarName(slug, prefix, "mode")}: ${pair[mode]};`
|
|
2590
|
+
)
|
|
2591
|
+
].join("\n");
|
|
2592
|
+
}
|
|
2593
|
+
function renderFallbackCss(t, opts) {
|
|
2594
|
+
const p = opts.prefix;
|
|
2595
|
+
const flat = Object.entries(t.flatColors).map(([slug, v]) => ` ${cssVarName(slug, p, "flat")}: ${v};`).join("\n");
|
|
2596
|
+
const lightColors = colorLines(t, p, "light");
|
|
2597
|
+
const frame = opts.target === "frame";
|
|
2598
|
+
const header = frame ? `/* bstage \uB514\uC790\uC778 \uD1A0\uD070 \u2014 \uACA9\uB9AC \uD504\uB808\uC784 (${p}). \uD638\uC2A4\uD2B8 :root\uB97C \uC0C1\uC18D\uD558\uC9C0 \uBABB\uD558\uB294 \uD504\uB808\uC784 \uBB38\uC11C\uC6A9 */` : `/* ================================================================
|
|
2599
|
+
* bstage \uB514\uC790\uC778 \uD1A0\uD070 \u2014 dev fallback (${p})
|
|
2600
|
+
* @bstage-sdk/design \uC0DD\uC131\uBB3C. \uAC1C\uBC1C/\uBBF8\uB9AC\uBCF4\uAE30 \uC804\uC6A9(:root fallback).
|
|
2601
|
+
* \uBC30\uD3EC \uC2DC\uC5D4 \uD50C\uB7AB\uD3FC :root \uAC12\uC744 \uC0C1\uC18D\uD558\uBA70 \uC774 \uD30C\uC77C\uC740 \uBC88\uB4E4\uB418\uC9C0 \uC54A\uB294\uB2E4.
|
|
2602
|
+
* ================================================================ */`;
|
|
2603
|
+
let css = `${header}
|
|
2604
|
+
|
|
2605
|
+
:root {
|
|
2606
|
+
${lightColors}
|
|
2607
|
+
|
|
2608
|
+
${flat}
|
|
2609
|
+
|
|
2610
|
+
--${p}-font-family: ${t.fontFamily};
|
|
2611
|
+
}
|
|
2612
|
+
`;
|
|
2613
|
+
if (opts.dark) {
|
|
2614
|
+
const darkColors = colorLines(t, p, "dark");
|
|
2615
|
+
if (!frame) {
|
|
2616
|
+
css += `
|
|
2617
|
+
@media (prefers-color-scheme: dark) {
|
|
2618
|
+
:root:not([data-bspoke="light"]) {
|
|
2619
|
+
${darkColors.replace(/^ {2}/gm, " ")}
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
`;
|
|
2623
|
+
}
|
|
2624
|
+
css += `
|
|
2625
|
+
:root[data-bspoke="dark"],
|
|
2626
|
+
:root.dark {
|
|
2627
|
+
${darkColors}
|
|
2628
|
+
}
|
|
2629
|
+
`;
|
|
2630
|
+
}
|
|
2631
|
+
return css;
|
|
2632
|
+
}
|
|
2633
|
+
var PREFIX = "user";
|
|
2634
|
+
var color = buildColorTree(modeColors, flatColors, PREFIX);
|
|
2635
|
+
var shadow = buildShadowRefs(shadowTokens, PREFIX);
|
|
2636
|
+
function renderFrameCss() {
|
|
2637
|
+
return renderFallbackCss(
|
|
2638
|
+
{ modeColors, flatColors, shadowTokens, fontFamily },
|
|
2639
|
+
{ prefix: PREFIX, dark: true, target: "frame" }
|
|
2640
|
+
);
|
|
2641
|
+
}
|
|
2642
|
+
|
|
1697
2643
|
// src/srcdoc/createSrcdoc.ts
|
|
2644
|
+
var FRAME_TOKEN_CSS = renderFrameCss();
|
|
1698
2645
|
var MAX_MEDIA_ORIGINS = 20;
|
|
1699
2646
|
var REPORT_FLUSH_DELAY_MS = 1e3;
|
|
1700
2647
|
var MAX_ELEMENT_NAME_LENGTH = 100;
|
|
@@ -1775,6 +2722,14 @@ function bootstrapScript(o) {
|
|
|
1775
2722
|
` maxCount: ${REPORT_COUNT_MAX},`,
|
|
1776
2723
|
` flushDelayMs: ${REPORT_FLUSH_DELAY_MS}`,
|
|
1777
2724
|
"});",
|
|
2725
|
+
// 호스트 테마를 프레임 문서에 반영한다(토큰 CSS의 `:root.dark`). 템플릿 코드보다 먼저 구독한다.
|
|
2726
|
+
"function applyTheme(theme) {",
|
|
2727
|
+
" var root = document.documentElement;",
|
|
2728
|
+
" if (!theme || typeof theme.dark !== 'boolean' || !root || !root.classList) return;",
|
|
2729
|
+
" root.classList.toggle('dark', theme.dark);",
|
|
2730
|
+
"}",
|
|
2731
|
+
"client.on('theme', applyTheme);",
|
|
2732
|
+
"client.ready.then(function (init) { applyTheme(init && init.theme); }, function () {});",
|
|
1778
2733
|
"var lastHeight = -1;",
|
|
1779
2734
|
"var scheduled = false;",
|
|
1780
2735
|
"function reportHeight() {",
|
|
@@ -1831,6 +2786,9 @@ function createSrcdoc(options) {
|
|
|
1831
2786
|
if (/<\/script|<!--/i.test(script)) {
|
|
1832
2787
|
throw new Error("[bstage-bridge] \uBD80\uD2B8\uC2A4\uD2B8\uB7A9 \uC2A4\uD06C\uB9BD\uD2B8\uC5D0 \uC2A4\uD06C\uB9BD\uD2B8 \uC885\uB8CC \uC2DC\uD000\uC2A4\uAC00 \uC788\uC2B5\uB2C8\uB2E4");
|
|
1833
2788
|
}
|
|
2789
|
+
if (/<\/style|<!--/i.test(FRAME_TOKEN_CSS)) {
|
|
2790
|
+
throw new Error("[bstage-bridge] \uB514\uC790\uC778 \uD1A0\uD070 CSS\uC5D0 \uC2A4\uD0C0\uC77C \uC885\uB8CC \uC2DC\uD000\uC2A4\uAC00 \uC788\uC2B5\uB2C8\uB2E4");
|
|
2791
|
+
}
|
|
1834
2792
|
return [
|
|
1835
2793
|
"<!doctype html>",
|
|
1836
2794
|
"<html>",
|
|
@@ -1841,7 +2799,10 @@ function createSrcdoc(options) {
|
|
|
1841
2799
|
`<title>${escapeHtml(title)}</title>`,
|
|
1842
2800
|
// body 높이를 콘텐츠 높이로 잰다 — documentElement.scrollHeight는 뷰포트 이상이라 줄어들지 못한다.
|
|
1843
2801
|
// flow-root는 자식 margin이 body 밖으로 접혀 나가 높이에서 빠지는 것을 막는다.
|
|
1844
|
-
|
|
2802
|
+
`<style>${FRAME_TOKEN_CSS}</style>`,
|
|
2803
|
+
// 글자색·글꼴은 호스트와 같은 토큰(inline 배치가 상속받던 값). 배경은 투명 — 호스트 배경이 비친다.
|
|
2804
|
+
// color-scheme은 두지 않는다 — 호스트도 두지 않으며, 다르면 브라우저가 iframe 캔버스를 불투명하게 칠한다.
|
|
2805
|
+
"<style>html,body{margin:0;padding:0;background:transparent;height:auto}body{display:flow-root;color:var(--user-mode-text-primary);font-family:var(--user-font-family)}</style>",
|
|
1845
2806
|
`<script nonce="${escapeHtml(nonce)}">
|
|
1846
2807
|
${script}
|
|
1847
2808
|
</script>`,
|
|
@@ -1852,6 +2813,7 @@ ${script}
|
|
|
1852
2813
|
}
|
|
1853
2814
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1854
2815
|
0 && (module.exports = {
|
|
2816
|
+
ACCOUNT_SESSION_CAPABILITY,
|
|
1855
2817
|
ALLOWED_METHODS,
|
|
1856
2818
|
ALLOWED_REQUEST_HEADERS,
|
|
1857
2819
|
BRIDGE_SURFACES,
|
|
@@ -1860,18 +2822,24 @@ ${script}
|
|
|
1860
2822
|
DEFAULT_POLICY,
|
|
1861
2823
|
HOST_ONLY_HEADERS,
|
|
1862
2824
|
IFRAME_ATTRIBUTES,
|
|
2825
|
+
LOGIN_BINDING_MS,
|
|
1863
2826
|
MAX_DECODE_PASSES,
|
|
1864
2827
|
MAX_PARTNER_ORIGINS,
|
|
1865
2828
|
MAX_PASS_THROUGH_HEADERS,
|
|
2829
|
+
OTP_SEND_PER_MINUTE,
|
|
2830
|
+
OTP_VERIFY_PER_MINUTE,
|
|
1866
2831
|
REPORTS_PER_SESSION,
|
|
1867
2832
|
ROUTING_HEADERS,
|
|
1868
2833
|
ROUTING_HEADER_PREFIXES,
|
|
2834
|
+
SESSION_PER_FRAME,
|
|
2835
|
+
SESSION_PER_MINUTE,
|
|
1869
2836
|
checkPath,
|
|
1870
2837
|
classifyDestination,
|
|
1871
2838
|
createBridgeHost,
|
|
1872
2839
|
createNonce,
|
|
1873
2840
|
createSession,
|
|
1874
2841
|
createSrcdoc,
|
|
2842
|
+
hasAccountCapability,
|
|
1875
2843
|
isAllowedGatewayPath,
|
|
1876
2844
|
isBridgeSurface,
|
|
1877
2845
|
isValidSession,
|
|
@@ -1879,5 +2847,6 @@ ${script}
|
|
|
1879
2847
|
normalizePinnedHeaders,
|
|
1880
2848
|
prepareFetch,
|
|
1881
2849
|
resolveDestination,
|
|
1882
|
-
resolvePolicy
|
|
2850
|
+
resolvePolicy,
|
|
2851
|
+
stripTokenKeys
|
|
1883
2852
|
});
|