@truly-you/trulyyou-web-sdk 0.1.24 → 0.1.26

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/index.d.ts ADDED
@@ -0,0 +1,86 @@
1
+ /**
2
+ * TrulyYou Web SDK - Client-side SDK for browser authentication
3
+ */
4
+ export class TrulyYouSDK {
5
+ constructor(config: {
6
+ appId: string;
7
+ mode?: 'visible' | 'hidden';
8
+ authUrl?: string;
9
+ apiUrl?: string;
10
+ targetElement?: string | HTMLElement;
11
+ mockMobile?: boolean;
12
+ });
13
+
14
+ /**
15
+ * Fetch with TrulyYou signature
16
+ */
17
+ fetchWithSignature(url: string, options?: RequestInit): Promise<Response>;
18
+
19
+ /**
20
+ * Get current configuration
21
+ */
22
+ getConfig(): {
23
+ appId: string;
24
+ mode: string;
25
+ authUrl: string;
26
+ mockMobile: boolean;
27
+ };
28
+
29
+ /**
30
+ * Update mockMobile setting
31
+ */
32
+ setMockMobile(enabled: boolean): void;
33
+
34
+ /**
35
+ * Update mode (visible/hidden)
36
+ */
37
+ setMode(mode: 'visible' | 'hidden'): void;
38
+ }
39
+
40
+ /**
41
+ * TrulyYou Server SDK - Server-side SDK for signature verification
42
+ */
43
+ export class TrulyYouServer {
44
+ constructor(config: {
45
+ appId: string;
46
+ secretKey: string;
47
+ apiUrl?: string;
48
+ });
49
+
50
+ /**
51
+ * Verify a signature from an incoming request
52
+ */
53
+ verifySignature(request: {
54
+ headers: Record<string, string | string[] | undefined>;
55
+ method: string;
56
+ url: string;
57
+ body?: string | object;
58
+ }): Promise<{
59
+ verified: boolean;
60
+ user?: {
61
+ _id?: string;
62
+ id?: string;
63
+ email?: string;
64
+ [key: string]: any;
65
+ };
66
+ verifications?: Record<string, any>;
67
+ authRequirementsMet?: boolean;
68
+ missingVerifications?: string[];
69
+ error?: string;
70
+ }>;
71
+
72
+ /**
73
+ * Express/Connect middleware for signature verification
74
+ */
75
+ middleware(options?: {
76
+ optional?: boolean;
77
+ onError?: (error: string, req: any, res: any, next: any) => void;
78
+ }): (req: any, res: any, next: any) => Promise<void>;
79
+ }
80
+
81
+ declare global {
82
+ interface Window {
83
+ TrulyYouSDK: typeof TrulyYouSDK;
84
+ TrulyYouServer: typeof TrulyYouServer;
85
+ }
86
+ }