Skip to content

Commit 710037d

Browse files
authored
@W-17554979@ Commerce-sdk-react readme updates (#2212)
* Commerce-sdk-react readme updates * Update changelog * More readme changes
1 parent e8e9123 commit 710037d

File tree

2 files changed

+14
-62
lines changed

2 files changed

+14
-62
lines changed

packages/commerce-sdk-react/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## v3.2.0-dev (Oct 29, 2024)
22
- Allow cookies for ShopperLogin API [#2190](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2190
33
- Fix refresh token TTL warning from firing when override is not provided [#2114](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2114)
4+
- Readme updates for private clients [#2212](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2212)
45

56
- Update CacheUpdateMatrix for mergeBasket mutation [#2138](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2092)
67
- Clear auth state if session has been invalidated by a password change [#2092](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2092)

packages/commerce-sdk-react/README.md

Lines changed: 13 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ In practice, we recommend:
4343
npm install @salesforce/commerce-sdk-react @tanstack/react-query
4444
```
4545

46-
## ⚡️ Quickstart (PWA Kit v2.3.0+)
46+
## ⚡️ Quickstart (PWA Kit v3.0+)
4747

4848
To integrate this library with your PWA Kit application you can use the `CommerceApiProvider` directly assuming that you use the `withReactQuery` higher order component to wrap your `AppConfig` component. Below is a snippet of how this is accomplished.
4949

@@ -54,6 +54,10 @@ import {CommerceApiProvider} from '@salesforce/commerce-sdk-react'
5454
import {withReactQuery} from '@salesforce/pwa-kit-react-sdk/ssr/universal/components/with-react-query'
5555

5656
const AppConfig = ({children}) => {
57+
const headers = {
58+
'correlation-id': correlationId
59+
}
60+
5761
return (
5862
<CommerceApiProvider
5963
clientId="12345678-1234-1234-1234-123412341234"
@@ -64,6 +68,11 @@ const AppConfig = ({children}) => {
6468
shortCode="12345678"
6569
locale="en-US"
6670
currency="USD"
71+
headers={headers}
72+
// Uncomment 'enablePWAKitPrivateClient' to use SLAS private client login flows.
73+
// Make sure to also enable useSLASPrivateClient in ssr.js when enabling this setting.
74+
// enablePWAKitPrivateClient={true}
75+
logger={createLogger({packageName: 'commerce-sdk-react'})}
6776
>
6877
{children}
6978
</CommerceApiProvider>
@@ -125,68 +134,10 @@ export default App
125134

126135
_💡 This section assumes you have read and completed the [Authorization for Shopper APIs](https://developer.salesforce.com/docs/commerce/commerce-api/guide/authorization-for-shopper-apis.html) guide._
127136

128-
To help reduce boilerplate code for managing shopper authentication, by default, this library automatically initializes shopper session and manages the tokens for developers. Currently, the library supports the [Public Client login flow](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas-public-client.html).
129-
130-
Commerce-react-sdk supports both public and private flow of the [Authorization for Shopper APIs](https://developer.salesforce.com/docs/commerce/commerce-api/guide/authorization-for-shopper-apis.html) guide._
131-
You can choose to use either public or private slas to login. By default, public flow is enabled.
132-
133-
#### How private SLAS works
134-
This section assumes you read and understand how [private SLAS](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas-private-client.html) flow works
135-
136-
To enable private slas flow, you need to pass your secret into the CommercerProvider via clientSecret prop.
137-
**Note** You should only use private slas if you know you can secure your secret since commercer-sdk-react runs isomorphically.
138-
139-
```js
140-
// app/components/_app-config/index.jsx
141-
142-
import {CommerceApiProvider} from '@salesforce/commerce-sdk-react'
143-
import {withReactQuery} from '@salesforce/pwa-kit-react-sdk/ssr/universal/components/with-react-query'
144-
145-
const AppConfig = ({children}) => {
146-
return (
147-
<CommerceApiProvider
148-
clientId="12345678-1234-1234-1234-123412341234"
149-
organizationId="f_ecom_aaaa_001"
150-
proxy="localhost:3000/mobify/proxy/api"
151-
redirectURI="localhost:3000/callback"
152-
siteId="RefArch"
153-
shortCode="12345678"
154-
locale="en-US"
155-
currency="USD"
156-
clientSecret="<your-slas-private-secret>"
157-
>
158-
{children}
159-
</CommerceApiProvider>
160-
)
161-
}
162-
```
163-
#### Disable slas private warnings
164-
By default, a warning as below will be displayed on client side to remind developers to always keep their secret safe and secured.
165-
```js
166-
'You are potentially exposing SLAS secret on browser. Make sure to keep it safe and secure!'
167-
```
168-
You can disable this warning by using CommerceProvider prop `silenceWarnings`
137+
To help reduce boilerplate code for managing shopper authentication, by default, this library automatically initializes shopper session and manages the tokens for developers. Commerce-sdk-react supports both the [SLAS Public Client login flow](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas-public-client.html) and [SLAS Private Client login flow](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas-private-client.html). Authorization using a private client is supported in PWA Kit 3.5 and later, and is the recommended authorization workflow.
169138

170-
```js
171-
const AppConfig = ({children}) => {
172-
return (
173-
<CommerceApiProvider
174-
clientId="12345678-1234-1234-1234-123412341234"
175-
organizationId="f_ecom_aaaa_001"
176-
proxy="localhost:3000/mobify/proxy/api"
177-
redirectURI="localhost:3000/callback"
178-
siteId="RefArch"
179-
shortCode="12345678"
180-
locale="en-US"
181-
currency="USD"
182-
clientSecret="<your-slas-private-secret>"
183-
silenceWarnings={true}
184-
>
185-
{children}
186-
</CommerceApiProvider>
187-
)
188-
}
189-
```
139+
#### Using a private SLAS client
140+
To enable a private client, see [Use a SLAS Private Client](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/use-a-slas-private-client.html).
190141

191142
### Shopper Session Initialization
192143

0 commit comments

Comments
 (0)