@ollaid/native-sso 1.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/README.md +1682 -0
- package/dist/components/AppsLogoSlider.d.ts +9 -0
- package/dist/components/DebugPanel.d.ts +12 -0
- package/dist/components/LoginModal.d.ts +20 -0
- package/dist/components/NativeSSOPage.d.ts +35 -0
- package/dist/components/OTPInput.d.ts +13 -0
- package/dist/components/OnboardingModal.d.ts +23 -0
- package/dist/components/PasswordRecoveryModal.d.ts +17 -0
- package/dist/components/PhoneInput.d.ts +15 -0
- package/dist/components/SignupModal.d.ts +18 -0
- package/dist/components/ui.d.ts +70 -0
- package/dist/hooks/useMobilePassword.d.ts +94 -0
- package/dist/hooks/useMobileRegistration.d.ts +148 -0
- package/dist/hooks/useNativeAuth.d.ts +262 -0
- package/dist/hooks/useTokenHealthCheck.d.ts +25 -0
- package/dist/index.cjs +4493 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +4493 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +38 -0
- package/dist/services/api.d.ts +49 -0
- package/dist/services/debugLogger.d.ts +23 -0
- package/dist/services/iamAccount.d.ts +45 -0
- package/dist/services/mobilePassword.d.ts +19 -0
- package/dist/services/mobileRegistration.d.ts +31 -0
- package/dist/services/nativeAuth.d.ts +55 -0
- package/dist/types/mobile.d.ts +128 -0
- package/dist/types/native.d.ts +289 -0
- package/package.json +50 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NativeSSOProvider — React Context pour @ollaid/native-sso
|
|
3
|
+
* Centralise la configuration pour les hooks et composants individuels
|
|
4
|
+
*
|
|
5
|
+
* @version 1.0.0
|
|
6
|
+
*/
|
|
7
|
+
import { type ReactNode } from 'react';
|
|
8
|
+
export interface NativeSSOConfig {
|
|
9
|
+
/** URL du Backend SaaS (ex: https://mon-saas.com/api) */
|
|
10
|
+
saasApiUrl: string;
|
|
11
|
+
/** URL du Backend IAM (ex: https://identityam.ollaid.com/api) */
|
|
12
|
+
iamApiUrl: string;
|
|
13
|
+
/** Timeout en ms (défaut: 30000) */
|
|
14
|
+
timeout?: number;
|
|
15
|
+
/** Mode debug (logs console) */
|
|
16
|
+
debug?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface NativeSSOProviderProps {
|
|
19
|
+
config: NativeSSOConfig;
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Provider React pour centraliser la config SSO.
|
|
24
|
+
*
|
|
25
|
+
* Usage :
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <NativeSSOProvider config={{ saasApiUrl: '...', iamApiUrl: '...' }}>
|
|
28
|
+
* <App />
|
|
29
|
+
* </NativeSSOProvider>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function NativeSSOProvider({ config, children }: NativeSSOProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
/**
|
|
34
|
+
* Hook pour accéder à la config SSO depuis le Provider.
|
|
35
|
+
* Optionnel : les hooks acceptent aussi la config en paramètre.
|
|
36
|
+
*/
|
|
37
|
+
export declare function useNativeSSOConfig(): NativeSSOConfig;
|
|
38
|
+
export default NativeSSOProvider;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client API pour @ollaid/native-sso
|
|
3
|
+
* Gestion des requêtes HTTP avec timeout, device ID, token storage
|
|
4
|
+
*
|
|
5
|
+
* @version 1.0.0
|
|
6
|
+
*/
|
|
7
|
+
export type ApiErrorType = 'network' | 'timeout' | 'server' | 'validation' | 'auth' | 'unknown';
|
|
8
|
+
export declare class ApiError extends Error {
|
|
9
|
+
type: ApiErrorType;
|
|
10
|
+
statusCode?: number;
|
|
11
|
+
errorType?: string;
|
|
12
|
+
response?: unknown;
|
|
13
|
+
constructor(message: string, type: ApiErrorType, statusCode?: number, errorType?: string, response?: unknown);
|
|
14
|
+
}
|
|
15
|
+
export interface NativeAuthConfig {
|
|
16
|
+
/** URL du Backend SaaS (pour config et exchange) */
|
|
17
|
+
saasApiUrl: string;
|
|
18
|
+
/** URL du Backend IAM (pour encrypt, init, validate, etc.) */
|
|
19
|
+
iamApiUrl: string;
|
|
20
|
+
/** Timeout en ms (défaut: 30000) */
|
|
21
|
+
timeout?: number;
|
|
22
|
+
/** Mode debug (logs console) */
|
|
23
|
+
debug?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare const setNativeAuthConfig: (newConfig: Partial<NativeAuthConfig>) => void;
|
|
26
|
+
export declare const getNativeAuthConfig: () => NativeAuthConfig;
|
|
27
|
+
export declare const isDebugMode: () => boolean;
|
|
28
|
+
export declare const getDeviceId: () => string;
|
|
29
|
+
declare const STORAGE: {
|
|
30
|
+
readonly AUTH_TOKEN: "auth_token";
|
|
31
|
+
readonly TOKEN: "token";
|
|
32
|
+
readonly USER: "user";
|
|
33
|
+
readonly ACCOUNT_TYPE: "account_type";
|
|
34
|
+
};
|
|
35
|
+
export declare const setAuthToken: (token: string) => void;
|
|
36
|
+
export declare const getAuthToken: () => string | null;
|
|
37
|
+
export declare const clearAuthToken: () => void;
|
|
38
|
+
export declare const setAuthUser: (user: unknown) => void;
|
|
39
|
+
export declare const getAuthUser: <T>() => T | null;
|
|
40
|
+
export declare const setAccountType: (type: string) => void;
|
|
41
|
+
export declare const getAccountType: () => string | null;
|
|
42
|
+
export { STORAGE as STORAGE_KEYS };
|
|
43
|
+
export declare function fetchWithTimeout<T>(url: string, options: RequestInit, timeout: number): Promise<T>;
|
|
44
|
+
export declare function getHeaders(token?: string): HeadersInit;
|
|
45
|
+
declare const _default: {
|
|
46
|
+
getConfig: () => NativeAuthConfig;
|
|
47
|
+
setConfig: (newConfig: Partial<NativeAuthConfig>) => void;
|
|
48
|
+
};
|
|
49
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug Logger pour @ollaid/native-sso
|
|
3
|
+
* Stocke l'historique des appels API en mémoire pour le DebugPanel
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
export interface ApiCallLog {
|
|
7
|
+
id: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
10
|
+
endpoint: string;
|
|
11
|
+
requestBody: unknown;
|
|
12
|
+
requestHeaders?: Record<string, string>;
|
|
13
|
+
responseStatus: number | null;
|
|
14
|
+
responseBody: unknown;
|
|
15
|
+
duration: number;
|
|
16
|
+
error?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function logApiCall(method: ApiCallLog['method'], endpoint: string, requestBody: unknown, requestHeaders?: Record<string, string>): string;
|
|
19
|
+
export declare function logApiResponse(logId: string, responseStatus: number, responseBody: unknown, startTime: number, error?: string): void;
|
|
20
|
+
export declare function getApiLogs(): ApiCallLog[];
|
|
21
|
+
export declare function clearApiLogs(): void;
|
|
22
|
+
export declare function subscribeToLogs(callback: (logs: ApiCallLog[]) => void): () => void;
|
|
23
|
+
export declare function exportLogsAsText(): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service IAM Account — APIs server-to-server
|
|
3
|
+
* link-phone, link-email, refresh-user-info, update-avatar, reset-avatar
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ ATTENTION — SERVER-TO-SERVER UNIQUEMENT
|
|
6
|
+
* Ces APIs utilisent la `secret_key` de votre application IAM.
|
|
7
|
+
* Elles doivent être appelées EXCLUSIVEMENT depuis un backend (Node.js, PHP, etc.).
|
|
8
|
+
* Ne JAMAIS appeler ces méthodes depuis du code frontend/navigateur car la
|
|
9
|
+
* secret_key serait exposée dans les DevTools réseau.
|
|
10
|
+
*
|
|
11
|
+
* @version 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
import type { LinkPhoneRequest, LinkPhoneResponse, LinkEmailRequest, LinkEmailResponse, RefreshUserInfoSingleRequest, RefreshUserInfoSingleResponse, RefreshUserInfoBulkRequest, RefreshUserInfoBulkResponse, UpdateAvatarRequest, UpdateAvatarResponse, ResetAvatarRequest, ResetAvatarResponse } from '../types/native';
|
|
14
|
+
export declare const iamAccountService: {
|
|
15
|
+
/**
|
|
16
|
+
* Lier un numéro de téléphone à un compte utilisateur existant
|
|
17
|
+
* POST {iamApiUrl}/iam/link-phone
|
|
18
|
+
*/
|
|
19
|
+
linkPhone(params: Partial<Pick<LinkPhoneRequest, "app_key" | "secret_key">> & Omit<LinkPhoneRequest, "app_key" | "secret_key">): Promise<LinkPhoneResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Lier une adresse email à un compte utilisateur existant
|
|
22
|
+
* POST {iamApiUrl}/iam/link-email
|
|
23
|
+
*/
|
|
24
|
+
linkEmail(params: Partial<Pick<LinkEmailRequest, "app_key" | "secret_key">> & Omit<LinkEmailRequest, "app_key" | "secret_key">): Promise<LinkEmailResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Récupérer les user_infos d'un utilisateur (mode single)
|
|
27
|
+
* POST {iamApiUrl}/iam/refresh-user-info
|
|
28
|
+
*/
|
|
29
|
+
refreshUserInfo(params: Partial<Pick<RefreshUserInfoSingleRequest, "secret_key">> & Omit<RefreshUserInfoSingleRequest, "secret_key">): Promise<RefreshUserInfoSingleResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* Récupérer les user_infos en bulk (max 100 alias_references)
|
|
32
|
+
* POST {iamApiUrl}/iam/refresh-user-info
|
|
33
|
+
*/
|
|
34
|
+
refreshUserInfoBulk(params: Partial<Pick<RefreshUserInfoBulkRequest, "secret_key">> & Omit<RefreshUserInfoBulkRequest, "secret_key">): Promise<RefreshUserInfoBulkResponse>;
|
|
35
|
+
/**
|
|
36
|
+
* Mettre à jour l'avatar d'un utilisateur pour une application spécifique
|
|
37
|
+
* POST {iamApiUrl}/iam/update-avatar
|
|
38
|
+
*/
|
|
39
|
+
updateAvatar(params: Partial<Pick<UpdateAvatarRequest, "app_key" | "secret_key">> & Omit<UpdateAvatarRequest, "app_key" | "secret_key">): Promise<UpdateAvatarResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Réinitialiser l'avatar d'un utilisateur (remettre à null pour utiliser l'image globale)
|
|
42
|
+
* POST {iamApiUrl}/iam/reset-avatar
|
|
43
|
+
*/
|
|
44
|
+
resetAvatar(params: Partial<Pick<ResetAvatarRequest, "app_key" | "secret_key">> & Omit<ResetAvatarRequest, "app_key" | "secret_key">): Promise<ResetAvatarResponse>;
|
|
45
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service de récupération de mot de passe v1.0
|
|
3
|
+
* Architecture Frontend-First : Appels directs à l'IAM
|
|
4
|
+
*
|
|
5
|
+
* @version 1.0.0
|
|
6
|
+
*/
|
|
7
|
+
import { ApiError } from './api';
|
|
8
|
+
import type { MobilePasswordInitResponse, MobilePasswordSelectMethodResponse, MobilePasswordResetResponse, MobilePasswordResendResponse } from '../types/mobile';
|
|
9
|
+
export declare const mobilePasswordService: {
|
|
10
|
+
hasCredentials(): boolean;
|
|
11
|
+
loadCredentials(): Promise<import("..").NativeCredentials>;
|
|
12
|
+
initRecovery(email: string): Promise<MobilePasswordInitResponse>;
|
|
13
|
+
selectMethod(processToken: string, receiveChoice: "email" | "phone"): Promise<MobilePasswordSelectMethodResponse>;
|
|
14
|
+
validateOtpLocally(inputCode: string, storedCode: string): boolean;
|
|
15
|
+
reset(processToken: string, password: string): Promise<MobilePasswordResetResponse>;
|
|
16
|
+
resendOtp(processToken: string): Promise<MobilePasswordResendResponse>;
|
|
17
|
+
};
|
|
18
|
+
export { ApiError };
|
|
19
|
+
export default mobilePasswordService;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service d'inscription Mobile SSO v1.0
|
|
3
|
+
* Architecture Frontend-First : Appels directs à l'IAM via nativeAuth
|
|
4
|
+
*
|
|
5
|
+
* @version 1.0.0
|
|
6
|
+
*/
|
|
7
|
+
import type { MobileRegistrationFormData, MobileVerifyOtpResponse, MobileRegistrationCompleteResponse, MobileResendOtpResponse } from '../types/mobile';
|
|
8
|
+
import type { NativeInitResponse } from '../types/native';
|
|
9
|
+
export declare const mobileRegistrationService: {
|
|
10
|
+
/**
|
|
11
|
+
* Init registration via nativeAuth.register() (Frontend-First)
|
|
12
|
+
*/
|
|
13
|
+
init(data: Omit<MobileRegistrationFormData, "password" | "password_confirmation">): Promise<NativeInitResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Verify OTP via nativeAuth.validate()
|
|
16
|
+
*/
|
|
17
|
+
verifyOtp(processToken: string, otpCode: string): Promise<MobileVerifyOtpResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Complete registration with password
|
|
20
|
+
*/
|
|
21
|
+
complete(processToken: string, password: string): Promise<MobileRegistrationCompleteResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Complete phone-only registration (no password)
|
|
24
|
+
*/
|
|
25
|
+
completePhoneOnly(processToken: string): Promise<MobileRegistrationCompleteResponse>;
|
|
26
|
+
/**
|
|
27
|
+
* Resend OTP
|
|
28
|
+
*/
|
|
29
|
+
resendOtp(processToken: string): Promise<MobileResendOtpResponse>;
|
|
30
|
+
};
|
|
31
|
+
export default mobileRegistrationService;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service d'authentification Native Mobile SSO v1.0
|
|
3
|
+
* Architecture Frontend-First : Direct IAM après encryption
|
|
4
|
+
*
|
|
5
|
+
* @version 1.0.0
|
|
6
|
+
*/
|
|
7
|
+
import type { NativeAuthType, NativeEncryptRequest, NativeEncryptResponse, NativeInitResponse, NativeValidateResponse, NativeGrantAccessResponse, NativeResendOtpResponse, NativeExchangeResponse, NativeCredentials } from '../types/native';
|
|
8
|
+
export declare const nativeAuthService: {
|
|
9
|
+
hasCredentials(): boolean;
|
|
10
|
+
getCredentials(): NativeCredentials | null;
|
|
11
|
+
loadCredentials(): Promise<NativeCredentials>;
|
|
12
|
+
encrypt(type: NativeAuthType, data: Partial<NativeEncryptRequest>): Promise<NativeEncryptResponse>;
|
|
13
|
+
init(nativeToken: string): Promise<NativeInitResponse>;
|
|
14
|
+
validate(processToken: string, creds: {
|
|
15
|
+
password?: string;
|
|
16
|
+
otp_code?: string;
|
|
17
|
+
}): Promise<NativeValidateResponse>;
|
|
18
|
+
verifyTotp(processToken: string, totpCode: string): Promise<NativeValidateResponse>;
|
|
19
|
+
grantAccess(processToken: string): Promise<NativeGrantAccessResponse>;
|
|
20
|
+
resendOtp(processToken: string): Promise<NativeResendOtpResponse>;
|
|
21
|
+
exchange(callbackToken: string): Promise<NativeExchangeResponse>;
|
|
22
|
+
checkToken(token: string): Promise<{
|
|
23
|
+
valid: boolean;
|
|
24
|
+
user_infos?: import("../types/native").UserInfos;
|
|
25
|
+
}>;
|
|
26
|
+
logout(token?: string): Promise<{
|
|
27
|
+
success: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
clearCredentials(): void;
|
|
30
|
+
loginEmail(email: string, accountType?: "user" | "admin"): Promise<NativeInitResponse>;
|
|
31
|
+
loginPhone(ccphone: string, phone: string, accountType?: "user" | "admin"): Promise<NativeInitResponse>;
|
|
32
|
+
loginAccessOtp(otpCode: string): Promise<NativeInitResponse>;
|
|
33
|
+
register(data: {
|
|
34
|
+
name: string;
|
|
35
|
+
email?: string;
|
|
36
|
+
ccphone: string;
|
|
37
|
+
phone: string;
|
|
38
|
+
town?: string;
|
|
39
|
+
country?: string;
|
|
40
|
+
registration_type?: "email" | "phone";
|
|
41
|
+
}): Promise<NativeInitResponse>;
|
|
42
|
+
registerPhoneOnly(data: {
|
|
43
|
+
name: string;
|
|
44
|
+
ccphone: string;
|
|
45
|
+
phone: string;
|
|
46
|
+
town?: string;
|
|
47
|
+
country?: string;
|
|
48
|
+
}): Promise<NativeInitResponse>;
|
|
49
|
+
recoverPassword(method: "email" | "phone", identifier: {
|
|
50
|
+
email?: string;
|
|
51
|
+
ccphone?: string;
|
|
52
|
+
phone?: string;
|
|
53
|
+
}): Promise<NativeInitResponse>;
|
|
54
|
+
};
|
|
55
|
+
export default nativeAuthService;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types pour le password recovery et registration Mobile SSO v1.0
|
|
3
|
+
*
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
export type MobilePasswordStatus = 'idle' | 'choice_required' | 'pending_otp' | 'pending_password' | 'completed';
|
|
7
|
+
export interface MobilePasswordState {
|
|
8
|
+
processToken: string | null;
|
|
9
|
+
status: MobilePasswordStatus;
|
|
10
|
+
storedOtp: string | null;
|
|
11
|
+
receiveMode: 'email' | 'phone' | null;
|
|
12
|
+
maskedEmail: string | null;
|
|
13
|
+
maskedPhone: string | null;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
error: string | null;
|
|
16
|
+
errorType: string | null;
|
|
17
|
+
credentialsLoaded: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface MobilePasswordInitResponse {
|
|
20
|
+
success: boolean;
|
|
21
|
+
message?: string;
|
|
22
|
+
error_type?: 'email_not_found' | 'phone_not_found' | 'validation_error' | string;
|
|
23
|
+
process_token?: string;
|
|
24
|
+
status?: string;
|
|
25
|
+
expires_at?: string;
|
|
26
|
+
otp_code?: string;
|
|
27
|
+
receive_mode?: 'email' | 'phone';
|
|
28
|
+
masked_email?: string;
|
|
29
|
+
masked_phone?: string;
|
|
30
|
+
has_phone?: boolean;
|
|
31
|
+
otp_code_dev?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface MobilePasswordSelectMethodResponse {
|
|
34
|
+
success: boolean;
|
|
35
|
+
message?: string;
|
|
36
|
+
error_type?: 'invalid_token' | 'validation_error' | string;
|
|
37
|
+
process_token?: string;
|
|
38
|
+
status?: 'pending_otp';
|
|
39
|
+
otp_code?: string;
|
|
40
|
+
receive_mode?: 'email' | 'phone';
|
|
41
|
+
masked_contact?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface MobilePasswordResetResponse {
|
|
44
|
+
success: boolean;
|
|
45
|
+
message?: string;
|
|
46
|
+
error_type?: 'weak_password' | 'token_expired' | 'invalid_token' | string;
|
|
47
|
+
status?: 'completed';
|
|
48
|
+
}
|
|
49
|
+
export interface MobilePasswordResendResponse {
|
|
50
|
+
success: boolean;
|
|
51
|
+
message?: string;
|
|
52
|
+
error_type?: 'cooldown_active' | 'session_expired' | string;
|
|
53
|
+
otp_code?: string;
|
|
54
|
+
receive_mode?: 'email' | 'phone';
|
|
55
|
+
cooldown_remaining?: number;
|
|
56
|
+
}
|
|
57
|
+
export type AccountType = 'email' | 'phone-only';
|
|
58
|
+
export interface MobileRegistrationFormData {
|
|
59
|
+
name: string;
|
|
60
|
+
email: string;
|
|
61
|
+
ccphone: string;
|
|
62
|
+
phone: string;
|
|
63
|
+
address?: string;
|
|
64
|
+
town?: string;
|
|
65
|
+
country?: string;
|
|
66
|
+
password: string;
|
|
67
|
+
password_confirmation: string;
|
|
68
|
+
registration_type?: 'email' | 'phone';
|
|
69
|
+
}
|
|
70
|
+
export interface MobileRegistrationInitResponse {
|
|
71
|
+
success: boolean;
|
|
72
|
+
message?: string;
|
|
73
|
+
error_type?: 'email_exists' | 'phone_exists' | 'validation_error' | string;
|
|
74
|
+
process_token?: string;
|
|
75
|
+
status?: string;
|
|
76
|
+
expires_at?: string;
|
|
77
|
+
otp_code_dev?: string;
|
|
78
|
+
otp_method?: 'email' | 'sms';
|
|
79
|
+
otp_sent_to?: string;
|
|
80
|
+
conflict?: {
|
|
81
|
+
type: 'email' | 'phone';
|
|
82
|
+
masked_identifier: string;
|
|
83
|
+
options: {
|
|
84
|
+
can_login: boolean;
|
|
85
|
+
can_recover_by_email: boolean;
|
|
86
|
+
can_recover_by_sms: boolean;
|
|
87
|
+
masked_email?: string;
|
|
88
|
+
masked_phone?: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export interface MobileVerifyOtpResponse {
|
|
93
|
+
success: boolean;
|
|
94
|
+
message?: string;
|
|
95
|
+
error_type?: 'invalid_otp' | 'otp_expired' | 'max_attempts_exceeded' | string;
|
|
96
|
+
status?: string;
|
|
97
|
+
callback_token?: string;
|
|
98
|
+
expires_at?: string;
|
|
99
|
+
recovery_token?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface MobileRegistrationCompleteResponse {
|
|
102
|
+
success: boolean;
|
|
103
|
+
message?: string;
|
|
104
|
+
error_type?: 'weak_password' | 'session_expired' | string;
|
|
105
|
+
callback_token?: string;
|
|
106
|
+
status?: 'completed';
|
|
107
|
+
}
|
|
108
|
+
export interface MobileResendOtpResponse {
|
|
109
|
+
success: boolean;
|
|
110
|
+
message?: string;
|
|
111
|
+
error_type?: 'cooldown_active' | 'session_expired' | string;
|
|
112
|
+
otp_code?: string;
|
|
113
|
+
cooldown_remaining?: number;
|
|
114
|
+
otp_code_dev?: string;
|
|
115
|
+
}
|
|
116
|
+
export interface MobileAuthFinalResponse {
|
|
117
|
+
success: boolean;
|
|
118
|
+
message?: string;
|
|
119
|
+
token: string;
|
|
120
|
+
expires_at: string;
|
|
121
|
+
user: {
|
|
122
|
+
reference: string;
|
|
123
|
+
name: string;
|
|
124
|
+
email?: string;
|
|
125
|
+
phone?: string;
|
|
126
|
+
image_url?: string;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types pour l'authentification Native SSO v1.0
|
|
3
|
+
* Architecture Frontend-First avec encryption directe
|
|
4
|
+
*
|
|
5
|
+
* @version 1.0.0
|
|
6
|
+
*/
|
|
7
|
+
export type NativeAuthType = 'login_email' | 'login_phone' | 'login_access_otp' | 'register' | 'recovery_password';
|
|
8
|
+
export type AccountType = 'email' | 'phone-only';
|
|
9
|
+
export type RegistrationType = 'email' | 'phone';
|
|
10
|
+
export type NativeAuthStatus = 'pending_password' | 'pending_otp' | 'pending_registration' | 'pending_2fa' | 'needs_access' | 'completed' | 'expired' | 'failed';
|
|
11
|
+
export interface NativeCredentials {
|
|
12
|
+
appKey: string;
|
|
13
|
+
encryptedCredentials: string;
|
|
14
|
+
}
|
|
15
|
+
export interface NativeEncryptRequest {
|
|
16
|
+
type: NativeAuthType;
|
|
17
|
+
app_key: string;
|
|
18
|
+
encrypted_credentials: string;
|
|
19
|
+
email?: string;
|
|
20
|
+
ccphone?: string;
|
|
21
|
+
phone?: string;
|
|
22
|
+
otp_code?: string;
|
|
23
|
+
account_type?: 'user' | 'admin';
|
|
24
|
+
name?: string;
|
|
25
|
+
town?: string;
|
|
26
|
+
country?: string;
|
|
27
|
+
registration_type?: RegistrationType;
|
|
28
|
+
method?: 'email' | 'phone';
|
|
29
|
+
}
|
|
30
|
+
export interface NativeConfigResponse {
|
|
31
|
+
success: boolean;
|
|
32
|
+
app_key: string;
|
|
33
|
+
encrypted_credentials: string;
|
|
34
|
+
debug?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface NativeEncryptResponse {
|
|
37
|
+
success: boolean;
|
|
38
|
+
native_token: string;
|
|
39
|
+
expires_in: number;
|
|
40
|
+
message?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface NativeInitResponse {
|
|
43
|
+
success: boolean;
|
|
44
|
+
message?: string;
|
|
45
|
+
error_type?: 'email_not_found' | 'phone_not_found' | 'alias_disabled' | 'access_denied' | 'user_suspended' | 'invalid_token' | 'token_expired' | 'validation_error' | 'invalid_country_code' | string;
|
|
46
|
+
process_token?: string;
|
|
47
|
+
status?: NativeAuthStatus;
|
|
48
|
+
expires_at?: string;
|
|
49
|
+
needs_access?: boolean;
|
|
50
|
+
callback_token?: string;
|
|
51
|
+
otp_sent_to?: string;
|
|
52
|
+
otp_expires_in?: number;
|
|
53
|
+
otp_code_dev?: string;
|
|
54
|
+
otp_method?: 'email' | 'sms';
|
|
55
|
+
disabled_type?: 'email' | 'phone';
|
|
56
|
+
alternative_method?: 'email' | 'phone' | null;
|
|
57
|
+
alternative_email?: string;
|
|
58
|
+
alternative_phone?: string;
|
|
59
|
+
application?: {
|
|
60
|
+
id: number;
|
|
61
|
+
name: string;
|
|
62
|
+
logo?: string;
|
|
63
|
+
};
|
|
64
|
+
user?: {
|
|
65
|
+
id: number;
|
|
66
|
+
name: string;
|
|
67
|
+
email?: string;
|
|
68
|
+
image_url?: string;
|
|
69
|
+
};
|
|
70
|
+
prompt?: {
|
|
71
|
+
title: string;
|
|
72
|
+
message: string;
|
|
73
|
+
actions: ('grant_access' | 'cancel')[];
|
|
74
|
+
};
|
|
75
|
+
conflict?: {
|
|
76
|
+
type: 'email' | 'phone';
|
|
77
|
+
masked_identifier: string;
|
|
78
|
+
options: {
|
|
79
|
+
can_login: boolean;
|
|
80
|
+
can_recover_by_email: boolean;
|
|
81
|
+
can_recover_by_sms: boolean;
|
|
82
|
+
masked_email?: string;
|
|
83
|
+
masked_phone?: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export interface NativeValidateResponse {
|
|
88
|
+
success: boolean;
|
|
89
|
+
message?: string;
|
|
90
|
+
error_type?: 'invalid_password' | 'invalid_otp' | 'otp_expired' | 'max_attempts_exceeded' | 'session_expired' | 'invalid_token' | 'requires_2fa' | string;
|
|
91
|
+
callback_token?: string;
|
|
92
|
+
requires_2fa?: boolean;
|
|
93
|
+
status?: NativeAuthStatus;
|
|
94
|
+
needs_access?: boolean;
|
|
95
|
+
process_token?: string;
|
|
96
|
+
application?: {
|
|
97
|
+
id: number;
|
|
98
|
+
name: string;
|
|
99
|
+
logo?: string;
|
|
100
|
+
};
|
|
101
|
+
user?: {
|
|
102
|
+
id: number;
|
|
103
|
+
name: string;
|
|
104
|
+
email?: string;
|
|
105
|
+
image_url?: string;
|
|
106
|
+
};
|
|
107
|
+
prompt?: {
|
|
108
|
+
title: string;
|
|
109
|
+
message: string;
|
|
110
|
+
actions: string[];
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export interface NativeGrantAccessResponse {
|
|
114
|
+
success: boolean;
|
|
115
|
+
message?: string;
|
|
116
|
+
error_type?: 'invalid_token' | 'access_exists' | string;
|
|
117
|
+
callback_token?: string;
|
|
118
|
+
status?: 'completed';
|
|
119
|
+
}
|
|
120
|
+
export interface NativeResendOtpResponse {
|
|
121
|
+
success: boolean;
|
|
122
|
+
message?: string;
|
|
123
|
+
error_type?: 'cooldown_active' | 'session_expired' | string;
|
|
124
|
+
cooldown_remaining?: number;
|
|
125
|
+
otp_sent_to?: string;
|
|
126
|
+
otp_expires_in?: number;
|
|
127
|
+
otp_code_dev?: string;
|
|
128
|
+
}
|
|
129
|
+
export interface NativeUser {
|
|
130
|
+
id?: number;
|
|
131
|
+
reference: string;
|
|
132
|
+
name: string;
|
|
133
|
+
email?: string | null;
|
|
134
|
+
phone?: string;
|
|
135
|
+
ccphone?: string;
|
|
136
|
+
image_url?: string;
|
|
137
|
+
account_type?: 'user' | 'client';
|
|
138
|
+
town?: string;
|
|
139
|
+
country?: string;
|
|
140
|
+
address?: string;
|
|
141
|
+
auth_2fa?: boolean;
|
|
142
|
+
}
|
|
143
|
+
export interface NativeExchangeResponse {
|
|
144
|
+
success: boolean;
|
|
145
|
+
message?: string;
|
|
146
|
+
error_type?: string;
|
|
147
|
+
debug_error?: string;
|
|
148
|
+
debug_file?: string;
|
|
149
|
+
token: string;
|
|
150
|
+
auth_token?: string;
|
|
151
|
+
expires_at: string;
|
|
152
|
+
user: NativeUser;
|
|
153
|
+
user_infos?: UserInfos;
|
|
154
|
+
}
|
|
155
|
+
export interface CheckTokenResponse {
|
|
156
|
+
success: boolean;
|
|
157
|
+
valid: boolean;
|
|
158
|
+
user_infos?: UserInfos;
|
|
159
|
+
}
|
|
160
|
+
export interface NativeAuthState {
|
|
161
|
+
credentialsLoaded: boolean;
|
|
162
|
+
processToken: string | null;
|
|
163
|
+
status: NativeAuthStatus | null;
|
|
164
|
+
user: NativeUser | null;
|
|
165
|
+
application: {
|
|
166
|
+
id: number;
|
|
167
|
+
name: string;
|
|
168
|
+
logo?: string;
|
|
169
|
+
} | null;
|
|
170
|
+
prompt: {
|
|
171
|
+
title: string;
|
|
172
|
+
message: string;
|
|
173
|
+
actions: string[];
|
|
174
|
+
} | null;
|
|
175
|
+
alternativeMethod: {
|
|
176
|
+
type: 'email' | 'phone';
|
|
177
|
+
value: string;
|
|
178
|
+
} | null;
|
|
179
|
+
conflict: {
|
|
180
|
+
type: 'email' | 'phone';
|
|
181
|
+
maskedIdentifier: string;
|
|
182
|
+
options: {
|
|
183
|
+
canLogin: boolean;
|
|
184
|
+
canRecoverByEmail: boolean;
|
|
185
|
+
canRecoverBySms: boolean;
|
|
186
|
+
maskedEmail?: string;
|
|
187
|
+
maskedPhone?: string;
|
|
188
|
+
};
|
|
189
|
+
} | null;
|
|
190
|
+
loading: boolean;
|
|
191
|
+
error: string | null;
|
|
192
|
+
errorType: string | null;
|
|
193
|
+
otpMethod?: 'email' | 'sms' | null;
|
|
194
|
+
otpSentTo?: string | null;
|
|
195
|
+
}
|
|
196
|
+
export interface UserInfos {
|
|
197
|
+
name: string;
|
|
198
|
+
email: string | null;
|
|
199
|
+
ccphone?: string;
|
|
200
|
+
phone?: string;
|
|
201
|
+
address?: string;
|
|
202
|
+
town?: string;
|
|
203
|
+
country?: string;
|
|
204
|
+
image_url?: string;
|
|
205
|
+
auth_2fa?: boolean;
|
|
206
|
+
}
|
|
207
|
+
export interface LinkPhoneRequest {
|
|
208
|
+
app_key: string;
|
|
209
|
+
secret_key: string;
|
|
210
|
+
iam_reference: string;
|
|
211
|
+
ccphone: string;
|
|
212
|
+
phone: string;
|
|
213
|
+
}
|
|
214
|
+
export interface LinkPhoneResponse {
|
|
215
|
+
success: boolean;
|
|
216
|
+
message: string;
|
|
217
|
+
user_reference?: string;
|
|
218
|
+
user_infos?: UserInfos;
|
|
219
|
+
}
|
|
220
|
+
export interface LinkEmailRequest {
|
|
221
|
+
app_key: string;
|
|
222
|
+
secret_key: string;
|
|
223
|
+
iam_reference: string;
|
|
224
|
+
email: string;
|
|
225
|
+
}
|
|
226
|
+
export interface LinkEmailResponse {
|
|
227
|
+
success: boolean;
|
|
228
|
+
message: string;
|
|
229
|
+
user_reference?: string;
|
|
230
|
+
user_infos?: UserInfos;
|
|
231
|
+
}
|
|
232
|
+
export interface RefreshUserInfoSingleRequest {
|
|
233
|
+
secret_key: string;
|
|
234
|
+
alias_reference: string;
|
|
235
|
+
}
|
|
236
|
+
export interface RefreshUserInfoSingleResponse {
|
|
237
|
+
success: boolean;
|
|
238
|
+
message?: string;
|
|
239
|
+
user_reference?: string;
|
|
240
|
+
alias_reference?: string;
|
|
241
|
+
login_type?: 'email' | 'phone';
|
|
242
|
+
user_infos?: UserInfos;
|
|
243
|
+
}
|
|
244
|
+
export interface RefreshUserInfoBulkRequest {
|
|
245
|
+
secret_key: string;
|
|
246
|
+
alias_references: string[];
|
|
247
|
+
}
|
|
248
|
+
export interface RefreshUserInfoBulkResponse {
|
|
249
|
+
success: boolean;
|
|
250
|
+
message?: string;
|
|
251
|
+
total_requested?: number;
|
|
252
|
+
total_found?: number;
|
|
253
|
+
total_errors?: number;
|
|
254
|
+
data?: Array<{
|
|
255
|
+
user_reference: string;
|
|
256
|
+
alias_reference: string;
|
|
257
|
+
login_type: 'email' | 'phone';
|
|
258
|
+
user_infos: UserInfos;
|
|
259
|
+
}>;
|
|
260
|
+
errors?: Array<{
|
|
261
|
+
alias_reference: string;
|
|
262
|
+
error: string;
|
|
263
|
+
}>;
|
|
264
|
+
}
|
|
265
|
+
export interface UpdateAvatarRequest {
|
|
266
|
+
app_key: string;
|
|
267
|
+
secret_key: string;
|
|
268
|
+
alias_reference: string;
|
|
269
|
+
avatar_url: string;
|
|
270
|
+
}
|
|
271
|
+
export interface UpdateAvatarResponse {
|
|
272
|
+
success: boolean;
|
|
273
|
+
message: string;
|
|
274
|
+
user_reference?: string;
|
|
275
|
+
alias_reference?: string;
|
|
276
|
+
user_infos?: UserInfos;
|
|
277
|
+
}
|
|
278
|
+
export interface ResetAvatarRequest {
|
|
279
|
+
app_key: string;
|
|
280
|
+
secret_key: string;
|
|
281
|
+
alias_reference: string;
|
|
282
|
+
}
|
|
283
|
+
export interface ResetAvatarResponse {
|
|
284
|
+
success: boolean;
|
|
285
|
+
message: string;
|
|
286
|
+
user_reference?: string;
|
|
287
|
+
alias_reference?: string;
|
|
288
|
+
user_infos?: UserInfos;
|
|
289
|
+
}
|