@micha.bigler/ui-core-micha 1.4.20 → 1.4.23
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/dist/auth/AuthContext.js +0 -1
- package/dist/auth/authApi.js +137 -378
- package/dist/components/MFAComponent.js +7 -7
- package/dist/components/MfaLoginComponent.js +6 -5
- package/dist/components/PasskeysComponent.js +5 -5
- package/dist/components/SecurityComponent.js +4 -3
- package/dist/components/SupportRecoveryRequestsTab.js +4 -4
- package/dist/components/UserInviteComponent.js +38 -0
- package/dist/components/UserListComponent.js +83 -0
- package/dist/pages/AccountPage.js +67 -23
- package/dist/pages/LoginPage.js +6 -5
- package/dist/pages/PasswordInvitePage.js +3 -3
- package/dist/pages/SignUpPage.js +3 -3
- package/dist/utils/authService.js +53 -0
- package/dist/utils/errors.js +33 -0
- package/dist/utils/webauthn.js +44 -0
- package/package.json +1 -1
- package/src/auth/AuthContext.jsx +0 -1
- package/src/auth/authApi.jsx +143 -478
- package/src/components/MFAComponent.jsx +7 -7
- package/src/components/MfaLoginComponent.jsx +6 -5
- package/src/components/PasskeysComponent.jsx +5 -5
- package/src/components/SecurityComponent.jsx +4 -3
- package/src/components/SupportRecoveryRequestsTab.jsx +4 -4
- package/src/components/UserInviteComponent.jsx +69 -0
- package/src/components/UserListComponent.jsx +167 -0
- package/src/pages/AccountPage.jsx +140 -47
- package/src/pages/LoginPage.jsx +6 -5
- package/src/pages/PasswordInvitePage.jsx +3 -3
- package/src/pages/SignUpPage.jsx +3 -3
- package/src/utils/authService.js +68 -0
- package/src/utils/errors.js +39 -0
- 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