import { ISlasClient, TokenResponse } from "./slasClient"; import { CustomQueryParameters, CustomRequestBody } from "../types"; /** * Converts a string into Base64 encoding * @param unencoded - A string to be encoded * @returns Base64 encoded string */ export declare const stringToBase64: (unencoded: string) => string; /** * Parse out the code and usid from a redirect url * @param urlString - A url that contains `code` and `usid` query parameters, typically returned when calling a Shopper Login endpoint * @returns An object containing the code and usid. */ export declare const getCodeAndUsidFromUrl: (urlString: string) => { code: string; usid: string; }; /** * Creates a random string to use as a code verifier. This code is created by the client and sent with both the authorization request (as a code challenge) and the token request. * @returns code verifier */ export declare const createCodeVerifier: () => string; /** * Encodes a code verifier to a code challenge to send to the authorization endpoint * @param codeVerifier - random string to use as a code verifier * @returns code challenge */ export declare const generateCodeChallenge: (codeVerifier: string) => Promise; /** * Wrapper for the authorization endpoint. For federated login (3rd party IDP non-guest), the caller should redirect the user to the url in the url field of the returned object. The url will be the login page for the 3rd party IDP and the user will be sent to the redirectURI on success. Guest sessions return the code and usid directly with no need to redirect. * @param options - an object containing the options for this method * @param options.slasClient - a configured instance of the ShopperLogin SDK client * @param options.codeVerifier - random string created by client app to use as a secret in the request * @param options.parameters - Request parameters used by the `authorizeCustomer` endpoint. * @param options.parameters.redirectURI - the location the client will be returned to after successful login with 3rd party IDP. Must be registered in SLAS. * @param options.parameters.hint? - optional string to hint at a particular IDP. Guest sessions are created by setting this to 'guest' * @param options.parameters.usid? - optional saved SLAS user id to link the new session to a previous session * @returns login url, user id and authorization code if available */ export declare function authorize(options: { slasClient: ISlasClient; codeVerifier: string; parameters: { redirectURI: string; hint?: string; usid?: string; } & CustomQueryParameters; }): Promise<{ code: string; url: string; usid: string; }>; /** * A single function to execute the ShopperLogin Private Client Guest Login as described in the [API documentation](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas-private-client.html). * @param options - an object containing the options for this method * @param options.slasClient - a configured instance of the ShopperLogin SDK client * @param options.credentials - client secret used for authentication * @param options.credentials.clientSecret - secret associated with client ID * @param options.parameters? - parameters to pass in the API calls. Custom parameters can be passed in with the prefix `c_` (e.g. c_myParam), and they be passed on the `authorizeCustomer` endpoint. * @param options.parameters.usid? - optional Unique Shopper Identifier to enable personalization * @returns TokenResponse */ export declare function loginGuestUserPrivate(options: { slasClient: ISlasClient; credentials: { clientSecret: string; }; parameters?: { usid?: string; } & CustomQueryParameters; }): Promise; /** * A single function to execute the ShopperLogin Public Client Guest Login with proof key for code exchange flow as described in the [API documentation](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas-public-client.html). * @param options - an object containing the options for this method * @param options.slasClient - a configured instance of the ShopperLogin SDK client * @param options.parameters - parameters to pass in the API calls. Custom parameters can be passed in with the prefix `c_` (e.g. c_myParam), and they be passed on the `authorizeCustomer` endpoint. * @param options.parameters.redirectURI - Per OAuth standard, a valid app route. Must be listed in your SLAS configuration. On server, this will not be actually called * @param options.parameters.usid? - Unique Shopper Identifier to enable personalization. * @returns TokenResponse */ export declare function loginGuestUser(options: { slasClient: ISlasClient; parameters: { redirectURI: string; usid?: string; } & CustomQueryParameters; }): Promise; /** * A single function to execute the ShopperLogin Private Client Registered User B2C Login as described in the [API documentation](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas-private-client.html). * @param options - an object containing the options for this method * @param options.slasClient - a configured instance of the ShopperLogin SDK client * @param options.credentials - the shopper username and password for login and client secret for additional authentication * @param options.credentials.username - the id of the user to login with * @param options.credentials.password - the password of the user to login with * @param options.credentials.clientSecret - secret associated with client ID * @param options.parameters - parameters to pass in the API calls. * @param options.parameters.redirectURI - Per OAuth standard, a valid app route. Must be listed in your SLAS configuration. On server, this will not be actually called * @param options.parameters.usid? - optional Unique Shopper Identifier to enable personalization * @param options.body? - optional body to pass in the ShopperLogin authenticateCustomer method * @returns TokenResponse */ export declare function loginRegisteredUserB2Cprivate(options: { slasClient: ISlasClient; credentials: { username: string; password: string; clientSecret: string; }; parameters: { redirectURI: string; usid?: string; }; body?: CustomRequestBody; }): Promise; /** * A single function to execute the ShopperLogin Private Client Registered User B2C Login with proof key for code exchange flow as described in the [API documentation](https://developer.salesforce.com/docs/commerce/commerce-api/guide/slas-public-client.html). * @param options - an object containing the options for this method * @param options.slasClient - a configured instance of the ShopperLogin SDK client * @param options.credentials - the id and password to login with. * @param options.credentials.username - the id of the user to login with. * @param options.credentials.password - the password of the user to login with. * @param options.parameters - parameters to pass in the API calls. * @param options.parameters.redirectURI - Per OAuth standard, a valid app route. Must be listed in your SLAS configuration. On server, this will not be actually called. On browser, this will be called, but ignored. * @param options.parameters.usid? - Unique Shopper Identifier to enable personalization. * @param options.body? - optional body to pass in the ShopperLogin authenticateCustomer method * @param options.parameters.usid * @param options.body * @returns TokenResponse */ export declare function loginRegisteredUserB2C(options: { slasClient: ISlasClient; credentials: { username: string; password: string; }; parameters: { redirectURI: string; usid?: string; }; body?: CustomRequestBody; }): Promise; /** * Exchange a refresh token for a new access token. * @param options - an object containing the options for this method * @param options.slasClient - a configured instance of the ShopperLogin SDK client * @param options.parameters - parameters to pass in the API calls. * @param options.parameters.refreshToken - a valid refresh token to exchange for a new access token (and refresh token). * @returns TokenResponse */ export declare function refreshAccessToken(options: { slasClient: ISlasClient; parameters: { refreshToken: string; }; }): Promise; /** * Exchange a refresh token for a new access token. * @param options - an object containing the options for this method * @param options.slasClient - a configured instance of the ShopperLogin SDK client * @param options.credentials - client secret used for authentication * @param options.credentials.clientSecret - secret associated with client ID * @param options.parameters - parameters to pass in the API calls. * @param options.parameters.refreshToken - a valid refresh token to exchange for a new access token (and refresh token). * @returns TokenResponse */ export declare function refreshAccessTokenPrivate(options: { slasClient: ISlasClient; credentials: { clientSecret: string; }; parameters: { refreshToken: string; }; }): Promise; /** * Logout a shopper. The shoppers access token and refresh token will be revoked and if the shopper authenticated with ECOM the OCAPI JWT will also be revoked. * @param options - an object containing the options for this method * @param options.slasClient - a configured instance of the ShopperLogin SDK client * @param options.parameters - parameters to pass in the API calls. * @param options.parameters.accessToken - a valid access token to exchange for a new access token (and refresh token). * @param options.parameters.refreshToken - a valid refresh token to exchange for a new access token (and refresh token). * @returns TokenResponse */ export declare function logout(options: { slasClient: ISlasClient; parameters: { accessToken: string; refreshToken: string; }; }): Promise;