postex-auth-sdk-stage 1.4.0 → 2.0.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/dist/auth.d.ts CHANGED
@@ -1,4 +1,12 @@
1
1
  type AuthEntity = "xstak" | "postex" | "callcourier" | "postexglobal" | "postexsa";
2
+ type AuthIdentifierInput = string | {
3
+ email?: string;
4
+ mobileNumber?: string;
5
+ realm?: string;
6
+ };
7
+ interface RealmOptions {
8
+ realm?: string;
9
+ }
2
10
  interface AuthSDKConfig {
3
11
  apiKey?: string;
4
12
  appId?: AuthEntity;
@@ -106,6 +114,8 @@ export declare class AuthSDK {
106
114
  constructor(config: AuthSDKConfig);
107
115
  private getBaseUrl;
108
116
  private normalizeAuthIdentifier;
117
+ private extractRealm;
118
+ private buildAuthRequestBody;
109
119
  private buildUrl;
110
120
  private request;
111
121
  /**
@@ -119,26 +129,17 @@ export declare class AuthSDK {
119
129
  * GET /auth/status - Check if client has trusted device session and what auth method is available.
120
130
  * Returns no_session | session_found | webauthn_ready per PostEx Auth BFF spec.
121
131
  */
122
- getStatus(identifier: string | {
123
- email?: string;
124
- mobileNumber?: string;
125
- }): Promise<AuthStatusResponse>;
132
+ getStatus(identifier: AuthIdentifierInput, options?: RealmOptions): Promise<AuthStatusResponse>;
126
133
  /**
127
134
  * POST /auth/initiate - Unified entry: returns webauthn_challenge or otp_sent.
128
135
  * Sets auth_session cookie when otp_sent.
129
136
  */
130
- initiateAuth(identifier: string | {
131
- email?: string;
132
- mobileNumber?: string;
133
- }): Promise<InitiateAuthResponse>;
137
+ initiateAuth(identifier: AuthIdentifierInput, options?: RealmOptions): Promise<InitiateAuthResponse>;
134
138
  /**
135
139
  * POST /otp/initiate - Direct OTP initiation using email or mobile number.
136
140
  * Requires at least one identifier: email or mobileNumber.
137
141
  */
138
- initiateOTP(identifier: string | {
139
- email?: string;
140
- mobileNumber?: string;
141
- }): Promise<OTPInitiateResponse>;
142
+ initiateOTP(identifier: AuthIdentifierInput, options?: RealmOptions): Promise<OTPInitiateResponse>;
142
143
  /**
143
144
  * POST /otp/verify - Verifies the OTP code entered by the user.
144
145
  * Stores tokens from the response.
@@ -229,7 +230,7 @@ export declare class AuthSDK {
229
230
  * Requires trusted device cookie (td). Refresh token is stored server-side.
230
231
  * Rate limit: 10 requests per minute.
231
232
  */
232
- refreshToken(): Promise<RefreshTokenResponse>;
233
+ refreshToken(options?: RealmOptions): Promise<RefreshTokenResponse>;
233
234
  /**
234
235
  * POST /auth/logout - Logout from the current device.
235
236
  * Revokes the current token and trusted device, then clears local tokens.