@sayren/storefront-sdk 0.3.0 → 0.4.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.
@@ -1,4 +1,4 @@
1
- import { a as AnonymousSession, c as TokenPair, o as LoginRequest, s as SignupRequest, t as ApiError } from "../http-DWaRhLfG.mjs";
1
+ import { a as AnonymousSession, c as TokenPair, l as WithdrawRequest, o as LoginRequest, s as SignupRequest, t as ApiError, u as WithdrawalBlockedDetails } from "../http-CxqZxTfE.mjs";
2
2
  //#region src/auth/index.d.ts
3
3
  export interface StorefrontAuthOptions {
4
4
  /** 예: https://api.sayren.app/storefront/v1 */
@@ -37,7 +37,13 @@ export declare function createStorefrontAuth(options: StorefrontAuthOptions): {
37
37
  * 액세스 토큰이 이미 만료됐으면(401) 서버에서 할 일이 없으므로 성공으로 본다.
38
38
  */
39
39
  signOut(accessToken: string): Promise<void>;
40
+ /**
41
+ * 구매자 탈퇴 — 계정·배송지·위시리스트·장바구니·적립금을 지우고 토큰을 모두 무효로 만든다. 되돌릴 수 없다.
42
+ * 주문·리뷰·문의 기록은 스토어가 보관한다. 진행 중인 주문이나 처리 중인 클레임이 있으면
43
+ * 409 `WITHDRAWAL_BLOCKED`(`error.details`: `WithdrawalBlockedDetails`)다. 앱은 성공 후 보관한 토큰을 지운다.
44
+ */
45
+ withdraw(accessToken: string, body: WithdrawRequest): Promise<void>;
40
46
  };
41
47
  export type StorefrontAuth = ReturnType<typeof createStorefrontAuth>;
42
48
  //#endregion
43
- export { type AnonymousSession, ApiError, type LoginRequest, type SignupRequest, type TokenPair };
49
+ export { type AnonymousSession, ApiError, type LoginRequest, type SignupRequest, type TokenPair, type WithdrawRequest, type WithdrawalBlockedDetails };
@@ -1,4 +1,4 @@
1
- import { t as createStorefrontClient, tt as ApiError } from "../client-Xb-2tNKT.mjs";
1
+ import { rt as ApiError, t as createStorefrontClient } from "../client-DHISrvXq.mjs";
2
2
  //#region src/auth/index.ts
3
3
  /**
4
4
  * 구매자 인증 — 화면은 스토어프런트가 그리고, 계정 저장과 인증 처리는 sayren이 한다.
@@ -51,6 +51,14 @@ function createStorefrontAuth(options) {
51
51
  if (error instanceof ApiError && error.status === 401) return;
52
52
  throw error;
53
53
  }
54
+ },
55
+ /**
56
+ * 구매자 탈퇴 — 계정·배송지·위시리스트·장바구니·적립금을 지우고 토큰을 모두 무효로 만든다. 되돌릴 수 없다.
57
+ * 주문·리뷰·문의 기록은 스토어가 보관한다. 진행 중인 주문이나 처리 중인 클레임이 있으면
58
+ * 409 `WITHDRAWAL_BLOCKED`(`error.details`: `WithdrawalBlockedDetails`)다. 앱은 성공 후 보관한 토큰을 지운다.
59
+ */
60
+ withdraw(accessToken, body) {
61
+ return client(accessToken).auth.withdraw(body);
54
62
  }
55
63
  };
56
64
  }
@@ -150,6 +150,21 @@ const anonymousSessionSchema = z.object({
150
150
  /** 이 시각까지 활동이 없으면 만료(ISO 8601). 쓸 때마다 늘어난다 */
151
151
  expiresAt: z.string()
152
152
  });
153
+ /**
154
+ * 구매자 탈퇴 — `POST /auth/withdraw`. 본인 확인으로 비밀번호를 다시 받는다.
155
+ * 진행 중인 주문(결제 대기~배송 중)·클레임·결제가 있으면 409 `WITHDRAWAL_BLOCKED`, 비밀번호가 틀리면
156
+ * 403 `PASSWORD_MISMATCH`다(로그인과 같은 5회 잠금).
157
+ */
158
+ const withdrawRequestSchema = z.object({ password: z.string().min(1) });
159
+ /** `WITHDRAWAL_BLOCKED`의 `error.details` — 탈퇴를 막는 항목 수 */
160
+ const withdrawalBlockedDetailsSchema = z.object({
161
+ /** 결제 대기~배송 중인 주문 상품 */
162
+ inProgressOrderItems: z.number().int(),
163
+ /** 처리 중인 취소·반품·교환 */
164
+ openClaims: z.number().int(),
165
+ /** 승인 중이거나 결제창이 열려 있을 수 있는 결제(결제창은 만료되면 풀린다) */
166
+ pendingPayments: z.number().int()
167
+ });
153
168
  //#endregion
154
169
  //#region src/schemas/cart.ts
155
170
  const cartItemSchema = z.object({
@@ -679,7 +694,9 @@ function createStorefrontClient(options) {
679
694
  signup: (body) => http.request("POST", "/auth/signup", tokenPairSchema, { body: signupRequestSchema.parse(body) }),
680
695
  login: (body) => http.request("POST", "/auth/login", tokenPairSchema, { body: loginRequestSchema.parse(body) }),
681
696
  refresh: (refreshToken) => http.request("POST", "/auth/token/refresh", tokenPairSchema, { body: { refreshToken } }),
682
- logout: () => http.requestVoid("POST", "/auth/logout")
697
+ logout: () => http.requestVoid("POST", "/auth/logout"),
698
+ /** 구매자 탈퇴 — 로그인 상태(accessToken)에서 비밀번호로 본인 확인. 성공하면 토큰은 모두 무효 */
699
+ withdraw: (body) => http.requestVoid("POST", "/auth/withdraw", { body: withdrawRequestSchema.parse(body) })
683
700
  },
684
701
  catalog: {
685
702
  listCategories: () => http.request("GET", "/categories", z.array(categoryNodeSchema)),
@@ -773,4 +790,4 @@ getStatus: (paymentId) => http.request("GET", path`/payments/${paymentId}`, paym
773
790
  };
774
791
  }
775
792
  //#endregion
776
- export { signupRequestSchema as $, PAYMENT_STATUS_VALUES as A, requestPaymentRequestSchema as B, createClaimRequestSchema as C, orderItemStatusSchema as D, claimStatusSchema as E, guestInfoSchema as F, productFacetsSchema as G, categoryNodeSchema as H, paymentMethodSchema as I, cartItemSchema as J, productSortSchema as K, paymentParamsSchema as L, confirmPaymentRequestSchema as M, confirmPaymentResultSchema as N, pageInfoSchema as O, createCheckoutRequestSchema as P, loginRequestSchema as Q, paymentStatusSchema as R, claimTypeSchema as S, myClaimSchema as T, productCardSchema as U, shippingAddressInputSchema as V, productDetailSchema as W, updateCartItemRequestSchema as X, cartSchema as Y, anonymousSessionSchema as Z, publicInquirySchema as _, reviewSummarySchema as a, customerInquirySchema as b, deliveryTrackingSchema as c, orderShippingAddressSchema as d, tokenPairSchema as et, memberAddressRequestSchema as f, createInquiryRequestSchema as g, updateProfileRequestSchema as h, publicReviewSchema as i, unwrapData as it, checkoutSessionSchema as j, pageSchema as k, myOrderItemSchema as l, memberSchema as m, createReviewRequestSchema as n, buildQuery as nt, updateReviewRequestSchema as o, memberAddressSchema as p, addCartItemRequestSchema as q, createReviewResultSchema as r, toApiError as rt, writableReviewSchema as s, createStorefrontClient as t, ApiError as tt, myOrderSchema as u, createCustomerInquiryRequestSchema as v, createClaimResultSchema as w, claimReasonSchema as x, customerInquiryCategorySchema as y, pgParamsSchema as z };
793
+ export { signupRequestSchema as $, PAYMENT_STATUS_VALUES as A, requestPaymentRequestSchema as B, createClaimRequestSchema as C, orderItemStatusSchema as D, claimStatusSchema as E, guestInfoSchema as F, productFacetsSchema as G, categoryNodeSchema as H, paymentMethodSchema as I, cartItemSchema as J, productSortSchema as K, paymentParamsSchema as L, confirmPaymentRequestSchema as M, confirmPaymentResultSchema as N, pageInfoSchema as O, createCheckoutRequestSchema as P, loginRequestSchema as Q, paymentStatusSchema as R, claimTypeSchema as S, myClaimSchema as T, productCardSchema as U, shippingAddressInputSchema as V, productDetailSchema as W, updateCartItemRequestSchema as X, cartSchema as Y, anonymousSessionSchema as Z, publicInquirySchema as _, reviewSummarySchema as a, toApiError as at, customerInquirySchema as b, deliveryTrackingSchema as c, orderShippingAddressSchema as d, tokenPairSchema as et, memberAddressRequestSchema as f, createInquiryRequestSchema as g, updateProfileRequestSchema as h, publicReviewSchema as i, buildQuery as it, checkoutSessionSchema as j, pageSchema as k, myOrderItemSchema as l, memberSchema as m, createReviewRequestSchema as n, withdrawalBlockedDetailsSchema as nt, updateReviewRequestSchema as o, unwrapData as ot, memberAddressSchema as p, addCartItemRequestSchema as q, createReviewResultSchema as r, ApiError as rt, writableReviewSchema as s, createStorefrontClient as t, withdrawRequestSchema as tt, myOrderSchema as u, createCustomerInquiryRequestSchema as v, createClaimResultSchema as w, claimReasonSchema as x, customerInquiryCategorySchema as y, pgParamsSchema as z };
@@ -35,6 +35,22 @@ declare const anonymousSessionSchema: z.ZodObject<{
35
35
  expiresAt: z.ZodString;
36
36
  }, z.core.$strip>;
37
37
  type AnonymousSession = z.infer<typeof anonymousSessionSchema>;
38
+ /**
39
+ * 구매자 탈퇴 — `POST /auth/withdraw`. 본인 확인으로 비밀번호를 다시 받는다.
40
+ * 진행 중인 주문(결제 대기~배송 중)·클레임·결제가 있으면 409 `WITHDRAWAL_BLOCKED`, 비밀번호가 틀리면
41
+ * 403 `PASSWORD_MISMATCH`다(로그인과 같은 5회 잠금).
42
+ */
43
+ declare const withdrawRequestSchema: z.ZodObject<{
44
+ password: z.ZodString;
45
+ }, z.core.$strip>;
46
+ type WithdrawRequest = z.infer<typeof withdrawRequestSchema>;
47
+ /** `WITHDRAWAL_BLOCKED`의 `error.details` — 탈퇴를 막는 항목 수 */
48
+ declare const withdrawalBlockedDetailsSchema: z.ZodObject<{
49
+ inProgressOrderItems: z.ZodNumber;
50
+ openClaims: z.ZodNumber;
51
+ pendingPayments: z.ZodNumber;
52
+ }, z.core.$strip>;
53
+ type WithdrawalBlockedDetails = z.infer<typeof withdrawalBlockedDetailsSchema>;
38
54
  //#endregion
39
55
  //#region src/http.d.ts
40
56
  declare class ApiError extends Error {
@@ -52,4 +68,4 @@ type TokenSource = string | null | undefined | (() => string | null | undefined)
52
68
  type Query = Record<string, string | number | boolean | undefined>;
53
69
  declare function buildQuery(query?: Query): string;
54
70
  //#endregion
55
- export { AnonymousSession as a, TokenPair as c, signupRequestSchema as d, tokenPairSchema as f, buildQuery as i, anonymousSessionSchema as l, Query as n, LoginRequest as o, TokenSource as r, SignupRequest as s, ApiError as t, loginRequestSchema as u };
71
+ export { AnonymousSession as a, TokenPair as c, anonymousSessionSchema as d, loginRequestSchema as f, withdrawalBlockedDetailsSchema as g, withdrawRequestSchema as h, buildQuery as i, WithdrawRequest as l, tokenPairSchema as m, Query as n, LoginRequest as o, signupRequestSchema as p, TokenSource as r, SignupRequest as s, ApiError as t, WithdrawalBlockedDetails as u };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as AnonymousSession, c as TokenPair, d as signupRequestSchema, f as tokenPairSchema, i as buildQuery, l as anonymousSessionSchema, n as Query, o as LoginRequest, r as TokenSource, s as SignupRequest, t as ApiError, u as loginRequestSchema } from "./http-DWaRhLfG.mjs";
1
+ import { a as AnonymousSession, c as TokenPair, d as anonymousSessionSchema, f as loginRequestSchema, g as withdrawalBlockedDetailsSchema, h as withdrawRequestSchema, i as buildQuery, l as WithdrawRequest, m as tokenPairSchema, n as Query, o as LoginRequest, p as signupRequestSchema, r as TokenSource, s as SignupRequest, t as ApiError, u as WithdrawalBlockedDetails } from "./http-CxqZxTfE.mjs";
2
2
  import { z } from "zod";
3
3
  //#region src/analytics-ids.d.ts
4
4
  /**
@@ -701,6 +701,8 @@ export declare function createStorefrontClient(options: StorefrontClientOptions)
701
701
  expiresIn: number;
702
702
  }>;
703
703
  logout: () => Promise<void>;
704
+ /** 구매자 탈퇴 — 로그인 상태(accessToken)에서 비밀번호로 본인 확인. 성공하면 토큰은 모두 무효 */
705
+ withdraw: (body: WithdrawRequest) => Promise<void>;
704
706
  };
705
707
  catalog: {
706
708
  listCategories: () => Promise<CategoryNode[]>;
@@ -1483,4 +1485,4 @@ export declare const deliveryTrackingSchema: z.ZodObject<{
1483
1485
  }, z.core.$strip>;
1484
1486
  export type DeliveryTracking = z.infer<typeof deliveryTrackingSchema>;
1485
1487
  //#endregion
1486
- export { AnonymousSession, ApiError, LoginRequest, type Query, type SessionStorage, SignupRequest, type StorefrontClient, type StorefrontClientOptions, type StorefrontSession, type StorefrontSessionOptions, TokenPair, type TokenSource, anonymousSessionSchema, buildQuery, loginRequestSchema, signupRequestSchema, tokenPairSchema };
1488
+ export { AnonymousSession, ApiError, LoginRequest, type Query, type SessionStorage, SignupRequest, type StorefrontClient, type StorefrontClientOptions, type StorefrontSession, type StorefrontSessionOptions, TokenPair, type TokenSource, WithdrawRequest, WithdrawalBlockedDetails, anonymousSessionSchema, buildQuery, loginRequestSchema, signupRequestSchema, tokenPairSchema, withdrawRequestSchema, withdrawalBlockedDetailsSchema };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as ANALYTICS_VISITOR_HEADER, c as analyticsClientEventSchema, i as ANALYTICS_VISITOR_COOKIE, l as analyticsIdSchema, n as ANALYTICS_SESSION_COOKIE, o as analyticsBatchSchema, r as ANALYTICS_SESSION_HEADER, s as analyticsClientEventNameSchema, t as ANALYTICS_MAX_BATCH_BYTES, u as analyticsServerEventNameSchema } from "./analytics-CgD70OqH.mjs";
2
2
  import { t as analyticsIdsFromCookie } from "./analytics-ids-COElZiI3.mjs";
3
- import { $ as signupRequestSchema, A as PAYMENT_STATUS_VALUES, B as requestPaymentRequestSchema, C as createClaimRequestSchema, D as orderItemStatusSchema, E as claimStatusSchema, F as guestInfoSchema, G as productFacetsSchema, H as categoryNodeSchema, I as paymentMethodSchema, J as cartItemSchema, K as productSortSchema, L as paymentParamsSchema, M as confirmPaymentRequestSchema, N as confirmPaymentResultSchema, O as pageInfoSchema, P as createCheckoutRequestSchema, Q as loginRequestSchema, R as paymentStatusSchema, S as claimTypeSchema, T as myClaimSchema, U as productCardSchema, V as shippingAddressInputSchema, W as productDetailSchema, X as updateCartItemRequestSchema, Y as cartSchema, Z as anonymousSessionSchema, _ as publicInquirySchema, a as reviewSummarySchema, b as customerInquirySchema, c as deliveryTrackingSchema, d as orderShippingAddressSchema, et as tokenPairSchema, f as memberAddressRequestSchema, g as createInquiryRequestSchema, h as updateProfileRequestSchema, i as publicReviewSchema, it as unwrapData, j as checkoutSessionSchema, k as pageSchema, l as myOrderItemSchema, m as memberSchema, n as createReviewRequestSchema, nt as buildQuery, o as updateReviewRequestSchema, p as memberAddressSchema, q as addCartItemRequestSchema, r as createReviewResultSchema, rt as toApiError, s as writableReviewSchema, t as createStorefrontClient, tt as ApiError, u as myOrderSchema, v as createCustomerInquiryRequestSchema, w as createClaimResultSchema, x as claimReasonSchema, y as customerInquiryCategorySchema, z as pgParamsSchema } from "./client-Xb-2tNKT.mjs";
3
+ import { $ as signupRequestSchema, A as PAYMENT_STATUS_VALUES, B as requestPaymentRequestSchema, C as createClaimRequestSchema, D as orderItemStatusSchema, E as claimStatusSchema, F as guestInfoSchema, G as productFacetsSchema, H as categoryNodeSchema, I as paymentMethodSchema, J as cartItemSchema, K as productSortSchema, L as paymentParamsSchema, M as confirmPaymentRequestSchema, N as confirmPaymentResultSchema, O as pageInfoSchema, P as createCheckoutRequestSchema, Q as loginRequestSchema, R as paymentStatusSchema, S as claimTypeSchema, T as myClaimSchema, U as productCardSchema, V as shippingAddressInputSchema, W as productDetailSchema, X as updateCartItemRequestSchema, Y as cartSchema, Z as anonymousSessionSchema, _ as publicInquirySchema, a as reviewSummarySchema, at as toApiError, b as customerInquirySchema, c as deliveryTrackingSchema, d as orderShippingAddressSchema, et as tokenPairSchema, f as memberAddressRequestSchema, g as createInquiryRequestSchema, h as updateProfileRequestSchema, i as publicReviewSchema, it as buildQuery, j as checkoutSessionSchema, k as pageSchema, l as myOrderItemSchema, m as memberSchema, n as createReviewRequestSchema, nt as withdrawalBlockedDetailsSchema, o as updateReviewRequestSchema, ot as unwrapData, p as memberAddressSchema, q as addCartItemRequestSchema, r as createReviewResultSchema, rt as ApiError, s as writableReviewSchema, t as createStorefrontClient, tt as withdrawRequestSchema, u as myOrderSchema, v as createCustomerInquiryRequestSchema, w as createClaimResultSchema, x as claimReasonSchema, y as customerInquiryCategorySchema, z as pgParamsSchema } from "./client-DHISrvXq.mjs";
4
4
  //#region src/session.ts
5
5
  /** 세션 키 상수 — SDK가 소유한다. store-sdk와 겹치지 않는 별도 네임스페이스. */
6
6
  const STOREFRONT_SESSION_KEYS = {
@@ -124,4 +124,4 @@ function createStorefrontSession(options) {
124
124
  };
125
125
  }
126
126
  //#endregion
127
- export { ANALYTICS_MAX_BATCH_BYTES, ANALYTICS_SESSION_COOKIE, ANALYTICS_SESSION_HEADER, ANALYTICS_VISITOR_COOKIE, ANALYTICS_VISITOR_HEADER, ApiError, PAYMENT_STATUS_VALUES, STOREFRONT_SESSION_KEYS, addCartItemRequestSchema, analyticsBatchSchema, analyticsClientEventNameSchema, analyticsClientEventSchema, analyticsIdSchema, analyticsIdsFromCookie, analyticsServerEventNameSchema, anonymousSessionSchema, buildQuery, cartItemSchema, cartSchema, categoryNodeSchema, checkoutSessionSchema, claimReasonSchema, claimStatusSchema, claimTypeSchema, confirmPaymentRequestSchema, confirmPaymentResultSchema, createCheckoutRequestSchema, createClaimRequestSchema, createClaimResultSchema, createCustomerInquiryRequestSchema, createInquiryRequestSchema, createReviewRequestSchema, createReviewResultSchema, createStorefrontClient, createStorefrontSession, customerInquiryCategorySchema, customerInquirySchema, deliveryTrackingSchema, guestInfoSchema, loginRequestSchema, memberAddressRequestSchema, memberAddressSchema, memberSchema, myClaimSchema, myOrderItemSchema, myOrderSchema, orderItemStatusSchema, orderShippingAddressSchema, pageInfoSchema, pageSchema, paymentMethodSchema, paymentParamsSchema, paymentStatusSchema, pgParamsSchema, productCardSchema, productDetailSchema, productFacetsSchema, productSortSchema, publicInquirySchema, publicReviewSchema, requestPaymentRequestSchema, reviewSummarySchema, shippingAddressInputSchema, signupRequestSchema, tokenPairSchema, updateCartItemRequestSchema, updateProfileRequestSchema, updateReviewRequestSchema, writableReviewSchema };
127
+ export { ANALYTICS_MAX_BATCH_BYTES, ANALYTICS_SESSION_COOKIE, ANALYTICS_SESSION_HEADER, ANALYTICS_VISITOR_COOKIE, ANALYTICS_VISITOR_HEADER, ApiError, PAYMENT_STATUS_VALUES, STOREFRONT_SESSION_KEYS, addCartItemRequestSchema, analyticsBatchSchema, analyticsClientEventNameSchema, analyticsClientEventSchema, analyticsIdSchema, analyticsIdsFromCookie, analyticsServerEventNameSchema, anonymousSessionSchema, buildQuery, cartItemSchema, cartSchema, categoryNodeSchema, checkoutSessionSchema, claimReasonSchema, claimStatusSchema, claimTypeSchema, confirmPaymentRequestSchema, confirmPaymentResultSchema, createCheckoutRequestSchema, createClaimRequestSchema, createClaimResultSchema, createCustomerInquiryRequestSchema, createInquiryRequestSchema, createReviewRequestSchema, createReviewResultSchema, createStorefrontClient, createStorefrontSession, customerInquiryCategorySchema, customerInquirySchema, deliveryTrackingSchema, guestInfoSchema, loginRequestSchema, memberAddressRequestSchema, memberAddressSchema, memberSchema, myClaimSchema, myOrderItemSchema, myOrderSchema, orderItemStatusSchema, orderShippingAddressSchema, pageInfoSchema, pageSchema, paymentMethodSchema, paymentParamsSchema, paymentStatusSchema, pgParamsSchema, productCardSchema, productDetailSchema, productFacetsSchema, productSortSchema, publicInquirySchema, publicReviewSchema, requestPaymentRequestSchema, reviewSummarySchema, shippingAddressInputSchema, signupRequestSchema, tokenPairSchema, updateCartItemRequestSchema, updateProfileRequestSchema, updateReviewRequestSchema, withdrawRequestSchema, withdrawalBlockedDetailsSchema, writableReviewSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sayren/storefront-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "main": "./dist/index.mjs",
5
5
  "types": "./dist/index.d.mts",
6
6
  "exports": {
package/src/auth/index.ts CHANGED
@@ -1,10 +1,23 @@
1
1
  import { createStorefrontClient } from "../client";
2
2
  import { ApiError } from "../http";
3
- import type { AnonymousSession, LoginRequest, SignupRequest, TokenPair } from "../schemas/auth";
3
+ import type {
4
+ AnonymousSession,
5
+ LoginRequest,
6
+ SignupRequest,
7
+ TokenPair,
8
+ WithdrawRequest,
9
+ } from "../schemas/auth";
4
10
 
5
11
  /** 실패는 모두 이 클래스다 — 메인 엔트리의 `ApiError`와 같은 클래스라 어느 쪽으로 `instanceof`해도 된다 */
6
12
  export { ApiError } from "../http";
7
- export type { AnonymousSession, LoginRequest, SignupRequest, TokenPair } from "../schemas/auth";
13
+ export type {
14
+ AnonymousSession,
15
+ LoginRequest,
16
+ SignupRequest,
17
+ TokenPair,
18
+ WithdrawalBlockedDetails,
19
+ WithdrawRequest,
20
+ } from "../schemas/auth";
8
21
 
9
22
  export interface StorefrontAuthOptions {
10
23
  /** 예: https://api.sayren.app/storefront/v1 */
@@ -68,6 +81,14 @@ export function createStorefrontAuth(options: StorefrontAuthOptions) {
68
81
  throw error;
69
82
  }
70
83
  },
84
+ /**
85
+ * 구매자 탈퇴 — 계정·배송지·위시리스트·장바구니·적립금을 지우고 토큰을 모두 무효로 만든다. 되돌릴 수 없다.
86
+ * 주문·리뷰·문의 기록은 스토어가 보관한다. 진행 중인 주문이나 처리 중인 클레임이 있으면
87
+ * 409 `WITHDRAWAL_BLOCKED`(`error.details`: `WithdrawalBlockedDetails`)다. 앱은 성공 후 보관한 토큰을 지운다.
88
+ */
89
+ withdraw(accessToken: string, body: WithdrawRequest): Promise<void> {
90
+ return client(accessToken).auth.withdraw(body);
91
+ },
71
92
  };
72
93
  }
73
94
 
package/src/client.ts CHANGED
@@ -7,6 +7,8 @@ import {
7
7
  loginRequestSchema,
8
8
  signupRequestSchema,
9
9
  tokenPairSchema,
10
+ type WithdrawRequest,
11
+ withdrawRequestSchema,
10
12
  } from "./schemas/auth";
11
13
  import {
12
14
  type AddCartItemRequest,
@@ -181,6 +183,9 @@ export function createStorefrontClient(options: StorefrontClientOptions) {
181
183
  refresh: (refreshToken: string) =>
182
184
  http.request("POST", "/auth/token/refresh", tokenPairSchema, { body: { refreshToken } }),
183
185
  logout: () => http.requestVoid("POST", "/auth/logout"),
186
+ /** 구매자 탈퇴 — 로그인 상태(accessToken)에서 비밀번호로 본인 확인. 성공하면 토큰은 모두 무효 */
187
+ withdraw: (body: WithdrawRequest) =>
188
+ http.requestVoid("POST", "/auth/withdraw", { body: withdrawRequestSchema.parse(body) }),
184
189
  },
185
190
 
186
191
  catalog: {
@@ -54,3 +54,26 @@ export const anonymousSessionSchema = z.object({
54
54
  });
55
55
 
56
56
  export type AnonymousSession = z.infer<typeof anonymousSessionSchema>;
57
+
58
+ /**
59
+ * 구매자 탈퇴 — `POST /auth/withdraw`. 본인 확인으로 비밀번호를 다시 받는다.
60
+ * 진행 중인 주문(결제 대기~배송 중)·클레임·결제가 있으면 409 `WITHDRAWAL_BLOCKED`, 비밀번호가 틀리면
61
+ * 403 `PASSWORD_MISMATCH`다(로그인과 같은 5회 잠금).
62
+ */
63
+ export const withdrawRequestSchema = z.object({
64
+ password: z.string().min(1),
65
+ });
66
+
67
+ export type WithdrawRequest = z.infer<typeof withdrawRequestSchema>;
68
+
69
+ /** `WITHDRAWAL_BLOCKED`의 `error.details` — 탈퇴를 막는 항목 수 */
70
+ export const withdrawalBlockedDetailsSchema = z.object({
71
+ /** 결제 대기~배송 중인 주문 상품 */
72
+ inProgressOrderItems: z.number().int(),
73
+ /** 처리 중인 취소·반품·교환 */
74
+ openClaims: z.number().int(),
75
+ /** 승인 중이거나 결제창이 열려 있을 수 있는 결제(결제창은 만료되면 풀린다) */
76
+ pendingPayments: z.number().int(),
77
+ });
78
+
79
+ export type WithdrawalBlockedDetails = z.infer<typeof withdrawalBlockedDetailsSchema>;