@pelican-identity/auth-core 1.2.9 → 1.2.11
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 +0 -13
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/engine/engine.d.ts +12 -5
- package/dist/engine/engine.d.ts.map +1 -1
- package/dist/engine/engine.js +123 -76
- package/dist/engine/engine.js.map +1 -1
- package/dist/index.d.mts +17 -6
- package/dist/index.d.ts +198 -8
- package/dist/index.js +613 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +222 -124
- package/dist/index.mjs.map +1 -1
- package/dist/utilities/transport.d.ts +4 -0
- package/dist/utilities/transport.d.ts.map +1 -1
- package/dist/utilities/transport.js +65 -11
- package/dist/utilities/transport.js.map +1 -1
- package/package.json +1 -1
- package/dist/types/types.d.ts +0 -102
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/types.js +0 -2
- package/dist/types/types.js.map +0 -1
- package/dist/utilities/crypto.d.ts +0 -18
- package/dist/utilities/crypto.d.ts.map +0 -1
- package/dist/utilities/crypto.js +0 -37
- package/dist/utilities/crypto.js.map +0 -1
- package/dist/utilities/stateMachine.d.ts +0 -9
- package/dist/utilities/stateMachine.d.ts.map +0 -1
- package/dist/utilities/stateMachine.js +0 -18
- package/dist/utilities/stateMachine.js.map +0 -1
- package/dist/utilities/storage.d.ts +0 -26
- package/dist/utilities/storage.d.ts.map +0 -1
- package/dist/utilities/storage.js +0 -92
- package/dist/utilities/storage.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,198 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
type AuthType = "login" | "signup" | "id-verification";
|
|
2
|
+
type PelicanAuthState = "idle" | "initializing" | "awaiting-pair" | "paired" | "awaiting-auth" | "authenticated" | "confirmed" | "error" | "terminated";
|
|
3
|
+
interface PelicanAuthConfig {
|
|
4
|
+
publicKey: string;
|
|
5
|
+
projectId: string;
|
|
6
|
+
authType: AuthType;
|
|
7
|
+
continuousMode?: boolean;
|
|
8
|
+
forceQRCode?: boolean;
|
|
9
|
+
}
|
|
10
|
+
type PelicanAuthEventMap = {
|
|
11
|
+
state: PelicanAuthState;
|
|
12
|
+
qr: string;
|
|
13
|
+
deeplink: string;
|
|
14
|
+
success: IdentityResult;
|
|
15
|
+
error: Error;
|
|
16
|
+
};
|
|
17
|
+
interface ISocketMessage {
|
|
18
|
+
type: "confirmed" | "request-passcode" | "client-terminated" | "phone-terminated" | "pair" | "paired" | "phone-auth-success" | "authenticate" | "confirm" | "register";
|
|
19
|
+
sessionID: string;
|
|
20
|
+
cipher?: string;
|
|
21
|
+
nonce?: string;
|
|
22
|
+
publicKey?: string;
|
|
23
|
+
url?: string;
|
|
24
|
+
authType?: AuthType;
|
|
25
|
+
projectId?: string;
|
|
26
|
+
grantedAttributes?: {
|
|
27
|
+
[key: string]: boolean;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
interface IPhone {
|
|
31
|
+
id: number;
|
|
32
|
+
country: string;
|
|
33
|
+
callingCode: string;
|
|
34
|
+
number: string;
|
|
35
|
+
verifiedAt: string;
|
|
36
|
+
verificationProvider: string;
|
|
37
|
+
}
|
|
38
|
+
interface IEmail {
|
|
39
|
+
id: number;
|
|
40
|
+
value: string;
|
|
41
|
+
verifiedAt: string;
|
|
42
|
+
verificationProvider: string;
|
|
43
|
+
}
|
|
44
|
+
type IdCardTypes = "national id card" | "passport" | "driver's license" | "residence permit";
|
|
45
|
+
interface IKycData {
|
|
46
|
+
id: number;
|
|
47
|
+
status?: "Approved" | "Declined" | "In Review";
|
|
48
|
+
document_type?: IdCardTypes;
|
|
49
|
+
document_number?: string;
|
|
50
|
+
personal_number?: string;
|
|
51
|
+
date_of_birth?: string | Date;
|
|
52
|
+
age?: number;
|
|
53
|
+
expiration_date?: string | Date;
|
|
54
|
+
date_of_issue?: string | Date;
|
|
55
|
+
issuing_state?: string;
|
|
56
|
+
issuing_state_name?: string;
|
|
57
|
+
first_name?: string;
|
|
58
|
+
last_name?: string;
|
|
59
|
+
full_name?: string;
|
|
60
|
+
gender?: string;
|
|
61
|
+
address?: string;
|
|
62
|
+
formatted_address?: string;
|
|
63
|
+
place_of_birth?: string;
|
|
64
|
+
marital_status?: string;
|
|
65
|
+
nationality?: string;
|
|
66
|
+
liveness_percentage?: number;
|
|
67
|
+
face_match_percentage?: number;
|
|
68
|
+
verified_at?: string | Date;
|
|
69
|
+
}
|
|
70
|
+
interface IUserData {
|
|
71
|
+
first_name?: string;
|
|
72
|
+
last_name?: string;
|
|
73
|
+
other_names?: string;
|
|
74
|
+
email?: IEmail;
|
|
75
|
+
phone?: IPhone;
|
|
76
|
+
dob?: string | Date;
|
|
77
|
+
gender?: "male" | "female" | "other";
|
|
78
|
+
country?: string;
|
|
79
|
+
state?: string;
|
|
80
|
+
city?: string;
|
|
81
|
+
address?: string;
|
|
82
|
+
occupation?: string;
|
|
83
|
+
company?: string;
|
|
84
|
+
website?: string;
|
|
85
|
+
}
|
|
86
|
+
interface IdentityResult {
|
|
87
|
+
user_id: string;
|
|
88
|
+
user_data?: IUserData;
|
|
89
|
+
id_verification: IKycData;
|
|
90
|
+
id_downloadurls?: {
|
|
91
|
+
front_of_card?: string;
|
|
92
|
+
back_of_card?: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
interface PelicanWebAuthProps extends PelicanAuthConfig {
|
|
96
|
+
onClose?: () => void;
|
|
97
|
+
onSuccess: (result: IdentityResult) => void;
|
|
98
|
+
onError?: (error: Error) => void;
|
|
99
|
+
buttonComponent?: React.ReactElement;
|
|
100
|
+
buttonText?: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
type Listener<T> = (payload: T) => void;
|
|
104
|
+
declare class PelicanAuthentication {
|
|
105
|
+
private readonly crypto;
|
|
106
|
+
private readonly stateMachine;
|
|
107
|
+
private transport?;
|
|
108
|
+
private sessionId;
|
|
109
|
+
private sessionKey;
|
|
110
|
+
private visibilityHandler?;
|
|
111
|
+
private backupCheckTimeout?;
|
|
112
|
+
private useWebSocket;
|
|
113
|
+
private listeners;
|
|
114
|
+
private readonly config;
|
|
115
|
+
constructor(config: PelicanAuthConfig);
|
|
116
|
+
on<K extends keyof PelicanAuthEventMap>(event: K, cb: Listener<PelicanAuthEventMap[K]>): () => boolean;
|
|
117
|
+
start(): Promise<void>;
|
|
118
|
+
stop(): void;
|
|
119
|
+
destroy(): void;
|
|
120
|
+
private shouldUseWebSocket;
|
|
121
|
+
private startWebSocketFlow;
|
|
122
|
+
private handleWebSocketMessage;
|
|
123
|
+
private handleAuthSuccess;
|
|
124
|
+
private startDeepLinkFlow;
|
|
125
|
+
private clearBackupCheck;
|
|
126
|
+
private checkSession;
|
|
127
|
+
private emitQRCode;
|
|
128
|
+
private emitDeepLink;
|
|
129
|
+
private attachVisibilityRecovery;
|
|
130
|
+
private detachVisibilityRecovery;
|
|
131
|
+
private fetchRelayUrl;
|
|
132
|
+
private terminate;
|
|
133
|
+
private restartIfContinuous;
|
|
134
|
+
private resetSession;
|
|
135
|
+
private emit;
|
|
136
|
+
private fail;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
interface EncryptedMessage {
|
|
140
|
+
cipher: string;
|
|
141
|
+
nonce: string;
|
|
142
|
+
}
|
|
143
|
+
declare class CryptoService {
|
|
144
|
+
generateSymmetricKey(): string;
|
|
145
|
+
encryptSymmetric({ plaintext, keyString, }: {
|
|
146
|
+
plaintext: string;
|
|
147
|
+
keyString: string;
|
|
148
|
+
}): EncryptedMessage;
|
|
149
|
+
decryptSymmetric({ encrypted, keyString, }: {
|
|
150
|
+
encrypted: EncryptedMessage;
|
|
151
|
+
keyString: string;
|
|
152
|
+
}): string | null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
declare class StateMachine {
|
|
156
|
+
private state;
|
|
157
|
+
private listeners;
|
|
158
|
+
get current(): PelicanAuthState;
|
|
159
|
+
transition(next: PelicanAuthState): void;
|
|
160
|
+
subscribe(fn: (s: PelicanAuthState) => void): () => boolean;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
type TransportHandlers = {
|
|
164
|
+
onOpen?: () => void;
|
|
165
|
+
onMessage?: (msg: ISocketMessage) => void;
|
|
166
|
+
onError?: (err: Event) => void;
|
|
167
|
+
onClose?: (ev: CloseEvent) => void;
|
|
168
|
+
};
|
|
169
|
+
declare class Transport {
|
|
170
|
+
private socket?;
|
|
171
|
+
private handlers;
|
|
172
|
+
private reconnectAttempts;
|
|
173
|
+
private maxReconnectAttempts;
|
|
174
|
+
private isExplicitlyClosed;
|
|
175
|
+
private url?;
|
|
176
|
+
private reconnectTimeout?;
|
|
177
|
+
private isReconnecting;
|
|
178
|
+
constructor(handlers: TransportHandlers);
|
|
179
|
+
connect(url: string): void;
|
|
180
|
+
private attemptReconnect;
|
|
181
|
+
send(payload: ISocketMessage): void;
|
|
182
|
+
close(): void;
|
|
183
|
+
get readyState(): number | undefined;
|
|
184
|
+
get isOpen(): boolean;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
interface AuthSession {
|
|
188
|
+
sessionId: string;
|
|
189
|
+
sessionKey: string;
|
|
190
|
+
}
|
|
191
|
+
declare const storeAuthSession: (sessionId: string, sessionKey: string, ttlMs?: number) => void;
|
|
192
|
+
declare const getAuthSession: () => AuthSession | null;
|
|
193
|
+
declare const clearAuthSession: () => void;
|
|
194
|
+
declare const clearAllAuthData: () => void;
|
|
195
|
+
|
|
196
|
+
declare const BASEURL = "http://192.168.1.9:8080";
|
|
197
|
+
|
|
198
|
+
export { type AuthSession, type AuthType, BASEURL, CryptoService, type IEmail, type IKycData, type IPhone, type ISocketMessage, type IUserData, type IdCardTypes, type IdentityResult, type PelicanAuthConfig, type PelicanAuthEventMap, type PelicanAuthState, PelicanAuthentication, type PelicanWebAuthProps, StateMachine, Transport, clearAllAuthData, clearAuthSession, getAuthSession, storeAuthSession };
|