postex-auth-sdk-stage 1.2.5 → 1.3.1

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/README.md CHANGED
@@ -88,7 +88,7 @@ new AuthSDK(config: AuthSDKConfig)
88
88
  | Parameter | Description |
89
89
  |-----------|-------------|
90
90
  | `config.apiKey` | (Optional) Your API key for authentication |
91
- | `config.appId` | (Optional) Selects which Auth environment to use. Allowed values: `'xstak'`, `'postex'`, `'callcourier'`, `'postexglobal'`. Default: `'postexglobal'` |
91
+ | `config.appId` | (Optional) Selects which Auth environment to use. Allowed values: `'xstak'`, `'postex'`, `'callcourier'`, `'postexglobal'`, `'postexsa'`. Default: `'postexglobal'` |
92
92
 
93
93
  ---
94
94
 
@@ -137,6 +137,30 @@ async initiateAuth(
137
137
 
138
138
  ---
139
139
 
140
+ #### initiateOTP()
141
+
142
+ Start OTP authentication directly via `/otp/initiate`.
143
+ Requires at least one identifier: `email` or `mobileNumber`.
144
+
145
+ ```typescript
146
+ async initiateOTP(
147
+ identifier: string | { email?: string; mobileNumber?: string }
148
+ ): Promise<{
149
+ message?: string;
150
+ }>
151
+ ```
152
+
153
+ **Supported input forms:**
154
+ - `auth.initiateOTP({ email: 'user@example.com' })`
155
+ - `auth.initiateOTP({ mobileNumber: '03011266254' })`
156
+ - `auth.initiateOTP({ email: 'user@example.com' })`
157
+
158
+ **Validation:**
159
+
160
+ - Throws an error when both `email` and `mobileNumber` are missing/empty.
161
+
162
+ ---
163
+
140
164
  #### verifyOTP()
141
165
 
142
166
  Verify the OTP code entered by the user. Automatically stores tokens on success.
@@ -716,7 +740,7 @@ import {
716
740
 
717
741
  ## Support and Resources
718
742
 
719
- - **API Documentation:** https://auth-stage.postexglobal.com/docs
743
+ - **API Documentation:** https://auth.postexglobal.com/docs
720
744
  - **GitHub Repository:** (Add your repository link)
721
745
  - **Issue Tracker:** (Add your issue tracker link)
722
746
  - **Email Support:** (Add your support email)
@@ -725,7 +749,7 @@ import {
725
749
 
726
750
  ## API overview
727
751
 
728
- - **AuthSDK** – Main client: `getStatus`, `initiateAuth`, `verifyOTP`, `resendOTP`, `verifySignupOTP`, `resendSignupOTP`, `verifyMagicLink`, `completeMagicLink`, `authenticateWithPasskey`, `registerPasskey`, `getPasskeyStatus`, `removePasskey`, `getRequestAuthHeaders`, `authenticatedFetch`, `refreshToken`, `logout`, `getAccessToken`, `storeTokens`, `clearTokens`
752
+ - **AuthSDK** – Main client: `getStatus`, `initiateAuth`, `initiateOTP`, `verifyOTP`, `resendOTP`, `verifySignupOTP`, `resendSignupOTP`, `verifyMagicLink`, `completeMagicLink`, `authenticateWithPasskey`, `registerPasskey`, `getPasskeyStatus`, `removePasskey`, `getRequestAuthHeaders`, `authenticatedFetch`, `refreshToken`, `logout`, `getAccessToken`, `storeTokens`, `clearTokens`
729
753
  - **WebAuthn** – Helpers: `isWebAuthnSupported`, `isConditionalUISupported`, base64/ArrayBuffer conversion, DPoP key and proof helpers, passkey email/mobile storage (`getPasskeyEmail`, `setPasskeyEmail`, `clearPasskeyEmail`, `getPasskeyMobileNumber`, `setPasskeyMobileNumber`, `clearPasskeyMobileNumber`)
730
754
  - **AuthSDKFetchError** – Error class with `response.status` and `response.data`
731
755
 
package/dist/auth.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- type AuthEntity = "xstak" | "postex" | "callcourier" | "postexglobal";
1
+ type AuthEntity = "xstak" | "postex" | "callcourier" | "postexglobal" | "postexsa";
2
2
  interface AuthSDKConfig {
3
3
  apiKey?: string;
4
4
  appId?: AuthEntity;
@@ -36,6 +36,17 @@ interface OTPVerifyResponse {
36
36
  email: string;
37
37
  [key: string]: any;
38
38
  }
39
+ interface OTPInitiateResponse {
40
+ statusText?: string;
41
+ statusCode?: number;
42
+ success?: boolean;
43
+ message?: string;
44
+ data?: {
45
+ message?: string;
46
+ [key: string]: any;
47
+ };
48
+ [key: string]: any;
49
+ }
39
50
  interface PasskeyRegistrationChallenge {
40
51
  challenge: string;
41
52
  rp: {
@@ -123,6 +134,14 @@ export declare class AuthSDK {
123
134
  email?: string;
124
135
  mobileNumber?: string;
125
136
  }): Promise<InitiateAuthResponse>;
137
+ /**
138
+ * POST /otp/initiate - Direct OTP initiation using email or mobile number.
139
+ * Requires at least one identifier: email or mobileNumber.
140
+ */
141
+ initiateOTP(identifier: string | {
142
+ email?: string;
143
+ mobileNumber?: string;
144
+ }): Promise<OTPInitiateResponse>;
126
145
  /**
127
146
  * POST /otp/verify - Verifies the OTP code entered by the user.
128
147
  * Stores tokens from the response.