@absolutejs/auth 0.29.0-beta.4 → 0.29.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.
@@ -1,10 +1,11 @@
1
1
  import type { RouteString } from '../types';
2
2
  import { type SigningKey } from './keys';
3
3
  import type { OnClientRegistration } from './registration';
4
- import type { AuthorizationCodeStore, ClientAssertionJtiStore, ClientRegistrationTokenStore, DeviceAuthorizationStore, InitialAccessTokenStore, LogoutDeliveryStore, OAuthClientStore, OidcRefreshTokenStore } from './types';
4
+ import type { AuthorizationCodeStore, ClientAssertionJtiStore, ClientRegistrationTokenStore, DeviceAuthorizationStore, InitialAccessTokenStore, LogoutDeliveryStore, OAuthClientStore, OidcRefreshTokenStore, PushedAuthorizationRequestStore } from './types';
5
5
  export declare const DEFAULT_OIDC_ROUTE: RouteString;
6
6
  export type OidcProviderConfig<UserType> = {
7
7
  accessTokenTtlMs?: number;
8
+ acrValuesSupported?: string[];
8
9
  authorizationCodeStore: AuthorizationCodeStore;
9
10
  clientAssertionJtiStore?: ClientAssertionJtiStore;
10
11
  clientRegistrationTokenStore?: ClientRegistrationTokenStore;
@@ -30,11 +31,20 @@ export type OidcProviderConfig<UserType> = {
30
31
  getUserId: (user: UserType) => string;
31
32
  idTokenTtlMs?: number;
32
33
  issuer: string;
34
+ dpopNonce?: {
35
+ secret: string;
36
+ };
37
+ getAcr?: (context: {
38
+ scopes: string[];
39
+ user: UserType;
40
+ }) => string | undefined;
33
41
  initialAccessTokenStore?: InitialAccessTokenStore;
34
42
  loginUrl?: string;
35
43
  logoutDeliveryStore?: LogoutDeliveryStore;
36
44
  oidcRoute?: RouteString;
37
45
  onClientRegistration?: OnClientRegistration;
46
+ pushedAuthorizationRequestStore?: PushedAuthorizationRequestStore;
47
+ pushedAuthorizationRequestTtlMs?: number;
38
48
  refreshTokenStore: OidcRefreshTokenStore;
39
49
  refreshTokenTtlMs?: number;
40
50
  signingKey: SigningKey;
@@ -57,7 +67,8 @@ export declare const exchangeToken: <UserType>({ actorClientId, audience, config
57
67
  requestedScopes?: string[];
58
68
  subjectToken: string;
59
69
  }) => Promise<TokenExchangeResult>;
60
- export declare const issueTokenSet: <UserType>({ claims, clientId, config, dpopJkt, nonce, now, scopes, sub }: {
70
+ export declare const issueTokenSet: <UserType>({ acr, claims, clientId, config, dpopJkt, nonce, now, scopes, sub }: {
71
+ acr?: string;
61
72
  claims?: Record<string, unknown>;
62
73
  clientId: string;
63
74
  config: OidcProviderConfig<UserType>;
@@ -1,3 +1,13 @@
1
+ export declare const extractDpopNonceClaim: (proof: string) => string | undefined;
2
+ export declare const mintDpopNonce: ({ now, secret }: {
3
+ now?: number;
4
+ secret: string;
5
+ }) => Promise<string>;
6
+ export declare const verifyDpopNonce: ({ now, nonce, secret }: {
7
+ nonce: string;
8
+ now?: number;
9
+ secret: string;
10
+ }) => Promise<boolean>;
1
11
  export type DpopResult = {
2
12
  jkt: string;
3
13
  jti?: string;
@@ -1,9 +1,10 @@
1
- import type { AuthorizationCodeStore, ClientAssertionJtiStore, ClientRegistrationTokenStore, DeviceAuthorizationStore, InitialAccessTokenStore, LogoutDeliveryStore, OAuthClient, OAuthClientStore, OidcRefreshTokenStore } from './types';
1
+ import type { AuthorizationCodeStore, ClientAssertionJtiStore, ClientRegistrationTokenStore, DeviceAuthorizationStore, InitialAccessTokenStore, LogoutDeliveryStore, OAuthClient, OAuthClientStore, OidcRefreshTokenStore, PushedAuthorizationRequestStore } from './types';
2
2
  export declare const createInMemoryAuthorizationCodeStore: () => AuthorizationCodeStore;
3
3
  export declare const createInMemoryClientAssertionJtiStore: () => ClientAssertionJtiStore;
4
- export declare const createInMemoryDeviceAuthorizationStore: () => DeviceAuthorizationStore;
5
- export declare const createInMemoryLogoutDeliveryStore: () => LogoutDeliveryStore;
6
4
  export declare const createInMemoryClientRegistrationTokenStore: () => ClientRegistrationTokenStore;
5
+ export declare const createInMemoryDeviceAuthorizationStore: () => DeviceAuthorizationStore;
7
6
  export declare const createInMemoryInitialAccessTokenStore: (initialHashes?: string[]) => InitialAccessTokenStore;
7
+ export declare const createInMemoryLogoutDeliveryStore: () => LogoutDeliveryStore;
8
8
  export declare const createInMemoryOAuthClientStore: (clients: OAuthClient[]) => OAuthClientStore;
9
9
  export declare const createInMemoryOidcRefreshTokenStore: () => OidcRefreshTokenStore;
10
+ export declare const createInMemoryPushedAuthorizationRequestStore: () => PushedAuthorizationRequestStore;
@@ -0,0 +1,28 @@
1
+ import type { OAuthClient, PushedAuthorizationRequestStore } from './types';
2
+ export declare const DEFAULT_PAR_TTL_MS: number;
3
+ export declare const REQUEST_URI_PREFIX = "urn:ietf:params:oauth:request_uri:";
4
+ export type PushAuthorizationResult = {
5
+ body: {
6
+ expires_in: number;
7
+ request_uri: string;
8
+ };
9
+ ok: true;
10
+ } | {
11
+ body: {
12
+ error: string;
13
+ };
14
+ ok: false;
15
+ status: 400 | 401;
16
+ };
17
+ export declare const consumePushedRequest: ({ clientId, requestUri, store }: {
18
+ clientId: string;
19
+ requestUri: string;
20
+ store: PushedAuthorizationRequestStore;
21
+ }) => Promise<Record<string, string> | undefined>;
22
+ export declare const pushAuthorizationRequest: ({ client, now, params, store, ttlMs }: {
23
+ client: OAuthClient;
24
+ now?: number;
25
+ params: Record<string, string>;
26
+ store: PushedAuthorizationRequestStore;
27
+ ttlMs?: number;
28
+ }) => Promise<PushAuthorizationResult>;
@@ -1,5 +1,5 @@
1
1
  import { type AnyPgDatabase } from '../stores/postgres';
2
- import type { AuthorizationCodeStore, ClientAssertionJtiStore, ClientRegistrationTokenStore, DeviceAuthorizationStore, InitialAccessTokenStore, LogoutDeliveryStore, OAuthClientStore, OidcRefreshTokenStore } from './types';
2
+ import type { AuthorizationCodeStore, ClientAssertionJtiStore, ClientRegistrationTokenStore, DeviceAuthorizationStore, InitialAccessTokenStore, LogoutDeliveryStore, OAuthClientStore, OidcRefreshTokenStore, PushedAuthorizationRequestStore } from './types';
3
3
  export declare const oauthClientAssertionJtisTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
4
4
  name: "auth_oauth_client_assertion_jtis";
5
5
  schema: undefined;
@@ -397,6 +397,25 @@ export declare const oauthCodesTable: import("drizzle-orm/pg-core").PgTableWithC
397
397
  name: "auth_oauth_codes";
398
398
  schema: undefined;
399
399
  columns: {
400
+ acr: import("drizzle-orm/pg-core").PgColumn<{
401
+ name: "acr";
402
+ tableName: "auth_oauth_codes";
403
+ dataType: "string";
404
+ columnType: "PgVarchar";
405
+ data: string;
406
+ driverParam: string;
407
+ notNull: false;
408
+ hasDefault: false;
409
+ isPrimaryKey: false;
410
+ isAutoincrement: false;
411
+ hasRuntimeDefault: false;
412
+ enumValues: [string, ...string[]];
413
+ baseColumn: never;
414
+ identity: undefined;
415
+ generated: undefined;
416
+ }, {}, {
417
+ length: 255;
418
+ }>;
400
419
  claims_json: import("drizzle-orm/pg-core").PgColumn<{
401
420
  name: "claims_json";
402
421
  tableName: "auth_oauth_codes";
@@ -1019,10 +1038,127 @@ export declare const oauthLogoutDeliveriesTable: import("drizzle-orm/pg-core").P
1019
1038
  };
1020
1039
  dialect: "pg";
1021
1040
  }>;
1041
+ export declare const oauthPushedAuthorizationRequestsTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
1042
+ name: "auth_oauth_pushed_authorization_requests";
1043
+ schema: undefined;
1044
+ columns: {
1045
+ client_id: import("drizzle-orm/pg-core").PgColumn<{
1046
+ name: "client_id";
1047
+ tableName: "auth_oauth_pushed_authorization_requests";
1048
+ dataType: "string";
1049
+ columnType: "PgVarchar";
1050
+ data: string;
1051
+ driverParam: string;
1052
+ notNull: true;
1053
+ hasDefault: false;
1054
+ isPrimaryKey: false;
1055
+ isAutoincrement: false;
1056
+ hasRuntimeDefault: false;
1057
+ enumValues: [string, ...string[]];
1058
+ baseColumn: never;
1059
+ identity: undefined;
1060
+ generated: undefined;
1061
+ }, {}, {
1062
+ length: 255;
1063
+ }>;
1064
+ created_at_ms: import("drizzle-orm/pg-core").PgColumn<{
1065
+ name: "created_at_ms";
1066
+ tableName: "auth_oauth_pushed_authorization_requests";
1067
+ dataType: "number";
1068
+ columnType: "PgBigInt53";
1069
+ data: number;
1070
+ driverParam: string | number;
1071
+ notNull: true;
1072
+ hasDefault: false;
1073
+ isPrimaryKey: false;
1074
+ isAutoincrement: false;
1075
+ hasRuntimeDefault: false;
1076
+ enumValues: undefined;
1077
+ baseColumn: never;
1078
+ identity: undefined;
1079
+ generated: undefined;
1080
+ }, {}, {}>;
1081
+ expires_at_ms: import("drizzle-orm/pg-core").PgColumn<{
1082
+ name: "expires_at_ms";
1083
+ tableName: "auth_oauth_pushed_authorization_requests";
1084
+ dataType: "number";
1085
+ columnType: "PgBigInt53";
1086
+ data: number;
1087
+ driverParam: string | number;
1088
+ notNull: true;
1089
+ hasDefault: false;
1090
+ isPrimaryKey: false;
1091
+ isAutoincrement: false;
1092
+ hasRuntimeDefault: false;
1093
+ enumValues: undefined;
1094
+ baseColumn: never;
1095
+ identity: undefined;
1096
+ generated: undefined;
1097
+ }, {}, {}>;
1098
+ params_json: import("drizzle-orm/pg-core").PgColumn<{
1099
+ name: "params_json";
1100
+ tableName: "auth_oauth_pushed_authorization_requests";
1101
+ dataType: "json";
1102
+ columnType: "PgJsonb";
1103
+ data: Record<string, string>;
1104
+ driverParam: unknown;
1105
+ notNull: true;
1106
+ hasDefault: false;
1107
+ isPrimaryKey: false;
1108
+ isAutoincrement: false;
1109
+ hasRuntimeDefault: false;
1110
+ enumValues: undefined;
1111
+ baseColumn: never;
1112
+ identity: undefined;
1113
+ generated: undefined;
1114
+ }, {}, {
1115
+ $type: Record<string, string>;
1116
+ }>;
1117
+ request_uri_hash: import("drizzle-orm/pg-core").PgColumn<{
1118
+ name: "request_uri_hash";
1119
+ tableName: "auth_oauth_pushed_authorization_requests";
1120
+ dataType: "string";
1121
+ columnType: "PgVarchar";
1122
+ data: string;
1123
+ driverParam: string;
1124
+ notNull: true;
1125
+ hasDefault: false;
1126
+ isPrimaryKey: true;
1127
+ isAutoincrement: false;
1128
+ hasRuntimeDefault: false;
1129
+ enumValues: [string, ...string[]];
1130
+ baseColumn: never;
1131
+ identity: undefined;
1132
+ generated: undefined;
1133
+ }, {}, {
1134
+ length: 255;
1135
+ }>;
1136
+ };
1137
+ dialect: "pg";
1138
+ }>;
1022
1139
  export declare const oauthRefreshTokensTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
1023
1140
  name: "auth_oauth_refresh_tokens";
1024
1141
  schema: undefined;
1025
1142
  columns: {
1143
+ acr: import("drizzle-orm/pg-core").PgColumn<{
1144
+ name: "acr";
1145
+ tableName: "auth_oauth_refresh_tokens";
1146
+ dataType: "string";
1147
+ columnType: "PgVarchar";
1148
+ data: string;
1149
+ driverParam: string;
1150
+ notNull: false;
1151
+ hasDefault: false;
1152
+ isPrimaryKey: false;
1153
+ isAutoincrement: false;
1154
+ hasRuntimeDefault: false;
1155
+ enumValues: [string, ...string[]];
1156
+ baseColumn: never;
1157
+ identity: undefined;
1158
+ generated: undefined;
1159
+ }, {}, {
1160
+ length: 255;
1161
+ }>;
1026
1162
  claims_json: import("drizzle-orm/pg-core").PgColumn<{
1027
1163
  name: "claims_json";
1028
1164
  tableName: "auth_oauth_refresh_tokens";
@@ -1206,6 +1342,7 @@ export declare const createNeonInitialAccessTokenStore: (databaseUrl: string) =>
1206
1342
  export declare const createNeonLogoutDeliveryStore: (databaseUrl: string) => LogoutDeliveryStore;
1207
1343
  export declare const createNeonOAuthClientStore: (databaseUrl: string) => OAuthClientStore;
1208
1344
  export declare const createNeonOidcRefreshTokenStore: (databaseUrl: string) => OidcRefreshTokenStore;
1345
+ export declare const createNeonPushedAuthorizationRequestStore: (databaseUrl: string) => PushedAuthorizationRequestStore;
1209
1346
  export declare const createPostgresAuthorizationCodeStore: (db: AnyPgDatabase) => AuthorizationCodeStore;
1210
1347
  export declare const createPostgresClientAssertionJtiStore: (db: AnyPgDatabase) => ClientAssertionJtiStore;
1211
1348
  export declare const createPostgresClientRegistrationTokenStore: (db: AnyPgDatabase) => ClientRegistrationTokenStore;
@@ -1214,3 +1351,4 @@ export declare const createPostgresInitialAccessTokenStore: (db: AnyPgDatabase)
1214
1351
  export declare const createPostgresLogoutDeliveryStore: (db: AnyPgDatabase) => LogoutDeliveryStore;
1215
1352
  export declare const createPostgresOAuthClientStore: (db: AnyPgDatabase) => OAuthClientStore;
1216
1353
  export declare const createPostgresOidcRefreshTokenStore: (db: AnyPgDatabase) => OidcRefreshTokenStore;
1354
+ export declare const createPostgresPushedAuthorizationRequestStore: (db: AnyPgDatabase) => PushedAuthorizationRequestStore;
@@ -29,10 +29,13 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
29
29
  query: {
30
30
  client_id?: string | undefined;
31
31
  scope?: string | undefined;
32
+ claims?: string | undefined;
32
33
  nonce?: string | undefined;
34
+ redirect_uri?: string | undefined;
35
+ acr_values?: string | undefined;
33
36
  code_challenge?: string | undefined;
34
37
  code_challenge_method?: string | undefined;
35
- redirect_uri?: string | undefined;
38
+ request_uri?: string | undefined;
36
39
  response_type?: string | undefined;
37
40
  state?: string | undefined;
38
41
  };
@@ -88,6 +91,45 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
88
91
  };
89
92
  };
90
93
  };
94
+ } & {
95
+ [x: string]: {
96
+ post: {
97
+ body: {
98
+ client_id?: string | undefined;
99
+ scope?: string | undefined;
100
+ audience?: string | undefined;
101
+ claims?: string | undefined;
102
+ nonce?: string | undefined;
103
+ resource?: string | undefined;
104
+ client_secret?: string | undefined;
105
+ redirect_uri?: string | undefined;
106
+ acr_values?: string | undefined;
107
+ code_challenge?: string | undefined;
108
+ code_challenge_method?: string | undefined;
109
+ response_type?: string | undefined;
110
+ state?: string | undefined;
111
+ client_assertion?: string | undefined;
112
+ client_assertion_type?: string | undefined;
113
+ };
114
+ params: {};
115
+ query: unknown;
116
+ headers: {
117
+ authorization?: string | undefined;
118
+ };
119
+ response: {
120
+ 200: Response;
121
+ 422: {
122
+ type: "validation";
123
+ on: string;
124
+ summary?: string;
125
+ message?: string;
126
+ found?: unknown;
127
+ property?: string;
128
+ expected?: string;
129
+ };
130
+ };
131
+ };
132
+ };
91
133
  } & {
92
134
  [x: string]: {
93
135
  post: {
@@ -7,11 +7,23 @@ export type OAuthClient = {
7
7
  name: string;
8
8
  postLogoutRedirectUris?: string[];
9
9
  redirectUris: string[];
10
+ requirePushedAuthorizationRequests?: boolean;
10
11
  scopes: string[];
11
12
  };
12
13
  export type ClientAssertionJtiStore = {
13
14
  recordIfFresh: (clientId: string, jti: string, expiresAt: number) => Promise<boolean>;
14
15
  };
16
+ export type PushedAuthorizationRequest = {
17
+ clientId: string;
18
+ createdAt: number;
19
+ expiresAt: number;
20
+ params: Record<string, string>;
21
+ requestUriHash: string;
22
+ };
23
+ export type PushedAuthorizationRequestStore = {
24
+ consumeRequest: (requestUriHash: string) => Promise<PushedAuthorizationRequest | undefined>;
25
+ saveRequest: (request: PushedAuthorizationRequest) => Promise<void>;
26
+ };
15
27
  export type OAuthClientStore = {
16
28
  deleteClient?: (clientId: string) => Promise<void>;
17
29
  findClient: (clientId: string) => Promise<OAuthClient | undefined>;
@@ -32,6 +44,7 @@ export type InitialAccessTokenStore = {
32
44
  consumeToken: (tokenHash: string) => Promise<boolean>;
33
45
  };
34
46
  export type AuthorizationCode = {
47
+ acr?: string;
35
48
  claims?: Record<string, unknown>;
36
49
  clientId: string;
37
50
  codeChallenge: string;
@@ -49,6 +62,7 @@ export type AuthorizationCodeStore = {
49
62
  saveCode: (code: AuthorizationCode) => Promise<void>;
50
63
  };
51
64
  export type OidcRefreshToken = {
65
+ acr?: string;
52
66
  claims?: Record<string, unknown>;
53
67
  clientId: string;
54
68
  createdAt: number;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.29.0-beta.4",
2
+ "version": "0.29.0",
3
3
  "name": "@absolutejs/auth",
4
4
  "description": "An authorization library for absolutejs",
5
5
  "repository": {