@absolutejs/auth 0.28.0 → 0.29.0-beta.1
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 +58 -3
- package/dist/index.js +524 -35
- package/dist/index.js.map +13 -10
- package/dist/oidc/config.d.ts +2 -1
- package/dist/oidc/inMemoryStores.d.ts +2 -1
- package/dist/oidc/logout.d.ts +38 -0
- package/dist/oidc/postgresStores.d.ts +233 -1
- package/dist/oidc/routes.d.ts +53 -1
- package/dist/oidc/types.d.ts +19 -0
- package/dist/webhooks/config.d.ts +14 -1
- package/dist/webhooks/dispatcher.d.ts +1 -1
- package/dist/webhooks/inMemoryStore.d.ts +2 -0
- package/dist/webhooks/postgresStore.d.ts +136 -0
- package/dist/webhooks/types.d.ts +14 -0
- package/package.json +1 -1
package/dist/oidc/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RouteString } from '../types';
|
|
2
2
|
import { type SigningKey } from './keys';
|
|
3
|
-
import type { AuthorizationCodeStore, DeviceAuthorizationStore, OAuthClientStore, OidcRefreshTokenStore } from './types';
|
|
3
|
+
import type { AuthorizationCodeStore, DeviceAuthorizationStore, LogoutDeliveryStore, OAuthClientStore, OidcRefreshTokenStore } from './types';
|
|
4
4
|
export declare const DEFAULT_OIDC_ROUTE: RouteString;
|
|
5
5
|
export type OidcProviderConfig<UserType> = {
|
|
6
6
|
accessTokenTtlMs?: number;
|
|
@@ -28,6 +28,7 @@ export type OidcProviderConfig<UserType> = {
|
|
|
28
28
|
idTokenTtlMs?: number;
|
|
29
29
|
issuer: string;
|
|
30
30
|
loginUrl?: string;
|
|
31
|
+
logoutDeliveryStore?: LogoutDeliveryStore;
|
|
31
32
|
oidcRoute?: RouteString;
|
|
32
33
|
refreshTokenStore: OidcRefreshTokenStore;
|
|
33
34
|
refreshTokenTtlMs?: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { AuthorizationCodeStore, DeviceAuthorizationStore, OAuthClient, OAuthClientStore, OidcRefreshTokenStore } from './types';
|
|
1
|
+
import type { AuthorizationCodeStore, DeviceAuthorizationStore, LogoutDeliveryStore, OAuthClient, OAuthClientStore, OidcRefreshTokenStore } from './types';
|
|
2
2
|
export declare const createInMemoryAuthorizationCodeStore: () => AuthorizationCodeStore;
|
|
3
3
|
export declare const createInMemoryDeviceAuthorizationStore: () => DeviceAuthorizationStore;
|
|
4
|
+
export declare const createInMemoryLogoutDeliveryStore: () => LogoutDeliveryStore;
|
|
4
5
|
export declare const createInMemoryOAuthClientStore: (clients: OAuthClient[]) => OAuthClientStore;
|
|
5
6
|
export declare const createInMemoryOidcRefreshTokenStore: () => OidcRefreshTokenStore;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { OidcProviderConfig } from './config';
|
|
2
|
+
import type { LogoutDelivery, OAuthClient } from './types';
|
|
3
|
+
export declare const resolvePostLogoutRedirect: ({ client, requestedUri }: {
|
|
4
|
+
client: OAuthClient;
|
|
5
|
+
requestedUri: string | undefined;
|
|
6
|
+
}) => string | undefined;
|
|
7
|
+
export declare const verifyIdTokenHint: <UserType>({ config, idTokenHint }: {
|
|
8
|
+
config: OidcProviderConfig<UserType>;
|
|
9
|
+
idTokenHint: string;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
audClientId: any;
|
|
12
|
+
sub: any;
|
|
13
|
+
} | undefined>;
|
|
14
|
+
type DeliveryFetch = (url: string, init: {
|
|
15
|
+
body: string;
|
|
16
|
+
headers: Record<string, string>;
|
|
17
|
+
method: string;
|
|
18
|
+
signal: AbortSignal;
|
|
19
|
+
}) => Promise<{
|
|
20
|
+
ok: boolean;
|
|
21
|
+
status: number;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const mintLogoutToken: <UserType>({ clientId, config, now, sub }: {
|
|
24
|
+
clientId: string;
|
|
25
|
+
config: OidcProviderConfig<UserType>;
|
|
26
|
+
now?: number;
|
|
27
|
+
sub: string;
|
|
28
|
+
}) => Promise<string>;
|
|
29
|
+
export declare const fanOutBackchannelLogout: <UserType>({ config, fetchImpl, now, onError, skipClientId, timeoutMs, userId }: {
|
|
30
|
+
config: OidcProviderConfig<UserType>;
|
|
31
|
+
fetchImpl?: DeliveryFetch;
|
|
32
|
+
now?: number;
|
|
33
|
+
onError?: (delivery: LogoutDelivery) => void | Promise<void>;
|
|
34
|
+
skipClientId?: string;
|
|
35
|
+
timeoutMs?: number;
|
|
36
|
+
userId: string;
|
|
37
|
+
}) => Promise<string[]>;
|
|
38
|
+
export {};
|
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { type AnyPgDatabase } from '../stores/postgres';
|
|
2
|
-
import type { AuthorizationCodeStore, DeviceAuthorizationStore, OAuthClientStore, OidcRefreshTokenStore } from './types';
|
|
2
|
+
import type { AuthorizationCodeStore, DeviceAuthorizationStore, LogoutDeliveryStore, OAuthClientStore, OidcRefreshTokenStore } from './types';
|
|
3
3
|
export declare const oauthClientsTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
4
4
|
name: "auth_oauth_clients";
|
|
5
5
|
schema: undefined;
|
|
6
6
|
columns: {
|
|
7
|
+
backchannel_logout_uri: import("drizzle-orm/pg-core").PgColumn<{
|
|
8
|
+
name: "backchannel_logout_uri";
|
|
9
|
+
tableName: "auth_oauth_clients";
|
|
10
|
+
dataType: "string";
|
|
11
|
+
columnType: "PgVarchar";
|
|
12
|
+
data: string;
|
|
13
|
+
driverParam: string;
|
|
14
|
+
notNull: false;
|
|
15
|
+
hasDefault: false;
|
|
16
|
+
isPrimaryKey: false;
|
|
17
|
+
isAutoincrement: false;
|
|
18
|
+
hasRuntimeDefault: false;
|
|
19
|
+
enumValues: [string, ...string[]];
|
|
20
|
+
baseColumn: never;
|
|
21
|
+
identity: undefined;
|
|
22
|
+
generated: undefined;
|
|
23
|
+
}, {}, {
|
|
24
|
+
length: 2048;
|
|
25
|
+
}>;
|
|
7
26
|
client_id: import("drizzle-orm/pg-core").PgColumn<{
|
|
8
27
|
name: "client_id";
|
|
9
28
|
tableName: "auth_oauth_clients";
|
|
@@ -61,6 +80,49 @@ export declare const oauthClientsTable: import("drizzle-orm/pg-core").PgTableWit
|
|
|
61
80
|
}, {}, {
|
|
62
81
|
length: 255;
|
|
63
82
|
}>;
|
|
83
|
+
post_logout_redirect_uris: import("drizzle-orm/pg-core").PgColumn<{
|
|
84
|
+
name: "post_logout_redirect_uris";
|
|
85
|
+
tableName: "auth_oauth_clients";
|
|
86
|
+
dataType: "array";
|
|
87
|
+
columnType: "PgArray";
|
|
88
|
+
data: string[];
|
|
89
|
+
driverParam: string | string[];
|
|
90
|
+
notNull: false;
|
|
91
|
+
hasDefault: false;
|
|
92
|
+
isPrimaryKey: false;
|
|
93
|
+
isAutoincrement: false;
|
|
94
|
+
hasRuntimeDefault: false;
|
|
95
|
+
enumValues: [string, ...string[]];
|
|
96
|
+
baseColumn: import("drizzle-orm").Column<{
|
|
97
|
+
name: "post_logout_redirect_uris";
|
|
98
|
+
tableName: "auth_oauth_clients";
|
|
99
|
+
dataType: "string";
|
|
100
|
+
columnType: "PgText";
|
|
101
|
+
data: string;
|
|
102
|
+
driverParam: string;
|
|
103
|
+
notNull: false;
|
|
104
|
+
hasDefault: false;
|
|
105
|
+
isPrimaryKey: false;
|
|
106
|
+
isAutoincrement: false;
|
|
107
|
+
hasRuntimeDefault: false;
|
|
108
|
+
enumValues: [string, ...string[]];
|
|
109
|
+
baseColumn: never;
|
|
110
|
+
identity: undefined;
|
|
111
|
+
generated: undefined;
|
|
112
|
+
}, {}, {}>;
|
|
113
|
+
identity: undefined;
|
|
114
|
+
generated: undefined;
|
|
115
|
+
}, {}, {
|
|
116
|
+
baseBuilder: import("drizzle-orm/pg-core").PgColumnBuilder<{
|
|
117
|
+
name: "post_logout_redirect_uris";
|
|
118
|
+
dataType: "string";
|
|
119
|
+
columnType: "PgText";
|
|
120
|
+
data: string;
|
|
121
|
+
enumValues: [string, ...string[]];
|
|
122
|
+
driverParam: string;
|
|
123
|
+
}, {}, {}, import("drizzle-orm").ColumnBuilderExtraConfig>;
|
|
124
|
+
size: undefined;
|
|
125
|
+
}>;
|
|
64
126
|
redirect_uris: import("drizzle-orm/pg-core").PgColumn<{
|
|
65
127
|
name: "redirect_uris";
|
|
66
128
|
tableName: "auth_oauth_clients";
|
|
@@ -582,6 +644,174 @@ export declare const oauthDeviceAuthorizationsTable: import("drizzle-orm/pg-core
|
|
|
582
644
|
};
|
|
583
645
|
dialect: "pg";
|
|
584
646
|
}>;
|
|
647
|
+
export declare const oauthLogoutDeliveriesTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
648
|
+
name: "auth_oauth_logout_deliveries";
|
|
649
|
+
schema: undefined;
|
|
650
|
+
columns: {
|
|
651
|
+
attempts: import("drizzle-orm/pg-core").PgColumn<{
|
|
652
|
+
name: "attempts";
|
|
653
|
+
tableName: "auth_oauth_logout_deliveries";
|
|
654
|
+
dataType: "number";
|
|
655
|
+
columnType: "PgBigInt53";
|
|
656
|
+
data: number;
|
|
657
|
+
driverParam: string | number;
|
|
658
|
+
notNull: true;
|
|
659
|
+
hasDefault: false;
|
|
660
|
+
isPrimaryKey: false;
|
|
661
|
+
isAutoincrement: false;
|
|
662
|
+
hasRuntimeDefault: false;
|
|
663
|
+
enumValues: undefined;
|
|
664
|
+
baseColumn: never;
|
|
665
|
+
identity: undefined;
|
|
666
|
+
generated: undefined;
|
|
667
|
+
}, {}, {}>;
|
|
668
|
+
client_id: import("drizzle-orm/pg-core").PgColumn<{
|
|
669
|
+
name: "client_id";
|
|
670
|
+
tableName: "auth_oauth_logout_deliveries";
|
|
671
|
+
dataType: "string";
|
|
672
|
+
columnType: "PgVarchar";
|
|
673
|
+
data: string;
|
|
674
|
+
driverParam: string;
|
|
675
|
+
notNull: true;
|
|
676
|
+
hasDefault: false;
|
|
677
|
+
isPrimaryKey: false;
|
|
678
|
+
isAutoincrement: false;
|
|
679
|
+
hasRuntimeDefault: false;
|
|
680
|
+
enumValues: [string, ...string[]];
|
|
681
|
+
baseColumn: never;
|
|
682
|
+
identity: undefined;
|
|
683
|
+
generated: undefined;
|
|
684
|
+
}, {}, {
|
|
685
|
+
length: 255;
|
|
686
|
+
}>;
|
|
687
|
+
created_at_ms: import("drizzle-orm/pg-core").PgColumn<{
|
|
688
|
+
name: "created_at_ms";
|
|
689
|
+
tableName: "auth_oauth_logout_deliveries";
|
|
690
|
+
dataType: "number";
|
|
691
|
+
columnType: "PgBigInt53";
|
|
692
|
+
data: number;
|
|
693
|
+
driverParam: string | number;
|
|
694
|
+
notNull: true;
|
|
695
|
+
hasDefault: false;
|
|
696
|
+
isPrimaryKey: false;
|
|
697
|
+
isAutoincrement: false;
|
|
698
|
+
hasRuntimeDefault: false;
|
|
699
|
+
enumValues: undefined;
|
|
700
|
+
baseColumn: never;
|
|
701
|
+
identity: undefined;
|
|
702
|
+
generated: undefined;
|
|
703
|
+
}, {}, {}>;
|
|
704
|
+
endpoint_url: import("drizzle-orm/pg-core").PgColumn<{
|
|
705
|
+
name: "endpoint_url";
|
|
706
|
+
tableName: "auth_oauth_logout_deliveries";
|
|
707
|
+
dataType: "string";
|
|
708
|
+
columnType: "PgVarchar";
|
|
709
|
+
data: string;
|
|
710
|
+
driverParam: string;
|
|
711
|
+
notNull: true;
|
|
712
|
+
hasDefault: false;
|
|
713
|
+
isPrimaryKey: false;
|
|
714
|
+
isAutoincrement: false;
|
|
715
|
+
hasRuntimeDefault: false;
|
|
716
|
+
enumValues: [string, ...string[]];
|
|
717
|
+
baseColumn: never;
|
|
718
|
+
identity: undefined;
|
|
719
|
+
generated: undefined;
|
|
720
|
+
}, {}, {
|
|
721
|
+
length: 2048;
|
|
722
|
+
}>;
|
|
723
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
724
|
+
name: "id";
|
|
725
|
+
tableName: "auth_oauth_logout_deliveries";
|
|
726
|
+
dataType: "string";
|
|
727
|
+
columnType: "PgVarchar";
|
|
728
|
+
data: string;
|
|
729
|
+
driverParam: string;
|
|
730
|
+
notNull: true;
|
|
731
|
+
hasDefault: false;
|
|
732
|
+
isPrimaryKey: true;
|
|
733
|
+
isAutoincrement: false;
|
|
734
|
+
hasRuntimeDefault: false;
|
|
735
|
+
enumValues: [string, ...string[]];
|
|
736
|
+
baseColumn: never;
|
|
737
|
+
identity: undefined;
|
|
738
|
+
generated: undefined;
|
|
739
|
+
}, {}, {
|
|
740
|
+
length: 255;
|
|
741
|
+
}>;
|
|
742
|
+
last_error: import("drizzle-orm/pg-core").PgColumn<{
|
|
743
|
+
name: "last_error";
|
|
744
|
+
tableName: "auth_oauth_logout_deliveries";
|
|
745
|
+
dataType: "string";
|
|
746
|
+
columnType: "PgText";
|
|
747
|
+
data: string;
|
|
748
|
+
driverParam: string;
|
|
749
|
+
notNull: false;
|
|
750
|
+
hasDefault: false;
|
|
751
|
+
isPrimaryKey: false;
|
|
752
|
+
isAutoincrement: false;
|
|
753
|
+
hasRuntimeDefault: false;
|
|
754
|
+
enumValues: [string, ...string[]];
|
|
755
|
+
baseColumn: never;
|
|
756
|
+
identity: undefined;
|
|
757
|
+
generated: undefined;
|
|
758
|
+
}, {}, {}>;
|
|
759
|
+
last_status: import("drizzle-orm/pg-core").PgColumn<{
|
|
760
|
+
name: "last_status";
|
|
761
|
+
tableName: "auth_oauth_logout_deliveries";
|
|
762
|
+
dataType: "number";
|
|
763
|
+
columnType: "PgBigInt53";
|
|
764
|
+
data: number;
|
|
765
|
+
driverParam: string | number;
|
|
766
|
+
notNull: false;
|
|
767
|
+
hasDefault: false;
|
|
768
|
+
isPrimaryKey: false;
|
|
769
|
+
isAutoincrement: false;
|
|
770
|
+
hasRuntimeDefault: false;
|
|
771
|
+
enumValues: undefined;
|
|
772
|
+
baseColumn: never;
|
|
773
|
+
identity: undefined;
|
|
774
|
+
generated: undefined;
|
|
775
|
+
}, {}, {}>;
|
|
776
|
+
logout_token: import("drizzle-orm/pg-core").PgColumn<{
|
|
777
|
+
name: "logout_token";
|
|
778
|
+
tableName: "auth_oauth_logout_deliveries";
|
|
779
|
+
dataType: "string";
|
|
780
|
+
columnType: "PgText";
|
|
781
|
+
data: string;
|
|
782
|
+
driverParam: string;
|
|
783
|
+
notNull: true;
|
|
784
|
+
hasDefault: false;
|
|
785
|
+
isPrimaryKey: false;
|
|
786
|
+
isAutoincrement: false;
|
|
787
|
+
hasRuntimeDefault: false;
|
|
788
|
+
enumValues: [string, ...string[]];
|
|
789
|
+
baseColumn: never;
|
|
790
|
+
identity: undefined;
|
|
791
|
+
generated: undefined;
|
|
792
|
+
}, {}, {}>;
|
|
793
|
+
user_id: import("drizzle-orm/pg-core").PgColumn<{
|
|
794
|
+
name: "user_id";
|
|
795
|
+
tableName: "auth_oauth_logout_deliveries";
|
|
796
|
+
dataType: "string";
|
|
797
|
+
columnType: "PgVarchar";
|
|
798
|
+
data: string;
|
|
799
|
+
driverParam: string;
|
|
800
|
+
notNull: true;
|
|
801
|
+
hasDefault: false;
|
|
802
|
+
isPrimaryKey: false;
|
|
803
|
+
isAutoincrement: false;
|
|
804
|
+
hasRuntimeDefault: false;
|
|
805
|
+
enumValues: [string, ...string[]];
|
|
806
|
+
baseColumn: never;
|
|
807
|
+
identity: undefined;
|
|
808
|
+
generated: undefined;
|
|
809
|
+
}, {}, {
|
|
810
|
+
length: 255;
|
|
811
|
+
}>;
|
|
812
|
+
};
|
|
813
|
+
dialect: "pg";
|
|
814
|
+
}>;
|
|
585
815
|
export declare const oauthRefreshTokensTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
586
816
|
name: "auth_oauth_refresh_tokens";
|
|
587
817
|
schema: undefined;
|
|
@@ -763,9 +993,11 @@ export declare const oauthRefreshTokensTable: import("drizzle-orm/pg-core").PgTa
|
|
|
763
993
|
}>;
|
|
764
994
|
export declare const createNeonAuthorizationCodeStore: (databaseUrl: string) => AuthorizationCodeStore;
|
|
765
995
|
export declare const createNeonDeviceAuthorizationStore: (databaseUrl: string) => DeviceAuthorizationStore;
|
|
996
|
+
export declare const createNeonLogoutDeliveryStore: (databaseUrl: string) => LogoutDeliveryStore;
|
|
766
997
|
export declare const createNeonOAuthClientStore: (databaseUrl: string) => OAuthClientStore;
|
|
767
998
|
export declare const createNeonOidcRefreshTokenStore: (databaseUrl: string) => OidcRefreshTokenStore;
|
|
768
999
|
export declare const createPostgresAuthorizationCodeStore: (db: AnyPgDatabase) => AuthorizationCodeStore;
|
|
769
1000
|
export declare const createPostgresDeviceAuthorizationStore: (db: AnyPgDatabase) => DeviceAuthorizationStore;
|
|
1001
|
+
export declare const createPostgresLogoutDeliveryStore: (db: AnyPgDatabase) => LogoutDeliveryStore;
|
|
770
1002
|
export declare const createPostgresOAuthClientStore: (db: AnyPgDatabase) => OAuthClientStore;
|
|
771
1003
|
export declare const createPostgresOidcRefreshTokenStore: (db: AnyPgDatabase) => OidcRefreshTokenStore;
|
package/dist/oidc/routes.d.ts
CHANGED
|
@@ -193,6 +193,58 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
|
|
|
193
193
|
};
|
|
194
194
|
};
|
|
195
195
|
};
|
|
196
|
+
} & {
|
|
197
|
+
[x: string]: {
|
|
198
|
+
get: {
|
|
199
|
+
body: unknown;
|
|
200
|
+
params: {};
|
|
201
|
+
query: {
|
|
202
|
+
client_id?: string | undefined;
|
|
203
|
+
state?: string | undefined;
|
|
204
|
+
id_token_hint?: string | undefined;
|
|
205
|
+
post_logout_redirect_uri?: string | undefined;
|
|
206
|
+
};
|
|
207
|
+
headers: unknown;
|
|
208
|
+
response: {
|
|
209
|
+
200: Response;
|
|
210
|
+
422: {
|
|
211
|
+
type: "validation";
|
|
212
|
+
on: string;
|
|
213
|
+
summary?: string;
|
|
214
|
+
message?: string;
|
|
215
|
+
found?: unknown;
|
|
216
|
+
property?: string;
|
|
217
|
+
expected?: string;
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
} & {
|
|
223
|
+
[x: string]: {
|
|
224
|
+
post: {
|
|
225
|
+
body: {
|
|
226
|
+
client_id?: string | undefined;
|
|
227
|
+
state?: string | undefined;
|
|
228
|
+
id_token_hint?: string | undefined;
|
|
229
|
+
post_logout_redirect_uri?: string | undefined;
|
|
230
|
+
};
|
|
231
|
+
params: {};
|
|
232
|
+
query: unknown;
|
|
233
|
+
headers: unknown;
|
|
234
|
+
response: {
|
|
235
|
+
200: Response;
|
|
236
|
+
422: {
|
|
237
|
+
type: "validation";
|
|
238
|
+
on: string;
|
|
239
|
+
summary?: string;
|
|
240
|
+
message?: string;
|
|
241
|
+
found?: unknown;
|
|
242
|
+
property?: string;
|
|
243
|
+
expected?: string;
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
};
|
|
196
248
|
} & {
|
|
197
249
|
[x: string]: {
|
|
198
250
|
get: {
|
|
@@ -224,7 +276,7 @@ export declare const oidcProviderRoutes: <UserType>(config: OidcProviderConfig<U
|
|
|
224
276
|
query: unknown;
|
|
225
277
|
headers: unknown;
|
|
226
278
|
response: {
|
|
227
|
-
200: Record<string, string | string[]>;
|
|
279
|
+
200: Record<string, string | boolean | string[]>;
|
|
228
280
|
};
|
|
229
281
|
};
|
|
230
282
|
};
|
package/dist/oidc/types.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export type OAuthClient = {
|
|
2
|
+
backchannelLogoutUri?: string;
|
|
2
3
|
clientId: string;
|
|
3
4
|
hashedSecret?: string;
|
|
4
5
|
name: string;
|
|
6
|
+
postLogoutRedirectUris?: string[];
|
|
5
7
|
redirectUris: string[];
|
|
6
8
|
scopes: string[];
|
|
7
9
|
};
|
|
@@ -39,6 +41,7 @@ export type OidcRefreshTokenStore = {
|
|
|
39
41
|
consumeToken: (tokenHash: string) => Promise<OidcRefreshToken | undefined>;
|
|
40
42
|
deleteForUser: (userId: string) => Promise<void>;
|
|
41
43
|
getToken: (tokenHash: string) => Promise<OidcRefreshToken | undefined>;
|
|
44
|
+
listClientIdsForUser: (userId: string) => Promise<string[]>;
|
|
42
45
|
saveToken: (token: OidcRefreshToken) => Promise<void>;
|
|
43
46
|
};
|
|
44
47
|
export type DeviceAuthorizationStatus = 'approved' | 'denied' | 'pending';
|
|
@@ -53,6 +56,22 @@ export type DeviceAuthorization = {
|
|
|
53
56
|
userCode: string;
|
|
54
57
|
userSub?: string;
|
|
55
58
|
};
|
|
59
|
+
export type LogoutDelivery = {
|
|
60
|
+
attempts: number;
|
|
61
|
+
clientId: string;
|
|
62
|
+
createdAt: number;
|
|
63
|
+
endpointUrl: string;
|
|
64
|
+
id: string;
|
|
65
|
+
lastError?: string;
|
|
66
|
+
lastStatus?: number;
|
|
67
|
+
logoutToken: string;
|
|
68
|
+
userId: string;
|
|
69
|
+
};
|
|
70
|
+
export type LogoutDeliveryStore = {
|
|
71
|
+
listFailed: (limit?: number) => Promise<LogoutDelivery[]>;
|
|
72
|
+
recordFailure: (delivery: LogoutDelivery) => Promise<void>;
|
|
73
|
+
removeFailure: (deliveryId: string) => Promise<void>;
|
|
74
|
+
};
|
|
56
75
|
export type DeviceAuthorizationStore = {
|
|
57
76
|
deleteByDeviceCodeHash: (deviceCodeHash: string) => Promise<void>;
|
|
58
77
|
findByDeviceCodeHash: (deviceCodeHash: string) => Promise<DeviceAuthorization | undefined>;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
import type { WebhookEndpoint, WebhookEvent } from './types';
|
|
1
|
+
import type { WebhookDeliveryStore, WebhookEndpoint, WebhookEvent } from './types';
|
|
2
|
+
export declare const DEFAULT_WEBHOOK_RETRY: {
|
|
3
|
+
readonly attempts: 3;
|
|
4
|
+
readonly backoffMultiplier: 2;
|
|
5
|
+
readonly initialDelayMs: 1000;
|
|
6
|
+
};
|
|
2
7
|
export declare const DEFAULT_WEBHOOK_TIMEOUT_MS: number;
|
|
8
|
+
export type WebhookRetryConfig = {
|
|
9
|
+
attempts?: number;
|
|
10
|
+
backoffMultiplier?: number;
|
|
11
|
+
initialDelayMs?: number;
|
|
12
|
+
};
|
|
3
13
|
export type WebhookFetch = (url: string, init: {
|
|
4
14
|
body: string;
|
|
5
15
|
headers: Record<string, string>;
|
|
@@ -10,6 +20,7 @@ export type WebhookFetch = (url: string, init: {
|
|
|
10
20
|
status: number;
|
|
11
21
|
}>;
|
|
12
22
|
export type WebhooksConfig = {
|
|
23
|
+
deliveryStore?: WebhookDeliveryStore;
|
|
13
24
|
endpoints: WebhookEndpoint[];
|
|
14
25
|
fetch?: WebhookFetch;
|
|
15
26
|
onDeliveryError?: (context: {
|
|
@@ -17,5 +28,7 @@ export type WebhooksConfig = {
|
|
|
17
28
|
error: unknown;
|
|
18
29
|
event: WebhookEvent;
|
|
19
30
|
}) => void | Promise<void>;
|
|
31
|
+
retry?: WebhookRetryConfig;
|
|
32
|
+
sleep?: (ms: number) => Promise<void>;
|
|
20
33
|
timeoutMs?: number;
|
|
21
34
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { AuditEvent } from '../audit/types';
|
|
2
2
|
import { type WebhooksConfig } from './config';
|
|
3
|
-
export declare const createWebhookDispatcher: ({ endpoints, fetch: fetchImpl, onDeliveryError, timeoutMs }: WebhooksConfig) => (event: AuditEvent) => Promise<void>;
|
|
3
|
+
export declare const createWebhookDispatcher: ({ deliveryStore, endpoints, fetch: fetchImpl, onDeliveryError, retry, sleep, timeoutMs }: WebhooksConfig) => (event: AuditEvent) => Promise<void>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { type AnyPgDatabase } from '../stores/postgres';
|
|
2
|
+
import type { WebhookDeliveryStore, WebhookEvent } from './types';
|
|
3
|
+
export declare const webhookDeliveriesTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
4
|
+
name: "auth_webhook_deliveries";
|
|
5
|
+
schema: undefined;
|
|
6
|
+
columns: {
|
|
7
|
+
attempts: import("drizzle-orm/pg-core").PgColumn<{
|
|
8
|
+
name: "attempts";
|
|
9
|
+
tableName: "auth_webhook_deliveries";
|
|
10
|
+
dataType: "number";
|
|
11
|
+
columnType: "PgBigInt53";
|
|
12
|
+
data: number;
|
|
13
|
+
driverParam: string | number;
|
|
14
|
+
notNull: true;
|
|
15
|
+
hasDefault: false;
|
|
16
|
+
isPrimaryKey: false;
|
|
17
|
+
isAutoincrement: false;
|
|
18
|
+
hasRuntimeDefault: false;
|
|
19
|
+
enumValues: undefined;
|
|
20
|
+
baseColumn: never;
|
|
21
|
+
identity: undefined;
|
|
22
|
+
generated: undefined;
|
|
23
|
+
}, {}, {}>;
|
|
24
|
+
created_at_ms: import("drizzle-orm/pg-core").PgColumn<{
|
|
25
|
+
name: "created_at_ms";
|
|
26
|
+
tableName: "auth_webhook_deliveries";
|
|
27
|
+
dataType: "number";
|
|
28
|
+
columnType: "PgBigInt53";
|
|
29
|
+
data: number;
|
|
30
|
+
driverParam: string | number;
|
|
31
|
+
notNull: true;
|
|
32
|
+
hasDefault: false;
|
|
33
|
+
isPrimaryKey: false;
|
|
34
|
+
isAutoincrement: false;
|
|
35
|
+
hasRuntimeDefault: false;
|
|
36
|
+
enumValues: undefined;
|
|
37
|
+
baseColumn: never;
|
|
38
|
+
identity: undefined;
|
|
39
|
+
generated: undefined;
|
|
40
|
+
}, {}, {}>;
|
|
41
|
+
endpoint_url: import("drizzle-orm/pg-core").PgColumn<{
|
|
42
|
+
name: "endpoint_url";
|
|
43
|
+
tableName: "auth_webhook_deliveries";
|
|
44
|
+
dataType: "string";
|
|
45
|
+
columnType: "PgVarchar";
|
|
46
|
+
data: string;
|
|
47
|
+
driverParam: string;
|
|
48
|
+
notNull: true;
|
|
49
|
+
hasDefault: false;
|
|
50
|
+
isPrimaryKey: false;
|
|
51
|
+
isAutoincrement: false;
|
|
52
|
+
hasRuntimeDefault: false;
|
|
53
|
+
enumValues: [string, ...string[]];
|
|
54
|
+
baseColumn: never;
|
|
55
|
+
identity: undefined;
|
|
56
|
+
generated: undefined;
|
|
57
|
+
}, {}, {
|
|
58
|
+
length: 2048;
|
|
59
|
+
}>;
|
|
60
|
+
envelope_id: import("drizzle-orm/pg-core").PgColumn<{
|
|
61
|
+
name: "envelope_id";
|
|
62
|
+
tableName: "auth_webhook_deliveries";
|
|
63
|
+
dataType: "string";
|
|
64
|
+
columnType: "PgVarchar";
|
|
65
|
+
data: string;
|
|
66
|
+
driverParam: string;
|
|
67
|
+
notNull: true;
|
|
68
|
+
hasDefault: false;
|
|
69
|
+
isPrimaryKey: true;
|
|
70
|
+
isAutoincrement: false;
|
|
71
|
+
hasRuntimeDefault: false;
|
|
72
|
+
enumValues: [string, ...string[]];
|
|
73
|
+
baseColumn: never;
|
|
74
|
+
identity: undefined;
|
|
75
|
+
generated: undefined;
|
|
76
|
+
}, {}, {
|
|
77
|
+
length: 255;
|
|
78
|
+
}>;
|
|
79
|
+
envelope_json: import("drizzle-orm/pg-core").PgColumn<{
|
|
80
|
+
name: "envelope_json";
|
|
81
|
+
tableName: "auth_webhook_deliveries";
|
|
82
|
+
dataType: "json";
|
|
83
|
+
columnType: "PgJsonb";
|
|
84
|
+
data: WebhookEvent;
|
|
85
|
+
driverParam: unknown;
|
|
86
|
+
notNull: true;
|
|
87
|
+
hasDefault: false;
|
|
88
|
+
isPrimaryKey: false;
|
|
89
|
+
isAutoincrement: false;
|
|
90
|
+
hasRuntimeDefault: false;
|
|
91
|
+
enumValues: undefined;
|
|
92
|
+
baseColumn: never;
|
|
93
|
+
identity: undefined;
|
|
94
|
+
generated: undefined;
|
|
95
|
+
}, {}, {
|
|
96
|
+
$type: WebhookEvent;
|
|
97
|
+
}>;
|
|
98
|
+
last_error: import("drizzle-orm/pg-core").PgColumn<{
|
|
99
|
+
name: "last_error";
|
|
100
|
+
tableName: "auth_webhook_deliveries";
|
|
101
|
+
dataType: "string";
|
|
102
|
+
columnType: "PgText";
|
|
103
|
+
data: string;
|
|
104
|
+
driverParam: string;
|
|
105
|
+
notNull: false;
|
|
106
|
+
hasDefault: false;
|
|
107
|
+
isPrimaryKey: false;
|
|
108
|
+
isAutoincrement: false;
|
|
109
|
+
hasRuntimeDefault: false;
|
|
110
|
+
enumValues: [string, ...string[]];
|
|
111
|
+
baseColumn: never;
|
|
112
|
+
identity: undefined;
|
|
113
|
+
generated: undefined;
|
|
114
|
+
}, {}, {}>;
|
|
115
|
+
last_status: import("drizzle-orm/pg-core").PgColumn<{
|
|
116
|
+
name: "last_status";
|
|
117
|
+
tableName: "auth_webhook_deliveries";
|
|
118
|
+
dataType: "number";
|
|
119
|
+
columnType: "PgBigInt53";
|
|
120
|
+
data: number;
|
|
121
|
+
driverParam: string | number;
|
|
122
|
+
notNull: false;
|
|
123
|
+
hasDefault: false;
|
|
124
|
+
isPrimaryKey: false;
|
|
125
|
+
isAutoincrement: false;
|
|
126
|
+
hasRuntimeDefault: false;
|
|
127
|
+
enumValues: undefined;
|
|
128
|
+
baseColumn: never;
|
|
129
|
+
identity: undefined;
|
|
130
|
+
generated: undefined;
|
|
131
|
+
}, {}, {}>;
|
|
132
|
+
};
|
|
133
|
+
dialect: "pg";
|
|
134
|
+
}>;
|
|
135
|
+
export declare const createNeonWebhookDeliveryStore: (databaseUrl: string) => WebhookDeliveryStore;
|
|
136
|
+
export declare const createPostgresWebhookDeliveryStore: (db: AnyPgDatabase) => WebhookDeliveryStore;
|
package/dist/webhooks/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AuditEvent, AuditEventType } from '../audit/types';
|
|
2
2
|
export type WebhookEndpoint = {
|
|
3
|
+
events?: readonly AuditEventType[];
|
|
3
4
|
secret: string;
|
|
4
5
|
url: string;
|
|
5
6
|
};
|
|
@@ -9,3 +10,16 @@ export type WebhookEvent = {
|
|
|
9
10
|
id: string;
|
|
10
11
|
type: AuditEventType;
|
|
11
12
|
};
|
|
13
|
+
export type WebhookDelivery = {
|
|
14
|
+
attempts: number;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
endpointUrl: string;
|
|
17
|
+
envelope: WebhookEvent;
|
|
18
|
+
lastError?: string;
|
|
19
|
+
lastStatus?: number;
|
|
20
|
+
};
|
|
21
|
+
export type WebhookDeliveryStore = {
|
|
22
|
+
listFailed: (limit?: number) => Promise<WebhookDelivery[]>;
|
|
23
|
+
recordFailure: (delivery: WebhookDelivery) => Promise<void>;
|
|
24
|
+
removeFailure: (envelopeId: string) => Promise<void>;
|
|
25
|
+
};
|
package/package.json
CHANGED