@absolutejs/auth 0.62.0 → 0.63.0
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 +76 -60
- package/dist/index.js.map +5 -4
- package/dist/routes/requireAuth.d.ts +43 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +76 -60
- package/dist/server.js.map +6 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3454,6 +3454,7 @@ export { createOAuthAccountLinkedProviderCredentialResolver, type OAuthLinkedPro
|
|
|
3454
3454
|
export { createNeonLinkedProviderStores, createNeonOAuthLinkedProviderCredentialResolver } from './linkedProviders/neonStores';
|
|
3455
3455
|
export { createInMemoryLinkedProviderStores } from './linkedProviders/inMemoryStores';
|
|
3456
3456
|
export { protectRoutePlugin } from './routes/protectRoute';
|
|
3457
|
+
export { requireAuthPlugin } from './routes/requireAuth';
|
|
3457
3458
|
export { sessionRoutes } from './routes/sessions';
|
|
3458
3459
|
export { stepUpPlugin } from './routes/stepUp';
|
|
3459
3460
|
export * from './session/sessionsConfig';
|
package/dist/index.js
CHANGED
|
@@ -2982,7 +2982,7 @@ var createCustomOAuth2Client = (providerConfig, credentials) => buildOAuth2Clien
|
|
|
2982
2982
|
var createOAuth2Client = (providerName, config) => buildOAuth2Client(providers[providerName], config);
|
|
2983
2983
|
|
|
2984
2984
|
// src/index.ts
|
|
2985
|
-
import { Elysia as
|
|
2985
|
+
import { Elysia as Elysia46 } from "elysia";
|
|
2986
2986
|
|
|
2987
2987
|
// src/apikeys/routes.ts
|
|
2988
2988
|
import { Elysia, t } from "elysia";
|
|
@@ -31532,6 +31532,21 @@ var createInMemoryLinkedProviderStores = (input = {}) => {
|
|
|
31532
31532
|
};
|
|
31533
31533
|
return { bindingStore, grantStore };
|
|
31534
31534
|
};
|
|
31535
|
+
// src/routes/requireAuth.ts
|
|
31536
|
+
import { Elysia as Elysia41, t as t33 } from "elysia";
|
|
31537
|
+
var requireAuthPlugin = ({
|
|
31538
|
+
authSessionStore
|
|
31539
|
+
} = {}) => new Elysia41({
|
|
31540
|
+
name: "@absolutejs/auth/require-auth",
|
|
31541
|
+
seed: pluginDependencySeed(authSessionStore)
|
|
31542
|
+
}).use(sessionStore()).guard({ cookie: t33.Cookie({ user_session_id: userSessionIdTypebox }) }).resolve(async ({ store: { session }, cookie: { user_session_id } }) => {
|
|
31543
|
+
const { user } = await getStatusFromSource({
|
|
31544
|
+
authSessionStore,
|
|
31545
|
+
session,
|
|
31546
|
+
user_session_id
|
|
31547
|
+
});
|
|
31548
|
+
return { user: user ?? null };
|
|
31549
|
+
}).onBeforeHandle(({ user, status }) => user === null ? status("Unauthorized", "User is not authenticated") : undefined).as("global");
|
|
31535
31550
|
// src/session/impersonation.ts
|
|
31536
31551
|
init_constants();
|
|
31537
31552
|
var DEFAULT_IMPERSONATION_TTL_MS = MILLISECONDS_IN_AN_HOUR;
|
|
@@ -32950,7 +32965,7 @@ var createInMemoryCredentialOfferStore = () => {
|
|
|
32950
32965
|
};
|
|
32951
32966
|
};
|
|
32952
32967
|
// src/oidc/vciRoutes.ts
|
|
32953
|
-
import { Elysia as
|
|
32968
|
+
import { Elysia as Elysia42, t as t34 } from "elysia";
|
|
32954
32969
|
var HTTP_OK4 = 200;
|
|
32955
32970
|
var HTTP_BAD_REQUEST4 = 400;
|
|
32956
32971
|
var HTTP_UNAUTHORIZED5 = 401;
|
|
@@ -32975,7 +32990,7 @@ var vciRoutes = ({
|
|
|
32975
32990
|
const credentialRoute = `${vciRoute}/credential`;
|
|
32976
32991
|
const nonceRoute = `${vciRoute}/nonce`;
|
|
32977
32992
|
const vciSigningKey = vciConfig.signingKey ?? signingKey;
|
|
32978
|
-
return new
|
|
32993
|
+
return new Elysia42().get("/.well-known/openid-credential-issuer", () => Response.json(buildIssuerMetadata({
|
|
32979
32994
|
config: vciConfig,
|
|
32980
32995
|
issuer: issuerUrl,
|
|
32981
32996
|
vciRoute
|
|
@@ -32998,11 +33013,11 @@ var vciRoutes = ({
|
|
|
32998
33013
|
return errorBody(result.error, HTTP_BAD_REQUEST4);
|
|
32999
33014
|
return Response.json({ credential: result.credential, format: result.format }, { status: HTTP_OK4 });
|
|
33000
33015
|
}, {
|
|
33001
|
-
body:
|
|
33002
|
-
format:
|
|
33003
|
-
proof:
|
|
33004
|
-
jwt:
|
|
33005
|
-
proof_type:
|
|
33016
|
+
body: t34.Object({
|
|
33017
|
+
format: t34.Optional(t34.Union([t34.Literal("vc+sd-jwt")])),
|
|
33018
|
+
proof: t34.Optional(t34.Object({
|
|
33019
|
+
jwt: t34.String(),
|
|
33020
|
+
proof_type: t34.Literal("jwt")
|
|
33006
33021
|
}))
|
|
33007
33022
|
})
|
|
33008
33023
|
}).post(nonceRoute, async () => {
|
|
@@ -33124,7 +33139,7 @@ var verifyStatusListJwt = async ({
|
|
|
33124
33139
|
};
|
|
33125
33140
|
};
|
|
33126
33141
|
// src/vc/statusListRoutes.ts
|
|
33127
|
-
import { Elysia as
|
|
33142
|
+
import { Elysia as Elysia43, t as t35 } from "elysia";
|
|
33128
33143
|
var HTTP_OK5 = 200;
|
|
33129
33144
|
var HTTP_NOT_FOUND = 404;
|
|
33130
33145
|
var DEFAULT_STATUS_ROUTE = "/vc/status";
|
|
@@ -33136,7 +33151,7 @@ var statusListRoutes = ({
|
|
|
33136
33151
|
ttlSeconds
|
|
33137
33152
|
}) => {
|
|
33138
33153
|
const listRoute = `${statusRoute}/:listId`;
|
|
33139
|
-
return new
|
|
33154
|
+
return new Elysia43().get(listRoute, async ({ params: { listId } }) => {
|
|
33140
33155
|
const bits = await getStatusList(listId);
|
|
33141
33156
|
if (bits === undefined) {
|
|
33142
33157
|
return new Response("Not found", { status: HTTP_NOT_FOUND });
|
|
@@ -33152,7 +33167,7 @@ var statusListRoutes = ({
|
|
|
33152
33167
|
headers: { "content-type": STATUS_LIST_SUB_TYP },
|
|
33153
33168
|
status: HTTP_OK5
|
|
33154
33169
|
});
|
|
33155
|
-
}, { params:
|
|
33170
|
+
}, { params: t35.Object({ listId: t35.String() }) });
|
|
33156
33171
|
};
|
|
33157
33172
|
// src/vc/openid4vp.ts
|
|
33158
33173
|
init_crypto();
|
|
@@ -33357,7 +33372,7 @@ var createInMemoryPresentationRequestStore = () => {
|
|
|
33357
33372
|
};
|
|
33358
33373
|
};
|
|
33359
33374
|
// src/vc/vpRoutes.ts
|
|
33360
|
-
import { Elysia as
|
|
33375
|
+
import { Elysia as Elysia44, t as t36 } from "elysia";
|
|
33361
33376
|
var HTTP_OK6 = 200;
|
|
33362
33377
|
var HTTP_BAD_REQUEST5 = 400;
|
|
33363
33378
|
var HTTP_NOT_FOUND2 = 404;
|
|
@@ -33376,7 +33391,7 @@ var vpRoutes = ({
|
|
|
33376
33391
|
const authorizeRoute = `${vpRoute}/authorize`;
|
|
33377
33392
|
const requestRoute = `${vpRoute}/request/:id`;
|
|
33378
33393
|
const responseRoute = `${vpRoute}/response`;
|
|
33379
|
-
return new
|
|
33394
|
+
return new Elysia44().post(authorizeRoute, async ({ body }) => {
|
|
33380
33395
|
const input = {
|
|
33381
33396
|
clientId: body.client_id ?? defaultClientId,
|
|
33382
33397
|
requestedClaims: body.requested_claims,
|
|
@@ -33394,10 +33409,10 @@ var vpRoutes = ({
|
|
|
33394
33409
|
requestId: result.request.requestId
|
|
33395
33410
|
}, { status: HTTP_OK6 });
|
|
33396
33411
|
}, {
|
|
33397
|
-
body:
|
|
33398
|
-
client_id:
|
|
33399
|
-
requested_claims:
|
|
33400
|
-
state:
|
|
33412
|
+
body: t36.Object({
|
|
33413
|
+
client_id: t36.Optional(t36.String()),
|
|
33414
|
+
requested_claims: t36.Array(t36.String()),
|
|
33415
|
+
state: t36.Optional(t36.String())
|
|
33401
33416
|
})
|
|
33402
33417
|
}).get(requestRoute, async ({ params: { id } }) => {
|
|
33403
33418
|
const stored = await vpConfig.requestStore.getRequest(id);
|
|
@@ -33423,7 +33438,7 @@ var vpRoutes = ({
|
|
|
33423
33438
|
},
|
|
33424
33439
|
status: HTTP_OK6
|
|
33425
33440
|
});
|
|
33426
|
-
}, { params:
|
|
33441
|
+
}, { params: t36.Object({ id: t36.String() }) }).post(responseRoute, async ({ body }) => {
|
|
33427
33442
|
const requestId = body.state;
|
|
33428
33443
|
if (requestId === undefined) {
|
|
33429
33444
|
return errorBody2("missing_state", HTTP_BAD_REQUEST5);
|
|
@@ -33444,10 +33459,10 @@ var vpRoutes = ({
|
|
|
33444
33459
|
verified: true
|
|
33445
33460
|
}, { status: HTTP_OK6 });
|
|
33446
33461
|
}, {
|
|
33447
|
-
body:
|
|
33448
|
-
presentation_submission:
|
|
33449
|
-
state:
|
|
33450
|
-
vp_token:
|
|
33462
|
+
body: t36.Object({
|
|
33463
|
+
presentation_submission: t36.Optional(t36.Unknown()),
|
|
33464
|
+
state: t36.Optional(t36.String()),
|
|
33465
|
+
vp_token: t36.String()
|
|
33451
33466
|
})
|
|
33452
33467
|
});
|
|
33453
33468
|
};
|
|
@@ -36803,7 +36818,7 @@ var blockMigrations = {
|
|
|
36803
36818
|
webhooks: initMigration("webhooks", [webhookDeliveriesTable])
|
|
36804
36819
|
};
|
|
36805
36820
|
// src/sso/samlIdpRoutes.ts
|
|
36806
|
-
import { Elysia as
|
|
36821
|
+
import { Elysia as Elysia45, t as t37 } from "elysia";
|
|
36807
36822
|
var HTTP_BAD_REQUEST6 = 400;
|
|
36808
36823
|
var HTTP_UNAUTHORIZED6 = 401;
|
|
36809
36824
|
var HTTP_FOUND2 = 302;
|
|
@@ -36913,19 +36928,19 @@ var samlIdpRoutes = ({
|
|
|
36913
36928
|
user: userSession.user
|
|
36914
36929
|
});
|
|
36915
36930
|
};
|
|
36916
|
-
return new
|
|
36931
|
+
return new Elysia45().use(sessionStore()).post(ssoIdpRoute, async ({ body, cookie: { user_session_id }, request, store }) => handleSpInitiated({
|
|
36917
36932
|
binding: "POST",
|
|
36918
36933
|
body,
|
|
36919
36934
|
inMemorySession: store.session,
|
|
36920
36935
|
request,
|
|
36921
36936
|
userSessionIdValue: user_session_id.value
|
|
36922
36937
|
}), {
|
|
36923
|
-
body:
|
|
36924
|
-
RelayState:
|
|
36925
|
-
SAMLRequest:
|
|
36938
|
+
body: t37.Object({
|
|
36939
|
+
RelayState: t37.Optional(t37.String()),
|
|
36940
|
+
SAMLRequest: t37.Optional(t37.String())
|
|
36926
36941
|
}),
|
|
36927
|
-
cookie:
|
|
36928
|
-
user_session_id:
|
|
36942
|
+
cookie: t37.Cookie({
|
|
36943
|
+
user_session_id: t37.Optional(userSessionIdTypebox)
|
|
36929
36944
|
})
|
|
36930
36945
|
}).get(ssoIdpRoute, async ({ cookie: { user_session_id }, query, request, store }) => handleSpInitiated({
|
|
36931
36946
|
binding: "Redirect",
|
|
@@ -36934,14 +36949,14 @@ var samlIdpRoutes = ({
|
|
|
36934
36949
|
request,
|
|
36935
36950
|
userSessionIdValue: user_session_id.value
|
|
36936
36951
|
}), {
|
|
36937
|
-
cookie:
|
|
36938
|
-
user_session_id:
|
|
36952
|
+
cookie: t37.Cookie({
|
|
36953
|
+
user_session_id: t37.Optional(userSessionIdTypebox)
|
|
36939
36954
|
}),
|
|
36940
|
-
query:
|
|
36941
|
-
RelayState:
|
|
36942
|
-
SAMLRequest:
|
|
36943
|
-
SigAlg:
|
|
36944
|
-
Signature:
|
|
36955
|
+
query: t37.Object({
|
|
36956
|
+
RelayState: t37.Optional(t37.String()),
|
|
36957
|
+
SAMLRequest: t37.Optional(t37.String()),
|
|
36958
|
+
SigAlg: t37.Optional(t37.String()),
|
|
36959
|
+
Signature: t37.Optional(t37.String())
|
|
36945
36960
|
})
|
|
36946
36961
|
}).get(idpInitiateRoute, async ({
|
|
36947
36962
|
cookie: { user_session_id },
|
|
@@ -36977,12 +36992,12 @@ var samlIdpRoutes = ({
|
|
|
36977
36992
|
user: userSession.user
|
|
36978
36993
|
});
|
|
36979
36994
|
}, {
|
|
36980
|
-
cookie:
|
|
36981
|
-
user_session_id:
|
|
36995
|
+
cookie: t37.Cookie({
|
|
36996
|
+
user_session_id: t37.Optional(userSessionIdTypebox)
|
|
36982
36997
|
}),
|
|
36983
|
-
query:
|
|
36984
|
-
RelayState:
|
|
36985
|
-
sp:
|
|
36998
|
+
query: t37.Object({
|
|
36999
|
+
RelayState: t37.Optional(t37.String()),
|
|
37000
|
+
sp: t37.Optional(t37.String())
|
|
36986
37001
|
})
|
|
36987
37002
|
}).get(idpMetadataRoute, async ({ request }) => xmlResponse(await idpAdapter.getIdpMetadata({
|
|
36988
37003
|
entityId: idpEntityId,
|
|
@@ -37431,7 +37446,7 @@ var buildAuthApplications = async (configuration) => {
|
|
|
37431
37446
|
const auditedOnRevocationSuccess = auditEmit ? composeRevocationAudit(onRevocationSuccess, auditEmit) : onRevocationSuccess;
|
|
37432
37447
|
const auditedOnSignOut = auditEmit ? composeSignOutAudit(onSignOut, auditEmit) : onSignOut;
|
|
37433
37448
|
const pluginSeed = pluginDependencySeed(configuration);
|
|
37434
|
-
const coreRoutes = new
|
|
37449
|
+
const coreRoutes = new Elysia46({
|
|
37435
37450
|
name: "@absolutejs/auth/core-routes",
|
|
37436
37451
|
seed: pluginSeed
|
|
37437
37452
|
}).use([
|
|
@@ -37488,7 +37503,7 @@ var buildAuthApplications = async (configuration) => {
|
|
|
37488
37503
|
profileRoute
|
|
37489
37504
|
})
|
|
37490
37505
|
]);
|
|
37491
|
-
const featureRoutes = new
|
|
37506
|
+
const featureRoutes = new Elysia46({
|
|
37492
37507
|
name: "@absolutejs/auth/feature-routes",
|
|
37493
37508
|
seed: pluginSeed
|
|
37494
37509
|
}).use([
|
|
@@ -37497,64 +37512,64 @@ var buildAuthApplications = async (configuration) => {
|
|
|
37497
37512
|
authSessionStore,
|
|
37498
37513
|
cookieSecure: resolvedCookieSecure,
|
|
37499
37514
|
lockoutGuard
|
|
37500
|
-
}) : new
|
|
37515
|
+
}) : new Elysia46,
|
|
37501
37516
|
auditedMfa ? mfaRoutes({
|
|
37502
37517
|
...auditedMfa,
|
|
37503
37518
|
authSessionStore,
|
|
37504
37519
|
cookieSecure: resolvedCookieSecure,
|
|
37505
37520
|
verificationProvider
|
|
37506
|
-
}) : new
|
|
37521
|
+
}) : new Elysia46,
|
|
37507
37522
|
passwordless ? passwordlessRoutes({
|
|
37508
37523
|
...passwordless,
|
|
37509
37524
|
authSessionStore,
|
|
37510
37525
|
cookieSecure: resolvedCookieSecure,
|
|
37511
37526
|
emit: auditEmit
|
|
37512
|
-
}) : new
|
|
37513
|
-
sessions ? sessionRoutes({ ...sessions, authSessionStore }) : new
|
|
37527
|
+
}) : new Elysia46,
|
|
37528
|
+
sessions ? sessionRoutes({ ...sessions, authSessionStore }) : new Elysia46,
|
|
37514
37529
|
sso ? oidcSsoRoutes({
|
|
37515
37530
|
...sso,
|
|
37516
37531
|
authSessionStore,
|
|
37517
37532
|
cookieSecure: resolvedCookieSecure
|
|
37518
|
-
}) : new
|
|
37533
|
+
}) : new Elysia46,
|
|
37519
37534
|
sso && sso.samlAdapter ? samlSsoRoutes({
|
|
37520
37535
|
...sso,
|
|
37521
37536
|
authSessionStore,
|
|
37522
37537
|
cookieSecure: resolvedCookieSecure,
|
|
37523
37538
|
samlAdapter: sso.samlAdapter
|
|
37524
|
-
}) : new
|
|
37539
|
+
}) : new Elysia46,
|
|
37525
37540
|
sso && sso.getOrganizationByEmailDomain ? ssoDiscoveryRoute({
|
|
37526
37541
|
getOrganizationByEmailDomain: sso.getOrganizationByEmailDomain,
|
|
37527
37542
|
ssoConnectionStore: sso.ssoConnectionStore,
|
|
37528
37543
|
ssoRoute: sso.ssoRoute
|
|
37529
|
-
}) : new
|
|
37530
|
-
scim ? scimRoutes(scim) : new
|
|
37531
|
-
apikeys ? apiKeysRoutes(apikeys) : new
|
|
37544
|
+
}) : new Elysia46,
|
|
37545
|
+
scim ? scimRoutes(scim) : new Elysia46,
|
|
37546
|
+
apikeys ? apiKeysRoutes(apikeys) : new Elysia46,
|
|
37532
37547
|
oidcConfig ? oidcProviderRoutes({
|
|
37533
37548
|
...oidcConfig,
|
|
37534
37549
|
authSessionStore
|
|
37535
|
-
}) : new
|
|
37550
|
+
}) : new Elysia46,
|
|
37536
37551
|
organizations ? organizationRoutes({
|
|
37537
37552
|
...organizations,
|
|
37538
37553
|
authSessionStore,
|
|
37539
37554
|
emit: auditEmit
|
|
37540
|
-
}) : new
|
|
37555
|
+
}) : new Elysia46,
|
|
37541
37556
|
roles ? roleRoutes({
|
|
37542
37557
|
...roles,
|
|
37543
37558
|
authSessionStore,
|
|
37544
37559
|
emit: auditEmit
|
|
37545
|
-
}) : new
|
|
37546
|
-
portal ? portalRoutes({ ...portal, emit: auditEmit }) : new
|
|
37560
|
+
}) : new Elysia46,
|
|
37561
|
+
portal ? portalRoutes({ ...portal, emit: auditEmit }) : new Elysia46,
|
|
37547
37562
|
webauthn ? webauthnRoutes({
|
|
37548
37563
|
...webauthn,
|
|
37549
37564
|
authSessionStore,
|
|
37550
37565
|
cookieSecure: resolvedCookieSecure,
|
|
37551
37566
|
emit: auditEmit
|
|
37552
|
-
}) : new
|
|
37567
|
+
}) : new Elysia46,
|
|
37553
37568
|
compliance ? complianceRoutes({
|
|
37554
37569
|
...compliance,
|
|
37555
37570
|
authSessionStore,
|
|
37556
37571
|
emit: auditEmit
|
|
37557
|
-
}) : new
|
|
37572
|
+
}) : new Elysia46,
|
|
37558
37573
|
createConfiguredAuthHtmxRoutes({ authSessionStore, config: htmx }),
|
|
37559
37574
|
agentAuthRoutes(resolvedAgentAuth)
|
|
37560
37575
|
]);
|
|
@@ -37569,7 +37584,7 @@ var buildAuthApplications = async (configuration) => {
|
|
|
37569
37584
|
};
|
|
37570
37585
|
var auth = async (configuration) => {
|
|
37571
37586
|
const { authContext, coreRoutes, featureRoutes } = await buildAuthApplications(configuration);
|
|
37572
|
-
const application = new
|
|
37587
|
+
const application = new Elysia46({
|
|
37573
37588
|
name: "@absolutejs/auth",
|
|
37574
37589
|
seed: pluginDependencySeed(configuration)
|
|
37575
37590
|
});
|
|
@@ -37672,6 +37687,7 @@ export {
|
|
|
37672
37687
|
resolveAuthHtmxRenderers,
|
|
37673
37688
|
resolveApiPrincipal,
|
|
37674
37689
|
resolveAgentPrincipal,
|
|
37690
|
+
requireAuthPlugin,
|
|
37675
37691
|
removeFromSessionRing,
|
|
37676
37692
|
rehashCredentialPassword,
|
|
37677
37693
|
registerClient,
|
|
@@ -38084,5 +38100,5 @@ export {
|
|
|
38084
38100
|
AGENT_CLAIM_GRANT_TYPE
|
|
38085
38101
|
};
|
|
38086
38102
|
|
|
38087
|
-
//# debugId=
|
|
38103
|
+
//# debugId=A719E0625663B7E664756E2164756E21
|
|
38088
38104
|
//# sourceMappingURL=index.js.map
|