1
0
Fork 0
peertube/server/models/oauth-token-interface.ts
2017-06-10 22:15:25 +02:00

48 lines
1.5 KiB
TypeScript

import * as Sequelize from 'sequelize'
import * as Bluebird from 'bluebird'
import { UserModel } from './user-interface'
export type OAuthTokenInfo = {
refreshToken: string
refreshTokenExpiresAt: Date,
client: {
id: number
},
user: {
id: number
}
}
export namespace OAuthTokenMethods {
export type GetByRefreshTokenAndPopulateClient = (refreshToken: string) => Bluebird<OAuthTokenInfo>
export type GetByTokenAndPopulateUser = (bearerToken: string) => Bluebird<OAuthTokenInstance>
export type GetByRefreshTokenAndPopulateUser = (refreshToken: string) => Bluebird<OAuthTokenInstance>
export type RemoveByUserIdCallback = (err: Error) => void
export type RemoveByUserId = (userId, callback) => void
}
export interface OAuthTokenClass {
getByRefreshTokenAndPopulateClient: OAuthTokenMethods.GetByRefreshTokenAndPopulateClient
getByTokenAndPopulateUser: OAuthTokenMethods.GetByTokenAndPopulateUser
getByRefreshTokenAndPopulateUser: OAuthTokenMethods.GetByRefreshTokenAndPopulateUser
removeByUserId: OAuthTokenMethods.RemoveByUserId
}
export interface OAuthTokenAttributes {
accessToken: string
accessTokenExpiresAt: Date
refreshToken: string
refreshTokenExpiresAt: Date
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> {}