@absolutejs/auth 0.45.6 → 0.45.7
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/index.d.ts +1 -0
- package/dist/index.js +101 -1
- package/dist/index.js.map +5 -4
- package/dist/webauthn/simpleWebAuthnAdapter.d.ts +2 -0
- package/package.json +8 -3
package/dist/index.d.ts
CHANGED
|
@@ -15274,6 +15274,7 @@ export * from './webauthn/adapter';
|
|
|
15274
15274
|
export * from './webauthn/config';
|
|
15275
15275
|
export * from './webauthn/types';
|
|
15276
15276
|
export { webauthnRoutes } from './webauthn/routes';
|
|
15277
|
+
export { createSimpleWebAuthnAdapter } from './webauthn/simpleWebAuthnAdapter';
|
|
15277
15278
|
export { createInMemoryWebAuthnCredentialStore } from './webauthn/inMemoryWebAuthnCredentialStore';
|
|
15278
15279
|
export { createNeonWebAuthnCredentialStore, createPostgresWebAuthnCredentialStore, webauthnCredentialsTable } from './webauthn/postgresWebAuthnCredentialStore';
|
|
15279
15280
|
export * from './organizations/config';
|
package/dist/index.js
CHANGED
|
@@ -25506,6 +25506,105 @@ var createInMemorySsoConnectionStore = () => {
|
|
|
25506
25506
|
}
|
|
25507
25507
|
};
|
|
25508
25508
|
};
|
|
25509
|
+
// src/webauthn/simpleWebAuthnAdapter.ts
|
|
25510
|
+
var createSimpleWebAuthnAdapter = async () => {
|
|
25511
|
+
const {
|
|
25512
|
+
generateAuthenticationOptions,
|
|
25513
|
+
generateRegistrationOptions,
|
|
25514
|
+
verifyAuthenticationResponse,
|
|
25515
|
+
verifyRegistrationResponse
|
|
25516
|
+
} = await import("@simplewebauthn/server");
|
|
25517
|
+
const toBase64Url3 = (bytes) => Buffer.from(bytes).toString("base64url");
|
|
25518
|
+
const fromBase64Url3 = (value) => new Uint8Array(Buffer.from(value, "base64url"));
|
|
25519
|
+
return {
|
|
25520
|
+
createAuthenticationOptions: async ({ allowCredentials, rpId }) => {
|
|
25521
|
+
const options = await generateAuthenticationOptions({
|
|
25522
|
+
allowCredentials: allowCredentials.map(({ id }) => ({
|
|
25523
|
+
id
|
|
25524
|
+
})),
|
|
25525
|
+
rpID: rpId
|
|
25526
|
+
});
|
|
25527
|
+
return {
|
|
25528
|
+
challenge: options.challenge,
|
|
25529
|
+
options: { ...options }
|
|
25530
|
+
};
|
|
25531
|
+
},
|
|
25532
|
+
createRegistrationOptions: async ({
|
|
25533
|
+
excludeCredentials,
|
|
25534
|
+
rpId,
|
|
25535
|
+
rpName,
|
|
25536
|
+
userDisplayName,
|
|
25537
|
+
userId,
|
|
25538
|
+
userName
|
|
25539
|
+
}) => {
|
|
25540
|
+
const options = await generateRegistrationOptions({
|
|
25541
|
+
excludeCredentials: excludeCredentials.map(({ id }) => ({
|
|
25542
|
+
id
|
|
25543
|
+
})),
|
|
25544
|
+
rpID: rpId,
|
|
25545
|
+
rpName,
|
|
25546
|
+
userDisplayName,
|
|
25547
|
+
userID: Uint8Array.from(new TextEncoder().encode(userId)),
|
|
25548
|
+
userName
|
|
25549
|
+
});
|
|
25550
|
+
return {
|
|
25551
|
+
challenge: options.challenge,
|
|
25552
|
+
options: { ...options }
|
|
25553
|
+
};
|
|
25554
|
+
},
|
|
25555
|
+
verifyAuthentication: async ({
|
|
25556
|
+
credential,
|
|
25557
|
+
expectedChallenge,
|
|
25558
|
+
expectedOrigin,
|
|
25559
|
+
expectedRPID,
|
|
25560
|
+
response
|
|
25561
|
+
}) => {
|
|
25562
|
+
const result = await verifyAuthenticationResponse({
|
|
25563
|
+
credential: {
|
|
25564
|
+
counter: credential.counter,
|
|
25565
|
+
id: credential.credentialId,
|
|
25566
|
+
publicKey: fromBase64Url3(credential.publicKey)
|
|
25567
|
+
},
|
|
25568
|
+
expectedChallenge,
|
|
25569
|
+
expectedOrigin,
|
|
25570
|
+
expectedRPID,
|
|
25571
|
+
response
|
|
25572
|
+
});
|
|
25573
|
+
return {
|
|
25574
|
+
newCounter: result.authenticationInfo?.newCounter,
|
|
25575
|
+
verified: result.verified
|
|
25576
|
+
};
|
|
25577
|
+
},
|
|
25578
|
+
verifyRegistration: async ({
|
|
25579
|
+
expectedChallenge,
|
|
25580
|
+
expectedOrigin,
|
|
25581
|
+
expectedRPID,
|
|
25582
|
+
response
|
|
25583
|
+
}) => {
|
|
25584
|
+
const result = await verifyRegistrationResponse({
|
|
25585
|
+
expectedChallenge,
|
|
25586
|
+
expectedOrigin,
|
|
25587
|
+
expectedRPID,
|
|
25588
|
+
response
|
|
25589
|
+
});
|
|
25590
|
+
if (!result.verified || !result.registrationInfo) {
|
|
25591
|
+
return { verified: false };
|
|
25592
|
+
}
|
|
25593
|
+
const { credential, credentialBackedUp, credentialDeviceType } = result.registrationInfo;
|
|
25594
|
+
return {
|
|
25595
|
+
credential: {
|
|
25596
|
+
backedUp: credentialBackedUp,
|
|
25597
|
+
counter: credential.counter,
|
|
25598
|
+
credentialId: credential.id,
|
|
25599
|
+
deviceType: credentialDeviceType,
|
|
25600
|
+
publicKey: toBase64Url3(credential.publicKey),
|
|
25601
|
+
transports: credential.transports
|
|
25602
|
+
},
|
|
25603
|
+
verified: true
|
|
25604
|
+
};
|
|
25605
|
+
}
|
|
25606
|
+
};
|
|
25607
|
+
};
|
|
25509
25608
|
// src/webauthn/inMemoryWebAuthnCredentialStore.ts
|
|
25510
25609
|
var cloneCredential2 = (value) => ({
|
|
25511
25610
|
...value,
|
|
@@ -26081,6 +26180,7 @@ export {
|
|
|
26081
26180
|
createTotpKeyUri,
|
|
26082
26181
|
createTamperEvidentSink,
|
|
26083
26182
|
createStatusList,
|
|
26183
|
+
createSimpleWebAuthnAdapter,
|
|
26084
26184
|
createSiemLogStream,
|
|
26085
26185
|
createSetupSession,
|
|
26086
26186
|
createSecretCipher,
|
|
@@ -26282,5 +26382,5 @@ export {
|
|
|
26282
26382
|
AuthIdentityConflictError
|
|
26283
26383
|
};
|
|
26284
26384
|
|
|
26285
|
-
//# debugId=
|
|
26385
|
+
//# debugId=936F4FF1936BF20064756E2164756E21
|
|
26286
26386
|
//# sourceMappingURL=index.js.map
|