@absolutejs/auth 0.45.6 → 0.45.8

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 CHANGED
@@ -15266,6 +15266,7 @@ export { ssoDiscoveryRoute } from './sso/discoveryRoute';
15266
15266
  export { oidcSsoRoutes } from './sso/oidcRoutes';
15267
15267
  export { samlIdpRoutes } from './sso/samlIdpRoutes';
15268
15268
  export { samlSsoRoutes } from './sso/samlRoutes';
15269
+ export { createNodeSamlAdapter } from './sso/nodeSamlAdapter';
15269
15270
  export { createInMemorySamlServiceProviderStore } from './sso/inMemorySamlServiceProviderStore';
15270
15271
  export { createInMemorySsoConnectionStore } from './sso/inMemorySsoConnectionStore';
15271
15272
  export { createNeonSamlServiceProviderStore, createPostgresSamlServiceProviderStore, samlServiceProvidersTable } from './sso/postgresSamlServiceProviderStore';
@@ -15274,6 +15275,7 @@ export * from './webauthn/adapter';
15274
15275
  export * from './webauthn/config';
15275
15276
  export * from './webauthn/types';
15276
15277
  export { webauthnRoutes } from './webauthn/routes';
15278
+ export { createSimpleWebAuthnAdapter } from './webauthn/simpleWebAuthnAdapter';
15277
15279
  export { createInMemoryWebAuthnCredentialStore } from './webauthn/inMemoryWebAuthnCredentialStore';
15278
15280
  export { createNeonWebAuthnCredentialStore, createPostgresWebAuthnCredentialStore, webauthnCredentialsTable } from './webauthn/postgresWebAuthnCredentialStore';
15279
15281
  export * from './organizations/config';
package/dist/index.js CHANGED
@@ -25462,6 +25462,57 @@ var samlIdpRoutes = ({
25462
25462
  ssoUrl: ssoUrlFor(request.url)
25463
25463
  })));
25464
25464
  };
25465
+ // src/sso/nodeSamlAdapter.ts
25466
+ var STANDARD_PROFILE_KEYS = new Set([
25467
+ "ID",
25468
+ "getAssertion",
25469
+ "getAssertionXml",
25470
+ "getSamlResponseXml",
25471
+ "issuer",
25472
+ "mainAttributes",
25473
+ "nameID",
25474
+ "nameIDFormat",
25475
+ "sessionIndex",
25476
+ "spNameQualifier"
25477
+ ]);
25478
+ var createNodeSamlAdapter = async () => {
25479
+ const { SAML } = await import("@node-saml/node-saml");
25480
+ const build = (acsUrl, connection) => {
25481
+ const spEntityId = new URL(acsUrl).origin;
25482
+ return new SAML({
25483
+ audience: spEntityId,
25484
+ callbackUrl: acsUrl,
25485
+ entryPoint: connection.config.idpSsoUrl,
25486
+ idpCert: connection.config.idpX509Cert,
25487
+ issuer: spEntityId,
25488
+ logoutUrl: connection.config.idpSloUrl,
25489
+ wantAssertionsSigned: true
25490
+ });
25491
+ };
25492
+ return {
25493
+ createAuthorizationUrl: ({ acsUrl, connection, relayState }) => build(acsUrl, connection).getAuthorizeUrlAsync(relayState ?? "", undefined, {}),
25494
+ getServiceProviderMetadata: ({ acsUrl, connection }) => build(acsUrl, connection).generateServiceProviderMetadata(null),
25495
+ validateAssertion: async ({ acsUrl, connection, samlResponse }) => {
25496
+ const { profile: profile2 } = await build(acsUrl, connection).validatePostResponseAsync({ SAMLResponse: samlResponse });
25497
+ if (!profile2) {
25498
+ throw new Error("SAML response contained no assertion profile");
25499
+ }
25500
+ const attributes = {};
25501
+ for (const [key, value] of Object.entries(profile2)) {
25502
+ if (!STANDARD_PROFILE_KEYS.has(key))
25503
+ attributes[key] = value;
25504
+ }
25505
+ const email = profile2.email ?? (profile2.nameID.includes("@") ? profile2.nameID : undefined);
25506
+ const result = {
25507
+ attributes,
25508
+ email,
25509
+ nameId: profile2.nameID,
25510
+ sessionIndex: profile2.sessionIndex
25511
+ };
25512
+ return result;
25513
+ }
25514
+ };
25515
+ };
25465
25516
  // src/sso/inMemorySamlServiceProviderStore.ts
25466
25517
  var createInMemorySamlServiceProviderStore = () => {
25467
25518
  const providers2 = new Map;
@@ -25506,6 +25557,105 @@ var createInMemorySsoConnectionStore = () => {
25506
25557
  }
25507
25558
  };
25508
25559
  };
25560
+ // src/webauthn/simpleWebAuthnAdapter.ts
25561
+ var createSimpleWebAuthnAdapter = async () => {
25562
+ const {
25563
+ generateAuthenticationOptions,
25564
+ generateRegistrationOptions,
25565
+ verifyAuthenticationResponse,
25566
+ verifyRegistrationResponse
25567
+ } = await import("@simplewebauthn/server");
25568
+ const toBase64Url3 = (bytes) => Buffer.from(bytes).toString("base64url");
25569
+ const fromBase64Url3 = (value) => new Uint8Array(Buffer.from(value, "base64url"));
25570
+ return {
25571
+ createAuthenticationOptions: async ({ allowCredentials, rpId }) => {
25572
+ const options = await generateAuthenticationOptions({
25573
+ allowCredentials: allowCredentials.map(({ id }) => ({
25574
+ id
25575
+ })),
25576
+ rpID: rpId
25577
+ });
25578
+ return {
25579
+ challenge: options.challenge,
25580
+ options: { ...options }
25581
+ };
25582
+ },
25583
+ createRegistrationOptions: async ({
25584
+ excludeCredentials,
25585
+ rpId,
25586
+ rpName,
25587
+ userDisplayName,
25588
+ userId,
25589
+ userName
25590
+ }) => {
25591
+ const options = await generateRegistrationOptions({
25592
+ excludeCredentials: excludeCredentials.map(({ id }) => ({
25593
+ id
25594
+ })),
25595
+ rpID: rpId,
25596
+ rpName,
25597
+ userDisplayName,
25598
+ userID: Uint8Array.from(new TextEncoder().encode(userId)),
25599
+ userName
25600
+ });
25601
+ return {
25602
+ challenge: options.challenge,
25603
+ options: { ...options }
25604
+ };
25605
+ },
25606
+ verifyAuthentication: async ({
25607
+ credential,
25608
+ expectedChallenge,
25609
+ expectedOrigin,
25610
+ expectedRPID,
25611
+ response
25612
+ }) => {
25613
+ const result = await verifyAuthenticationResponse({
25614
+ credential: {
25615
+ counter: credential.counter,
25616
+ id: credential.credentialId,
25617
+ publicKey: fromBase64Url3(credential.publicKey)
25618
+ },
25619
+ expectedChallenge,
25620
+ expectedOrigin,
25621
+ expectedRPID,
25622
+ response
25623
+ });
25624
+ return {
25625
+ newCounter: result.authenticationInfo?.newCounter,
25626
+ verified: result.verified
25627
+ };
25628
+ },
25629
+ verifyRegistration: async ({
25630
+ expectedChallenge,
25631
+ expectedOrigin,
25632
+ expectedRPID,
25633
+ response
25634
+ }) => {
25635
+ const result = await verifyRegistrationResponse({
25636
+ expectedChallenge,
25637
+ expectedOrigin,
25638
+ expectedRPID,
25639
+ response
25640
+ });
25641
+ if (!result.verified || !result.registrationInfo) {
25642
+ return { verified: false };
25643
+ }
25644
+ const { credential, credentialBackedUp, credentialDeviceType } = result.registrationInfo;
25645
+ return {
25646
+ credential: {
25647
+ backedUp: credentialBackedUp,
25648
+ counter: credential.counter,
25649
+ credentialId: credential.id,
25650
+ deviceType: credentialDeviceType,
25651
+ publicKey: toBase64Url3(credential.publicKey),
25652
+ transports: credential.transports
25653
+ },
25654
+ verified: true
25655
+ };
25656
+ }
25657
+ };
25658
+ };
25509
25659
  // src/webauthn/inMemoryWebAuthnCredentialStore.ts
25510
25660
  var cloneCredential2 = (value) => ({
25511
25661
  ...value,
@@ -26081,6 +26231,7 @@ export {
26081
26231
  createTotpKeyUri,
26082
26232
  createTamperEvidentSink,
26083
26233
  createStatusList,
26234
+ createSimpleWebAuthnAdapter,
26084
26235
  createSiemLogStream,
26085
26236
  createSetupSession,
26086
26237
  createSecretCipher,
@@ -26125,6 +26276,7 @@ export {
26125
26276
  createPostgresAccessTokenStore,
26126
26277
  createOrganization,
26127
26278
  createOAuthLinkedProviderCredentialResolver,
26279
+ createNodeSamlAdapter,
26128
26280
  createNeonWebhookDeliveryStore,
26129
26281
  createNeonWebAuthnCredentialStore,
26130
26282
  createNeonWarrantStore,
@@ -26282,5 +26434,5 @@ export {
26282
26434
  AuthIdentityConflictError
26283
26435
  };
26284
26436
 
26285
- //# debugId=E03238E021BE190464756E2164756E21
26437
+ //# debugId=CF175090287D988A64756E2164756E21
26286
26438
  //# sourceMappingURL=index.js.map