@contember/engine-http 1.1.0-alpha.5 → 1.1.0-alpha.8
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/dist/src/common/index.js +5 -1
- package/dist/src/common/index.js.map +1 -1
- package/dist/src/content/GraphQlSchemaFactory.js +2 -1
- package/dist/src/content/GraphQlSchemaFactory.js.map +1 -1
- package/dist/src/content/index.js +5 -1
- package/dist/src/content/index.js.map +1 -1
- package/dist/src/graphql/errors.js +2 -2
- package/dist/src/graphql/errors.js.map +1 -1
- package/dist/src/graphql/index.js +5 -1
- package/dist/src/graphql/index.js.map +1 -1
- package/dist/src/index.js +5 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/koa/index.js +5 -1
- package/dist/src/koa/index.js.map +1 -1
- package/dist/src/misc/index.js +5 -1
- package/dist/src/misc/index.js.map +1 -1
- package/dist/src/project-common/index.js +5 -1
- package/dist/src/project-common/index.js.map +1 -1
- package/dist/src/system/index.js +5 -1
- package/dist/src/system/index.js.map +1 -1
- package/dist/src/tenant/index.js +5 -1
- package/dist/src/tenant/index.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/utils/CryptoWrapper.js +5 -1
- package/dist/src/utils/CryptoWrapper.js.map +1 -1
- package/dist/tests/cases/unit/crypto.test.js +28 -26
- package/dist/tests/cases/unit/crypto.test.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -13
- package/src/content/GraphQlSchemaFactory.ts +1 -1
- package/src/graphql/errors.ts +1 -1
- package/tests/cases/unit/crypto.test.ts +18 -21
- package/vite.config.js +3 -0
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-http",
|
|
3
|
-
"version": "1.1.0-alpha.
|
|
3
|
+
"version": "1.1.0-alpha.8",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"typings": "dist/src/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "
|
|
8
|
+
"test": "vitest"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@apollographql/graphql-playground-html": "^1.6.24",
|
|
12
|
-
"@contember/database": "^1.1.0-alpha.
|
|
13
|
-
"@contember/engine-content-api": "^1.1.0-alpha.
|
|
14
|
-
"@contember/engine-plugins": "^1.1.0-alpha.
|
|
15
|
-
"@contember/engine-system-api": "^1.1.0-alpha.
|
|
16
|
-
"@contember/engine-tenant-api": "^1.1.0-alpha.
|
|
17
|
-
"@contember/graphql-utils": "^1.1.0-alpha.
|
|
18
|
-
"@contember/schema": "^1.1.0-alpha.
|
|
19
|
-
"@contember/schema-utils": "^1.1.0-alpha.
|
|
12
|
+
"@contember/database": "^1.1.0-alpha.8",
|
|
13
|
+
"@contember/engine-content-api": "^1.1.0-alpha.8",
|
|
14
|
+
"@contember/engine-plugins": "^1.1.0-alpha.8",
|
|
15
|
+
"@contember/engine-system-api": "^1.1.0-alpha.8",
|
|
16
|
+
"@contember/engine-tenant-api": "^1.1.0-alpha.8",
|
|
17
|
+
"@contember/graphql-utils": "^1.1.0-alpha.8",
|
|
18
|
+
"@contember/schema": "^1.1.0-alpha.8",
|
|
19
|
+
"@contember/schema-utils": "^1.1.0-alpha.8",
|
|
20
20
|
"@graphql-tools/merge": "^6.2.14",
|
|
21
|
-
"@graphql-tools/schema": "^
|
|
21
|
+
"@graphql-tools/schema": "^8.3.5",
|
|
22
22
|
"@types/lru-cache": "^5.1.0",
|
|
23
23
|
"accepts": "^1.3.7",
|
|
24
24
|
"bcrypt": "^5.0.1",
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
"@types/lru-cache": "^5.1.0",
|
|
36
36
|
"@types/node": "^17.0.5",
|
|
37
37
|
"@types/uuid": "^8.3.0",
|
|
38
|
-
"graphql": "^15.4.0"
|
|
39
|
-
"uvu": "^0.5.3"
|
|
38
|
+
"graphql": "^15.4.0"
|
|
40
39
|
},
|
|
41
40
|
"peerDependencies": {
|
|
42
41
|
"graphql": "^14.6.0",
|
|
@@ -46,7 +46,7 @@ export class GraphQlSchemaFactory {
|
|
|
46
46
|
}
|
|
47
47
|
const { permissions, verifier } = this.permissionFactory.createPermissions(schema, identity)
|
|
48
48
|
|
|
49
|
-
const authorizator = new Authorizator(permissions)
|
|
49
|
+
const authorizator = new Authorizator(permissions, schema.acl.customPrimary ?? false)
|
|
50
50
|
const dataSchemaBuilder = this.graphqlSchemaBuilderFactory.create(schema.model, authorizator)
|
|
51
51
|
const contentSchemaFactory = new IntrospectionSchemaDefinitionFactory(
|
|
52
52
|
new IntrospectionSchemaFactory(
|
package/src/graphql/errors.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GraphQLError } from 'graphql'
|
|
2
2
|
import { UserError } from '@contember/engine-content-api'
|
|
3
3
|
import { GraphQLListener } from './execution'
|
|
4
|
-
import { ForbiddenError } from '
|
|
4
|
+
import { ForbiddenError } from '@contember/graphql-utils'
|
|
5
5
|
|
|
6
6
|
interface ErrorContext {
|
|
7
7
|
user: string
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { test } from '
|
|
2
|
-
import * as assert from 'uvu/assert'
|
|
1
|
+
import { test, assert } from 'vitest'
|
|
3
2
|
import { CryptoWrapper } from '../../../src'
|
|
4
3
|
import * as crypto from 'crypto'
|
|
5
4
|
|
|
@@ -16,22 +15,22 @@ test('encryption v1 16 chars string (block size)', async () => {
|
|
|
16
15
|
const cryptoWrapper = new CryptoWrapper(encryptionKey)
|
|
17
16
|
const input = 'a'.repeat(16)
|
|
18
17
|
const inputBuffer = Buffer.from(input)
|
|
19
|
-
assert.
|
|
18
|
+
assert.strictEqual(inputBuffer.length, 16)
|
|
20
19
|
const value = encryptOld(inputBuffer)
|
|
21
20
|
const decrypted = await cryptoWrapper.decrypt(value, 1)
|
|
22
|
-
assert.
|
|
23
|
-
assert.
|
|
21
|
+
assert.strictEqual(decrypted.needsReEncrypt, true)
|
|
22
|
+
assert.strictEqual(decrypted.value.toString(), input)
|
|
24
23
|
})
|
|
25
24
|
|
|
26
25
|
test('encryption v1 17 chars string', async () => {
|
|
27
26
|
const cryptoWrapper = new CryptoWrapper(encryptionKey)
|
|
28
27
|
const input = 'a'.repeat(17)
|
|
29
28
|
const inputBuffer = Buffer.from(input)
|
|
30
|
-
assert.
|
|
29
|
+
assert.strictEqual(inputBuffer.length, 17)
|
|
31
30
|
const value = encryptOld(inputBuffer)
|
|
32
31
|
const decrypted = await cryptoWrapper.decrypt(value, 1)
|
|
33
|
-
assert.
|
|
34
|
-
assert.
|
|
32
|
+
assert.strictEqual(decrypted.needsReEncrypt, true)
|
|
33
|
+
assert.strictEqual(decrypted.value.toString(), input)
|
|
35
34
|
})
|
|
36
35
|
|
|
37
36
|
|
|
@@ -39,12 +38,12 @@ test('encryption v2 16 chars string (block size)', async () => {
|
|
|
39
38
|
const cryptoWrapper = new CryptoWrapper(encryptionKey)
|
|
40
39
|
const input = 'a'.repeat(16)
|
|
41
40
|
const inputBuffer = Buffer.from(input)
|
|
42
|
-
assert.
|
|
41
|
+
assert.strictEqual(inputBuffer.length, 16)
|
|
43
42
|
const value = await cryptoWrapper.encrypt(inputBuffer)
|
|
44
|
-
assert.
|
|
43
|
+
assert.strictEqual(value.version, 2)
|
|
45
44
|
const decrypted = await cryptoWrapper.decrypt(value.value, value.version)
|
|
46
|
-
assert.
|
|
47
|
-
assert.
|
|
45
|
+
assert.strictEqual(decrypted.needsReEncrypt, false)
|
|
46
|
+
assert.strictEqual(decrypted.value.toString(), input)
|
|
48
47
|
})
|
|
49
48
|
|
|
50
49
|
|
|
@@ -52,27 +51,25 @@ test('encryption v2 17 chars string', async () => {
|
|
|
52
51
|
const cryptoWrapper = new CryptoWrapper(encryptionKey)
|
|
53
52
|
const input = 'a'.repeat(17)
|
|
54
53
|
const inputBuffer = Buffer.from(input)
|
|
55
|
-
assert.
|
|
54
|
+
assert.strictEqual(inputBuffer.length, 17)
|
|
56
55
|
const value = await cryptoWrapper.encrypt(inputBuffer)
|
|
57
|
-
assert.
|
|
56
|
+
assert.strictEqual(value.version, 2)
|
|
58
57
|
const decrypted = await cryptoWrapper.decrypt(value.value, value.version)
|
|
59
|
-
assert.
|
|
60
|
-
assert.
|
|
58
|
+
assert.strictEqual(decrypted.needsReEncrypt, false)
|
|
59
|
+
assert.strictEqual(decrypted.value.toString(), input)
|
|
61
60
|
})
|
|
62
61
|
|
|
63
62
|
test('encryption v2: corrupted auth key', async () => {
|
|
64
63
|
const cryptoWrapper = new CryptoWrapper(encryptionKey)
|
|
65
|
-
const inputBuffer = Buffer.from('
|
|
64
|
+
const inputBuffer = Buffer.from('ab')
|
|
66
65
|
const value = await cryptoWrapper.encrypt(inputBuffer)
|
|
67
66
|
let err: any = { message: 'not failed' }
|
|
68
67
|
try {
|
|
69
|
-
const corrupted =
|
|
68
|
+
const corrupted = value.value.swap16()
|
|
70
69
|
await cryptoWrapper.decrypt(corrupted, value.version)
|
|
71
70
|
} catch (e) {
|
|
72
71
|
err = e
|
|
73
72
|
}
|
|
74
|
-
assert.
|
|
73
|
+
assert.equal('Unsupported state or unable to authenticate data', err.message)
|
|
75
74
|
})
|
|
76
75
|
|
|
77
|
-
|
|
78
|
-
test.run()
|
package/vite.config.js
ADDED