@absolutejs/auth 0.35.0 → 0.36.0-beta.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/cli/migrate.js +16 -1
- package/dist/cli/migrate.js.map +4 -4
- package/dist/index.d.ts +32 -2
- package/dist/index.js +300 -1
- package/dist/index.js.map +8 -8
- package/dist/oidc/config.d.ts +72 -1
- package/dist/oidc/inMemoryStores.d.ts +2 -1
- package/dist/oidc/postgresStores.d.ts +214 -1
- package/dist/oidc/routes.d.ts +30 -0
- package/dist/oidc/types.d.ts +22 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13491,6 +13491,7 @@ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute,
|
|
|
13491
13491
|
resource?: string | undefined;
|
|
13492
13492
|
refresh_token?: string | undefined;
|
|
13493
13493
|
device_code?: string | undefined;
|
|
13494
|
+
auth_req_id?: string | undefined;
|
|
13494
13495
|
client_secret?: string | undefined;
|
|
13495
13496
|
grant_type?: string | undefined;
|
|
13496
13497
|
code?: string | undefined;
|
|
@@ -13613,6 +13614,35 @@ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute,
|
|
|
13613
13614
|
};
|
|
13614
13615
|
};
|
|
13615
13616
|
};
|
|
13617
|
+
} & {
|
|
13618
|
+
[x: string]: {
|
|
13619
|
+
post: {
|
|
13620
|
+
body: {
|
|
13621
|
+
client_id?: string | undefined;
|
|
13622
|
+
scope?: string | undefined;
|
|
13623
|
+
client_secret?: string | undefined;
|
|
13624
|
+
binding_message?: string | undefined;
|
|
13625
|
+
login_hint?: string | undefined;
|
|
13626
|
+
};
|
|
13627
|
+
params: {};
|
|
13628
|
+
query: unknown;
|
|
13629
|
+
headers: {
|
|
13630
|
+
authorization?: string | undefined;
|
|
13631
|
+
};
|
|
13632
|
+
response: {
|
|
13633
|
+
200: Response;
|
|
13634
|
+
422: {
|
|
13635
|
+
type: "validation";
|
|
13636
|
+
on: string;
|
|
13637
|
+
summary?: string;
|
|
13638
|
+
message?: string;
|
|
13639
|
+
found?: unknown;
|
|
13640
|
+
property?: string;
|
|
13641
|
+
expected?: string;
|
|
13642
|
+
};
|
|
13643
|
+
};
|
|
13644
|
+
};
|
|
13645
|
+
};
|
|
13616
13646
|
} & {
|
|
13617
13647
|
[x: string]: {
|
|
13618
13648
|
post: {
|
|
@@ -15124,12 +15154,12 @@ export type { DpopResult } from './oidc/dpop';
|
|
|
15124
15154
|
export { CLIENT_ASSERTION_TYPE, verifyClientAssertion, verifyJwtSignedByClient } from './oidc/clientAuth';
|
|
15125
15155
|
export { parseSignedRequestObject } from './oidc/jar';
|
|
15126
15156
|
export type { JarParseResult } from './oidc/jar';
|
|
15127
|
-
export { createInMemoryAuthorizationCodeStore, createInMemoryClientAssertionJtiStore, createInMemoryClientRegistrationTokenStore, createInMemoryDeviceAuthorizationStore, createInMemoryInitialAccessTokenStore, createInMemoryLogoutDeliveryStore, createInMemoryOAuthClientStore, createInMemoryOidcRefreshTokenStore, createInMemoryPushedAuthorizationRequestStore } from './oidc/inMemoryStores';
|
|
15157
|
+
export { createInMemoryAuthorizationCodeStore, createInMemoryBackchannelAuthStore, createInMemoryClientAssertionJtiStore, createInMemoryClientRegistrationTokenStore, createInMemoryDeviceAuthorizationStore, createInMemoryInitialAccessTokenStore, createInMemoryLogoutDeliveryStore, createInMemoryOAuthClientStore, createInMemoryOidcRefreshTokenStore, createInMemoryPushedAuthorizationRequestStore } from './oidc/inMemoryStores';
|
|
15128
15158
|
export { consumePushedRequest, pushAuthorizationRequest, DEFAULT_PAR_TTL_MS, REQUEST_URI_PREFIX } from './oidc/par';
|
|
15129
15159
|
export { fetchUserInfo, readUserInfoBearer, userInfoChallengeHeader } from './oidc/userinfo';
|
|
15130
15160
|
export type { UserInfoResult } from './oidc/userinfo';
|
|
15131
15161
|
export { fanOutBackchannelLogout, mintLogoutToken, resolvePostLogoutRedirect, verifyIdTokenHint } from './oidc/logout';
|
|
15132
|
-
export { createNeonAuthorizationCodeStore, createNeonClientAssertionJtiStore, createNeonClientRegistrationTokenStore, createNeonDeviceAuthorizationStore, createNeonInitialAccessTokenStore, createNeonLogoutDeliveryStore, createNeonOAuthClientStore, createNeonOidcRefreshTokenStore, createNeonPushedAuthorizationRequestStore, createPostgresAuthorizationCodeStore, createPostgresClientAssertionJtiStore, createPostgresClientRegistrationTokenStore, createPostgresDeviceAuthorizationStore, createPostgresInitialAccessTokenStore, createPostgresLogoutDeliveryStore, createPostgresOAuthClientStore, createPostgresOidcRefreshTokenStore, createPostgresPushedAuthorizationRequestStore, oauthClientAssertionJtisTable, oauthClientRegistrationTokensTable, oauthClientsTable, oauthCodesTable, oauthDeviceAuthorizationsTable, oauthInitialAccessTokensTable, oauthLogoutDeliveriesTable, oauthPushedAuthorizationRequestsTable, oauthRefreshTokensTable } from './oidc/postgresStores';
|
|
15162
|
+
export { createNeonAuthorizationCodeStore, createNeonBackchannelAuthStore, createNeonClientAssertionJtiStore, createNeonClientRegistrationTokenStore, createNeonDeviceAuthorizationStore, createNeonInitialAccessTokenStore, createNeonLogoutDeliveryStore, createNeonOAuthClientStore, createNeonOidcRefreshTokenStore, createNeonPushedAuthorizationRequestStore, createPostgresAuthorizationCodeStore, createPostgresBackchannelAuthStore, createPostgresClientAssertionJtiStore, createPostgresClientRegistrationTokenStore, createPostgresDeviceAuthorizationStore, createPostgresInitialAccessTokenStore, createPostgresLogoutDeliveryStore, createPostgresOAuthClientStore, createPostgresOidcRefreshTokenStore, createPostgresPushedAuthorizationRequestStore, oauthClientAssertionJtisTable, oauthClientRegistrationTokensTable, oauthClientsTable, oauthCodesTable, oauthBackchannelAuthRequestsTable, oauthDeviceAuthorizationsTable, oauthInitialAccessTokensTable, oauthLogoutDeliveriesTable, oauthPushedAuthorizationRequestsTable, oauthRefreshTokensTable } from './oidc/postgresStores';
|
|
15133
15163
|
export { deleteRegisteredClient, getRegisteredClient, registerClient, updateRegisteredClient, type ClientRegistrationDecision, type ClientRegistrationMetadata, type OnClientRegistration, type RegisterClientResult } from './oidc/registration';
|
|
15134
15164
|
export * from './adaptive/config';
|
|
15135
15165
|
export * from './adaptive/fingerprint';
|
package/dist/index.js
CHANGED
|
@@ -4790,6 +4790,126 @@ var exchangeDeviceCode = async ({
|
|
|
4790
4790
|
});
|
|
4791
4791
|
return { ...tokenSet, ok: true };
|
|
4792
4792
|
};
|
|
4793
|
+
var AUTH_REQ_ID_BYTES = 32;
|
|
4794
|
+
var DEFAULT_BACKCHANNEL_TTL_MINUTES = 10;
|
|
4795
|
+
var DEFAULT_BACKCHANNEL_TTL_MS = MILLISECONDS_IN_A_MINUTE * DEFAULT_BACKCHANNEL_TTL_MINUTES;
|
|
4796
|
+
var DEFAULT_BACKCHANNEL_POLL_INTERVAL_SECONDS = 5;
|
|
4797
|
+
var CIBA_GRANT_TYPE = "urn:openid:params:grant-type:ciba";
|
|
4798
|
+
var issueBackchannelAuth = async ({
|
|
4799
|
+
clientId,
|
|
4800
|
+
config,
|
|
4801
|
+
loginHint,
|
|
4802
|
+
bindingMessage,
|
|
4803
|
+
now = Date.now(),
|
|
4804
|
+
requestedScopes
|
|
4805
|
+
}) => {
|
|
4806
|
+
if (!config.backchannelAuthStore || !config.resolveBackchannelUser) {
|
|
4807
|
+
return { error: "invalid_request", ok: false };
|
|
4808
|
+
}
|
|
4809
|
+
const client = await config.clientStore.findClient(clientId);
|
|
4810
|
+
if (!client)
|
|
4811
|
+
return { error: "invalid_client", ok: false };
|
|
4812
|
+
const resolved = await config.resolveBackchannelUser({
|
|
4813
|
+
client,
|
|
4814
|
+
loginHint
|
|
4815
|
+
});
|
|
4816
|
+
if (!resolved)
|
|
4817
|
+
return { error: "unknown_user_id", ok: false };
|
|
4818
|
+
const authReqId = generateSecureToken(AUTH_REQ_ID_BYTES);
|
|
4819
|
+
const ttl = config.backchannelAuthTtlMs ?? DEFAULT_BACKCHANNEL_TTL_MS;
|
|
4820
|
+
const interval = config.backchannelPollIntervalSeconds ?? DEFAULT_BACKCHANNEL_POLL_INTERVAL_SECONDS;
|
|
4821
|
+
await config.backchannelAuthStore.saveBackchannelAuth({
|
|
4822
|
+
authReqId,
|
|
4823
|
+
bindingMessage,
|
|
4824
|
+
clientId,
|
|
4825
|
+
createdAt: now,
|
|
4826
|
+
expiresAt: now + ttl,
|
|
4827
|
+
intervalSeconds: interval,
|
|
4828
|
+
scopes: requestedScopes,
|
|
4829
|
+
status: "pending",
|
|
4830
|
+
userSub: resolved.sub
|
|
4831
|
+
});
|
|
4832
|
+
await config.onBackchannelAuthRequest?.({
|
|
4833
|
+
authReqId,
|
|
4834
|
+
bindingMessage,
|
|
4835
|
+
clientId,
|
|
4836
|
+
scopes: requestedScopes,
|
|
4837
|
+
userSub: resolved.sub
|
|
4838
|
+
});
|
|
4839
|
+
return {
|
|
4840
|
+
auth_req_id: authReqId,
|
|
4841
|
+
expires_in: Math.floor(ttl / MS_PER_SECOND),
|
|
4842
|
+
interval,
|
|
4843
|
+
ok: true
|
|
4844
|
+
};
|
|
4845
|
+
};
|
|
4846
|
+
var decideBackchannel = async (config, authReqId, approval) => {
|
|
4847
|
+
if (!config.backchannelAuthStore) {
|
|
4848
|
+
return { error: "not_configured", ok: false };
|
|
4849
|
+
}
|
|
4850
|
+
const record = await config.backchannelAuthStore.findByAuthReqId(authReqId);
|
|
4851
|
+
if (!record)
|
|
4852
|
+
return { error: "invalid_auth_req_id", ok: false };
|
|
4853
|
+
if (record.expiresAt < Date.now()) {
|
|
4854
|
+
return { error: "expired_token", ok: false };
|
|
4855
|
+
}
|
|
4856
|
+
if (record.status !== "pending") {
|
|
4857
|
+
return { error: "already_decided", ok: false };
|
|
4858
|
+
}
|
|
4859
|
+
await config.backchannelAuthStore.updateStatus(authReqId, approval.status, approval.userSub ?? record.userSub);
|
|
4860
|
+
return { ok: true };
|
|
4861
|
+
};
|
|
4862
|
+
var approveBackchannelAuth = async ({
|
|
4863
|
+
authReqId,
|
|
4864
|
+
config,
|
|
4865
|
+
userSub
|
|
4866
|
+
}) => decideBackchannel(config, authReqId, {
|
|
4867
|
+
status: "approved",
|
|
4868
|
+
userSub
|
|
4869
|
+
});
|
|
4870
|
+
var denyBackchannelAuth = async ({
|
|
4871
|
+
authReqId,
|
|
4872
|
+
config
|
|
4873
|
+
}) => decideBackchannel(config, authReqId, { status: "denied" });
|
|
4874
|
+
var exchangeBackchannelAuth = async ({
|
|
4875
|
+
authReqId,
|
|
4876
|
+
clientId,
|
|
4877
|
+
config,
|
|
4878
|
+
dpopJkt,
|
|
4879
|
+
now = Date.now()
|
|
4880
|
+
}) => {
|
|
4881
|
+
if (!config.backchannelAuthStore) {
|
|
4882
|
+
return { error: "invalid_grant", ok: false };
|
|
4883
|
+
}
|
|
4884
|
+
const record = await config.backchannelAuthStore.findByAuthReqId(authReqId);
|
|
4885
|
+
if (!record || record.clientId !== clientId) {
|
|
4886
|
+
return { error: "invalid_grant", ok: false };
|
|
4887
|
+
}
|
|
4888
|
+
if (record.expiresAt < now) {
|
|
4889
|
+
await config.backchannelAuthStore.deleteByAuthReqId(authReqId);
|
|
4890
|
+
return { error: "expired_token", ok: false };
|
|
4891
|
+
}
|
|
4892
|
+
if (record.lastPolledAt !== undefined && now - record.lastPolledAt < record.intervalSeconds * MS_PER_SECOND) {
|
|
4893
|
+
return { error: "slow_down", ok: false };
|
|
4894
|
+
}
|
|
4895
|
+
await config.backchannelAuthStore.recordPoll(authReqId, now);
|
|
4896
|
+
if (record.status === "pending") {
|
|
4897
|
+
return { error: "authorization_pending", ok: false };
|
|
4898
|
+
}
|
|
4899
|
+
if (record.status === "denied" || record.userSub === undefined) {
|
|
4900
|
+
return { error: "access_denied", ok: false };
|
|
4901
|
+
}
|
|
4902
|
+
await config.backchannelAuthStore.deleteByAuthReqId(authReqId);
|
|
4903
|
+
const tokenSet = await issueTokenSet({
|
|
4904
|
+
clientId,
|
|
4905
|
+
config,
|
|
4906
|
+
dpopJkt,
|
|
4907
|
+
now,
|
|
4908
|
+
scopes: record.scopes,
|
|
4909
|
+
sub: record.userSub
|
|
4910
|
+
});
|
|
4911
|
+
return { ...tokenSet, ok: true };
|
|
4912
|
+
};
|
|
4793
4913
|
|
|
4794
4914
|
// src/oidc/clientAuth.ts
|
|
4795
4915
|
var CLIENT_ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer";
|
|
@@ -5517,6 +5637,7 @@ var oidcProviderRoutes = (config) => {
|
|
|
5517
5637
|
const introspectRoute = `${oidcRoute}/introspect`;
|
|
5518
5638
|
const revokeRoute = `${oidcRoute}/revoke`;
|
|
5519
5639
|
const deviceAuthorizationRoute = `${oidcRoute}/device_authorization`;
|
|
5640
|
+
const backchannelAuthorizationRoute = `${oidcRoute}/bc-authorize`;
|
|
5520
5641
|
const deviceApproveRoute = `${oidcRoute}/device/decision`;
|
|
5521
5642
|
const endSessionRoute = `${oidcRoute}/end_session`;
|
|
5522
5643
|
const parRoute = `${oidcRoute}/par`;
|
|
@@ -5671,6 +5792,38 @@ var oidcProviderRoutes = (config) => {
|
|
|
5671
5792
|
token_type: dpopResult === undefined ? "Bearer" : "DPoP"
|
|
5672
5793
|
}, HTTP_OK2);
|
|
5673
5794
|
};
|
|
5795
|
+
const grantBackchannel = async (client, body, dpop) => {
|
|
5796
|
+
if (config.backchannelAuthStore === undefined) {
|
|
5797
|
+
return oauthError2(HTTP_BAD_REQUEST2, "unsupported_grant_type");
|
|
5798
|
+
}
|
|
5799
|
+
if (body.auth_req_id === undefined) {
|
|
5800
|
+
return oauthError2(HTTP_BAD_REQUEST2, "invalid_request");
|
|
5801
|
+
}
|
|
5802
|
+
const dpopResult = dpop === undefined ? undefined : await verifyDpopProof({
|
|
5803
|
+
htm: "POST",
|
|
5804
|
+
htu: tokenUrl,
|
|
5805
|
+
proof: dpop
|
|
5806
|
+
});
|
|
5807
|
+
if (dpop !== undefined && dpopResult === undefined) {
|
|
5808
|
+
return oauthError2(HTTP_BAD_REQUEST2, "invalid_dpop_proof");
|
|
5809
|
+
}
|
|
5810
|
+
const result = await exchangeBackchannelAuth({
|
|
5811
|
+
authReqId: body.auth_req_id,
|
|
5812
|
+
clientId: client.clientId,
|
|
5813
|
+
config,
|
|
5814
|
+
dpopJkt: dpopResult?.jkt
|
|
5815
|
+
});
|
|
5816
|
+
if (!result.ok)
|
|
5817
|
+
return oauthError2(HTTP_BAD_REQUEST2, result.error);
|
|
5818
|
+
return jsonResponse({
|
|
5819
|
+
access_token: result.access_token,
|
|
5820
|
+
expires_in: result.expires_in,
|
|
5821
|
+
id_token: result.id_token,
|
|
5822
|
+
refresh_token: result.refresh_token,
|
|
5823
|
+
scope: result.scope,
|
|
5824
|
+
token_type: dpopResult === undefined ? "Bearer" : "DPoP"
|
|
5825
|
+
}, HTTP_OK2);
|
|
5826
|
+
};
|
|
5674
5827
|
const grantDeviceCode = async (client, body, dpop) => {
|
|
5675
5828
|
if (config.deviceAuthorizationStore === undefined) {
|
|
5676
5829
|
return oauthError2(HTTP_BAD_REQUEST2, "unsupported_grant_type");
|
|
@@ -5711,6 +5864,9 @@ var oidcProviderRoutes = (config) => {
|
|
|
5711
5864
|
if (config.deviceAuthorizationStore) {
|
|
5712
5865
|
grantTypes.push("urn:ietf:params:oauth:grant-type:device_code");
|
|
5713
5866
|
}
|
|
5867
|
+
if (config.backchannelAuthStore) {
|
|
5868
|
+
grantTypes.push(CIBA_GRANT_TYPE);
|
|
5869
|
+
}
|
|
5714
5870
|
const discovery = {
|
|
5715
5871
|
authorization_endpoint: `${issuer}${authorizeRoute}`,
|
|
5716
5872
|
backchannel_logout_session_supported: false,
|
|
@@ -5742,6 +5898,11 @@ var oidcProviderRoutes = (config) => {
|
|
|
5742
5898
|
if (config.deviceAuthorizationStore) {
|
|
5743
5899
|
discovery.device_authorization_endpoint = `${issuer}${deviceAuthorizationRoute}`;
|
|
5744
5900
|
}
|
|
5901
|
+
if (config.backchannelAuthStore) {
|
|
5902
|
+
discovery.backchannel_authentication_endpoint = `${issuer}${backchannelAuthorizationRoute}`;
|
|
5903
|
+
discovery.backchannel_token_delivery_modes_supported = ["poll"];
|
|
5904
|
+
discovery.backchannel_user_code_parameter_supported = false;
|
|
5905
|
+
}
|
|
5745
5906
|
if (config.clientRegistrationTokenStore !== undefined) {
|
|
5746
5907
|
discovery.registration_endpoint = registrationBaseUrl;
|
|
5747
5908
|
}
|
|
@@ -5964,10 +6125,14 @@ var oidcProviderRoutes = (config) => {
|
|
|
5964
6125
|
if (body.grant_type === "urn:ietf:params:oauth:grant-type:device_code") {
|
|
5965
6126
|
return grantDeviceCode(client, body, headers.dpop);
|
|
5966
6127
|
}
|
|
6128
|
+
if (body.grant_type === CIBA_GRANT_TYPE) {
|
|
6129
|
+
return grantBackchannel(client, body, headers.dpop);
|
|
6130
|
+
}
|
|
5967
6131
|
return oauthError2(HTTP_BAD_REQUEST2, "unsupported_grant_type");
|
|
5968
6132
|
}, {
|
|
5969
6133
|
body: t12.Object({
|
|
5970
6134
|
audience: t12.Optional(t12.String()),
|
|
6135
|
+
auth_req_id: t12.Optional(t12.String()),
|
|
5971
6136
|
client_assertion: t12.Optional(t12.String()),
|
|
5972
6137
|
client_assertion_type: t12.Optional(t12.String()),
|
|
5973
6138
|
client_id: t12.Optional(t12.String()),
|
|
@@ -6082,6 +6247,50 @@ var oidcProviderRoutes = (config) => {
|
|
|
6082
6247
|
headers: t12.Object({
|
|
6083
6248
|
authorization: t12.Optional(t12.String())
|
|
6084
6249
|
})
|
|
6250
|
+
}).post(backchannelAuthorizationRoute, async ({ body, headers }) => {
|
|
6251
|
+
if (config.backchannelAuthStore === undefined) {
|
|
6252
|
+
return oauthError2(HTTP_BAD_REQUEST2, "unsupported_grant_type");
|
|
6253
|
+
}
|
|
6254
|
+
const basic = readBasicAuth2(headers.authorization);
|
|
6255
|
+
const clientId = body.client_id ?? basic.clientId;
|
|
6256
|
+
const clientSecret = body.client_secret ?? basic.clientSecret;
|
|
6257
|
+
if (clientId === undefined) {
|
|
6258
|
+
return oauthError2(HTTP_UNAUTHORIZED2, "invalid_client");
|
|
6259
|
+
}
|
|
6260
|
+
const client = await authenticateClient(clientId, clientSecret);
|
|
6261
|
+
if (client === undefined) {
|
|
6262
|
+
return oauthError2(HTTP_UNAUTHORIZED2, "invalid_client");
|
|
6263
|
+
}
|
|
6264
|
+
if (body.login_hint === undefined) {
|
|
6265
|
+
return oauthError2(HTTP_BAD_REQUEST2, "invalid_request");
|
|
6266
|
+
}
|
|
6267
|
+
const requested = body.scope === undefined || body.scope.length === 0 ? client.scopes : body.scope.split(" ").filter((entry) => client.scopes.includes(entry));
|
|
6268
|
+
const result = await issueBackchannelAuth({
|
|
6269
|
+
bindingMessage: body.binding_message,
|
|
6270
|
+
clientId: client.clientId,
|
|
6271
|
+
config,
|
|
6272
|
+
loginHint: body.login_hint,
|
|
6273
|
+
now: Date.now(),
|
|
6274
|
+
requestedScopes: requested
|
|
6275
|
+
});
|
|
6276
|
+
if (!result.ok)
|
|
6277
|
+
return oauthError2(HTTP_BAD_REQUEST2, result.error);
|
|
6278
|
+
return jsonResponse({
|
|
6279
|
+
auth_req_id: result.auth_req_id,
|
|
6280
|
+
expires_in: result.expires_in,
|
|
6281
|
+
interval: result.interval
|
|
6282
|
+
}, HTTP_OK2);
|
|
6283
|
+
}, {
|
|
6284
|
+
body: t12.Object({
|
|
6285
|
+
binding_message: t12.Optional(t12.String()),
|
|
6286
|
+
client_id: t12.Optional(t12.String()),
|
|
6287
|
+
client_secret: t12.Optional(t12.String()),
|
|
6288
|
+
login_hint: t12.Optional(t12.String()),
|
|
6289
|
+
scope: t12.Optional(t12.String())
|
|
6290
|
+
}),
|
|
6291
|
+
headers: t12.Object({
|
|
6292
|
+
authorization: t12.Optional(t12.String())
|
|
6293
|
+
})
|
|
6085
6294
|
}).post(deviceAuthorizationRoute, async ({ body, headers }) => {
|
|
6086
6295
|
if (config.deviceAuthorizationStore === undefined) {
|
|
6087
6296
|
return oauthError2(HTTP_BAD_REQUEST2, "unsupported_grant_type");
|
|
@@ -21542,6 +21751,30 @@ var createInMemoryAuthorizationCodeStore = () => {
|
|
|
21542
21751
|
}
|
|
21543
21752
|
};
|
|
21544
21753
|
};
|
|
21754
|
+
var createInMemoryBackchannelAuthStore = () => {
|
|
21755
|
+
const byAuthReqId = new Map;
|
|
21756
|
+
return {
|
|
21757
|
+
deleteByAuthReqId: async (authReqId) => {
|
|
21758
|
+
byAuthReqId.delete(authReqId);
|
|
21759
|
+
},
|
|
21760
|
+
findByAuthReqId: async (authReqId) => byAuthReqId.get(authReqId),
|
|
21761
|
+
recordPoll: async (authReqId, polledAt) => {
|
|
21762
|
+
const record = byAuthReqId.get(authReqId);
|
|
21763
|
+
if (!record)
|
|
21764
|
+
return;
|
|
21765
|
+
byAuthReqId.set(authReqId, { ...record, lastPolledAt: polledAt });
|
|
21766
|
+
},
|
|
21767
|
+
saveBackchannelAuth: async (request) => {
|
|
21768
|
+
byAuthReqId.set(request.authReqId, { ...request });
|
|
21769
|
+
},
|
|
21770
|
+
updateStatus: async (authReqId, status, userSub) => {
|
|
21771
|
+
const record = byAuthReqId.get(authReqId);
|
|
21772
|
+
if (!record)
|
|
21773
|
+
return;
|
|
21774
|
+
byAuthReqId.set(authReqId, { ...record, status, userSub });
|
|
21775
|
+
}
|
|
21776
|
+
};
|
|
21777
|
+
};
|
|
21545
21778
|
var createInMemoryClientAssertionJtiStore = () => {
|
|
21546
21779
|
const seen = new Map;
|
|
21547
21780
|
return {
|
|
@@ -21689,6 +21922,20 @@ var createInMemoryPushedAuthorizationRequestStore = () => {
|
|
|
21689
21922
|
var URL_LENGTH = 2048;
|
|
21690
21923
|
var DEFAULT_LIST_LIMIT2 = 100;
|
|
21691
21924
|
var ID_LENGTH7 = 255;
|
|
21925
|
+
var oauthBackchannelAuthRequestsTable = pgTable("auth_oauth_backchannel_auth_requests", {
|
|
21926
|
+
auth_req_id: varchar("auth_req_id", { length: ID_LENGTH7 }).primaryKey(),
|
|
21927
|
+
binding_message: text("binding_message"),
|
|
21928
|
+
client_id: varchar("client_id", { length: ID_LENGTH7 }).notNull(),
|
|
21929
|
+
created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
21930
|
+
expires_at_ms: bigint("expires_at_ms", { mode: "number" }).notNull(),
|
|
21931
|
+
interval_seconds: bigint("interval_seconds", {
|
|
21932
|
+
mode: "number"
|
|
21933
|
+
}).notNull(),
|
|
21934
|
+
last_polled_at_ms: bigint("last_polled_at_ms", { mode: "number" }),
|
|
21935
|
+
scopes: text("scopes").array().notNull(),
|
|
21936
|
+
status: varchar("status", { length: 16 }).notNull(),
|
|
21937
|
+
user_sub: varchar("user_sub", { length: ID_LENGTH7 })
|
|
21938
|
+
});
|
|
21692
21939
|
var oauthClientAssertionJtisTable = pgTable("auth_oauth_client_assertion_jtis", {
|
|
21693
21940
|
client_id: varchar("client_id", { length: ID_LENGTH7 }).notNull(),
|
|
21694
21941
|
composite_key: varchar("composite_key", {
|
|
@@ -22054,6 +22301,48 @@ var createPostgresPushedAuthorizationRequestStore = (db) => ({
|
|
|
22054
22301
|
});
|
|
22055
22302
|
}
|
|
22056
22303
|
});
|
|
22304
|
+
var toBackchannelAuth = (row) => ({
|
|
22305
|
+
authReqId: row.auth_req_id,
|
|
22306
|
+
bindingMessage: row.binding_message ?? undefined,
|
|
22307
|
+
clientId: row.client_id,
|
|
22308
|
+
createdAt: row.created_at_ms,
|
|
22309
|
+
expiresAt: row.expires_at_ms,
|
|
22310
|
+
intervalSeconds: row.interval_seconds,
|
|
22311
|
+
lastPolledAt: row.last_polled_at_ms ?? undefined,
|
|
22312
|
+
scopes: row.scopes,
|
|
22313
|
+
status: row.status,
|
|
22314
|
+
userSub: row.user_sub ?? undefined
|
|
22315
|
+
});
|
|
22316
|
+
var createNeonBackchannelAuthStore = (databaseUrl) => createPostgresBackchannelAuthStore(createNeonDatabase(databaseUrl));
|
|
22317
|
+
var createPostgresBackchannelAuthStore = (db) => ({
|
|
22318
|
+
deleteByAuthReqId: async (authReqId) => {
|
|
22319
|
+
await db.delete(oauthBackchannelAuthRequestsTable).where(eq(oauthBackchannelAuthRequestsTable.auth_req_id, authReqId));
|
|
22320
|
+
},
|
|
22321
|
+
findByAuthReqId: async (authReqId) => {
|
|
22322
|
+
const [row] = await db.select().from(oauthBackchannelAuthRequestsTable).where(eq(oauthBackchannelAuthRequestsTable.auth_req_id, authReqId)).limit(1);
|
|
22323
|
+
return row ? toBackchannelAuth(row) : undefined;
|
|
22324
|
+
},
|
|
22325
|
+
recordPoll: async (authReqId, polledAt) => {
|
|
22326
|
+
await db.update(oauthBackchannelAuthRequestsTable).set({ last_polled_at_ms: polledAt }).where(eq(oauthBackchannelAuthRequestsTable.auth_req_id, authReqId));
|
|
22327
|
+
},
|
|
22328
|
+
saveBackchannelAuth: async (request) => {
|
|
22329
|
+
await db.insert(oauthBackchannelAuthRequestsTable).values({
|
|
22330
|
+
auth_req_id: request.authReqId,
|
|
22331
|
+
binding_message: request.bindingMessage ?? null,
|
|
22332
|
+
client_id: request.clientId,
|
|
22333
|
+
created_at_ms: request.createdAt,
|
|
22334
|
+
expires_at_ms: request.expiresAt,
|
|
22335
|
+
interval_seconds: request.intervalSeconds,
|
|
22336
|
+
last_polled_at_ms: request.lastPolledAt ?? null,
|
|
22337
|
+
scopes: request.scopes,
|
|
22338
|
+
status: request.status,
|
|
22339
|
+
user_sub: request.userSub ?? null
|
|
22340
|
+
});
|
|
22341
|
+
},
|
|
22342
|
+
updateStatus: async (authReqId, status, userSub) => {
|
|
22343
|
+
await db.update(oauthBackchannelAuthRequestsTable).set({ status, user_sub: userSub ?? null }).where(eq(oauthBackchannelAuthRequestsTable.auth_req_id, authReqId));
|
|
22344
|
+
}
|
|
22345
|
+
});
|
|
22057
22346
|
// src/adaptive/config.ts
|
|
22058
22347
|
var DEFAULT_HISTORY_LIMIT = 50;
|
|
22059
22348
|
var DEFAULT_MAX_TRAVEL_KMH = 900;
|
|
@@ -23316,6 +23605,7 @@ var blockMigrations = {
|
|
|
23316
23605
|
lockout: initMigration("lockout", [lockoutsTable]),
|
|
23317
23606
|
mfa: initMigration("mfa", [mfaEnrollmentsTable]),
|
|
23318
23607
|
oidc: initMigration("oidc", [
|
|
23608
|
+
oauthBackchannelAuthRequestsTable,
|
|
23319
23609
|
oauthClientAssertionJtisTable,
|
|
23320
23610
|
oauthClientRegistrationTokensTable,
|
|
23321
23611
|
oauthClientsTable,
|
|
@@ -24034,6 +24324,7 @@ export {
|
|
|
24034
24324
|
oauthClientsTable,
|
|
24035
24325
|
oauthClientRegistrationTokensTable,
|
|
24036
24326
|
oauthClientAssertionJtisTable,
|
|
24327
|
+
oauthBackchannelAuthRequestsTable,
|
|
24037
24328
|
mintLogoutToken,
|
|
24038
24329
|
mintDpopNonce,
|
|
24039
24330
|
mfaTotpRoutes,
|
|
@@ -24052,6 +24343,7 @@ export {
|
|
|
24052
24343
|
jwkThumbprint,
|
|
24053
24344
|
issueTokenSet,
|
|
24054
24345
|
issueDeviceAuthorization,
|
|
24346
|
+
issueBackchannelAuth,
|
|
24055
24347
|
isValidUser,
|
|
24056
24348
|
isValidProviderOption,
|
|
24057
24349
|
isUserSessionId,
|
|
@@ -24098,11 +24390,13 @@ export {
|
|
|
24098
24390
|
exchangeToken,
|
|
24099
24391
|
exchangeDeviceCode,
|
|
24100
24392
|
exchangeClientCredentials,
|
|
24393
|
+
exchangeBackchannelAuth,
|
|
24101
24394
|
evaluatePassword,
|
|
24102
24395
|
endImpersonation,
|
|
24103
24396
|
encryptTotpSecret,
|
|
24104
24397
|
encryptSecret,
|
|
24105
24398
|
denyDeviceAuthorization,
|
|
24399
|
+
denyBackchannelAuth,
|
|
24106
24400
|
deleteWarrant,
|
|
24107
24401
|
deleteRegisteredClient,
|
|
24108
24402
|
defineProvidersConfiguration,
|
|
@@ -24157,6 +24451,7 @@ export {
|
|
|
24157
24451
|
createPostgresCredentialStore,
|
|
24158
24452
|
createPostgresClientRegistrationTokenStore,
|
|
24159
24453
|
createPostgresClientAssertionJtiStore,
|
|
24454
|
+
createPostgresBackchannelAuthStore,
|
|
24160
24455
|
createPostgresAuthorizationCodeStore,
|
|
24161
24456
|
createPostgresAuditSink,
|
|
24162
24457
|
createPostgresApiKeyStore,
|
|
@@ -24191,6 +24486,7 @@ export {
|
|
|
24191
24486
|
createNeonCredentialStore,
|
|
24192
24487
|
createNeonClientRegistrationTokenStore,
|
|
24193
24488
|
createNeonClientAssertionJtiStore,
|
|
24489
|
+
createNeonBackchannelAuthStore,
|
|
24194
24490
|
createNeonAuthorizationCodeStore,
|
|
24195
24491
|
createNeonAuthSessionStore,
|
|
24196
24492
|
createNeonAuditSink,
|
|
@@ -24227,6 +24523,7 @@ export {
|
|
|
24227
24523
|
createInMemoryClientRegistrationTokenStore,
|
|
24228
24524
|
createInMemoryClientAssertionJtiStore,
|
|
24229
24525
|
createInMemoryCheckCache,
|
|
24526
|
+
createInMemoryBackchannelAuthStore,
|
|
24230
24527
|
createInMemoryAuthorizationCodeStore,
|
|
24231
24528
|
createInMemoryAuthSessionStore,
|
|
24232
24529
|
createInMemoryAuditSink,
|
|
@@ -24260,6 +24557,7 @@ export {
|
|
|
24260
24557
|
assessRisk,
|
|
24261
24558
|
assessAbuse,
|
|
24262
24559
|
approveDeviceAuthorization,
|
|
24560
|
+
approveBackchannelAuth,
|
|
24263
24561
|
apiKeysTable,
|
|
24264
24562
|
apiKeysRoutes,
|
|
24265
24563
|
apiClientsTable,
|
|
@@ -24297,8 +24595,9 @@ export {
|
|
|
24297
24595
|
DEFAULT_CREDENTIAL_SESSION_TTL_MS,
|
|
24298
24596
|
DEFAULT_BACKUP_CODE_COUNT,
|
|
24299
24597
|
CLIENT_ASSERTION_TYPE,
|
|
24598
|
+
CIBA_GRANT_TYPE,
|
|
24300
24599
|
AuthIdentityConflictError
|
|
24301
24600
|
};
|
|
24302
24601
|
|
|
24303
|
-
//# debugId=
|
|
24602
|
+
//# debugId=6F90E4F856A11E4B64756E2164756E21
|
|
24304
24603
|
//# sourceMappingURL=index.js.map
|