@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.
- package/dist/cli/migrate.js.map +1 -1
- package/dist/index.js +61 -1
- package/dist/index.js.map +4 -4
- package/dist/oidc/index.d.ts +1 -0
- package/dist/oidc/index.js +40 -1
- package/dist/oidc/index.js.map +5 -4
- package/dist/oidc/operator.d.ts +14 -0
- package/dist/oidc/types.d.ts +4 -0
- package/dist/server.js +61 -1
- package/dist/server.js.map +4 -4
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AuthorizationCodeStore, ClientRegistrationTokenStore, DeviceAuthorizationStore, OidcRefreshTokenStore } from './types';
|
|
2
|
+
type OAuthClientCredentialStores = {
|
|
3
|
+
authorizationCodeStore: AuthorizationCodeStore;
|
|
4
|
+
clientRegistrationTokenStore: ClientRegistrationTokenStore;
|
|
5
|
+
deviceAuthorizationStore: DeviceAuthorizationStore;
|
|
6
|
+
refreshTokenStore: OidcRefreshTokenStore;
|
|
7
|
+
};
|
|
8
|
+
export declare const revokeOAuthClientCredentials: (clientId: string, stores: OAuthClientCredentialStores) => Promise<{
|
|
9
|
+
revokedAuthorizationCodes: number;
|
|
10
|
+
revokedDeviceAuthorizations: number;
|
|
11
|
+
revokedRefreshTokens: number;
|
|
12
|
+
revokedRegistrationTokens: number;
|
|
13
|
+
}>;
|
|
14
|
+
export {};
|
package/dist/oidc/types.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export type ClientRegistrationToken = {
|
|
|
42
42
|
};
|
|
43
43
|
export type ClientRegistrationTokenStore = {
|
|
44
44
|
deleteByClientId: (clientId: string) => Promise<void>;
|
|
45
|
+
deleteForClient?: (clientId: string) => Promise<number>;
|
|
45
46
|
findByTokenHash: (tokenHash: string) => Promise<ClientRegistrationToken | undefined>;
|
|
46
47
|
saveToken: (token: ClientRegistrationToken) => Promise<void>;
|
|
47
48
|
};
|
|
@@ -65,6 +66,7 @@ export type AuthorizationCode = {
|
|
|
65
66
|
};
|
|
66
67
|
export type AuthorizationCodeStore = {
|
|
67
68
|
consumeCode: (codeHash: string) => Promise<AuthorizationCode | undefined>;
|
|
69
|
+
deleteForClient?: (clientId: string) => Promise<number>;
|
|
68
70
|
deleteForUserClient: (userId: string, clientId: string) => Promise<number>;
|
|
69
71
|
saveCode: (code: AuthorizationCode) => Promise<void>;
|
|
70
72
|
};
|
|
@@ -87,6 +89,7 @@ export type OidcRefreshTokenConnection = {
|
|
|
87
89
|
export type OidcRefreshTokenStore = {
|
|
88
90
|
consumeToken: (tokenHash: string) => Promise<OidcRefreshToken | undefined>;
|
|
89
91
|
deleteForUser: (userId: string) => Promise<void>;
|
|
92
|
+
deleteForClient?: (clientId: string) => Promise<number>;
|
|
90
93
|
deleteForUserClient: (userId: string, clientId: string) => Promise<number>;
|
|
91
94
|
getToken: (tokenHash: string) => Promise<OidcRefreshToken | undefined>;
|
|
92
95
|
listClientIdsForUser: (userId: string) => Promise<string[]>;
|
|
@@ -123,6 +126,7 @@ export type LogoutDeliveryStore = {
|
|
|
123
126
|
};
|
|
124
127
|
export type DeviceAuthorizationStore = {
|
|
125
128
|
deleteByDeviceCodeHash: (deviceCodeHash: string) => Promise<void>;
|
|
129
|
+
deleteForClient?: (clientId: string) => Promise<number>;
|
|
126
130
|
deleteForUserClient: (userId: string, clientId: string) => Promise<number>;
|
|
127
131
|
findByDeviceCodeHash: (deviceCodeHash: string) => Promise<DeviceAuthorization | undefined>;
|
|
128
132
|
findByUserCode: (userCode: string) => Promise<DeviceAuthorization | undefined>;
|
package/dist/server.js
CHANGED
|
@@ -27708,6 +27708,16 @@ var createInMemoryAuthorizationCodeStore = () => {
|
|
|
27708
27708
|
codes.delete(codeHash);
|
|
27709
27709
|
return record;
|
|
27710
27710
|
},
|
|
27711
|
+
deleteForClient: async (clientId) => {
|
|
27712
|
+
let deleted = 0;
|
|
27713
|
+
for (const [hash, code] of codes) {
|
|
27714
|
+
if (code.clientId !== clientId)
|
|
27715
|
+
continue;
|
|
27716
|
+
codes.delete(hash);
|
|
27717
|
+
deleted += 1;
|
|
27718
|
+
}
|
|
27719
|
+
return deleted;
|
|
27720
|
+
},
|
|
27711
27721
|
deleteForUserClient: async (userId, clientId) => {
|
|
27712
27722
|
let deleted = 0;
|
|
27713
27723
|
for (const [hash, code] of codes) {
|
|
@@ -27773,6 +27783,16 @@ var createInMemoryClientRegistrationTokenStore = () => {
|
|
|
27773
27783
|
byHash.delete(hash);
|
|
27774
27784
|
}
|
|
27775
27785
|
},
|
|
27786
|
+
deleteForClient: async (clientId) => {
|
|
27787
|
+
let deleted = 0;
|
|
27788
|
+
for (const [hash, token] of byHash) {
|
|
27789
|
+
if (token.clientId !== clientId)
|
|
27790
|
+
continue;
|
|
27791
|
+
byHash.delete(hash);
|
|
27792
|
+
deleted += 1;
|
|
27793
|
+
}
|
|
27794
|
+
return deleted;
|
|
27795
|
+
},
|
|
27776
27796
|
findByTokenHash: async (tokenHash) => byHash.get(tokenHash),
|
|
27777
27797
|
saveToken: async (token) => {
|
|
27778
27798
|
for (const [hash, existing] of byHash) {
|
|
@@ -27789,6 +27809,16 @@ var createInMemoryDeviceAuthorizationStore = () => {
|
|
|
27789
27809
|
deleteByDeviceCodeHash: async (deviceCodeHash) => {
|
|
27790
27810
|
byDeviceCode.delete(deviceCodeHash);
|
|
27791
27811
|
},
|
|
27812
|
+
deleteForClient: async (clientId) => {
|
|
27813
|
+
let deleted = 0;
|
|
27814
|
+
for (const [hash, authorization] of byDeviceCode) {
|
|
27815
|
+
if (authorization.clientId !== clientId)
|
|
27816
|
+
continue;
|
|
27817
|
+
byDeviceCode.delete(hash);
|
|
27818
|
+
deleted += 1;
|
|
27819
|
+
}
|
|
27820
|
+
return deleted;
|
|
27821
|
+
},
|
|
27792
27822
|
deleteForUserClient: async (userId, clientId) => {
|
|
27793
27823
|
let deleted = 0;
|
|
27794
27824
|
for (const [hash, authorization] of byDeviceCode) {
|
|
@@ -27870,6 +27900,16 @@ var createInMemoryOidcRefreshTokenStore = () => {
|
|
|
27870
27900
|
tokens.delete(tokenHash);
|
|
27871
27901
|
return record;
|
|
27872
27902
|
},
|
|
27903
|
+
deleteForClient: async (clientId) => {
|
|
27904
|
+
let deleted = 0;
|
|
27905
|
+
for (const [hash, token] of tokens) {
|
|
27906
|
+
if (token.clientId !== clientId)
|
|
27907
|
+
continue;
|
|
27908
|
+
tokens.delete(hash);
|
|
27909
|
+
deleted += 1;
|
|
27910
|
+
}
|
|
27911
|
+
return deleted;
|
|
27912
|
+
},
|
|
27873
27913
|
deleteForUser: async (userId) => {
|
|
27874
27914
|
for (const [hash, token] of tokens) {
|
|
27875
27915
|
if (token.userId === userId)
|
|
@@ -28164,6 +28204,10 @@ var createPostgresAuthorizationCodeStore = (db) => ({
|
|
|
28164
28204
|
const [row] = await db.delete(oauthCodesTable).where(eq(oauthCodesTable.code_hash, codeHash)).returning();
|
|
28165
28205
|
return row ? toCode(row) : undefined;
|
|
28166
28206
|
},
|
|
28207
|
+
deleteForClient: async (clientId) => {
|
|
28208
|
+
const deleted = await db.delete(oauthCodesTable).where(eq(oauthCodesTable.client_id, clientId)).returning({ codeHash: oauthCodesTable.code_hash });
|
|
28209
|
+
return deleted.length;
|
|
28210
|
+
},
|
|
28167
28211
|
deleteForUserClient: async (userId, clientId) => {
|
|
28168
28212
|
const deleted = await db.delete(oauthCodesTable).where(and(eq(oauthCodesTable.user_id, userId), eq(oauthCodesTable.client_id, clientId))).returning({ codeHash: oauthCodesTable.code_hash });
|
|
28169
28213
|
return deleted.length;
|
|
@@ -28193,6 +28237,12 @@ var createPostgresClientRegistrationTokenStore = (db) => ({
|
|
|
28193
28237
|
deleteByClientId: async (clientId) => {
|
|
28194
28238
|
await db.delete(oauthClientRegistrationTokensTable).where(eq(oauthClientRegistrationTokensTable.client_id, clientId));
|
|
28195
28239
|
},
|
|
28240
|
+
deleteForClient: async (clientId) => {
|
|
28241
|
+
const deleted = await db.delete(oauthClientRegistrationTokensTable).where(eq(oauthClientRegistrationTokensTable.client_id, clientId)).returning({
|
|
28242
|
+
tokenHash: oauthClientRegistrationTokensTable.token_hash
|
|
28243
|
+
});
|
|
28244
|
+
return deleted.length;
|
|
28245
|
+
},
|
|
28196
28246
|
findByTokenHash: async (tokenHash) => {
|
|
28197
28247
|
const [row] = await db.select().from(oauthClientRegistrationTokensTable).where(eq(oauthClientRegistrationTokensTable.token_hash, tokenHash)).limit(1);
|
|
28198
28248
|
if (!row)
|
|
@@ -28217,6 +28267,12 @@ var createPostgresDeviceAuthorizationStore = (db) => ({
|
|
|
28217
28267
|
deleteByDeviceCodeHash: async (deviceCodeHash) => {
|
|
28218
28268
|
await db.delete(oauthDeviceAuthorizationsTable).where(eq(oauthDeviceAuthorizationsTable.device_code_hash, deviceCodeHash));
|
|
28219
28269
|
},
|
|
28270
|
+
deleteForClient: async (clientId) => {
|
|
28271
|
+
const deleted = await db.delete(oauthDeviceAuthorizationsTable).where(eq(oauthDeviceAuthorizationsTable.client_id, clientId)).returning({
|
|
28272
|
+
deviceCodeHash: oauthDeviceAuthorizationsTable.device_code_hash
|
|
28273
|
+
});
|
|
28274
|
+
return deleted.length;
|
|
28275
|
+
},
|
|
28220
28276
|
deleteForUserClient: async (userId, clientId) => {
|
|
28221
28277
|
const deleted = await db.delete(oauthDeviceAuthorizationsTable).where(and(eq(oauthDeviceAuthorizationsTable.user_sub, userId), eq(oauthDeviceAuthorizationsTable.client_id, clientId))).returning({
|
|
28222
28278
|
deviceCodeHash: oauthDeviceAuthorizationsTable.device_code_hash
|
|
@@ -28311,6 +28367,10 @@ var createPostgresOidcRefreshTokenStore = (db) => ({
|
|
|
28311
28367
|
const [row] = await db.delete(oauthRefreshTokensTable).where(eq(oauthRefreshTokensTable.token_hash, tokenHash)).returning();
|
|
28312
28368
|
return row ? toRefresh(row) : undefined;
|
|
28313
28369
|
},
|
|
28370
|
+
deleteForClient: async (clientId) => {
|
|
28371
|
+
const deleted = await db.delete(oauthRefreshTokensTable).where(eq(oauthRefreshTokensTable.client_id, clientId)).returning({ tokenHash: oauthRefreshTokensTable.token_hash });
|
|
28372
|
+
return deleted.length;
|
|
28373
|
+
},
|
|
28314
28374
|
deleteForUser: async (userId) => {
|
|
28315
28375
|
await db.delete(oauthRefreshTokensTable).where(eq(oauthRefreshTokensTable.user_id, userId));
|
|
28316
28376
|
},
|
|
@@ -30526,5 +30586,5 @@ export {
|
|
|
30526
30586
|
auth2 as auth
|
|
30527
30587
|
};
|
|
30528
30588
|
|
|
30529
|
-
//# debugId=
|
|
30589
|
+
//# debugId=286B6E54F8CE0D4D64756E2164756E21
|
|
30530
30590
|
//# sourceMappingURL=server.js.map
|