@julr/sesame 0.5.1 → 0.7.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/LICENSE.md +1 -1
- package/README.md +470 -64
- package/build/authorize_controller-sCZIjnc-.js +251 -0
- package/build/{client_info_controller-BucHGx4u.js → client_info_controller-B5A3tpbk.js} +11 -4
- package/build/commands/sesame_client.d.ts +20 -0
- package/build/commands/sesame_key.d.ts +12 -0
- package/build/commands/sesame_purge.d.ts +0 -2
- package/build/commands/sesame_purge.js +12 -3
- package/build/configure-t9q3KonY.js +31 -0
- package/build/configure.js +1 -24
- package/build/consent_controller-ChBboaSd.js +96 -0
- package/build/consent_retry-DMkfhmk9.js +41 -0
- package/build/{decorate-BKZEjPRg.js → decorate-RQD1h28J.js} +3 -9
- package/build/id_token_service-BtBUiL_n.js +54 -0
- package/build/index.d.ts +2 -8
- package/build/index.js +59 -10
- package/build/{introspect_controller-6bRt9sZt.js → introspect_controller-LVYGWhMj.js} +28 -10
- package/build/issue_authorization_code-Dr4-bbMp.js +39 -0
- package/build/jwks_controller-4HUVS_HC.js +22 -0
- package/build/{main-EbeMS5S9.js → main-Dx9kZv07.js} +35 -43
- package/build/{metadata_controller-DeaMRnUr.js → metadata_controller-hwfmxlF7.js} +81 -6
- package/build/oauth_error-CvxtZvjp.js +189 -0
- package/build/providers/sesame_provider.d.ts +1 -1
- package/build/providers/sesame_provider.js +17 -6
- package/build/{register_controller-sIJ1rxdM.js → register_controller-Cdk3c32j.js} +44 -8
- package/build/revoke_controller-Daz4Yqfs.js +48 -0
- package/build/services/main.js +3 -3
- package/build/sesame_manager-CeEmlzba.js +515 -0
- package/build/sesame_manager-DQxvsTEq.js +2 -0
- package/build/src/actions/authorize.d.ts +46 -0
- package/build/src/actions/exchange_authorization_code.d.ts +34 -0
- package/build/src/actions/exchange_client_credentials.d.ts +28 -0
- package/build/src/actions/exchange_refresh_token.d.ts +59 -0
- package/build/src/actions/issue_authorization_code.d.ts +26 -0
- package/build/src/controllers/authorize_controller.d.ts +18 -17
- package/build/src/controllers/consent_controller.d.ts +5 -0
- package/build/src/controllers/jwks_controller.d.ts +14 -0
- package/build/src/controllers/metadata_controller.d.ts +10 -3
- package/build/src/controllers/register_controller.d.ts +30 -30
- package/build/src/controllers/token_controller.d.ts +8 -5
- package/build/src/controllers/userinfo_controller.d.ts +14 -0
- package/build/src/guard/guard.d.ts +1 -1
- package/build/src/guard/lucid.d.ts +8 -0
- package/build/src/guard/lucid.js +46 -0
- package/build/src/guard/main.d.ts +2 -9
- package/build/src/guard/main.js +2 -6
- package/build/src/guard/types.d.ts +0 -9
- package/build/src/guard/user_provider.d.ts +9 -1
- package/build/src/middleware/any_scope_middleware.js +10 -1
- package/build/src/middleware/scope_middleware.js +10 -1
- package/build/src/models/oauth_authorization_code.d.ts +1 -0
- package/build/src/models/oauth_pending_authorization_request.d.ts +1 -0
- package/build/src/oauth_error.d.ts +74 -74
- package/build/src/routes.d.ts +3 -1
- package/build/src/services/client_service.d.ts +5 -2
- package/build/src/services/id_token_service.d.ts +30 -0
- package/build/src/services/key_service.d.ts +20 -0
- package/build/src/sesame_manager.d.ts +56 -4
- package/build/src/storage/consent_retry.d.ts +4 -0
- package/build/src/storage/drivers/kysely.d.ts +166 -0
- package/build/src/storage/drivers/kysely.js +480 -0
- package/build/src/storage/drivers/lucid.d.ts +162 -0
- package/build/src/storage/drivers/lucid.js +549 -0
- package/build/src/storage/migrations/kysely.d.ts +6 -0
- package/build/src/storage/types.d.ts +197 -0
- package/build/src/storage/types.js +1 -0
- package/build/src/stores.d.ts +21 -0
- package/build/src/types.d.ts +120 -0
- package/build/src/types.js +2 -0
- package/build/stubs/config/sesame.stub +4 -1
- package/build/stubs/config/sesame_kysely.stub +35 -0
- package/build/stubs/main.ts +5 -0
- package/build/stubs/migrations/create_oauth_authorization_codes_table.stub +1 -0
- package/build/stubs/migrations/create_oauth_pending_authorization_requests_table.stub +1 -0
- package/build/stubs/migrations/create_oauth_refresh_tokens_table.stub +1 -1
- package/build/stubs/migrations/kysely/create_oauth_tables.stub +151 -0
- package/build/taze.config.d.ts +2 -0
- package/build/token_controller-DRatCQNT.js +492 -0
- package/build/token_service-DDQ3Dxaj.js +59 -0
- package/build/types-DEtn2Zdb.js +75 -0
- package/build/userinfo_controller-YwN26wK-.js +37 -0
- package/build/vite.config.d.ts +2 -0
- package/package.json +55 -54
- package/build/authorize_controller-YUfAy-R2.js +0 -138
- package/build/client_service-WTNMqWzY.js +0 -65
- package/build/consent_controller-Dprwd1ed.js +0 -85
- package/build/oauth_access_token-bsoM5KeU.js +0 -18
- package/build/oauth_client-BIoY5jBR.js +0 -24
- package/build/oauth_error-CnJ3L8tf.js +0 -94
- package/build/revoke_controller-D6isoQCi.js +0 -41
- package/build/sesame_manager-Bu4MHqZV.js +0 -4
- package/build/sesame_manager-DwDZy5Vy.js +0 -167
- package/build/src/grants/authorization_code_grant.d.ts +0 -23
- package/build/src/grants/client_credentials_grant.d.ts +0 -23
- package/build/src/grants/refresh_token_grant.d.ts +0 -27
- package/build/token_controller-DzcrLMyS.js +0 -194
- package/build/token_service-fhoA4slP.js +0 -31
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { DateTime } from 'luxon';
|
|
2
|
+
import { OAuthAccessToken } from '../../models/oauth_access_token.js';
|
|
3
|
+
import { OAuthAuthorizationCode } from '../../models/oauth_authorization_code.js';
|
|
4
|
+
import { OAuthClient } from '../../models/oauth_client.js';
|
|
5
|
+
import { OAuthConsent } from '../../models/oauth_consent.js';
|
|
6
|
+
import { OAuthPendingAuthorizationRequest } from '../../models/oauth_pending_authorization_request.js';
|
|
7
|
+
import { OAuthRefreshToken } from '../../models/oauth_refresh_token.js';
|
|
8
|
+
import type { CreateAccessTokenRecord, CreateAuthorizationCodeRecord, CreateClientRecord, CreatePendingAuthorizationRequestRecord, ExchangeAuthorizationCodeOptions, IssueTokenPairOptions, OAuthAccessTokenRecord, OAuthAuthorizationCodeRecord, OAuthClientRecord, OAuthConsentRecord, OAuthPendingAuthorizationRequestRecord, OAuthRefreshTokenRecord, PurgeTokensOptions, RotateRefreshTokenOptions, SesamePurgeResult, SesameStore, UpdateClientRecord } from '../types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Persist OAuth records through the application's Lucid connection.
|
|
11
|
+
*/
|
|
12
|
+
export declare class LucidStore implements SesameStore {
|
|
13
|
+
#private;
|
|
14
|
+
/**
|
|
15
|
+
* Bind this store to a Lucid transaction when one is supplied.
|
|
16
|
+
*/
|
|
17
|
+
constructor(client?: any);
|
|
18
|
+
/**
|
|
19
|
+
* Find a registered client by its public identifier.
|
|
20
|
+
*/
|
|
21
|
+
findClient(clientId: string): Promise<OAuthClientRecord | null>;
|
|
22
|
+
/**
|
|
23
|
+
* List clients newest first, optionally for a single owner.
|
|
24
|
+
*/
|
|
25
|
+
listClients(options?: {
|
|
26
|
+
userId?: string;
|
|
27
|
+
}): Promise<OAuthClientRecord[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Insert a client and return its stored record.
|
|
30
|
+
*/
|
|
31
|
+
createClient(data: CreateClientRecord): Promise<OAuthClientRecord>;
|
|
32
|
+
/**
|
|
33
|
+
* Update only the supplied public client fields.
|
|
34
|
+
*/
|
|
35
|
+
updateClient(options: {
|
|
36
|
+
id: string;
|
|
37
|
+
data: UpdateClientRecord;
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Replace a confidential client's stored secret hash.
|
|
41
|
+
*/
|
|
42
|
+
updateClientSecret(options: {
|
|
43
|
+
id: string;
|
|
44
|
+
secret: string;
|
|
45
|
+
}): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Delete a client and all its associated OAuth records atomically.
|
|
48
|
+
*/
|
|
49
|
+
deleteClient(clientId: string): Promise<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* Look up an access-token hash, optionally limited to one client.
|
|
52
|
+
*/
|
|
53
|
+
findAccessToken(options: {
|
|
54
|
+
hash: string;
|
|
55
|
+
clientId?: string;
|
|
56
|
+
}): Promise<OAuthAccessTokenRecord | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Insert a hashed access token.
|
|
59
|
+
*/
|
|
60
|
+
createAccessToken(data: CreateAccessTokenRecord): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Revoke an active access token owned by the requesting client.
|
|
63
|
+
*/
|
|
64
|
+
revokeAccessToken(options: {
|
|
65
|
+
hash: string;
|
|
66
|
+
clientId: string;
|
|
67
|
+
now: DateTime;
|
|
68
|
+
}): Promise<boolean>;
|
|
69
|
+
/**
|
|
70
|
+
* Look up a refresh-token hash owned by a client.
|
|
71
|
+
*/
|
|
72
|
+
findRefreshToken(options: {
|
|
73
|
+
hash: string;
|
|
74
|
+
clientId: string;
|
|
75
|
+
}): Promise<OAuthRefreshTokenRecord | null>;
|
|
76
|
+
/**
|
|
77
|
+
* Revoke a refresh token and its associated active access token together.
|
|
78
|
+
*/
|
|
79
|
+
revokeRefreshToken(options: {
|
|
80
|
+
hash: string;
|
|
81
|
+
clientId: string;
|
|
82
|
+
now: DateTime;
|
|
83
|
+
}): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Invalidate a client's token family after refresh-token replay.
|
|
86
|
+
*/
|
|
87
|
+
revokeTokenFamily(options: {
|
|
88
|
+
clientId: string;
|
|
89
|
+
userId: string;
|
|
90
|
+
now: DateTime;
|
|
91
|
+
}): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Find an authorization-code hash issued to a client.
|
|
94
|
+
*/
|
|
95
|
+
findAuthorizationCode(options: {
|
|
96
|
+
code: string;
|
|
97
|
+
clientId: string;
|
|
98
|
+
}): Promise<OAuthAuthorizationCodeRecord | null>;
|
|
99
|
+
/**
|
|
100
|
+
* Store a short-lived authorization-code hash.
|
|
101
|
+
*/
|
|
102
|
+
createAuthorizationCode(data: CreateAuthorizationCodeRecord): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Discard an expired or invalid authorization code.
|
|
105
|
+
*/
|
|
106
|
+
deleteAuthorizationCode(id: string): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Consume a code exactly once and issue its tokens in one transaction.
|
|
109
|
+
*/
|
|
110
|
+
exchangeAuthorizationCode(options: ExchangeAuthorizationCodeOptions): Promise<boolean>;
|
|
111
|
+
/**
|
|
112
|
+
* Find a user's current consent for a client.
|
|
113
|
+
*/
|
|
114
|
+
findConsent(options: {
|
|
115
|
+
clientId: string;
|
|
116
|
+
userId: string;
|
|
117
|
+
}): Promise<OAuthConsentRecord | null>;
|
|
118
|
+
/**
|
|
119
|
+
* Merge newly approved scopes into the user's consent.
|
|
120
|
+
*/
|
|
121
|
+
grantConsent(options: {
|
|
122
|
+
clientId: string;
|
|
123
|
+
userId: string;
|
|
124
|
+
scopes: string[];
|
|
125
|
+
}): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Persist an authorization request awaiting user consent.
|
|
128
|
+
*/
|
|
129
|
+
createPendingAuthorizationRequest(data: CreatePendingAuthorizationRequestRecord): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Return a valid pending request only to the process that deletes it.
|
|
132
|
+
*/
|
|
133
|
+
consumePendingAuthorizationRequest(options: {
|
|
134
|
+
token: string;
|
|
135
|
+
userId: string;
|
|
136
|
+
now: DateTime;
|
|
137
|
+
}): Promise<OAuthPendingAuthorizationRequestRecord | null>;
|
|
138
|
+
/**
|
|
139
|
+
* Persist a new access/refresh pair atomically during the grace period.
|
|
140
|
+
*/
|
|
141
|
+
issueTokenPair(options: IssueTokenPairOptions): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Conditionally consume a refresh token and persist its replacement pair.
|
|
144
|
+
*/
|
|
145
|
+
rotateRefreshToken(options: RotateRefreshTokenOptions): Promise<boolean>;
|
|
146
|
+
/**
|
|
147
|
+
* Revoke a user's tokens and remove their short-lived OAuth records.
|
|
148
|
+
*/
|
|
149
|
+
revokeAllForUser(options: {
|
|
150
|
+
userId: string;
|
|
151
|
+
now: DateTime;
|
|
152
|
+
}): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Remove revoked and aged OAuth records and return per-table counts.
|
|
155
|
+
*/
|
|
156
|
+
purgeTokens(options: PurgeTokensOptions): Promise<SesamePurgeResult>;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Create a Sesame store backed by the application's Lucid connection.
|
|
160
|
+
*/
|
|
161
|
+
export declare function lucidStore(): SesameStore;
|
|
162
|
+
export { OAuthAccessToken, OAuthAuthorizationCode, OAuthClient, OAuthConsent, OAuthPendingAuthorizationRequest, OAuthRefreshToken, };
|