@pelican-identity/react 1.2.0 → 1.2.2
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 +320 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# Pelican Identity React SDK
|
|
2
|
+
|
|
3
|
+
React SDK for Pelican authentication and identity verification on the web.
|
|
4
|
+
👉 **Pelican Dashboard:** https://dash.pelicanidentity.com
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
### Using npm
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @pelican-identity/react
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Using yarn
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
yarn add @pelican-identity/react
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Using pnpm
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add @pelican-identity/react
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Requirements
|
|
31
|
+
|
|
32
|
+
- React **17, 18, or 19**
|
|
33
|
+
- A modern browser environment
|
|
34
|
+
- A Pelican project configured in the Pelican dashboard
|
|
35
|
+
|
|
36
|
+
> This SDK is **browser-only** and must be used in client-side React components.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Required Setup
|
|
41
|
+
|
|
42
|
+
### 1. Whitelist your domain in Pelican Dashboard
|
|
43
|
+
|
|
44
|
+
You must add your website’s domain (e.g. `example.com`, `app.example.com`, or `localhost`) to your project’s whitelist in the Pelican dashboard.
|
|
45
|
+
|
|
46
|
+
Pelican validates **explicit domain ownership** on every authentication attempt.
|
|
47
|
+
👉 **Pelican Dashboard:** https://dash.pelicanidentity.com
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### 2. Client-side usage only (important)
|
|
52
|
+
|
|
53
|
+
If you are using **Next.js, Remix, or similar frameworks**, ensure the SDK is only initialized on the client.
|
|
54
|
+
|
|
55
|
+
For Next.js App Router:
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
"use client";
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
### Basic Usage
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
import { PelicanAuth } from "@pelican-identity/react";
|
|
69
|
+
|
|
70
|
+
export default function LoginPage() {
|
|
71
|
+
return (
|
|
72
|
+
<PelicanAuth
|
|
73
|
+
publicKey="your-business-public-key"
|
|
74
|
+
projectId="your-project-id"
|
|
75
|
+
authType="login"
|
|
76
|
+
onSuccess={(data) => {
|
|
77
|
+
console.log("Authentication successful:", data);
|
|
78
|
+
}}
|
|
79
|
+
onError={(error) => {
|
|
80
|
+
console.error("Authentication failed:", error);
|
|
81
|
+
}}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Complete Example
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
"use client";
|
|
93
|
+
|
|
94
|
+
import { useState } from "react";
|
|
95
|
+
import { PelicanAuth } from "@pelican-identity/react";
|
|
96
|
+
|
|
97
|
+
export default function Login() {
|
|
98
|
+
const [user, setUser] = useState(null);
|
|
99
|
+
const [error, setError] = useState<string | null>(null);
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<div style={{ maxWidth: 400, margin: "auto" }}>
|
|
103
|
+
<h2>Login to MyApp</h2>
|
|
104
|
+
|
|
105
|
+
<PelicanAuth
|
|
106
|
+
publicKey="your-business-public-key"
|
|
107
|
+
projectId="your-project-id"
|
|
108
|
+
authType="login"
|
|
109
|
+
onSuccess={(data) => {
|
|
110
|
+
setUser(data);
|
|
111
|
+
setError(null);
|
|
112
|
+
}}
|
|
113
|
+
onError={(err) => {
|
|
114
|
+
setError(err.message);
|
|
115
|
+
setUser(null);
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
118
|
+
|
|
119
|
+
{user && <p>Authenticated successfully</p>}
|
|
120
|
+
{error && <p style={{ color: "red" }}>{error}</p>}
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## API Reference
|
|
129
|
+
|
|
130
|
+
### `PelicanAuth`
|
|
131
|
+
|
|
132
|
+
Main authentication component.
|
|
133
|
+
|
|
134
|
+
#### Props
|
|
135
|
+
|
|
136
|
+
| Prop | Type | Required | Description |
|
|
137
|
+
| ----------------- | ------------------------------------------ | -------- | --------------------------------------------------- |
|
|
138
|
+
| `publicKey` | `string` | ✅ | Business public key from Pelican dashboard |
|
|
139
|
+
| `projectId` | `string` | ✅ | Project ID from Pelican dashboard |
|
|
140
|
+
| `authType` | `"signup" \| "login" \| "id-verification"` | ✅ | Authentication flow |
|
|
141
|
+
| `onSuccess` | `(data: IdentityResult) => void` | ✅ | Success callback containing authenticated user data |
|
|
142
|
+
| `onError` | `(error: Error) => void` | Optional | Error callback |
|
|
143
|
+
| `onStateChange` | `(state: AuthState) => void` | Optional | State change callback |
|
|
144
|
+
| `buttonComponent` | `ReactNode` | Optional | Custom trigger UI |
|
|
145
|
+
| `forceQRCode` | `boolean` | Optional | Always show QR code instead of deep link |
|
|
146
|
+
| `continuousMode` | `boolean` | Optional | Automatically restart auth after completion |
|
|
147
|
+
|
|
148
|
+
> If `publicKey` or `projectId` is invalid, Pelican will fail immediately.
|
|
149
|
+
|
|
150
|
+
## 👉 **Pelican Dashboard:** https://dash.pelicanidentity.com
|
|
151
|
+
|
|
152
|
+
## Authentication Flow
|
|
153
|
+
|
|
154
|
+
Pelican Web authentication works using:
|
|
155
|
+
|
|
156
|
+
- **QR codes** (desktop → mobile)
|
|
157
|
+
- **Deep links** (mobile browsers)
|
|
158
|
+
|
|
159
|
+
The SDK automatically chooses the best option based on the user’s device.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Authentication Response
|
|
164
|
+
|
|
165
|
+
When authentication completes successfully, Pelican returns a structured **identity result** to your application via the `onSuccess` callback.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Success Callback
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
onSuccess: (result: IdentityResult) => void;
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## IdentityResult
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
interface IdentityResult {
|
|
181
|
+
/** Deterministic unique user identifier specific to your business */
|
|
182
|
+
user_id: string;
|
|
183
|
+
|
|
184
|
+
/** Basic user profile and contact information (if available) */
|
|
185
|
+
user_data?: IUserData;
|
|
186
|
+
|
|
187
|
+
/** Identity document and liveness verification data */
|
|
188
|
+
id_verification: IKycData;
|
|
189
|
+
|
|
190
|
+
/** Download URLs for verified identity documents */
|
|
191
|
+
id_downloadurls?: {
|
|
192
|
+
front_of_card?: string;
|
|
193
|
+
back_of_card?: string;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## `user_id`
|
|
201
|
+
|
|
202
|
+
- A **stable, deterministic identifier** generated by Pelican.
|
|
203
|
+
- Unique **per business**, not global.
|
|
204
|
+
- Safe to store and use as your internal user reference.
|
|
205
|
+
- Does **not** expose personally identifiable information (PII).
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## User Data (`user_data`)
|
|
210
|
+
|
|
211
|
+
Returned when available and permitted by the authentication flow.
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
interface IUserData {
|
|
215
|
+
first_name?: string;
|
|
216
|
+
last_name?: string;
|
|
217
|
+
other_names?: string;
|
|
218
|
+
email?: IEmail;
|
|
219
|
+
phone?: IPhone;
|
|
220
|
+
dob?: string | Date;
|
|
221
|
+
gender?: "male" | "female" | "other";
|
|
222
|
+
country?: string;
|
|
223
|
+
state?: string;
|
|
224
|
+
city?: string;
|
|
225
|
+
address?: string;
|
|
226
|
+
occupation?: string;
|
|
227
|
+
company?: string;
|
|
228
|
+
website?: string;
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
All contact data returned by Pelican is **verified**.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Identity Verification (`id_verification`)
|
|
237
|
+
|
|
238
|
+
Returned for flows involving identity verification or KYC.
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
interface IKycData {
|
|
242
|
+
id: number;
|
|
243
|
+
status?: "Approved" | "Declined" | "In Review";
|
|
244
|
+
document_type?:
|
|
245
|
+
| "national id card"
|
|
246
|
+
| "passport"
|
|
247
|
+
| "driver's license"
|
|
248
|
+
| "residence permit";
|
|
249
|
+
document_number?: string;
|
|
250
|
+
nationality?: string;
|
|
251
|
+
age?: number;
|
|
252
|
+
verified_at?: string | Date;
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Authentication Flow Differences
|
|
259
|
+
|
|
260
|
+
| Auth Type | Returned Data |
|
|
261
|
+
| ----------------- | ------------------------------------------- |
|
|
262
|
+
| `signup` | `user_id`, basic `user_data` |
|
|
263
|
+
| `login` | `user_id` |
|
|
264
|
+
| `id-verification` | `user_id`, `id_verification`, document URLs |
|
|
265
|
+
|
|
266
|
+
Returned fields depend on:
|
|
267
|
+
|
|
268
|
+
- User consent
|
|
269
|
+
- Project configuration
|
|
270
|
+
- Regulatory requirements
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Troubleshooting
|
|
275
|
+
|
|
276
|
+
### Blank page or no QR code
|
|
277
|
+
|
|
278
|
+
- Ensure the SDK is running client-side
|
|
279
|
+
- Confirm your domain is whitelisted
|
|
280
|
+
|
|
281
|
+
### Authentication never completes
|
|
282
|
+
|
|
283
|
+
- Ensure the browser tab regains focus after mobile authentication
|
|
284
|
+
|
|
285
|
+
### Unsupported authentication type
|
|
286
|
+
|
|
287
|
+
- Ensure `authType` is valid
|
|
288
|
+
|
|
289
|
+
### Billing issues, please contact this site owner
|
|
290
|
+
|
|
291
|
+
- Ensure your business wallet has sufficient balance
|
|
292
|
+
- Low balance alerts can be configured in the Pelican dashboard
|
|
293
|
+
👉 **Pelican Dashboard:** https://dash.pelicanidentity.com
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Security Notes
|
|
298
|
+
|
|
299
|
+
- All identity data is transmitted **encrypted**.
|
|
300
|
+
- Pelican never exposes raw credentials.
|
|
301
|
+
- Identifiers are scoped per business.
|
|
302
|
+
- Domains are validated on every authentication request.
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
### Final note
|
|
307
|
+
|
|
308
|
+
Pelican deliberately separates:
|
|
309
|
+
|
|
310
|
+
- **Identity** (who the user is)
|
|
311
|
+
- **Authentication** (this session)
|
|
312
|
+
- **Verification** (confidence level)
|
|
313
|
+
|
|
314
|
+
This ensures your web application remains secure, flexible, and compliant.
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## License
|
|
319
|
+
|
|
320
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pelican-identity/react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "React components for Pelican Identity authentication",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@pelican-identity/auth-core": "1.2.
|
|
24
|
+
"@pelican-identity/auth-core": "1.2.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/react": "^18.2.45",
|