@absolutejs/auth 0.56.9 → 0.56.10

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.
@@ -7,5 +7,6 @@
7
7
  */
8
8
  export type { OidcProviderConfig } from './config';
9
9
  export { generateSigningKey, jwkThumbprint, signJwt, toPublicJwk, verifyJwt, type SigningKey } from './keys';
10
+ export { revokeOAuthClientCredentials } from './operator';
10
11
  export { createNeonAuthorizationCodeStore, createNeonClientAssertionJtiStore, createNeonClientRegistrationTokenStore, createNeonDeviceAuthorizationStore, createNeonInitialAccessTokenStore, createNeonOAuthClientStore, createNeonOidcRefreshTokenStore, createPostgresAuthorizationCodeStore, createPostgresClientAssertionJtiStore, createPostgresClientRegistrationTokenStore, createPostgresDeviceAuthorizationStore, createPostgresInitialAccessTokenStore, createPostgresOAuthClientStore, createPostgresOidcRefreshTokenStore } from './postgresStores';
11
12
  export type { AuthorizationCodeStore, ClientAssertionJtiStore, ClientRegistrationTokenStore, DeviceAuthorizationStore, InitialAccessTokenStore, OAuthClient, OAuthClientStore, OidcRefreshTokenConnection, OidcRefreshTokenStore } from './types';
@@ -125,6 +125,24 @@ var verifyJwt = async (token, publicJwk) => {
125
125
  payload
126
126
  };
127
127
  };
128
+ // src/oidc/operator.ts
129
+ var operatorDelete = (store, storeName) => {
130
+ if (!store.deleteForClient)
131
+ throw new Error(`${storeName} does not support operator revocation`);
132
+ return store.deleteForClient;
133
+ };
134
+ var revokeOAuthClientCredentials = async (clientId, stores) => {
135
+ const revokedAuthorizationCodes = await operatorDelete(stores.authorizationCodeStore, "Authorization code store")(clientId);
136
+ const revokedDeviceAuthorizations = await operatorDelete(stores.deviceAuthorizationStore, "Device authorization store")(clientId);
137
+ const revokedRefreshTokens = await operatorDelete(stores.refreshTokenStore, "Refresh token store")(clientId);
138
+ const revokedRegistrationTokens = await operatorDelete(stores.clientRegistrationTokenStore, "Client registration token store")(clientId);
139
+ return {
140
+ revokedAuthorizationCodes,
141
+ revokedDeviceAuthorizations,
142
+ revokedRefreshTokens,
143
+ revokedRegistrationTokens
144
+ };
145
+ };
128
146
  // node_modules/drizzle-orm/entity.js
129
147
  var entityKind = Symbol.for("drizzle:entityKind");
130
148
  var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
@@ -11907,6 +11925,10 @@ var createPostgresAuthorizationCodeStore = (db) => ({
11907
11925
  const [row] = await db.delete(oauthCodesTable).where(eq(oauthCodesTable.code_hash, codeHash)).returning();
11908
11926
  return row ? toCode(row) : undefined;
11909
11927
  },
11928
+ deleteForClient: async (clientId) => {
11929
+ const deleted = await db.delete(oauthCodesTable).where(eq(oauthCodesTable.client_id, clientId)).returning({ codeHash: oauthCodesTable.code_hash });
11930
+ return deleted.length;
11931
+ },
11910
11932
  deleteForUserClient: async (userId, clientId) => {
11911
11933
  const deleted = await db.delete(oauthCodesTable).where(and(eq(oauthCodesTable.user_id, userId), eq(oauthCodesTable.client_id, clientId))).returning({ codeHash: oauthCodesTable.code_hash });
11912
11934
  return deleted.length;
@@ -11936,6 +11958,12 @@ var createPostgresClientRegistrationTokenStore = (db) => ({
11936
11958
  deleteByClientId: async (clientId) => {
11937
11959
  await db.delete(oauthClientRegistrationTokensTable).where(eq(oauthClientRegistrationTokensTable.client_id, clientId));
11938
11960
  },
11961
+ deleteForClient: async (clientId) => {
11962
+ const deleted = await db.delete(oauthClientRegistrationTokensTable).where(eq(oauthClientRegistrationTokensTable.client_id, clientId)).returning({
11963
+ tokenHash: oauthClientRegistrationTokensTable.token_hash
11964
+ });
11965
+ return deleted.length;
11966
+ },
11939
11967
  findByTokenHash: async (tokenHash) => {
11940
11968
  const [row] = await db.select().from(oauthClientRegistrationTokensTable).where(eq(oauthClientRegistrationTokensTable.token_hash, tokenHash)).limit(1);
11941
11969
  if (!row)
@@ -11960,6 +11988,12 @@ var createPostgresDeviceAuthorizationStore = (db) => ({
11960
11988
  deleteByDeviceCodeHash: async (deviceCodeHash) => {
11961
11989
  await db.delete(oauthDeviceAuthorizationsTable).where(eq(oauthDeviceAuthorizationsTable.device_code_hash, deviceCodeHash));
11962
11990
  },
11991
+ deleteForClient: async (clientId) => {
11992
+ const deleted = await db.delete(oauthDeviceAuthorizationsTable).where(eq(oauthDeviceAuthorizationsTable.client_id, clientId)).returning({
11993
+ deviceCodeHash: oauthDeviceAuthorizationsTable.device_code_hash
11994
+ });
11995
+ return deleted.length;
11996
+ },
11963
11997
  deleteForUserClient: async (userId, clientId) => {
11964
11998
  const deleted = await db.delete(oauthDeviceAuthorizationsTable).where(and(eq(oauthDeviceAuthorizationsTable.user_sub, userId), eq(oauthDeviceAuthorizationsTable.client_id, clientId))).returning({
11965
11999
  deviceCodeHash: oauthDeviceAuthorizationsTable.device_code_hash
@@ -12054,6 +12088,10 @@ var createPostgresOidcRefreshTokenStore = (db) => ({
12054
12088
  const [row] = await db.delete(oauthRefreshTokensTable).where(eq(oauthRefreshTokensTable.token_hash, tokenHash)).returning();
12055
12089
  return row ? toRefresh(row) : undefined;
12056
12090
  },
12091
+ deleteForClient: async (clientId) => {
12092
+ const deleted = await db.delete(oauthRefreshTokensTable).where(eq(oauthRefreshTokensTable.client_id, clientId)).returning({ tokenHash: oauthRefreshTokensTable.token_hash });
12093
+ return deleted.length;
12094
+ },
12057
12095
  deleteForUser: async (userId) => {
12058
12096
  await db.delete(oauthRefreshTokensTable).where(eq(oauthRefreshTokensTable.user_id, userId));
12059
12097
  },
@@ -12153,6 +12191,7 @@ export {
12153
12191
  verifyJwt,
12154
12192
  toPublicJwk,
12155
12193
  signJwt,
12194
+ revokeOAuthClientCredentials,
12156
12195
  jwkThumbprint,
12157
12196
  generateSigningKey,
12158
12197
  createPostgresOidcRefreshTokenStore,
@@ -12171,5 +12210,5 @@ export {
12171
12210
  createNeonAuthorizationCodeStore
12172
12211
  };
12173
12212
 
12174
- //# debugId=84ADA662658B454564756E2164756E21
12213
+ //# debugId=3782E808539F50C164756E2164756E21
12175
12214
  //# sourceMappingURL=index.js.map