@salesforce/commerce-sdk-react 1.0.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +10 -0
- package/CHANGELOG.md +35 -0
- package/LICENSE +14 -0
- package/README.md +327 -0
- package/auth/index.d.ts +220 -0
- package/auth/index.js +472 -0
- package/auth/storage.d.ts +48 -0
- package/auth/storage.js +122 -0
- package/components/ShopperExperience/Component/index.d.ts +17 -0
- package/components/ShopperExperience/Component/index.js +49 -0
- package/components/ShopperExperience/Page/index.d.ts +28 -0
- package/components/ShopperExperience/Page/index.js +97 -0
- package/components/ShopperExperience/Region/index.d.ts +41 -0
- package/components/ShopperExperience/Region/index.js +64 -0
- package/components/ShopperExperience/index.d.ts +5 -0
- package/components/ShopperExperience/index.js +49 -0
- package/components/ShopperExperience/prop-types.d.ts +39 -0
- package/components/ShopperExperience/prop-types.js +46 -0
- package/components/ShopperExperience/types.d.ts +8 -0
- package/components/ShopperExperience/types.js +5 -0
- package/components/index.d.ts +2 -0
- package/components/index.js +16 -0
- package/hooks/ShopperBaskets/cache.d.ts +5 -0
- package/hooks/ShopperBaskets/cache.js +351 -0
- package/hooks/ShopperBaskets/index.d.ts +3 -0
- package/hooks/ShopperBaskets/index.js +27 -0
- package/hooks/ShopperBaskets/mutation.d.ts +381 -0
- package/hooks/ShopperBaskets/mutation.js +380 -0
- package/hooks/ShopperBaskets/query.d.ts +55 -0
- package/hooks/ShopperBaskets/query.js +215 -0
- package/hooks/ShopperBaskets/queryKeyHelpers.d.ts +72 -0
- package/hooks/ShopperBaskets/queryKeyHelpers.js +49 -0
- package/hooks/ShopperContexts/cache.d.ts +5 -0
- package/hooks/ShopperContexts/cache.js +45 -0
- package/hooks/ShopperContexts/index.d.ts +3 -0
- package/hooks/ShopperContexts/index.js +27 -0
- package/hooks/ShopperContexts/mutation.d.ts +35 -0
- package/hooks/ShopperContexts/mutation.js +68 -0
- package/hooks/ShopperContexts/query.d.ts +15 -0
- package/hooks/ShopperContexts/query.js +59 -0
- package/hooks/ShopperContexts/queryKeyHelpers.d.ts +30 -0
- package/hooks/ShopperContexts/queryKeyHelpers.js +25 -0
- package/hooks/ShopperCustomers/cache.d.ts +5 -0
- package/hooks/ShopperCustomers/cache.js +387 -0
- package/hooks/ShopperCustomers/index.d.ts +3 -0
- package/hooks/ShopperCustomers/index.js +27 -0
- package/hooks/ShopperCustomers/mutation.d.ts +163 -0
- package/hooks/ShopperCustomers/mutation.js +203 -0
- package/hooks/ShopperCustomers/query.d.ts +115 -0
- package/hooks/ShopperCustomers/query.js +489 -0
- package/hooks/ShopperCustomers/queryKeyHelpers.d.ts +142 -0
- package/hooks/ShopperCustomers/queryKeyHelpers.js +91 -0
- package/hooks/ShopperExperience/index.d.ts +2 -0
- package/hooks/ShopperExperience/index.js +16 -0
- package/hooks/ShopperExperience/query.d.ts +31 -0
- package/hooks/ShopperExperience/query.js +104 -0
- package/hooks/ShopperExperience/queryKeyHelpers.d.ts +38 -0
- package/hooks/ShopperExperience/queryKeyHelpers.js +31 -0
- package/hooks/ShopperGiftCertificates/index.d.ts +2 -0
- package/hooks/ShopperGiftCertificates/index.js +16 -0
- package/hooks/ShopperGiftCertificates/query.d.ts +15 -0
- package/hooks/ShopperGiftCertificates/query.js +70 -0
- package/hooks/ShopperGiftCertificates/queryKeyHelpers.d.ts +29 -0
- package/hooks/ShopperGiftCertificates/queryKeyHelpers.js +25 -0
- package/hooks/ShopperLogin/cache.d.ts +3 -0
- package/hooks/ShopperLogin/cache.js +33 -0
- package/hooks/ShopperLogin/index.d.ts +3 -0
- package/hooks/ShopperLogin/index.js +27 -0
- package/hooks/ShopperLogin/mutation.d.ts +119 -0
- package/hooks/ShopperLogin/mutation.js +138 -0
- package/hooks/ShopperLogin/query.d.ts +45 -0
- package/hooks/ShopperLogin/query.js +176 -0
- package/hooks/ShopperLogin/queryKeyHelpers.d.ts +53 -0
- package/hooks/ShopperLogin/queryKeyHelpers.js +43 -0
- package/hooks/ShopperOrders/cache.d.ts +5 -0
- package/hooks/ShopperOrders/cache.js +54 -0
- package/hooks/ShopperOrders/index.d.ts +3 -0
- package/hooks/ShopperOrders/index.js +27 -0
- package/hooks/ShopperOrders/mutation.d.ts +54 -0
- package/hooks/ShopperOrders/mutation.js +83 -0
- package/hooks/ShopperOrders/query.d.ts +37 -0
- package/hooks/ShopperOrders/query.js +139 -0
- package/hooks/ShopperOrders/queryKeyHelpers.d.ts +50 -0
- package/hooks/ShopperOrders/queryKeyHelpers.js +37 -0
- package/hooks/ShopperProducts/index.d.ts +2 -0
- package/hooks/ShopperProducts/index.js +16 -0
- package/hooks/ShopperProducts/query.d.ts +47 -0
- package/hooks/ShopperProducts/query.js +178 -0
- package/hooks/ShopperProducts/queryKeyHelpers.d.ts +55 -0
- package/hooks/ShopperProducts/queryKeyHelpers.js +43 -0
- package/hooks/ShopperPromotions/index.d.ts +2 -0
- package/hooks/ShopperPromotions/index.js +16 -0
- package/hooks/ShopperPromotions/query.d.ts +29 -0
- package/hooks/ShopperPromotions/query.js +102 -0
- package/hooks/ShopperPromotions/queryKeyHelpers.d.ts +38 -0
- package/hooks/ShopperPromotions/queryKeyHelpers.js +31 -0
- package/hooks/ShopperSearch/index.d.ts +2 -0
- package/hooks/ShopperSearch/index.js +16 -0
- package/hooks/ShopperSearch/query.d.ts +26 -0
- package/hooks/ShopperSearch/query.js +99 -0
- package/hooks/ShopperSearch/queryKeyHelpers.d.ts +37 -0
- package/hooks/ShopperSearch/queryKeyHelpers.js +31 -0
- package/hooks/index.d.ts +18 -0
- package/hooks/index.js +188 -0
- package/hooks/types.d.ts +128 -0
- package/hooks/types.js +5 -0
- package/hooks/useAccessToken.d.ts +11 -0
- package/hooks/useAccessToken.js +43 -0
- package/hooks/useAuthContext.d.ts +9 -0
- package/hooks/useAuthContext.js +30 -0
- package/hooks/useAuthHelper.d.ts +23 -0
- package/hooks/useAuthHelper.js +66 -0
- package/hooks/useAuthorizationHeader.d.ts +9 -0
- package/hooks/useAuthorizationHeader.js +45 -0
- package/hooks/useCommerceApi.d.ts +9 -0
- package/hooks/useCommerceApi.js +26 -0
- package/hooks/useConfig.d.ts +7 -0
- package/hooks/useConfig.js +24 -0
- package/hooks/useCustomerId.d.ts +7 -0
- package/hooks/useCustomerId.js +38 -0
- package/hooks/useCustomerType.d.ts +21 -0
- package/hooks/useCustomerType.js +43 -0
- package/hooks/useEncUserId.d.ts +9 -0
- package/hooks/useEncUserId.js +36 -0
- package/hooks/useLocalStorage.d.ts +8 -0
- package/hooks/useLocalStorage.js +40 -0
- package/hooks/useMutation.d.ts +12 -0
- package/hooks/useMutation.js +38 -0
- package/hooks/useQuery.d.ts +15 -0
- package/hooks/useQuery.js +57 -0
- package/hooks/useUsid.d.ts +7 -0
- package/hooks/useUsid.js +34 -0
- package/hooks/utils.d.ts +32 -0
- package/hooks/utils.js +125 -0
- package/index.d.ts +5 -0
- package/index.js +40 -0
- package/package.json +88 -0
- package/provider.d.ts +36 -0
- package/provider.js +124 -0
- package/scripts/build-and-release-docs.js +48 -0
- package/scripts/version.js +22 -0
- package/utils.d.ts +5 -0
- package/utils.js +18 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { ApiClients, Argument, DataType } from '../types';
|
|
2
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
declare type Client = ApiClients['shopperLogin'];
|
|
4
|
+
/** Mutations available for Shopper Login. */
|
|
5
|
+
export declare const ShopperLoginMutations: {
|
|
6
|
+
/**
|
|
7
|
+
* Allows the customer to authenticate when their identity provider is down.
|
|
8
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `authorizePasswordlessCustomer` endpoint.
|
|
9
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=authorizePasswordlessCustomer| Salesforce Developer Center} for more information about the API endpoint.
|
|
10
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#authorizepasswordlesscustomer | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
11
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
12
|
+
*/
|
|
13
|
+
readonly AuthorizePasswordlessCustomer: "authorizePasswordlessCustomer";
|
|
14
|
+
/**
|
|
15
|
+
* Log out a shopper. The shopper's access token and refresh token are revoked. If the shopper authenticated with a B2C Commerce (ECOM) instance, the OCAPI JWT is also revoked. This should be called for Registered users that have logged in using SLAS. his should be called for registered users that have logged in using SLAS. This endpoint is not for use with guest users.
|
|
16
|
+
|
|
17
|
+
Required header: Authorization header bearer token of the Shopper access token to logout.
|
|
18
|
+
|
|
19
|
+
Required parameters: `refresh token`, `channel_id`, and `client`.
|
|
20
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `logoutCustomer` endpoint.
|
|
21
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=logoutCustomer| Salesforce Developer Center} for more information about the API endpoint.
|
|
22
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#logoutcustomer | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
23
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
24
|
+
*/
|
|
25
|
+
readonly LogoutCustomer: "logoutCustomer";
|
|
26
|
+
/**
|
|
27
|
+
* Get the shopper or guest JWT access token and a refresh token. This is the second step of the OAuth 2.1 authorization code flow.
|
|
28
|
+
|
|
29
|
+
For a private client, an application is able to get an access token for the shopper through the back channel (a trusted server) by passing in the client credentials and the authorization code retrieved from the `authorize` endpoint.
|
|
30
|
+
|
|
31
|
+
For a guest user, get the shopper JWT access token and a refresh token. This is where a client appplication is able to get an access token for the guest user through the back channel (a trusted server) by passing in the client credentials.
|
|
32
|
+
|
|
33
|
+
For a public client using PKCE, an application will pass a PKCE `code_verifier`` that matches the `code_challenge`` that was used to `authorize` the customer along with the authorization code.
|
|
34
|
+
|
|
35
|
+
When refreshing the access token with a private client ID and client secret, the refresh token is _not_ regenerated. However, when refreshing the access token with a public client ID, the refresh token is _always_ regenerated. The old refresh token is voided with every refresh call, so the refresh token on the client needs to be replaced to always store the new refresh token.
|
|
36
|
+
|
|
37
|
+
See the Body section for required parameters, including `grant_type` and others, depending on the value of `grant_type`.
|
|
38
|
+
|
|
39
|
+
**Important**: We strongly recommended using the `channel_id` query parameter because **it will be required in the future**.
|
|
40
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `getAccessToken` endpoint.
|
|
41
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getAccessToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
42
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#getaccesstoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
43
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
44
|
+
*/
|
|
45
|
+
readonly GetAccessToken: "getAccessToken";
|
|
46
|
+
/**
|
|
47
|
+
* Get a shopper JWT access token for a registered customer using session bridge.
|
|
48
|
+
|
|
49
|
+
For public client id requests the grant_type must be set to `session_bridge`.
|
|
50
|
+
|
|
51
|
+
For private client_id and secret the grant_type must be set to `client_credentials` along with a basic authorization header.
|
|
52
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `getSessionBridgeAccessToken` endpoint.
|
|
53
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getSessionBridgeAccessToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
54
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#getsessionbridgeaccesstoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
55
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
56
|
+
*/
|
|
57
|
+
readonly GetSessionBridgeAccessToken: "getSessionBridgeAccessToken";
|
|
58
|
+
/**
|
|
59
|
+
* Get a shopper JWT access token for a registered customer whose credentials are stored using a third party system.
|
|
60
|
+
|
|
61
|
+
For external trusted-system requests, a basic authorization header that includes a SLAS client ID and SLAS client secret can be used in place of the bearer token.
|
|
62
|
+
|
|
63
|
+
For internal trusted-system requests, the bearer token must be a C2C JWT.
|
|
64
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `getTrustedSystemAccessToken` endpoint.
|
|
65
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getTrustedSystemAccessToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
66
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#gettrustedsystemaccesstoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
67
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
68
|
+
*/
|
|
69
|
+
readonly GetTrustedSystemAccessToken: "getTrustedSystemAccessToken";
|
|
70
|
+
/**
|
|
71
|
+
* Get a shopper JWT access token for a registered customer using a trusted agent (merchant).
|
|
72
|
+
|
|
73
|
+
If using a SLAS private client ID, you must also use an `_sfdc_client_auth` header.
|
|
74
|
+
|
|
75
|
+
The value of the `_sfdc_client_auth` header must be a Base64-encoded string. The string is composed of a SLAS private client ID and client secret, separated by a colon (`:`). For example, `privateClientId:privateClientsecret` becomes `cHJpdmF0ZUNsaWVudElkOnByaXZhdGVDbGllbnRzZWNyZXQ=` after Base64 encoding.
|
|
76
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `getTrustedAgentAccessToken` endpoint.
|
|
77
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getTrustedAgentAccessToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
78
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#gettrustedagentaccesstoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
79
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
80
|
+
*/
|
|
81
|
+
readonly GetTrustedAgentAccessToken: "getTrustedAgentAccessToken";
|
|
82
|
+
/**
|
|
83
|
+
* Creates a new password
|
|
84
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `resetPassword` endpoint.
|
|
85
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=resetPassword| Salesforce Developer Center} for more information about the API endpoint.
|
|
86
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#resetpassword | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
87
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
88
|
+
*/
|
|
89
|
+
readonly ResetPassword: "resetPassword";
|
|
90
|
+
/**
|
|
91
|
+
* Issue a shopper token (JWT).
|
|
92
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `getPasswordLessAccessToken` endpoint.
|
|
93
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getPasswordLessAccessToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
94
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#getpasswordlessaccesstoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
95
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
96
|
+
*/
|
|
97
|
+
readonly GetPasswordLessAccessToken: "getPasswordLessAccessToken";
|
|
98
|
+
/**
|
|
99
|
+
* Invalidate the refresh token. A basic auth header with Base64-encoded `clientId:secret` is required in the Authorization header, and the refresh token to be revoked is required in the body.
|
|
100
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `revokeToken` endpoint.
|
|
101
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=revokeToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
102
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#revoketoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
103
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
104
|
+
*/
|
|
105
|
+
readonly RevokeToken: "revokeToken";
|
|
106
|
+
/**
|
|
107
|
+
* Returns the token properties. A basic auth header with Base64-encoded `clientId:secret` is required in the Authorization header, as well as an access token or refresh token. Use `token_type_hint` to help identify the token.
|
|
108
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `introspectToken` endpoint.
|
|
109
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=introspectToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
110
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#introspecttoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
111
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
112
|
+
*/
|
|
113
|
+
readonly IntrospectToken: "introspectToken";
|
|
114
|
+
};
|
|
115
|
+
/** Mutation for Shopper Login. */
|
|
116
|
+
export declare type ShopperLoginMutation = (typeof ShopperLoginMutations)[keyof typeof ShopperLoginMutations];
|
|
117
|
+
export declare function useShopperLoginMutation<Mutation extends ShopperLoginMutation>(mutation: Mutation): UseMutationResult<DataType<Client[Mutation]>, unknown, Argument<Client[Mutation]>>;
|
|
118
|
+
export {};
|
|
119
|
+
//# sourceMappingURL=mutation.d.ts.map
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ShopperLoginMutations = void 0;
|
|
7
|
+
exports.useShopperLoginMutation = useShopperLoginMutation;
|
|
8
|
+
var _useMutation = require("../useMutation");
|
|
9
|
+
var _utils = require("../utils");
|
|
10
|
+
var _useCommerceApi = _interopRequireDefault(require("../useCommerceApi"));
|
|
11
|
+
var _cache = require("./cache");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
15
|
+
* All rights reserved.
|
|
16
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** Mutations available for Shopper Login. */
|
|
21
|
+
const ShopperLoginMutations = {
|
|
22
|
+
/**
|
|
23
|
+
* Allows the customer to authenticate when their identity provider is down.
|
|
24
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `authorizePasswordlessCustomer` endpoint.
|
|
25
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=authorizePasswordlessCustomer| Salesforce Developer Center} for more information about the API endpoint.
|
|
26
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#authorizepasswordlesscustomer | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
27
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
28
|
+
*/
|
|
29
|
+
AuthorizePasswordlessCustomer: 'authorizePasswordlessCustomer',
|
|
30
|
+
/**
|
|
31
|
+
* Log out a shopper. The shopper's access token and refresh token are revoked. If the shopper authenticated with a B2C Commerce (ECOM) instance, the OCAPI JWT is also revoked. This should be called for Registered users that have logged in using SLAS. his should be called for registered users that have logged in using SLAS. This endpoint is not for use with guest users.
|
|
32
|
+
Required header: Authorization header bearer token of the Shopper access token to logout.
|
|
33
|
+
Required parameters: `refresh token`, `channel_id`, and `client`.
|
|
34
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `logoutCustomer` endpoint.
|
|
35
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=logoutCustomer| Salesforce Developer Center} for more information about the API endpoint.
|
|
36
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#logoutcustomer | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
37
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
38
|
+
*/
|
|
39
|
+
LogoutCustomer: 'logoutCustomer',
|
|
40
|
+
/**
|
|
41
|
+
* Get the shopper or guest JWT access token and a refresh token. This is the second step of the OAuth 2.1 authorization code flow.
|
|
42
|
+
For a private client, an application is able to get an access token for the shopper through the back channel (a trusted server) by passing in the client credentials and the authorization code retrieved from the `authorize` endpoint.
|
|
43
|
+
For a guest user, get the shopper JWT access token and a refresh token. This is where a client appplication is able to get an access token for the guest user through the back channel (a trusted server) by passing in the client credentials.
|
|
44
|
+
For a public client using PKCE, an application will pass a PKCE `code_verifier`` that matches the `code_challenge`` that was used to `authorize` the customer along with the authorization code.
|
|
45
|
+
When refreshing the access token with a private client ID and client secret, the refresh token is _not_ regenerated. However, when refreshing the access token with a public client ID, the refresh token is _always_ regenerated. The old refresh token is voided with every refresh call, so the refresh token on the client needs to be replaced to always store the new refresh token.
|
|
46
|
+
See the Body section for required parameters, including `grant_type` and others, depending on the value of `grant_type`.
|
|
47
|
+
**Important**: We strongly recommended using the `channel_id` query parameter because **it will be required in the future**.
|
|
48
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `getAccessToken` endpoint.
|
|
49
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getAccessToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
50
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#getaccesstoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
51
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
52
|
+
*/
|
|
53
|
+
GetAccessToken: 'getAccessToken',
|
|
54
|
+
/**
|
|
55
|
+
* Get a shopper JWT access token for a registered customer using session bridge.
|
|
56
|
+
For public client id requests the grant_type must be set to `session_bridge`.
|
|
57
|
+
For private client_id and secret the grant_type must be set to `client_credentials` along with a basic authorization header.
|
|
58
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `getSessionBridgeAccessToken` endpoint.
|
|
59
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getSessionBridgeAccessToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
60
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#getsessionbridgeaccesstoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
61
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
62
|
+
*/
|
|
63
|
+
GetSessionBridgeAccessToken: 'getSessionBridgeAccessToken',
|
|
64
|
+
/**
|
|
65
|
+
* Get a shopper JWT access token for a registered customer whose credentials are stored using a third party system.
|
|
66
|
+
For external trusted-system requests, a basic authorization header that includes a SLAS client ID and SLAS client secret can be used in place of the bearer token.
|
|
67
|
+
For internal trusted-system requests, the bearer token must be a C2C JWT.
|
|
68
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `getTrustedSystemAccessToken` endpoint.
|
|
69
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getTrustedSystemAccessToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
70
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#gettrustedsystemaccesstoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
71
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
72
|
+
*/
|
|
73
|
+
GetTrustedSystemAccessToken: 'getTrustedSystemAccessToken',
|
|
74
|
+
/**
|
|
75
|
+
* Get a shopper JWT access token for a registered customer using a trusted agent (merchant).
|
|
76
|
+
If using a SLAS private client ID, you must also use an `_sfdc_client_auth` header.
|
|
77
|
+
The value of the `_sfdc_client_auth` header must be a Base64-encoded string. The string is composed of a SLAS private client ID and client secret, separated by a colon (`:`). For example, `privateClientId:privateClientsecret` becomes `cHJpdmF0ZUNsaWVudElkOnByaXZhdGVDbGllbnRzZWNyZXQ=` after Base64 encoding.
|
|
78
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `getTrustedAgentAccessToken` endpoint.
|
|
79
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getTrustedAgentAccessToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
80
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#gettrustedagentaccesstoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
81
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
82
|
+
*/
|
|
83
|
+
GetTrustedAgentAccessToken: 'getTrustedAgentAccessToken',
|
|
84
|
+
/**
|
|
85
|
+
* Creates a new password
|
|
86
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `resetPassword` endpoint.
|
|
87
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=resetPassword| Salesforce Developer Center} for more information about the API endpoint.
|
|
88
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#resetpassword | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
89
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
90
|
+
*/
|
|
91
|
+
ResetPassword: 'resetPassword',
|
|
92
|
+
/**
|
|
93
|
+
* Issue a shopper token (JWT).
|
|
94
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `getPasswordLessAccessToken` endpoint.
|
|
95
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getPasswordLessAccessToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
96
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#getpasswordlessaccesstoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
97
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
98
|
+
*/
|
|
99
|
+
GetPasswordLessAccessToken: 'getPasswordLessAccessToken',
|
|
100
|
+
/**
|
|
101
|
+
* Invalidate the refresh token. A basic auth header with Base64-encoded `clientId:secret` is required in the Authorization header, and the refresh token to be revoked is required in the body.
|
|
102
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `revokeToken` endpoint.
|
|
103
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=revokeToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
104
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#revoketoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
105
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
106
|
+
*/
|
|
107
|
+
RevokeToken: 'revokeToken',
|
|
108
|
+
/**
|
|
109
|
+
* Returns the token properties. A basic auth header with Base64-encoded `clientId:secret` is required in the Authorization header, as well as an access token or refresh token. Use `token_type_hint` to help identify the token.
|
|
110
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Login `introspectToken` endpoint.
|
|
111
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=introspectToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
112
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#introspecttoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
113
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
114
|
+
*/
|
|
115
|
+
IntrospectToken: 'introspectToken'
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/** Mutation for Shopper Login. */
|
|
119
|
+
exports.ShopperLoginMutations = ShopperLoginMutations;
|
|
120
|
+
function useShopperLoginMutation(mutation) {
|
|
121
|
+
const getCacheUpdates = _cache.cacheUpdateMatrix[mutation];
|
|
122
|
+
// TODO: Remove this check when all mutations are implemented.
|
|
123
|
+
if (!getCacheUpdates) throw new _utils.NotImplementedError(`The '${mutation}' mutation`);
|
|
124
|
+
|
|
125
|
+
// The `Options` and `Data` types for each mutation are similar, but distinct, and the union
|
|
126
|
+
// type generated from `Client[Mutation]` seems to be too complex for TypeScript to handle.
|
|
127
|
+
// I'm not sure if there's a way to avoid the type assertions in here for the methods that
|
|
128
|
+
// use them. However, I'm fairly confident that they are safe to do, as they seem to be simply
|
|
129
|
+
// re-asserting what we already have.
|
|
130
|
+
const {
|
|
131
|
+
shopperLogin: client
|
|
132
|
+
} = (0, _useCommerceApi.default)();
|
|
133
|
+
return (0, _useMutation.useMutation)({
|
|
134
|
+
client,
|
|
135
|
+
method: opts => client[mutation](opts),
|
|
136
|
+
getCacheUpdates: getCacheUpdates
|
|
137
|
+
});
|
|
138
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import { ApiClients, ApiQueryOptions, Argument, DataType, NullableParameters } from '../types';
|
|
3
|
+
declare type Client = ApiClients['shopperLogin'];
|
|
4
|
+
/**
|
|
5
|
+
* Get credential quality statistics for a user.
|
|
6
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
7
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
8
|
+
* @returns A TanStack Query query hook with data from the Shopper Login `retrieveCredQualityUserInfo` endpoint.
|
|
9
|
+
* @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.
|
|
10
|
+
* @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.
|
|
11
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useCredQualityUserInfo: (apiOptions: NullableParameters<Argument<Client['retrieveCredQualityUserInfo']>>, queryOptions?: ApiQueryOptions<Client['retrieveCredQualityUserInfo']>) => UseQueryResult<DataType<Client['retrieveCredQualityUserInfo']>>;
|
|
14
|
+
/**
|
|
15
|
+
* Returns a JSON listing of claims about the currently authenticated user.
|
|
16
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
17
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
18
|
+
* @returns A TanStack Query query hook with data from the Shopper Login `getUserInfo` endpoint.
|
|
19
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getUserInfo| Salesforce Developer Center} for more information about the API endpoint.
|
|
20
|
+
* @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.
|
|
21
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
22
|
+
*/
|
|
23
|
+
export declare const useUserInfo: (apiOptions: NullableParameters<Argument<Client['getUserInfo']>>, queryOptions?: ApiQueryOptions<Client['getUserInfo']>) => UseQueryResult<DataType<Client['getUserInfo']>>;
|
|
24
|
+
/**
|
|
25
|
+
* Returns a JSON listing of the OpenID/OAuth endpoints, supported scopes and claims, public keys used to sign the tokens, and other details.
|
|
26
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
27
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
28
|
+
* @returns A TanStack Query query hook with data from the Shopper Login `getWellknownOpenidConfiguration` endpoint.
|
|
29
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getWellknownOpenidConfiguration| Salesforce Developer Center} for more information about the API endpoint.
|
|
30
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#getwellknownopenidconfiguration | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
31
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
32
|
+
*/
|
|
33
|
+
export declare const useWellknownOpenidConfiguration: (apiOptions: NullableParameters<Argument<Client['getWellknownOpenidConfiguration']>>, queryOptions?: ApiQueryOptions<Client['getWellknownOpenidConfiguration']>) => UseQueryResult<DataType<Client['getWellknownOpenidConfiguration']>>;
|
|
34
|
+
/**
|
|
35
|
+
* Returns a JSON Web Key Set (JWKS) containing the current, past, and future public keys. The key set enables clients to validate the Shopper JSON Web Token (JWT) issued by SLAS.
|
|
36
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
37
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
38
|
+
* @returns A TanStack Query query hook with data from the Shopper Login `getJwksUri` endpoint.
|
|
39
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getJwksUri| Salesforce Developer Center} for more information about the API endpoint.
|
|
40
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#getjwksuri | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
41
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
42
|
+
*/
|
|
43
|
+
export declare const useJwksUri: (apiOptions: NullableParameters<Argument<Client['getJwksUri']>>, queryOptions?: ApiQueryOptions<Client['getJwksUri']>) => UseQueryResult<DataType<Client['getJwksUri']>>;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useWellknownOpenidConfiguration = exports.useUserInfo = exports.useJwksUri = exports.useCredQualityUserInfo = void 0;
|
|
7
|
+
var _useCommerceApi = _interopRequireDefault(require("../useCommerceApi"));
|
|
8
|
+
var _useQuery = require("../useQuery");
|
|
9
|
+
var _utils = require("../utils");
|
|
10
|
+
var queryKeyHelpers = _interopRequireWildcard(require("./queryKeyHelpers"));
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
15
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } /*
|
|
16
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
17
|
+
* All rights reserved.
|
|
18
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
19
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Get credential quality statistics for a user.
|
|
23
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
24
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
25
|
+
* @returns A TanStack Query query hook with data from the Shopper Login `retrieveCredQualityUserInfo` endpoint.
|
|
26
|
+
* @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.
|
|
27
|
+
* @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.
|
|
28
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
29
|
+
*/
|
|
30
|
+
const useCredQualityUserInfo = (apiOptions, queryOptions = {}) => {
|
|
31
|
+
const {
|
|
32
|
+
shopperLogin: client
|
|
33
|
+
} = (0, _useCommerceApi.default)();
|
|
34
|
+
const methodName = 'retrieveCredQualityUserInfo';
|
|
35
|
+
const requiredParameters = ['organizationId', 'username'];
|
|
36
|
+
|
|
37
|
+
// Parameters can be set in `apiOptions` or `client.clientConfig`;
|
|
38
|
+
// we must merge them in order to generate the correct query key.
|
|
39
|
+
const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
|
|
40
|
+
const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
|
|
41
|
+
// We don't use `netOptions` here because we manipulate the options in `useQuery`.
|
|
42
|
+
const method = /*#__PURE__*/function () {
|
|
43
|
+
var _ref = _asyncToGenerator(function* (options) {
|
|
44
|
+
return yield client[methodName](options);
|
|
45
|
+
});
|
|
46
|
+
return function method(_x) {
|
|
47
|
+
return _ref.apply(this, arguments);
|
|
48
|
+
};
|
|
49
|
+
}();
|
|
50
|
+
|
|
51
|
+
// For some reason, if we don't explicitly set these generic parameters, the inferred type for
|
|
52
|
+
// `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
|
|
53
|
+
return (0, _useQuery.useQuery)(netOptions, queryOptions, {
|
|
54
|
+
method,
|
|
55
|
+
queryKey,
|
|
56
|
+
requiredParameters
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Returns a JSON listing of claims about the currently authenticated user.
|
|
61
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
62
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
63
|
+
* @returns A TanStack Query query hook with data from the Shopper Login `getUserInfo` endpoint.
|
|
64
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getUserInfo| Salesforce Developer Center} for more information about the API endpoint.
|
|
65
|
+
* @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.
|
|
66
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
67
|
+
*/
|
|
68
|
+
exports.useCredQualityUserInfo = useCredQualityUserInfo;
|
|
69
|
+
const useUserInfo = (apiOptions, queryOptions = {}) => {
|
|
70
|
+
const {
|
|
71
|
+
shopperLogin: client
|
|
72
|
+
} = (0, _useCommerceApi.default)();
|
|
73
|
+
const methodName = 'getUserInfo';
|
|
74
|
+
const requiredParameters = ['organizationId'];
|
|
75
|
+
|
|
76
|
+
// Parameters can be set in `apiOptions` or `client.clientConfig`;
|
|
77
|
+
// we must merge them in order to generate the correct query key.
|
|
78
|
+
const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
|
|
79
|
+
const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
|
|
80
|
+
// We don't use `netOptions` here because we manipulate the options in `useQuery`.
|
|
81
|
+
const method = /*#__PURE__*/function () {
|
|
82
|
+
var _ref2 = _asyncToGenerator(function* (options) {
|
|
83
|
+
return yield client[methodName](options);
|
|
84
|
+
});
|
|
85
|
+
return function method(_x2) {
|
|
86
|
+
return _ref2.apply(this, arguments);
|
|
87
|
+
};
|
|
88
|
+
}();
|
|
89
|
+
|
|
90
|
+
// For some reason, if we don't explicitly set these generic parameters, the inferred type for
|
|
91
|
+
// `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
|
|
92
|
+
return (0, _useQuery.useQuery)(netOptions, queryOptions, {
|
|
93
|
+
method,
|
|
94
|
+
queryKey,
|
|
95
|
+
requiredParameters
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Returns a JSON listing of the OpenID/OAuth endpoints, supported scopes and claims, public keys used to sign the tokens, and other details.
|
|
100
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
101
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
102
|
+
* @returns A TanStack Query query hook with data from the Shopper Login `getWellknownOpenidConfiguration` endpoint.
|
|
103
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getWellknownOpenidConfiguration| Salesforce Developer Center} for more information about the API endpoint.
|
|
104
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#getwellknownopenidconfiguration | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
105
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
106
|
+
*/
|
|
107
|
+
exports.useUserInfo = useUserInfo;
|
|
108
|
+
const useWellknownOpenidConfiguration = (apiOptions, queryOptions = {}) => {
|
|
109
|
+
const {
|
|
110
|
+
shopperLogin: client
|
|
111
|
+
} = (0, _useCommerceApi.default)();
|
|
112
|
+
const methodName = 'getWellknownOpenidConfiguration';
|
|
113
|
+
const requiredParameters = ['organizationId'];
|
|
114
|
+
|
|
115
|
+
// Parameters can be set in `apiOptions` or `client.clientConfig`;
|
|
116
|
+
// we must merge them in order to generate the correct query key.
|
|
117
|
+
const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
|
|
118
|
+
const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
|
|
119
|
+
// We don't use `netOptions` here because we manipulate the options in `useQuery`.
|
|
120
|
+
const method = /*#__PURE__*/function () {
|
|
121
|
+
var _ref3 = _asyncToGenerator(function* (options) {
|
|
122
|
+
return yield client[methodName](options);
|
|
123
|
+
});
|
|
124
|
+
return function method(_x3) {
|
|
125
|
+
return _ref3.apply(this, arguments);
|
|
126
|
+
};
|
|
127
|
+
}();
|
|
128
|
+
|
|
129
|
+
// For some reason, if we don't explicitly set these generic parameters, the inferred type for
|
|
130
|
+
// `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
|
|
131
|
+
return (0, _useQuery.useQuery)(netOptions, queryOptions, {
|
|
132
|
+
method,
|
|
133
|
+
queryKey,
|
|
134
|
+
requiredParameters
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Returns a JSON Web Key Set (JWKS) containing the current, past, and future public keys. The key set enables clients to validate the Shopper JSON Web Token (JWT) issued by SLAS.
|
|
139
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
140
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
141
|
+
* @returns A TanStack Query query hook with data from the Shopper Login `getJwksUri` endpoint.
|
|
142
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-login?meta=getJwksUri| Salesforce Developer Center} for more information about the API endpoint.
|
|
143
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperlogin.shopperlogin-1.html#getjwksuri | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
144
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
145
|
+
*/
|
|
146
|
+
exports.useWellknownOpenidConfiguration = useWellknownOpenidConfiguration;
|
|
147
|
+
const useJwksUri = (apiOptions, queryOptions = {}) => {
|
|
148
|
+
const {
|
|
149
|
+
shopperLogin: client
|
|
150
|
+
} = (0, _useCommerceApi.default)();
|
|
151
|
+
const methodName = 'getJwksUri';
|
|
152
|
+
const requiredParameters = ['organizationId'];
|
|
153
|
+
|
|
154
|
+
// Parameters can be set in `apiOptions` or `client.clientConfig`;
|
|
155
|
+
// we must merge them in order to generate the correct query key.
|
|
156
|
+
const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
|
|
157
|
+
const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
|
|
158
|
+
// We don't use `netOptions` here because we manipulate the options in `useQuery`.
|
|
159
|
+
const method = /*#__PURE__*/function () {
|
|
160
|
+
var _ref4 = _asyncToGenerator(function* (options) {
|
|
161
|
+
return yield client[methodName](options);
|
|
162
|
+
});
|
|
163
|
+
return function method(_x4) {
|
|
164
|
+
return _ref4.apply(this, arguments);
|
|
165
|
+
};
|
|
166
|
+
}();
|
|
167
|
+
|
|
168
|
+
// For some reason, if we don't explicitly set these generic parameters, the inferred type for
|
|
169
|
+
// `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
|
|
170
|
+
return (0, _useQuery.useQuery)(netOptions, queryOptions, {
|
|
171
|
+
method,
|
|
172
|
+
queryKey,
|
|
173
|
+
requiredParameters
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
exports.useJwksUri = useJwksUri;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ShopperLogin } from 'commerce-sdk-isomorphic';
|
|
2
|
+
import { Argument, ExcludeTail } from '../types';
|
|
3
|
+
declare type Client = ShopperLogin<{
|
|
4
|
+
shortCode: string;
|
|
5
|
+
}>;
|
|
6
|
+
declare type Params<T extends keyof QueryKeys> = Partial<Argument<Client[T]>['parameters']>;
|
|
7
|
+
export declare type QueryKeys = {
|
|
8
|
+
retrieveCredQualityUserInfo: [
|
|
9
|
+
'/commerce-sdk-react',
|
|
10
|
+
'/organizations/',
|
|
11
|
+
string | undefined,
|
|
12
|
+
'/cred-qual/user',
|
|
13
|
+
Params<'retrieveCredQualityUserInfo'>
|
|
14
|
+
];
|
|
15
|
+
getUserInfo: [
|
|
16
|
+
'/commerce-sdk-react',
|
|
17
|
+
'/organizations/',
|
|
18
|
+
string | undefined,
|
|
19
|
+
'/oauth2/userinfo',
|
|
20
|
+
Params<'getUserInfo'>
|
|
21
|
+
];
|
|
22
|
+
getWellknownOpenidConfiguration: [
|
|
23
|
+
'/commerce-sdk-react',
|
|
24
|
+
'/organizations/',
|
|
25
|
+
string | undefined,
|
|
26
|
+
'/oauth2/.well-known/openid-configuration',
|
|
27
|
+
Params<'getWellknownOpenidConfiguration'>
|
|
28
|
+
];
|
|
29
|
+
getJwksUri: [
|
|
30
|
+
'/commerce-sdk-react',
|
|
31
|
+
'/organizations/',
|
|
32
|
+
string | undefined,
|
|
33
|
+
'/oauth2/jwks',
|
|
34
|
+
Params<'getJwksUri'>
|
|
35
|
+
];
|
|
36
|
+
};
|
|
37
|
+
declare type QueryKeyHelper<T extends keyof QueryKeys> = {
|
|
38
|
+
/**
|
|
39
|
+
* Reduces the given parameters (which may have additional, unknown properties) to an object
|
|
40
|
+
* containing *only* the properties required for an endpoint.
|
|
41
|
+
*/
|
|
42
|
+
parameters: (params: Params<T>) => Params<T>;
|
|
43
|
+
/** Generates the path component of the query key for an endpoint. */
|
|
44
|
+
path: (params: Params<T>) => ExcludeTail<QueryKeys[T]>;
|
|
45
|
+
/** Generates the full query key for an endpoint. */
|
|
46
|
+
queryKey: (params: Params<T>) => QueryKeys[T];
|
|
47
|
+
};
|
|
48
|
+
export declare const retrieveCredQualityUserInfo: QueryKeyHelper<'retrieveCredQualityUserInfo'>;
|
|
49
|
+
export declare const getUserInfo: QueryKeyHelper<'getUserInfo'>;
|
|
50
|
+
export declare const getWellknownOpenidConfiguration: QueryKeyHelper<'getWellknownOpenidConfiguration'>;
|
|
51
|
+
export declare const getJwksUri: QueryKeyHelper<'getJwksUri'>;
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=queryKeyHelpers.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.retrieveCredQualityUserInfo = exports.getWellknownOpenidConfiguration = exports.getUserInfo = exports.getJwksUri = void 0;
|
|
7
|
+
var _utils = require("../utils");
|
|
8
|
+
/*
|
|
9
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
10
|
+
* All rights reserved.
|
|
11
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
12
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// We must use a client with no parameters in order to have required/optional match the API spec
|
|
16
|
+
|
|
17
|
+
// This is defined here, rather than `types.ts`, because it relies on `Client` and `QueryKeys`,
|
|
18
|
+
// and making those generic would add too much complexity.
|
|
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
|
+
const getUserInfo = {
|
|
27
|
+
parameters: params => (0, _utils.pick)(params, ['organizationId', 'channel_id']),
|
|
28
|
+
path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/oauth2/userinfo'],
|
|
29
|
+
queryKey: params => [...getUserInfo.path(params), getUserInfo.parameters(params)]
|
|
30
|
+
};
|
|
31
|
+
exports.getUserInfo = getUserInfo;
|
|
32
|
+
const getWellknownOpenidConfiguration = {
|
|
33
|
+
parameters: params => (0, _utils.pick)(params, ['organizationId']),
|
|
34
|
+
path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/oauth2/.well-known/openid-configuration'],
|
|
35
|
+
queryKey: params => [...getWellknownOpenidConfiguration.path(params), getWellknownOpenidConfiguration.parameters(params)]
|
|
36
|
+
};
|
|
37
|
+
exports.getWellknownOpenidConfiguration = getWellknownOpenidConfiguration;
|
|
38
|
+
const getJwksUri = {
|
|
39
|
+
parameters: params => (0, _utils.pick)(params, ['organizationId']),
|
|
40
|
+
path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/oauth2/jwks'],
|
|
41
|
+
queryKey: params => [...getJwksUri.path(params), getJwksUri.parameters(params)]
|
|
42
|
+
};
|
|
43
|
+
exports.getJwksUri = getJwksUri;
|