@bstage-sdk/bridge 0.14.2 → 0.15.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/dist/host.d.cts CHANGED
@@ -1,7 +1,35 @@
1
- import { f as BridgeHostEventType, e as BridgeEventMap, C as ToastKind, L as LogLevel, l as BridgeSurface, A as ThemeState, S as SlotState, M as MemberState, m as BridgeTranslations, y as TemplateReport } from './messages-Cdjpvu2S.cjs';
2
- export { a as BRIDGE_SURFACES, I as IFRAME_ATTRIBUTES, q as REPORTS_PER_SESSION, z as TemplateReportKind, G as isBridgeSurface } from './messages-Cdjpvu2S.cjs';
1
+ import { h as BridgeHostEventType, g as BridgeEventMap, N as NavigateOptions, Z as ToastKind, L as LogLevel, n as BridgeSurface, Y as ThemeState, T as SlotState, M as MemberState, o as BridgeTranslations, a as AccountHostQuery, b as AccountSpaceInfo, G as ReverificationStatus, J as SessionOp, s as OtpOp, t as OtpPurpose, W as TemplateReport } from './messages-_p1yCNj9.cjs';
2
+ export { A as ACCOUNT_SESSION_CAPABILITY, c as BRIDGE_SURFACES, I as IFRAME_ATTRIBUTES, w as REPORTS_PER_SESSION, X as TemplateReportKind, a1 as isBridgeSurface } from './messages-_p1yCNj9.cjs';
3
3
  export { C as CreateSrcdocOptions, c as createNonce, d as createSession, e as createSrcdoc, f as isValidSession } from './createSrcdoc-DYZk6dDJ.cjs';
4
4
 
5
+ /**
6
+ * 계정 세션 요청(session·otp) 처리. 호스트가 계정 API를 대신 부르고 로그인 쿠키를 호스트에서 설정한다.
7
+ * 이 파일이 지키는 것: 권한 없는 배치에서 닫힘(fail-closed), op·본문 허용 목록, 응답에서 토큰 제거,
8
+ * 가입 직후 로그인의 결속(같은 세션·같은 이메일·1회·60초), 레이트 리밋. 실제 호출은 임베더의 실행기 몫이다.
9
+ */
10
+ /** session 분당 상한 — 구현 선택(가입·로그인은 사람이 한 번씩 누르는 동작). */
11
+ declare const SESSION_PER_MINUTE = 5;
12
+ /** 프레임 세션(호스트 하나)당 session 총 상한. */
13
+ declare const SESSION_PER_FRAME = 20;
14
+ /** otp 발송 분당 상한 — 편의 제한일 뿐 통제가 아니다(리로드로 초기화). 정본은 게이트웨이의 번호·IP 제한. */
15
+ declare const OTP_SEND_PER_MINUTE = 3;
16
+ /** otp 확인 분당 상한. */
17
+ declare const OTP_VERIFY_PER_MINUTE = 10;
18
+ /** 가입이 LOGIN_REQUIRED를 돌려준 뒤 loginAfterSignup을 허용하는 시간. */
19
+ declare const LOGIN_BINDING_MS = 60000;
20
+ /** 이름에 token이 들어간 키를 깊이와 무관하게 지운 사본. 허용 목록이 놓친 새 필드에 대한 2차 방어. */
21
+ declare function stripTokenKeys(value: unknown, depth?: number): unknown;
22
+ /** 이 배치가 계정 세션 요청을 열 수 있는가 — 권한 값과 page 배치를 함께 본다. */
23
+ declare function hasAccountCapability(init: BridgeInitInput): boolean;
24
+ /**
25
+ * 계정 상한 상태 저장소 — 호스트 페이지 쪽 문자열 저장소. 리로드(호스트 재생성)로 상한이 초기화되지 않게
26
+ * 같은 탭 안에서 상태를 잇는다. 편의 제한을 단단하게 할 뿐 정본 통제는 서버 쪽 제한이다.
27
+ */
28
+ interface AccountStateStore {
29
+ get(): string | null;
30
+ set(value: string): void;
31
+ }
32
+
5
33
  /** 호스트 fetch 정책. */
6
34
  interface BridgePolicy {
7
35
  /** 같은 origin에서 허용할 경로 접두사. 기본 `["/gw/"]`(`/gw` 정확 일치 포함). */
@@ -180,10 +208,52 @@ interface BridgeInitInput {
180
208
  readonly member: MemberState;
181
209
  readonly partnerOrigins: readonly string[];
182
210
  readonly translations?: BridgeTranslations;
211
+ /**
212
+ * 이 배치에 허용된 기능. `account-session`이 있고 page 배치일 때만 계정 세션 요청(session·otp)을 처리한다.
213
+ * 판정 근거는 호스트가 가진 배치 설정이어야 한다 — manifest·프레임 메시지를 근거로 채우지 말 것.
214
+ */
215
+ readonly capabilities?: readonly string[];
216
+ /** 아래 계정 필드는 `account-session` 권한이 있을 때만 init에 실린다(허용 키·형만). */
217
+ readonly query?: AccountHostQuery;
218
+ readonly country?: string;
219
+ readonly space?: AccountSpaceInfo;
220
+ /** 재인증 임시토큰 보관 상태 — 토큰 값은 넣지 않는다(호스트가 실행기 안에서 보관한다). */
221
+ readonly reverification?: ReverificationStatus;
183
222
  }
223
+ /**
224
+ * 계정 세션 실행기 — 임베더(플랫폼)가 구현한다. 브리지가 op·본문을 허용 목록으로 다시 만든 뒤 부른다.
225
+ * 실행기는 정해진 계정 엔드포인트만 부르고(인증 헤더 없는 전용 fetch), 성공하면 호스트에서 로그인 쿠키를
226
+ * 설정한다. 돌려준 객체는 브리지가 다시 허용 목록(`ok·status·code·message·httpStatus·createdAt·next`)으로
227
+ * 거르고 이름에 token이 든 키를 지운다 — 그래도 토큰을 담아 돌려주지 말 것.
228
+ */
229
+ type SessionImpl = (op: SessionOp, body: Readonly<Record<string, unknown>>) => Promise<{
230
+ readonly ok: boolean;
231
+ readonly status?: string;
232
+ readonly code?: number;
233
+ readonly message?: string;
234
+ readonly httpStatus?: number;
235
+ readonly createdAt?: string;
236
+ /** 성공 뒤 프레임이 전체 리로드로 이동할 같은 origin 경로. */
237
+ readonly next?: {
238
+ readonly path: string;
239
+ };
240
+ }>;
241
+ /** SMS OTP 실행기 — 목적지 게이트웨이는 임베더가 phase로 정한다. purpose는 브리지가 op에서 고정해 넘긴다. */
242
+ type OtpImpl = (request: {
243
+ readonly op: OtpOp;
244
+ readonly endpoint: 'send' | 'verify';
245
+ readonly purpose: OtpPurpose;
246
+ readonly body: Readonly<Record<string, unknown>>;
247
+ }) => Promise<{
248
+ readonly ok: boolean;
249
+ readonly status: number;
250
+ readonly data?: Readonly<Record<string, unknown>>;
251
+ readonly error?: Readonly<Record<string, unknown>>;
252
+ }>;
184
253
  /** 요청별 호스트 처리기. 없으면 해당 요청은 `UNSUPPORTED`(openExternal·log는 기본 동작이 있다). */
185
254
  interface BridgeHostHandlers {
186
- readonly navigate?: (path: string) => void;
255
+ /** 옵션은 프레임이 `replace`·`reload`를 줬을 때만 두 번째 인자로 넘어온다. */
256
+ readonly navigate?: (path: string, options?: NavigateOptions) => void;
187
257
  readonly back?: () => void;
188
258
  /** 없으면 `window.open(url, '_blank', 'noopener,noreferrer')`. */
189
259
  readonly openExternal?: (url: string) => void;
@@ -226,6 +296,15 @@ interface CreateBridgeHostOptions {
226
296
  */
227
297
  readonly pinnedHeaders?: Readonly<Record<string, string>>;
228
298
  readonly handlers?: BridgeHostHandlers;
299
+ /** 계정 세션 실행기. `init.capabilities`에 `account-session`이 없으면 주입돼 있어도 부르지 않는다(NOT_ALLOWED). */
300
+ readonly sessionImpl?: SessionImpl;
301
+ /** SMS OTP 실행기. 권한 조건은 sessionImpl과 같다. */
302
+ readonly otpImpl?: OtpImpl;
303
+ /**
304
+ * 계정 상한·카운터 저장소. 리로드로 호스트가 다시 만들어져도 상한이 이어지게 한다. 생략하면 호스트 탭의
305
+ * sessionStorage(접근 불가면 메모리). 테스트·SSR에서 바꿔 끼운다.
306
+ */
307
+ readonly accountStateStore?: AccountStateStore;
229
308
  readonly policy?: Partial<BridgePolicy>;
230
309
  /**
231
310
  * 호스트가 dispose될 때 한 번 불린다. `frame-unload`(프레임 문서가 내려감)·`frame-mismatch`(토큰이 없거나 다른
@@ -299,4 +378,4 @@ interface PathCheck {
299
378
  */
300
379
  declare function checkPath(pathname: string, options?: PathCheckOptions): PathCheck;
301
380
 
302
- export { ALLOWED_METHODS, ALLOWED_REQUEST_HEADERS, type BridgeDisposeReason, type BridgeHost, type BridgeHostHandlers, type BridgeInitInput, type BridgePolicy, BridgeSurface, CREDENTIAL_HEADERS, type CreateBridgeHostOptions, DEFAULT_GATEWAY_DENY_SEGMENTS, DEFAULT_POLICY, type Destination, type DestinationContext, type DestinationKind, type FrameWindow, HOST_ONLY_HEADERS, type HostFetch, type HostWindow, type IframeLike, MAX_DECODE_PASSES, MAX_PARTNER_ORIGINS, MAX_PASS_THROUGH_HEADERS, type MessageEventLike, type PathCheck, type PathCheckOptions, type PreparedFetch, ROUTING_HEADERS, ROUTING_HEADER_PREFIXES, TemplateReport, checkPath, classifyDestination, createBridgeHost, isAllowedGatewayPath, normalizePartnerOrigins, normalizePinnedHeaders, prepareFetch, resolveDestination, resolvePolicy };
381
+ export { ALLOWED_METHODS, ALLOWED_REQUEST_HEADERS, type BridgeDisposeReason, type BridgeHost, type BridgeHostHandlers, type BridgeInitInput, type BridgePolicy, BridgeSurface, CREDENTIAL_HEADERS, type CreateBridgeHostOptions, DEFAULT_GATEWAY_DENY_SEGMENTS, DEFAULT_POLICY, type Destination, type DestinationContext, type DestinationKind, type FrameWindow, HOST_ONLY_HEADERS, type HostFetch, type HostWindow, type IframeLike, LOGIN_BINDING_MS, MAX_DECODE_PASSES, MAX_PARTNER_ORIGINS, MAX_PASS_THROUGH_HEADERS, type MessageEventLike, NavigateOptions, OTP_SEND_PER_MINUTE, OTP_VERIFY_PER_MINUTE, type OtpImpl, OtpOp, OtpPurpose, type PathCheck, type PathCheckOptions, type PreparedFetch, ROUTING_HEADERS, ROUTING_HEADER_PREFIXES, SESSION_PER_FRAME, SESSION_PER_MINUTE, type SessionImpl, SessionOp, TemplateReport, checkPath, classifyDestination, createBridgeHost, hasAccountCapability, isAllowedGatewayPath, normalizePartnerOrigins, normalizePinnedHeaders, prepareFetch, resolveDestination, resolvePolicy, stripTokenKeys };
package/dist/host.d.ts CHANGED
@@ -1,7 +1,35 @@
1
- import { f as BridgeHostEventType, e as BridgeEventMap, C as ToastKind, L as LogLevel, l as BridgeSurface, A as ThemeState, S as SlotState, M as MemberState, m as BridgeTranslations, y as TemplateReport } from './messages-Cdjpvu2S.js';
2
- export { a as BRIDGE_SURFACES, I as IFRAME_ATTRIBUTES, q as REPORTS_PER_SESSION, z as TemplateReportKind, G as isBridgeSurface } from './messages-Cdjpvu2S.js';
1
+ import { h as BridgeHostEventType, g as BridgeEventMap, N as NavigateOptions, Z as ToastKind, L as LogLevel, n as BridgeSurface, Y as ThemeState, T as SlotState, M as MemberState, o as BridgeTranslations, a as AccountHostQuery, b as AccountSpaceInfo, G as ReverificationStatus, J as SessionOp, s as OtpOp, t as OtpPurpose, W as TemplateReport } from './messages-_p1yCNj9.js';
2
+ export { A as ACCOUNT_SESSION_CAPABILITY, c as BRIDGE_SURFACES, I as IFRAME_ATTRIBUTES, w as REPORTS_PER_SESSION, X as TemplateReportKind, a1 as isBridgeSurface } from './messages-_p1yCNj9.js';
3
3
  export { C as CreateSrcdocOptions, c as createNonce, d as createSession, e as createSrcdoc, f as isValidSession } from './createSrcdoc-DYZk6dDJ.js';
4
4
 
5
+ /**
6
+ * 계정 세션 요청(session·otp) 처리. 호스트가 계정 API를 대신 부르고 로그인 쿠키를 호스트에서 설정한다.
7
+ * 이 파일이 지키는 것: 권한 없는 배치에서 닫힘(fail-closed), op·본문 허용 목록, 응답에서 토큰 제거,
8
+ * 가입 직후 로그인의 결속(같은 세션·같은 이메일·1회·60초), 레이트 리밋. 실제 호출은 임베더의 실행기 몫이다.
9
+ */
10
+ /** session 분당 상한 — 구현 선택(가입·로그인은 사람이 한 번씩 누르는 동작). */
11
+ declare const SESSION_PER_MINUTE = 5;
12
+ /** 프레임 세션(호스트 하나)당 session 총 상한. */
13
+ declare const SESSION_PER_FRAME = 20;
14
+ /** otp 발송 분당 상한 — 편의 제한일 뿐 통제가 아니다(리로드로 초기화). 정본은 게이트웨이의 번호·IP 제한. */
15
+ declare const OTP_SEND_PER_MINUTE = 3;
16
+ /** otp 확인 분당 상한. */
17
+ declare const OTP_VERIFY_PER_MINUTE = 10;
18
+ /** 가입이 LOGIN_REQUIRED를 돌려준 뒤 loginAfterSignup을 허용하는 시간. */
19
+ declare const LOGIN_BINDING_MS = 60000;
20
+ /** 이름에 token이 들어간 키를 깊이와 무관하게 지운 사본. 허용 목록이 놓친 새 필드에 대한 2차 방어. */
21
+ declare function stripTokenKeys(value: unknown, depth?: number): unknown;
22
+ /** 이 배치가 계정 세션 요청을 열 수 있는가 — 권한 값과 page 배치를 함께 본다. */
23
+ declare function hasAccountCapability(init: BridgeInitInput): boolean;
24
+ /**
25
+ * 계정 상한 상태 저장소 — 호스트 페이지 쪽 문자열 저장소. 리로드(호스트 재생성)로 상한이 초기화되지 않게
26
+ * 같은 탭 안에서 상태를 잇는다. 편의 제한을 단단하게 할 뿐 정본 통제는 서버 쪽 제한이다.
27
+ */
28
+ interface AccountStateStore {
29
+ get(): string | null;
30
+ set(value: string): void;
31
+ }
32
+
5
33
  /** 호스트 fetch 정책. */
6
34
  interface BridgePolicy {
7
35
  /** 같은 origin에서 허용할 경로 접두사. 기본 `["/gw/"]`(`/gw` 정확 일치 포함). */
@@ -180,10 +208,52 @@ interface BridgeInitInput {
180
208
  readonly member: MemberState;
181
209
  readonly partnerOrigins: readonly string[];
182
210
  readonly translations?: BridgeTranslations;
211
+ /**
212
+ * 이 배치에 허용된 기능. `account-session`이 있고 page 배치일 때만 계정 세션 요청(session·otp)을 처리한다.
213
+ * 판정 근거는 호스트가 가진 배치 설정이어야 한다 — manifest·프레임 메시지를 근거로 채우지 말 것.
214
+ */
215
+ readonly capabilities?: readonly string[];
216
+ /** 아래 계정 필드는 `account-session` 권한이 있을 때만 init에 실린다(허용 키·형만). */
217
+ readonly query?: AccountHostQuery;
218
+ readonly country?: string;
219
+ readonly space?: AccountSpaceInfo;
220
+ /** 재인증 임시토큰 보관 상태 — 토큰 값은 넣지 않는다(호스트가 실행기 안에서 보관한다). */
221
+ readonly reverification?: ReverificationStatus;
183
222
  }
223
+ /**
224
+ * 계정 세션 실행기 — 임베더(플랫폼)가 구현한다. 브리지가 op·본문을 허용 목록으로 다시 만든 뒤 부른다.
225
+ * 실행기는 정해진 계정 엔드포인트만 부르고(인증 헤더 없는 전용 fetch), 성공하면 호스트에서 로그인 쿠키를
226
+ * 설정한다. 돌려준 객체는 브리지가 다시 허용 목록(`ok·status·code·message·httpStatus·createdAt·next`)으로
227
+ * 거르고 이름에 token이 든 키를 지운다 — 그래도 토큰을 담아 돌려주지 말 것.
228
+ */
229
+ type SessionImpl = (op: SessionOp, body: Readonly<Record<string, unknown>>) => Promise<{
230
+ readonly ok: boolean;
231
+ readonly status?: string;
232
+ readonly code?: number;
233
+ readonly message?: string;
234
+ readonly httpStatus?: number;
235
+ readonly createdAt?: string;
236
+ /** 성공 뒤 프레임이 전체 리로드로 이동할 같은 origin 경로. */
237
+ readonly next?: {
238
+ readonly path: string;
239
+ };
240
+ }>;
241
+ /** SMS OTP 실행기 — 목적지 게이트웨이는 임베더가 phase로 정한다. purpose는 브리지가 op에서 고정해 넘긴다. */
242
+ type OtpImpl = (request: {
243
+ readonly op: OtpOp;
244
+ readonly endpoint: 'send' | 'verify';
245
+ readonly purpose: OtpPurpose;
246
+ readonly body: Readonly<Record<string, unknown>>;
247
+ }) => Promise<{
248
+ readonly ok: boolean;
249
+ readonly status: number;
250
+ readonly data?: Readonly<Record<string, unknown>>;
251
+ readonly error?: Readonly<Record<string, unknown>>;
252
+ }>;
184
253
  /** 요청별 호스트 처리기. 없으면 해당 요청은 `UNSUPPORTED`(openExternal·log는 기본 동작이 있다). */
185
254
  interface BridgeHostHandlers {
186
- readonly navigate?: (path: string) => void;
255
+ /** 옵션은 프레임이 `replace`·`reload`를 줬을 때만 두 번째 인자로 넘어온다. */
256
+ readonly navigate?: (path: string, options?: NavigateOptions) => void;
187
257
  readonly back?: () => void;
188
258
  /** 없으면 `window.open(url, '_blank', 'noopener,noreferrer')`. */
189
259
  readonly openExternal?: (url: string) => void;
@@ -226,6 +296,15 @@ interface CreateBridgeHostOptions {
226
296
  */
227
297
  readonly pinnedHeaders?: Readonly<Record<string, string>>;
228
298
  readonly handlers?: BridgeHostHandlers;
299
+ /** 계정 세션 실행기. `init.capabilities`에 `account-session`이 없으면 주입돼 있어도 부르지 않는다(NOT_ALLOWED). */
300
+ readonly sessionImpl?: SessionImpl;
301
+ /** SMS OTP 실행기. 권한 조건은 sessionImpl과 같다. */
302
+ readonly otpImpl?: OtpImpl;
303
+ /**
304
+ * 계정 상한·카운터 저장소. 리로드로 호스트가 다시 만들어져도 상한이 이어지게 한다. 생략하면 호스트 탭의
305
+ * sessionStorage(접근 불가면 메모리). 테스트·SSR에서 바꿔 끼운다.
306
+ */
307
+ readonly accountStateStore?: AccountStateStore;
229
308
  readonly policy?: Partial<BridgePolicy>;
230
309
  /**
231
310
  * 호스트가 dispose될 때 한 번 불린다. `frame-unload`(프레임 문서가 내려감)·`frame-mismatch`(토큰이 없거나 다른
@@ -299,4 +378,4 @@ interface PathCheck {
299
378
  */
300
379
  declare function checkPath(pathname: string, options?: PathCheckOptions): PathCheck;
301
380
 
302
- export { ALLOWED_METHODS, ALLOWED_REQUEST_HEADERS, type BridgeDisposeReason, type BridgeHost, type BridgeHostHandlers, type BridgeInitInput, type BridgePolicy, BridgeSurface, CREDENTIAL_HEADERS, type CreateBridgeHostOptions, DEFAULT_GATEWAY_DENY_SEGMENTS, DEFAULT_POLICY, type Destination, type DestinationContext, type DestinationKind, type FrameWindow, HOST_ONLY_HEADERS, type HostFetch, type HostWindow, type IframeLike, MAX_DECODE_PASSES, MAX_PARTNER_ORIGINS, MAX_PASS_THROUGH_HEADERS, type MessageEventLike, type PathCheck, type PathCheckOptions, type PreparedFetch, ROUTING_HEADERS, ROUTING_HEADER_PREFIXES, TemplateReport, checkPath, classifyDestination, createBridgeHost, isAllowedGatewayPath, normalizePartnerOrigins, normalizePinnedHeaders, prepareFetch, resolveDestination, resolvePolicy };
381
+ export { ALLOWED_METHODS, ALLOWED_REQUEST_HEADERS, type BridgeDisposeReason, type BridgeHost, type BridgeHostHandlers, type BridgeInitInput, type BridgePolicy, BridgeSurface, CREDENTIAL_HEADERS, type CreateBridgeHostOptions, DEFAULT_GATEWAY_DENY_SEGMENTS, DEFAULT_POLICY, type Destination, type DestinationContext, type DestinationKind, type FrameWindow, HOST_ONLY_HEADERS, type HostFetch, type HostWindow, type IframeLike, LOGIN_BINDING_MS, MAX_DECODE_PASSES, MAX_PARTNER_ORIGINS, MAX_PASS_THROUGH_HEADERS, type MessageEventLike, NavigateOptions, OTP_SEND_PER_MINUTE, OTP_VERIFY_PER_MINUTE, type OtpImpl, OtpOp, OtpPurpose, type PathCheck, type PathCheckOptions, type PreparedFetch, ROUTING_HEADERS, ROUTING_HEADER_PREFIXES, SESSION_PER_FRAME, SESSION_PER_MINUTE, type SessionImpl, SessionOp, TemplateReport, checkPath, classifyDestination, createBridgeHost, hasAccountCapability, isAllowedGatewayPath, normalizePartnerOrigins, normalizePinnedHeaders, prepareFetch, resolveDestination, resolvePolicy, stripTokenKeys };