@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
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
|
|
84
|
+
const identitySubjectId = get(context, 'identity.sub')
|
|
85
85
|
|
|
86
|
-
if (
|
|
87
|
-
mutation.createdBy =
|
|
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
|
|
162
|
+
const identitySubjectId = get(context, 'identity.sub')
|
|
163
163
|
|
|
164
|
-
if (
|
|
165
|
-
mutation.updatedBy =
|
|
164
|
+
if (identitySubjectId) {
|
|
165
|
+
mutation.updatedBy = identitySubjectId
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
const timestamp = new Date().toJSON()
|
package/src/Document.spec.js
CHANGED
|
@@ -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 = {
|
|
25
|
+
const identity = { sub: 'USER_ID' }
|
|
26
26
|
const getContext = () => ({ validator, identity })
|
|
27
27
|
|
|
28
28
|
let id
|
package/src/Operation.spec.js
CHANGED
|
@@ -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 = {
|
|
22
|
+
const identity = { sub: 'USER_ID' }
|
|
23
23
|
const DEFAULT_CONTEXT = { validator, identity }
|
|
24
24
|
|
|
25
25
|
describe('Operation', () => {
|
|
@@ -5,14 +5,13 @@ const { privateKey: PRIVATE_KEY } = require('./keys')
|
|
|
5
5
|
|
|
6
6
|
const createAccessToken = (options, attributes) => {
|
|
7
7
|
const {
|
|
8
|
-
algorithm
|
|
8
|
+
algorithm = 'RS256',
|
|
9
9
|
privateKey = PRIVATE_KEY,
|
|
10
10
|
...jwtOptions
|
|
11
11
|
} = options
|
|
12
12
|
|
|
13
13
|
const payload = {
|
|
14
|
-
sub:
|
|
15
|
-
accountId: 'ACCOUNT_ID',
|
|
14
|
+
sub: 'USER_ID',
|
|
16
15
|
...attributes
|
|
17
16
|
}
|
|
18
17
|
|