@truly-you/trulyyou-web-sdk 0.1.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.
@@ -0,0 +1,77 @@
1
+ import { TrulyYouSDKConfig, FetchOptions, SigningResult, FetchResult } from '../types';
2
+ export declare class TrulyYouSDK {
3
+ private config;
4
+ private frontendUrl;
5
+ private apiUrl;
6
+ private authAppId;
7
+ private invisible;
8
+ private targetElement;
9
+ private brandingCache;
10
+ private realtimeUrl;
11
+ private mockMobileDevice;
12
+ constructor(config: TrulyYouSDKConfig);
13
+ /**
14
+ * Fetch app branding from SDK backend
15
+ */
16
+ private fetchBranding;
17
+ /**
18
+ * Generate QR code with app icon overlaid in center
19
+ */
20
+ private generateQRCodeWithIcon;
21
+ private getDefaultFrontendUrl;
22
+ private getDefaultApiUrl;
23
+ /**
24
+ * Detect if running on iOS device
25
+ */
26
+ private isIOSDevice;
27
+ /**
28
+ * Detect if running on Safari browser
29
+ */
30
+ private isSafariBrowser;
31
+ /**
32
+ * Detect if running on desktop device (not just viewport-based)
33
+ * Returns false if mockMobileDevice is enabled (treats as mobile)
34
+ */
35
+ private isDesktopDevice;
36
+ /**
37
+ * Resolve target element from string selector or HTMLElement
38
+ */
39
+ private resolveTargetElement;
40
+ /**
41
+ * Probe iframe to check if key exists in iframe's localStorage
42
+ * Also checks backend to verify key exists and is active
43
+ */
44
+ private probeIframeForKey;
45
+ /**
46
+ * Lightweight API call to check if key exists and is active in backend
47
+ * Calls SDK frontend which proxies to SDK backend
48
+ */
49
+ private checkKeyStatus;
50
+ /**
51
+ * Open enrollment popup and wait for completion
52
+ */
53
+ private enrollWithPopup;
54
+ /**
55
+ * Sign with iframe (mobile device)
56
+ */
57
+ private signWithIframe;
58
+ /**
59
+ * Sign with WebSocket handoff (desktop device)
60
+ */
61
+ private signWithWebSocketHandoff;
62
+ /**
63
+ * Sign a payload with WebAuthn without a server-generated challenge
64
+ * Encodes the payload directly as the challenge
65
+ * Uses iframe to extract key from iframe's localStorage, not host
66
+ */
67
+ signPayload(apiCallStructure: {
68
+ body: any;
69
+ uri: string;
70
+ method: string;
71
+ headers?: any;
72
+ }, signatureId?: string): Promise<SigningResult>;
73
+ /**
74
+ * Fetch with automatic payload signing
75
+ */
76
+ fetchWithSignature(url: string, options?: FetchOptions): Promise<FetchResult>;
77
+ }
@@ -0,0 +1,36 @@
1
+ export interface TrulyYouSDKConfig {
2
+ frontendUrl?: string;
3
+ apiUrl?: string;
4
+ appId?: string;
5
+ authAppId?: string;
6
+ invisible?: boolean;
7
+ targetElement?: string | HTMLElement;
8
+ spinnerColor?: string;
9
+ spinnerBgColor?: string;
10
+ spinnerTextColor?: string;
11
+ realtimeUrl?: string;
12
+ mockMobileDevice?: boolean;
13
+ pusherAppKey?: string;
14
+ pusherConfig?: {
15
+ wsHost?: string;
16
+ wsPort?: number;
17
+ cluster?: string;
18
+ forceTLS?: boolean;
19
+ encrypted?: boolean;
20
+ disableStats?: boolean;
21
+ enabledTransports?: string[];
22
+ };
23
+ }
24
+ export interface FetchOptions extends RequestInit {
25
+ headers?: Record<string, string>;
26
+ }
27
+ export interface SigningResult {
28
+ signature: string;
29
+ keyId: string;
30
+ signatureId?: string;
31
+ }
32
+ export interface FetchResult {
33
+ response: Response;
34
+ signature?: string;
35
+ signatureId?: string;
36
+ }
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@truly-you/trulyyou-web-sdk",
3
+ "version": "0.1.0",
4
+ "description": "TrulyYou Web SDK for secure authentication and payload signing",
5
+ "type": "module",
6
+ "main": "dist/index.esm.js",
7
+ "module": "dist/index.esm.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.esm.js",
12
+ "require": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "scripts": {
17
+ "build": "rollup -c",
18
+ "dev": "rollup -c -w",
19
+ "prepublishOnly": "npm run build"
20
+ },
21
+ "keywords": [
22
+ "trulyyou",
23
+ "authentication",
24
+ "webauthn",
25
+ "passkey",
26
+ "signing"
27
+ ],
28
+ "author": "Mona",
29
+ "license": "MIT",
30
+ "devDependencies": {
31
+ "@rollup/plugin-commonjs": "^25.0.7",
32
+ "@rollup/plugin-node-resolve": "^15.2.3",
33
+ "@rollup/plugin-typescript": "^11.1.6",
34
+ "@rollup/plugin-terser": "^0.4.4",
35
+ "@types/node": "^20.10.0",
36
+ "rollup": "^4.6.0",
37
+ "typescript": "^5.3.3"
38
+ },
39
+ "dependencies": {
40
+ "pusher-js": "^8.4.0-rc2"
41
+ }
42
+ }
43
+
@@ -0,0 +1,58 @@
1
+ import resolve from '@rollup/plugin-node-resolve';
2
+ import commonjs from '@rollup/plugin-commonjs';
3
+ import typescript from '@rollup/plugin-typescript';
4
+ import terser from '@rollup/plugin-terser';
5
+
6
+ const isDevelopment = process.env.NODE_ENV === 'development';
7
+
8
+ const baseConfig = {
9
+ input: 'src/index.ts',
10
+ plugins: [
11
+ resolve({
12
+ browser: true,
13
+ preferBuiltins: false
14
+ }),
15
+ commonjs(),
16
+ typescript({
17
+ tsconfig: './tsconfig.json',
18
+ declaration: true,
19
+ declarationDir: 'dist'
20
+ }),
21
+ !isDevelopment && terser()
22
+ ].filter(Boolean)
23
+ };
24
+
25
+ export default [
26
+ // CommonJS build
27
+ {
28
+ ...baseConfig,
29
+ output: {
30
+ file: 'dist/index.js',
31
+ format: 'cjs',
32
+ sourcemap: true,
33
+ exports: 'auto'
34
+ }
35
+ },
36
+
37
+ // ES Module build
38
+ {
39
+ ...baseConfig,
40
+ output: {
41
+ file: 'dist/index.esm.js',
42
+ format: 'es',
43
+ sourcemap: true
44
+ }
45
+ },
46
+
47
+ // UMD build for script tags
48
+ {
49
+ ...baseConfig,
50
+ output: {
51
+ file: 'dist/index.umd.js',
52
+ format: 'umd',
53
+ name: 'TrulyYouSDK',
54
+ sourcemap: true
55
+ }
56
+ }
57
+ ];
58
+
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { TrulyYouSDK } from './sdk/TrulyYouSDK'
2
+ export * from './types'
3
+