postex-auth-sdk-stage 1.2.4 → 1.3.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/README.md +31 -3
- package/dist/auth.d.ts +20 -1
- package/dist/postex-auth-sdk-stage.es.js +168 -150
- package/dist/postex-auth-sdk-stage.es.js.map +1 -1
- package/dist/postex-auth-sdk-stage.iife.js +1 -1
- package/dist/postex-auth-sdk-stage.iife.js.map +1 -1
- package/dist/postex-auth-sdk-stage.umd.js +1 -1
- package/dist/postex-auth-sdk-stage.umd.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,7 +40,10 @@ npm install postex-auth-sdk-stage
|
|
|
40
40
|
```javascript
|
|
41
41
|
import { AuthSDK } from 'postex-auth-sdk-stage';
|
|
42
42
|
|
|
43
|
-
const auth = new AuthSDK({
|
|
43
|
+
const auth = new AuthSDK({
|
|
44
|
+
apiKey: 'your-api-key',
|
|
45
|
+
appId: 'postexglobal'
|
|
46
|
+
});
|
|
44
47
|
```
|
|
45
48
|
|
|
46
49
|
### Basic Authentication Flow
|
|
@@ -85,6 +88,7 @@ new AuthSDK(config: AuthSDKConfig)
|
|
|
85
88
|
| Parameter | Description |
|
|
86
89
|
|-----------|-------------|
|
|
87
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'` |
|
|
88
92
|
|
|
89
93
|
---
|
|
90
94
|
|
|
@@ -133,6 +137,30 @@ async initiateAuth(
|
|
|
133
137
|
|
|
134
138
|
---
|
|
135
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
|
+
|
|
136
164
|
#### verifyOTP()
|
|
137
165
|
|
|
138
166
|
Verify the OTP code entered by the user. Automatically stores tokens on success.
|
|
@@ -712,7 +740,7 @@ import {
|
|
|
712
740
|
|
|
713
741
|
## Support and Resources
|
|
714
742
|
|
|
715
|
-
- **API Documentation:** https://auth
|
|
743
|
+
- **API Documentation:** https://auth.postexglobal.com/docs
|
|
716
744
|
- **GitHub Repository:** (Add your repository link)
|
|
717
745
|
- **Issue Tracker:** (Add your issue tracker link)
|
|
718
746
|
- **Email Support:** (Add your support email)
|
|
@@ -721,7 +749,7 @@ import {
|
|
|
721
749
|
|
|
722
750
|
## API overview
|
|
723
751
|
|
|
724
|
-
- **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`
|
|
725
753
|
- **WebAuthn** – Helpers: `isWebAuthnSupported`, `isConditionalUISupported`, base64/ArrayBuffer conversion, DPoP key and proof helpers, passkey email/mobile storage (`getPasskeyEmail`, `setPasskeyEmail`, `clearPasskeyEmail`, `getPasskeyMobileNumber`, `setPasskeyMobileNumber`, `clearPasskeyMobileNumber`)
|
|
726
754
|
- **AuthSDKFetchError** – Error class with `response.status` and `response.data`
|
|
727
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.
|