@sayren/storefront-sdk 0.2.1 → 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.
- package/dist/analytics/index.mjs +2 -1
- package/dist/{analytics-ids-o0a07Ohr.mjs → analytics-CgD70OqH.mjs} +1 -37
- package/dist/analytics-ids-COElZiI3.mjs +38 -0
- package/dist/auth/index.d.mts +49 -0
- package/dist/auth/index.mjs +66 -0
- package/dist/client-DHISrvXq.mjs +793 -0
- package/dist/http-CxqZxTfE.d.mts +71 -0
- package/dist/index.d.mts +9 -43
- package/dist/index.mjs +4 -762
- package/package.json +6 -1
- package/src/auth/index.ts +95 -0
- package/src/client.ts +13 -1
- package/src/schemas/auth.ts +38 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/schemas/auth.d.ts
|
|
3
|
+
declare const tokenPairSchema: z.ZodObject<{
|
|
4
|
+
accessToken: z.ZodString;
|
|
5
|
+
refreshToken: z.ZodString;
|
|
6
|
+
expiresIn: z.ZodNumber;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
type TokenPair = z.infer<typeof tokenPairSchema>;
|
|
9
|
+
declare const signupRequestSchema: z.ZodObject<{
|
|
10
|
+
email: z.ZodEmail;
|
|
11
|
+
password: z.ZodString;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
14
|
+
agreements: z.ZodObject<{
|
|
15
|
+
terms: z.ZodLiteral<true>;
|
|
16
|
+
privacy: z.ZodLiteral<true>;
|
|
17
|
+
marketing: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
cartToken: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
type SignupRequest = z.infer<typeof signupRequestSchema>;
|
|
22
|
+
declare const loginRequestSchema: z.ZodObject<{
|
|
23
|
+
email: z.ZodEmail;
|
|
24
|
+
password: z.ZodString;
|
|
25
|
+
cartToken: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
type LoginRequest = z.infer<typeof loginRequestSchema>;
|
|
28
|
+
/**
|
|
29
|
+
* 비회원 익명 세션 — `POST /auth/anonymous` 응답. `cartToken`을 `X-Cart-Token` 헤더로 보내면 장바구니와
|
|
30
|
+
* 비회원 주문이 이 세션에 쌓인다. 구매자 계정이 아니므로 `/me/*`에는 쓸 수 없다.
|
|
31
|
+
* 마지막 활동 후 30일이 지나거나 로그인·가입으로 회원 장바구니에 병합되면 더는 쓸 수 없다.
|
|
32
|
+
*/
|
|
33
|
+
declare const anonymousSessionSchema: z.ZodObject<{
|
|
34
|
+
cartToken: z.ZodString;
|
|
35
|
+
expiresAt: z.ZodString;
|
|
36
|
+
}, z.core.$strip>;
|
|
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>;
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/http.d.ts
|
|
56
|
+
declare class ApiError extends Error {
|
|
57
|
+
readonly status: number;
|
|
58
|
+
readonly code: string;
|
|
59
|
+
readonly traceId?: string | undefined;
|
|
60
|
+
readonly body?: unknown | undefined;
|
|
61
|
+
/** 엔벨로프 `$.error.details` — 에러 코드별 보조 데이터. 없으면 undefined */
|
|
62
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
63
|
+
constructor(status: number, code: string, message: string, traceId?: string | undefined, body?: unknown | undefined,
|
|
64
|
+
/** 엔벨로프 `$.error.details` — 에러 코드별 보조 데이터. 없으면 undefined */
|
|
65
|
+
details?: Record<string, unknown> | undefined);
|
|
66
|
+
}
|
|
67
|
+
type TokenSource = string | null | undefined | (() => string | null | undefined);
|
|
68
|
+
type Query = Record<string, string | number | boolean | undefined>;
|
|
69
|
+
declare function buildQuery(query?: Query): string;
|
|
70
|
+
//#endregion
|
|
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,3 +1,4 @@
|
|
|
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";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
//#region src/analytics-ids.d.ts
|
|
3
4
|
/**
|
|
@@ -14,48 +15,6 @@ export declare function analyticsIdsFromCookie(cookieHeader: string | null | und
|
|
|
14
15
|
sessionId?: string;
|
|
15
16
|
};
|
|
16
17
|
//#endregion
|
|
17
|
-
//#region src/http.d.ts
|
|
18
|
-
export declare class ApiError extends Error {
|
|
19
|
-
readonly status: number;
|
|
20
|
-
readonly code: string;
|
|
21
|
-
readonly traceId?: string | undefined;
|
|
22
|
-
readonly body?: unknown | undefined;
|
|
23
|
-
/** 엔벨로프 `$.error.details` — 에러 코드별 보조 데이터. 없으면 undefined */
|
|
24
|
-
readonly details?: Record<string, unknown> | undefined;
|
|
25
|
-
constructor(status: number, code: string, message: string, traceId?: string | undefined, body?: unknown | undefined,
|
|
26
|
-
/** 엔벨로프 `$.error.details` — 에러 코드별 보조 데이터. 없으면 undefined */
|
|
27
|
-
details?: Record<string, unknown> | undefined);
|
|
28
|
-
}
|
|
29
|
-
type TokenSource = string | null | undefined | (() => string | null | undefined);
|
|
30
|
-
type Query = Record<string, string | number | boolean | undefined>;
|
|
31
|
-
export declare function buildQuery(query?: Query): string;
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/schemas/auth.d.ts
|
|
34
|
-
export declare const tokenPairSchema: z.ZodObject<{
|
|
35
|
-
accessToken: z.ZodString;
|
|
36
|
-
refreshToken: z.ZodString;
|
|
37
|
-
expiresIn: z.ZodNumber;
|
|
38
|
-
}, z.core.$strip>;
|
|
39
|
-
export type TokenPair = z.infer<typeof tokenPairSchema>;
|
|
40
|
-
export declare const signupRequestSchema: z.ZodObject<{
|
|
41
|
-
email: z.ZodEmail;
|
|
42
|
-
password: z.ZodString;
|
|
43
|
-
name: z.ZodString;
|
|
44
|
-
phone: z.ZodOptional<z.ZodString>;
|
|
45
|
-
agreements: z.ZodObject<{
|
|
46
|
-
terms: z.ZodLiteral<true>;
|
|
47
|
-
privacy: z.ZodLiteral<true>;
|
|
48
|
-
marketing: z.ZodDefault<z.ZodBoolean>;
|
|
49
|
-
}, z.core.$strip>;
|
|
50
|
-
}, z.core.$strip>;
|
|
51
|
-
export type SignupRequest = z.infer<typeof signupRequestSchema>;
|
|
52
|
-
export declare const loginRequestSchema: z.ZodObject<{
|
|
53
|
-
email: z.ZodEmail;
|
|
54
|
-
password: z.ZodString;
|
|
55
|
-
cartToken: z.ZodOptional<z.ZodString>;
|
|
56
|
-
}, z.core.$strip>;
|
|
57
|
-
export type LoginRequest = z.infer<typeof loginRequestSchema>;
|
|
58
|
-
//#endregion
|
|
59
18
|
//#region src/schemas/cart.d.ts
|
|
60
19
|
export declare const cartItemSchema: z.ZodObject<{
|
|
61
20
|
cartItemId: z.ZodString;
|
|
@@ -721,6 +680,11 @@ export declare function createStorefrontClient(options: StorefrontClientOptions)
|
|
|
721
680
|
joinedAt: string;
|
|
722
681
|
} | null>;
|
|
723
682
|
auth: {
|
|
683
|
+
/** 비회원 익명 세션 발급 — 응답의 cartToken을 `cartToken` 옵션(X-Cart-Token)으로 쓴다 */
|
|
684
|
+
anonymous: () => Promise<{
|
|
685
|
+
cartToken: string;
|
|
686
|
+
expiresAt: string;
|
|
687
|
+
}>;
|
|
724
688
|
signup: (body: SignupRequest) => Promise<{
|
|
725
689
|
accessToken: string;
|
|
726
690
|
refreshToken: string;
|
|
@@ -737,6 +701,8 @@ export declare function createStorefrontClient(options: StorefrontClientOptions)
|
|
|
737
701
|
expiresIn: number;
|
|
738
702
|
}>;
|
|
739
703
|
logout: () => Promise<void>;
|
|
704
|
+
/** 구매자 탈퇴 — 로그인 상태(accessToken)에서 비밀번호로 본인 확인. 성공하면 토큰은 모두 무효 */
|
|
705
|
+
withdraw: (body: WithdrawRequest) => Promise<void>;
|
|
740
706
|
};
|
|
741
707
|
catalog: {
|
|
742
708
|
listCategories: () => Promise<CategoryNode[]>;
|
|
@@ -1519,4 +1485,4 @@ export declare const deliveryTrackingSchema: z.ZodObject<{
|
|
|
1519
1485
|
}, z.core.$strip>;
|
|
1520
1486
|
export type DeliveryTracking = z.infer<typeof deliveryTrackingSchema>;
|
|
1521
1487
|
//#endregion
|
|
1522
|
-
export type
|
|
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 };
|