@jarvis-security/sdk 1.0.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/index.d.mts CHANGED
@@ -1,161 +1,208 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
3
-
4
- type AuthStatus = "idle" | "loading" | "authenticated" | "unauthenticated" | "error";
5
- type BiometricMethod = "passkey" | "retina" | "voice" | "fingerprint";
6
- type ClearanceLevel = "Level 1" | "Level 2" | "Level 3" | "Admin";
7
- interface UserProfile {
8
- uid: string;
9
- email: string;
10
- fullName: string;
11
- clearanceLevel: ClearanceLevel;
12
- hasBiometrics: boolean;
13
- createdAt?: string;
14
- lastLoginAt?: string;
15
- }
16
- interface AuthResult {
17
- success: boolean;
18
- user?: UserProfile;
19
- error?: string;
20
- errorCode?: string;
21
- }
22
- interface AuthAdapter {
23
- readonly name: string;
24
- register(email: string, passkey: string, fullName: string): Promise<AuthResult>;
25
- login(email: string, passkey: string): Promise<AuthResult>;
26
- logout(): Promise<AuthResult>;
27
- resetPassword(email: string): Promise<AuthResult>;
28
- verifyFace(imageBase64: string): Promise<AuthResult>;
29
- verifyVoice(audioBlob: Blob): Promise<AuthResult>;
30
- verifyFingerprint(scanData: string): Promise<AuthResult>;
31
- enrollBiometrics(userId: string): Promise<AuthResult>;
32
- verifyPasskey(email?: string): Promise<AuthResult>;
33
- getCurrentUser(): Promise<UserProfile | null>;
34
- onAuthStateChanged(callback: (user: UserProfile | null) => void): () => void;
35
- }
36
- interface TelemetryData {
37
- cpu: number;
38
- memory: string;
39
- authState: "CONNECTED" | "DISCONNECTED";
40
- power: number;
41
- }
42
- interface TerminalMessage {
43
- id: string;
44
- text: string;
45
- timestamp: Date;
46
- type: "info" | "success" | "error" | "warning";
47
- }
48
- interface AccessModalState {
49
- open: boolean;
50
- isSuccess: boolean;
51
- title: string;
52
- message: string;
53
- }
54
-
55
- declare function __resetMockAdapterStateForTests(): void;
56
- declare class MockAuthAdapter implements AuthAdapter {
57
- readonly name = "MockAuthAdapter";
58
- private listeners;
59
- private currentUser;
60
- constructor();
61
- private emit;
62
- register(email: string, passkey: string, fullName: string): Promise<AuthResult>;
63
- login(email: string, passkey: string): Promise<AuthResult>;
64
- logout(): Promise<AuthResult>;
65
- resetPassword(email: string): Promise<AuthResult>;
66
- verifyFace(_imageBase64: string): Promise<AuthResult>;
67
- verifyVoice(_audioBlob: Blob): Promise<AuthResult>;
68
- verifyFingerprint(_scanData: string): Promise<AuthResult>;
69
- enrollBiometrics(userId: string): Promise<AuthResult>;
70
- verifyPasskey(_email?: string): Promise<AuthResult>;
71
- getCurrentUser(): Promise<UserProfile | null>;
72
- onAuthStateChanged(callback: (user: UserProfile | null) => void): () => void;
73
- }
74
- declare class BackendAuthAdapter implements AuthAdapter {
75
- readonly name = "BackendAuthAdapter";
76
- private listeners;
77
- private currentUser;
78
- private baseUrl;
79
- constructor(baseUrl?: string);
80
- private emit;
81
- private request;
82
- register(email: string, passkey: string, fullName: string): Promise<AuthResult>;
83
- login(email: string, passkey: string): Promise<AuthResult>;
84
- logout(): Promise<AuthResult>;
85
- resetPassword(email: string): Promise<AuthResult>;
86
- verifyFace(imageBase64: string): Promise<AuthResult>;
87
- verifyVoice(audioBlob: Blob): Promise<AuthResult>;
88
- verifyFingerprint(_scanData: string): Promise<AuthResult>;
89
- enrollBiometrics(_userId: string): Promise<AuthResult>;
90
- verifyPasskey(_email?: string): Promise<AuthResult>;
91
- getCurrentUser(): Promise<UserProfile | null>;
92
- onAuthStateChanged(callback: (user: UserProfile | null) => void): () => void;
93
- }
94
- type AuthAdapterName = "mock" | "backend" | "firebase";
95
- declare function createAuthAdapter(kind?: AuthAdapterName, options?: {
96
- baseUrl?: string;
97
- }): AuthAdapter;
98
-
99
- interface AuthContextValue {
100
- user: UserProfile | null;
101
- status: AuthStatus;
102
- error: string | null;
103
- adapter: AuthAdapter;
104
- adapterName: AuthAdapterName;
105
- audioEnabled: boolean;
106
- activeMethod: BiometricMethod;
107
- isRegisterMode: boolean;
108
- terminalText: string;
109
- modal: AccessModalState;
110
- login: (email: string, passkey: string) => Promise<void>;
111
- register: (email: string, passkey: string, fullName: string) => Promise<void>;
112
- logout: () => Promise<void>;
113
- resetPassword: (email: string) => Promise<void>;
114
- verifyFace: (imageBase64: string) => Promise<void>;
115
- verifyVoice: (audioBlob: Blob) => Promise<void>;
116
- verifyFingerprint: (scanData: string) => Promise<void>;
117
- enrollBiometrics: () => Promise<void>;
118
- verifyPasskey: () => Promise<AuthResult>;
119
- setActiveMethod: (method: BiometricMethod) => void;
120
- toggleMode: () => void;
121
- toggleAudio: () => void;
122
- updateTerminal: (msg: string) => void;
123
- showModal: (isSuccess: boolean, title: string, message: string) => void;
124
- closeModal: () => void;
125
- playBeep: (freq?: number, type?: OscillatorType, duration?: number) => void;
126
- playSuccess: () => void;
127
- playError: () => void;
128
- }
129
- declare function AuthProvider({ children, adapter: adapterArg, adapterOptions, }: {
130
- children: ReactNode;
131
- adapter?: AuthAdapterName | AuthAdapter;
132
- adapterOptions?: {
133
- baseUrl?: string;
134
- };
135
- }): react.JSX.Element;
136
- declare function useAuth(): AuthContextValue;
137
-
138
- declare class SoundEngine {
139
- private ctx;
140
- private ensureContext;
141
- playBeep(freq?: number, type?: OscillatorType, duration?: number, gain?: number): void;
142
- playSuccess(): void;
143
- playError(): void;
144
- unlock(): void;
145
- }
146
-
147
- declare function AuthPortal(): react.JSX.Element;
148
-
149
- declare function ArcReactorHud(): react.JSX.Element;
150
-
151
- declare function CanvasBackground(): react.JSX.Element;
152
-
153
- declare function PasskeyForm(): react.JSX.Element;
154
-
155
- declare function FacialScanner(): react.JSX.Element;
156
-
157
- declare function VoiceScanner(): react.JSX.Element;
158
-
159
- declare function FingerprintPad(): react.JSX.Element;
160
-
161
- export { type AccessModalState, ArcReactorHud, type AuthAdapter, type AuthAdapterName, type AuthContextValue, AuthPortal, AuthProvider, type AuthResult, type AuthStatus, BackendAuthAdapter, type BiometricMethod, CanvasBackground, type ClearanceLevel, FacialScanner, FingerprintPad, MockAuthAdapter, PasskeyForm, SoundEngine, type TelemetryData, type TerminalMessage, type UserProfile, VoiceScanner, __resetMockAdapterStateForTests, createAuthAdapter, useAuth };
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ type AuthStatus = "idle" | "loading" | "authenticated" | "unauthenticated" | "error";
5
+ type BiometricMethod = "passkey" | "retina" | "voice" | "fingerprint";
6
+ type ClearanceLevel = "Level 1" | "Level 2" | "Level 3" | "Admin";
7
+ interface UserProfile {
8
+ uid: string;
9
+ email: string;
10
+ fullName: string;
11
+ clearanceLevel: ClearanceLevel;
12
+ hasBiometrics: boolean;
13
+ createdAt?: string;
14
+ lastLoginAt?: string;
15
+ }
16
+ interface AuthResult {
17
+ success: boolean;
18
+ user?: UserProfile;
19
+ error?: string;
20
+ errorCode?: string;
21
+ }
22
+ interface AuthAdapter {
23
+ readonly name: string;
24
+ register(email: string, passkey: string, fullName: string): Promise<AuthResult>;
25
+ login(email: string, passkey: string): Promise<AuthResult>;
26
+ logout(): Promise<AuthResult>;
27
+ resetPassword(email: string): Promise<AuthResult>;
28
+ /** Device face auth via WebAuthn platform authenticator (Windows Hello / Face ID). */
29
+ verifyFace(): Promise<AuthResult>;
30
+ /** Voice auth via real DSP voiceprint matching against an enrolled sample. */
31
+ verifyVoice(audioBlob: Blob): Promise<AuthResult>;
32
+ /** Device fingerprint auth via WebAuthn platform authenticator (Touch ID / Windows Hello). */
33
+ verifyFingerprint(): Promise<AuthResult>;
34
+ /** Enroll device biometric (WebAuthn platform authenticator). */
35
+ enrollBiometrics(userId: string): Promise<AuthResult>;
36
+ /** Enroll a voiceprint from a recorded sample. */
37
+ enrollVoice(audioBlob: Blob): Promise<AuthResult>;
38
+ verifyPasskey(email?: string): Promise<AuthResult>;
39
+ getCurrentUser(): Promise<UserProfile | null>;
40
+ onAuthStateChanged(callback: (user: UserProfile | null) => void): () => void;
41
+ }
42
+ interface TelemetryData {
43
+ cpu: number;
44
+ memory: string;
45
+ authState: "CONNECTED" | "DISCONNECTED";
46
+ power: number;
47
+ }
48
+ interface TerminalMessage {
49
+ id: string;
50
+ text: string;
51
+ timestamp: Date;
52
+ type: "info" | "success" | "error" | "warning";
53
+ }
54
+ interface AccessModalState {
55
+ open: boolean;
56
+ isSuccess: boolean;
57
+ title: string;
58
+ message: string;
59
+ }
60
+
61
+ declare function __resetMockAdapterStateForTests(): void;
62
+ declare class MockAuthAdapter implements AuthAdapter {
63
+ readonly name = "MockAuthAdapter";
64
+ private listeners;
65
+ private currentUser;
66
+ constructor();
67
+ private emit;
68
+ register(email: string, passkey: string, fullName: string): Promise<AuthResult>;
69
+ login(email: string, passkey: string): Promise<AuthResult>;
70
+ logout(): Promise<AuthResult>;
71
+ resetPassword(email: string): Promise<AuthResult>;
72
+ /** Resolve a full profile for an email (falls back to a minimal profile). */
73
+ private resolveUserByEmail;
74
+ /** Stamp, persist and broadcast an authenticated user. */
75
+ private commitUser;
76
+ private markBiometricsEnrolled;
77
+ /** Shared real WebAuthn platform-biometric login gate (face + fingerprint). */
78
+ private platformBiometricLogin;
79
+ verifyFace(): Promise<AuthResult>;
80
+ verifyVoice(audioBlob: Blob): Promise<AuthResult>;
81
+ verifyFingerprint(): Promise<AuthResult>;
82
+ enrollBiometrics(_userId: string): Promise<AuthResult>;
83
+ enrollVoice(audioBlob: Blob): Promise<AuthResult>;
84
+ verifyPasskey(_email?: string): Promise<AuthResult>;
85
+ getCurrentUser(): Promise<UserProfile | null>;
86
+ onAuthStateChanged(callback: (user: UserProfile | null) => void): () => void;
87
+ }
88
+ declare class BackendAuthAdapter implements AuthAdapter {
89
+ readonly name = "BackendAuthAdapter";
90
+ private listeners;
91
+ private currentUser;
92
+ private baseUrl;
93
+ constructor(baseUrl?: string);
94
+ private emit;
95
+ private request;
96
+ register(email: string, passkey: string, fullName: string): Promise<AuthResult>;
97
+ login(email: string, passkey: string): Promise<AuthResult>;
98
+ logout(): Promise<AuthResult>;
99
+ resetPassword(email: string): Promise<AuthResult>;
100
+ /** Establish a session with the backend after a successful local biometric gate. */
101
+ private biometricLogin;
102
+ verifyFace(): Promise<AuthResult>;
103
+ verifyVoice(audioBlob: Blob): Promise<AuthResult>;
104
+ verifyFingerprint(): Promise<AuthResult>;
105
+ enrollBiometrics(_userId: string): Promise<AuthResult>;
106
+ enrollVoice(audioBlob: Blob): Promise<AuthResult>;
107
+ verifyPasskey(_email?: string): Promise<AuthResult>;
108
+ getCurrentUser(): Promise<UserProfile | null>;
109
+ onAuthStateChanged(callback: (user: UserProfile | null) => void): () => void;
110
+ }
111
+ type AuthAdapterName = "mock" | "backend" | "firebase";
112
+ declare function createAuthAdapter(kind?: AuthAdapterName, options?: {
113
+ baseUrl?: string;
114
+ }): AuthAdapter;
115
+
116
+ interface AuthContextValue {
117
+ user: UserProfile | null;
118
+ status: AuthStatus;
119
+ error: string | null;
120
+ adapter: AuthAdapter;
121
+ adapterName: AuthAdapterName;
122
+ audioEnabled: boolean;
123
+ activeMethod: BiometricMethod;
124
+ isRegisterMode: boolean;
125
+ terminalText: string;
126
+ modal: AccessModalState;
127
+ login: (email: string, passkey: string) => Promise<void>;
128
+ register: (email: string, passkey: string, fullName: string) => Promise<void>;
129
+ logout: () => Promise<void>;
130
+ resetPassword: (email: string) => Promise<void>;
131
+ verifyFace: () => Promise<void>;
132
+ verifyVoice: (audioBlob: Blob) => Promise<void>;
133
+ verifyFingerprint: () => Promise<void>;
134
+ enrollBiometrics: () => Promise<void>;
135
+ enrollVoice: (audioBlob: Blob) => Promise<void>;
136
+ verifyPasskey: () => Promise<AuthResult>;
137
+ setActiveMethod: (method: BiometricMethod) => void;
138
+ toggleMode: () => void;
139
+ toggleAudio: () => void;
140
+ updateTerminal: (msg: string) => void;
141
+ showModal: (isSuccess: boolean, title: string, message: string) => void;
142
+ closeModal: () => void;
143
+ playBeep: (freq?: number, type?: OscillatorType, duration?: number) => void;
144
+ playSuccess: () => void;
145
+ playError: () => void;
146
+ }
147
+ declare function AuthProvider({ children, adapter: adapterArg, adapterOptions, }: {
148
+ children: ReactNode;
149
+ adapter?: AuthAdapterName | AuthAdapter;
150
+ adapterOptions?: {
151
+ baseUrl?: string;
152
+ };
153
+ }): react.JSX.Element;
154
+ declare function useAuth(): AuthContextValue;
155
+
156
+ declare class SoundEngine {
157
+ private ctx;
158
+ private ensureContext;
159
+ playBeep(freq?: number, type?: OscillatorType, duration?: number, gain?: number): void;
160
+ playSuccess(): void;
161
+ playError(): void;
162
+ unlock(): void;
163
+ }
164
+
165
+ declare function AuthPortal(): react.JSX.Element;
166
+
167
+ declare function ArcReactorHud(): react.JSX.Element;
168
+
169
+ declare function CanvasBackground(): react.JSX.Element;
170
+
171
+ declare function PasskeyForm(): react.JSX.Element;
172
+
173
+ /**
174
+ * Real device face authentication.
175
+ *
176
+ * This does NOT do a fake camera capture. It invokes the OS-level WebAuthn
177
+ * platform authenticator (Windows Hello / Face ID), which owns the camera and
178
+ * performs the genuine biometric match. The raw face data never reaches this
179
+ * app — the OS returns a signed cryptographic assertion instead.
180
+ */
181
+ declare function FacialScanner(): react.JSX.Element;
182
+
183
+ interface VoiceScannerProps {
184
+ /**
185
+ * "enroll" extracts and stores a new voiceprint for the signed-in user.
186
+ * "verify" extracts a probe voiceprint and matches it against enrolled ones.
187
+ */
188
+ mode?: "enroll" | "verify";
189
+ }
190
+ /**
191
+ * Real voice authentication using client-side DSP.
192
+ *
193
+ * Records a genuine microphone sample, extracts an MFCC voiceprint entirely on
194
+ * device, and either stores it (enroll) or matches it 1:N against enrolled
195
+ * voiceprints (verify). No audio or voiceprint ever leaves the device.
196
+ */
197
+ declare function VoiceScanner({ mode }: VoiceScannerProps): react.JSX.Element;
198
+
199
+ /**
200
+ * Real device fingerprint authentication.
201
+ *
202
+ * This does NOT fabricate a scan string. It invokes the OS-level WebAuthn
203
+ * platform authenticator (Windows Hello fingerprint / Touch ID), which owns the
204
+ * sensor and performs the genuine match. The raw print never leaves the device.
205
+ */
206
+ declare function FingerprintPad(): react.JSX.Element;
207
+
208
+ export { type AccessModalState, ArcReactorHud, type AuthAdapter, type AuthAdapterName, type AuthContextValue, AuthPortal, AuthProvider, type AuthResult, type AuthStatus, BackendAuthAdapter, type BiometricMethod, CanvasBackground, type ClearanceLevel, FacialScanner, FingerprintPad, MockAuthAdapter, PasskeyForm, SoundEngine, type TelemetryData, type TerminalMessage, type UserProfile, VoiceScanner, __resetMockAdapterStateForTests, createAuthAdapter, useAuth };