@konfiqo/storefront-sdk 0.6.0 → 0.7.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/README.md +174 -82
- package/dist/index.cjs +61 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +151 -21
- package/dist/index.d.ts +151 -21
- package/dist/index.js +59 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -159,19 +159,23 @@ interface StoreContact {
|
|
|
159
159
|
/** Contact phone number. */
|
|
160
160
|
phone: string | null;
|
|
161
161
|
}
|
|
162
|
-
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
162
|
+
/**
|
|
163
|
+
* The seller's company details, as entered in the store settings. Use them
|
|
164
|
+
* in an imprint or footer. Each field is null when not set.
|
|
165
|
+
*/
|
|
166
|
+
interface StoreCompany {
|
|
167
|
+
/** Legal title of the company. */
|
|
168
|
+
title: string | null;
|
|
169
|
+
/** Registered address. */
|
|
170
|
+
address: string | null;
|
|
171
|
+
/** Tax office (vergi dairesi). */
|
|
172
|
+
taxOffice: string | null;
|
|
173
|
+
/** Tax number (10 or 11 digits). */
|
|
174
|
+
taxNumber: string | null;
|
|
175
|
+
/** MERSIS number (16 digits). */
|
|
176
|
+
mersisNumber: string | null;
|
|
177
|
+
/** KEP (registered e-mail) address. */
|
|
178
|
+
kepAddress: string | null;
|
|
175
179
|
}
|
|
176
180
|
/** What a cookie is for: necessary ones need no consent. */
|
|
177
181
|
type CookieCategory = 'necessary' | 'analytics' | 'marketing';
|
|
@@ -216,6 +220,62 @@ interface StoreContent {
|
|
|
216
220
|
/** `Markdoc.transform` output (plain objects). Render with `<Content>`. */
|
|
217
221
|
tree: ContentNode;
|
|
218
222
|
}
|
|
223
|
+
/** A blog post as listed (no body). */
|
|
224
|
+
interface BlogPostSummary {
|
|
225
|
+
/** URL slug; the argument of `blog.get`. */
|
|
226
|
+
slug: string;
|
|
227
|
+
title: string;
|
|
228
|
+
/** Short teaser text. */
|
|
229
|
+
summary: string;
|
|
230
|
+
/** Storage key of the cover image, or null. */
|
|
231
|
+
coverImage: string | null;
|
|
232
|
+
/**
|
|
233
|
+
* Media URL of `coverImage`, **relative** (`/v1/media/<key>?pk=<key>`):
|
|
234
|
+
* prefix the API origin, or use `client.media.url(post.coverImage)`.
|
|
235
|
+
*/
|
|
236
|
+
coverImageUrl: string | null;
|
|
237
|
+
/** When the post went live (ISO 8601). */
|
|
238
|
+
publishedAt: string;
|
|
239
|
+
/** When the post last changed (ISO 8601). */
|
|
240
|
+
updatedAt: string;
|
|
241
|
+
}
|
|
242
|
+
/** A blog post with its body. */
|
|
243
|
+
interface BlogPost extends BlogPostSummary {
|
|
244
|
+
/** Description for search engines. The summary when none was written. */
|
|
245
|
+
metaDescription: string;
|
|
246
|
+
/** `Markdoc.transform` output (plain objects). Render with `<Content>`. */
|
|
247
|
+
tree: ContentNode;
|
|
248
|
+
}
|
|
249
|
+
/** `GET /v1/blog`: a page of posts, newest first. */
|
|
250
|
+
interface BlogPostList {
|
|
251
|
+
items: BlogPostSummary[];
|
|
252
|
+
pagination: {
|
|
253
|
+
page: number;
|
|
254
|
+
pageSize: number;
|
|
255
|
+
total: number;
|
|
256
|
+
totalPages: number;
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
/** A legal text kept with a cart or an order: the text the buyer was shown. */
|
|
260
|
+
interface LegalDocument {
|
|
261
|
+
/** Content key, one of {@link LEGAL_KEYS}. */
|
|
262
|
+
key: string;
|
|
263
|
+
title: string;
|
|
264
|
+
/** `Markdoc.transform` output. Render with `<Content>`. */
|
|
265
|
+
tree: ContentNode;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* `POST /v1/carts/:id/agreements`: the order documents filled in for this
|
|
269
|
+
* cart. Show them, then pass `agreementsHash` to `carts.checkout`.
|
|
270
|
+
*/
|
|
271
|
+
interface CartAgreements {
|
|
272
|
+
/** The order number the order will get. Already printed in the documents. */
|
|
273
|
+
orderNumber: string;
|
|
274
|
+
/** The order documents (`legal.preliminary-information`, `legal.distance-sales`). */
|
|
275
|
+
documents: LegalDocument[];
|
|
276
|
+
/** Hash of the shown texts (64 hex characters). Checkout refuses a stale one. */
|
|
277
|
+
agreementsHash: string;
|
|
278
|
+
}
|
|
219
279
|
/** The ad pixels a store configured (ids are validated by the API). */
|
|
220
280
|
interface AdPixels {
|
|
221
281
|
/** Meta Pixel. */
|
|
@@ -252,8 +312,8 @@ interface Store {
|
|
|
252
312
|
theme: ThemeV1 | null;
|
|
253
313
|
/** Contact details. */
|
|
254
314
|
contact: StoreContact;
|
|
255
|
-
/**
|
|
256
|
-
|
|
315
|
+
/** Company details of the seller. */
|
|
316
|
+
company: StoreCompany;
|
|
257
317
|
/** Shipping rules, or null when the store has no shipping configured. */
|
|
258
318
|
shipping: ShippingRules | null;
|
|
259
319
|
/**
|
|
@@ -688,6 +748,8 @@ interface Order {
|
|
|
688
748
|
lines: OrderLine[];
|
|
689
749
|
/** Shipments. */
|
|
690
750
|
shipments: OrderShipment[];
|
|
751
|
+
/** The legal texts the buyer accepted at checkout, as placed. */
|
|
752
|
+
agreements: LegalDocument[];
|
|
691
753
|
}
|
|
692
754
|
/** `POST /v1/account/session`: the signed-in buyer. */
|
|
693
755
|
interface AccountSession {
|
|
@@ -775,8 +837,30 @@ interface RequestCodeOptions extends RequestOptions {
|
|
|
775
837
|
*/
|
|
776
838
|
turnstileToken?: string;
|
|
777
839
|
}
|
|
840
|
+
/**
|
|
841
|
+
* The `agreementsHash` to send when re-opening payment on an `ordered` cart.
|
|
842
|
+
*
|
|
843
|
+
* On an `ordered` cart (the buyer already placed the order and payment is
|
|
844
|
+
* still pending), `carts.agreements` answers `cart_read_only`, so there is no
|
|
845
|
+
* fresh hash to send. Pass this value to `carts.checkout` instead: commerce
|
|
846
|
+
* re-opens the pending payment and does not read the hash on that path.
|
|
847
|
+
*
|
|
848
|
+
* If the old order was cancelled (for example, after a declined payment),
|
|
849
|
+
* commerce answers `agreements_changed` instead. Then call
|
|
850
|
+
* `carts.agreements` again, show the documents, ask the buyer to accept them,
|
|
851
|
+
* and check out with the new `agreementsHash`.
|
|
852
|
+
*/
|
|
853
|
+
declare const REOPEN_AGREEMENTS_HASH: string;
|
|
778
854
|
/** Options of `carts.checkout`. */
|
|
779
855
|
interface CheckoutOptions extends RequestOptions {
|
|
856
|
+
/**
|
|
857
|
+
* The `agreementsHash` of the {@link CartAgreements} the buyer was
|
|
858
|
+
* shown (`carts.agreements`). Sent as the JSON body. Checkout refuses
|
|
859
|
+
* with `agreements_changed` when the cart or a legal text changed since.
|
|
860
|
+
* To re-open payment on an `ordered` cart, pass
|
|
861
|
+
* {@link REOPEN_AGREEMENTS_HASH}.
|
|
862
|
+
*/
|
|
863
|
+
agreementsHash: string;
|
|
780
864
|
/**
|
|
781
865
|
* The checkout challenge token (Cloudflare Turnstile), required when
|
|
782
866
|
* `store.checkoutChallenge` is set. Single-use: get a new one (reset the
|
|
@@ -838,9 +922,22 @@ interface StorefrontClient {
|
|
|
838
922
|
getContent(key: string, options?: RequestOptions): Promise<StoreContent>;
|
|
839
923
|
/** Store information. */
|
|
840
924
|
readonly store: {
|
|
841
|
-
/** `GET /v1/store`: name, language, currency, logo, theme, contact,
|
|
925
|
+
/** `GET /v1/store`: name, language, currency, logo, theme, contact, company details, shipping rules. */
|
|
842
926
|
get(options?: RequestOptions): Promise<Store>;
|
|
843
927
|
};
|
|
928
|
+
/** Blog posts. Only published posts whose time has come are served. */
|
|
929
|
+
readonly blog: {
|
|
930
|
+
/**
|
|
931
|
+
* `GET /v1/blog`: a page of posts, newest first. `pageSize` is 1 to 50
|
|
932
|
+
* (default 12). A page past the end answers an empty `items`.
|
|
933
|
+
*/
|
|
934
|
+
list(query?: {
|
|
935
|
+
page?: number;
|
|
936
|
+
pageSize?: number;
|
|
937
|
+
}, options?: RequestOptions): Promise<BlogPostList>;
|
|
938
|
+
/** `GET /v1/blog/:slug`. Rejects with `blog_post_not_found`. */
|
|
939
|
+
get(slug: string, options?: RequestOptions): Promise<BlogPost>;
|
|
940
|
+
};
|
|
844
941
|
/** Categories. */
|
|
845
942
|
readonly categories: {
|
|
846
943
|
/** `GET /v1/categories`: the active category tree. */
|
|
@@ -885,6 +982,17 @@ interface StorefrontClient {
|
|
|
885
982
|
shippingOptions(cartId: string, options?: RequestOptions): Promise<ShippingOptionList>;
|
|
886
983
|
/** `PUT /v1/carts/:id/shipping-option`: selects a shipping option by id. */
|
|
887
984
|
setShippingOption(cartId: string, optionId: string, options?: RequestOptions): Promise<Cart>;
|
|
985
|
+
/**
|
|
986
|
+
* `POST /v1/carts/:id/agreements`: the order documents (preliminary
|
|
987
|
+
* information and distance sales agreement) filled in with this cart,
|
|
988
|
+
* and their hash. Show the documents, ask the buyer to accept them,
|
|
989
|
+
* then pass the hash to `checkout`. Call it again after any change to
|
|
990
|
+
* the cart. Refuses with `legal_not_confirmed` (the store takes no
|
|
991
|
+
* orders yet), `cart_incomplete`, or `cart_read_only` (the cart is
|
|
992
|
+
* ordered or expired; to re-open payment on an ordered cart, see
|
|
993
|
+
* {@link REOPEN_AGREEMENTS_HASH}).
|
|
994
|
+
*/
|
|
995
|
+
agreements(cartId: string, options?: RequestOptions): Promise<CartAgreements>;
|
|
888
996
|
/**
|
|
889
997
|
* `POST /v1/carts/:id/checkout`: places the order (or re-opens payment
|
|
890
998
|
* for the cart's order) and answers how to present payment. Keep the
|
|
@@ -897,8 +1005,17 @@ interface StorefrontClient {
|
|
|
897
1005
|
* `turnstileToken` (see `renderTurnstile`); tokens are single-use, so
|
|
898
1006
|
* reset the widget after every call. Re-opening payment on an already
|
|
899
1007
|
* ordered cart needs no token.
|
|
1008
|
+
*
|
|
1009
|
+
* `agreementsHash` is required: send the hash from `agreements` that
|
|
1010
|
+
* the buyer accepted. On `agreements_changed`, load the agreements
|
|
1011
|
+
* again, show them and ask the buyer to accept before checking out
|
|
1012
|
+
* with the new hash. This also happens after a declined payment: the
|
|
1013
|
+
* cart opens again and the next order gets a new number. To re-open
|
|
1014
|
+
* payment on an
|
|
1015
|
+
* `ordered` cart, where `agreements` answers `cart_read_only`, pass
|
|
1016
|
+
* {@link REOPEN_AGREEMENTS_HASH}.
|
|
900
1017
|
*/
|
|
901
|
-
checkout(cartId: string, options
|
|
1018
|
+
checkout(cartId: string, options: CheckoutOptions): Promise<CheckoutResult>;
|
|
902
1019
|
};
|
|
903
1020
|
/** Buyer order status. */
|
|
904
1021
|
readonly orders: {
|
|
@@ -967,6 +1084,15 @@ interface StorefrontClient {
|
|
|
967
1084
|
*/
|
|
968
1085
|
declare function createStorefrontClient(options: StorefrontClientOptions): StorefrontClient;
|
|
969
1086
|
|
|
1087
|
+
/**
|
|
1088
|
+
* Content keys of the legal texts. A store keeps each one as content: load
|
|
1089
|
+
* it with `getContent(key)` and render it with `<Content>`. The `legal.`
|
|
1090
|
+
* prefix is reserved for these six keys.
|
|
1091
|
+
*/
|
|
1092
|
+
declare const LEGAL_KEYS: readonly ["legal.kvkk", "legal.privacy", "legal.preliminary-information", "legal.distance-sales", "legal.returns", "legal.cookies"];
|
|
1093
|
+
/** One of {@link LEGAL_KEYS}. */
|
|
1094
|
+
type LegalKey = (typeof LEGAL_KEYS)[number];
|
|
1095
|
+
|
|
970
1096
|
/** `checkout_incomplete`: what the cart still lacks. */
|
|
971
1097
|
type CheckoutMissing = 'lines' | 'customer' | 'identityNumber' | 'shippingAddress' | 'shippingOption';
|
|
972
1098
|
/**
|
|
@@ -1011,6 +1137,10 @@ interface StorefrontErrorDetailsMap {
|
|
|
1011
1137
|
checkout_incomplete: {
|
|
1012
1138
|
missing: CheckoutMissing[];
|
|
1013
1139
|
};
|
|
1140
|
+
/** `carts.agreements` on a cart that lacks these parts: collect them first. */
|
|
1141
|
+
cart_incomplete: {
|
|
1142
|
+
missing: CheckoutMissing[];
|
|
1143
|
+
};
|
|
1014
1144
|
/** Let the buyer fix `field`, then check out again. */
|
|
1015
1145
|
invalid_buyer_details: {
|
|
1016
1146
|
field: BuyerDetailField;
|
|
@@ -1041,7 +1171,7 @@ interface StorefrontErrorDetailsMap {
|
|
|
1041
1171
|
};
|
|
1042
1172
|
}
|
|
1043
1173
|
/** Error codes of the Storefront API (the `error` field of an error response). */
|
|
1044
|
-
type StorefrontApiErrorCode = 'store_not_found' | 'origin_not_allowed' | 'invalid_request' | 'invalid_buyer_ip' | 'catalog_unavailable' | 'product_not_found' | 'content_not_found' | 'cart_not_found' | 'variant_not_found' | 'line_not_found' | 'insufficient_stock' | 'quantity_out_of_range' | 'too_many_lines' | 'invalid_shipping_option' | 'cart_read_only' | 'checkout_in_progress' | 'checkout_incomplete' | 'cart_changed' | 'invalid_personalization' | 'out_of_stock' | 'amount_out_of_range' | 'nothing_to_pay' | 'invalid_buyer_details' | 'payment_unavailable' | 'checkout_unavailable' | 'order_not_found' | 'order_unavailable' | 'media_not_found' | 'media_unavailable' | 'challenge_required' | 'challenge_failed' | 'challenge_unavailable' | 'too_many_open_orders' | 'not_signed_in' | 'invalid_code' | 'profile_required' | 'too_many_code_requests' | 'invalid_recovery_token' | 'cart_not_recoverable' | 'unavailable';
|
|
1174
|
+
type StorefrontApiErrorCode = 'store_not_found' | 'origin_not_allowed' | 'invalid_request' | 'invalid_buyer_ip' | 'catalog_unavailable' | 'product_not_found' | 'content_not_found' | 'blog_post_not_found' | 'cart_not_found' | 'variant_not_found' | 'line_not_found' | 'insufficient_stock' | 'quantity_out_of_range' | 'too_many_lines' | 'invalid_shipping_option' | 'cart_read_only' | 'checkout_in_progress' | 'checkout_incomplete' | 'legal_not_confirmed' | 'agreements_changed' | 'cart_incomplete' | 'cart_changed' | 'invalid_personalization' | 'out_of_stock' | 'amount_out_of_range' | 'nothing_to_pay' | 'invalid_buyer_details' | 'payment_unavailable' | 'checkout_unavailable' | 'order_not_found' | 'order_unavailable' | 'media_not_found' | 'media_unavailable' | 'challenge_required' | 'challenge_failed' | 'challenge_unavailable' | 'too_many_open_orders' | 'not_signed_in' | 'invalid_code' | 'profile_required' | 'too_many_code_requests' | 'invalid_recovery_token' | 'cart_not_recoverable' | 'unavailable';
|
|
1045
1175
|
/**
|
|
1046
1176
|
* Codes the SDK assigns itself:
|
|
1047
1177
|
* - `rate_limited` — HTTP 429 without a known `error` code (the throttler);
|
|
@@ -1291,11 +1421,11 @@ interface TurnstileWidget {
|
|
|
1291
1421
|
* Renders a Turnstile widget with the store's `siteKey`
|
|
1292
1422
|
* (`store.checkoutChallenge.siteKey`) into `element`, loading the script
|
|
1293
1423
|
* first if needed. Pass each token from `onToken` to
|
|
1294
|
-
* `carts.checkout(id, { turnstileToken })`, then `reset()`.
|
|
1424
|
+
* `carts.checkout(id, { agreementsHash, turnstileToken })`, then `reset()`.
|
|
1295
1425
|
*/
|
|
1296
1426
|
declare function renderTurnstile(element: HTMLElement, siteKey: string, options: RenderTurnstileOptions): Promise<TurnstileWidget>;
|
|
1297
1427
|
|
|
1298
1428
|
/** Version of the Storefront SDK package. */
|
|
1299
|
-
declare const SDK_VERSION = "0.
|
|
1429
|
+
declare const SDK_VERSION = "0.7.0";
|
|
1300
1430
|
|
|
1301
|
-
export { type Account, type AccountOrder, type AccountProfileInput, type AccountSession, type AdPixels, type AddLineInput, type Address, type AddressInput, type AnyStorefrontError, BUYER_IP_HEADER, type BuyerDetailField, type Cart, type CartCustomer, type CartIdStorage, type CartLine, type CartStatus, type Category, type CategoryGridSection, type CategoryList, type CheckoutChallenge, type CheckoutEmbed, type CheckoutEmbedKind, type CheckoutMissing, type CheckoutOptions, type CheckoutResult, type CheckoutResultBase, type ClosedCheckoutPage, type ClosedCheckoutResult, type ClosedPaymentMount, type ContentNode, type CookieCategory, type CookieInfo, type CookieJar, type CustomerInput, DEFAULT_TIMEOUT_MS, type EmbeddedCheckoutResult, type EmbeddedPaymentMount, type FeaturedProductsSection, type HeroSection, type KnownThemeSection, type MountPaymentOptions, type Order, type OrderLine, type OrderShipment, type OrderStatus, PUBLISHABLE_KEY_HEADER, type Pagination, type PaymentMount, type PaymentPresentation, type PaymentStatus, type Product, type ProductListQuery, type ProductPage, type ProductPersonalization, type ProductVariant, type RedirectCheckoutResult, type RedirectPaymentMount, type RenderTurnstileOptions, type RequestCodeOptions, type RequestOptions, type RichTextSection, SDK_VERSION, STOREFRONT_KEY_HEADER, type SavedAddress, type SavedAddressInput, type ShipmentStatus, type ShippingOption, type ShippingOptionList, type ShippingRules, type Store, type
|
|
1431
|
+
export { type Account, type AccountOrder, type AccountProfileInput, type AccountSession, type AdPixels, type AddLineInput, type Address, type AddressInput, type AnyStorefrontError, BUYER_IP_HEADER, type BlogPost, type BlogPostList, type BlogPostSummary, type BuyerDetailField, type Cart, type CartAgreements, type CartCustomer, type CartIdStorage, type CartLine, type CartStatus, type Category, type CategoryGridSection, type CategoryList, type CheckoutChallenge, type CheckoutEmbed, type CheckoutEmbedKind, type CheckoutMissing, type CheckoutOptions, type CheckoutResult, type CheckoutResultBase, type ClosedCheckoutPage, type ClosedCheckoutResult, type ClosedPaymentMount, type ContentNode, type CookieCategory, type CookieInfo, type CookieJar, type CustomerInput, DEFAULT_TIMEOUT_MS, type EmbeddedCheckoutResult, type EmbeddedPaymentMount, type FeaturedProductsSection, type HeroSection, type KnownThemeSection, LEGAL_KEYS, type LegalDocument, type LegalKey, type MountPaymentOptions, type Order, type OrderLine, type OrderShipment, type OrderStatus, PUBLISHABLE_KEY_HEADER, type Pagination, type PaymentMount, type PaymentPresentation, type PaymentStatus, type Product, type ProductListQuery, type ProductPage, type ProductPersonalization, type ProductVariant, REOPEN_AGREEMENTS_HASH, type RedirectCheckoutResult, type RedirectPaymentMount, type RenderTurnstileOptions, type RequestCodeOptions, type RequestOptions, type RichTextSection, SDK_VERSION, STOREFRONT_KEY_HEADER, type SavedAddress, type SavedAddressInput, type ShipmentStatus, type ShippingOption, type ShippingOptionList, type ShippingRules, type Store, type StoreCompany, type StoreContact, type StoreContent, type StorefrontApiErrorCode, type StorefrontClient, type StorefrontClientErrorCode, type StorefrontClientOptions, StorefrontError, type StorefrontErrorCode, type StorefrontErrorDetails, type StorefrontErrorDetailsMap, THEME_FONTS, TURNSTILE_SCRIPT_URL, TURNSTILE_TOKEN_HEADER, type ThemeColors, type ThemeFont, type ThemeFooter, type ThemeHomepage, type ThemeLink, type ThemeSection, type ThemeSocial, type ThemeV1, type TurnstileApi, type TurnstileWidget, type UnknownThemeSection, type UnsupportedPaymentMount, type UpdateLineInput, type ValidationIssue, cartIdKey, clearCartId, cookieCartStorage, cookiesForHost, createStorefrontClient, formatMoney, isKnownThemeSection, isStorefrontError, loadCartId, loadTurnstile, mountPayment, onDefaultDomain, pixelsForHost, renderTurnstile, saveCartId };
|
package/dist/index.d.ts
CHANGED
|
@@ -159,19 +159,23 @@ interface StoreContact {
|
|
|
159
159
|
/** Contact phone number. */
|
|
160
160
|
phone: string | null;
|
|
161
161
|
}
|
|
162
|
-
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
162
|
+
/**
|
|
163
|
+
* The seller's company details, as entered in the store settings. Use them
|
|
164
|
+
* in an imprint or footer. Each field is null when not set.
|
|
165
|
+
*/
|
|
166
|
+
interface StoreCompany {
|
|
167
|
+
/** Legal title of the company. */
|
|
168
|
+
title: string | null;
|
|
169
|
+
/** Registered address. */
|
|
170
|
+
address: string | null;
|
|
171
|
+
/** Tax office (vergi dairesi). */
|
|
172
|
+
taxOffice: string | null;
|
|
173
|
+
/** Tax number (10 or 11 digits). */
|
|
174
|
+
taxNumber: string | null;
|
|
175
|
+
/** MERSIS number (16 digits). */
|
|
176
|
+
mersisNumber: string | null;
|
|
177
|
+
/** KEP (registered e-mail) address. */
|
|
178
|
+
kepAddress: string | null;
|
|
175
179
|
}
|
|
176
180
|
/** What a cookie is for: necessary ones need no consent. */
|
|
177
181
|
type CookieCategory = 'necessary' | 'analytics' | 'marketing';
|
|
@@ -216,6 +220,62 @@ interface StoreContent {
|
|
|
216
220
|
/** `Markdoc.transform` output (plain objects). Render with `<Content>`. */
|
|
217
221
|
tree: ContentNode;
|
|
218
222
|
}
|
|
223
|
+
/** A blog post as listed (no body). */
|
|
224
|
+
interface BlogPostSummary {
|
|
225
|
+
/** URL slug; the argument of `blog.get`. */
|
|
226
|
+
slug: string;
|
|
227
|
+
title: string;
|
|
228
|
+
/** Short teaser text. */
|
|
229
|
+
summary: string;
|
|
230
|
+
/** Storage key of the cover image, or null. */
|
|
231
|
+
coverImage: string | null;
|
|
232
|
+
/**
|
|
233
|
+
* Media URL of `coverImage`, **relative** (`/v1/media/<key>?pk=<key>`):
|
|
234
|
+
* prefix the API origin, or use `client.media.url(post.coverImage)`.
|
|
235
|
+
*/
|
|
236
|
+
coverImageUrl: string | null;
|
|
237
|
+
/** When the post went live (ISO 8601). */
|
|
238
|
+
publishedAt: string;
|
|
239
|
+
/** When the post last changed (ISO 8601). */
|
|
240
|
+
updatedAt: string;
|
|
241
|
+
}
|
|
242
|
+
/** A blog post with its body. */
|
|
243
|
+
interface BlogPost extends BlogPostSummary {
|
|
244
|
+
/** Description for search engines. The summary when none was written. */
|
|
245
|
+
metaDescription: string;
|
|
246
|
+
/** `Markdoc.transform` output (plain objects). Render with `<Content>`. */
|
|
247
|
+
tree: ContentNode;
|
|
248
|
+
}
|
|
249
|
+
/** `GET /v1/blog`: a page of posts, newest first. */
|
|
250
|
+
interface BlogPostList {
|
|
251
|
+
items: BlogPostSummary[];
|
|
252
|
+
pagination: {
|
|
253
|
+
page: number;
|
|
254
|
+
pageSize: number;
|
|
255
|
+
total: number;
|
|
256
|
+
totalPages: number;
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
/** A legal text kept with a cart or an order: the text the buyer was shown. */
|
|
260
|
+
interface LegalDocument {
|
|
261
|
+
/** Content key, one of {@link LEGAL_KEYS}. */
|
|
262
|
+
key: string;
|
|
263
|
+
title: string;
|
|
264
|
+
/** `Markdoc.transform` output. Render with `<Content>`. */
|
|
265
|
+
tree: ContentNode;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* `POST /v1/carts/:id/agreements`: the order documents filled in for this
|
|
269
|
+
* cart. Show them, then pass `agreementsHash` to `carts.checkout`.
|
|
270
|
+
*/
|
|
271
|
+
interface CartAgreements {
|
|
272
|
+
/** The order number the order will get. Already printed in the documents. */
|
|
273
|
+
orderNumber: string;
|
|
274
|
+
/** The order documents (`legal.preliminary-information`, `legal.distance-sales`). */
|
|
275
|
+
documents: LegalDocument[];
|
|
276
|
+
/** Hash of the shown texts (64 hex characters). Checkout refuses a stale one. */
|
|
277
|
+
agreementsHash: string;
|
|
278
|
+
}
|
|
219
279
|
/** The ad pixels a store configured (ids are validated by the API). */
|
|
220
280
|
interface AdPixels {
|
|
221
281
|
/** Meta Pixel. */
|
|
@@ -252,8 +312,8 @@ interface Store {
|
|
|
252
312
|
theme: ThemeV1 | null;
|
|
253
313
|
/** Contact details. */
|
|
254
314
|
contact: StoreContact;
|
|
255
|
-
/**
|
|
256
|
-
|
|
315
|
+
/** Company details of the seller. */
|
|
316
|
+
company: StoreCompany;
|
|
257
317
|
/** Shipping rules, or null when the store has no shipping configured. */
|
|
258
318
|
shipping: ShippingRules | null;
|
|
259
319
|
/**
|
|
@@ -688,6 +748,8 @@ interface Order {
|
|
|
688
748
|
lines: OrderLine[];
|
|
689
749
|
/** Shipments. */
|
|
690
750
|
shipments: OrderShipment[];
|
|
751
|
+
/** The legal texts the buyer accepted at checkout, as placed. */
|
|
752
|
+
agreements: LegalDocument[];
|
|
691
753
|
}
|
|
692
754
|
/** `POST /v1/account/session`: the signed-in buyer. */
|
|
693
755
|
interface AccountSession {
|
|
@@ -775,8 +837,30 @@ interface RequestCodeOptions extends RequestOptions {
|
|
|
775
837
|
*/
|
|
776
838
|
turnstileToken?: string;
|
|
777
839
|
}
|
|
840
|
+
/**
|
|
841
|
+
* The `agreementsHash` to send when re-opening payment on an `ordered` cart.
|
|
842
|
+
*
|
|
843
|
+
* On an `ordered` cart (the buyer already placed the order and payment is
|
|
844
|
+
* still pending), `carts.agreements` answers `cart_read_only`, so there is no
|
|
845
|
+
* fresh hash to send. Pass this value to `carts.checkout` instead: commerce
|
|
846
|
+
* re-opens the pending payment and does not read the hash on that path.
|
|
847
|
+
*
|
|
848
|
+
* If the old order was cancelled (for example, after a declined payment),
|
|
849
|
+
* commerce answers `agreements_changed` instead. Then call
|
|
850
|
+
* `carts.agreements` again, show the documents, ask the buyer to accept them,
|
|
851
|
+
* and check out with the new `agreementsHash`.
|
|
852
|
+
*/
|
|
853
|
+
declare const REOPEN_AGREEMENTS_HASH: string;
|
|
778
854
|
/** Options of `carts.checkout`. */
|
|
779
855
|
interface CheckoutOptions extends RequestOptions {
|
|
856
|
+
/**
|
|
857
|
+
* The `agreementsHash` of the {@link CartAgreements} the buyer was
|
|
858
|
+
* shown (`carts.agreements`). Sent as the JSON body. Checkout refuses
|
|
859
|
+
* with `agreements_changed` when the cart or a legal text changed since.
|
|
860
|
+
* To re-open payment on an `ordered` cart, pass
|
|
861
|
+
* {@link REOPEN_AGREEMENTS_HASH}.
|
|
862
|
+
*/
|
|
863
|
+
agreementsHash: string;
|
|
780
864
|
/**
|
|
781
865
|
* The checkout challenge token (Cloudflare Turnstile), required when
|
|
782
866
|
* `store.checkoutChallenge` is set. Single-use: get a new one (reset the
|
|
@@ -838,9 +922,22 @@ interface StorefrontClient {
|
|
|
838
922
|
getContent(key: string, options?: RequestOptions): Promise<StoreContent>;
|
|
839
923
|
/** Store information. */
|
|
840
924
|
readonly store: {
|
|
841
|
-
/** `GET /v1/store`: name, language, currency, logo, theme, contact,
|
|
925
|
+
/** `GET /v1/store`: name, language, currency, logo, theme, contact, company details, shipping rules. */
|
|
842
926
|
get(options?: RequestOptions): Promise<Store>;
|
|
843
927
|
};
|
|
928
|
+
/** Blog posts. Only published posts whose time has come are served. */
|
|
929
|
+
readonly blog: {
|
|
930
|
+
/**
|
|
931
|
+
* `GET /v1/blog`: a page of posts, newest first. `pageSize` is 1 to 50
|
|
932
|
+
* (default 12). A page past the end answers an empty `items`.
|
|
933
|
+
*/
|
|
934
|
+
list(query?: {
|
|
935
|
+
page?: number;
|
|
936
|
+
pageSize?: number;
|
|
937
|
+
}, options?: RequestOptions): Promise<BlogPostList>;
|
|
938
|
+
/** `GET /v1/blog/:slug`. Rejects with `blog_post_not_found`. */
|
|
939
|
+
get(slug: string, options?: RequestOptions): Promise<BlogPost>;
|
|
940
|
+
};
|
|
844
941
|
/** Categories. */
|
|
845
942
|
readonly categories: {
|
|
846
943
|
/** `GET /v1/categories`: the active category tree. */
|
|
@@ -885,6 +982,17 @@ interface StorefrontClient {
|
|
|
885
982
|
shippingOptions(cartId: string, options?: RequestOptions): Promise<ShippingOptionList>;
|
|
886
983
|
/** `PUT /v1/carts/:id/shipping-option`: selects a shipping option by id. */
|
|
887
984
|
setShippingOption(cartId: string, optionId: string, options?: RequestOptions): Promise<Cart>;
|
|
985
|
+
/**
|
|
986
|
+
* `POST /v1/carts/:id/agreements`: the order documents (preliminary
|
|
987
|
+
* information and distance sales agreement) filled in with this cart,
|
|
988
|
+
* and their hash. Show the documents, ask the buyer to accept them,
|
|
989
|
+
* then pass the hash to `checkout`. Call it again after any change to
|
|
990
|
+
* the cart. Refuses with `legal_not_confirmed` (the store takes no
|
|
991
|
+
* orders yet), `cart_incomplete`, or `cart_read_only` (the cart is
|
|
992
|
+
* ordered or expired; to re-open payment on an ordered cart, see
|
|
993
|
+
* {@link REOPEN_AGREEMENTS_HASH}).
|
|
994
|
+
*/
|
|
995
|
+
agreements(cartId: string, options?: RequestOptions): Promise<CartAgreements>;
|
|
888
996
|
/**
|
|
889
997
|
* `POST /v1/carts/:id/checkout`: places the order (or re-opens payment
|
|
890
998
|
* for the cart's order) and answers how to present payment. Keep the
|
|
@@ -897,8 +1005,17 @@ interface StorefrontClient {
|
|
|
897
1005
|
* `turnstileToken` (see `renderTurnstile`); tokens are single-use, so
|
|
898
1006
|
* reset the widget after every call. Re-opening payment on an already
|
|
899
1007
|
* ordered cart needs no token.
|
|
1008
|
+
*
|
|
1009
|
+
* `agreementsHash` is required: send the hash from `agreements` that
|
|
1010
|
+
* the buyer accepted. On `agreements_changed`, load the agreements
|
|
1011
|
+
* again, show them and ask the buyer to accept before checking out
|
|
1012
|
+
* with the new hash. This also happens after a declined payment: the
|
|
1013
|
+
* cart opens again and the next order gets a new number. To re-open
|
|
1014
|
+
* payment on an
|
|
1015
|
+
* `ordered` cart, where `agreements` answers `cart_read_only`, pass
|
|
1016
|
+
* {@link REOPEN_AGREEMENTS_HASH}.
|
|
900
1017
|
*/
|
|
901
|
-
checkout(cartId: string, options
|
|
1018
|
+
checkout(cartId: string, options: CheckoutOptions): Promise<CheckoutResult>;
|
|
902
1019
|
};
|
|
903
1020
|
/** Buyer order status. */
|
|
904
1021
|
readonly orders: {
|
|
@@ -967,6 +1084,15 @@ interface StorefrontClient {
|
|
|
967
1084
|
*/
|
|
968
1085
|
declare function createStorefrontClient(options: StorefrontClientOptions): StorefrontClient;
|
|
969
1086
|
|
|
1087
|
+
/**
|
|
1088
|
+
* Content keys of the legal texts. A store keeps each one as content: load
|
|
1089
|
+
* it with `getContent(key)` and render it with `<Content>`. The `legal.`
|
|
1090
|
+
* prefix is reserved for these six keys.
|
|
1091
|
+
*/
|
|
1092
|
+
declare const LEGAL_KEYS: readonly ["legal.kvkk", "legal.privacy", "legal.preliminary-information", "legal.distance-sales", "legal.returns", "legal.cookies"];
|
|
1093
|
+
/** One of {@link LEGAL_KEYS}. */
|
|
1094
|
+
type LegalKey = (typeof LEGAL_KEYS)[number];
|
|
1095
|
+
|
|
970
1096
|
/** `checkout_incomplete`: what the cart still lacks. */
|
|
971
1097
|
type CheckoutMissing = 'lines' | 'customer' | 'identityNumber' | 'shippingAddress' | 'shippingOption';
|
|
972
1098
|
/**
|
|
@@ -1011,6 +1137,10 @@ interface StorefrontErrorDetailsMap {
|
|
|
1011
1137
|
checkout_incomplete: {
|
|
1012
1138
|
missing: CheckoutMissing[];
|
|
1013
1139
|
};
|
|
1140
|
+
/** `carts.agreements` on a cart that lacks these parts: collect them first. */
|
|
1141
|
+
cart_incomplete: {
|
|
1142
|
+
missing: CheckoutMissing[];
|
|
1143
|
+
};
|
|
1014
1144
|
/** Let the buyer fix `field`, then check out again. */
|
|
1015
1145
|
invalid_buyer_details: {
|
|
1016
1146
|
field: BuyerDetailField;
|
|
@@ -1041,7 +1171,7 @@ interface StorefrontErrorDetailsMap {
|
|
|
1041
1171
|
};
|
|
1042
1172
|
}
|
|
1043
1173
|
/** Error codes of the Storefront API (the `error` field of an error response). */
|
|
1044
|
-
type StorefrontApiErrorCode = 'store_not_found' | 'origin_not_allowed' | 'invalid_request' | 'invalid_buyer_ip' | 'catalog_unavailable' | 'product_not_found' | 'content_not_found' | 'cart_not_found' | 'variant_not_found' | 'line_not_found' | 'insufficient_stock' | 'quantity_out_of_range' | 'too_many_lines' | 'invalid_shipping_option' | 'cart_read_only' | 'checkout_in_progress' | 'checkout_incomplete' | 'cart_changed' | 'invalid_personalization' | 'out_of_stock' | 'amount_out_of_range' | 'nothing_to_pay' | 'invalid_buyer_details' | 'payment_unavailable' | 'checkout_unavailable' | 'order_not_found' | 'order_unavailable' | 'media_not_found' | 'media_unavailable' | 'challenge_required' | 'challenge_failed' | 'challenge_unavailable' | 'too_many_open_orders' | 'not_signed_in' | 'invalid_code' | 'profile_required' | 'too_many_code_requests' | 'invalid_recovery_token' | 'cart_not_recoverable' | 'unavailable';
|
|
1174
|
+
type StorefrontApiErrorCode = 'store_not_found' | 'origin_not_allowed' | 'invalid_request' | 'invalid_buyer_ip' | 'catalog_unavailable' | 'product_not_found' | 'content_not_found' | 'blog_post_not_found' | 'cart_not_found' | 'variant_not_found' | 'line_not_found' | 'insufficient_stock' | 'quantity_out_of_range' | 'too_many_lines' | 'invalid_shipping_option' | 'cart_read_only' | 'checkout_in_progress' | 'checkout_incomplete' | 'legal_not_confirmed' | 'agreements_changed' | 'cart_incomplete' | 'cart_changed' | 'invalid_personalization' | 'out_of_stock' | 'amount_out_of_range' | 'nothing_to_pay' | 'invalid_buyer_details' | 'payment_unavailable' | 'checkout_unavailable' | 'order_not_found' | 'order_unavailable' | 'media_not_found' | 'media_unavailable' | 'challenge_required' | 'challenge_failed' | 'challenge_unavailable' | 'too_many_open_orders' | 'not_signed_in' | 'invalid_code' | 'profile_required' | 'too_many_code_requests' | 'invalid_recovery_token' | 'cart_not_recoverable' | 'unavailable';
|
|
1045
1175
|
/**
|
|
1046
1176
|
* Codes the SDK assigns itself:
|
|
1047
1177
|
* - `rate_limited` — HTTP 429 without a known `error` code (the throttler);
|
|
@@ -1291,11 +1421,11 @@ interface TurnstileWidget {
|
|
|
1291
1421
|
* Renders a Turnstile widget with the store's `siteKey`
|
|
1292
1422
|
* (`store.checkoutChallenge.siteKey`) into `element`, loading the script
|
|
1293
1423
|
* first if needed. Pass each token from `onToken` to
|
|
1294
|
-
* `carts.checkout(id, { turnstileToken })`, then `reset()`.
|
|
1424
|
+
* `carts.checkout(id, { agreementsHash, turnstileToken })`, then `reset()`.
|
|
1295
1425
|
*/
|
|
1296
1426
|
declare function renderTurnstile(element: HTMLElement, siteKey: string, options: RenderTurnstileOptions): Promise<TurnstileWidget>;
|
|
1297
1427
|
|
|
1298
1428
|
/** Version of the Storefront SDK package. */
|
|
1299
|
-
declare const SDK_VERSION = "0.
|
|
1429
|
+
declare const SDK_VERSION = "0.7.0";
|
|
1300
1430
|
|
|
1301
|
-
export { type Account, type AccountOrder, type AccountProfileInput, type AccountSession, type AdPixels, type AddLineInput, type Address, type AddressInput, type AnyStorefrontError, BUYER_IP_HEADER, type BuyerDetailField, type Cart, type CartCustomer, type CartIdStorage, type CartLine, type CartStatus, type Category, type CategoryGridSection, type CategoryList, type CheckoutChallenge, type CheckoutEmbed, type CheckoutEmbedKind, type CheckoutMissing, type CheckoutOptions, type CheckoutResult, type CheckoutResultBase, type ClosedCheckoutPage, type ClosedCheckoutResult, type ClosedPaymentMount, type ContentNode, type CookieCategory, type CookieInfo, type CookieJar, type CustomerInput, DEFAULT_TIMEOUT_MS, type EmbeddedCheckoutResult, type EmbeddedPaymentMount, type FeaturedProductsSection, type HeroSection, type KnownThemeSection, type MountPaymentOptions, type Order, type OrderLine, type OrderShipment, type OrderStatus, PUBLISHABLE_KEY_HEADER, type Pagination, type PaymentMount, type PaymentPresentation, type PaymentStatus, type Product, type ProductListQuery, type ProductPage, type ProductPersonalization, type ProductVariant, type RedirectCheckoutResult, type RedirectPaymentMount, type RenderTurnstileOptions, type RequestCodeOptions, type RequestOptions, type RichTextSection, SDK_VERSION, STOREFRONT_KEY_HEADER, type SavedAddress, type SavedAddressInput, type ShipmentStatus, type ShippingOption, type ShippingOptionList, type ShippingRules, type Store, type
|
|
1431
|
+
export { type Account, type AccountOrder, type AccountProfileInput, type AccountSession, type AdPixels, type AddLineInput, type Address, type AddressInput, type AnyStorefrontError, BUYER_IP_HEADER, type BlogPost, type BlogPostList, type BlogPostSummary, type BuyerDetailField, type Cart, type CartAgreements, type CartCustomer, type CartIdStorage, type CartLine, type CartStatus, type Category, type CategoryGridSection, type CategoryList, type CheckoutChallenge, type CheckoutEmbed, type CheckoutEmbedKind, type CheckoutMissing, type CheckoutOptions, type CheckoutResult, type CheckoutResultBase, type ClosedCheckoutPage, type ClosedCheckoutResult, type ClosedPaymentMount, type ContentNode, type CookieCategory, type CookieInfo, type CookieJar, type CustomerInput, DEFAULT_TIMEOUT_MS, type EmbeddedCheckoutResult, type EmbeddedPaymentMount, type FeaturedProductsSection, type HeroSection, type KnownThemeSection, LEGAL_KEYS, type LegalDocument, type LegalKey, type MountPaymentOptions, type Order, type OrderLine, type OrderShipment, type OrderStatus, PUBLISHABLE_KEY_HEADER, type Pagination, type PaymentMount, type PaymentPresentation, type PaymentStatus, type Product, type ProductListQuery, type ProductPage, type ProductPersonalization, type ProductVariant, REOPEN_AGREEMENTS_HASH, type RedirectCheckoutResult, type RedirectPaymentMount, type RenderTurnstileOptions, type RequestCodeOptions, type RequestOptions, type RichTextSection, SDK_VERSION, STOREFRONT_KEY_HEADER, type SavedAddress, type SavedAddressInput, type ShipmentStatus, type ShippingOption, type ShippingOptionList, type ShippingRules, type Store, type StoreCompany, type StoreContact, type StoreContent, type StorefrontApiErrorCode, type StorefrontClient, type StorefrontClientErrorCode, type StorefrontClientOptions, StorefrontError, type StorefrontErrorCode, type StorefrontErrorDetails, type StorefrontErrorDetailsMap, THEME_FONTS, TURNSTILE_SCRIPT_URL, TURNSTILE_TOKEN_HEADER, type ThemeColors, type ThemeFont, type ThemeFooter, type ThemeHomepage, type ThemeLink, type ThemeSection, type ThemeSocial, type ThemeV1, type TurnstileApi, type TurnstileWidget, type UnknownThemeSection, type UnsupportedPaymentMount, type UpdateLineInput, type ValidationIssue, cartIdKey, clearCartId, cookieCartStorage, cookiesForHost, createStorefrontClient, formatMoney, isKnownThemeSection, isStorefrontError, loadCartId, loadTurnstile, mountPayment, onDefaultDomain, pixelsForHost, renderTurnstile, saveCartId };
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var API_CODES = /* @__PURE__ */ new Set([
|
|
|
7
7
|
"catalog_unavailable",
|
|
8
8
|
"product_not_found",
|
|
9
9
|
"content_not_found",
|
|
10
|
+
"blog_post_not_found",
|
|
10
11
|
"cart_not_found",
|
|
11
12
|
"variant_not_found",
|
|
12
13
|
"line_not_found",
|
|
@@ -17,6 +18,9 @@ var API_CODES = /* @__PURE__ */ new Set([
|
|
|
17
18
|
"cart_read_only",
|
|
18
19
|
"checkout_in_progress",
|
|
19
20
|
"checkout_incomplete",
|
|
21
|
+
"legal_not_confirmed",
|
|
22
|
+
"agreements_changed",
|
|
23
|
+
"cart_incomplete",
|
|
20
24
|
"cart_changed",
|
|
21
25
|
"invalid_personalization",
|
|
22
26
|
"out_of_stock",
|
|
@@ -132,6 +136,7 @@ function apiError(code, status, message, b) {
|
|
|
132
136
|
return new StorefrontError(code, status, message, {
|
|
133
137
|
variantIds: arr(b.variantIds)
|
|
134
138
|
});
|
|
139
|
+
case "cart_incomplete":
|
|
135
140
|
case "checkout_incomplete":
|
|
136
141
|
return new StorefrontError(code, status, message, {
|
|
137
142
|
missing: arr(b.missing)
|
|
@@ -169,6 +174,7 @@ var STOREFRONT_KEY_HEADER = "x-konfiqo-storefront-key";
|
|
|
169
174
|
var SERVER_KEY_HEADER = "x-konfiqo-server-key";
|
|
170
175
|
var TURNSTILE_TOKEN_HEADER = "x-konfiqo-turnstile-token";
|
|
171
176
|
var BUYER_IP_HEADER = "x-konfiqo-buyer-ip";
|
|
177
|
+
var REOPEN_AGREEMENTS_HASH = "0".repeat(64);
|
|
172
178
|
function seg(v) {
|
|
173
179
|
if (typeof v !== "string" || v === "" || v === "." || v === "..") {
|
|
174
180
|
throw new TypeError(
|
|
@@ -313,6 +319,17 @@ function createStorefrontClient(options) {
|
|
|
313
319
|
store: {
|
|
314
320
|
get: (o) => get(() => "/v1/store", o)
|
|
315
321
|
},
|
|
322
|
+
blog: {
|
|
323
|
+
list: (query = {}, o) => get(() => {
|
|
324
|
+
const params = new URLSearchParams();
|
|
325
|
+
if (query.page !== void 0) params.set("page", String(query.page));
|
|
326
|
+
if (query.pageSize !== void 0)
|
|
327
|
+
params.set("pageSize", String(query.pageSize));
|
|
328
|
+
const qs = params.toString();
|
|
329
|
+
return `/v1/blog${qs ? `?${qs}` : ""}`;
|
|
330
|
+
}, o),
|
|
331
|
+
get: (slug, o) => get(() => `/v1/blog/${seg(slug)}`, o)
|
|
332
|
+
},
|
|
316
333
|
categories: {
|
|
317
334
|
list: (o) => get(() => "/v1/categories", o)
|
|
318
335
|
},
|
|
@@ -372,13 +389,37 @@ function createStorefrontClient(options) {
|
|
|
372
389
|
{ id: optionId },
|
|
373
390
|
o
|
|
374
391
|
),
|
|
375
|
-
|
|
392
|
+
agreements: (cartId, o) => request(
|
|
376
393
|
"POST",
|
|
377
|
-
() => `${cart(cartId)}/
|
|
394
|
+
() => `${cart(cartId)}/agreements`,
|
|
378
395
|
void 0,
|
|
379
|
-
o
|
|
380
|
-
|
|
381
|
-
)
|
|
396
|
+
o
|
|
397
|
+
),
|
|
398
|
+
checkout: async (cartId, o) => {
|
|
399
|
+
const hash = o?.agreementsHash;
|
|
400
|
+
if (typeof hash !== "string" || !/^[0-9a-f]{64}$/i.test(hash)) {
|
|
401
|
+
throw new StorefrontError(
|
|
402
|
+
"invalid_request",
|
|
403
|
+
0,
|
|
404
|
+
"carts.checkout needs the agreementsHash of carts.agreements (64 hex characters)",
|
|
405
|
+
{
|
|
406
|
+
issues: [
|
|
407
|
+
{
|
|
408
|
+
path: "agreementsHash",
|
|
409
|
+
message: "Must be the 64 hex characters from carts.agreements"
|
|
410
|
+
}
|
|
411
|
+
]
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
return request(
|
|
416
|
+
"POST",
|
|
417
|
+
() => `${cart(cartId)}/checkout`,
|
|
418
|
+
{ agreementsHash: o.agreementsHash },
|
|
419
|
+
o,
|
|
420
|
+
o.turnstileToken ? { [TURNSTILE_TOKEN_HEADER]: o.turnstileToken } : {}
|
|
421
|
+
);
|
|
422
|
+
}
|
|
382
423
|
},
|
|
383
424
|
orders: {
|
|
384
425
|
get: (orderId, token, o) => get(
|
|
@@ -457,6 +498,16 @@ function transportError(e, timedOut, timeoutMs) {
|
|
|
457
498
|
);
|
|
458
499
|
}
|
|
459
500
|
|
|
501
|
+
// src/legal.ts
|
|
502
|
+
var LEGAL_KEYS = [
|
|
503
|
+
"legal.kvkk",
|
|
504
|
+
"legal.privacy",
|
|
505
|
+
"legal.preliminary-information",
|
|
506
|
+
"legal.distance-sales",
|
|
507
|
+
"legal.returns",
|
|
508
|
+
"legal.cookies"
|
|
509
|
+
];
|
|
510
|
+
|
|
460
511
|
// src/theme.ts
|
|
461
512
|
var THEME_FONTS = [
|
|
462
513
|
"inter",
|
|
@@ -715,11 +766,13 @@ async function renderTurnstile(element, siteKey, options) {
|
|
|
715
766
|
}
|
|
716
767
|
|
|
717
768
|
// src/index.ts
|
|
718
|
-
var SDK_VERSION = "0.
|
|
769
|
+
var SDK_VERSION = "0.7.0";
|
|
719
770
|
export {
|
|
720
771
|
BUYER_IP_HEADER,
|
|
721
772
|
DEFAULT_TIMEOUT_MS,
|
|
773
|
+
LEGAL_KEYS,
|
|
722
774
|
PUBLISHABLE_KEY_HEADER,
|
|
775
|
+
REOPEN_AGREEMENTS_HASH,
|
|
723
776
|
SDK_VERSION,
|
|
724
777
|
STOREFRONT_KEY_HEADER,
|
|
725
778
|
StorefrontError,
|