@stacksjs/types 0.70.85 → 0.70.87
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/package.json +19 -5
- package/src/ai.ts +0 -41
- package/src/analytics.ts +0 -58
- package/src/api.ts +0 -77
- package/src/app.ts +0 -189
- package/src/attributes.ts +0 -5
- package/src/auth.ts +0 -161
- package/src/auto-imports.ts +0 -8
- package/src/binary.ts +0 -13
- package/src/cache.ts +0 -325
- package/src/cdn.ts +0 -17
- package/src/chat.ts +0 -193
- package/src/cli.ts +0 -445
- package/src/cloud.ts +0 -381
- package/src/cms.ts +0 -14
- package/src/commerce.ts +0 -18
- package/src/components.ts +0 -62
- package/src/configure.ts +0 -13
- package/src/cors.ts +0 -86
- package/src/cron-jobs.ts +0 -146
- package/src/dashboard.ts +0 -218
- package/src/database.ts +0 -117
- package/src/dependencies.ts +0 -69
- package/src/deploy.ts +0 -17
- package/src/dns.ts +0 -470
- package/src/docs.ts +0 -27
- package/src/email.ts +0 -511
- package/src/env.ts +0 -1
- package/src/errors.ts +0 -110
- package/src/events.ts +0 -37
- package/src/exit-code.ts +0 -10
- package/src/file-systems.ts +0 -70
- package/src/git.ts +0 -133
- package/src/hashing.ts +0 -127
- package/src/helpers.ts +0 -9
- package/src/i18n.ts +0 -121
- package/src/index.ts +0 -80
- package/src/library.ts +0 -911
- package/src/logging.ts +0 -62
- package/src/manifest.ts +0 -9
- package/src/marketing.ts +0 -14
- package/src/model-dashboard-augmentation.ts +0 -51
- package/src/model-names.ts +0 -1
- package/src/model.ts +0 -353
- package/src/monitoring.ts +0 -14
- package/src/native.ts +0 -0
- package/src/notifications.ts +0 -153
- package/src/oauth.ts +0 -488
- package/src/pages.ts +0 -10
- package/src/payments.ts +0 -440
- package/src/phone.ts +0 -78
- package/src/ports.ts +0 -20
- package/src/promise.ts +0 -1
- package/src/push.ts +0 -143
- package/src/queue.ts +0 -413
- package/src/reactivity.ts +0 -1
- package/src/realtime.ts +0 -584
- package/src/request.ts +0 -541
- package/src/response.ts +0 -16
- package/src/router.ts +0 -124
- package/src/saas.ts +0 -33
- package/src/scheduler.ts +0 -1
- package/src/search-engine.ts +0 -251
- package/src/security.ts +0 -23
- package/src/server.ts +0 -16
- package/src/services.ts +0 -211
- package/src/settings-config.ts +0 -10
- package/src/sms.ts +0 -265
- package/src/stack-extensions.ts +0 -184
- package/src/stacks.ts +0 -339
- package/src/storage.ts +0 -173
- package/src/table-names.ts +0 -1
- package/src/tables.ts +0 -57
- package/src/team.ts +0 -8
- package/src/ui.ts +0 -197
- package/src/utils.ts +0 -46
package/src/oauth.ts
DELETED
|
@@ -1,488 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OAuth & Token Types
|
|
3
|
-
*
|
|
4
|
-
* Comprehensive type definitions for OAuth 2.0 authentication,
|
|
5
|
-
* personal access tokens, and related functionality.
|
|
6
|
-
*
|
|
7
|
-
* This module provides type-safe interfaces for:
|
|
8
|
-
* - Access tokens (JWT-like tokens for API authentication)
|
|
9
|
-
* - Refresh tokens (for obtaining new access tokens)
|
|
10
|
-
* - OAuth clients (applications authorized to request tokens)
|
|
11
|
-
* - Database row types (for raw database queries)
|
|
12
|
-
* - Token creation and validation results
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
// ============================================================================
|
|
16
|
-
// BRANDED TYPES
|
|
17
|
-
// ============================================================================
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Branded type for authentication tokens.
|
|
21
|
-
* Using a branded type ensures tokens are not accidentally confused with regular strings.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* const token: AuthToken = 'abc123' as AuthToken
|
|
26
|
-
* // or use createAuthToken helper
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export type AuthToken = string & { readonly __brand: 'AuthToken' }
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Branded type for refresh tokens.
|
|
33
|
-
* Distinct from AuthToken to prevent accidental misuse.
|
|
34
|
-
*/
|
|
35
|
-
export type RefreshTokenString = string & { readonly __brand: 'RefreshToken' }
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Branded type for OAuth client secrets.
|
|
39
|
-
*/
|
|
40
|
-
export type ClientSecret = string & { readonly __brand: 'ClientSecret' }
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Branded type for hashed token values stored in database.
|
|
44
|
-
*/
|
|
45
|
-
export type HashedToken = string & { readonly __brand: 'HashedToken' }
|
|
46
|
-
|
|
47
|
-
// ============================================================================
|
|
48
|
-
// TOKEN SCOPE TYPES
|
|
49
|
-
// ============================================================================
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Common OAuth scopes/abilities.
|
|
53
|
-
* Use these predefined scopes or define custom ones.
|
|
54
|
-
*/
|
|
55
|
-
export type CommonScope =
|
|
56
|
-
| '*' // Wildcard - all permissions
|
|
57
|
-
| 'read'
|
|
58
|
-
| 'write'
|
|
59
|
-
| 'delete'
|
|
60
|
-
| 'admin'
|
|
61
|
-
| 'user:read'
|
|
62
|
-
| 'user:write'
|
|
63
|
-
| 'posts:read'
|
|
64
|
-
| 'posts:write'
|
|
65
|
-
| 'posts:delete'
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Token scope - can be common scopes or custom string scopes.
|
|
69
|
-
*/
|
|
70
|
-
export type TokenScope = CommonScope | (string & {})
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Array of token scopes/abilities.
|
|
74
|
-
*/
|
|
75
|
-
export type TokenScopes = TokenScope[]
|
|
76
|
-
|
|
77
|
-
// ============================================================================
|
|
78
|
-
// ACCESS TOKEN TYPES
|
|
79
|
-
// ============================================================================
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Access token entity with full metadata.
|
|
83
|
-
* Represents a token after being retrieved from the database.
|
|
84
|
-
*/
|
|
85
|
-
export interface AccessToken {
|
|
86
|
-
/** Unique token identifier */
|
|
87
|
-
readonly id: number
|
|
88
|
-
/** ID of the user this token belongs to */
|
|
89
|
-
readonly userId: number
|
|
90
|
-
/** ID of the OAuth client that issued this token */
|
|
91
|
-
readonly clientId: number
|
|
92
|
-
/** Human-readable name for the token */
|
|
93
|
-
readonly name: string
|
|
94
|
-
/** Array of scopes/abilities granted to this token */
|
|
95
|
-
readonly scopes: TokenScopes
|
|
96
|
-
/** Whether the token has been revoked */
|
|
97
|
-
readonly revoked: boolean
|
|
98
|
-
/** When the token expires (null = never expires) */
|
|
99
|
-
readonly expiresAt: Date | null
|
|
100
|
-
/** When the token was created */
|
|
101
|
-
readonly createdAt: Date
|
|
102
|
-
/** When the token was last updated */
|
|
103
|
-
readonly updatedAt: Date
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Personal access token with additional metadata.
|
|
108
|
-
* Extended version used in the Auth class.
|
|
109
|
-
*/
|
|
110
|
-
export interface PersonalAccessToken extends AccessToken {
|
|
111
|
-
/** Abilities is an alias for scopes */
|
|
112
|
-
readonly abilities: TokenScopes
|
|
113
|
-
/** The plain text token (only available immediately after creation) */
|
|
114
|
-
readonly plainTextToken?: AuthToken
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Mutable version of AccessToken for internal use.
|
|
119
|
-
*/
|
|
120
|
-
export interface MutableAccessToken {
|
|
121
|
-
id: number
|
|
122
|
-
userId: number
|
|
123
|
-
clientId: number
|
|
124
|
-
name: string
|
|
125
|
-
scopes: TokenScopes
|
|
126
|
-
revoked: boolean
|
|
127
|
-
expiresAt: Date | null
|
|
128
|
-
createdAt: Date
|
|
129
|
-
updatedAt: Date
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// ============================================================================
|
|
133
|
-
// REFRESH TOKEN TYPES
|
|
134
|
-
// ============================================================================
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Refresh token entity for obtaining new access tokens.
|
|
138
|
-
*/
|
|
139
|
-
export interface RefreshToken {
|
|
140
|
-
/** Unique refresh token identifier */
|
|
141
|
-
readonly id: number
|
|
142
|
-
/** ID of the associated access token */
|
|
143
|
-
readonly accessTokenId: number
|
|
144
|
-
/** Whether the refresh token has been revoked */
|
|
145
|
-
readonly revoked: boolean
|
|
146
|
-
/** When the refresh token expires */
|
|
147
|
-
readonly expiresAt: Date | null
|
|
148
|
-
/** When the refresh token was created */
|
|
149
|
-
readonly createdAt: Date
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// ============================================================================
|
|
153
|
-
// OAUTH CLIENT TYPES
|
|
154
|
-
// ============================================================================
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* OAuth client types for different authentication flows.
|
|
158
|
-
*/
|
|
159
|
-
export type OAuthClientType = 'personal_access' | 'password' | 'authorization_code' | 'client_credentials'
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* OAuth client entity representing an authorized application.
|
|
163
|
-
*/
|
|
164
|
-
export interface OAuthClient {
|
|
165
|
-
/** Unique client identifier */
|
|
166
|
-
readonly id: number
|
|
167
|
-
/** Client name */
|
|
168
|
-
readonly name: string
|
|
169
|
-
/** Client secret (hashed in database) */
|
|
170
|
-
readonly secret: ClientSecret | string
|
|
171
|
-
/** Authentication provider */
|
|
172
|
-
readonly provider: string | null
|
|
173
|
-
/** OAuth redirect URI */
|
|
174
|
-
readonly redirect: string
|
|
175
|
-
/** Whether this is a personal access client */
|
|
176
|
-
readonly personalAccessClient: boolean
|
|
177
|
-
/** Whether this is a password grant client */
|
|
178
|
-
readonly passwordClient: boolean
|
|
179
|
-
/** Whether the client has been revoked */
|
|
180
|
-
readonly revoked: boolean
|
|
181
|
-
/** When the client was created */
|
|
182
|
-
readonly createdAt: Date
|
|
183
|
-
/** When the client was last updated */
|
|
184
|
-
readonly updatedAt: Date | null
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// ============================================================================
|
|
188
|
-
// DATABASE ROW TYPES
|
|
189
|
-
// ============================================================================
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Raw database row for oauth_access_tokens table.
|
|
193
|
-
* Use this when working with raw SQL queries.
|
|
194
|
-
*/
|
|
195
|
-
export interface OAuthAccessTokenRow {
|
|
196
|
-
id: number
|
|
197
|
-
user_id: number
|
|
198
|
-
oauth_client_id: number
|
|
199
|
-
token: string
|
|
200
|
-
name: string | null
|
|
201
|
-
scopes: string | null
|
|
202
|
-
revoked: boolean | number
|
|
203
|
-
expires_at: string | null
|
|
204
|
-
created_at: string | null
|
|
205
|
-
updated_at: string | null
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Raw database row for oauth_refresh_tokens table.
|
|
210
|
-
*/
|
|
211
|
-
export interface OAuthRefreshTokenRow {
|
|
212
|
-
id: number
|
|
213
|
-
access_token_id: number
|
|
214
|
-
token: string
|
|
215
|
-
revoked: boolean | number
|
|
216
|
-
expires_at: string | null
|
|
217
|
-
created_at: string | null
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Raw database row for oauth_clients table.
|
|
222
|
-
*/
|
|
223
|
-
export interface OAuthClientRow {
|
|
224
|
-
id: number
|
|
225
|
-
name: string
|
|
226
|
-
secret: string
|
|
227
|
-
provider: string | null
|
|
228
|
-
redirect: string
|
|
229
|
-
personal_access_client: boolean | number
|
|
230
|
-
password_client: boolean | number
|
|
231
|
-
revoked: boolean | number
|
|
232
|
-
created_at: string | null
|
|
233
|
-
updated_at: string | null
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// ============================================================================
|
|
237
|
-
// TOKEN CREATION TYPES
|
|
238
|
-
// ============================================================================
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Options for creating a new token.
|
|
242
|
-
*/
|
|
243
|
-
export interface TokenCreateOptions {
|
|
244
|
-
/** Human-readable name for the token */
|
|
245
|
-
name?: string
|
|
246
|
-
/** Scopes/abilities to grant to the token */
|
|
247
|
-
abilities?: TokenScopes
|
|
248
|
-
/** Alternative name for abilities */
|
|
249
|
-
scopes?: TokenScopes
|
|
250
|
-
/** When the token should expire */
|
|
251
|
-
expiresAt?: Date
|
|
252
|
-
/** Token expiry in minutes (alternative to expiresAt) */
|
|
253
|
-
expiresInMinutes?: number
|
|
254
|
-
/** Whether to create a refresh token */
|
|
255
|
-
withRefreshToken?: boolean
|
|
256
|
-
/** Refresh token expiry in days */
|
|
257
|
-
refreshExpiresInDays?: number
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Result returned when creating a personal access token.
|
|
262
|
-
*/
|
|
263
|
-
export interface PersonalAccessTokenResult {
|
|
264
|
-
/** The created access token entity */
|
|
265
|
-
readonly accessToken: AccessToken
|
|
266
|
-
/** The plain text token - SAVE THIS, it won't be shown again */
|
|
267
|
-
readonly plainTextToken: AuthToken | string
|
|
268
|
-
/** The plain text refresh token (if requested) */
|
|
269
|
-
readonly refreshToken?: RefreshTokenString | string
|
|
270
|
-
/** Token expiry in seconds (for OAuth2 compatibility) */
|
|
271
|
-
readonly expiresIn: number
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Result returned when creating a token via the Auth class.
|
|
276
|
-
*/
|
|
277
|
-
export interface NewAccessToken {
|
|
278
|
-
/** The created access token entity */
|
|
279
|
-
readonly accessToken: PersonalAccessToken
|
|
280
|
-
/** The plain text token */
|
|
281
|
-
readonly plainTextToken: AuthToken
|
|
282
|
-
/**
|
|
283
|
-
* Plain text refresh token paired with the access token. Single-use:
|
|
284
|
-
* exchanging it for a new access token also rotates this refresh
|
|
285
|
-
* value. Omitted when the caller passed `withRefreshToken: false`.
|
|
286
|
-
*/
|
|
287
|
-
readonly refreshToken?: string
|
|
288
|
-
/** Access-token expiry in seconds (OAuth2 `expires_in` shape) */
|
|
289
|
-
readonly expiresIn?: number
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Result returned when refreshing a token.
|
|
294
|
-
*/
|
|
295
|
-
export interface RefreshTokenResult {
|
|
296
|
-
/** The new access token entity */
|
|
297
|
-
readonly accessToken: AccessToken
|
|
298
|
-
/** The new plain text access token */
|
|
299
|
-
readonly plainTextToken: AuthToken | string
|
|
300
|
-
/** The new plain text refresh token */
|
|
301
|
-
readonly refreshToken: RefreshTokenString | string
|
|
302
|
-
/** Token expiry in seconds */
|
|
303
|
-
readonly expiresIn: number
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// ============================================================================
|
|
307
|
-
// OAUTH CLIENT CREATION TYPES
|
|
308
|
-
// ============================================================================
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Options for creating a new OAuth client.
|
|
312
|
-
*/
|
|
313
|
-
export interface CreateClientOptions {
|
|
314
|
-
/** Client name */
|
|
315
|
-
name: string
|
|
316
|
-
/** OAuth redirect URI */
|
|
317
|
-
redirect: string
|
|
318
|
-
/** User ID who owns this client */
|
|
319
|
-
userId?: number
|
|
320
|
-
/** Whether this is a personal access client */
|
|
321
|
-
personalAccessClient?: boolean
|
|
322
|
-
/** Whether this is a password grant client */
|
|
323
|
-
passwordClient?: boolean
|
|
324
|
-
/** Authentication provider */
|
|
325
|
-
provider?: string
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Result returned when creating a new OAuth client.
|
|
330
|
-
*/
|
|
331
|
-
export interface CreateClientResult {
|
|
332
|
-
/** The created client entity */
|
|
333
|
-
readonly client: OAuthClient
|
|
334
|
-
/** The plain text client secret - SAVE THIS, it won't be shown again */
|
|
335
|
-
readonly plainTextSecret: ClientSecret | string
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// ============================================================================
|
|
339
|
-
// TOKEN VALIDATION TYPES
|
|
340
|
-
// ============================================================================
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Result of token validation.
|
|
344
|
-
*/
|
|
345
|
-
export interface TokenValidationResult {
|
|
346
|
-
/** Whether the token is valid */
|
|
347
|
-
readonly valid: boolean
|
|
348
|
-
/** The access token if valid */
|
|
349
|
-
readonly token?: AccessToken
|
|
350
|
-
/** Error message if invalid */
|
|
351
|
-
readonly error?: string
|
|
352
|
-
/** Whether the token was rotated */
|
|
353
|
-
readonly rotated?: boolean
|
|
354
|
-
/** New token if rotated */
|
|
355
|
-
readonly newToken?: AuthToken
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Token payload extracted from JWT-like tokens.
|
|
360
|
-
*/
|
|
361
|
-
export interface TokenPayload {
|
|
362
|
-
/** Subject (user ID) */
|
|
363
|
-
readonly sub: number
|
|
364
|
-
/** Issued at timestamp */
|
|
365
|
-
readonly iat: number
|
|
366
|
-
/** Expiration timestamp */
|
|
367
|
-
readonly exp: number
|
|
368
|
-
/** JWT ID */
|
|
369
|
-
readonly jti: string
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// ============================================================================
|
|
373
|
-
// AUTHENTICATION CREDENTIALS
|
|
374
|
-
// ============================================================================
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* User credentials for authentication.
|
|
378
|
-
*/
|
|
379
|
-
export interface AuthCredentials {
|
|
380
|
-
/** User's email address */
|
|
381
|
-
email?: string
|
|
382
|
-
/** User's password */
|
|
383
|
-
password?: string
|
|
384
|
-
/** Additional credential fields (for custom auth) */
|
|
385
|
-
[key: string]: string | undefined
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Login result containing user and token.
|
|
390
|
-
*/
|
|
391
|
-
export interface LoginResult<TUser = unknown> {
|
|
392
|
-
/** The authenticated user */
|
|
393
|
-
readonly user: TUser
|
|
394
|
-
/** The authentication token */
|
|
395
|
-
readonly token: AuthToken
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// ============================================================================
|
|
399
|
-
// DATABASE DRIVER TYPES
|
|
400
|
-
// ============================================================================
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Supported database drivers for OAuth tables.
|
|
404
|
-
*/
|
|
405
|
-
export type DatabaseDriver = 'postgres' | 'mysql' | 'sqlite'
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* SQL syntax configuration based on database driver.
|
|
409
|
-
*/
|
|
410
|
-
export interface DatabaseSqlSyntax {
|
|
411
|
-
/** Current timestamp function */
|
|
412
|
-
readonly now: string
|
|
413
|
-
/** Boolean true value */
|
|
414
|
-
readonly boolTrue: string
|
|
415
|
-
/** Boolean false value */
|
|
416
|
-
readonly boolFalse: string
|
|
417
|
-
/** Auto-increment keyword */
|
|
418
|
-
readonly autoIncrement: string
|
|
419
|
-
/** Primary key syntax */
|
|
420
|
-
readonly primaryKey: string
|
|
421
|
-
/** Parameter placeholder function */
|
|
422
|
-
readonly param: (index: number) => string
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// ============================================================================
|
|
426
|
-
// TYPE GUARDS
|
|
427
|
-
// ============================================================================
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Type guard to check if a value is an AccessToken.
|
|
431
|
-
*/
|
|
432
|
-
export function isAccessToken(value: unknown): value is AccessToken {
|
|
433
|
-
return (
|
|
434
|
-
typeof value === 'object'
|
|
435
|
-
&& value !== null
|
|
436
|
-
&& 'id' in value
|
|
437
|
-
&& 'userId' in value
|
|
438
|
-
&& 'clientId' in value
|
|
439
|
-
&& 'scopes' in value
|
|
440
|
-
)
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Type guard to check if a value is a PersonalAccessToken.
|
|
445
|
-
*/
|
|
446
|
-
export function isPersonalAccessToken(value: unknown): value is PersonalAccessToken {
|
|
447
|
-
return isAccessToken(value) && 'abilities' in value
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Type guard to check if a value is an OAuthClient.
|
|
452
|
-
*/
|
|
453
|
-
export function isOAuthClient(value: unknown): value is OAuthClient {
|
|
454
|
-
return (
|
|
455
|
-
typeof value === 'object'
|
|
456
|
-
&& value !== null
|
|
457
|
-
&& 'id' in value
|
|
458
|
-
&& 'name' in value
|
|
459
|
-
&& 'secret' in value
|
|
460
|
-
&& 'redirect' in value
|
|
461
|
-
)
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
// ============================================================================
|
|
465
|
-
// UTILITY TYPES
|
|
466
|
-
// ============================================================================
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* Make specific properties of a type optional.
|
|
470
|
-
*/
|
|
471
|
-
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Make specific properties of a type required.
|
|
475
|
-
*/
|
|
476
|
-
export type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* Extract the user type from a generic context.
|
|
480
|
-
*/
|
|
481
|
-
export type ExtractUser<T> = T extends { user: infer U } ? U : never
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* Token with user attached.
|
|
485
|
-
*/
|
|
486
|
-
export interface TokenWithUser<TUser = unknown> extends AccessToken {
|
|
487
|
-
readonly user: TUser
|
|
488
|
-
}
|