@salesforce/commerce-sdk-react 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
## v1.0.2 (Sep 21, 2023)
|
|
2
|
+
|
|
3
|
+
- commerce-sdk-react: have typedoc-related deps as dev dependencies [#1425](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/1425)
|
|
4
|
+
- Updated commerce-sdk-isomorphic to v1.10.4 [#137](https://github.com/SalesforceCommerceCloud/commerce-sdk-isomorphic/pull/137)
|
|
5
|
+
|
|
1
6
|
## v1.0.1 (Jul 26, 2023)
|
|
2
7
|
|
|
3
8
|
- Updated the expiry of the guest refresh token cookie to 30 days, to match the actual [duration of the token](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas.html?q=refresh+token#access-tokens-and-refresh-tokens). [#1342](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/1342)
|
package/auth/index.js
CHANGED
|
@@ -82,6 +82,10 @@ const DATA_MAP = {
|
|
|
82
82
|
store.delete('cc-nx-g');
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
|
+
refresh_token_expires_in: {
|
|
86
|
+
storageType: 'local',
|
|
87
|
+
key: 'refresh_token_expires_in'
|
|
88
|
+
},
|
|
85
89
|
// For Hybrid setups, we need a mechanism to inform PWA Kit whenever customer login state changes on SFRA.
|
|
86
90
|
// So we maintain a copy of the refersh_tokens in the local storage which is compared to the actual refresh_token stored in cookie storage.
|
|
87
91
|
// If the key or value of the refresh_token in local storage is different from the one in cookie storage, this indicates a change in customer auth state and we invalidate the access_token in PWA Kit.
|
|
@@ -207,7 +211,8 @@ class Auth {
|
|
|
207
211
|
refresh_token: this.get('refresh_token_registered') || this.get('refresh_token_guest'),
|
|
208
212
|
token_type: this.get('token_type'),
|
|
209
213
|
usid: this.get('usid'),
|
|
210
|
-
customer_type: this.get('customer_type')
|
|
214
|
+
customer_type: this.get('customer_type'),
|
|
215
|
+
refresh_token_expires_in: this.get('refresh_token_expires_in')
|
|
211
216
|
};
|
|
212
217
|
}
|
|
213
218
|
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
2
|
import { ApiClients, ApiQueryOptions, Argument, DataType, NullableParameters } from '../types';
|
|
3
3
|
type Client = ApiClients['shopperLogin'];
|
|
4
|
-
/**
|
|
5
|
-
* Get credential quality statistics for a user.
|
|
6
|
-
* @group ShopperLogin
|
|
7
|
-
* @category Query
|
|
8
|
-
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
9
|
-
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
10
|
-
* @returns A TanStack Query query hook with data from the Shopper Login `retrieveCredQualityUserInfo` endpoint.
|
|
11
|
-
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=retrieveCredQualityUserInfo| Salesforce Developer Center} for more information about the API endpoint.
|
|
12
|
-
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#retrievecredqualityuserinfo | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
13
|
-
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
14
|
-
*/
|
|
15
|
-
export declare const useCredQualityUserInfo: (apiOptions: NullableParameters<Argument<Client['retrieveCredQualityUserInfo']>>, queryOptions?: ApiQueryOptions<Client['retrieveCredQualityUserInfo']>) => UseQueryResult<DataType<Client['retrieveCredQualityUserInfo']>>;
|
|
16
4
|
/**
|
|
17
5
|
* Returns a JSON listing of claims about the currently authenticated user.
|
|
18
6
|
* @group ShopperLogin
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useWellknownOpenidConfiguration = exports.useUserInfo = exports.useJwksUri =
|
|
6
|
+
exports.useWellknownOpenidConfiguration = exports.useUserInfo = exports.useJwksUri = void 0;
|
|
7
7
|
var _useCommerceApi = _interopRequireDefault(require("../useCommerceApi"));
|
|
8
8
|
var _useQuery = require("../useQuery");
|
|
9
9
|
var _utils = require("../utils");
|
|
@@ -18,46 +18,6 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
18
18
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
19
19
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
20
20
|
*/
|
|
21
|
-
/**
|
|
22
|
-
* Get credential quality statistics for a user.
|
|
23
|
-
* @group ShopperLogin
|
|
24
|
-
* @category Query
|
|
25
|
-
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
26
|
-
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
27
|
-
* @returns A TanStack Query query hook with data from the Shopper Login `retrieveCredQualityUserInfo` endpoint.
|
|
28
|
-
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=retrieveCredQualityUserInfo| Salesforce Developer Center} for more information about the API endpoint.
|
|
29
|
-
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#retrievecredqualityuserinfo | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
30
|
-
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
31
|
-
*/
|
|
32
|
-
const useCredQualityUserInfo = (apiOptions, queryOptions = {}) => {
|
|
33
|
-
const {
|
|
34
|
-
shopperLogin: client
|
|
35
|
-
} = (0, _useCommerceApi.default)();
|
|
36
|
-
const methodName = 'retrieveCredQualityUserInfo';
|
|
37
|
-
const requiredParameters = ['organizationId', 'username'];
|
|
38
|
-
|
|
39
|
-
// Parameters can be set in `apiOptions` or `client.clientConfig`;
|
|
40
|
-
// we must merge them in order to generate the correct query key.
|
|
41
|
-
const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
|
|
42
|
-
const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
|
|
43
|
-
// We don't use `netOptions` here because we manipulate the options in `useQuery`.
|
|
44
|
-
const method = /*#__PURE__*/function () {
|
|
45
|
-
var _ref = _asyncToGenerator(function* (options) {
|
|
46
|
-
return yield client[methodName](options);
|
|
47
|
-
});
|
|
48
|
-
return function method(_x) {
|
|
49
|
-
return _ref.apply(this, arguments);
|
|
50
|
-
};
|
|
51
|
-
}();
|
|
52
|
-
|
|
53
|
-
// For some reason, if we don't explicitly set these generic parameters, the inferred type for
|
|
54
|
-
// `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
|
|
55
|
-
return (0, _useQuery.useQuery)(netOptions, queryOptions, {
|
|
56
|
-
method,
|
|
57
|
-
queryKey,
|
|
58
|
-
requiredParameters
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
21
|
/**
|
|
62
22
|
* Returns a JSON listing of claims about the currently authenticated user.
|
|
63
23
|
* @group ShopperLogin
|
|
@@ -69,7 +29,6 @@ const useCredQualityUserInfo = (apiOptions, queryOptions = {}) => {
|
|
|
69
29
|
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#getuserinfo | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
70
30
|
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
71
31
|
*/
|
|
72
|
-
exports.useCredQualityUserInfo = useCredQualityUserInfo;
|
|
73
32
|
const useUserInfo = (apiOptions, queryOptions = {}) => {
|
|
74
33
|
const {
|
|
75
34
|
shopperLogin: client
|
|
@@ -83,11 +42,11 @@ const useUserInfo = (apiOptions, queryOptions = {}) => {
|
|
|
83
42
|
const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
|
|
84
43
|
// We don't use `netOptions` here because we manipulate the options in `useQuery`.
|
|
85
44
|
const method = /*#__PURE__*/function () {
|
|
86
|
-
var
|
|
45
|
+
var _ref = _asyncToGenerator(function* (options) {
|
|
87
46
|
return yield client[methodName](options);
|
|
88
47
|
});
|
|
89
|
-
return function method(
|
|
90
|
-
return
|
|
48
|
+
return function method(_x) {
|
|
49
|
+
return _ref.apply(this, arguments);
|
|
91
50
|
};
|
|
92
51
|
}();
|
|
93
52
|
|
|
@@ -124,11 +83,11 @@ const useWellknownOpenidConfiguration = (apiOptions, queryOptions = {}) => {
|
|
|
124
83
|
const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
|
|
125
84
|
// We don't use `netOptions` here because we manipulate the options in `useQuery`.
|
|
126
85
|
const method = /*#__PURE__*/function () {
|
|
127
|
-
var
|
|
86
|
+
var _ref2 = _asyncToGenerator(function* (options) {
|
|
128
87
|
return yield client[methodName](options);
|
|
129
88
|
});
|
|
130
|
-
return function method(
|
|
131
|
-
return
|
|
89
|
+
return function method(_x2) {
|
|
90
|
+
return _ref2.apply(this, arguments);
|
|
132
91
|
};
|
|
133
92
|
}();
|
|
134
93
|
|
|
@@ -165,11 +124,11 @@ const useJwksUri = (apiOptions, queryOptions = {}) => {
|
|
|
165
124
|
const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
|
|
166
125
|
// We don't use `netOptions` here because we manipulate the options in `useQuery`.
|
|
167
126
|
const method = /*#__PURE__*/function () {
|
|
168
|
-
var
|
|
127
|
+
var _ref3 = _asyncToGenerator(function* (options) {
|
|
169
128
|
return yield client[methodName](options);
|
|
170
129
|
});
|
|
171
|
-
return function method(
|
|
172
|
-
return
|
|
130
|
+
return function method(_x3) {
|
|
131
|
+
return _ref3.apply(this, arguments);
|
|
173
132
|
};
|
|
174
133
|
}();
|
|
175
134
|
|
|
@@ -5,13 +5,6 @@ type Client = ShopperLogin<{
|
|
|
5
5
|
}>;
|
|
6
6
|
type Params<T extends keyof QueryKeys> = Partial<Argument<Client[T]>['parameters']>;
|
|
7
7
|
export type QueryKeys = {
|
|
8
|
-
retrieveCredQualityUserInfo: [
|
|
9
|
-
'/commerce-sdk-react',
|
|
10
|
-
'/organizations/',
|
|
11
|
-
string | undefined,
|
|
12
|
-
'/cred-qual/user',
|
|
13
|
-
Params<'retrieveCredQualityUserInfo'>
|
|
14
|
-
];
|
|
15
8
|
getUserInfo: [
|
|
16
9
|
'/commerce-sdk-react',
|
|
17
10
|
'/organizations/',
|
|
@@ -45,7 +38,6 @@ type QueryKeyHelper<T extends keyof QueryKeys> = {
|
|
|
45
38
|
/** Generates the full query key for an endpoint. */
|
|
46
39
|
queryKey: (params: Params<T>) => QueryKeys[T];
|
|
47
40
|
};
|
|
48
|
-
export declare const retrieveCredQualityUserInfo: QueryKeyHelper<'retrieveCredQualityUserInfo'>;
|
|
49
41
|
export declare const getUserInfo: QueryKeyHelper<'getUserInfo'>;
|
|
50
42
|
export declare const getWellknownOpenidConfiguration: QueryKeyHelper<'getWellknownOpenidConfiguration'>;
|
|
51
43
|
export declare const getJwksUri: QueryKeyHelper<'getJwksUri'>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.getWellknownOpenidConfiguration = exports.getUserInfo = exports.getJwksUri = void 0;
|
|
7
7
|
var _utils = require("../utils");
|
|
8
8
|
/*
|
|
9
9
|
* Copyright (c) 2023, Salesforce, Inc.
|
|
@@ -17,12 +17,6 @@ var _utils = require("../utils");
|
|
|
17
17
|
// This is defined here, rather than `types.ts`, because it relies on `Client` and `QueryKeys`,
|
|
18
18
|
// and making those generic would add too much complexity.
|
|
19
19
|
|
|
20
|
-
const retrieveCredQualityUserInfo = {
|
|
21
|
-
parameters: params => (0, _utils.pick)(params, ['organizationId', 'username']),
|
|
22
|
-
path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/cred-qual/user'],
|
|
23
|
-
queryKey: params => [...retrieveCredQualityUserInfo.path(params), retrieveCredQualityUserInfo.parameters(params)]
|
|
24
|
-
};
|
|
25
|
-
exports.retrieveCredQualityUserInfo = retrieveCredQualityUserInfo;
|
|
26
20
|
const getUserInfo = {
|
|
27
21
|
parameters: params => (0, _utils.pick)(params, ['organizationId', 'channel_id']),
|
|
28
22
|
path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/oauth2/userinfo'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/commerce-sdk-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A library that provides react hooks for fetching data from Commerce Cloud",
|
|
5
5
|
"homepage": "https://github.com/SalesforceCommerceCloud/pwa-kit/tree/develop/packages/ecom-react-hooks#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -40,14 +40,12 @@
|
|
|
40
40
|
"version": "node ./scripts/version.js"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"commerce-sdk-isomorphic": "^1.10.
|
|
43
|
+
"commerce-sdk-isomorphic": "^1.10.4",
|
|
44
44
|
"js-cookie": "^3.0.1",
|
|
45
|
-
"jwt-decode": "^3.1.2"
|
|
46
|
-
"typedoc": "^0.24.7",
|
|
47
|
-
"typedoc-plugin-missing-exports": "^2.0.0"
|
|
45
|
+
"jwt-decode": "^3.1.2"
|
|
48
46
|
},
|
|
49
47
|
"devDependencies": {
|
|
50
|
-
"@salesforce/pwa-kit-dev": "3.1.
|
|
48
|
+
"@salesforce/pwa-kit-dev": "3.1.1",
|
|
51
49
|
"@tanstack/react-query": "^4.28.0",
|
|
52
50
|
"@testing-library/jest-dom": "^5.16.5",
|
|
53
51
|
"@testing-library/react": "^14.0.0",
|
|
@@ -59,7 +57,7 @@
|
|
|
59
57
|
"@types/react-dom": "^18.2.1",
|
|
60
58
|
"@types/react-helmet": "^6.1.6",
|
|
61
59
|
"cross-env": "^5.2.1",
|
|
62
|
-
"internal-lib-build": "3.1.
|
|
60
|
+
"internal-lib-build": "3.1.1",
|
|
63
61
|
"jsonwebtoken": "^9.0.0",
|
|
64
62
|
"nock": "^13.3.0",
|
|
65
63
|
"nodemon": "^2.0.22",
|
|
@@ -69,6 +67,7 @@
|
|
|
69
67
|
"semver": "^7.5.2",
|
|
70
68
|
"shelljs": "^0.8.5",
|
|
71
69
|
"typedoc": "^0.24.7",
|
|
70
|
+
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
72
71
|
"typescript": "4.9.5"
|
|
73
72
|
},
|
|
74
73
|
"peerDependencies": {
|
|
@@ -86,5 +85,5 @@
|
|
|
86
85
|
"publishConfig": {
|
|
87
86
|
"directory": "dist"
|
|
88
87
|
},
|
|
89
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "0194d62014788b280549e70e6e80da279227b500"
|
|
90
89
|
}
|