-
Notifications
You must be signed in to change notification settings - Fork 145
/
refreshToken.js
89 lines (81 loc) · 2.77 KB
/
refreshToken.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
var
error = require('./../error');
/**
* Typical refreshToken schema:
* userId: { type: "object", required: true },
* clientId: { type: "object", required: true },
* token: { type: "string", required: true, unique: true },
* scope: { type: "array", required: false,
* items: { type: "string", enum: ["possible", "scope", "values"] },
* }
*
* Primary key: token
* Unique key: userId + clientId pair should be unique
*/
/**
* Gets userId parameter of the refreshToken
*
* @param refreshToken {Object} RefreshToken object
*/
module.exports.getUserId = function(refreshToken) {
throw new error.serverError('RefreshToken model method "getUserId" is not implemented');
};
/**
* Gets clientId parameter of the refreshToken
*
* @param refreshToken {Object} RefreshToken object
*/
module.exports.getClientId = function(refreshToken) {
throw new error.serverError('RefreshToken model method "getClientId" is not implemented');
};
/**
* Gets scope parameter of the refreshToken
*
* @param refreshToken {Object} RefreshToken object
*/
module.exports.getScope = function(refreshToken) {
throw new error.serverError('RefreshToken model method "getScope" is not implemented');
};
/**
* Fetches refreshToken object by token
* Should be implemented with server logic
*
* @param token {String} Unique identifier
* @param cb {Function} Function callback ->(error, object)
*/
module.exports.fetchByToken = function(token, cb) {
throw new error.serverError('RefreshToken model method "fetchByToken" is not implemented');
};
/**
* Removes refreshToken (revokes) for the client-user pair
* Should be implemented with server logic
*
* @param userId {String} Unique identifier
* @param clientId {String} Unique identifier
* @param cb {Function} Function callback ->(error)
*/
module.exports.removeByUserIdClientId = function(userId, clientId, cb) {
throw new error.serverError('RefreshToken model method "removeByUserIdClientId" is not implemented');
};
/**
* Removes refreshToken (revokes) by token value
* Should be implemented with server logic
*
* @param refreshToken {String} Unique identifier
* @param cb {Function} Function callback ->(error)
*/
module.exports.removeByRefreshToken = function(refreshToken, cb) {
throw new error.serverError('RefreshToken model method "removeByRefreshToken" is not implemented');
};
/**
* Create refreshToken object (generate + save)
* Should be implemented with server logic
*
* @param userId {String} Unique identifier
* @param clientId {String} Unique identifier
* @param scope {Array|null} Scope values
* @param cb {Function} Function callback ->(error, token{String})
*/
module.exports.create = function(userId, clientId, scope, cb) {
throw new error.serverError('RefreshToken model method "create" is not implemented');
};