nskd-lbr 1.1.1 → 1.1.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # NoSkid Certificate Library
2
2
 
3
- A modern JavaScript library for verifying NoSkid certificates and implementing certificate-based authentication.
3
+ A modern JavaScript library for verifying NoSkid certificates.
4
4
 
5
5
  ## Table of Contents
6
6
 
@@ -8,7 +8,6 @@ A modern JavaScript library for verifying NoSkid certificates and implementing c
8
8
  - [Quick Start](#quick-start)
9
9
  - [Constructor Options](#constructor-options)
10
10
  - [Methods](#methods)
11
- - [Login with NoSkid](#login-with-noskid)
12
11
  - [Response Objects](#response-objects)
13
12
  - [Examples](#examples)
14
13
  - [Error Handling](#error-handling)
@@ -31,14 +30,14 @@ npm install nskd-lbr
31
30
  ```
32
31
 
33
32
  ```js
34
- const NskdLbr = require('nskd-lbr');
33
+ import NskdLbr from 'nskd-lbr';
35
34
  ```
36
35
 
37
36
  ## Quick Start
38
37
 
39
38
  ```js
40
39
  // Initialize the library
41
- const noskid = new NskdLbr(); //eventually specify parameters, well let the default ones here
40
+ const noskid = new NskdLbr();
42
41
 
43
42
  // Verify a certificate from file upload
44
43
  const fileInput = document.getElementById('certificate-file');
@@ -67,11 +66,6 @@ const noskid = new NskdLbr({
67
66
  strictCheck: true, // Validate local vs API data
68
67
  useLegacyAPI: false, // Use legacy API format
69
68
 
70
- // Login feature options
71
- loginEndpoint: '', // Login API endpoint
72
- onLoginSuccess: null, // Success callback function
73
- onLoginFail: null, // Failure callback function
74
-
75
69
  // Logging
76
70
  onLog: null // Custom logging function
77
71
  });
@@ -86,9 +80,6 @@ const noskid = new NskdLbr({
86
80
  | `timeout` | `number` | `10000` | API request timeout in milliseconds |
87
81
  | `strictCheck` | `boolean` | `true` | Compare local certificate data with API response |
88
82
  | `useLegacyAPI` | `boolean` | `false` | Use legacy API format (affects username/nickname field) |
89
- | `loginEndpoint` | `string` | `''` | Login API endpoint (required for login feature) |
90
- | `onLoginSuccess` | `function` | `null` | `(result, certData) => {}` - Called on successful login |
91
- | `onLoginFail` | `function` | `null` | `(error, certData) => {}` - Called on failed login |
92
83
  | `onLog` | `function` | `null` | `(message, level) => {}` - Custom logging function |
93
84
 
94
85
  ## Methods
@@ -97,7 +88,7 @@ const noskid = new NskdLbr({
97
88
 
98
89
  #### `loadFromFile(file)`
99
90
 
100
- Load and verify a certificate from a PNG file.'
91
+ Load and verify a certificate from a PNG file.
101
92
 
102
93
  **Parameters:**
103
94
  - `file` (`File`) - PNG certificate file from file input
@@ -168,7 +159,7 @@ console.log(details);
168
159
 
169
160
  #### `reset()`
170
161
 
171
- Reset all certificate data and close any open login modals.
162
+ Reset all certificate data.
172
163
 
173
164
  **Returns:** `void`
174
165
 
@@ -182,79 +173,6 @@ Log messages with different levels (when debug is enabled).
182
173
 
183
174
  **Returns:** `void`
184
175
 
185
- ## Login with NoSkid
186
-
187
- The library provides a complete login system with a responsive modal interface.
188
-
189
- If you want a clean login button, please use this one:
190
- ![button](https://raw.githubusercontent.com/douxxtech/noskid.today/refs/heads/main/misc/nskd-lbr/src/login.svg)
191
-
192
- ### `showLoginModal()`
193
-
194
- Display a login modal for certificate-based authentication.
195
-
196
- **Requirements:**
197
- - Browser environment only
198
- - `loginEndpoint` must be configured
199
- - Valid login API endpoint that accepts POST requests
200
-
201
- **Returns:** `Promise<LoginResult>`
202
-
203
- **Example:**
204
- ```js
205
- const noskid = new NskdLbr({
206
- loginEndpoint: 'https://your-api.com/login',
207
- onLoginSuccess: (result, certData) => {
208
- console.log('Welcome', certData.localUsername);
209
- // Redirect user, update UI, etc.
210
- },
211
- onLoginFail: (error, certData) => {
212
- console.error('Login failed:', error.message);
213
- // Show error message, etc.
214
- }
215
- });
216
-
217
- // Show login modal
218
- try {
219
- const loginResult = await noskid.showLoginModal();
220
- console.log('Login successful:', loginResult);
221
- } catch (error) {
222
- console.log('Login cancelled:', error.message);
223
- }
224
- ```
225
-
226
- ### Login API Format
227
-
228
- Your login endpoint should accept POST requests with this format:
229
-
230
- **Request:**
231
- ```json
232
- {
233
- "certificate": {
234
- "key": "a1b2c3d4e5f6789...",
235
- "username": "john_doe",
236
- "certificate_number": "12345",
237
- "percentage": 95,
238
- "country": "United States",
239
- "countryCode": "US",
240
- "creationDate": "2024-01-15 14:30:25"
241
- },
242
- "password": "user_password"
243
- }
244
- ```
245
-
246
- **Response:**
247
- ```json
248
- {
249
- "success": true,
250
- "message": "Login successful",
251
- "data": {
252
- "token": "jwt_token_here",
253
- "user": {...}
254
- }
255
- }
256
- ```
257
-
258
176
  ## Response Objects
259
177
 
260
178
  ### VerificationResult
@@ -286,16 +204,6 @@ interface CertificateData {
286
204
  }
287
205
  ```
288
206
 
289
- ### LoginResult
290
-
291
- ```js
292
- interface LoginResult {
293
- success: boolean; // Whether login was successful
294
- data: CertificateData; // Certificate data
295
- response: any; // API response from login endpoint
296
- }
297
- ```
298
-
299
207
  ## Examples
300
208
 
301
209
  ### Basic Certificate Verification
@@ -330,45 +238,6 @@ try {
330
238
  }
331
239
  ```
332
240
 
333
- ### Complete Login Implementation
334
-
335
- ```js
336
- const noskid = new NskdLbr({
337
- debug: true,
338
- loginEndpoint: 'https://api.yoursite.com/auth/noskid',
339
- onLoginSuccess: (result, certData) => {
340
- // Store authentication token
341
- localStorage.setItem('auth_token', result.response.token);
342
-
343
- // Update UI
344
- document.getElementById('login-btn').style.display = 'none';
345
- document.getElementById('user-info').textContent =
346
- `Welcome, ${certData.localUsername}!`;
347
-
348
- // Redirect or update application state
349
- window.location.href = '/dashboard';
350
- },
351
- onLoginFail: (error, certData) => {
352
- // Show error message
353
- alert(`Login failed: ${error.message}`);
354
-
355
- // Log for debugging
356
- console.error('Login error:', error);
357
- }
358
- });
359
-
360
- // Add login button event
361
- document.getElementById('noskid-login-btn').addEventListener('click', async () => {
362
- try {
363
- await noskid.showLoginModal();
364
- } catch (error) {
365
- if (error.message !== 'Login cancelled') {
366
- console.error('Login error:', error);
367
- }
368
- }
369
- });
370
- ```
371
-
372
241
  ### Custom Configuration
373
242
 
374
243
  ```js
@@ -395,25 +264,25 @@ try {
395
264
  const result = await noskid.loadFromFile(file);
396
265
 
397
266
  if (result.valid) {
398
- console.log('Certificate is valid');
267
+ console.log('Certificate is valid');
399
268
  } else {
400
269
  // Handle different failure reasons
401
270
  if (result.strictCheck && result.message.includes('mismatch')) {
402
- console.log('⚠️ Certificate data mismatch - try disabling strict check');
271
+ console.log('Certificate data mismatch - try disabling strict check');
403
272
  } else {
404
- console.log('Certificate verification failed:', result.message);
273
+ console.log('Certificate verification failed:', result.message);
405
274
  }
406
275
  }
407
276
  } catch (error) {
408
277
  // Handle different error types
409
278
  if (error.message.includes('timeout')) {
410
- console.log('🕐 Request timed out - server may be slow');
279
+ console.log('Request timed out - server may be slow');
411
280
  } else if (error.message.includes('PNG')) {
412
- console.log('📄 Invalid file format - please upload a PNG certificate');
281
+ console.log('Invalid file format - please upload a PNG certificate');
413
282
  } else if (error.message.includes('verification key')) {
414
- console.log('🔑 Invalid verification key format');
283
+ console.log('Invalid verification key format');
415
284
  } else {
416
- console.log('💥 Unexpected error:', error.message);
285
+ console.log('Unexpected error:', error.message);
417
286
  }
418
287
  }
419
288
  ```
@@ -431,8 +300,6 @@ The library provides detailed error messages for different failure scenarios:
431
300
  | `"No valid verification key found"` | Certificate missing key | Check certificate validity |
432
301
  | `"Request timeout"` | Network/server issues | Check connection, increase timeout |
433
302
  | `"Data mismatch"` | Local vs API data differs | Disable `strictCheck` or verify certificate |
434
- | `"Login endpoint is not configured"` | Missing login endpoint | Set `loginEndpoint` option |
435
- | `"Login modal is only available in browser"` | Node.js environment | Use in browser only |
436
303
 
437
304
  ### Best Practices
438
305
 
@@ -455,7 +322,7 @@ if (noskid.isValidCertificate()) {
455
322
  }
456
323
 
457
324
  // Reset state when needed
458
- noskid.reset(); // Clears all data and closes modals
325
+ noskid.reset(); // Clears all data
459
326
  ```
460
327
 
461
328
  ## Browser Support
@@ -488,7 +355,7 @@ This library is licensed under the NSDv1.0 License. See the [LICENSE](LICENSE) f
488
355
  ---
489
356
 
490
357
  **Need Help?**
491
- - 🐛 Issues: [GitHub Issues](https://github.com/douxxtech/noskid.today/issues)
358
+ - Issues: [GitHub Issues](https://github.com/dpipstudio/noskid.today/issues)
492
359
 
493
360
  <a align="center" href="https://github.com/douxxtech" target="_blank">
494
361
  <img src="https://madeby.douxx.tech"></img>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nskd-lbr",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "A JavaScript library for working with NoSkid certificates.",
5
5
  "main": "src/nskd-lbr.js",
6
6
  "scripts": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/douxxtech/noskid.today.git"
11
+ "url": "git+https://github.com/dpipstudio/noskid.today.git"
12
12
  },
13
13
  "keywords": [
14
14
  "noskid",
@@ -17,7 +17,7 @@
17
17
  "author": "Douxx",
18
18
  "license": "SEE LICENSE IN LICENSE",
19
19
  "bugs": {
20
- "url": "https://github.com/douxxtech/noskid.today/issues"
20
+ "url": "https://github.com/dpipstudio/noskid.today/issues"
21
21
  },
22
- "homepage": "https://github.com/douxxtech/noskid.today#readme"
22
+ "homepage": "https://github.com/dpipstudio/noskid.today#readme"
23
23
  }