boho 0.9.0 → 1.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.
- package/LICENSE +1 -1
- package/README.md +13 -1
- package/dist/boho.cjs +9 -2
- package/dist/boho.iife.js +19 -0
- package/dist/boho.iife.js.map +1 -0
- package/dist/boho.js +19 -0
- package/dist/boho.js.map +1 -0
- package/package.json +14 -8
- package/rollup.config.js +47 -0
- package/src/boho.js +9 -19
- package/src/constants.js +24 -25
- package/src/{browserDefault.js → index.js} +1 -1
- package/src/sha256-mbp.js +1 -1
- package/test/{AUTH_process_ESM.js → AUTH_process.js} +8 -2
- package/test/{ENC_PACK_CJS.cjs → ENC_PACK.cjs} +3 -3
- package/test/{ENC_PACK_ESM.js → ENC_PACK.js} +4 -1
- package/test/{RAND_ESM.js → RAND.js} +3 -3
- package/test-browser/index.html +2 -1
- package/test-browser/loader.html +8 -6
- package/dist/boho.esm.js +0 -3
- package/dist/boho.esm.js.map +0 -1
- package/dist/boho.min.js +0 -3
- package/dist/boho.min.js.map +0 -1
- package/dist/boho.mjs +0 -2
- package/test/AUTH_process_CJS.cjs +0 -93
- package/test/RAND_CJS.cjs +0 -16
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
const { describe, it } = require('node:test');
|
|
2
|
-
const assert = require('node:assert');
|
|
3
|
-
const BOHO = require('boho')
|
|
4
|
-
const Boho = BOHO.Boho
|
|
5
|
-
const MBP = BOHO.MBP
|
|
6
|
-
const MetaSize = BOHO.MetaSize
|
|
7
|
-
const BohoMsg = BOHO.BohoMsg
|
|
8
|
-
const Meta = BOHO.Meta
|
|
9
|
-
|
|
10
|
-
describe('AUTH process CJS', function () {
|
|
11
|
-
const id = 'id'
|
|
12
|
-
const key = 'key'
|
|
13
|
-
|
|
14
|
-
// client side
|
|
15
|
-
const c = new Boho()
|
|
16
|
-
c.set_id8(id)
|
|
17
|
-
c.set_key(key)
|
|
18
|
-
|
|
19
|
-
// server side
|
|
20
|
-
const s = new Boho()
|
|
21
|
-
const auth_nonce_buffer = s.auth_nonce()
|
|
22
|
-
const auth_hmac_buffer = c.auth_hmac(auth_nonce_buffer)
|
|
23
|
-
|
|
24
|
-
const unpack = MBP.unpack(auth_hmac_buffer, Meta.AUTH_HMAC)
|
|
25
|
-
|
|
26
|
-
// Find hashID8 from DATABASE then set the id and key.
|
|
27
|
-
s.set_id8(id)
|
|
28
|
-
|
|
29
|
-
s.set_key('wrong-key') // if key is wrong.
|
|
30
|
-
const check_auth_hmack_fail = s.check_auth_hmac(unpack)
|
|
31
|
-
|
|
32
|
-
s.set_key(key) // if correct.
|
|
33
|
-
const auth_ack_buffer = s.check_auth_hmac(unpack)
|
|
34
|
-
|
|
35
|
-
const auth_ack_buffer_with_incorrect_hmac = MBP.Buffer.alloc(9)
|
|
36
|
-
const isCorrectSeverHMAC = c.check_auth_ack_hmac(auth_ack_buffer)
|
|
37
|
-
|
|
38
|
-
auth_ack_buffer.copy(auth_ack_buffer_with_incorrect_hmac)
|
|
39
|
-
auth_ack_buffer_with_incorrect_hmac[2] ^= 0x55 // change hmac
|
|
40
|
-
const wrongSeverHMACResult = c.check_auth_ack_hmac(auth_ack_buffer_with_incorrect_hmac)
|
|
41
|
-
|
|
42
|
-
// 1. client send AUTH_REQ first
|
|
43
|
-
|
|
44
|
-
describe('2. server reply AUTH_NONCE', function () {
|
|
45
|
-
it('should return static size buffer', function () {
|
|
46
|
-
assert.equal(auth_nonce_buffer.byteLength, MetaSize.AUTH_NONCE)
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('should pack[0] is header type ', function () {
|
|
50
|
-
assert.ok(auth_nonce_buffer[0], BohoMsg.AUTH_NONCE)
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
describe('3. client reply AUTH_HMAC', function () {
|
|
55
|
-
it('should return static size buffer', function () {
|
|
56
|
-
assert.equal(auth_hmac_buffer.byteLength, MetaSize.AUTH_HMAC)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('should pack[0] is header type ', function () {
|
|
60
|
-
assert.ok(auth_hmac_buffer[0], BohoMsg.AUTH_HMAC)
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
describe('3. server check AUTH_HMACK pack', function () {
|
|
65
|
-
it('3.1. should success unpack', function () {
|
|
66
|
-
assert.ok(typeof unpack === 'object')
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
describe('3.2. check_auth_hmac(obj) ', function () {
|
|
70
|
-
// wrong key of id.
|
|
71
|
-
it('3.2.1. should return false when wrong key', function () {
|
|
72
|
-
assert.ok(!check_auth_hmack_fail)
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
// correct id and key
|
|
76
|
-
it('3-2.2. should return AUTH_ACK buffer pack when correct key', function () {
|
|
77
|
-
assert.equal(auth_ack_buffer[0], BohoMsg.AUTH_ACK)
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
describe('4. client process', function () {
|
|
83
|
-
describe('4.1 check_auth_ack_hmac()', function () {
|
|
84
|
-
it('should return true when correct AUTH_ACK ', function () {
|
|
85
|
-
assert.ok(isCorrectSeverHMAC)
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
it('should return false when AUTH_ACK has wrong hmac', function () {
|
|
89
|
-
assert.ok(!wrongSeverHMACResult)
|
|
90
|
-
})
|
|
91
|
-
})
|
|
92
|
-
})
|
|
93
|
-
})
|
package/test/RAND_CJS.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const { describe, it } = require('node:test');
|
|
2
|
-
const assert = require('node:assert');
|
|
3
|
-
const RAND = require('boho').RAND
|
|
4
|
-
|
|
5
|
-
describe('RAND CJS', function () {
|
|
6
|
-
describe('for number', function () {
|
|
7
|
-
const num = 16
|
|
8
|
-
it('should return Uint8Array', function () {
|
|
9
|
-
assert.ok(RAND(num) instanceof Uint8Array)
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
it('should return number-bytes size of Uint8Array', function () {
|
|
13
|
-
assert.ok(RAND(num).byteLength === num)
|
|
14
|
-
})
|
|
15
|
-
})
|
|
16
|
-
})
|