@positivegrid/pg-mongoose-schema 26.7.1 → 27.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/models/oauth.js +14 -4
  2. package/package.json +1 -1
package/models/oauth.js CHANGED
@@ -16,7 +16,12 @@ module.exports = function (mongoose) {
16
16
  code: { type: String, required: true },
17
17
  clientId: { type: ObjectId, ref: 'OathClient', required: true },
18
18
  redirectURI: { type: String, required: true },
19
- userId: { type: String, required: true }
19
+ userId: { type: ObjectId, ref: 'User', required: true },
20
+ scopes: [{ type: String, required: true }],
21
+ expiresAt: { type: Date, required: true },
22
+ codeChallenge: { type: String },
23
+ codeChallengeMethod: { type: String, default: 'S256' },
24
+ date: { type: Date, default: Date.now }
20
25
  }, { collection: 'auth_authorizationCodes', toJSON: { virtuals: true }, toObject: { virtuals: true } })
21
26
  AuthorizationCodeSchema.plugin(deepPopulate, {})
22
27
 
@@ -24,15 +29,20 @@ module.exports = function (mongoose) {
24
29
  const AccessTokenSchema = new Schema({
25
30
  token: { type: String, required: true },
26
31
  expirationDate: { type: Date, required: true },
27
- userId: { type: String, required: true },
28
- clientId: { type: ObjectId, ref: 'OathClient', required: true }
32
+ userId: { type: ObjectId, ref: 'User', required: true },
33
+ clientId: { type: ObjectId, ref: 'OathClient', required: true },
34
+ scopes: [{ type: String, required: true }],
35
+ date: { type: Date, default: Date.now }
29
36
  }, { collection: 'auth_accessTokens', toJSON: { virtuals: true }, toObject: { virtuals: true } })
30
37
 
31
38
  // refreshTokens
32
39
  const RefreshTokenSchema = new Schema({
33
40
  refreshToken: { type: String, required: true },
34
41
  clientId: { type: ObjectId, ref: 'OathClient', required: true },
35
- userId: { type: String, required: true }
42
+ expirationDate: { type: Date, required: true },
43
+ userId: { type: ObjectId, ref: 'User', required: true },
44
+ scopes: [{ type: String, required: true }],
45
+ date: { type: Date, default: Date.now }
36
46
  }, { collection: 'auth_refreshTokens', toJSON: { virtuals: true }, toObject: { virtuals: true } })
37
47
 
38
48
  mongoose.model('OauthClient', clientSchema)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@positivegrid/pg-mongoose-schema",
3
- "version": "26.7.1",
3
+ "version": "27.0.0",
4
4
  "description": "Positive Grid mongoose schema",
5
5
  "author": "Ferrari Lee <shiyung@positivegrid.com>",
6
6
  "homepage": "https://git.positivegrid.com:8443/backend/pg-mongoose-schema",