@prabhask5/stellar-engine 1.0.11 → 1.0.13
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/README.md +31 -28
- package/dist/auth/deviceVerification.d.ts +57 -0
- package/dist/auth/deviceVerification.d.ts.map +1 -0
- package/dist/auth/deviceVerification.js +258 -0
- package/dist/auth/deviceVerification.js.map +1 -0
- package/dist/auth/resolveAuthState.d.ts.map +1 -1
- package/dist/auth/resolveAuthState.js +25 -83
- package/dist/auth/resolveAuthState.js.map +1 -1
- package/dist/auth/singleUser.d.ts +58 -8
- package/dist/auth/singleUser.d.ts.map +1 -1
- package/dist/auth/singleUser.js +345 -179
- package/dist/auth/singleUser.js.map +1 -1
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/entries/auth.d.ts +2 -2
- package/dist/entries/auth.d.ts.map +1 -1
- package/dist/entries/auth.js +2 -2
- package/dist/entries/auth.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/supabase/auth.d.ts +19 -1
- package/dist/supabase/auth.d.ts.map +1 -1
- package/dist/supabase/auth.js +66 -3
- package/dist/supabase/auth.js.map +1 -1
- package/dist/supabase/validate.d.ts +1 -1
- package/dist/supabase/validate.js +4 -4
- package/dist/supabase/validate.js.map +1 -1
- package/dist/types.d.ts +10 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Single-User Auth Module
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Uses Supabase email/password auth where the PIN *is* the password (padded).
|
|
5
|
+
* Replaces the previous anonymous auth + client-side SHA-256 hash approach.
|
|
6
|
+
*
|
|
7
|
+
* - Setup: signUp() with email + padded PIN
|
|
8
|
+
* - Unlock: signInWithPassword() with email + padded PIN
|
|
9
|
+
* - Device verification: signInWithOtp() for untrusted devices
|
|
10
|
+
* - Offline fallback: cached credentials in IndexedDB
|
|
7
11
|
*/
|
|
8
12
|
import type { SingleUserConfig } from '../types';
|
|
13
|
+
/**
|
|
14
|
+
* Pad a PIN to meet Supabase's minimum password length.
|
|
15
|
+
* e.g. "1234" → "1234_stellar" (12 chars, well above the 6-char minimum)
|
|
16
|
+
*/
|
|
17
|
+
export declare function padPin(pin: string): string;
|
|
9
18
|
/**
|
|
10
19
|
* Check if single-user mode has been set up (config exists in IndexedDB).
|
|
11
20
|
*/
|
|
@@ -18,19 +27,44 @@ export declare function getSingleUserInfo(): Promise<{
|
|
|
18
27
|
profile: Record<string, unknown>;
|
|
19
28
|
gateType: SingleUserConfig['gateType'];
|
|
20
29
|
codeLength?: 4 | 6;
|
|
30
|
+
email?: string;
|
|
31
|
+
maskedEmail?: string;
|
|
21
32
|
} | null>;
|
|
22
33
|
/**
|
|
23
|
-
* First-time setup:
|
|
24
|
-
*
|
|
34
|
+
* First-time setup: create Supabase user with email/password auth.
|
|
35
|
+
*
|
|
36
|
+
* Uses signUp() which sends a confirmation email if emailConfirmation is enabled.
|
|
37
|
+
* The PIN is padded to meet Supabase's minimum password length.
|
|
38
|
+
*
|
|
39
|
+
* @returns confirmationRequired — true if the caller should show a "check your email" modal
|
|
25
40
|
*/
|
|
26
|
-
export declare function setupSingleUser(gate: string, profile: Record<string, unknown
|
|
41
|
+
export declare function setupSingleUser(gate: string, profile: Record<string, unknown>, email: string): Promise<{
|
|
27
42
|
error: string | null;
|
|
43
|
+
confirmationRequired: boolean;
|
|
28
44
|
}>;
|
|
29
45
|
/**
|
|
30
|
-
*
|
|
46
|
+
* Complete setup after email confirmation succeeds.
|
|
47
|
+
* Called when the original tab receives AUTH_CONFIRMED via BroadcastChannel.
|
|
48
|
+
*/
|
|
49
|
+
export declare function completeSingleUserSetup(): Promise<{
|
|
50
|
+
error: string | null;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Unlock: verify PIN via signInWithPassword, handle device verification.
|
|
54
|
+
*
|
|
55
|
+
* Returns deviceVerificationRequired if the device is untrusted.
|
|
31
56
|
*/
|
|
32
57
|
export declare function unlockSingleUser(gate: string): Promise<{
|
|
33
58
|
error: string | null;
|
|
59
|
+
deviceVerificationRequired?: boolean;
|
|
60
|
+
maskedEmail?: string;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Complete device verification after OTP email link is clicked.
|
|
64
|
+
* Called when the original tab receives AUTH_CONFIRMED via BroadcastChannel.
|
|
65
|
+
*/
|
|
66
|
+
export declare function completeDeviceVerification(tokenHash?: string): Promise<{
|
|
67
|
+
error: string | null;
|
|
34
68
|
}>;
|
|
35
69
|
/**
|
|
36
70
|
* Lock: stop sync engine, reset auth state to 'none'.
|
|
@@ -38,7 +72,7 @@ export declare function unlockSingleUser(gate: string): Promise<{
|
|
|
38
72
|
*/
|
|
39
73
|
export declare function lockSingleUser(): Promise<void>;
|
|
40
74
|
/**
|
|
41
|
-
* Change the gate (code/password). Verifies old gate
|
|
75
|
+
* Change the gate (code/password). Verifies old gate via signInWithPassword.
|
|
42
76
|
*/
|
|
43
77
|
export declare function changeSingleUserGate(oldGate: string, newGate: string): Promise<{
|
|
44
78
|
error: string | null;
|
|
@@ -49,6 +83,22 @@ export declare function changeSingleUserGate(oldGate: string, newGate: string):
|
|
|
49
83
|
export declare function updateSingleUserProfile(profile: Record<string, unknown>): Promise<{
|
|
50
84
|
error: string | null;
|
|
51
85
|
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Initiate an email change. Requires online state.
|
|
88
|
+
* Supabase sends a confirmation email to the new address.
|
|
89
|
+
*/
|
|
90
|
+
export declare function changeSingleUserEmail(newEmail: string): Promise<{
|
|
91
|
+
error: string | null;
|
|
92
|
+
confirmationRequired: boolean;
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* Complete email change after the user confirms via the email link.
|
|
96
|
+
* Called when the original tab receives AUTH_CONFIRMED with type 'email_change'.
|
|
97
|
+
*/
|
|
98
|
+
export declare function completeSingleUserEmailChange(): Promise<{
|
|
99
|
+
error: string | null;
|
|
100
|
+
newEmail: string | null;
|
|
101
|
+
}>;
|
|
52
102
|
/**
|
|
53
103
|
* Full reset: clear config, sign out of Supabase, clear all data.
|
|
54
104
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleUser.d.ts","sourceRoot":"","sources":["../../src/auth/singleUser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"singleUser.d.ts","sourceRoot":"","sources":["../../src/auth/singleUser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAwBjD;;;GAGG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG1C;AAyBD;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAO1D;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC;IACjD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,IAAI,CAAC,CAUR;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,oBAAoB,EAAE,OAAO,CAAA;C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