@selldone/sdk-storefront
Version:
A TypeScript SDK to connect to your shop and build a fully functional storefront and website by simply developing a frontend web application. All backend operations are seamlessly managed by the serverless Selldone solution.
70 lines • 3.76 kB
JavaScript
/*
* Copyright (c) 2023-2024. Selldone® Business OS™
*
* Author: M.Pajuhaan
* Web: https://selldone.com
* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
*
* All rights reserved. In the weave of time, where traditions and innovations intermingle, this content was crafted.
* From the essence of thought, through the corridors of creativity, each word, and sentiment has been molded.
* Not just to exist, but to inspire. Like an artist's stroke or a sculptor's chisel, every nuance is deliberate.
* Our journey is not just about reaching a destination, but about creating a masterpiece.
* Tread carefully, for you're treading on dreams.
*/
import { Customer } from "@selldone/core-js/models";
/**
* Verifies the OTP (One-Time Password) received by the user.
*
* This method sends the user's OTP to the specified endpoint for verification. It's typically
* used to confirm the user's phone number in processes like two-factor authentication or
* phone number verification.
*
* @param {string | number} dial_code - The dial code of the country/region (e.g., +1 for the US).
* @param {string} country_code - The ISO code of the country (e.g., 'US' for the United States).
* @param {string | number} phone - The phone number for which the OTP was requested.
* @param {string | number} verification_code - The OTP received by the user.
* @param {Customer.Source} source - The origin of the OTP request, either 'customer' or 'vendor'.
*
* @returns {Promise<ISMSVerifyOTPServerResponse>} - Returns a promise that resolves with the
* server's response to the OTP verification.
*
* @example
*
* verifyOTP('+1', 'US', '1234567890', '123456', Customer.Source.CUSTOMER)
* .then(response => console.log(response))
* .catch(error => console.error(error));
*
*/
export default function XapiAuthSMSVerifyOtp(dial_code, country_code, phone, verification_code, source) {
const params = {
dial_code: dial_code,
country_code: country_code,
phone: phone,
verification_code: verification_code,
source: source ? source : Customer.Source.CUSTOMER,
};
const url = window.XAPI.SHOP_LOGIN_VERIFY(this.shop_name);
return this.postNow(url, params);
}
//█████████████████████████████████████████████████████████████
//―――――――――――――――― 🦫 Types ――――――――――――――――
//█████████████████████████████████████████████████████████████
export var XapiAuthSMSVerifyOtpTypes;
(function (XapiAuthSMSVerifyOtpTypes) {
/**
* Enum representing the possible methods of OTP (One-Time Password) verification success.
*
* The methods include:
* - `REGISTER`: A new user has been registered. The next step typically requires the user to enter their email.
* - `SELECT`: There are multiple users with the same phone number, and the user needs to select one.
* - `LOGIN`: The user is authenticated, and an access token is returned.
*
*/
let Method;
(function (Method) {
Method["REGISTER"] = "register";
Method["SELECT"] = "select";
Method["LOGIN"] = "login";
})(Method = XapiAuthSMSVerifyOtpTypes.Method || (XapiAuthSMSVerifyOtpTypes.Method = {}));
})(XapiAuthSMSVerifyOtpTypes || (XapiAuthSMSVerifyOtpTypes = {}));
//# sourceMappingURL=XapiAuthSMSVerifyOtp.js.map