@ollaid/native-sso 2.1.5 → 2.6.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.
Files changed (41) hide show
  1. package/README.md +398 -63
  2. package/dist/components/AvatarCropModal.d.ts +16 -0
  3. package/dist/components/DebugPanel.d.ts +7 -2
  4. package/dist/components/LoginModal.d.ts +2 -2
  5. package/dist/components/NativeSSOPage.d.ts +11 -3
  6. package/dist/components/OnboardingModal.d.ts +14 -7
  7. package/dist/components/PasswordRecoveryModal.d.ts +1 -1
  8. package/dist/components/PhoneInput.d.ts +2 -1
  9. package/dist/components/SignupModal.d.ts +1 -1
  10. package/dist/components/ui.d.ts +4 -2
  11. package/dist/hooks/useLogout.d.ts +1 -1
  12. package/dist/hooks/useMobilePassword.d.ts +1 -1
  13. package/dist/hooks/useMobileRegistration.d.ts +2 -2
  14. package/dist/hooks/useNativeAuth.d.ts +8 -5
  15. package/dist/hooks/useTokenHealthCheck.d.ts +11 -1
  16. package/dist/index-Bpixveaz.js +489 -0
  17. package/dist/index-Bpixveaz.js.map +1 -0
  18. package/dist/index-DDOXM37y.cjs +488 -0
  19. package/dist/index-DDOXM37y.cjs.map +1 -0
  20. package/dist/index.cjs +9231 -414
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.ts +8 -5
  23. package/dist/index.js +9232 -415
  24. package/dist/index.js.map +1 -1
  25. package/dist/provider.d.ts +4 -1
  26. package/dist/services/api.d.ts +76 -7
  27. package/dist/services/debugLogger.d.ts +1 -1
  28. package/dist/services/iamAccount.d.ts +1 -1
  29. package/dist/services/mobilePassword.d.ts +1 -1
  30. package/dist/services/mobileRegistration.d.ts +1 -1
  31. package/dist/services/nativeAuth.d.ts +3 -2
  32. package/dist/services/profile.d.ts +31 -0
  33. package/dist/services/profileChange.d.ts +30 -0
  34. package/dist/services/profileMedia.d.ts +16 -0
  35. package/dist/types/mobile.d.ts +1 -1
  36. package/dist/types/native.d.ts +23 -1
  37. package/dist/web-BQDVoI6q.cjs +146 -0
  38. package/dist/web-BQDVoI6q.cjs.map +1 -0
  39. package/dist/web-DPmAPlXS.js +146 -0
  40. package/dist/web-DPmAPlXS.js.map +1 -0
  41. package/package.json +11 -4
@@ -2,9 +2,10 @@
2
2
  * NativeSSOProvider — React Context pour @ollaid/native-sso
3
3
  * Centralise la configuration pour les hooks et composants individuels
4
4
  *
5
- * @version 2.1.4
5
+ * @version 2.6.0
6
6
  */
7
7
  import { type ReactNode } from 'react';
8
+ import { type NativeStorageAdapter } from './services/api';
8
9
  export interface NativeSSOConfig {
9
10
  /** URL du Backend SaaS (ex: https://mon-saas.com/api) */
10
11
  saasApiUrl: string;
@@ -14,6 +15,8 @@ export interface NativeSSOConfig {
14
15
  timeout?: number;
15
16
  /** Mode debug (logs console) */
16
17
  debug?: boolean;
18
+ /** Stockage injectable pour les apps natives / Capacitor */
19
+ storage?: NativeStorageAdapter;
17
20
  }
18
21
  export interface NativeSSOProviderProps {
19
22
  config: NativeSSOConfig;
@@ -2,7 +2,7 @@
2
2
  * Client API pour @ollaid/native-sso
3
3
  * Gestion des requêtes HTTP avec timeout, device ID, token storage
4
4
  *
5
- * @version 2.1.4
5
+ * @version 2.6.0
6
6
  */
7
7
  export type ApiErrorType = 'network' | 'timeout' | 'server' | 'validation' | 'auth' | 'unknown';
8
8
  export declare class ApiError extends Error {
@@ -28,19 +28,76 @@ export interface NativeAuthConfig {
28
28
  * Ex: 'iam', 'iam_vendor', 'iam_client', 'iam_admin'
29
29
  */
30
30
  configPrefix?: string;
31
+ /**
32
+ * Stockage session injectable.
33
+ * Défaut: localStorage en navigateur, mémoire en fallback.
34
+ * Utile pour Capacitor ou des wrappers secure-storage côté app consommatrice.
35
+ */
36
+ storage?: NativeStorageAdapter;
37
+ }
38
+ export interface NativeStorageAdapter {
39
+ getItem(key: string): string | null;
40
+ setItem(key: string, value: string): void;
41
+ removeItem(key: string): void;
42
+ clear(): void;
31
43
  }
44
+ export declare function setNativeStorage(adapter?: NativeStorageAdapter): void;
45
+ export declare function getNativeStorage(): NativeStorageAdapter;
32
46
  export declare const setNativeAuthConfig: (newConfig: Partial<NativeAuthConfig>) => void;
33
47
  export declare const getNativeAuthConfig: () => NativeAuthConfig;
34
48
  export declare const isDebugMode: () => boolean;
49
+ export declare const getSaasApiBaseUrl: () => string;
50
+ export declare const getIamApiBaseUrl: () => string;
35
51
  export declare const getDeviceId: () => string;
52
+ /**
53
+ * Stable session UUID (instance id) persisted in localStorage.
54
+ *
55
+ * This is NOT a security token. It is used to disambiguate sessions across devices/webviews
56
+ * and to help backends implement multi-session behavior safely.
57
+ */
58
+ export declare const getSessionUuid: () => string;
59
+ export interface NativeDeviceContext {
60
+ deviceName?: string | null;
61
+ deviceModel?: string | null;
62
+ deviceManufacturer?: string | null;
63
+ operatingSystem?: string | null;
64
+ osVersion?: string | null;
65
+ platform?: string | null;
66
+ browser?: string | null;
67
+ language?: string | null;
68
+ webviewVersion?: string | null;
69
+ isNative?: boolean | null;
70
+ label?: string | null;
71
+ }
72
+ export declare function ensureDeviceContext(): Promise<NativeDeviceContext | null>;
36
73
  declare const STORAGE: {
37
- readonly AUTH_TOKEN: "auth_token";
38
- readonly TOKEN: "token";
39
- readonly USER: "user";
40
- readonly ACCOUNT_TYPE: "account_type";
41
- readonly ALIAS_REFERENCE: "alias_reference";
42
- readonly APP_ACCESS_TOKEN_REF: "app_access_token_ref";
74
+ readonly AUTH_TOKEN: "sso_auth_token";
75
+ readonly TOKEN: "sso_token";
76
+ readonly USER: "sso_user";
77
+ readonly ACCOUNT_TYPE: "sso_account_type";
78
+ readonly ALIAS_REFERENCE: "sso_alias_reference";
79
+ readonly APP_ACCESS_TOKEN_REF: "sso_app_access_token_ref";
80
+ readonly REFRESH_TOKEN: "sso_refresh_token";
81
+ readonly TOKEN_EXPIRES_AT: "sso_token_expires_at";
82
+ readonly REFRESH_EXPIRES_AT: "sso_refresh_expires_at";
83
+ };
84
+ declare const PROFILE_STORAGE: {
85
+ readonly IMAGE_LAST_STATUS: "sso_image_last_status";
86
+ readonly IMAGE_LAST_CHECK: "sso_image_last_check";
87
+ readonly IMAGE_RECHECK_AT: "sso_image_recheck_at";
43
88
  };
89
+ export interface SsoSessionSnapshot<TUser = unknown> {
90
+ authToken: string | null;
91
+ refreshToken: string | null;
92
+ refreshExpiresAt: string | null;
93
+ tokenExpiresAt: string | null;
94
+ appAccessTokenRef: string | null;
95
+ aliasReference: string | null;
96
+ accountType: string | null;
97
+ deviceId: string | null;
98
+ sessionUuid: string | null;
99
+ user: TUser | null;
100
+ }
44
101
  export declare const setAuthToken: (token: string) => void;
45
102
  export declare const getAuthToken: () => string | null;
46
103
  /**
@@ -73,7 +130,19 @@ export declare const setAuthUser: (user: unknown) => void;
73
130
  export declare const getAuthUser: <T>() => T | null;
74
131
  export declare const setAccountType: (type: string) => void;
75
132
  export declare const getAccountType: () => string | null;
133
+ export declare function getSsoSessionSnapshot<TUser = unknown>(): SsoSessionSnapshot<TUser>;
134
+ export declare function hasSsoSession(): boolean;
76
135
  export { STORAGE as STORAGE_KEYS };
136
+ export { PROFILE_STORAGE as PROFILE_PROMPT_KEYS };
137
+ export interface ProfilePromptState {
138
+ lastStatus: boolean | null;
139
+ lastCheckAt: number | null;
140
+ recheckAt: number | null;
141
+ }
142
+ export declare function getProfilePromptState(): ProfilePromptState;
143
+ export declare function setProfilePromptState(status: boolean, recheckAt?: number | null): void;
144
+ export declare function markProfilePromptComplete(): void;
145
+ export declare function snoozeProfilePrompt(hours?: number): void;
77
146
  export declare function fetchWithTimeout<T>(url: string, options: RequestInit, timeout: number): Promise<T>;
78
147
  export declare function getHeaders(token?: string, includeConfigPrefix?: boolean): HeadersInit;
79
148
  declare const _default: {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Debug Logger pour @ollaid/native-sso
3
3
  * Stocke l'historique des appels API en mémoire pour le DebugPanel
4
- * @version 2.1.4
4
+ * @version 2.6.0
5
5
  */
6
6
  export interface ApiCallLog {
7
7
  id: string;
@@ -8,7 +8,7 @@
8
8
  * Ne JAMAIS appeler ces méthodes depuis du code frontend/navigateur car la
9
9
  * secret_key serait exposée dans les DevTools réseau.
10
10
  *
11
- * @version 2.1.4
11
+ * @version 2.6.0
12
12
  */
13
13
  import type { LinkPhoneRequest, LinkPhoneResponse, LinkEmailRequest, LinkEmailResponse, RefreshUserInfoSingleRequest, RefreshUserInfoSingleResponse, RefreshUserInfoBulkRequest, RefreshUserInfoBulkResponse, UpdateAvatarRequest, UpdateAvatarResponse, ResetAvatarRequest, ResetAvatarResponse } from '../types/native';
14
14
  export declare const iamAccountService: {
@@ -2,7 +2,7 @@
2
2
  * Service de récupération de mot de passe v1.0
3
3
  * Architecture Frontend-First : Appels directs à l'IAM
4
4
  *
5
- * @version 2.1.4
5
+ * @version 2.6.0
6
6
  */
7
7
  import { ApiError } from './api';
8
8
  import type { MobilePasswordInitResponse, MobilePasswordSelectMethodResponse, MobilePasswordResetResponse, MobilePasswordResendResponse } from '../types/mobile';
@@ -2,7 +2,7 @@
2
2
  * Service d'inscription Mobile SSO v1.0
3
3
  * Architecture Frontend-First : Appels directs à l'IAM via nativeAuth
4
4
  *
5
- * @version 2.1.4
5
+ * @version 2.6.0
6
6
  */
7
7
  import type { MobileRegistrationFormData, MobileVerifyOtpResponse, MobileRegistrationCompleteResponse, MobileResendOtpResponse } from '../types/mobile';
8
8
  import type { NativeInitResponse } from '../types/native';
@@ -2,9 +2,9 @@
2
2
  * Service d'authentification Native Mobile SSO v1.0
3
3
  * Architecture Frontend-First : Direct IAM après encryption
4
4
  *
5
- * @version 2.1.4
5
+ * @version 2.6.0
6
6
  */
7
- import type { NativeAuthType, NativeEncryptRequest, NativeEncryptResponse, NativeInitResponse, NativeValidateResponse, NativeGrantAccessResponse, NativeResendOtpResponse, NativeExchangeResponse, NativeCredentials } from '../types/native';
7
+ import type { NativeAuthType, NativeEncryptRequest, NativeEncryptResponse, NativeInitResponse, NativeValidateResponse, NativeGrantAccessResponse, NativeResendOtpResponse, NativeExchangeResponse, NativeCredentials, NativeRefreshResponse } from '../types/native';
8
8
  export declare const nativeAuthService: {
9
9
  hasCredentials(): boolean;
10
10
  getCredentials(): NativeCredentials | null;
@@ -27,6 +27,7 @@ export declare const nativeAuthService: {
27
27
  valid: boolean;
28
28
  user?: import("../types/native").UserInfos;
29
29
  }>;
30
+ refresh(): Promise<NativeRefreshResponse>;
30
31
  logout(token?: string): Promise<{
31
32
  success: boolean;
32
33
  }>;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Profile service for @ollaid/native-sso
3
+ * Updates the authenticated profile fields via IAM.
4
+ *
5
+ * @version 2.6.0
6
+ */
7
+ import type { UserInfos } from '../types/native';
8
+ export interface ProfileUpdateRequest {
9
+ name?: string;
10
+ ccphone?: string;
11
+ phone?: string;
12
+ email?: string;
13
+ address?: string;
14
+ town?: string;
15
+ country?: string;
16
+ }
17
+ export interface ProfileUpdateResponse {
18
+ message?: string;
19
+ user?: UserInfos;
20
+ user_infos?: UserInfos;
21
+ }
22
+ export interface ProfileFetchResponse {
23
+ message?: string;
24
+ user?: UserInfos;
25
+ user_infos?: UserInfos;
26
+ }
27
+ export declare const profileService: {
28
+ getProfile(): Promise<ProfileFetchResponse>;
29
+ updateProfile(data: ProfileUpdateRequest): Promise<ProfileUpdateResponse>;
30
+ };
31
+ export default profileService;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Profile change service for @ollaid/native-sso
3
+ * Uses authenticated IAM endpoints for email / phone change with OTP confirmation.
4
+ *
5
+ * @version 2.6.0
6
+ */
7
+ export type ProfileChangeKind = 'email' | 'phone';
8
+ export type ProfileChangeMethod = 'email' | 'phone';
9
+ export interface ProfileChangeRequestResponse {
10
+ success: boolean;
11
+ message?: string;
12
+ request_id?: number;
13
+ method?: ProfileChangeMethod;
14
+ otp_dev?: string | null;
15
+ }
16
+ export interface ProfileChangeVerifyResponse {
17
+ success: boolean;
18
+ message?: string;
19
+ step?: 'pending_new_otp' | 'completed' | string;
20
+ user?: unknown;
21
+ }
22
+ export declare const profileChangeService: {
23
+ requestEmailChange(newEmail: string, method?: ProfileChangeMethod): Promise<ProfileChangeRequestResponse>;
24
+ requestPhoneChange(ccphone: string, phone: string, method?: ProfileChangeMethod): Promise<ProfileChangeRequestResponse>;
25
+ verifyOldOTP(requestId: number, otpCode: string): Promise<ProfileChangeVerifyResponse>;
26
+ verifyNewOTP(requestId: number, otpCode: string): Promise<ProfileChangeVerifyResponse>;
27
+ resendOTP(requestId: number): Promise<ProfileChangeRequestResponse>;
28
+ switchMethod(requestId: number, method: ProfileChangeMethod): Promise<ProfileChangeRequestResponse>;
29
+ };
30
+ export default profileChangeService;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Profile media service for @ollaid/native-sso
3
+ * Uploads the cropped avatar to the IAM authenticated profile endpoint.
4
+ *
5
+ * @version 2.6.0
6
+ */
7
+ import type { UserInfos } from '../types/native';
8
+ export interface ProfileImageUploadResponse {
9
+ message?: string;
10
+ user?: UserInfos;
11
+ user_infos?: UserInfos;
12
+ }
13
+ export declare const profileMediaService: {
14
+ uploadProfileImage(image: Blob, filename?: string): Promise<ProfileImageUploadResponse>;
15
+ };
16
+ export default profileMediaService;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Types pour le password recovery et registration Mobile SSO v1.0
3
3
  *
4
- * @version 2.1.4
4
+ * @version 2.6.0
5
5
  */
6
6
  export type MobilePasswordStatus = 'idle' | 'choice_required' | 'pending_otp' | 'pending_password' | 'completed';
7
7
  export interface MobilePasswordState {
@@ -2,7 +2,7 @@
2
2
  * Types pour l'authentification Native SSO v1.0
3
3
  * Architecture Frontend-First avec encryption directe
4
4
  *
5
- * @version 2.1.4
5
+ * @version 2.6.0
6
6
  */
7
7
  export type NativeAuthType = 'login_email' | 'login_phone' | 'login_access_otp' | 'register' | 'recovery_password';
8
8
  export type AccountType = 'email' | 'phone-only';
@@ -152,6 +152,10 @@ export interface NativeExchangeResponse {
152
152
  token: string;
153
153
  auth_token?: string;
154
154
  expires_at: string;
155
+ /** Refresh token (optional until all SaaS backends implement it) */
156
+ refresh_token?: string;
157
+ /** Refresh expiration timestamp */
158
+ refresh_expires_at?: string;
155
159
  user: NativeUser;
156
160
  user_infos?: UserInfos;
157
161
  /** Alias reference retournée au niveau racine par certains backends SaaS */
@@ -159,6 +163,20 @@ export interface NativeExchangeResponse {
159
163
  /** Référence AppAccessToken IAM liée au token Sanctum (pour revocation rapide) */
160
164
  app_access_token_ref?: string;
161
165
  }
166
+ export interface NativeRefreshResponse {
167
+ success: boolean;
168
+ message?: string;
169
+ error_type?: string;
170
+ token?: string;
171
+ expires_at?: string;
172
+ refresh_token?: string;
173
+ refresh_expires_at?: string;
174
+ user?: NativeUser | UserInfos;
175
+ /** Référence AppAccessToken IAM liée au token Sanctum (pour revocation rapide) */
176
+ app_access_token_ref?: string;
177
+ /** Alias reference optionnelle */
178
+ alias_reference?: string;
179
+ }
162
180
  export interface CheckTokenResponse {
163
181
  status?: string;
164
182
  success?: boolean;
@@ -201,6 +219,7 @@ export interface NativeAuthState {
201
219
  otpSentTo?: string | null;
202
220
  }
203
221
  export interface UserInfos {
222
+ reference?: string;
204
223
  name: string;
205
224
  email: string | null;
206
225
  ccphone?: string;
@@ -209,7 +228,10 @@ export interface UserInfos {
209
228
  town?: string;
210
229
  country?: string;
211
230
  image_url?: string;
231
+ image?: string;
212
232
  auth_2fa?: boolean;
233
+ alias_reference?: string;
234
+ iam_reference?: string;
213
235
  }
214
236
  export interface LinkPhoneRequest {
215
237
  app_key: string;
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const index = require("./index-DDOXM37y.cjs");
4
+ class DeviceWeb extends index.WebPlugin {
5
+ async getId() {
6
+ return {
7
+ identifier: this.getUid()
8
+ };
9
+ }
10
+ async getInfo() {
11
+ if (typeof navigator === "undefined" || !navigator.userAgent) {
12
+ throw this.unavailable("Device API not available in this browser");
13
+ }
14
+ const ua = navigator.userAgent;
15
+ const uaFields = this.parseUa(ua);
16
+ return {
17
+ model: uaFields.model,
18
+ platform: "web",
19
+ operatingSystem: uaFields.operatingSystem,
20
+ osVersion: uaFields.osVersion,
21
+ manufacturer: navigator.vendor,
22
+ isVirtual: false,
23
+ webViewVersion: uaFields.browserVersion
24
+ };
25
+ }
26
+ async getBatteryInfo() {
27
+ if (typeof navigator === "undefined" || !navigator.getBattery) {
28
+ throw this.unavailable("Device API not available in this browser");
29
+ }
30
+ let battery = {};
31
+ try {
32
+ battery = await navigator.getBattery();
33
+ } catch (e) {
34
+ }
35
+ return {
36
+ batteryLevel: battery.level,
37
+ isCharging: battery.charging
38
+ };
39
+ }
40
+ async getLanguageCode() {
41
+ return {
42
+ value: navigator.language.split("-")[0].toLowerCase()
43
+ };
44
+ }
45
+ async getLanguageTag() {
46
+ return {
47
+ value: navigator.language
48
+ };
49
+ }
50
+ parseUa(ua) {
51
+ const uaFields = {};
52
+ const start = ua.indexOf("(") + 1;
53
+ let end = ua.indexOf(") AppleWebKit");
54
+ if (ua.indexOf(") Gecko") !== -1) {
55
+ end = ua.indexOf(") Gecko");
56
+ }
57
+ const fields = ua.substring(start, end);
58
+ if (ua.indexOf("Android") !== -1) {
59
+ const tmpFields = fields.replace("; wv", "").split("; ").pop();
60
+ if (tmpFields) {
61
+ uaFields.model = tmpFields.split(" Build")[0];
62
+ }
63
+ uaFields.osVersion = fields.split("; ")[1];
64
+ } else {
65
+ uaFields.model = fields.split("; ")[0];
66
+ if (typeof navigator !== "undefined" && navigator.oscpu) {
67
+ uaFields.osVersion = navigator.oscpu;
68
+ } else {
69
+ if (ua.indexOf("Windows") !== -1) {
70
+ uaFields.osVersion = fields;
71
+ } else {
72
+ const tmpFields = fields.split("; ").pop();
73
+ if (tmpFields) {
74
+ const lastParts = tmpFields.replace(" like Mac OS X", "").split(" ");
75
+ uaFields.osVersion = lastParts[lastParts.length - 1].replace(/_/g, ".");
76
+ }
77
+ }
78
+ }
79
+ }
80
+ if (/android/i.test(ua)) {
81
+ uaFields.operatingSystem = "android";
82
+ } else if (/iPad|iPhone|iPod/.test(ua) && !window.MSStream) {
83
+ uaFields.operatingSystem = "ios";
84
+ } else if (/Win/.test(ua)) {
85
+ uaFields.operatingSystem = "windows";
86
+ } else if (/Mac/i.test(ua)) {
87
+ uaFields.operatingSystem = "mac";
88
+ } else {
89
+ uaFields.operatingSystem = "unknown";
90
+ }
91
+ const isSafari = !!window.ApplePaySession;
92
+ const isChrome = !!window.chrome;
93
+ const isFirefox = /Firefox/.test(ua);
94
+ const isEdge = /Edg/.test(ua);
95
+ const isFirefoxIOS = /FxiOS/.test(ua);
96
+ const isChromeIOS = /CriOS/.test(ua);
97
+ const isEdgeIOS = /EdgiOS/.test(ua);
98
+ if (isSafari || isChrome && !isEdge || isFirefoxIOS || isChromeIOS || isEdgeIOS) {
99
+ let searchWord;
100
+ if (isFirefoxIOS) {
101
+ searchWord = "FxiOS";
102
+ } else if (isChromeIOS) {
103
+ searchWord = "CriOS";
104
+ } else if (isEdgeIOS) {
105
+ searchWord = "EdgiOS";
106
+ } else if (isSafari) {
107
+ searchWord = "Version";
108
+ } else {
109
+ searchWord = "Chrome";
110
+ }
111
+ const words = ua.split(" ");
112
+ for (const word of words) {
113
+ if (word.includes(searchWord)) {
114
+ const version = word.split("/")[1];
115
+ uaFields.browserVersion = version;
116
+ }
117
+ }
118
+ } else if (isFirefox || isEdge) {
119
+ const reverseUA = ua.split("").reverse().join("");
120
+ const reverseVersion = reverseUA.split("/")[0];
121
+ const version = reverseVersion.split("").reverse().join("");
122
+ uaFields.browserVersion = version;
123
+ }
124
+ return uaFields;
125
+ }
126
+ getUid() {
127
+ if (typeof window !== "undefined" && window.localStorage) {
128
+ let uid = window.localStorage.getItem("_capuid");
129
+ if (uid) {
130
+ return uid;
131
+ }
132
+ uid = this.uuid4();
133
+ window.localStorage.setItem("_capuid", uid);
134
+ return uid;
135
+ }
136
+ return this.uuid4();
137
+ }
138
+ uuid4() {
139
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
140
+ const r = Math.random() * 16 | 0, v = c === "x" ? r : r & 3 | 8;
141
+ return v.toString(16);
142
+ });
143
+ }
144
+ }
145
+ exports.DeviceWeb = DeviceWeb;
146
+ //# sourceMappingURL=web-BQDVoI6q.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-BQDVoI6q.cjs","sources":["../../../node_modules/@capacitor/device/dist/esm/web.js"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\nexport class DeviceWeb extends WebPlugin {\n async getId() {\n return {\n identifier: this.getUid(),\n };\n }\n async getInfo() {\n if (typeof navigator === 'undefined' || !navigator.userAgent) {\n throw this.unavailable('Device API not available in this browser');\n }\n const ua = navigator.userAgent;\n const uaFields = this.parseUa(ua);\n return {\n model: uaFields.model,\n platform: 'web',\n operatingSystem: uaFields.operatingSystem,\n osVersion: uaFields.osVersion,\n manufacturer: navigator.vendor,\n isVirtual: false,\n webViewVersion: uaFields.browserVersion,\n };\n }\n async getBatteryInfo() {\n if (typeof navigator === 'undefined' || !navigator.getBattery) {\n throw this.unavailable('Device API not available in this browser');\n }\n let battery = {};\n try {\n battery = await navigator.getBattery();\n }\n catch (e) {\n // Let it fail, we don't care\n }\n return {\n batteryLevel: battery.level,\n isCharging: battery.charging,\n };\n }\n async getLanguageCode() {\n return {\n value: navigator.language.split('-')[0].toLowerCase(),\n };\n }\n async getLanguageTag() {\n return {\n value: navigator.language,\n };\n }\n parseUa(ua) {\n const uaFields = {};\n const start = ua.indexOf('(') + 1;\n let end = ua.indexOf(') AppleWebKit');\n if (ua.indexOf(') Gecko') !== -1) {\n end = ua.indexOf(') Gecko');\n }\n const fields = ua.substring(start, end);\n if (ua.indexOf('Android') !== -1) {\n const tmpFields = fields.replace('; wv', '').split('; ').pop();\n if (tmpFields) {\n uaFields.model = tmpFields.split(' Build')[0];\n }\n uaFields.osVersion = fields.split('; ')[1];\n }\n else {\n uaFields.model = fields.split('; ')[0];\n if (typeof navigator !== 'undefined' && navigator.oscpu) {\n uaFields.osVersion = navigator.oscpu;\n }\n else {\n if (ua.indexOf('Windows') !== -1) {\n uaFields.osVersion = fields;\n }\n else {\n const tmpFields = fields.split('; ').pop();\n if (tmpFields) {\n const lastParts = tmpFields\n .replace(' like Mac OS X', '')\n .split(' ');\n uaFields.osVersion = lastParts[lastParts.length - 1].replace(/_/g, '.');\n }\n }\n }\n }\n if (/android/i.test(ua)) {\n uaFields.operatingSystem = 'android';\n }\n else if (/iPad|iPhone|iPod/.test(ua) && !window.MSStream) {\n uaFields.operatingSystem = 'ios';\n }\n else if (/Win/.test(ua)) {\n uaFields.operatingSystem = 'windows';\n }\n else if (/Mac/i.test(ua)) {\n uaFields.operatingSystem = 'mac';\n }\n else {\n uaFields.operatingSystem = 'unknown';\n }\n // Check for browsers based on non-standard javascript apis, only not user agent\n const isSafari = !!window.ApplePaySession;\n const isChrome = !!window.chrome;\n const isFirefox = /Firefox/.test(ua);\n const isEdge = /Edg/.test(ua);\n const isFirefoxIOS = /FxiOS/.test(ua);\n const isChromeIOS = /CriOS/.test(ua);\n const isEdgeIOS = /EdgiOS/.test(ua);\n // FF and Edge User Agents both end with \"/MAJOR.MINOR\"\n if (isSafari ||\n (isChrome && !isEdge) ||\n isFirefoxIOS ||\n isChromeIOS ||\n isEdgeIOS) {\n // Safari version comes as \"... Version/MAJOR.MINOR ...\"\n // Chrome version comes as \"... Chrome/MAJOR.MINOR ...\"\n // FirefoxIOS version comes as \"... FxiOS/MAJOR.MINOR ...\"\n // ChromeIOS version comes as \"... CriOS/MAJOR.MINOR ...\"\n let searchWord;\n if (isFirefoxIOS) {\n searchWord = 'FxiOS';\n }\n else if (isChromeIOS) {\n searchWord = 'CriOS';\n }\n else if (isEdgeIOS) {\n searchWord = 'EdgiOS';\n }\n else if (isSafari) {\n searchWord = 'Version';\n }\n else {\n searchWord = 'Chrome';\n }\n const words = ua.split(' ');\n for (const word of words) {\n if (word.includes(searchWord)) {\n const version = word.split('/')[1];\n uaFields.browserVersion = version;\n }\n }\n }\n else if (isFirefox || isEdge) {\n const reverseUA = ua.split('').reverse().join('');\n const reverseVersion = reverseUA.split('/')[0];\n const version = reverseVersion.split('').reverse().join('');\n uaFields.browserVersion = version;\n }\n return uaFields;\n }\n getUid() {\n if (typeof window !== 'undefined' && window.localStorage) {\n let uid = window.localStorage.getItem('_capuid');\n if (uid) {\n return uid;\n }\n uid = this.uuid4();\n window.localStorage.setItem('_capuid', uid);\n return uid;\n }\n return this.uuid4();\n }\n uuid4() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n const r = (Math.random() * 16) | 0, v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["WebPlugin"],"mappings":";;;AACO,MAAM,kBAAkBA,MAAAA,UAAU;AAAA,EACrC,MAAM,QAAQ;AACV,WAAO;AAAA,MACH,YAAY,KAAK,OAAM;AAAA,IACnC;AAAA,EACI;AAAA,EACA,MAAM,UAAU;AACZ,QAAI,OAAO,cAAc,eAAe,CAAC,UAAU,WAAW;AAC1D,YAAM,KAAK,YAAY,0CAA0C;AAAA,IACrE;AACA,UAAM,KAAK,UAAU;AACrB,UAAM,WAAW,KAAK,QAAQ,EAAE;AAChC,WAAO;AAAA,MACH,OAAO,SAAS;AAAA,MAChB,UAAU;AAAA,MACV,iBAAiB,SAAS;AAAA,MAC1B,WAAW,SAAS;AAAA,MACpB,cAAc,UAAU;AAAA,MACxB,WAAW;AAAA,MACX,gBAAgB,SAAS;AAAA,IACrC;AAAA,EACI;AAAA,EACA,MAAM,iBAAiB;AACnB,QAAI,OAAO,cAAc,eAAe,CAAC,UAAU,YAAY;AAC3D,YAAM,KAAK,YAAY,0CAA0C;AAAA,IACrE;AACA,QAAI,UAAU,CAAA;AACd,QAAI;AACA,gBAAU,MAAM,UAAU,WAAU;A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AAC;AAC7C,YAAM,UAAU,eAAe,MAAM,EAAE,EAAE,QAAO,EAAG,KAAK,EAAE;AAC1D,eAAS,iBAAiB;AAAA,IAC9B;AACA,WAAO;AAAA,EACX;AAAA,EACA,SAAS;AACL,QAAI,OAAO,WAAW,eAAe,OAAO,cAAc;AACtD,UAAI,MAAM,OAAO,aAAa,QAAQ,SAAS;AAC/C,UAAI,KAAK;AACL,eAAO;AAAA,MACX;AACA,YAAM,KAAK,MAAK;AAChB,aAAO,aAAa,QAAQ,WAAW,GAAG;AAC1C,aAAO;AAAA,IACX;AACA,WAAO,KAAK,MAAK;AAAA,EACrB;AAAA,EACA,QAAQ;AACJ,WAAO,uCAAuC,QAAQ,SAAS,SAAU,GAAG;AACxE,YAAM,IAAK,KAAK,OAAM,IAAK,KAAM,GAAG,IAAI,MAAM,MAAM,IAAK,IAAI,IAAO;AACpE,aAAO,EAAE,SAAS,EAAE;AAAA,IACxB,CAAC;AAAA,EACL;AACJ;;","x_google_ignoreList":[0]}
@@ -0,0 +1,146 @@
1
+ import { W as WebPlugin } from "./index-Bpixveaz.js";
2
+ class DeviceWeb extends WebPlugin {
3
+ async getId() {
4
+ return {
5
+ identifier: this.getUid()
6
+ };
7
+ }
8
+ async getInfo() {
9
+ if (typeof navigator === "undefined" || !navigator.userAgent) {
10
+ throw this.unavailable("Device API not available in this browser");
11
+ }
12
+ const ua = navigator.userAgent;
13
+ const uaFields = this.parseUa(ua);
14
+ return {
15
+ model: uaFields.model,
16
+ platform: "web",
17
+ operatingSystem: uaFields.operatingSystem,
18
+ osVersion: uaFields.osVersion,
19
+ manufacturer: navigator.vendor,
20
+ isVirtual: false,
21
+ webViewVersion: uaFields.browserVersion
22
+ };
23
+ }
24
+ async getBatteryInfo() {
25
+ if (typeof navigator === "undefined" || !navigator.getBattery) {
26
+ throw this.unavailable("Device API not available in this browser");
27
+ }
28
+ let battery = {};
29
+ try {
30
+ battery = await navigator.getBattery();
31
+ } catch (e) {
32
+ }
33
+ return {
34
+ batteryLevel: battery.level,
35
+ isCharging: battery.charging
36
+ };
37
+ }
38
+ async getLanguageCode() {
39
+ return {
40
+ value: navigator.language.split("-")[0].toLowerCase()
41
+ };
42
+ }
43
+ async getLanguageTag() {
44
+ return {
45
+ value: navigator.language
46
+ };
47
+ }
48
+ parseUa(ua) {
49
+ const uaFields = {};
50
+ const start = ua.indexOf("(") + 1;
51
+ let end = ua.indexOf(") AppleWebKit");
52
+ if (ua.indexOf(") Gecko") !== -1) {
53
+ end = ua.indexOf(") Gecko");
54
+ }
55
+ const fields = ua.substring(start, end);
56
+ if (ua.indexOf("Android") !== -1) {
57
+ const tmpFields = fields.replace("; wv", "").split("; ").pop();
58
+ if (tmpFields) {
59
+ uaFields.model = tmpFields.split(" Build")[0];
60
+ }
61
+ uaFields.osVersion = fields.split("; ")[1];
62
+ } else {
63
+ uaFields.model = fields.split("; ")[0];
64
+ if (typeof navigator !== "undefined" && navigator.oscpu) {
65
+ uaFields.osVersion = navigator.oscpu;
66
+ } else {
67
+ if (ua.indexOf("Windows") !== -1) {
68
+ uaFields.osVersion = fields;
69
+ } else {
70
+ const tmpFields = fields.split("; ").pop();
71
+ if (tmpFields) {
72
+ const lastParts = tmpFields.replace(" like Mac OS X", "").split(" ");
73
+ uaFields.osVersion = lastParts[lastParts.length - 1].replace(/_/g, ".");
74
+ }
75
+ }
76
+ }
77
+ }
78
+ if (/android/i.test(ua)) {
79
+ uaFields.operatingSystem = "android";
80
+ } else if (/iPad|iPhone|iPod/.test(ua) && !window.MSStream) {
81
+ uaFields.operatingSystem = "ios";
82
+ } else if (/Win/.test(ua)) {
83
+ uaFields.operatingSystem = "windows";
84
+ } else if (/Mac/i.test(ua)) {
85
+ uaFields.operatingSystem = "mac";
86
+ } else {
87
+ uaFields.operatingSystem = "unknown";
88
+ }
89
+ const isSafari = !!window.ApplePaySession;
90
+ const isChrome = !!window.chrome;
91
+ const isFirefox = /Firefox/.test(ua);
92
+ const isEdge = /Edg/.test(ua);
93
+ const isFirefoxIOS = /FxiOS/.test(ua);
94
+ const isChromeIOS = /CriOS/.test(ua);
95
+ const isEdgeIOS = /EdgiOS/.test(ua);
96
+ if (isSafari || isChrome && !isEdge || isFirefoxIOS || isChromeIOS || isEdgeIOS) {
97
+ let searchWord;
98
+ if (isFirefoxIOS) {
99
+ searchWord = "FxiOS";
100
+ } else if (isChromeIOS) {
101
+ searchWord = "CriOS";
102
+ } else if (isEdgeIOS) {
103
+ searchWord = "EdgiOS";
104
+ } else if (isSafari) {
105
+ searchWord = "Version";
106
+ } else {
107
+ searchWord = "Chrome";
108
+ }
109
+ const words = ua.split(" ");
110
+ for (const word of words) {
111
+ if (word.includes(searchWord)) {
112
+ const version = word.split("/")[1];
113
+ uaFields.browserVersion = version;
114
+ }
115
+ }
116
+ } else if (isFirefox || isEdge) {
117
+ const reverseUA = ua.split("").reverse().join("");
118
+ const reverseVersion = reverseUA.split("/")[0];
119
+ const version = reverseVersion.split("").reverse().join("");
120
+ uaFields.browserVersion = version;
121
+ }
122
+ return uaFields;
123
+ }
124
+ getUid() {
125
+ if (typeof window !== "undefined" && window.localStorage) {
126
+ let uid = window.localStorage.getItem("_capuid");
127
+ if (uid) {
128
+ return uid;
129
+ }
130
+ uid = this.uuid4();
131
+ window.localStorage.setItem("_capuid", uid);
132
+ return uid;
133
+ }
134
+ return this.uuid4();
135
+ }
136
+ uuid4() {
137
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
138
+ const r = Math.random() * 16 | 0, v = c === "x" ? r : r & 3 | 8;
139
+ return v.toString(16);
140
+ });
141
+ }
142
+ }
143
+ export {
144
+ DeviceWeb
145
+ };
146
+ //# sourceMappingURL=web-DPmAPlXS.js.map