Skip to content

Commit 3e12665

Browse files
committed
configuration to test passkey with hybrid auth
1 parent e7706b5 commit 3e12665

File tree

4 files changed

+49
-79
lines changed

4 files changed

+49
-79
lines changed

packages/template-retail-react-app/app/components/_app-config/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ const AppConfig = ({children, locals = {}}) => {
107107
defaultDnt={DEFAULT_DNT_STATE}
108108
// Set 'enablePWAKitPrivateClient' to true to use SLAS private client login flows.
109109
// Make sure to also enable useSLASPrivateClient in ssr.js when enabling this setting.
110-
enablePWAKitPrivateClient={false}
110+
enablePWAKitPrivateClient={true}
111111
privateClientProxyEndpoint={slasPrivateClientProxyEndpoint}
112112
// Uncomment 'hybridAuthEnabled' if the current site has Hybrid Auth enabled. Do NOT set this flag for hybrid storefronts using Plugin SLAS.
113-
// hybridAuthEnabled={true}
113+
hybridAuthEnabled={true}
114114
logger={createLogger({packageName: 'commerce-sdk-react'})}
115115
>
116116
<MultiSiteProvider site={locals.site} locale={locals.locale} buildUrl={locals.buildUrl}>

packages/template-retail-react-app/app/routes.jsx

Lines changed: 28 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
// we don't want it to count toward coverage until we figure out how to cover the `functions`
1313
// metric for this file in its test.
1414

15-
import React from 'react'
15+
import React, {useEffect} from 'react'
1616
import loadable from '@loadable/component'
1717
import {getConfig} from '@salesforce/pwa-kit-runtime/utils/ssr-config'
18+
import {withRouter} from 'react-router-dom'
1819

1920
// Components
2021
import {Skeleton} from '@salesforce/retail-react-app/app/components/shared/ui'
@@ -30,15 +31,6 @@ const Registration = loadable(() => import('./pages/registration'), {
3031
})
3132
const ResetPassword = loadable(() => import('./pages/reset-password'), {fallback})
3233
const Account = loadable(() => import('./pages/account'), {fallback})
33-
const Cart = loadable(() => import('./pages/cart'), {fallback})
34-
const Checkout = loadable(() => import('./pages/checkout'), {
35-
fallback
36-
})
37-
const CheckoutOneClick = loadable(() => import('./pages/checkout-one-click'), {
38-
fallback
39-
})
40-
const CheckoutConfirmation = loadable(() => import('./pages/confirmation'), {fallback})
41-
const SocialLoginRedirect = loadable(() => import('./pages/social-login-redirect'), {fallback})
4234
const LoginRedirect = loadable(() => import('./pages/login-redirect'), {fallback})
4335
const ProductDetail = loadable(() => import('./pages/product-detail'), {fallback})
4436
const ProductList = loadable(() => import('./pages/product-list'), {
@@ -58,6 +50,11 @@ export const routes = [
5850
component: Home,
5951
exact: true
6052
},
53+
{
54+
path: '/home',
55+
component: Home,
56+
exact: true
57+
},
6158
{
6259
path: '/login',
6360
component: Login,
@@ -77,28 +74,11 @@ export const routes = [
7774
path: '/account',
7875
component: Account
7976
},
80-
{
81-
path: '/checkout',
82-
component: (props) => {
83-
const enabled = getConfig()?.app?.oneClickCheckout?.enabled
84-
return enabled ? <CheckoutOneClick {...props} /> : <Checkout {...props} />
85-
},
86-
exact: true
87-
},
88-
{
89-
path: '/checkout/confirmation/:orderNo',
90-
component: CheckoutConfirmation
91-
},
9277
{
9378
path: '/callback',
9479
component: LoginRedirect,
9580
exact: true
9681
},
97-
{
98-
path: '/cart',
99-
component: Cart,
100-
exact: true
101-
},
10282
{
10383
path: '/product/:productId',
10484
component: ProductDetail
@@ -118,44 +98,31 @@ export const routes = [
11898
{
11999
path: '/store-locator',
120100
component: StoreLocator
101+
},
102+
{
103+
path: '*',
104+
component: withRouter((props) => {
105+
const {location} = props
106+
const urlParams = new URLSearchParams(location.search)
107+
108+
useEffect(() => {
109+
const newURL = new URL(window.location)
110+
if (!urlParams.has('redirected')) {
111+
newURL.searchParams.append('redirected', '1')
112+
window.location.href = newURL
113+
}
114+
}, [window.location.href])
115+
if (urlParams.has('redirected')) {
116+
return <PageNotFound {...props} />
117+
}
118+
return null
119+
})
121120
}
122121
]
123122

124123
export default () => {
125124
const config = getConfig()
126-
const loginConfig = config?.app?.login
127-
const resetPasswordLandingPath = loginConfig?.resetPassword?.landingPath
128-
const socialLoginEnabled = loginConfig?.social?.enabled
129-
const socialRedirectURI = loginConfig?.social?.redirectURI
130-
const passwordlessLoginEnabled = loginConfig?.passwordless?.enabled
131-
const passwordlessLoginLandingPath = loginConfig?.passwordless?.landingPath
132-
133-
// Add dynamic routes conditionally (only if features are enabled and paths are defined)
134-
const dynamicRoutes = [
135-
resetPasswordLandingPath && {
136-
path: resetPasswordLandingPath,
137-
component: ResetPassword,
138-
exact: true
139-
},
140-
passwordlessLoginEnabled &&
141-
passwordlessLoginLandingPath && {
142-
path: passwordlessLoginLandingPath,
143-
component: Login,
144-
exact: true
145-
},
146-
socialLoginEnabled &&
147-
socialRedirectURI && {
148-
path: socialRedirectURI,
149-
component: SocialLoginRedirect,
150-
exact: true
151-
}
152-
].filter(Boolean)
153-
154-
const allRoutes = configureRoutes([...routes, ...dynamicRoutes], config, {
155-
ignoredRoutes: ['/callback'],
156-
fuzzyPathMatching: true
125+
return configureRoutes(routes, config, {
126+
ignoredRoutes: ['/callback', '*']
157127
})
158-
159-
// Add catch-all route at the end so it doesn't match before dynamic routes
160-
return [...allRoutes, {path: '*', component: PageNotFound}]
161128
}

packages/template-retail-react-app/app/ssr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const options = {
5151
// Set this to false if using a SLAS public client
5252
// When setting this to true, make sure to also set the PWA_KIT_SLAS_CLIENT_SECRET
5353
// environment variable as this endpoint will return HTTP 501 if it is not set
54-
useSLASPrivateClient: false,
54+
useSLASPrivateClient: true,
5555

5656
// If you wish to use additional SLAS endpoints that require private clients,
5757
// customize this regex to include the additional endpoints the custom SLAS

packages/template-retail-react-app/config/default.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,26 @@ module.exports = {
4848
landingPath: '/reset-password-landing'
4949
},
5050
passkey: {
51-
enabled: false,
52-
callbackURI: process.env.PASSKEY_CALLBACK_URI
51+
enabled: true,
52+
mode: 'callback',
53+
callbackURI: 'https://webhook.site/1b592264-a9b1-4d75-a892-cf68fed334f1'
5354
}
5455
},
55-
defaultSite: 'RefArchGlobal',
56-
siteAliases: {
57-
RefArch: 'us',
58-
RefArchGlobal: 'global'
59-
},
56+
defaultSite: 'RefArch',
57+
// Provide aliases for your sites. These will be used in place of your site id when generating paths throughout the application.
58+
// siteAliases: {
59+
// RefArch: 'us',
60+
// RefArchGlobal: 'global'
61+
// },
62+
// The sites for your app, which is imported from sites.js
6063
sites,
6164
commerceAPI: {
62-
proxyPath: `/mobify/proxy/api`,
65+
proxyPath: '/mobify/proxy/api',
6366
parameters: {
64-
clientId: 'c9c45bfd-0ed3-4aa2-9971-40f88962b836',
65-
organizationId: 'f_ecom_zzrf_001',
66-
shortCode: '8o7m175y',
67-
siteId: 'RefArchGlobal'
67+
clientId: 'c8dd028e-e65e-4654-9a2d-4b471d0ae694',
68+
organizationId: 'f_ecom_tbdq_stg',
69+
shortCode: 'sandbox-001',
70+
siteId: 'RefArch'
6871
}
6972
},
7073
einsteinAPI: {
@@ -109,14 +112,14 @@ module.exports = {
109112
'**/*.json'
110113
],
111114
ssrParameters: {
112-
ssrFunctionNodeVersion: '24.x',
115+
ssrFunctionNodeVersion: '22.x',
113116
proxyConfigs: [
114117
{
115-
host: 'kv7kzm78.api.commercecloud.salesforce.com',
118+
host: 'sandbox-001.api.commercecloud.salesforce.com',
116119
path: 'api'
117120
},
118121
{
119-
host: 'zzrf-001.dx.commercecloud.salesforce.com',
122+
host: 'ha-stg.phased-launch-testing.com',
120123
path: 'ocapi'
121124
}
122125
]

0 commit comments

Comments
 (0)