Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
API: Add proper refresh token support (#13785)
Damian Legawiec93d6b269a8af
diff --git a/CLAUDE.md b/CLAUDE.mdindex 61be7dc183..ef58715e6e 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -23,6 +23,7 @@ Current plans:- `6.0-fulfillment-and-delivery.md` — Shipment→Fulfillment, ShippingMethod→DeliveryMethod, drop ShippingCategory, FulfillmentProvider strategy- `6.0-returns-exchanges-claims.md` — First-class Return, Exchange, Claim models replacing ReturnAuthorization/Reimbursement chain- `6.0-channels-catalogs-b2b.md` — Channel, Catalog, ProductListing (replaces StoreProduct), Company/CompanyLocation/CompanyContact for B2B+- `6.0-platform-auth.md` — Drop Devise, own auth stack, User→Customer/Staff rename- `5.x-store-api-bridges.md` — Bridge 6.0 naming into 5.5 Store API (fulfillments, delivery, status, remove master_variant)## Monorepo Structurediff --git a/docs/api-reference/store.yaml b/docs/api-reference/store.yamlindex 8488ff7a1a..78c07e90bf 100644--- a/docs/api-reference/store.yaml+++ b/docs/api-reference/store.yaml@@ -661,16 +661,17 @@ paths:content:application/json:example:- token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6IjA2MjgxZDNhLTY0MDMtNDAzOS05OTRkLTE2ZDhjOTBhMGQ3OSIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzczNzQ5MzQwfQ.Kl9askzK2lIUX6EE9vvhHWyHaquHkZ_sc6BZxGiCZQo+ token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6ImUxNmIzMTA4LTkzNjUtNDA5YS04MTlmLWM1YWUzNGQ0ZTk0MiIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzczNzU3ODYyfQ.ckgPs71jNwRgeGSYqIcotysVDCSAAUhvk_GHRJTSRnQ+ refresh_token: bLzrrimH27YjfKSWHmpv59nDuser:id: cus_UkLWZg9DAJemail: [email protected]- first_name: Doria- last_name: Crooks+ first_name: Zenia+ last_name: Gerlachphone:accepts_email_marketing: false- created_at: '2026-03-17T11:08:59.916Z'- updated_at: '2026-03-17T11:08:59.916Z'+ created_at: '2026-03-17T13:31:02.565Z'+ updated_at: '2026-03-17T13:31:02.565Z'addresses: []default_billing_address:default_shipping_address:@@ -713,8 +714,8 @@ paths:- Authenticationsecurity:- api_key: []- bearer_auth: []- description: Generates a new JWT token for the authenticated user+ description: Exchanges a refresh token for a new access JWT and rotated refresh+ token. No Authorization header needed.x-codeSamples:- lang: javascriptlabel: Spree SDK@@ -727,7 +728,7 @@ paths:})const auth = await client.auth.refresh({- bearerToken: '<token>',+ refresh_token: 'rt_xxx',})parameters:- name: x-spree-api-key@@ -735,43 +736,49 @@ paths:required: trueschema:type: string- - name: Authorization- in: header- required: true- description: Bearer token- schema:- type: stringresponses:'200':description: token refreshedcontent:application/json:example:- token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6IjJhOTg0Y2U0LWU2YzEtNDBhNy1hZjc3LWFlNTk4MGU1N2I2YyIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzczNzQ5MzQxfQ.vXMc-DeChD2XOedkMAgvvKo9DntG2Z9Eqfk_M-AM7Mg+ token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6Ijg5YTYwYjQxLWJhMTUtNDdkMC1iOGZmLWQ2MGVkZjkzZDhkMSIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzczNzU3ODY0fQ.Cac-aCqrH-dwXNR6lDdfp1prDTCjsE8Ak6GsjqPKm4Q+ refresh_token: HFaqot6SgwFH662V43pZa9C3user:id: cus_UkLWZg9DAJemail: [email protected]- first_name: Meri- last_name: Heidenreich+ first_name: Elva+ last_name: Jakubowskiphone:accepts_email_marketing: false- created_at: '2026-03-17T11:09:01.383Z'- updated_at: '2026-03-17T11:09:01.383Z'+ created_at: '2026-03-17T13:31:04.024Z'+ updated_at: '2026-03-17T13:31:04.024Z'addresses: []default_billing_address:default_shipping_address:schema:"$ref": "#/components/schemas/AuthResponse"'401':- description: missing or invalid token+ description: missing or invalid refresh tokencontent:application/json:example:error:- code: authentication_required- message: Authentication required+ code: invalid_refresh_token+ message: Invalid or expired refresh tokenschema:"$ref": "#/components/schemas/ErrorResponse"+ requestBody:+ content:+ application/json:+ schema:+ type: object+ properties:+ refresh_token:+ type: string+ description: Refresh token from login response+ required:+ - refresh_token"/api/v3/store/carts":get:summary: List active carts@@ -814,9 +821,9 @@ paths:example:data:- id: cart_gbHJdmfrXB- number: R484340314- token: N7TTKMuBxaDBo49UicQDfB7bSvMFrLooRBZ- email: [email protected]+ number: R697243469+ token: 7bfomRAZGuJxHvALn7uiU5G6DEJZwSNTAtr+ email: [email protected]special_instructions:currency: USDlocale: en@@ -835,8 +842,8 @@ paths:display_additional_tax_total: "$0.00"total: '110.0'display_total: "$110.00"- created_at: '2026-03-17T11:09:02.184Z'- updated_at: '2026-03-17T11:09:02.264Z'+ created_at: '2026-03-17T13:31:04.882Z'+ updated_at: '2026-03-17T13:31:04.934Z'delivery_total: '100.0'display_delivery_total: "$100.00"current_step: address@@ -851,8 +858,8 @@ paths:variant_id: variant_gbHJdmfrXBquantity: 1currency: USD- name: Product 29224- slug: product-29224+ name: Product 23761+ slug: product-23761options_text: ''price: '10.0'display_price: "$10.00"@@ -871,21 +878,21 @@ paths:discounted_amount: '10.0'display_discounted_amount: "$10.00"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:02.230Z'- updated_at: '2026-03-17T11:09:02.230Z'+ created_at: '2026-03-17T13:31:04.912Z'+ updated_at: '2026-03-17T13:31:04.912Z'compare_at_amount:thumbnail_url:option_values: []digital_links: []fulfillments:- id: ful_gbHJdmfrXB- number: H82243017261+ number: H32519968460tracking: U10000tracking_url:cost: '100.0'display_cost: "$100.00"- created_at: '2026-03-17T11:09:02.243Z'- updated_at: '2026-03-17T11:09:02.262Z'+ created_at: '2026-03-17T13:31:04.921Z'+ updated_at: '2026-03-17T13:31:04.931Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -900,7 +907,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_37- name: Ronald O'Hara+ name: Sheri Hodkiewiczaddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -955,9 +962,9 @@ paths:state_name: STATE_NAME_42payment_methods: []- id: cart_UkLWZg9DAJ- number: R988721875- token: 6mz7ACtmJu3dmgkUFeWtREay2E2V2CmjJMf- email: [email protected]+ number: R021779891+ token: unW9g9qmuoF7jHUHY2Gv7KsksJpLpPck1A7+ email: [email protected]special_instructions:currency: USDlocale: en@@ -976,8 +983,8 @@ paths:display_additional_tax_total: "$0.00"total: '110.0'display_total: "$110.00"- created_at: '2026-03-17T11:09:01.976Z'- updated_at: '2026-03-17T11:09:02.175Z'+ created_at: '2026-03-17T13:31:04.716Z'+ updated_at: '2026-03-17T13:31:04.876Z'delivery_total: '100.0'display_delivery_total: "$100.00"current_step: address@@ -992,8 +999,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 1306- slug: product-1306+ name: Product 1217+ slug: product-1217options_text: ''price: '10.0'display_price: "$10.00"@@ -1012,21 +1019,21 @@ paths:discounted_amount: '10.0'display_discounted_amount: "$10.00"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:02.072Z'- updated_at: '2026-03-17T11:09:02.072Z'+ created_at: '2026-03-17T13:31:04.796Z'+ updated_at: '2026-03-17T13:31:04.796Z'compare_at_amount:thumbnail_url:option_values: []digital_links: []fulfillments:- id: ful_UkLWZg9DAJ- number: H16381684003+ number: H60685875733tracking: U10000tracking_url:cost: '100.0'display_cost: "$100.00"- created_at: '2026-03-17T11:09:02.091Z'- updated_at: '2026-03-17T11:09:02.170Z'+ created_at: '2026-03-17T13:31:04.812Z'+ updated_at: '2026-03-17T13:31:04.871Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -1041,7 +1048,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_37- name: Ronald O'Hara+ name: Sheri Hodkiewiczaddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -1169,8 +1176,8 @@ paths:application/json:example:id: cart_UkLWZg9DAJ- number: R662248778- token: G5FdYWdcNAcsJoFqCPdZhnW5ZHFC93tEFn6+ number: R671255877+ token: ddJ7VqTu6PyWaTgA2SDFQGYKJ1wqnDrvuSzemail:special_instructions:currency: USD@@ -1190,8 +1197,8 @@ paths:display_additional_tax_total: "$0.00"total: '0.0'display_total: "$0.00"- created_at: '2026-03-17T11:09:02.981Z'- updated_at: '2026-03-17T11:09:02.981Z'+ created_at: '2026-03-17T13:31:05.668Z'+ updated_at: '2026-03-17T13:31:05.668Z'delivery_total: '0.0'display_delivery_total: "$0.00"current_step: address@@ -1300,9 +1307,9 @@ paths:application/json:example:id: cart_UkLWZg9DAJ- number: R642950995- token: WZ3iT8aGpmK1cAjjgjytcwXeE3QNuSNK3Hn- email: [email protected]+ number: R494225149+ token: PjhEZ59PPi81AcWawUHfYX7oZYW1duqzEGg+ email: [email protected]special_instructions:currency: USDlocale: en@@ -1321,8 +1328,8 @@ paths:display_additional_tax_total: "$0.00"total: '110.0'display_total: "$110.00"- created_at: '2026-03-17T11:09:03.268Z'- updated_at: '2026-03-17T11:09:03.345Z'+ created_at: '2026-03-17T13:31:05.962Z'+ updated_at: '2026-03-17T13:31:06.059Z'delivery_total: '100.0'display_delivery_total: "$100.00"current_step: address@@ -1337,8 +1344,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 58546- slug: product-58546+ name: Product 52169+ slug: product-52169options_text: ''price: '10.0'display_price: "$10.00"@@ -1357,21 +1364,21 @@ paths:discounted_amount: '10.0'display_discounted_amount: "$10.00"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:03.311Z'- updated_at: '2026-03-17T11:09:03.311Z'+ created_at: '2026-03-17T13:31:06.023Z'+ updated_at: '2026-03-17T13:31:06.023Z'compare_at_amount:thumbnail_url:option_values: []digital_links: []fulfillments:- id: ful_UkLWZg9DAJ- number: H73493840246+ number: H00356197759tracking: U10000tracking_url:cost: '100.0'display_cost: "$100.00"- created_at: '2026-03-17T11:09:03.320Z'- updated_at: '2026-03-17T11:09:03.342Z'+ created_at: '2026-03-17T13:31:06.030Z'+ updated_at: '2026-03-17T13:31:06.056Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -1386,7 +1393,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_47- name: Leah Fay+ name: Rocio Wittingaddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -1521,9 +1528,9 @@ paths:application/json:example:id: cart_UkLWZg9DAJ- number: R588483908- token: rbnxf7dKcdzrjazScvUXiQg1LmzGbiyjgbb- email: [email protected]+ number: R675289587+ token: Nv9t7Fad6UERBzGLVhF4Q4h5rRXp6hB9anC+ email: [email protected]special_instructions: Leave at doorcurrency: USDlocale: en@@ -1542,8 +1549,8 @@ paths:display_additional_tax_total: "$0.00"total: '29.99'display_total: "$29.99"- created_at: '2026-03-17T11:09:03.977Z'- updated_at: '2026-03-17T11:09:04.142Z'+ created_at: '2026-03-17T13:31:06.661Z'+ updated_at: '2026-03-17T13:31:06.817Z'delivery_total: '10.0'display_delivery_total: "$10.00"current_step: payment@@ -1560,8 +1567,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 69060- slug: product-69060+ name: Product 67748+ slug: product-67748options_text: ''price: '19.99'display_price: "$19.99"@@ -1580,21 +1587,21 @@ paths:discounted_amount: '19.99'display_discounted_amount: "$19.99"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:04.009Z'- updated_at: '2026-03-17T11:09:04.089Z'+ created_at: '2026-03-17T13:31:06.691Z'+ updated_at: '2026-03-17T13:31:06.769Z'compare_at_amount:thumbnail_url:option_values: []digital_links: []fulfillments:- id: ful_gbHJdmfrXB- number: H15005255064+ number: H69146355063tracking:tracking_url:cost: '10.0'display_cost: "$10.00"- created_at: '2026-03-17T11:09:04.110Z'- updated_at: '2026-03-17T11:09:04.124Z'+ created_at: '2026-03-17T13:31:06.787Z'+ updated_at: '2026-03-17T13:31:06.801Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -1609,7 +1616,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_49- name: Cherrie Murray+ name: Lucina Johnsonaddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -1831,9 +1838,9 @@ paths:application/json:example:id: cart_UkLWZg9DAJ- number: R015650875- token: mQr6dGrhR5MiSEbdcemjdPjiv4Bs7pTj6zg- email: [email protected]+ number: R534753884+ token: LkNFFRxRAPfzLkoqALbqo8NDvKfmQ9oiFjS+ email: [email protected]special_instructions:currency: USDlocale: en@@ -1852,8 +1859,8 @@ paths:display_additional_tax_total: "$0.00"total: '110.0'display_total: "$110.00"- created_at: '2026-03-17T11:09:04.816Z'- updated_at: '2026-03-17T11:09:04.884Z'+ created_at: '2026-03-17T13:31:07.637Z'+ updated_at: '2026-03-17T13:31:07.698Z'delivery_total: '100.0'display_delivery_total: "$100.00"current_step: address@@ -1868,8 +1875,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 82796- slug: product-82796+ name: Product 86043+ slug: product-86043options_text: ''price: '10.0'display_price: "$10.00"@@ -1888,21 +1895,21 @@ paths:discounted_amount: '10.0'display_discounted_amount: "$10.00"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:04.861Z'- updated_at: '2026-03-17T11:09:04.861Z'+ created_at: '2026-03-17T13:31:07.674Z'+ updated_at: '2026-03-17T13:31:07.674Z'compare_at_amount:thumbnail_url:option_values: []digital_links: []fulfillments:- id: ful_UkLWZg9DAJ- number: H78738090462+ number: H73657546437tracking: U10000tracking_url:cost: '100.0'display_cost: "$100.00"- created_at: '2026-03-17T11:09:04.867Z'- updated_at: '2026-03-17T11:09:04.882Z'+ created_at: '2026-03-17T13:31:07.681Z'+ updated_at: '2026-03-17T13:31:07.695Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -1917,7 +1924,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_57- name: Jospeh Mosciski+ name: Winnie Nolanaddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -2036,8 +2043,8 @@ paths:application/json:example:id: or_UkLWZg9DAJ- number: R071246840- email: [email protected]+ number: R516410685+ email: [email protected]special_instructions:currency: USDlocale: en@@ -2056,9 +2063,9 @@ paths:display_additional_tax_total: "$0.00"total: '29.99'display_total: "$29.99"- completed_at: '2026-03-17T11:09:06.295Z'- created_at: '2026-03-17T11:09:06.062Z'- updated_at: '2026-03-17T11:09:06.295Z'+ completed_at: '2026-03-17T13:31:09.316Z'+ created_at: '2026-03-17T13:31:09.079Z'+ updated_at: '2026-03-17T13:31:09.316Z'fulfillment_status: backorderpayment_status: paiddelivery_total: '10.0'@@ -2069,8 +2076,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 10516- slug: product-10516+ name: Product 101409+ slug: product-101409options_text: ''price: '19.99'display_price: "$19.99"@@ -2089,21 +2096,21 @@ paths:discounted_amount: '19.99'display_discounted_amount: "$19.99"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:06.092Z'- updated_at: '2026-03-17T11:09:06.299Z'+ created_at: '2026-03-17T13:31:09.115Z'+ updated_at: '2026-03-17T13:31:09.320Z'compare_at_amount:thumbnail_url:option_values: []digital_links: []fulfillments:- id: ful_gbHJdmfrXB- number: H82652938763+ number: H27475079463tracking:tracking_url:cost: '10.0'display_cost: "$10.00"- created_at: '2026-03-17T11:09:06.174Z'- updated_at: '2026-03-17T11:09:06.289Z'+ created_at: '2026-03-17T13:31:09.191Z'+ updated_at: '2026-03-17T13:31:09.309Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -2118,7 +2125,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_63- name: Gavin Kihn+ name: Shonna Grantaddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -2140,11 +2147,11 @@ paths:- id: py_UkLWZg9DAJpayment_method_id: pm_UkLWZg9DAJresponse_code: '12345'- number: PP3SRF2Y+ number: PEHEUNS0amount: '29.99'display_amount: "$29.99"- created_at: '2026-03-17T11:09:06.247Z'- updated_at: '2026-03-17T11:09:06.271Z'+ created_at: '2026-03-17T13:31:09.266Z'+ updated_at: '2026-03-17T13:31:09.290Z'status: completedsource_type: credit_cardsource_id: card_UkLWZg9DAJ@@ -2277,8 +2284,8 @@ paths:meta_description:meta_keywords:children_count: 1- created_at: '2026-03-17T11:09:06.963Z'- updated_at: '2026-03-17T11:09:07.045Z'+ created_at: '2026-03-17T13:31:09.991Z'+ updated_at: '2026-03-17T13:31:10.098Z'parent_id:description: ''description_html: ''@@ -2296,8 +2303,8 @@ paths:meta_description:meta_keywords:children_count: 1- created_at: '2026-03-17T11:09:06.971Z'- updated_at: '2026-03-17T11:09:07.045Z'+ created_at: '2026-03-17T13:31:10.001Z'+ updated_at: '2026-03-17T13:31:10.098Z'parent_id: ctg_UkLWZg9DAJdescription: ''description_html: ''@@ -2315,8 +2322,8 @@ paths:meta_description:meta_keywords:children_count: 0- created_at: '2026-03-17T11:09:06.983Z'- updated_at: '2026-03-17T11:09:06.989Z'+ created_at: '2026-03-17T13:31:10.013Z'+ updated_at: '2026-03-17T13:31:10.030Z'parent_id: ctg_gbHJdmfrXBdescription: ''description_html: ''@@ -2417,8 +2424,8 @@ paths:meta_description:meta_keywords:children_count: 1- created_at: '2026-03-17T11:09:07.429Z'- updated_at: '2026-03-17T11:09:07.469Z'+ created_at: '2026-03-17T13:31:10.505Z'+ updated_at: '2026-03-17T13:31:10.543Z'parent_id: ctg_UkLWZg9DAJdescription: ''description_html: ''@@ -2545,19 +2552,18 @@ paths:example:data:- id: prod_UkLWZg9DAJ- name: Product 196030+ name: Product 199073description: |-- Molestias voluptates velit ratione temporibus fugiat occaecati harum. Quo perferendis libero dolor porro dignissimos. Mollitia facilis eum nulla rerum alias sit pariatur. Doloremque consequatur consectetur fugiat nemo. Quas omnis dolor molestiae repellendus illum provident quasi quidem.- Aspernatur ipsam atque recusandae aliquid adipisci placeat exercitationem. Quisquam officiis omnis iure voluptatum reprehenderit. Totam quis mollitia quisquam atque quae eveniet hic harum. Placeat aspernatur perspiciatis natus laborum corporis magnam. Occaecati ipsum perspiciatis unde aliquid rem dignissimos veniam dolore.- Incidunt quo delectus voluptates accusantium omnis. Illum dolore enim totam maiores. Aliquid rerum labore mollitia enim. Similique aliquid in ullam fugit doloribus error. Eligendi corporis id eaque vel doloremque ipsum.- Quisquam reiciendis consequuntur distinctio ullam. Eaque repellendus voluptatem possimus sed magni ea saepe modi. Fugit ex culpa et impedit sit omnis autem. Dolores ratione odit velit aperiam quam odio quas beatae. Tempora velit laborum nobis voluptatibus repudiandae dolores exercitationem quidem.- slug: product-196030+ Cumque enim consequatur eos nobis. Consequatur minus asperiores laudantium eius dolores suscipit ut accusamus. Vel magni iusto molestiae necessitatibus sed nisi odit. Sed soluta omnis enim voluptatum velit in ex odit. Nostrum quis labore hic quo numquam soluta.+ Architecto numquam quidem fugiat ut sapiente. Perferendis cupiditate ducimus nemo ex libero illo. Cupiditate dolor assumenda laboriosam earum repellat ad.+ Impedit corporis quae nemo officia sit voluptatibus beatae. Suscipit molestias ipsam laboriosam id aperiam asperiores. Totam fugiat hic tenetur nam optio sint.+ slug: product-199073meta_description:meta_keywords:variant_count: 0- available_on: '2025-03-17T11:09:07.940Z'- created_at: '2026-03-17T11:09:07.954Z'- updated_at: '2026-03-17T11:09:07.967Z'+ available_on: '2025-03-17T13:31:11.026Z'+ created_at: '2026-03-17T13:31:11.039Z'+ updated_at: '2026-03-17T13:31:11.052Z'purchasable: truein_stock: falsebackorderable: true@@ -2827,9 +2833,9 @@ paths:application/json:example:id: cart_UkLWZg9DAJ- number: R566629622- token: zozUNso9MbS4TjnsBVHuo3UtMQ2pCyEZeVu- email: [email protected]+ number: R548970950+ token: 1ohw9b5fkMFfn955mYHyMeFrQZJya4pM7SD+ email: [email protected]special_instructions:currency: USDlocale: en@@ -2848,8 +2854,8 @@ paths:display_additional_tax_total: "$0.00"total: '110.0'display_total: "$110.00"- created_at: '2026-03-17T11:09:10.033Z'- updated_at: '2026-03-17T11:09:10.193Z'+ created_at: '2026-03-17T13:31:13.005Z'+ updated_at: '2026-03-17T13:31:13.154Z'delivery_total: '100.0'display_delivery_total: "$100.00"current_step: address@@ -2861,8 +2867,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 234345- slug: product-234345+ name: Product 235106+ slug: product-235106options_text: ''price: '10.0'display_price: "$10.00"@@ -2881,21 +2887,21 @@ paths:discounted_amount: '10.0'display_discounted_amount: "$10.00"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:10.089Z'- updated_at: '2026-03-17T11:09:10.089Z'+ created_at: '2026-03-17T13:31:13.059Z'+ updated_at: '2026-03-17T13:31:13.059Z'compare_at_amount:thumbnail_url:option_values: []digital_links: []fulfillments:- id: ful_UkLWZg9DAJ- number: H36924076198+ number: H96742613911tracking: U10000tracking_url:cost: '100.0'display_cost: "$100.00"- created_at: '2026-03-17T11:09:10.103Z'- updated_at: '2026-03-17T11:09:10.126Z'+ created_at: '2026-03-17T13:31:13.068Z'+ updated_at: '2026-03-17T13:31:13.089Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -2910,7 +2916,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_85- name: Francoise Becker+ name: Luke Ebertaddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -2931,12 +2937,12 @@ paths:payments:- id: py_UkLWZg9DAJpayment_method_id: pm_UkLWZg9DAJ- response_code: 1-SC-20260317110910185236- number: PISJZB31+ response_code: 1-SC-20260317133113146337+ number: PMEU0DUHamount: '50.0'display_amount: "$50.00"- created_at: '2026-03-17T11:09:10.186Z'- updated_at: '2026-03-17T11:09:10.186Z'+ created_at: '2026-03-17T13:31:13.148Z'+ updated_at: '2026-03-17T13:31:13.148Z'status: checkoutsource_type: store_creditsource_id: credit_UkLWZg9DAJ@@ -3080,9 +3086,9 @@ paths:application/json:example:id: cart_UkLWZg9DAJ- number: R950863645- token: Pmmf1oCAnMoBMAJgQWmfDRaw2RY54xM6dyL- email: [email protected]+ number: R758123948+ token: CWpShy9fWn96dCNAb5LNCz9knAw98gEADC8+ email: [email protected]special_instructions:currency: USDlocale: en@@ -3101,8 +3107,8 @@ paths:display_additional_tax_total: "$0.00"total: '110.0'display_total: "$110.00"- created_at: '2026-03-17T11:09:11.372Z'- updated_at: '2026-03-17T11:09:11.483Z'+ created_at: '2026-03-17T13:31:14.347Z'+ updated_at: '2026-03-17T13:31:14.464Z'delivery_total: '100.0'display_delivery_total: "$100.00"current_step: address@@ -3117,8 +3123,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 259776- slug: product-259776+ name: Product 256598+ slug: product-256598options_text: ''price: '10.0'display_price: "$10.00"@@ -3137,21 +3143,21 @@ paths:discounted_amount: '10.0'display_discounted_amount: "$10.00"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:11.404Z'- updated_at: '2026-03-17T11:09:11.478Z'+ created_at: '2026-03-17T13:31:14.380Z'+ updated_at: '2026-03-17T13:31:14.460Z'compare_at_amount:thumbnail_url:option_values: []digital_links: []fulfillments:- id: ful_UkLWZg9DAJ- number: H75907176022+ number: H66029573545tracking: U10000tracking_url:cost: '100.0'display_cost: "$100.00"- created_at: '2026-03-17T11:09:11.409Z'- updated_at: '2026-03-17T11:09:11.423Z'+ created_at: '2026-03-17T13:31:14.388Z'+ updated_at: '2026-03-17T13:31:14.403Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -3166,7 +3172,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_93- name: Shawnna Wunsch+ name: Devon Bahringeraddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -3632,16 +3638,17 @@ paths:content:application/json:example:- token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6IjI2OTY1OTdiLWNmODUtNDUyNC04NzI2LTkxNWY0MWJjYTJmMyIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzczNzQ5MzU2fQ.-x1Y7F7nsLp18di7pLJgE5pvM0Q8HH2kgBHra8kTJqc+ token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6ImE3MGU3YWJlLTA2OTgtNDI0OS1iYWM2LThmMDljNzcwMjg0YyIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzczNzU3ODc5fQ.ANjn2ggzInGM5l9T02IqBkWT-ah-wC-mF1_Y7dBTus4+ refresh_token: 6zf6EN4jw3JhDDQLvJHYrqq2user:id: cus_UkLWZg9DAJemail: [email protected]- first_name: Major- last_name: Russel+ first_name: Joaquina+ last_name: Lockmanphone:accepts_email_marketing: false- created_at: '2026-03-17T11:09:16.554Z'- updated_at: '2026-03-17T11:09:16.829Z'+ created_at: '2026-03-17T13:31:19.494Z'+ updated_at: '2026-03-17T13:31:19.767Z'addresses: []default_billing_address:default_shipping_address:@@ -3729,8 +3736,8 @@ paths:example:data:- id: or_UkLWZg9DAJ- number: R041326761- email: [email protected]+ number: R274518608+ email: [email protected]special_instructions:currency: USDlocale: en@@ -3749,9 +3756,9 @@ paths:display_additional_tax_total: "$0.00"total: '110.0'display_total: "$110.00"- completed_at: '2026-03-17T11:09:17.759Z'- created_at: '2026-03-17T11:09:17.701Z'- updated_at: '2026-03-17T11:09:17.759Z'+ completed_at: '2026-03-17T13:31:20.680Z'+ created_at: '2026-03-17T13:31:20.624Z'+ updated_at: '2026-03-17T13:31:20.680Z'fulfillment_status:payment_status:delivery_total: '100.0'@@ -3762,8 +3769,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 273883- slug: product-273883+ name: Product 275268+ slug: product-275268options_text: ''price: '10.0'display_price: "$10.00"@@ -3782,21 +3789,21 @@ paths:discounted_amount: '10.0'display_discounted_amount: "$10.00"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:17.735Z'- updated_at: '2026-03-17T11:09:17.735Z'+ created_at: '2026-03-17T13:31:20.658Z'+ updated_at: '2026-03-17T13:31:20.658Z'compare_at_amount:thumbnail_url:option_values: []digital_links: []fulfillments:- id: ful_UkLWZg9DAJ- number: H84711058919+ number: H78837386136tracking: U10000tracking_url:cost: '100.0'display_cost: "$100.00"- created_at: '2026-03-17T11:09:17.741Z'- updated_at: '2026-03-17T11:09:17.756Z'+ created_at: '2026-03-17T13:31:20.663Z'+ updated_at: '2026-03-17T13:31:20.677Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -3811,7 +3818,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_113- name: Franklin Lindgren+ name: Dolly Mannaddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -3931,8 +3938,8 @@ paths:application/json:example:id: or_UkLWZg9DAJ- number: R645042949- email: [email protected]+ number: R334602628+ email: [email protected]special_instructions:currency: USDlocale: en@@ -3951,9 +3958,9 @@ paths:display_additional_tax_total: "$0.00"total: '110.0'display_total: "$110.00"- completed_at: '2026-03-17T11:09:18.461Z'- created_at: '2026-03-17T11:09:18.402Z'- updated_at: '2026-03-17T11:09:18.460Z'+ completed_at: '2026-03-17T13:31:21.362Z'+ created_at: '2026-03-17T13:31:21.311Z'+ updated_at: '2026-03-17T13:31:21.362Z'fulfillment_status:payment_status:delivery_total: '100.0'@@ -3964,8 +3971,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 296890- slug: product-296890+ name: Product 293548+ slug: product-293548options_text: ''price: '10.0'display_price: "$10.00"@@ -3984,21 +3991,21 @@ paths:discounted_amount: '10.0'display_discounted_amount: "$10.00"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:18.437Z'- updated_at: '2026-03-17T11:09:18.437Z'+ created_at: '2026-03-17T13:31:21.341Z'+ updated_at: '2026-03-17T13:31:21.341Z'compare_at_amount:thumbnail_url:option_values: []digital_links: []fulfillments:- id: ful_UkLWZg9DAJ- number: H33481902500+ number: H91647952388tracking: U10000tracking_url:cost: '100.0'display_cost: "$100.00"- created_at: '2026-03-17T11:09:18.443Z'- updated_at: '2026-03-17T11:09:18.457Z'+ created_at: '2026-03-17T13:31:21.347Z'+ updated_at: '2026-03-17T13:31:21.360Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -4013,7 +4020,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_119- name: Fae Jacobs+ name: Sherri Parkeraddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -4119,7 +4126,8 @@ paths:content:application/json:example:- token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6IjhjMzI5MDdmLTY0YjUtNDhjYy1iYzIzLTczNGRlMmI1ODY0MSIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzczNzQ5MzU5fQ.zNrpztxm2UNFJOCLNxyave3oPtM7C2labUgD_MPWIJs+ token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6ImM2NjRlMmFmLTViZjUtNGYyMC04YmFhLTcyMDY5ZmI3YmNhZiIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzczNzU3ODgyfQ.RxdDcn7lKEQdzdF8Db5vir-EmSbizc9G0Iy2K8wDiEo+ refresh_token: 1eSBudYGmhKZrRr3RsbfwnhRuser:id: cus_UkLWZg9DAJemail: [email protected]@@ -4127,8 +4135,8 @@ paths:last_name: Doephone: "+1234567890"accepts_email_marketing: true- created_at: '2026-03-17T11:09:19.676Z'- updated_at: '2026-03-17T11:09:19.676Z'+ created_at: '2026-03-17T13:31:22.815Z'+ updated_at: '2026-03-17T13:31:22.815Z'addresses: []default_billing_address:default_shipping_address:@@ -4232,13 +4240,13 @@ paths:application/json:example:id: cus_UkLWZg9DAJ- email: [email protected]- first_name: Arcelia- last_name: Wehner+ email: [email protected]+ first_name: Ada+ last_name: Russelphone: 555-555-0199accepts_email_marketing: false- created_at: '2026-03-17T11:09:20.233Z'- updated_at: '2026-03-17T11:09:20.508Z'+ created_at: '2026-03-17T13:31:23.410Z'+ updated_at: '2026-03-17T13:31:23.682Z'addresses:- id: addr_gbHJdmfrXBfirstname: John@@ -4362,13 +4370,13 @@ paths:application/json:example:id: cus_UkLWZg9DAJ- email: [email protected]+ email: [email protected]first_name: Updatedlast_name: Namephone: 555-555-0199accepts_email_marketing: false- created_at: '2026-03-17T11:09:20.800Z'- updated_at: '2026-03-17T11:09:21.078Z'+ created_at: '2026-03-17T13:31:23.978Z'+ updated_at: '2026-03-17T13:31:24.465Z'addresses:- id: addr_gbHJdmfrXBfirstname: John@@ -4587,13 +4595,13 @@ paths:example:data:- id: ful_UkLWZg9DAJ- number: H63240219895+ number: H09695067944tracking: U10000tracking_url:cost: '100.0'display_cost: "$100.00"- created_at: '2026-03-17T11:09:24.572Z'- updated_at: '2026-03-17T11:09:24.618Z'+ created_at: '2026-03-17T13:31:27.925Z'+ updated_at: '2026-03-17T13:31:27.939Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -4608,7 +4616,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_145- name: Kym Franecki+ name: Pamelia Beeraddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -4690,9 +4698,9 @@ paths:application/json:example:id: cart_UkLWZg9DAJ- number: R890653960- token: mrhjXaXips6FC3VCk56kgd5B17T7C8bdMgs- email: [email protected]+ number: R312977713+ token: K8bzQ36zyaDf8epBWgEMTdFfnQPrjgoMEgV+ email: [email protected]special_instructions:currency: USDlocale: en@@ -4711,8 +4719,8 @@ paths:display_additional_tax_total: "$0.00"total: '110.0'display_total: "$110.00"- created_at: '2026-03-17T11:09:25.213Z'- updated_at: '2026-03-17T11:09:25.294Z'+ created_at: '2026-03-17T13:31:28.508Z'+ updated_at: '2026-03-17T13:31:28.600Z'delivery_total: '100.0'display_delivery_total: "$100.00"current_step: payment@@ -4729,8 +4737,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 383153- slug: product-383153+ name: Product 388607+ slug: product-388607options_text: ''price: '10.0'display_price: "$10.00"@@ -4749,21 +4757,21 @@ paths:discounted_amount: '10.0'display_discounted_amount: "$10.00"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:25.239Z'- updated_at: '2026-03-17T11:09:25.239Z'+ created_at: '2026-03-17T13:31:28.541Z'+ updated_at: '2026-03-17T13:31:28.541Z'compare_at_amount:thumbnail_url:option_values: []digital_links: []fulfillments:- id: ful_UkLWZg9DAJ- number: H16155815703+ number: H51846293008tracking: U10000tracking_url:cost: '100.0'display_cost: "$100.00"- created_at: '2026-03-17T11:09:25.244Z'- updated_at: '2026-03-17T11:09:25.280Z'+ created_at: '2026-03-17T13:31:28.547Z'+ updated_at: '2026-03-17T13:31:28.583Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -4778,7 +4786,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_149- name: Annis Schuster+ name: Rory Schaeferaddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -4915,7 +4923,7 @@ paths:example:data:- id: gc_UkLWZg9DAJ- code: 065351D532D765B7+ code: D5C45BB9DD347FF0status: activecurrency: USDamount: '10.0'@@ -4929,8 +4937,8 @@ paths:redeemed_at:expired: falseactive: true- created_at: '2026-03-17T11:09:26.483Z'- updated_at: '2026-03-17T11:09:26.483Z'+ created_at: '2026-03-17T13:31:29.947Z'+ updated_at: '2026-03-17T13:31:29.947Z'meta:page: 1limit: 25@@ -5013,7 +5021,7 @@ paths:application/json:example:id: gc_UkLWZg9DAJ- code: 7A9E9E3A098E7D92+ code: 470987BEE687983Dstatus: activecurrency: USDamount: '10.0'@@ -5027,8 +5035,8 @@ paths:redeemed_at:expired: falseactive: true- created_at: '2026-03-17T11:09:27.571Z'- updated_at: '2026-03-17T11:09:27.571Z'+ created_at: '2026-03-17T13:31:31.050Z'+ updated_at: '2026-03-17T13:31:31.050Z'schema:"$ref": "#/components/schemas/GiftCard"'404':@@ -5105,9 +5113,9 @@ paths:application/json:example:id: cart_UkLWZg9DAJ- number: R338516031- token: HGe69Uw2fzxrxAwxzeMHYaoV1fGTjd7xPuA- email: [email protected]+ number: R827338349+ token: J58SZzPH5sditEnV3Q5NeMFoFPzYWNaKLiB+ email: [email protected]special_instructions:currency: USDlocale: en@@ -5126,8 +5134,8 @@ paths:display_additional_tax_total: "$0.00"total: '29.99'display_total: "$29.99"- created_at: '2026-03-17T11:09:29.378Z'- updated_at: '2026-03-17T11:09:29.516Z'+ created_at: '2026-03-17T13:31:32.877Z'+ updated_at: '2026-03-17T13:31:33.025Z'delivery_total: '0.0'display_delivery_total: "$0.00"current_step: address@@ -5148,8 +5156,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 421275- slug: product-421275+ name: Product 421961+ slug: product-421961options_text: ''price: '10.0'display_price: "$10.00"@@ -5168,8 +5176,8 @@ paths:discounted_amount: '10.0'display_discounted_amount: "$10.00"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:29.430Z'- updated_at: '2026-03-17T11:09:29.430Z'+ created_at: '2026-03-17T13:31:32.932Z'+ updated_at: '2026-03-17T13:31:32.932Z'compare_at_amount:thumbnail_url:option_values: []@@ -5178,8 +5186,8 @@ paths:variant_id: variant_gbHJdmfrXBquantity: 1currency: USD- name: Product 436242- slug: product-436242+ name: Product 431769+ slug: product-431769options_text: ''price: '19.99'display_price: "$19.99"@@ -5198,8 +5206,8 @@ paths:discounted_amount: '19.99'display_discounted_amount: "$19.99"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:29.487Z'- updated_at: '2026-03-17T11:09:29.487Z'+ created_at: '2026-03-17T13:31:32.994Z'+ updated_at: '2026-03-17T13:31:32.994Z'compare_at_amount:thumbnail_url:option_values: []@@ -5319,9 +5327,9 @@ paths:application/json:example:id: cart_UkLWZg9DAJ- number: R706546575- token: X1CqHQ9YZ5sgR19vRDK6PgB4rswuS2x1tV5- email: [email protected]+ number: R480934325+ token: 6ovgFsi8GH2ZGNNzeEiKNLn3huW6izmpycy+ email: [email protected]special_instructions:currency: USDlocale: en@@ -5340,8 +5348,8 @@ paths:display_additional_tax_total: "$0.00"total: '0.0'display_total: "$0.00"- created_at: '2026-03-17T11:09:31.287Z'- updated_at: '2026-03-17T11:09:31.318Z'+ created_at: '2026-03-17T13:31:35.060Z'+ updated_at: '2026-03-17T13:31:35.095Z'delivery_total: '0.0'display_delivery_total: "$0.00"current_step: address@@ -5359,8 +5367,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 468960- slug: product-468960+ name: Product 462397+ slug: product-462397options_text: ''price: '10.0'display_price: "$10.00"@@ -5379,8 +5387,8 @@ paths:discounted_amount: '10.0'display_discounted_amount: "$10.00"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:31.317Z'- updated_at: '2026-03-17T11:09:31.333Z'+ created_at: '2026-03-17T13:31:35.095Z'+ updated_at: '2026-03-17T13:31:35.114Z'compare_at_amount:thumbnail_url:option_values: []@@ -5480,9 +5488,9 @@ paths:application/json:example:id: cart_UkLWZg9DAJ- number: R978178791- token: pQsMhMXBpPNMMYmtC9kUtsxzEAunrMAJFSr- email: [email protected]+ number: R637650730+ token: BQtHn7w8gcpcK4HpPKuzHEtJgMbz5PKXPtR+ email: [email protected]special_instructions:currency: USDlocale: en@@ -5501,8 +5509,8 @@ paths:display_additional_tax_total: "$0.00"total: '0.0'display_total: "$0.00"- created_at: '2026-03-17T11:09:31.880Z'- updated_at: '2026-03-17T11:09:31.925Z'+ created_at: '2026-03-17T13:31:35.679Z'+ updated_at: '2026-03-17T13:31:35.750Z'delivery_total: '0.0'display_delivery_total: "$0.00"current_step: address@@ -6056,7 +6064,7 @@ paths:application/json:example:id: or_UkLWZg9DAJ- number: R555790607+ number: R094228688email: [email protected]special_instructions:currency: USD@@ -6076,9 +6084,9 @@ paths:display_additional_tax_total: "$0.00"total: '110.0'display_total: "$110.00"- completed_at: '2026-03-17T11:09:33.673Z'- created_at: '2026-03-17T11:09:33.621Z'- updated_at: '2026-03-17T11:09:33.673Z'+ completed_at: '2026-03-17T13:31:37.735Z'+ created_at: '2026-03-17T13:31:37.679Z'+ updated_at: '2026-03-17T13:31:37.734Z'fulfillment_status:payment_status:delivery_total: '100.0'@@ -6089,8 +6097,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 502915- slug: product-502915+ name: Product 503088+ slug: product-503088options_text: ''price: '10.0'display_price: "$10.00"@@ -6109,21 +6117,21 @@ paths:discounted_amount: '10.0'display_discounted_amount: "$10.00"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:33.652Z'- updated_at: '2026-03-17T11:09:33.652Z'+ created_at: '2026-03-17T13:31:37.712Z'+ updated_at: '2026-03-17T13:31:37.712Z'compare_at_amount:thumbnail_url:option_values: []digital_links: []fulfillments:- id: ful_UkLWZg9DAJ- number: H82674523059+ number: H32393637608tracking: U10000tracking_url:cost: '100.0'display_cost: "$100.00"- created_at: '2026-03-17T11:09:33.657Z'- updated_at: '2026-03-17T11:09:33.671Z'+ created_at: '2026-03-17T13:31:37.718Z'+ updated_at: '2026-03-17T13:31:37.732Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -6138,7 +6146,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_190- name: Ezequiel Powlowski+ name: Coreen Creminaddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -6343,13 +6351,13 @@ paths:id: ps_gbHJdmfrXBstatus: pendingcurrency: USD- external_id: bogus_538df4229b8457059597f030+ external_id: bogus_50f4461454014df3c3f580feexternal_data:- client_secret: bogus_secret_d88f3fd44c1aaf8a+ client_secret: bogus_secret_82b4b55ca09a4b9dcustomer_external_id:expires_at:- created_at: '2026-03-17T11:09:36.340Z'- updated_at: '2026-03-17T11:09:36.340Z'+ created_at: '2026-03-17T13:31:40.212Z'+ updated_at: '2026-03-17T13:31:40.212Z'amount: '110.0'payment_method_id: pm_UkLWZg9DAJorder_id: or_UkLWZg9DAJ@@ -6444,13 +6452,13 @@ paths:id: ps_UkLWZg9DAJstatus: pendingcurrency: USD- external_id: bogus_5a1b5dc24b815fab254a4bd3+ external_id: bogus_2c81450b3dbf127c8baba6ebexternal_data:client_secret: secret_123customer_external_id:expires_at:- created_at: '2026-03-17T11:09:36.962Z'- updated_at: '2026-03-17T11:09:36.962Z'+ created_at: '2026-03-17T13:31:40.824Z'+ updated_at: '2026-03-17T13:31:40.824Z'amount: '110.0'payment_method_id: pm_UkLWZg9DAJorder_id: or_UkLWZg9DAJ@@ -6507,13 +6515,13 @@ paths:id: ps_UkLWZg9DAJstatus: pendingcurrency: USD- external_id: bogus_458b7faedce75adc69b37dc0+ external_id: bogus_170c0d463f37fb14d294d956external_data:client_secret: secret_123customer_external_id:expires_at:- created_at: '2026-03-17T11:09:38.363Z'- updated_at: '2026-03-17T11:09:38.377Z'+ created_at: '2026-03-17T13:31:42.189Z'+ updated_at: '2026-03-17T13:31:42.205Z'amount: '50.0'payment_method_id: pm_UkLWZg9DAJorder_id: or_UkLWZg9DAJ@@ -6610,13 +6618,13 @@ paths:id: ps_UkLWZg9DAJstatus: completedcurrency: USD- external_id: bogus_89db7fabe62aabce53637a7b+ external_id: bogus_d2c49cb7be375df8dc495ee1external_data:client_secret: secret_123customer_external_id:expires_at:- created_at: '2026-03-17T11:09:38.974Z'- updated_at: '2026-03-17T11:09:38.988Z'+ created_at: '2026-03-17T13:31:42.807Z'+ updated_at: '2026-03-17T13:31:42.821Z'amount: '110.0'payment_method_id: pm_UkLWZg9DAJorder_id: or_UkLWZg9DAJ@@ -6696,11 +6704,11 @@ paths:example:id: pss_gbHJdmfrXBstatus: pending- external_id: bogus_seti_d2931be753228eabc5f3c112- external_client_secret: bogus_seti_secret_8d1f4d4a06981223+ external_id: bogus_seti_c57a7308d036f78cac969568+ external_client_secret: bogus_seti_secret_a7e281cd22b18e89external_data: {}- created_at: '2026-03-17T11:09:40.244Z'- updated_at: '2026-03-17T11:09:40.244Z'+ created_at: '2026-03-17T13:31:44.054Z'+ updated_at: '2026-03-17T13:31:44.054Z'payment_method_id: pm_UkLWZg9DAJpayment_source_id:payment_source_type:@@ -6797,12 +6805,12 @@ paths:example:id: pss_UkLWZg9DAJstatus: pending- external_id: seti_test_7c610767f186b826932dea5f- external_client_secret: seti_secret_f7cc91e162d62fac9b9c2cf3+ external_id: seti_test_0de4156b7058602d6da56ff6+ external_client_secret: seti_secret_79962547abd2392e8356076eexternal_data:client_secret: secret_123- created_at: '2026-03-17T11:09:41.891Z'- updated_at: '2026-03-17T11:09:41.891Z'+ created_at: '2026-03-17T13:31:45.722Z'+ updated_at: '2026-03-17T13:31:45.722Z'payment_method_id: pm_UkLWZg9DAJpayment_source_id:payment_source_type:@@ -6875,12 +6883,12 @@ paths:example:id: pss_UkLWZg9DAJstatus: completed- external_id: seti_test_dcaaf9cef3fbabd05e2c138e- external_client_secret: seti_secret_03d91fbdd0f280e260f738d5+ external_id: seti_test_2c35ad9cf75115b3ff052b35+ external_client_secret: seti_secret_0cb8754bfacba149b9a2dc17external_data:client_secret: secret_123- created_at: '2026-03-17T11:09:43.119Z'- updated_at: '2026-03-17T11:09:43.134Z'+ created_at: '2026-03-17T13:31:46.826Z'+ updated_at: '2026-03-17T13:31:46.840Z'payment_method_id: pm_UkLWZg9DAJpayment_source_id: card_UkLWZg9DAJpayment_source_type: Spree::CreditCard@@ -6967,11 +6975,11 @@ paths:- id: py_UkLWZg9DAJpayment_method_id: pm_UkLWZg9DAJresponse_code: '12345'- number: PCORBMQO+ number: PY8ZTQQNamount: '110.0'display_amount: "$110.00"- created_at: '2026-03-17T11:09:44.332Z'- updated_at: '2026-03-17T11:09:44.332Z'+ created_at: '2026-03-17T13:31:48.006Z'+ updated_at: '2026-03-17T13:31:48.006Z'status: checkoutsource_type: credit_cardsource_id: card_UkLWZg9DAJ@@ -7058,11 +7066,11 @@ paths:id: py_UkLWZg9DAJpayment_method_id: pm_UkLWZg9DAJresponse_code:- number: P6EYDMHH+ number: P82H6TJCamount: '110.0'display_amount: "$110.00"- created_at: '2026-03-17T11:09:44.970Z'- updated_at: '2026-03-17T11:09:44.970Z'+ created_at: '2026-03-17T13:31:48.637Z'+ updated_at: '2026-03-17T13:31:48.637Z'status: checkoutsource_type:source_id:@@ -7220,18 +7228,20 @@ paths:example:data:- id: prod_UkLWZg9DAJ- name: Product 623688- description: Praesentium cumque veniam ut eligendi. Aspernatur aliquid- consequatur animi illo. Animi ab quisquam soluta quos recusandae- repudiandae facilis quidem. Saepe ut voluptatibus rerum asperiores- sunt officiis.- slug: product-623688+ name: Product 623014+ description: |-+ Voluptatum non doloribus fugiat unde adipisci. Debitis natus molestiae cumque omnis ad. Repellendus quibusdam explicabo nobis veniam quas harum suscipit libero.+ Tempore reiciendis ipsa dolor inventore illum. Ut veniam minus hic velit vel. Officia soluta sequi nam tempore. Maxime officia esse repudiandae exercitationem. Quasi quisquam necessitatibus nemo fugiat at soluta explicabo.+ Ratione excepturi dignissimos tempore a recusandae sunt accusantium ex. Fuga ea dolore qui voluptatibus nihil. Nisi ipsum reprehenderit magnam perferendis nemo similique. Aliquam ratione sed eos et repellat id cupiditate nam.+ Similique saepe a sit adipisci illum cumque quae. Laborum a aliquid adipisci cupiditate officiis omnis perferendis. Nesciunt repellendus ab cumque ullam necessitatibus. Rem itaque similique quasi ullam. Expedita deleniti et possimus dolor quis.+ Quibusdam et odit cupiditate cumque voluptas dolorem illo accusantium. Aliquid dicta voluptatum eligendi odio quod. Libero eos officiis ipsa dicta. Labore dolorem eveniet repudiandae optio nemo.+ slug: product-623014meta_description:meta_keywords:variant_count: 1- available_on: '2025-03-17T11:09:45.768Z'- created_at: '2026-03-17T11:09:45.785Z'- updated_at: '2026-03-17T11:09:45.835Z'+ available_on: '2025-03-17T13:31:49.320Z'+ created_at: '2026-03-17T13:31:49.339Z'+ updated_at: '2026-03-17T13:31:49.388Z'purchasable: truein_stock: falsebackorderable: true@@ -7251,19 +7261,20 @@ paths:price_list_id:original_price:- id: prod_gbHJdmfrXB- name: Product 63680+ name: Product 635757description: |-- Distinctio sed illo sunt nostrum similique doloribus. Unde eligendi culpa rem sit dolor voluptatibus. Consectetur et quod maxime veniam nemo sunt molestias explicabo. Inventore porro molestiae quod esse consectetur. Assumenda blanditiis ex ipsam deserunt esse reiciendis quam repudiandae.- Voluptatibus pariatur quis in quas. Optio architecto eveniet qui enim. Accusantium labore beatae doloribus cum placeat eligendi quia reiciendis. Hic ducimus recusandae quae repellat necessitatibus praesentium eos.- Doloribus modi debitis vero aliquid incidunt consectetur occaecati sequi. Quas incidunt quia fuga saepe tempora. Blanditiis magni error sequi officiis illum soluta minus animi. Magni minima facilis reiciendis qui possimus.- Velit culpa sit soluta quidem. Corporis consectetur eveniet ratione placeat. Quam perspiciatis natus debitis quod.- slug: product-63680+ Eos numquam voluptas optio quis possimus libero. Cupiditate vel officiis neque quia magni. Ipsa delectus quae dolores iure repellat consequuntur amet. Suscipit minima inventore pariatur magnam fugit officia.+ Sed accusantium vitae sit doloribus. Est tempora quaerat aspernatur officia minima tempore ratione. Similique accusantium soluta ex a saepe animi. Reiciendis nulla harum rerum repellendus commodi. Eos hic praesentium dicta aspernatur nostrum dolorem.+ Quam aliquam maxime ipsa assumenda. Earum possimus officiis debitis reiciendis. Quaerat nisi tempora et corrupti eaque est earum. Suscipit dolore laudantium illo ipsa. Ab voluptatem totam id incidunt reiciendis temporibus quo architecto.+ Deserunt sint temporibus natus expedita dolorum. Molestiae at eos omnis sed ad nemo nisi placeat. Aut quasi aliquam praesentium vitae esse vero officia architecto.+ Ad amet natus accusamus vitae. Blanditiis nesciunt molestiae magni perspiciatis dolorem. Ea earum id dolorem laboriosam assumenda nobis. Sit recusandae quos non accusamus iusto nesciunt ipsa.+ slug: product-635757meta_description:meta_keywords:variant_count: 0- available_on: '2025-03-17T11:09:45.841Z'- created_at: '2026-03-17T11:09:45.853Z'- updated_at: '2026-03-17T11:09:45.868Z'+ available_on: '2025-03-17T13:31:49.395Z'+ created_at: '2026-03-17T13:31:49.406Z'+ updated_at: '2026-03-17T13:31:49.422Z'purchasable: truein_stock: falsebackorderable: true@@ -7369,17 +7380,20 @@ paths:application/json:example:id: prod_UkLWZg9DAJ- name: Product 745151+ name: Product 741721description: |-- Nisi ad quidem voluptatum eos error voluptate quis illum. Neque eveniet sunt non ab hic quibusdam magnam. Quia nemo mollitia quisquam rerum voluptatibus minus architecto aspernatur. Impedit harum occaecati non dolorum in. Atque repellendus est ex officia nesciunt nobis eaque.- Deserunt sapiente nemo incidunt perferendis recusandae sed iste. Sunt nesciunt omnis iure at nobis saepe aliquid tempore. Laudantium sapiente cumque quaerat maiores atque. In iure suscipit officiis reprehenderit et quae placeat necessitatibus. Doloremque ipsam fugit eos sed hic.- slug: product-745151+ Minima fugit laborum nihil aliquam voluptatem eius adipisci. Laboriosam voluptate ipsum laudantium nesciunt. Ipsa rem molestias iure ex est temporibus deleniti numquam.+ Eum animi ipsum libero nihil quisquam quas culpa. Repellat facere velit quasi autem. Fugiat suscipit eius adipisci laborum.+ Necessitatibus quod reprehenderit cumque provident quia aut. Similique ad recusandae non magnam officiis nostrum eaque. Iste mollitia non neque blanditiis asperiores facilis. Rerum dolore enim mollitia molestiae deserunt porro.+ Dolor deleniti cum autem laboriosam occaecati delectus non blanditiis. Quaerat earum nisi commodi occaecati dolor. Maiores sit voluptatum possimus sequi esse.+ Eius voluptatem expedita dignissimos odit. Vero rerum quasi quidem repudiandae dolor odio. Deserunt repellendus nihil in magnam laudantium.+ slug: product-741721meta_description:meta_keywords:variant_count: 1- available_on: '2025-03-17T11:09:46.482Z'- created_at: '2026-03-17T11:09:46.507Z'- updated_at: '2026-03-17T11:09:46.550Z'+ available_on: '2025-03-17T13:31:50.030Z'+ created_at: '2026-03-17T13:31:50.058Z'+ updated_at: '2026-03-17T13:31:50.102Z'purchasable: truein_stock: falsebackorderable: true@@ -7601,9 +7615,9 @@ paths:application/json:example:id: cart_UkLWZg9DAJ- number: R976729305- token: 67N62YvK6jAwc6saY88Dor3oXH3yCJ6SwEd- email: [email protected]+ number: R603145577+ token: nhuCGHm3NS2fn55nGW77n3SqF5ZFoo7MDXJ+ email: [email protected]special_instructions:currency: USDlocale: en@@ -7622,8 +7636,8 @@ paths:display_additional_tax_total: "$0.00"total: '110.0'display_total: "$110.00"- created_at: '2026-03-17T11:09:48.613Z'- updated_at: '2026-03-17T11:09:48.664Z'+ created_at: '2026-03-17T13:31:52.072Z'+ updated_at: '2026-03-17T13:31:52.122Z'delivery_total: '100.0'display_delivery_total: "$100.00"current_step: address@@ -7635,8 +7649,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 1026026- slug: product-1026026+ name: Product 1027725+ slug: product-1027725options_text: ''price: '10.0'display_price: "$10.00"@@ -7655,21 +7669,21 @@ paths:discounted_amount: '10.0'display_discounted_amount: "$10.00"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:48.642Z'- updated_at: '2026-03-17T11:09:48.642Z'+ created_at: '2026-03-17T13:31:52.100Z'+ updated_at: '2026-03-17T13:31:52.100Z'compare_at_amount:thumbnail_url:option_values: []digital_links: []fulfillments:- id: ful_UkLWZg9DAJ- number: H29586878850+ number: H80881646234tracking: U10000tracking_url:cost: '100.0'display_cost: "$100.00"- created_at: '2026-03-17T11:09:48.648Z'- updated_at: '2026-03-17T11:09:48.661Z'+ created_at: '2026-03-17T13:31:52.105Z'+ updated_at: '2026-03-17T13:31:52.119Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -7684,7 +7698,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_262- name: Dulcie Yundt+ name: Ezra Jerdeaddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -7705,12 +7719,12 @@ paths:payments:- id: py_UkLWZg9DAJpayment_method_id: pm_UkLWZg9DAJ- response_code: 1-SC-20260317110948977896- number: P2PV9JH9+ response_code: 1-SC-20260317133152444067+ number: PR7UTZELamount: '10.0'display_amount: "$10.00"- created_at: '2026-03-17T11:09:48.982Z'- updated_at: '2026-03-17T11:09:48.982Z'+ created_at: '2026-03-17T13:31:52.448Z'+ updated_at: '2026-03-17T13:31:52.448Z'status: checkoutsource_type: store_creditsource_id: credit_UkLWZg9DAJ@@ -7842,9 +7856,9 @@ paths:application/json:example:id: cart_UkLWZg9DAJ- number: R879324607- token: bVMf5uqHWM8t6vkodTQkVMt6eEsqgqxXKvE- email: [email protected]+ number: R763668804+ token: ju4W396u9wfnVBmEmjRuXFmkFea6T3qh6c7+ email: [email protected]special_instructions:currency: USDlocale: en@@ -7863,8 +7877,8 @@ paths:display_additional_tax_total: "$0.00"total: '110.0'display_total: "$110.00"- created_at: '2026-03-17T11:09:50.167Z'- updated_at: '2026-03-17T11:09:50.227Z'+ created_at: '2026-03-17T13:31:53.645Z'+ updated_at: '2026-03-17T13:31:53.735Z'delivery_total: '100.0'display_delivery_total: "$100.00"current_step: address@@ -7879,8 +7893,8 @@ paths:variant_id: variant_UkLWZg9DAJquantity: 1currency: USD- name: Product 10430- slug: product-10430+ name: Product 1048280+ slug: product-1048280options_text: ''price: '10.0'display_price: "$10.00"@@ -7899,21 +7913,21 @@ paths:discounted_amount: '10.0'display_discounted_amount: "$10.00"display_compare_at_amount: "$0.00"- created_at: '2026-03-17T11:09:50.195Z'- updated_at: '2026-03-17T11:09:50.195Z'+ created_at: '2026-03-17T13:31:53.689Z'+ updated_at: '2026-03-17T13:31:53.689Z'compare_at_amount:thumbnail_url:option_values: []digital_links: []fulfillments:- id: ful_UkLWZg9DAJ- number: H41153821153+ number: H78102974840tracking: U10000tracking_url:cost: '100.0'display_cost: "$100.00"- created_at: '2026-03-17T11:09:50.202Z'- updated_at: '2026-03-17T11:09:50.222Z'+ created_at: '2026-03-17T13:31:53.701Z'+ updated_at: '2026-03-17T13:31:53.730Z'status: pendingfulfillment_type: shippingfulfilled_at:@@ -7928,7 +7942,7 @@ paths:stock_location:id: sloc_UkLWZg9DAJstate_abbr: STATE_ABBR_270- name: Reda Kling+ name: Remedios Bradtkeaddress1: 1600 Pennsylvania Ave NWcity: Washingtonzipcode: '20500'@@ -8044,9 +8058,9 @@ paths:data:- id: wl_UkLWZg9DAJname: My Wishlist- token: KEqyqC2e64MuP6PqNq1VEEMt- created_at: '2026-03-17T11:09:50.854Z'- updated_at: '2026-03-17T11:09:50.854Z'+ token: b2FWPXMe1zYUt44v5b844iMd+ created_at: '2026-03-17T13:31:54.386Z'+ updated_at: '2026-03-17T13:31:54.386Z'is_default: falseis_private: truemeta:@@ -8122,9 +8136,9 @@ paths:example:id: wl_gbHJdmfrXBname: Birthday Ideas- token: fLj9TtN1WWbZUi1jC3mzAbq5- created_at: '2026-03-17T11:09:52.079Z'- updated_at: '2026-03-17T11:09:52.079Z'+ token: 6SUAvk35qCyNReLdDkEdqajK+ created_at: '2026-03-17T13:31:55.809Z'+ updated_at: '2026-03-17T13:31:55.809Z'is_default: falseis_private: trueschema:@@ -8220,9 +8234,9 @@ paths:example:id: wl_UkLWZg9DAJname: My Wishlist- token: PKxgiBGzYXXxcKYiT4qQ55dk- created_at: '2026-03-17T11:09:53.301Z'- updated_at: '2026-03-17T11:09:53.301Z'+ token: SikYNpQzsrATdQFECHcEREjE+ created_at: '2026-03-17T13:31:56.958Z'+ updated_at: '2026-03-17T13:31:56.958Z'is_default: falseis_private: trueschema:@@ -8284,9 +8298,9 @@ paths:example:id: wl_UkLWZg9DAJname: Updated Name- token: gKtD7oQkECeoD7K59VSSCyRa- created_at: '2026-03-17T11:09:54.446Z'- updated_at: '2026-03-17T11:09:54.484Z'+ token: wPW3f7PtPeEMYC2ViaERbRxN+ created_at: '2026-03-17T13:31:58.314Z'+ updated_at: '2026-03-17T13:31:58.419Z'is_default: falseis_private: trueschema:@@ -8398,8 +8412,8 @@ paths:variant_id: variant_gbHJdmfrXBwishlist_id: wl_UkLWZg9DAJquantity: 1- created_at: '2026-03-17T11:09:55.680Z'- updated_at: '2026-03-17T11:09:55.680Z'+ created_at: '2026-03-17T13:31:59.669Z'+ updated_at: '2026-03-17T13:31:59.669Z'variant:id: variant_gbHJdmfrXBproduct_id: prod_gbHJdmfrXB@@ -8407,8 +8421,8 @@ paths:options_text: ''track_inventory: truemedia_count: 0- created_at: '2026-03-17T11:09:55.653Z'- updated_at: '2026-03-17T11:09:55.664Z'+ created_at: '2026-03-17T13:31:59.643Z'+ updated_at: '2026-03-17T13:31:59.652Z'thumbnail_url:purchasable: truein_stock: false@@ -8653,10 +8667,14 @@ components:token:type: stringdescription: JWT access token+ refresh_token:+ type: string+ description: Refresh token for obtaining new access tokensuser:"$ref": "#/components/schemas/Customer"required:- token+ - refresh_token- userCheckoutRequirement:type: objectdiff --git a/docs/plans/6.0-platform-auth.md b/docs/plans/6.0-platform-auth.mdnew file mode 100644index 0000000000..3ba29d2d2b--- /dev/null+++ b/docs/plans/6.0-platform-auth.md@@ -0,0 +1,386 @@+# Platform-Owned Authentication & User Model Rename++**Status:** In Progress (RefreshToken shipping in 5.5, rest in 6.0)+**Target:** Spree 5.5 (RefreshToken) + Spree 6.0 (Devise removal, User→Customer rename)+**Depends on:** Admin SPA (6.0-admin-spa.md — removes Rails admin, kills Devise dependency) for Devise removal+**Author:** Damian + Claude+**Last updated:** 2026-03-17++## Summary++Two changes in one plan:++1. **Drop Devise, own the auth stack.** Spree already has a JWT-based, strategy-pattern auth system that's fully independent of Devise for the API layer. Devise is only used by the deprecated Rails admin (being replaced by React SPA in 6.0). Remove the Devise dependency entirely and make Spree's built-in auth the default — `has_secure_password`, JWT tokens, pluggable strategies.++2. **Rename User → Customer.** `Spree.user_class` → `Spree.customer_class`. Default customer model becomes `Spree::Customer` (replaces `Spree::LegacyUser`). `Spree.admin_user_class` stays, default becomes `Spree::AdminUser` (replaces `Spree::LegacyAdminUser`). "User" is ambiguous — "customer" is what storefront users actually are.++## Problem++### Devise dependency++1. **Wrong tool for headless.** Devise is a full-stack Rails auth library — controllers, views, routes, Warden middleware, cookie sessions. Spree is API-first with JWT tokens. Devise provides ~5% of its surface area to Spree (password hashing, reset tokens), the rest is dead weight.++2. **Sends the wrong signal.** TypeScript developers evaluating Spree see Devise in the dependency chain and think "this is a Rails monolith." Removing it strengthens the API-first positioning.++3. **Already built.** The core auth stack is already implemented and operational:+ - `Spree::Authentication::Strategies::BaseStrategy` — pluggable strategy pattern+ - `Spree::Authentication::Strategies::EmailPasswordStrategy` — email+password with bcrypt+ - `Spree::UserIdentity` — OAuth/social login identity storage+ - JWT issuance and validation in API v3 controllers+ - API key system (publishable `pk_*` + secret `sk_*`)+ - Password reset via `generates_token_for` (Rails 7.1+)++4. **Conditional dependency anyway.** Devise is not in any gemspec — it's already optional via conditional inheritance in the legacy admin controllers (`defined?(Devise::SessionsController) ? Devise::SessionsController : ...`). The legacy Rails admin is being replaced by the React SPA.++### User naming++5. **"User" is ambiguous.** `Spree.user_class` could mean customer, admin, API consumer, or anyone. Every new developer asks "which user?" The model is `Spree::LegacyUser` — the name itself admits the problem.++6. **API already uses "customer."** Store API endpoints are `/store/customers`, `/store/customer`, the serializer is `CustomerSerializer`. But the model is `Spree.user_class`. This mismatch confuses developers.++## Current State++### Auth system++| Component | Status | Location |+|---|---|---|+| JWT issuance/validation | Built | `api/controllers/concerns/spree/api/v3/jwt_authentication.rb` |+| API key auth (pk/sk) | Built | `api/controllers/concerns/spree/api/v3/api_key_authentication.rb` |+| Strategy framework | Built | `core/app/models/spree/authentication/strategies/base_strategy.rb` |+| Email+password strategy | Built | `core/app/models/spree/authentication/strategies/email_password_strategy.rb` |+| OAuth identity storage | Built | `core/app/models/spree/user_identity.rb` |+| Password reset tokens | Built | `core/app/models/concerns/spree/user_methods.rb` (via `generates_token_for`) |+| Store API auth endpoints | Built | `api/controllers/spree/api/v3/store/auth_controller.rb` |+| Rate limiting | Available | Rails 7.1+ `rate_limit` DSL |+| Devise (legacy admin only) | Conditional | `admin/app/controllers/spree/admin/user_sessions_controller.rb` |++### User models++| Current | Purpose | Default class |+|---|---|---|+| `Spree.user_class` | Storefront customer | `Spree::LegacyUser` |+| `Spree.admin_user_class` | Admin/staff user | `Spree::LegacyAdminUser` |++## Key Decisions (do not deviate without discussion)++### Auth++- **Drop Devise entirely.** No conditional fallbacks, no generator, no `devise_for` routes. The legacy Rails admin is gone in 6.0 (replaced by React SPA).+- **`has_secure_password` is the foundation.** Rails core, no gem dependency. Handles bcrypt hashing, `authenticate(password)` method, password confirmation validation.+- **JWT stays as-is.** Short-lived access tokens, separate audiences for store (`store_api`) and admin (`admin_api`). Already implemented and working.+- **Strategy pattern stays as-is.** `Spree.store_authentication_strategies` and `Spree.admin_authentication_strategies` for registering custom providers.+- **Add refresh token support (5.5).** Short-lived access JWT (15 min) + long-lived refresh token (stored in DB, rotatable, revocable). Better UX for React admin and Next.js storefront — silent refresh instead of forced re-login. Ships in 5.5 — can't wait for 6.0 because every storefront has broken session management without it.+- **Rate limiting on auth endpoints.** Use Rails `rate_limit` DSL on login, register, and password reset endpoints. Baked in, not optional.+- **Account lockout after failed attempts.** Track `failed_attempts` and `locked_at` on Customer/AdminUser model. Simple, no Devise dependency.+- **Remove all Devise generators.** Drop `spree/authentication/devise/` generator directory.+- **Keep the adapter pattern.** `Spree.store_authentication_strategies` lets developers plug in Auth0, Clerk, Firebase, LDAP, etc. by implementing `BaseStrategy`.++### User → Customer/AdminUser rename++- **`Spree.user_class` → `Spree.customer_class`**. Deprecation alias for one release.+- **`Spree.admin_user_class` stays as-is.** Model stays `Spree::AdminUser`, accessor stays `admin_user_class`. Only the default implementation changes from `LegacyAdminUser` to `AdminUser`.+- **Default models: `Spree::Customer` and `Spree::AdminUser`**. Replace `Spree::LegacyUser` and `Spree::LegacyAdminUser`.+- **`Spree::Customer` includes `has_secure_password`** and all auth concerns by default. Production-ready out of the box, not a "legacy" placeholder.+- **`Spree::AdminUser` includes `has_secure_password`** and admin auth concerns.+- **Prefix IDs: `cust_` for Customer, `adm_` for AdminUser.**+- **Concerns renamed:** `Spree::UserMethods` → `Spree::CustomerMethods`, `Spree::AdminUserMethods` stays as-is. Aliases for one release.+- **Database tables stay configurable.** `Spree.customer_class` can point to any model — `User`, `Customer`, whatever the app uses. The rename is about the Spree interface and defaults, not forcing a table name.++## Design Details++### Spree::Customer (replaces LegacyUser)++```ruby+class Spree::Customer < Spree.base_class+ has_prefix_id :cust++ has_secure_password++ include Spree::CustomerMethods # orders, addresses, payments, wishlists+ include Spree::Metafields+ include Spree::Metadata++ has_many :identities, class_name: 'Spree::UserIdentity', as: :user, dependent: :destroy++ validates :email, presence: true, uniqueness: { case_sensitive: false }++ # Account security+ attribute :failed_attempts, :integer, default: 0+ attribute :locked_at, :datetime++ def locked?+ locked_at.present? && locked_at > 30.minutes.ago+ end++ def record_failed_attempt!+ increment!(:failed_attempts)+ update!(locked_at: Time.current) if failed_attempts >= 5+ end++ def reset_failed_attempts!+ update!(failed_attempts: 0, locked_at: nil)+ end+end+```++### Spree::AdminUser (replaces LegacyAdminUser)++```ruby+class Spree::AdminUser < Spree.base_class+ has_prefix_id :adm++ has_secure_password++ include Spree::AdminUserMethods # roles, permissions, store access+ include Spree::Metafields+ include Spree::Metadata++ has_many :identities, class_name: 'Spree::UserIdentity', as: :user, dependent: :destroy++ validates :email, presence: true, uniqueness: { case_sensitive: false }++ attribute :failed_attempts, :integer, default: 0+ attribute :locked_at, :datetime+end+```++### Refresh Token Model++```ruby+class Spree::RefreshToken < Spree.base_class+ has_prefix_id :rt++ belongs_to :user, polymorphic: true # Customer or AdminUser++ has_secure_token :token++ validates :token, :expires_at, presence: true++ scope :active, -> { where('expires_at > ?', Time.current) }+ scope :expired, -> { where('expires_at <= ?', Time.current) }++ attribute :expires_at, :datetime+ attribute :ip_address, :string+ attribute :user_agent, :string++ def expired?+ expires_at <= Time.current+ end++ def rotate!+ transaction do+ destroy!+ self.class.create!(+ user: user,+ expires_at: 30.days.from_now,+ ip_address: ip_address,+ user_agent: user_agent+ )+ end+ end+end+```++### Auth API Endpoints++```+# Store API+POST /api/v3/store/auth/login # email+password → access JWT + refresh token+POST /api/v3/store/auth/refresh # refresh token → new access JWT + rotated refresh token+POST /api/v3/store/auth/logout # revoke refresh token+POST /api/v3/store/auth/oauth/callback # OAuth provider callback → JWT + refresh token++POST /api/v3/store/customers # register → JWT + refresh token+POST /api/v3/store/customer/password_resets # request reset email+PATCH /api/v3/store/customer/password_resets/:token # consume token, set password → JWT++# Admin API+POST /api/v3/admin/auth/login # email+password → access JWT + refresh token+POST /api/v3/admin/auth/refresh # refresh token → new access JWT+POST /api/v3/admin/auth/logout # revoke refresh token+```++### Auth Flow++```+1. Customer visits storefront+2. Login: POST /auth/login { email, password }+ → EmailPasswordStrategy.authenticate(email, password, request_env)+ → Strategy returns success(customer) or failure(message)+ → Controller issues: { access_token: JWT (15 min), refresh_token: "rt_xxx" (30 days) }++3. API requests: Authorization: Bearer <access_token>+ → JwtAuthentication concern validates, sets current_customer++4. Token expires (15 min)+ → POST /auth/refresh { refresh_token: "rt_xxx" }+ → Validate refresh token, rotate it, issue new access JWT+ → Returns: { access_token: new JWT, refresh_token: "rt_yyy" (rotated) }++5. Logout: POST /auth/logout { refresh_token: "rt_xxx" }+ → Delete refresh token from DB+```++### Configuration++```ruby+Spree.configure do |config|+ # Customer auth strategies (extensible)+ config.store_authentication_strategies = {+ email: Spree::Authentication::Strategies::EmailPasswordStrategy+ # Add custom: google: MyApp::Auth::GoogleStrategy+ }++ # Admin auth strategies+ config.admin_authentication_strategies = {+ email: Spree::Authentication::Strategies::EmailPasswordStrategy+ }++ # JWT config+ config.jwt_access_token_expiry = 15.minutes+ config.jwt_secret = Rails.application.secret_key_base++ # Refresh token config+ config.refresh_token_expiry = 30.days++ # Account lockout+ config.max_failed_login_attempts = 5+ config.lockout_duration = 30.minutes+end+```++### Custom Auth Provider Example++```ruby+# Using Auth0+class MyApp::Auth::Auth0Strategy < Spree::Authentication::Strategies::BaseStrategy+ def provider+ :auth0+ end++ def authenticate(email, token, request_env = {})+ # Verify Auth0 JWT+ payload = Auth0Client.verify(token)+ user = find_user_by_email(payload['email']) ||+ find_or_create_user_from_oauth(+ provider: 'auth0',+ uid: payload['sub'],+ info: { email: payload['email'], name: payload['name'] }+ )+ success(user)+ rescue Auth0Client::InvalidToken => e+ failure(e.message)+ end+end++# Register in config+Spree.configure do |config|+ config.store_authentication_strategies[:auth0] = MyApp::Auth::Auth0Strategy+end+```++## Migration Path++### Phase 1: Customer/AdminUser models + has_secure_password++```ruby+class CreateSpreeCustomersAndAdminUsers < ActiveRecord::Migration[7.2]+ def change+ # If app uses custom user tables, these aren't needed.+ # For new installs using Spree defaults:++ create_table :spree_customers do |t|+ t.string :email, null: false+ t.string :password_digest, null: false+ t.integer :failed_attempts, null: false, default: 0+ t.datetime :locked_at+ t.jsonb :metadata+ t.timestamps+ end+ add_index :spree_customers, :email, unique: true++ create_table :spree_admin_users do |t|+ t.string :email, null: false+ t.string :password_digest, null: false+ t.integer :failed_attempts, null: false, default: 0+ t.datetime :locked_at+ t.jsonb :metadata+ t.timestamps+ end+ add_index :spree_admin_users, :email, unique: true++ # Refresh tokens+ create_table :spree_refresh_tokens do |t|+ t.string :token, null: false+ t.references :user, polymorphic: true, null: false+ t.datetime :expires_at, null: false+ t.string :ip_address+ t.string :user_agent+ t.timestamps+ end+ add_index :spree_refresh_tokens, :token, unique: true+ add_index :spree_refresh_tokens, [:user_type, :user_id]+ add_index :spree_refresh_tokens, :expires_at+ end+end+```++### Phase 2: Data migration (for existing Devise-based installs)++No data migration is needed — just change `user_class` to `customer_class` in Spree initializer. For both Devise-based and custom user models.++### Phase 3: Rename config accessors + concerns++- `Spree.user_class` → `Spree.customer_class` (deprecation alias for `user_class`)+- `Spree.admin_user_class` stays as-is+- `Spree::UserMethods` → `Spree::CustomerMethods` (deprecation alias)+- `Spree::AdminUserMethods` stays as-is+- `Spree::LegacyUser` → `Spree::Customer` (new default)+- `Spree::LegacyAdminUser` → `Spree::AdminUser` (new default, production-ready)+- Rename `user_id` FK → `customer_id` on 11 customer-facing tables (see decisions.md entry)+- Update `belongs_to :user` → `belongs_to :customer` on those models++### Phase 4: Refresh token support++- Create `Spree::RefreshToken` model+- Update `AuthController` to issue refresh tokens alongside access JWTs+- Add `POST /auth/refresh` and `POST /auth/logout` endpoints+- Add rate limiting to auth endpoints+- Add account lockout to Customer/AdminUser++### Phase 5: Remove Devise++- Delete `spree/core/lib/generators/spree/authentication/devise/` directory+- Delete `spree/admin/lib/generators/spree/admin/devise/` directory+- Delete `spree/admin/app/controllers/spree/admin/user_sessions_controller.rb`+- Delete `spree/admin/app/controllers/spree/admin/user_passwords_controller.rb`+- Remove all `defined?(Devise::...)` conditional checks+- Remove Warden references from controller helpers+- Delete `Spree::LegacyUser` and `Spree::LegacyAdminUser`++### Phase 6: Cleanup (still 6.0)++- Remove deprecation alias for `user_class` (keep only `customer_class`)+- Remove `Spree::OauthAccessToken` if any references remain+- Update all docs referencing Devise++## Constraints on Current Work++- **Don't add new Devise dependencies.** No new `devise_for`, no new Devise controller inheritance.+- **Use `Spree.user_class` / `Spree.admin_user_class` for now** — `user_class` will become `customer_class` in 6.0, `admin_user_class` stays.+- **New auth features should use the strategy pattern.** Don't bypass `BaseStrategy` for auth logic.+- **JWT tokens are the only API auth mechanism.** No cookie sessions in API controllers.++## Open Questions++None at this time.++## References++- Current auth strategy: `spree/core/app/models/spree/authentication/strategies/base_strategy.rb`+- Current JWT implementation: `spree/api/app/controllers/concerns/spree/api/v3/jwt_authentication.rb`+- Current user models: `spree/core/app/models/spree/legacy_user.rb`, `spree/core/app/models/spree/legacy_admin_user.rb`+- Current user concerns: `spree/core/app/models/concerns/spree/user_methods.rb`, `spree/core/app/models/concerns/spree/admin_user_methods.rb`+- Devise generators (to be removed): `spree/core/lib/generators/spree/authentication/devise/`+- Related plan: `6.0-admin-spa.md` (React admin removes Rails admin, kills Devise dependency)+- Related plan: `6.0-channels-catalogs-b2b.md` (Company → CompanyContact references customer/staff)diff --git a/docs/plans/decisions.md b/docs/plans/decisions.mdindex ec528c4ece..6c330366ff 100644--- a/docs/plans/decisions.md+++ b/docs/plans/decisions.md@@ -1,3 +1,44 @@+## 2026-03-17: Rename StockItem → StockLevel+`Spree::StockItem` → `Spree::StockLevel`, `spree_stock_items` → `spree_stock_levels`.+Prefix ID: `si_` → `sl_`.++Every other platform uses "level" for this concept — Shopify (`InventoryLevel`),+Medusa (`InventoryLevel`), Vendure (`StockLevel`), Saleor (`Stock`). "Item" sounds+like a physical object; "level" correctly describes "the quantity of a variant at+a location."++Part of the 6.0 model rename wave. Includes renaming the FK columns+(`stock_item_id` → `stock_level_id`) on StockMovement, StockReservation, and+any other referencing tables.++## 2026-03-16: Rename user_id → customer_id on customer-facing models+As part of the User → Customer rename (6.0-platform-auth.md), rename `user_id`+foreign key columns to `customer_id` on all models where the FK references a+storefront customer (not an admin user).++**Rename to `customer_id`** (11 models — FK references Spree.customer_class):+- `spree_orders.user_id` → `customer_id`+- `spree_addresses.user_id` → `customer_id`+- `spree_credit_cards.user_id` → `customer_id`+- `spree_store_credits.user_id` → `customer_id`+- `spree_wishlists.user_id` → `customer_id`+- `spree_gift_cards.user_id` → `customer_id`+- `spree_gateway_customers.user_id` → `customer_id`+- `spree_payment_sources.user_id` → `customer_id`+- `spree_newsletter_subscribers.user_id` → `customer_id`+- `spree_promotion_rule_users.user_id` → `customer_id`+- `spree_customer_group_users.user_id` → `customer_id`++**Keep as `user_id`** (5 models — FK references Spree.admin_user_class or is polymorphic):+- `spree_imports.user_id` — admin who ran the import+- `spree_exports.user_id` — admin who ran the export+- `spree_reports.user_id` — admin who generated the report+- `spree_state_changes.user_id` — admin who triggered the change+- `spree_user_identities.user_id` — polymorphic (Customer or AdminUser)++Single migration renames all 11 columns. Model associations updated:+`belongs_to :user` → `belongs_to :customer` with `class_name: Spree.customer_class`.+## 2026-03-16: PaymentMethod and DeliveryMethod become SingleStoreResourceBoth PaymentMethod and DeliveryMethod (renamed from ShippingMethod) switch frommulti-store join tables (`StorePaymentMethod`, `StoreShippingMethod`) todiff --git a/packages/next/.changeset/fulfillment-delivery-rename.md b/packages/next/.changeset/fulfillment-delivery-rename.mddeleted file mode 100644index 544457c09b..0000000000--- a/packages/next/.changeset/fulfillment-delivery-rename.md+++ /dev/null@@ -1,15 +0,0 @@-----"@spree/next": minor------### Breaking: Shipping → Delivery/Fulfillment naming--Renamed server actions to match SDK 0.12.0 naming:--- `getShipments()` → `getFulfillments()`-- `selectShippingRate(shipmentId, rateId)` → `selectDeliveryRate(fulfillmentId, rateId)`--### Updated type re-exports--- `Shipment` → `Fulfillment`-- `ShippingRate` → `DeliveryRate`diff --git a/packages/next/.changeset/get-cart-explicit-id.md b/packages/next/.changeset/get-cart-explicit-id.mddeleted file mode 100644index 84d6cba61e..0000000000--- a/packages/next/.changeset/get-cart-explicit-id.md+++ /dev/null@@ -1,5 +0,0 @@-----"@spree/next": patch------Allow `getCart()` to accept an optional `explicitCartId` parameter. When provided, fetches that specific cart directly by ID instead of reading from cookies. Needed for the confirm-payment flow where the cart ID is known from the URL but cookies may have been cleared.diff --git a/packages/next/CHANGELOG.md b/packages/next/CHANGELOG.mdindex afe3c67bb7..a81357e618 100644--- a/packages/next/CHANGELOG.md+++ b/packages/next/CHANGELOG.md@@ -1,5 +1,40 @@# @spree/next+## 0.13.0++### Minor Changes++- ### Breaking: Shipping → Delivery/Fulfillment naming++ Renamed server actions to match SDK 0.12.0 naming:++ - `getShipments()` → `getFulfillments()`+ - `selectShippingRate(shipmentId, rateId)` → `selectDeliveryRate(fulfillmentId, rateId)`++ ### Updated type re-exports++ - `Shipment` → `Fulfillment`+ - `ShippingRate` → `DeliveryRate`++- ### Refresh token support++ - New `_spree_refresh_token` cookie — stored alongside JWT on login/register/password reset+ - `withAuthRefresh()` now uses refresh tokens for 401 recovery instead of re-sending the expired JWT+ - Proactive token refresh triggers at 5 minutes before expiry (was 1 hour)+ - `logout()` now revokes the refresh token server-side before clearing cookies+ - `login()`, `register()`, `resetPassword()` automatically save the refresh token cookie++### Patch Changes++- Allow `getCart()` to accept an optional `explicitCartId` parameter. When provided, fetches that specific cart directly by ID instead of reading from cookies. Needed for the confirm-payment flow where the cart ID is known from the URL but cookies may have been cleared.++## 1.0.0++### Patch Changes++- Updated dependencies []:+ - @spree/[email protected]+## 0.12.0### Minor Changesdiff --git a/packages/next/package.json b/packages/next/package.jsonindex 81c925644f..68c08dcbf1 100644--- a/packages/next/package.json+++ b/packages/next/package.json@@ -1,6 +1,6 @@{"name": "@spree/next",- "version": "0.12.0",+ "version": "0.13.0","description": "Next.js integration for Spree Commerce — server actions, caching, and cookie-based auth","type": "module","main": "./dist/index.js",@@ -62,7 +62,7 @@"url": "https://github.com/spree/spree/issues"},"peerDependencies": {- "@spree/sdk": ">=0.12.0",+ "@spree/sdk": ">=0.13.0","next": ">=15.0.0","react": ">=19.0.0"},diff --git a/packages/next/src/actions/auth.ts b/packages/next/src/actions/auth.tsindex a097178d2e..0ac2163d8f 100644--- a/packages/next/src/actions/auth.ts+++ b/packages/next/src/actions/auth.ts@@ -3,7 +3,7 @@import { revalidateTag } from 'next/cache';import type { Customer } from '@spree/sdk';import { getClient } from '../config';-import { setAccessToken, clearAccessToken, getAccessToken, getCartToken, getCartId, clearCartCookies } from '../cookies';+import { setAccessToken, clearAccessToken, getAccessToken, setRefreshToken, getRefreshToken, clearRefreshToken, getCartToken, getCartId, clearCartCookies } from '../cookies';import { withAuthRefresh } from '../auth-helpers';/**@@ -17,6 +17,7 @@ export async function login(try {const result = await getClient().auth.login({ email, password });await setAccessToken(result.token);+ await setRefreshToken(result.refresh_token);// Associate guest cart if one existsconst cartToken = await getCartToken();@@ -62,6 +63,7 @@ export async function register(try {const result = await getClient().customers.create(params);await setAccessToken(result.token);+ await setRefreshToken(result.refresh_token);// Associate guest cartconst cartToken = await getCartToken();@@ -94,7 +96,18 @@ export async function register(* from seeing/modifying the previous user's cart.*/export async function logout(): Promise<void> {+ // Revoke refresh token server-side+ const refreshToken = await getRefreshToken();+ if (refreshToken) {+ try {+ await getClient().auth.logout({ refresh_token: refreshToken });+ } catch {+ // Non-fatal — token may already be expired/revoked+ }+ }+await clearAccessToken();+ await clearRefreshToken();await clearCartCookies();revalidateTag('customer');revalidateTag('cart');@@ -115,6 +128,7 @@ export async function getCustomer(): Promise<Customer | null> {});} catch {await clearAccessToken();+ await clearRefreshToken();return null;}}@@ -152,6 +166,7 @@ export async function resetPassword(password_confirmation,});await setAccessToken(result.token);+ await setRefreshToken(result.refresh_token);revalidateTag('customer');revalidateTag('cart');return { success: true };diff --git a/packages/next/src/auth-helpers.ts b/packages/next/src/auth-helpers.tsindex 43491ffa84..0691a0fdc5 100644--- a/packages/next/src/auth-helpers.ts+++ b/packages/next/src/auth-helpers.ts@@ -1,11 +1,11 @@import { SpreeError } from '@spree/sdk';import type { RequestOptions } from '@spree/sdk';import { getClient } from './config';-import { getAccessToken, setAccessToken, clearAccessToken } from './cookies';+import { getAccessToken, setAccessToken, clearAccessToken, getRefreshToken, setRefreshToken, clearRefreshToken } from './cookies';/*** Get auth request options from the current JWT token.- * Proactively refreshes the token if it expires within 1 hour.+ * Proactively refreshes the token using the refresh token if the JWT is close to expiry.*/export async function getAuthOptions(): Promise<RequestOptions> {const token = await getAccessToken();@@ -19,14 +19,11 @@ export async function getAuthOptions(): Promise<RequestOptions> {const exp = payload.exp;const now = Math.floor(Date.now() / 1000);- // Refresh if token expires in less than 1 hour- if (exp && exp - now < 3600) {- try {- const refreshed = await getClient().auth.refresh({ token });- await setAccessToken(refreshed.token);- return { token: refreshed.token };- } catch {- // Refresh failed — use existing token, it might still work+ // Refresh if token expires in less than 5 minutes+ if (exp && exp - now < 300) {+ const newToken = await tryRefresh();+ if (newToken) {+ return { token: newToken };}}} catch {@@ -54,18 +51,38 @@ export async function withAuthRefresh<T>(try {return await fn(options);} catch (error: unknown) {- // If 401, try refreshing the token once+ // If 401, try refreshing the token using the refresh tokenif (error instanceof SpreeError && error.status === 401) {- try {- const refreshed = await getClient().auth.refresh({ token: options.token });- await setAccessToken(refreshed.token);- return await fn({ token: refreshed.token });- } catch {- // Refresh failed — clear token and rethrow- await clearAccessToken();- throw error;+ const newToken = await tryRefresh();+ if (newToken) {+ return await fn({ token: newToken });}+ // Refresh failed — clear all auth cookies and rethrow+ await clearAccessToken();+ await clearRefreshToken();+ throw error;}throw error;}}++/**+ * Try to refresh the access token using the stored refresh token.+ * Returns the new access token on success, null on failure.+ */+async function tryRefresh(): Promise<string | null> {+ const refreshToken = await getRefreshToken();+ if (!refreshToken) return null;++ try {+ const refreshed = await getClient().auth.refresh({ refresh_token: refreshToken });+ await setAccessToken(refreshed.token);+ await setRefreshToken(refreshed.refresh_token);+ return refreshed.token;+ } catch {+ // Refresh token is invalid/expired — clear it+ await clearRefreshToken();+ await clearAccessToken();+ return null;+ }+}diff --git a/packages/next/src/cookies.ts b/packages/next/src/cookies.tsindex 8e639c9708..bf88bb299e 100644--- a/packages/next/src/cookies.ts+++ b/packages/next/src/cookies.ts@@ -3,8 +3,10 @@ import { getConfig } from './config';const DEFAULT_CART_COOKIE = '_spree_cart_token';const DEFAULT_ACCESS_TOKEN_COOKIE = '_spree_jwt';+const DEFAULT_REFRESH_TOKEN_COOKIE = '_spree_refresh_token';const CART_TOKEN_MAX_AGE = 60 * 60 * 24 * 30; // 30 daysconst ACCESS_TOKEN_MAX_AGE = 60 * 60 * 24 * 7; // 7 days+const REFRESH_TOKEN_MAX_AGE = 60 * 60 * 24 * 30; // 30 daysfunction getCartCookieName(): string {try {@@ -87,6 +89,36 @@ export async function clearAccessToken(): Promise<void> {});}+// --- Refresh Token ---++function getRefreshTokenCookieName(): string {+ return DEFAULT_REFRESH_TOKEN_COOKIE;+}++export async function getRefreshToken(): Promise<string | undefined> {+ const cookieStore = await cookies();+ return cookieStore.get(getRefreshTokenCookieName())?.value;+}++export async function setRefreshToken(token: string): Promise<void> {+ const cookieStore = await cookies();+ cookieStore.set(getRefreshTokenCookieName(), token, {+ httpOnly: true,+ secure: process.env.NODE_ENV === 'production',+ sameSite: 'lax',+ path: '/',+ maxAge: REFRESH_TOKEN_MAX_AGE,+ });+}++export async function clearRefreshToken(): Promise<void> {+ const cookieStore = await cookies();+ cookieStore.set(getRefreshTokenCookieName(), '', {+ maxAge: -1,+ path: '/',+ });+}+// --- Cart Options (combined cart + access tokens for cart/checkout/payment actions) ---export async function getCartOptions(): Promise<{diff --git a/packages/next/tests/auth-helpers.test.ts b/packages/next/tests/auth-helpers.test.tsindex 14188ac2e8..5692645ff0 100644--- a/packages/next/tests/auth-helpers.test.ts+++ b/packages/next/tests/auth-helpers.test.ts@@ -5,6 +5,7 @@ import { initSpreeNext, resetClient } from '../src/config';const mockClient = {auth: {refresh: vi.fn(),+ logout: vi.fn(),},};@@ -31,6 +32,14 @@ function makeJwt(expInSeconds: number): string {return `header.${btoa(JSON.stringify(payload))}.signature`;}+// Helper: mock cookies to return different values for different cookie names+function mockCookies(values: Record<string, string | undefined>) {+ mockCookieStore.get.mockImplementation((name: string) => {+ const value = values[name];+ return value ? { value } : undefined;+ });+}+describe('auth-helpers', () => {beforeEach(() => {vi.clearAllMocks();@@ -40,7 +49,7 @@ describe('auth-helpers', () => {describe('getAuthOptions', () => {it('returns empty object when no token', async () => {- mockCookieStore.get.mockReturnValue(undefined);+ mockCookies({});const options = await getAuthOptions();expect(options).toEqual({});});@@ -48,34 +57,48 @@ describe('auth-helpers', () => {it('returns token without refresh when far from expiry', async () => {const futureExp = Math.floor(Date.now() / 1000) + 86400; // 24h from nowconst jwt = makeJwt(futureExp);- mockCookieStore.get.mockReturnValue({ value: jwt });+ mockCookies({ '_spree_jwt': jwt });const options = await getAuthOptions();expect(options).toEqual({ token: jwt });expect(mockClient.auth.refresh).not.toHaveBeenCalled();});- it('refreshes token when near expiry', async () => {- const nearExp = Math.floor(Date.now() / 1000) + 1800; // 30min from now (< 1h)+ it('refreshes token using refresh_token when near expiry', async () => {+ const nearExp = Math.floor(Date.now() / 1000) + 120; // 2min from now (< 5min threshold)const jwt = makeJwt(nearExp);const newJwt = 'refreshed_token';- mockCookieStore.get.mockReturnValue({ value: jwt });- mockClient.auth.refresh.mockResolvedValue({ token: newJwt });+ mockCookies({ '_spree_jwt': jwt, '_spree_refresh_token': 'rt_old' });+ mockClient.auth.refresh.mockResolvedValue({ token: newJwt, refresh_token: 'rt_new' });const options = await getAuthOptions();expect(options).toEqual({ token: newJwt });- expect(mockClient.auth.refresh).toHaveBeenCalledWith({ token: jwt });+ expect(mockClient.auth.refresh).toHaveBeenCalledWith({ refresh_token: 'rt_old' });expect(mockCookieStore.set).toHaveBeenCalledWith('_spree_jwt',newJwt,expect.any(Object));+ expect(mockCookieStore.set).toHaveBeenCalledWith(+ '_spree_refresh_token',+ 'rt_new',+ expect.any(Object)+ );+ });++ it('uses original token when no refresh token available near expiry', async () => {+ const nearExp = Math.floor(Date.now() / 1000) + 120;+ const jwt = makeJwt(nearExp);+ mockCookies({ '_spree_jwt': jwt }); // no refresh token cookie++ const options = await getAuthOptions();+ expect(options).toEqual({ token: jwt });});it('uses original token when refresh fails near expiry', async () => {- const nearExp = Math.floor(Date.now() / 1000) + 1800;+ const nearExp = Math.floor(Date.now() / 1000) + 120;const jwt = makeJwt(nearExp);- mockCookieStore.get.mockReturnValue({ value: jwt });+ mockCookies({ '_spree_jwt': jwt, '_spree_refresh_token': 'rt_old' });mockClient.auth.refresh.mockRejectedValue(new Error('Refresh failed'));const options = await getAuthOptions();@@ -84,7 +107,7 @@ describe('auth-helpers', () => {it('uses token as-is when JWT cannot be decoded', async () => {const malformedJwt = 'not-a-valid-jwt';- mockCookieStore.get.mockReturnValue({ value: malformedJwt });+ mockCookies({ '_spree_jwt': malformedJwt });const options = await getAuthOptions();expect(options).toEqual({ token: malformedJwt });@@ -94,7 +117,7 @@ describe('auth-helpers', () => {describe('withAuthRefresh', () => {it('throws when not authenticated', async () => {- mockCookieStore.get.mockReturnValue(undefined);+ mockCookies({});const fn = vi.fn();await expect(withAuthRefresh(fn)).rejects.toThrow('Not authenticated');@@ -104,7 +127,7 @@ describe('auth-helpers', () => {it('calls fn with auth options and returns result', async () => {const futureExp = Math.floor(Date.now() / 1000) + 86400;const jwt = makeJwt(futureExp);- mockCookieStore.get.mockReturnValue({ value: jwt });+ mockCookies({ '_spree_jwt': jwt });const fn = vi.fn().mockResolvedValue({ data: 'result' });const result = await withAuthRefresh(fn);@@ -116,47 +139,48 @@ describe('auth-helpers', () => {const futureExp = Math.floor(Date.now() / 1000) + 86400;const jwt = makeJwt(futureExp);const newJwt = 'refreshed_token';- mockCookieStore.get.mockReturnValue({ value: jwt });+ mockCookies({ '_spree_jwt': jwt, '_spree_refresh_token': 'rt_old' });const error401 = new SpreeError({ error: { message: 'Unauthorized' } } as any, 401);const fn = vi.fn().mockRejectedValueOnce(error401).mockResolvedValueOnce({ data: 'retried' });- mockClient.auth.refresh.mockResolvedValue({ token: newJwt });+ mockClient.auth.refresh.mockResolvedValue({ token: newJwt, refresh_token: 'rt_new' });const result = await withAuthRefresh(fn);expect(result).toEqual({ data: 'retried' });expect(fn).toHaveBeenCalledTimes(2);expect(fn).toHaveBeenLastCalledWith({ token: newJwt });- expect(mockCookieStore.set).toHaveBeenCalledWith(- '_spree_jwt',- newJwt,- expect.any(Object)- );+ expect(mockClient.auth.refresh).toHaveBeenCalledWith({ refresh_token: 'rt_old' });});- it('clears token and rethrows when refresh fails on 401', async () => {+ it('clears tokens and rethrows when refresh fails on 401', async () => {const futureExp = Math.floor(Date.now() / 1000) + 86400;const jwt = makeJwt(futureExp);- mockCookieStore.get.mockReturnValue({ value: jwt });+ mockCookies({ '_spree_jwt': jwt, '_spree_refresh_token': 'rt_old' });const error401 = new SpreeError({ error: { message: 'Unauthorized' } } as any, 401);const fn = vi.fn().mockRejectedValue(error401);mockClient.auth.refresh.mockRejectedValue(new Error('Refresh failed'));await expect(withAuthRefresh(fn)).rejects.toThrow('Unauthorized');- // Token should be cleared+ // Both tokens should be clearedexpect(mockCookieStore.set).toHaveBeenCalledWith('_spree_jwt','',expect.objectContaining({ maxAge: -1 }));+ expect(mockCookieStore.set).toHaveBeenCalledWith(+ '_spree_refresh_token',+ '',+ expect.objectContaining({ maxAge: -1 })+ );});it('rethrows non-401 errors without refresh', async () => {const futureExp = Math.floor(Date.now() / 1000) + 86400;const jwt = makeJwt(futureExp);- mockCookieStore.get.mockReturnValue({ value: jwt });+ mockCookies({ '_spree_jwt': jwt });const error500 = new Error('Server error');const fn = vi.fn().mockRejectedValue(error500);diff --git a/packages/sdk/.changeset/fulfillment-delivery-rename.md b/packages/sdk/.changeset/fulfillment-delivery-rename.mddeleted file mode 100644index 1e4fc61676..0000000000--- a/packages/sdk/.changeset/fulfillment-delivery-rename.md+++ /dev/null@@ -1,32 +0,0 @@-----"@spree/sdk": minor------### Breaking: Shipping → Delivery/Fulfillment naming--Renamed all shipping/shipment API surface to use delivery/fulfillment vocabulary:--- `client.carts.shipments` → `client.carts.fulfillments`-- `selected_shipping_rate_id` param → `selected_delivery_rate_id`-- `/carts/:id/shipments` endpoint → `/carts/:id/fulfillments`--### Breaking: Renamed response fields--- `shipment_state` → `fulfillment_status` (on Order)-- `payment_state` → `payment_status` (on Order)-- `ship_total` / `display_ship_total` → `delivery_total` / `display_delivery_total` (on Cart/Order)-- `state` → `status` (on Payment, GiftCard)-- `shipped_at` → `fulfilled_at` (on Fulfillment)-- `shipping_method` → `delivery_method` (on Fulfillment, DeliveryRate)-- `shipping_rates` → `delivery_rates` (on Fulfillment)--### Breaking: Removed fields--- Removed `is_master` from Variant-- Removed `expand=master_variant` from Product (use `expand=default_variant`)--### Type renames--- `Shipment` → `Fulfillment` / `StoreFulfillment`-- `ShippingMethod` → `DeliveryMethod` / `StoreDeliveryMethod`-- `ShippingRate` → `DeliveryRate` / `StoreDeliveryRate`diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.mdindex 4cfbe9d218..96f02f1054 100644--- a/packages/sdk/CHANGELOG.md+++ b/packages/sdk/CHANGELOG.md@@ -1,5 +1,15 @@# @spree/sdk+## 0.13.0++### Minor Changes++- ### Refresh token support++ - `AuthTokens` type now includes `refresh_token` field — returned by login, register, and password reset+ - `client.auth.refresh({ refresh_token })` — exchanges a refresh token for a new access JWT + rotated refresh token. No Authorization header needed.+ - `client.auth.logout({ refresh_token })` — revokes the refresh token server-side+## 0.12.1### Patch Changesdiff --git a/packages/sdk/package.json b/packages/sdk/package.jsonindex 5205d9392f..c840656d61 100644--- a/packages/sdk/package.json+++ b/packages/sdk/package.json@@ -1,6 +1,6 @@{"name": "@spree/sdk",- "version": "0.12.1",+ "version": "0.13.0","description": "Official TypeScript SDK for Spree Commerce Store API","type": "module","main": "./dist/index.cjs",diff --git a/packages/sdk/src/store-client.ts b/packages/sdk/src/store-client.tsindex 64efcf7f40..7a0972df0a 100644--- a/packages/sdk/src/store-client.ts+++ b/packages/sdk/src/store-client.ts@@ -67,10 +67,18 @@ export class StoreClient {this.request<AuthTokens>('POST', '/auth/login', { body: credentials }),/**- * Refresh access token (requires valid Bearer token)+ * Refresh access token using a refresh token.+ * Returns new access JWT + rotated refresh token.+ * No Authorization header needed — uses refresh_token in body.*/- refresh: (options: RequestOptions): Promise<AuthTokens> =>- this.request<AuthTokens>('POST', '/auth/refresh', options),+ refresh: (params: { refresh_token: string }, options?: RequestOptions): Promise<AuthTokens> =>+ this.request<AuthTokens>('POST', '/auth/refresh', { ...options, body: params }),++ /**+ * Logout — revokes the refresh token.+ */+ logout: (params: { refresh_token: string }, options?: RequestOptions): Promise<void> =>+ this.request<void>('POST', '/auth/logout', { ...options, body: params }),};// ============================================diff --git a/packages/sdk/src/types/index.ts b/packages/sdk/src/types/index.tsindex 12d93a490a..05f3b51141 100644--- a/packages/sdk/src/types/index.ts+++ b/packages/sdk/src/types/index.ts@@ -133,6 +133,7 @@ export type {// Store auth typesexport interface AuthTokens {token: string;+ refresh_token: string;user: {id: string;email: string;diff --git a/packages/sdk/tests/auth.test.ts b/packages/sdk/tests/auth.test.tsindex 1faeb36fdd..ef751b6b85 100644--- a/packages/sdk/tests/auth.test.ts+++ b/packages/sdk/tests/auth.test.ts@@ -107,11 +107,20 @@ describe('auth', () => {});describe('refresh', () => {- it('returns new tokens', async () => {+ it('returns new access token and rotated refresh token', async () => {const client = createTestClient();- const result = await client.auth.refresh({ token: 'old-token' });+ const result = await client.auth.refresh({ refresh_token: 'rt_old' });expect(result.token).toBe('refreshed-jwt-token');+ expect(result.refresh_token).toBe('rt_refreshed');+ });+ });++ describe('logout', () => {+ it('revokes the refresh token', async () => {+ const client = createTestClient();+ await client.auth.logout({ refresh_token: 'rt_login' });+ // 204 No Content — no error means success});});});diff --git a/packages/sdk/tests/mocks/handlers.ts b/packages/sdk/tests/mocks/handlers.tsindex b0a33ae465..b7764ac05e 100644--- a/packages/sdk/tests/mocks/handlers.ts+++ b/packages/sdk/tests/mocks/handlers.ts@@ -114,15 +114,19 @@ const paginationMeta = { page: 1, limit: 25, count: 1, pages: 1 };export const handlers = [// Authhttp.post(`${API_PREFIX}/auth/login`, () =>- HttpResponse.json({ token: 'test-jwt-token', user: fixtures.user })+ HttpResponse.json({ token: 'test-jwt-token', refresh_token: 'rt_login', user: fixtures.user })),http.post(`${API_PREFIX}/customers`, () =>- HttpResponse.json({ token: 'test-jwt-token', user: fixtures.user })+ HttpResponse.json({ token: 'test-jwt-token', refresh_token: 'rt_register', user: fixtures.user })),http.post(`${API_PREFIX}/auth/refresh`, () =>- HttpResponse.json({ token: 'refreshed-jwt-token', user: fixtures.user })+ HttpResponse.json({ token: 'refreshed-jwt-token', refresh_token: 'rt_refreshed', user: fixtures.user })+ ),++ http.post(`${API_PREFIX}/auth/logout`, () =>+ new HttpResponse(null, { status: 204 })),// Productsdiff --git a/server/Gemfile.lock b/server/Gemfile.lockindex 8a65ba01ff..3e655022fa 100644--- a/server/Gemfile.lock+++ b/server/Gemfile.lock@@ -11,7 +11,7 @@ GITPATHremote: ../spree/adminspecs:- spree_admin (5.4.0.beta7)+ spree_admin (5.4.0.beta8)active_link_tobreadcrumbs_on_rails (~> 4.1)chartkick (~> 5.0)@@ -23,7 +23,7 @@ PATHmapkick-rb (~> 0.1)pagy (~> 43.0)ruby-oembed (~> 0.18)- spree (>= 5.4.0.beta7)+ spree (>= 5.4.0.beta8)stimulus-railstailwindcss-rails (>= 4.0)tailwindcss-ruby (>= 4.0)@@ -33,22 +33,22 @@ PATHPATHremote: ../spree/emailsspecs:- spree_emails (5.4.0.beta7)- spree (>= 5.4.0.beta7)+ spree_emails (5.4.0.beta8)+ spree (>= 5.4.0.beta8)PATHremote: ../spreespecs:- spree (5.4.0.beta7)- spree_api (= 5.4.0.beta7)- spree_core (= 5.4.0.beta7)- spree_api (5.4.0.beta7)+ spree (5.4.0.beta8)+ spree_api (= 5.4.0.beta8)+ spree_core (= 5.4.0.beta8)+ spree_api (5.4.0.beta8)alba (~> 3.0)oj (~> 3.16)pagy (~> 43.0)- spree_core (= 5.4.0.beta7)+ spree_core (= 5.4.0.beta8)typelizer (~> 0.10.0)- spree_core (5.4.0.beta7)+ spree_core (5.4.0.beta8)active_storage_validations (= 1.3.0)acts-as-taggable-onacts_as_list (>= 0.8)@@ -1125,12 +1125,12 @@ CHECKSUMSsimplecov-cobertura (3.1.0) sha256=6d7f38aa32c965ca2174b2e5bd88cb17138eaf629518854976ac50e628925dc5simplecov-html (0.13.2) sha256=bd0b8e54e7c2d7685927e8d6286466359b6f16b18cb0df47b508e8d73c777246simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428- spree (5.4.0.beta7)- spree_admin (5.4.0.beta7)- spree_api (5.4.0.beta7)- spree_core (5.4.0.beta7)+ spree (5.4.0.beta8)+ spree_admin (5.4.0.beta8)+ spree_api (5.4.0.beta8)+ spree_core (5.4.0.beta8)spree_dev_tools (0.5.3) sha256=64ae7b215ac5d5c5f5890f6fc0dbcb12882b9af305a860f36f95f564ec240a75- spree_emails (5.4.0.beta7)+ spree_emails (5.4.0.beta8)spree_extension (1.0.2) sha256=71725dafe45319a2be1bd2b564a416afe8029af8e18ac703bdb835e09553e1dfspree_i18n (5.3.2) sha256=03b805235ca156644951f6bc3d07cbe43d0aa01134c4a27e3f3304011956f79bspree_stripe (1.6.0.beta)diff --git a/spree/api/app/controllers/concerns/spree/api/v3/error_handler.rb b/spree/api/app/controllers/concerns/spree/api/v3/error_handler.rbindex b64a9dd4bb..1b364d0c84 100644--- a/spree/api/app/controllers/concerns/spree/api/v3/error_handler.rb+++ b/spree/api/app/controllers/concerns/spree/api/v3/error_handler.rb@@ -12,6 +12,7 @@ module Spreeaccess_denied: 'access_denied',invalid_token: 'invalid_token',invalid_provider: 'invalid_provider',+ invalid_refresh_token: 'invalid_refresh_token',current_password_invalid: 'current_password_invalid',password_reset_token_invalid: 'password_reset_token_invalid',redirect_url_not_allowed: 'redirect_url_not_allowed',diff --git a/spree/api/app/controllers/spree/api/v3/store/auth_controller.rb b/spree/api/app/controllers/spree/api/v3/store/auth_controller.rbindex 085a2c9ddd..c9f6a72083 100644--- a/spree/api/app/controllers/spree/api/v3/store/auth_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/store/auth_controller.rb@@ -7,9 +7,9 @@ module Spreerate_limit to: Spree::Api::Config[:rate_limit_login], within: Spree::Api::Config[:rate_limit_window].seconds, store: Rails.cache, only: :create, with: RATE_LIMIT_RESPONSErate_limit to: Spree::Api::Config[:rate_limit_refresh], within: Spree::Api::Config[:rate_limit_window].seconds, store: Rails.cache, only: :refresh, with: RATE_LIMIT_RESPONSErate_limit to: Spree::Api::Config[:rate_limit_oauth], within: Spree::Api::Config[:rate_limit_window].seconds, store: Rails.cache, only: :oauth_callback, with: RATE_LIMIT_RESPONSE+ rate_limit to: Spree::Api::Config[:rate_limit_refresh], within: Spree::Api::Config[:rate_limit_window].seconds, store: Rails.cache, only: :logout, with: RATE_LIMIT_RESPONSE- skip_before_action :authenticate_user, only: [:create, :oauth_callback]- prepend_before_action :require_authentication!, only: [:refresh]+ skip_before_action :authenticate_user, only: [:create, :refresh, :oauth_callback]# POST /api/v3/store/auth/login# Supports multiple authentication providers via :provider param@@ -23,11 +23,7 @@ module Spreeif result.success?user = result.value- token = generate_jwt(user)- render json: {- token: token,- user: user_serializer.new(user, params: serializer_params).to_h- }+ render json: auth_response(user)elserender_error(code: ERROR_CODES[:authentication_failed],@@ -38,21 +34,55 @@ module Spreeend# POST /api/v3/store/auth/refresh+ # Accepts: { "refresh_token": "rt_xxx" }+ # Returns new access JWT + rotated refresh tokendef refresh- token = generate_jwt(current_user)+ refresh_token_value = params[:refresh_token]++ if refresh_token_value.blank?+ return render_error(+ code: ERROR_CODES[:invalid_refresh_token],+ message: 'refresh_token is required',+ status: :unauthorized+ )+ end++ refresh_token = Spree::RefreshToken.active.find_by(token: refresh_token_value)++ if refresh_token.nil?+ return render_error(+ code: ERROR_CODES[:invalid_refresh_token],+ message: 'Invalid or expired refresh token',+ status: :unauthorized+ )+ end++ user = refresh_token.user+ new_refresh_token = refresh_token.rotate!(request_env: request_env_for_token)+render json: {- token: token,- user: user_serializer.new(current_user, params: serializer_params).to_h+ token: generate_jwt(user),+ refresh_token: new_refresh_token.token,+ user: user_serializer.new(user, params: serializer_params).to_h}end+ # POST /api/v3/store/auth/logout+ # Accepts: { "refresh_token": "rt_xxx" }+ # Revokes the refresh token+ def logout+ refresh_token_value = params[:refresh_token]++ if refresh_token_value.present?+ Spree::RefreshToken.find_by(token: refresh_token_value)&.destroy+ end++ head :no_content+ end+# POST /api/v3/store/auth/oauth/callback# OAuth callback endpoint for server-side OAuth flowsdef oauth_callback- # This endpoint is designed for OAuth flows where the server- # exchanges the authorization code for an access token- # For client-side flows, use the regular /login endpoint with id_token-strategy = authentication_strategyreturn unless strategy # Error already rendered by determine_strategy@@ -60,11 +90,7 @@ module Spreeif result.success?user = result.value- token = generate_jwt(user)- render json: {- token: token,- user: user_serializer.new(user, params: serializer_params).to_h- }+ render json: auth_response(user)elserender_error(code: ERROR_CODES[:authentication_failed],@@ -88,6 +114,23 @@ module Spreeprivate+ def auth_response(user)+ refresh_token = Spree::RefreshToken.create_for(user, request_env: request_env_for_token)++ {+ token: generate_jwt(user),+ refresh_token: refresh_token.token,+ user: user_serializer.new(user, params: serializer_params).to_h+ }+ end++ def request_env_for_token+ {+ ip_address: request.remote_ip,+ user_agent: request.user_agent&.truncate(255)+ }+ end+def authentication_strategystrategy_class = determine_strategystrategy_class.new(diff --git a/spree/api/app/controllers/spree/api/v3/store/customer/password_resets_controller.rb b/spree/api/app/controllers/spree/api/v3/store/customer/password_resets_controller.rbindex fb29a0aa5b..b2f54eed4f 100644--- a/spree/api/app/controllers/spree/api/v3/store/customer/password_resets_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/store/customer/password_resets_controller.rb@@ -55,10 +55,12 @@ module Spreeif user.update(password: params[:password], password_confirmation: params[:password_confirmation])jwt = generate_jwt(user)+ refresh_token = Spree::RefreshToken.create_for(user, request_env: { ip_address: request.remote_ip, user_agent: request.user_agent&.truncate(255) })user.publish_event('customer.password_reset')render json: {token: jwt,+ refresh_token: refresh_token.token,user: serializer_class.new(user, params: serializer_params).to_h}elsediff --git a/spree/api/app/controllers/spree/api/v3/store/customers_controller.rb b/spree/api/app/controllers/spree/api/v3/store/customers_controller.rbindex 3f2e70916f..38638af166 100644--- a/spree/api/app/controllers/spree/api/v3/store/customers_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/store/customers_controller.rb@@ -13,9 +13,13 @@ module Spreeuser = Spree.user_class.new(create_params)if user.save- token = generate_jwt(user)+ refresh_token = Spree::RefreshToken.create_for(user, request_env: {+ ip_address: request.remote_ip,+ user_agent: request.user_agent&.truncate(255)+ })render json: {- token: token,+ token: generate_jwt(user),+ refresh_token: refresh_token.token,user: user_serializer.new(user, params: serializer_params).to_h}, status: :createdelsediff --git a/spree/api/config/routes.rb b/spree/api/config/routes.rbindex edf7fbb6d0..f700e0b5f1 100644--- a/spree/api/config/routes.rb+++ b/spree/api/config/routes.rb@@ -5,6 +5,7 @@ Spree::Core::Engine.add_routes do# Authenticationpost 'auth/login', to: 'auth#create'post 'auth/refresh', to: 'auth#refresh'+ post 'auth/logout', to: 'auth#logout'post 'auth/oauth/callback', to: 'auth#oauth_callback'# Marketsdiff --git a/spree/api/lib/spree/api/configuration.rb b/spree/api/lib/spree/api/configuration.rbindex e7e602dd44..8cd4c7e228 100644--- a/spree/api/lib/spree/api/configuration.rb+++ b/spree/api/lib/spree/api/configuration.rb@@ -11,6 +11,7 @@ module Spreepreference :jwt_expiration, :integer, default: 3600 # 1 hour in secondspreference :jwt_secret_key, :string, default: nil+ preference :refresh_token_expiry, :integer, default: 2_592_000 # 30 days in seconds# Rate limitingpreference :rate_limit_per_key, :integer, default: 300 # per publishable API keydiff --git a/spree/api/lib/spree/api/openapi/schema_helper.rb b/spree/api/lib/spree/api/openapi/schema_helper.rbindex 3e38731ef8..0857c79736 100644--- a/spree/api/lib/spree/api/openapi/schema_helper.rb+++ b/spree/api/lib/spree/api/openapi/schema_helper.rb@@ -81,9 +81,10 @@ module Spreetype: :object,properties: {token: { type: :string, description: 'JWT access token' },+ refresh_token: { type: :string, description: 'Refresh token for obtaining new access tokens' },user: { '$ref' => '#/components/schemas/Customer' }},- required: %w[token user]+ required: %w[token refresh_token user]},CheckoutRequirement: {type: :object,diff --git a/spree/api/spec/controllers/concerns/spree/api/v3/jwt_authentication_spec.rb b/spree/api/spec/controllers/concerns/spree/api/v3/jwt_authentication_spec.rbindex 5c79629944..ae823c3786 100644--- a/spree/api/spec/controllers/concerns/spree/api/v3/jwt_authentication_spec.rb+++ b/spree/api/spec/controllers/concerns/spree/api/v3/jwt_authentication_spec.rb@@ -1,113 +1,87 @@require 'spec_helper'-RSpec.describe Spree::Api::V3::Store::AuthController, type: :controller do- render_views-- include_context 'API v3 Store'-- before do- request.headers['X-Spree-Api-Key'] = api_key.token+# Test JWT authentication concerns.+# Token generation tested via AuthController (login).+# Token verification/extraction tested via CustomersController (GET /customer requires JWT).+RSpec.describe 'Spree::Api::V3::JwtAuthentication' do+ describe 'token generation' do+ # Use AuthController for testing token generation (login creates JWT)+ let(:controller_class) { Spree::Api::V3::Store::AuthController }++ it 'includes jti, iss, and aud claims in generated token', type: :request do+ store = Spree::Store.default || create(:store)+ api_key = create(:api_key, :publishable, store: store)+ existing_user = create(:user, password: 'password123', password_confirmation: 'password123')++ post '/api/v3/store/auth/login',+ params: { provider: 'email', email: existing_user.email, password: 'password123' }.to_json,+ headers: { 'X-Spree-Api-Key' => api_key.token, 'Content-Type' => 'application/json' }++ data = JSON.parse(response.body)+ token = data['token']+ secret = Rails.application.credentials.jwt_secret_key || ENV['JWT_SECRET_KEY'] || Rails.application.secret_key_base+ payload = JWT.decode(token, secret, true, algorithm: 'HS256').first++ expect(payload['jti']).to be_present+ expect(payload['iss']).to eq('spree')+ expect(payload['aud']).to eq('store_api')+ expect(payload['user_id']).to eq(existing_user.id)+ expect(payload['user_type']).to eq('customer')+ expect(payload['exp']).to be_present+ endend- describe 'Spree::Api::V3::JwtAuthentication' do- let!(:existing_user) { create(:user, password: 'password123', password_confirmation: 'password123') }-- describe 'JWT token claims' do- it 'includes jti, iss, and aud claims in generated token' do- post :create, params: { provider: 'email', email: existing_user.email, password: 'password123' }-- token = json_response['token']- secret = Rails.application.credentials.jwt_secret_key || ENV['JWT_SECRET_KEY'] || Rails.application.secret_key_base- payload = JWT.decode(token, secret, true, algorithm: 'HS256').first+ describe 'token verification and extraction' do+ let!(:store) { Spree::Store.default || create(:store) }+ let!(:api_key) { create(:api_key, :publishable, store: store) }+ let!(:user) { create(:user, password: 'password123', password_confirmation: 'password123') }+ let(:headers) { { 'X-Spree-Api-Key' => api_key.token, 'Content-Type' => 'application/json' } }- expect(payload['jti']).to be_present- expect(payload['iss']).to eq('spree')- expect(payload['aud']).to eq('store_api')- expect(payload['user_id']).to eq(existing_user.id)- expect(payload['user_type']).to eq('customer')- expect(payload['exp']).to be_present- end-- it 'generates unique jti for each token' do- post :create, params: { provider: 'email', email: existing_user.email, password: 'password123' }- first_jti = JWT.decode(json_response['token'], nil, false).first['jti']-- post :create, params: { provider: 'email', email: existing_user.email, password: 'password123' }- second_jti = JWT.decode(json_response['token'], nil, false).first['jti']-- expect(first_jti).not_to eq(second_jti)- end+ def generate_jwt(user, expiration: 3600)+ Spree::Api::V3::TestingSupport.generate_jwt(user, expiration: expiration)end- describe 'token verification' do- it 'rejects tokens with wrong issuer' do- bad_token = JWT.encode(- { user_id: user.id, user_type: 'customer', iss: 'wrong', aud: 'store_api', exp: 1.hour.from_now.to_i },- Rails.application.secret_key_base,- 'HS256'- )- request.headers['Authorization'] = "Bearer #{bad_token}"-- post :refresh+ it 'extracts token from Authorization Bearer header', type: :request do+ jwt = generate_jwt(user)+ get '/api/v3/store/customer', headers: headers.merge('Authorization' => "Bearer #{jwt}")- expect(response).to have_http_status(:unauthorized)- end-- it 'rejects tokens with wrong audience' do- bad_token = JWT.encode(- { user_id: user.id, user_type: 'customer', iss: 'spree', aud: 'wrong_api', exp: 1.hour.from_now.to_i },- Rails.application.secret_key_base,- 'HS256'- )- request.headers['Authorization'] = "Bearer #{bad_token}"-- post :refresh-- expect(response).to have_http_status(:unauthorized)- end-- it 'rejects expired tokens' do- expired_token = Spree::Api::V3::TestingSupport.generate_jwt(user, expiration: -1.hour.to_i)- request.headers['Authorization'] = "Bearer #{expired_token}"-- post :refresh-- expect(response).to have_http_status(:unauthorized)- end+ expect(response).to have_http_status(:ok)end- describe 'configurable expiration' do- it 'uses the configured jwt_expiration' do- original = Spree::Api::Config[:jwt_expiration]- Spree::Api::Config[:jwt_expiration] = 7200+ it 'rejects tokens with wrong issuer', type: :request do+ bad_token = JWT.encode(+ { user_id: user.id, user_type: 'customer', iss: 'wrong', aud: 'store_api', exp: 1.hour.from_now.to_i },+ Rails.application.secret_key_base,+ 'HS256'+ )+ get '/api/v3/store/customer', headers: headers.merge('Authorization' => "Bearer #{bad_token}")- post :create, params: { provider: 'email', email: existing_user.email, password: 'password123' }+ expect(response).to have_http_status(:unauthorized)+ end- token = json_response['token']- payload = JWT.decode(token, nil, false).first+ it 'rejects tokens with wrong audience', type: :request do+ bad_token = JWT.encode(+ { user_id: user.id, user_type: 'customer', iss: 'spree', aud: 'wrong_api', exp: 1.hour.from_now.to_i },+ Rails.application.secret_key_base,+ 'HS256'+ )+ get '/api/v3/store/customer', headers: headers.merge('Authorization' => "Bearer #{bad_token}")- # Token expiration should be approximately 2 hours from now- expected_exp = Time.current.to_i + 7200- expect(payload['exp']).to be_within(5).of(expected_exp)- ensure- Spree::Api::Config[:jwt_expiration] = original- end+ expect(response).to have_http_status(:unauthorized)end- describe 'token extraction' do- it 'extracts token from Authorization Bearer header' do- request.headers['Authorization'] = "Bearer #{jwt_token}"+ it 'rejects expired tokens', type: :request do+ expired_token = generate_jwt(user, expiration: -1.hour.to_i)+ get '/api/v3/store/customer', headers: headers.merge('Authorization' => "Bearer #{expired_token}")- post :refresh-- expect(response).to have_http_status(:ok)- end+ expect(response).to have_http_status(:unauthorized)+ end- it 'does not extract token from query params on non-digitals controllers' do- post :refresh, params: { token: jwt_token }+ it 'does not extract token from query params on non-digitals controllers', type: :request do+ jwt = generate_jwt(user)+ get '/api/v3/store/customer', params: { token: jwt }, headers: headers- expect(response).to have_http_status(:unauthorized)- end+ expect(response).to have_http_status(:unauthorized)endendenddiff --git a/spree/api/spec/controllers/spree/api/v3/store/auth_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/store/auth_controller_spec.rbindex f40cd063f3..6ea10e3774 100644--- a/spree/api/spec/controllers/spree/api/v3/store/auth_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/store/auth_controller_spec.rb@@ -19,6 +19,19 @@ RSpec.describe Spree::Api::V3::Store::AuthController, type: :controller doexpect(json_response['token']).to be_presentend+ it 'returns a refresh token on login' do+ post :create, params: { provider: 'email', email: existing_user.email, password: 'password123' }++ expect(response).to have_http_status(:ok)+ expect(json_response['refresh_token']).to be_present+ end++ it 'creates a RefreshToken record' do+ expect {+ post :create, params: { provider: 'email', email: existing_user.email, password: 'password123' }+ }.to change(Spree::RefreshToken, :count).by(1)+ end+it 'returns user data on successful login' dopost :create, params: { provider: 'email', email: existing_user.email, password: 'password123' }@@ -52,6 +65,12 @@ RSpec.describe Spree::Api::V3::Store::AuthController, type: :controller doexpect(response).to have_http_status(:unauthorized)end++ it 'does not create a RefreshToken on failure' do+ expect {+ post :create, params: { provider: 'email', email: existing_user.email, password: 'wrong' }+ }.not_to change(Spree::RefreshToken, :count)+ endendcontext 'without API key' do@@ -66,50 +85,90 @@ RSpec.describe Spree::Api::V3::Store::AuthController, type: :controller doenddescribe 'POST #refresh' do- before do- request.headers['Authorization'] = "Bearer #{jwt_token}"- end+ let!(:existing_user) { create(:user, password: 'password123', password_confirmation: 'password123') }+ let!(:refresh_token) { Spree::RefreshToken.create_for(existing_user) }- it 'returns a new token' do- post :refresh+ it 'returns a new access token and rotated refresh token' do+ post :refresh, params: { refresh_token: refresh_token.token }expect(response).to have_http_status(:ok)expect(json_response['token']).to be_present+ expect(json_response['refresh_token']).to be_present+ # Refresh token should be rotated (different from original)+ expect(json_response['refresh_token']).not_to eq(refresh_token.token)end- context 'without token' do- before { request.headers['Authorization'] = nil }+ it 'returns user data' do+ post :refresh, params: { refresh_token: refresh_token.token }++ expect(json_response['user']).to be_present+ expect(json_response['user']['email']).to eq(existing_user.email)+ end++ it 'destroys the old refresh token' do+ post :refresh, params: { refresh_token: refresh_token.token }++ expect(Spree::RefreshToken.find_by(id: refresh_token.id)).to be_nil+ end+ it 'creates a new refresh token' do+ expect {+ post :refresh, params: { refresh_token: refresh_token.token }+ }.not_to change(Spree::RefreshToken, :count) # one destroyed, one created+ end++ context 'without refresh_token param' doit 'returns unauthorized' dopost :refreshexpect(response).to have_http_status(:unauthorized)- expect(json_response['error']['code']).to eq('authentication_required')+ expect(json_response['error']['code']).to eq('invalid_refresh_token')endend- context 'with invalid token' do- before { request.headers['Authorization'] = 'Bearer invalid' }-+ context 'with invalid refresh token' doit 'returns unauthorized' do- post :refresh+ post :refresh, params: { refresh_token: 'invalid_token' }expect(response).to have_http_status(:unauthorized)- expect(json_response['error']['code']).to eq('authentication_required')+ expect(json_response['error']['code']).to eq('invalid_refresh_token')endend- context 'with expired token' do- let(:expired_token) { Spree::Api::V3::TestingSupport.generate_jwt(user, expiration: -1.hour.to_i) }-- before { request.headers['Authorization'] = "Bearer #{expired_token}" }+ context 'with expired refresh token' do+ before { refresh_token.update_column(:expires_at, 1.day.ago) }it 'returns unauthorized' do- post :refresh+ post :refresh, params: { refresh_token: refresh_token.token }expect(response).to have_http_status(:unauthorized)- expect(json_response['error']['code']).to eq('authentication_required')+ expect(json_response['error']['code']).to eq('invalid_refresh_token')endendend++ describe 'POST #logout' do+ let!(:existing_user) { create(:user, password: 'password123', password_confirmation: 'password123') }+ let!(:refresh_token) { Spree::RefreshToken.create_for(existing_user) }++ it 'revokes the refresh token' do+ expect {+ post :logout, params: { refresh_token: refresh_token.token }+ }.to change(Spree::RefreshToken, :count).by(-1)++ expect(response).to have_http_status(:no_content)+ end++ it 'succeeds even with invalid refresh token' do+ post :logout, params: { refresh_token: 'nonexistent' }++ expect(response).to have_http_status(:no_content)+ end++ it 'succeeds without refresh token param' do+ post :logout++ expect(response).to have_http_status(:no_content)+ end+ endenddiff --git a/spree/api/spec/integration/spree/api/v3/store/auth_spec.rb b/spree/api/spec/integration/spree/api/v3/store/auth_spec.rbindex d6d6b07321..4c5f5c4153 100644--- a/spree/api/spec/integration/spree/api/v3/store/auth_spec.rb+++ b/spree/api/spec/integration/spree/api/v3/store/auth_spec.rb@@ -79,37 +79,44 @@ RSpec.describe 'Authentication API', type: :request, swagger_doc: 'api-referencepath '/api/v3/store/auth/refresh' dopost 'Refresh token' dotags 'Authentication'+ consumes 'application/json'produces 'application/json'- security [api_key: [], bearer_auth: []]- description 'Generates a new JWT token for the authenticated user'+ security [api_key: []]+ description 'Exchanges a refresh token for a new access JWT and rotated refresh token. No Authorization header needed.'sdk_example <<~JSconst auth = await client.auth.refresh({- bearerToken: '<token>',+ refresh_token: 'rt_xxx',})JSparameter name: 'x-spree-api-key', in: :header, type: :string, required: true- parameter name: 'Authorization', in: :header, type: :string, required: true,- description: 'Bearer token'+ parameter name: :body, in: :body, schema: {+ type: :object,+ properties: {+ refresh_token: { type: :string, description: 'Refresh token from login response' }+ },+ required: %w[refresh_token]+ }response '200', 'token refreshed' dolet(:'x-spree-api-key') { api_key.token }- let(:'Authorization') { "Bearer #{jwt_token}" }- let(:jwt_token) { Spree::Api::V3::TestingSupport.generate_jwt(existing_user) }+ let(:refresh_token_record) { Spree::RefreshToken.create_for(existing_user) }+ let(:body) { { refresh_token: refresh_token_record.token } }schema '$ref' => '#/components/schemas/AuthResponse'run_test! do |response|data = JSON.parse(response.body)expect(data['token']).to be_present+ expect(data['refresh_token']).to be_presentexpect(data['user']).to be_presentendend- response '401', 'missing or invalid token' do+ response '401', 'missing or invalid refresh token' dolet(:'x-spree-api-key') { api_key.token }- let(:'Authorization') { 'Bearer invalid_token' }+ let(:body) { { refresh_token: 'invalid_token' } }schema '$ref' => '#/components/schemas/ErrorResponse'diff --git a/spree/core/app/models/spree/refresh_token.rb b/spree/core/app/models/spree/refresh_token.rbnew file mode 100644index 0000000000..a55ec9e99b--- /dev/null+++ b/spree/core/app/models/spree/refresh_token.rb@@ -0,0 +1,60 @@+module Spree+ class RefreshToken < Spree.base_class+ has_prefix_id :rt++ belongs_to :user, polymorphic: true++ has_secure_token :token++ validates :user, :expires_at, presence: true++ scope :active, -> { where('expires_at > ?', Time.current) }+ scope :expired, -> { where('expires_at <= ?', Time.current) }++ def expired?+ expires_at <= Time.current+ end++ # Rotate: destroy this token and create a new one.+ # Returns the new token.+ def rotate!(request_env: {})+ new_token = nil+ transaction do+ new_token = self.class.create!(+ user: user,+ expires_at: self.class.default_expiry.from_now,+ ip_address: request_env[:ip_address] || ip_address,+ user_agent: request_env[:user_agent] || user_agent+ )+ destroy!+ end+ new_token+ end++ # Create a refresh token for a user+ def self.create_for(user, request_env: {})+ create!(+ user: user,+ expires_at: default_expiry.from_now,+ ip_address: request_env[:ip_address],+ user_agent: request_env[:user_agent]+ )+ end++ # Revoke all refresh tokens for a user (e.g., on password change)+ def self.revoke_all_for(user)+ where(user: user).delete_all+ end++ # Clean up expired tokens+ def self.cleanup_expired!+ expired.delete_all+ end++ def self.default_expiry+ Spree::Api::Config[:refresh_token_expiry].seconds+ rescue StandardError+ 30.days+ end+ end+enddiff --git a/spree/core/db/migrate/20260317000000_create_spree_refresh_tokens.rb b/spree/core/db/migrate/20260317000000_create_spree_refresh_tokens.rbnew file mode 100644index 0000000000..d6122acfea--- /dev/null+++ b/spree/core/db/migrate/20260317000000_create_spree_refresh_tokens.rb@@ -0,0 +1,16 @@+class CreateSpreeRefreshTokens < ActiveRecord::Migration[7.2]+ def change+ create_table :spree_refresh_tokens do |t|+ t.string :token, null: false+ t.references :user, polymorphic: true, null: false+ t.datetime :expires_at, null: false+ t.string :ip_address+ t.string :user_agent+ t.timestamps+ end++ add_index :spree_refresh_tokens, :token, unique: true+ add_index :spree_refresh_tokens, :expires_at+ add_index :spree_refresh_tokens, [:user_type, :user_id], name: 'idx_refresh_tokens_user'+ end+enddiff --git a/spree/core/spec/models/spree/refresh_token_spec.rb b/spree/core/spec/models/spree/refresh_token_spec.rbnew file mode 100644index 0000000000..729619812e--- /dev/null+++ b/spree/core/spec/models/spree/refresh_token_spec.rb@@ -0,0 +1,166 @@+require 'spec_helper'++RSpec.describe Spree::RefreshToken, type: :model do+ let(:user) { create(:user) }++ describe 'validations' do+ it 'requires a user' do+ token = described_class.new(expires_at: 30.days.from_now)+ token.valid?+ expect(token.errors[:user]).to be_present+ end++ it 'requires expires_at' do+ token = described_class.new(user: user)+ # has_secure_token generates token automatically+ token.valid?+ expect(token.errors[:expires_at]).to be_present+ end++ it 'auto-generates a token via has_secure_token' do+ token = described_class.create!(user: user, expires_at: 30.days.from_now)+ expect(token.token).to be_present+ expect(token.token.length).to be >= 24+ end+ end++ describe '.create_for' do+ it 'creates a refresh token for a user' do+ token = described_class.create_for(user)++ expect(token).to be_persisted+ expect(token.user).to eq(user)+ expect(token.token).to be_present+ expect(token.expires_at).to be > Time.current+ end++ it 'stores request env data' do+ token = described_class.create_for(user, request_env: {+ ip_address: '192.168.1.1',+ user_agent: 'Mozilla/5.0'+ })++ expect(token.ip_address).to eq('192.168.1.1')+ expect(token.user_agent).to eq('Mozilla/5.0')+ end++ it 'sets default 30-day expiry' do+ token = described_class.create_for(user)++ expect(token.expires_at).to be_within(1.minute).of(30.days.from_now)+ end+ end++ describe '#expired?' do+ it 'returns false for active tokens' do+ token = described_class.create_for(user)+ expect(token.expired?).to be false+ end++ it 'returns true for expired tokens' do+ token = described_class.create_for(user)+ token.update_column(:expires_at, 1.hour.ago)+ expect(token.expired?).to be true+ end+ end++ describe '#rotate!' do+ let!(:original_token) { described_class.create_for(user) }++ it 'destroys the original token' do+ original_id = original_token.id+ original_token.rotate!+ expect(described_class.find_by(id: original_id)).to be_nil+ end++ it 'creates a new token' do+ new_token = original_token.rotate!+ expect(new_token).to be_persisted+ expect(new_token.token).not_to eq(original_token.token)+ end++ it 'preserves the user' do+ new_token = original_token.rotate!+ expect(new_token.user).to eq(user)+ end++ it 'keeps total count the same' do+ expect {+ original_token.rotate!+ }.not_to change(described_class, :count)+ end++ it 'accepts new request env' do+ new_token = original_token.rotate!(request_env: {+ ip_address: '10.0.0.1',+ user_agent: 'NewBrowser/1.0'+ })+ expect(new_token.ip_address).to eq('10.0.0.1')+ expect(new_token.user_agent).to eq('NewBrowser/1.0')+ end+ end++ describe 'scopes' do+ let!(:active_token) { described_class.create_for(user) }+ let!(:expired_token) do+ t = described_class.create_for(user)+ t.update_column(:expires_at, 1.day.ago)+ t+ end++ describe '.active' do+ it 'returns only non-expired tokens' do+ expect(described_class.active).to include(active_token)+ expect(described_class.active).not_to include(expired_token)+ end+ end++ describe '.expired' do+ it 'returns only expired tokens' do+ expect(described_class.expired).to include(expired_token)+ expect(described_class.expired).not_to include(active_token)+ end+ end+ end++ describe '.revoke_all_for' do+ it 'deletes all tokens for a user' do+ described_class.create_for(user)+ described_class.create_for(user)++ expect {+ described_class.revoke_all_for(user)+ }.to change(described_class, :count).by(-2)+ end++ it 'does not delete tokens for other users' do+ other_user = create(:user)+ described_class.create_for(user)+ other_token = described_class.create_for(other_user)++ described_class.revoke_all_for(user)++ expect(described_class.find_by(id: other_token.id)).to be_present+ end+ end++ describe '.cleanup_expired!' do+ it 'deletes expired tokens' do+ active = described_class.create_for(user)+ expired = described_class.create_for(user)+ expired.update_column(:expires_at, 1.day.ago)++ described_class.cleanup_expired!++ expect(described_class.find_by(id: active.id)).to be_present+ expect(described_class.find_by(id: expired.id)).to be_nil+ end+ end++ describe 'prefixed_id' do+ it 'uses rt_ prefix' do+ token = described_class.create_for(user)+ expect(token.prefixed_id).to start_with('rt_')+ end+ end+end