aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/oauth/oauth-token-interface.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/oauth/oauth-token-interface.ts')
-rw-r--r--server/models/oauth/oauth-token-interface.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/server/models/oauth/oauth-token-interface.ts b/server/models/oauth/oauth-token-interface.ts
new file mode 100644
index 000000000..815ad5eef
--- /dev/null
+++ b/server/models/oauth/oauth-token-interface.ts
@@ -0,0 +1,48 @@
1import * as Sequelize from 'sequelize'
2import * as Bluebird from 'bluebird'
3
4import { UserModel } from '../user'
5
6export type OAuthTokenInfo = {
7 refreshToken: string
8 refreshTokenExpiresAt: Date,
9 client: {
10 id: number
11 },
12 user: {
13 id: number
14 }
15}
16
17export namespace OAuthTokenMethods {
18 export type GetByRefreshTokenAndPopulateClient = (refreshToken: string) => Bluebird<OAuthTokenInfo>
19 export type GetByTokenAndPopulateUser = (bearerToken: string) => Bluebird<OAuthTokenInstance>
20 export type GetByRefreshTokenAndPopulateUser = (refreshToken: string) => Bluebird<OAuthTokenInstance>
21
22 export type RemoveByUserIdCallback = (err: Error) => void
23 export type RemoveByUserId = (userId, callback) => void
24}
25
26export interface OAuthTokenClass {
27 getByRefreshTokenAndPopulateClient: OAuthTokenMethods.GetByRefreshTokenAndPopulateClient
28 getByTokenAndPopulateUser: OAuthTokenMethods.GetByTokenAndPopulateUser
29 getByRefreshTokenAndPopulateUser: OAuthTokenMethods.GetByRefreshTokenAndPopulateUser
30 removeByUserId: OAuthTokenMethods.RemoveByUserId
31}
32
33export interface OAuthTokenAttributes {
34 accessToken: string
35 accessTokenExpiresAt: Date
36 refreshToken: string
37 refreshTokenExpiresAt: Date
38
39 User?: UserModel
40}
41
42export interface OAuthTokenInstance extends OAuthTokenClass, OAuthTokenAttributes, Sequelize.Instance<OAuthTokenAttributes> {
43 id: number
44 createdAt: Date
45 updatedAt: Date
46}
47
48export interface OAuthTokenModel extends OAuthTokenClass, Sequelize.Model<OAuthTokenInstance, OAuthTokenAttributes> {}