@kravc/dos 1.8.10 → 1.9.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kravc/dos",
3
- "version": "1.8.10",
3
+ "version": "1.9.0",
4
4
  "description": "Convention-based, easy-to-use library for building API-driven serverless services.",
5
5
  "keywords": [
6
6
  "Service",
package/src/Document.js CHANGED
@@ -81,10 +81,10 @@ class Document extends Component {
81
81
  const { validator } = context
82
82
  mutation = validator.normalize(mutation, this.id)
83
83
 
84
- const accountId = get(context, 'identity.accountId')
84
+ const identitySubjectId = get(context, 'identity.sub')
85
85
 
86
- if (accountId) {
87
- mutation.createdBy = accountId
86
+ if (identitySubjectId) {
87
+ mutation.createdBy = identitySubjectId
88
88
  }
89
89
 
90
90
  const timestamp = new Date().toJSON()
@@ -159,10 +159,10 @@ class Document extends Component {
159
159
  static async update(context, query, mutation, originalDocument = null) {
160
160
  mutation = omit(mutation, [ this.idKey, 'createdAt', 'createdBy' ])
161
161
 
162
- const accountId = get(context, 'identity.accountId')
162
+ const identitySubjectId = get(context, 'identity.sub')
163
163
 
164
- if (accountId) {
165
- mutation.updatedBy = accountId
164
+ if (identitySubjectId) {
165
+ mutation.updatedBy = identitySubjectId
166
166
  }
167
167
 
168
168
  const timestamp = new Date().toJSON()
@@ -22,7 +22,7 @@ Profile.schema = loadSync('examples/Profile.yaml')
22
22
 
23
23
  describe('Document', () => {
24
24
  const validator = new Validator([ Profile.schema ])
25
- const identity = { accountId: 'ACCOUNT_ID' }
25
+ const identity = { sub: 'USER_ID' }
26
26
  const getContext = () => ({ validator, identity })
27
27
 
28
28
  let id
@@ -19,7 +19,7 @@ class Profile extends Document {}
19
19
  Profile.schema = loadSync('examples/Profile.yaml')
20
20
 
21
21
  const validator = new Validator([ Profile.schema ])
22
- const identity = { accountId: 'ACCOUNT_ID' }
22
+ const identity = { sub: 'USER_ID' }
23
23
  const DEFAULT_CONTEXT = { validator, identity }
24
24
 
25
25
  describe('Operation', () => {
@@ -44,7 +44,7 @@ class SystemAuthorization {
44
44
  return { isAuthorized: false, error }
45
45
  }
46
46
 
47
- return { isAuthorized: true, accountId: 'SYSTEM' }
47
+ return { isAuthorized: true, isSystem: true }
48
48
  }
49
49
  }
50
50
 
@@ -5,14 +5,13 @@ const { privateKey: PRIVATE_KEY } = require('./keys')
5
5
 
6
6
  const createAccessToken = (options, attributes) => {
7
7
  const {
8
- algorithm = 'RS256',
8
+ algorithm = 'RS256',
9
9
  privateKey = PRIVATE_KEY,
10
10
  ...jwtOptions
11
11
  } = options
12
12
 
13
13
  const payload = {
14
- sub: 'SESSION_ID',
15
- accountId: 'ACCOUNT_ID',
14
+ sub: 'USER_ID',
16
15
  ...attributes
17
16
  }
18
17