]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/oauth/oauth-token-interface.ts
First upload step is ok
[github/Chocobozzz/PeerTube.git] / server / models / oauth / oauth-token-interface.ts
CommitLineData
6fcd19ba 1import * as Promise from 'bluebird'
39445ead 2import * as Sequelize from 'sequelize'
e02643f3 3
e4f97bab 4import { UserModel } from '../account/user-interface'
e02643f3 5
69818c93
C
6export type OAuthTokenInfo = {
7 refreshToken: string
8 refreshTokenExpiresAt: Date,
9 client: {
10 id: number
11 },
12 user: {
13 id: number
14 }
15}
16
e02643f3 17export namespace OAuthTokenMethods {
6fcd19ba
C
18 export type GetByRefreshTokenAndPopulateClient = (refreshToken: string) => Promise<OAuthTokenInfo>
19 export type GetByTokenAndPopulateUser = (bearerToken: string) => Promise<OAuthTokenInstance>
20 export type GetByRefreshTokenAndPopulateUser = (refreshToken: string) => Promise<OAuthTokenInstance>
e02643f3
C
21}
22
23export interface OAuthTokenClass {
24 getByRefreshTokenAndPopulateClient: OAuthTokenMethods.GetByRefreshTokenAndPopulateClient
25 getByTokenAndPopulateUser: OAuthTokenMethods.GetByTokenAndPopulateUser
26 getByRefreshTokenAndPopulateUser: OAuthTokenMethods.GetByRefreshTokenAndPopulateUser
e02643f3
C
27}
28
29export interface OAuthTokenAttributes {
30 accessToken: string
31 accessTokenExpiresAt: Date
32 refreshToken: string
33 refreshTokenExpiresAt: Date
34
f981dae8
C
35 userId?: number
36 oAuthClientId?: number
e02643f3
C
37 User?: UserModel
38}
39
40export interface OAuthTokenInstance extends OAuthTokenClass, OAuthTokenAttributes, Sequelize.Instance<OAuthTokenAttributes> {
41 id: number
42 createdAt: Date
43 updatedAt: Date
44}
45
46export interface OAuthTokenModel extends OAuthTokenClass, Sequelize.Model<OAuthTokenInstance, OAuthTokenAttributes> {}