@truly-you/trulyyou-web-sdk 0.1.23 → 0.1.25
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 +86 -0
- package/index.js +687 -0
- package/package.json +11 -34
- package/README.md +0 -57
- package/dist/index.d.ts +0 -2
- package/dist/index.esm.js +0 -9
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -9
- package/dist/index.js.map +0 -1
- package/dist/index.umd.js +0 -9
- package/dist/index.umd.js.map +0 -1
- package/dist/sdk/TrulyYouSDK.d.ts +0 -96
- package/dist/types.d.ts +0 -36
- package/rollup.config.js +0 -58
- package/src/index.ts +0 -3
- package/src/sdk/TrulyYouSDK.ts +0 -2023
- package/src/types.ts +0 -40
- package/tsconfig.json +0 -20
|
@@ -1,96 +0,0 @@
|
|
|
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
|
-
* Helper to get keyId by authFlowId from localStorage
|
|
15
|
-
* Keys are stored as: trulyYouKeyId_<authFlowId> with value being just the keyId
|
|
16
|
-
*/
|
|
17
|
-
private getKeyIdByAuthFlowId;
|
|
18
|
-
/**
|
|
19
|
-
* Fetch app branding from SDK backend
|
|
20
|
-
* Returns true if authFlowId was successfully loaded
|
|
21
|
-
*/
|
|
22
|
-
private fetchBranding;
|
|
23
|
-
/**
|
|
24
|
-
* Ensure authFlowId is loaded before proceeding with signing operations
|
|
25
|
-
* Throws error if authFlowId cannot be loaded
|
|
26
|
-
*/
|
|
27
|
-
private ensureAuthFlowIdLoaded;
|
|
28
|
-
/**
|
|
29
|
-
* Generate QR code with app icon overlaid in center
|
|
30
|
-
*/
|
|
31
|
-
private generateQRCodeWithIcon;
|
|
32
|
-
private getDefaultFrontendUrl;
|
|
33
|
-
private getDefaultApiUrl;
|
|
34
|
-
/**
|
|
35
|
-
* Detect if running on iOS device
|
|
36
|
-
*/
|
|
37
|
-
private isIOSDevice;
|
|
38
|
-
/**
|
|
39
|
-
* Detect if running on Safari browser
|
|
40
|
-
*/
|
|
41
|
-
private isSafariBrowser;
|
|
42
|
-
/**
|
|
43
|
-
* Detect if running on desktop device (not just viewport-based)
|
|
44
|
-
* Returns false if mockMobileDevice is enabled (treats as mobile)
|
|
45
|
-
*/
|
|
46
|
-
private isDesktopDevice;
|
|
47
|
-
/**
|
|
48
|
-
* Resolve target element from string selector or HTMLElement
|
|
49
|
-
*/
|
|
50
|
-
private resolveTargetElement;
|
|
51
|
-
/**
|
|
52
|
-
* Probe iframe to check if key exists in iframe's localStorage
|
|
53
|
-
* Also checks backend to verify key exists and is active
|
|
54
|
-
* REQUIRES authFlowId to be loaded first
|
|
55
|
-
* @param handoff - If true, probes for handoff keyId (with _handoff suffix)
|
|
56
|
-
*/
|
|
57
|
-
private probeIframeForKey;
|
|
58
|
-
/**
|
|
59
|
-
* Open enrollment popup and wait for completion
|
|
60
|
-
*/
|
|
61
|
-
private enrollWithPopup;
|
|
62
|
-
/**
|
|
63
|
-
* Sign with iframe (mobile device)
|
|
64
|
-
*/
|
|
65
|
-
private signWithIframe;
|
|
66
|
-
/**
|
|
67
|
-
* Sign with WebSocket handoff (desktop device)
|
|
68
|
-
*/
|
|
69
|
-
private signWithWebSocketHandoff;
|
|
70
|
-
/**
|
|
71
|
-
* Sign a payload with WebAuthn without a server-generated challenge
|
|
72
|
-
* Encodes the payload directly as the challenge
|
|
73
|
-
* Uses iframe to extract key from iframe's localStorage, not host
|
|
74
|
-
*/
|
|
75
|
-
signPayload(apiCallStructure: {
|
|
76
|
-
body: any;
|
|
77
|
-
uri: string;
|
|
78
|
-
method: string;
|
|
79
|
-
headers?: any;
|
|
80
|
-
}, signatureId?: string, existingKeyId?: string): Promise<SigningResult>;
|
|
81
|
-
/**
|
|
82
|
-
* Fetch with automatic payload signing
|
|
83
|
-
*/
|
|
84
|
-
fetchWithSignature(url: string, options?: FetchOptions): Promise<FetchResult>;
|
|
85
|
-
/**
|
|
86
|
-
* Public method to probe for keyId - checks localStorage first, then probes TrulyYou frontend via iframe
|
|
87
|
-
* Returns the keyId if found, null otherwise
|
|
88
|
-
* @param handoff - If true, probes for handoff keyId (with _handoff suffix)
|
|
89
|
-
*/
|
|
90
|
-
probeForKeyId(handoff?: boolean): Promise<string | null>;
|
|
91
|
-
/**
|
|
92
|
-
* Clear all keys (both handoff and non-handoff) from localStorage
|
|
93
|
-
* Clears from both same-origin localStorage and TrulyYou frontend's localStorage via iframe
|
|
94
|
-
*/
|
|
95
|
-
clearAllKeys(): Promise<void>;
|
|
96
|
-
}
|
package/dist/types.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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/rollup.config.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
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
DELETED