@pelican-identity/auth-core 1.2.9 → 1.2.10
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/index.d.ts +187 -8
- package/dist/index.js +515 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/constants.d.ts +0 -2
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -2
- package/dist/constants.js.map +0 -1
- package/dist/engine/engine.d.ts +0 -31
- package/dist/engine/engine.d.ts.map +0 -1
- package/dist/engine/engine.js +0 -238
- package/dist/engine/engine.js.map +0 -1
- package/dist/index.d.ts.map +0 -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/utilities/transport.d.ts +0 -22
- package/dist/utilities/transport.d.ts.map +0 -1
- package/dist/utilities/transport.js +0 -57
- package/dist/utilities/transport.js.map +0 -1
package/README.md
CHANGED
|
@@ -13,11 +13,6 @@ The Vanilla SDK provides a framework-agnostic way to integrate Pelican authentic
|
|
|
13
13
|
Ideal for projects without a build step. Includes the UI and logic in a single file.
|
|
14
14
|
|
|
15
15
|
```html
|
|
16
|
-
<link
|
|
17
|
-
rel="stylesheet"
|
|
18
|
-
href="https://cdn.jsdelivr.net/npm/@pelican-identity/vanilla@1.0.2/dist/pelican.css"
|
|
19
|
-
/>
|
|
20
|
-
|
|
21
16
|
<script src="https://cdn.jsdelivr.net/npm/@pelican-identity/vanilla@1.0.2/dist/index.min.js"></script>
|
|
22
17
|
|
|
23
18
|
<div id="pelican-auth-root"></div>
|
|
@@ -44,7 +39,6 @@ npm install @pelican-identity/vanilla
|
|
|
44
39
|
|
|
45
40
|
```typescript
|
|
46
41
|
import { createPelicanAuth } from "@pelican-identity/vanilla";
|
|
47
|
-
import "@pelican-identity/vanilla/dist/pelican.css";
|
|
48
42
|
|
|
49
43
|
const cleanup = createPelicanAuth("container-id", {
|
|
50
44
|
publicKey: "...",
|
|
@@ -164,11 +158,4 @@ interface IdentityResult {
|
|
|
164
158
|
**Cause:** The engine might be in `initializing` state or the domain isn't whitelisted.
|
|
165
159
|
**Fix:** Check your Pelican Dashboard and ensure your current domain (including port if applicable) is added to the project whitelist.
|
|
166
160
|
|
|
167
|
-
### Styles not applying
|
|
168
|
-
|
|
169
|
-
**Cause:** The CSS file is missing.
|
|
170
|
-
**Fix:** If using NPM, ensure you import `@pelican-identity/vanilla/dist/pelican.css`. If using the CDN `.min.js` version with `injectStyle: true`, this should be automatic.
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
161
|
**Would you like me to help you create a "Getting Started" guide specifically for the Pelican Dashboard setup to complement this SDK documentation?**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,187 @@
|
|
|
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 listeners;
|
|
112
|
+
private readonly config;
|
|
113
|
+
constructor(config: PelicanAuthConfig);
|
|
114
|
+
on<K extends keyof PelicanAuthEventMap>(event: K, cb: Listener<PelicanAuthEventMap[K]>): () => boolean;
|
|
115
|
+
start(): Promise<void>;
|
|
116
|
+
stop(): void;
|
|
117
|
+
private fetchRelayUrl;
|
|
118
|
+
private emitEntryPoint;
|
|
119
|
+
private handleMessage;
|
|
120
|
+
private handleAuthSuccess;
|
|
121
|
+
private getCachedEntry;
|
|
122
|
+
private attachVisibilityRecovery;
|
|
123
|
+
private detachVisibilityRecovery;
|
|
124
|
+
private terminate;
|
|
125
|
+
private restartIfContinuous;
|
|
126
|
+
private resetSession;
|
|
127
|
+
destroy(): void;
|
|
128
|
+
private emit;
|
|
129
|
+
private fail;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface EncryptedMessage {
|
|
133
|
+
cipher: string;
|
|
134
|
+
nonce: string;
|
|
135
|
+
}
|
|
136
|
+
declare class CryptoService {
|
|
137
|
+
generateSymmetricKey(): string;
|
|
138
|
+
encryptSymmetric({ plaintext, keyString, }: {
|
|
139
|
+
plaintext: string;
|
|
140
|
+
keyString: string;
|
|
141
|
+
}): EncryptedMessage;
|
|
142
|
+
decryptSymmetric({ encrypted, keyString, }: {
|
|
143
|
+
encrypted: EncryptedMessage;
|
|
144
|
+
keyString: string;
|
|
145
|
+
}): string | null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
declare class StateMachine {
|
|
149
|
+
private state;
|
|
150
|
+
private listeners;
|
|
151
|
+
get current(): PelicanAuthState;
|
|
152
|
+
transition(next: PelicanAuthState): void;
|
|
153
|
+
subscribe(fn: (s: PelicanAuthState) => void): () => boolean;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
type TransportHandlers = {
|
|
157
|
+
onOpen?: () => void;
|
|
158
|
+
onMessage?: (msg: ISocketMessage) => void;
|
|
159
|
+
onError?: (err: Event) => void;
|
|
160
|
+
onClose?: (ev: CloseEvent) => void;
|
|
161
|
+
};
|
|
162
|
+
declare class Transport {
|
|
163
|
+
private socket?;
|
|
164
|
+
private handlers;
|
|
165
|
+
private reconnectAttempts;
|
|
166
|
+
private maxReconnectAttempts;
|
|
167
|
+
private isExplicitlyClosed;
|
|
168
|
+
private url?;
|
|
169
|
+
constructor(handlers: TransportHandlers);
|
|
170
|
+
connect(url: string): void;
|
|
171
|
+
private attemptReconnect;
|
|
172
|
+
send(payload: ISocketMessage): void;
|
|
173
|
+
close(): void;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface AuthSession {
|
|
177
|
+
sessionId: string;
|
|
178
|
+
sessionKey: string;
|
|
179
|
+
}
|
|
180
|
+
declare const storeAuthSession: (sessionId: string, sessionKey: string, ttlMs?: number) => void;
|
|
181
|
+
declare const getAuthSession: () => AuthSession | null;
|
|
182
|
+
declare const clearAuthSession: () => void;
|
|
183
|
+
declare const clearAllAuthData: () => void;
|
|
184
|
+
|
|
185
|
+
declare const BASEURL = "https://identityapi.pelicanidentity.com";
|
|
186
|
+
|
|
187
|
+
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 };
|