@micha.bigler/ui-core-micha 1.4.20 → 1.4.22

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.
Files changed (33) hide show
  1. package/dist/auth/AuthContext.js +0 -1
  2. package/dist/auth/authApi.js +137 -378
  3. package/dist/components/MFAComponent.js +7 -7
  4. package/dist/components/MfaLoginComponent.js +6 -5
  5. package/dist/components/PasskeysComponent.js +5 -5
  6. package/dist/components/SecurityComponent.js +4 -3
  7. package/dist/components/SupportRecoveryRequestsTab.js +4 -4
  8. package/dist/components/UserInviteComponent.js +38 -0
  9. package/dist/components/UserListComponent.js +83 -0
  10. package/dist/pages/AccountPage.js +67 -23
  11. package/dist/pages/LoginPage.js +6 -5
  12. package/dist/pages/PasswordInvitePage.js +3 -3
  13. package/dist/pages/SignUpPage.js +3 -3
  14. package/dist/utils/authService.js +53 -0
  15. package/dist/utils/errors.js +33 -0
  16. package/dist/utils/webauthn.js +44 -0
  17. package/package.json +1 -1
  18. package/src/auth/AuthContext.jsx +0 -1
  19. package/src/auth/authApi.jsx +143 -478
  20. package/src/components/MFAComponent.jsx +7 -7
  21. package/src/components/MfaLoginComponent.jsx +6 -5
  22. package/src/components/PasskeysComponent.jsx +5 -5
  23. package/src/components/SecurityComponent.jsx +4 -3
  24. package/src/components/SupportRecoveryRequestsTab.jsx +4 -4
  25. package/src/components/UserInviteComponent.jsx +69 -0
  26. package/src/components/UserListComponent.jsx +167 -0
  27. package/src/pages/AccountPage.jsx +140 -47
  28. package/src/pages/LoginPage.jsx +6 -5
  29. package/src/pages/PasswordInvitePage.jsx +3 -3
  30. package/src/pages/SignUpPage.jsx +3 -3
  31. package/src/utils/authService.js +68 -0
  32. package/src/utils/errors.js +39 -0
  33. package/src/utils/webauthn.js +51 -0
@@ -0,0 +1,44 @@
1
+ // src/utils/webauthn.js
2
+ export function bufferToBase64URL(buffer) {
3
+ const bytes = new Uint8Array(buffer);
4
+ let str = '';
5
+ for (const char of bytes) {
6
+ str += String.fromCharCode(char);
7
+ }
8
+ const base64 = btoa(str);
9
+ return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
10
+ }
11
+ export function serializeCredential(credential) {
12
+ const p = {
13
+ id: credential.id,
14
+ rawId: bufferToBase64URL(credential.rawId),
15
+ type: credential.type,
16
+ response: {
17
+ clientDataJSON: bufferToBase64URL(credential.response.clientDataJSON),
18
+ },
19
+ };
20
+ if (credential.response.attestationObject) {
21
+ p.response.attestationObject = bufferToBase64URL(credential.response.attestationObject);
22
+ }
23
+ if (credential.response.authenticatorData) {
24
+ p.response.authenticatorData = bufferToBase64URL(credential.response.authenticatorData);
25
+ }
26
+ if (credential.response.signature) {
27
+ p.response.signature = bufferToBase64URL(credential.response.signature);
28
+ }
29
+ if (credential.response.userHandle) {
30
+ p.response.userHandle = bufferToBase64URL(credential.response.userHandle);
31
+ }
32
+ if (typeof credential.getClientExtensionResults === 'function') {
33
+ p.clientExtensionResults = credential.getClientExtensionResults();
34
+ }
35
+ return p;
36
+ }
37
+ export function ensureWebAuthnSupport() {
38
+ if (typeof window === 'undefined' ||
39
+ typeof navigator === 'undefined' ||
40
+ !window.PublicKeyCredential ||
41
+ !navigator.credentials) {
42
+ throw new Error('Auth.PASSKEY_NOT_SUPPORTED');
43
+ }
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micha.bigler/ui-core-micha",
3
- "version": "1.4.20",
3
+ "version": "1.4.22",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "private": false,
@@ -4,7 +4,6 @@ import React, {
4
4
  useState,
5
5
  useEffect,
6
6
  } from 'react';
7
- // REMOVED: import axios from 'axios'; -> Not needed here anymore
8
7
  import { ensureCsrfToken } from './apiClient'; // <--- IMPORT ADDED
9
8
  import {
10
9
  fetchCurrentUser,