PeerTube/server/models/oauth/oauth-token-interface.ts

47 lines
1.4 KiB
TypeScript
Raw Normal View History

import * as Promise from 'bluebird'
2017-11-23 10:36:15 -06:00
import * as Sequelize from 'sequelize'
2017-05-22 13:58:25 -05:00
2017-11-09 10:51:58 -06:00
import { UserModel } from '../account/user-interface'
2017-05-22 13:58:25 -05:00
2017-06-10 15:15:25 -05:00
export type OAuthTokenInfo = {
refreshToken: string
refreshTokenExpiresAt: Date,
client: {
id: number
},
user: {
id: number
}
}
2017-05-22 13:58:25 -05:00
export namespace OAuthTokenMethods {
export type GetByRefreshTokenAndPopulateClient = (refreshToken: string) => Promise<OAuthTokenInfo>
export type GetByTokenAndPopulateUser = (bearerToken: string) => Promise<OAuthTokenInstance>
export type GetByRefreshTokenAndPopulateUser = (refreshToken: string) => Promise<OAuthTokenInstance>
2017-05-22 13:58:25 -05:00
}
export interface OAuthTokenClass {
getByRefreshTokenAndPopulateClient: OAuthTokenMethods.GetByRefreshTokenAndPopulateClient
getByTokenAndPopulateUser: OAuthTokenMethods.GetByTokenAndPopulateUser
getByRefreshTokenAndPopulateUser: OAuthTokenMethods.GetByRefreshTokenAndPopulateUser
}
export interface OAuthTokenAttributes {
accessToken: string
accessTokenExpiresAt: Date
refreshToken: string
refreshTokenExpiresAt: Date
2017-07-12 04:56:02 -05:00
userId?: number
oAuthClientId?: number
2017-05-22 13:58:25 -05:00
User?: UserModel
}
export interface OAuthTokenInstance extends OAuthTokenClass, OAuthTokenAttributes, Sequelize.Instance<OAuthTokenAttributes> {
id: number
createdAt: Date
updatedAt: Date
}
export interface OAuthTokenModel extends OAuthTokenClass, Sequelize.Model<OAuthTokenInstance, OAuthTokenAttributes> {}