rbor 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +79 -0
- data/lib/rbor.rb +2 -1
- metadata +7 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '08c79cb896b6acb68848c207ceba42f7c70200438d2bba93117b2b5de9b1c366'
|
|
4
|
+
data.tar.gz: ee6f5a5e5b6e97b048ed81b537854769c1979921f280fcb62879a853fba59a0b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 26c1a09c4e61a53d9ae40d70cd3f12a7e44611bce8c5e372daa6a1b5efdbca64f4b8bd8a75ca31158423d61c97eb6131cebd5d5cb1d5107ee3ad0306145764d6
|
|
7
|
+
data.tar.gz: f09583740bfaa7bad50c4a40605a1f99f06e7b6179b2830e981a49d371fbcbdec9a121e3a8e7ce06c78ec4f2407424267146274954a3592f4d55887f4ea3cf9c
|
data/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Ruby-cBOR
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/rb/rbor)
|
|
4
|
+
|
|
5
|
+
The Concise Binary Object Representation (CBOR) is a data format whose
|
|
6
|
+
design goals include the possibility of extremely small code size, fairly
|
|
7
|
+
small message size, and extensibility without the need for version negotiation
|
|
8
|
+
(RFC8949). It is used in different protocols like the Client to Authenticator
|
|
9
|
+
Protocol CTAP2 which is a essential part of FIDO2 authenticators/ Passkeys.
|
|
10
|
+
|
|
11
|
+
This gem implements de-/serialization for the following Ruby classes:
|
|
12
|
+
|
|
13
|
+
- `Integer`
|
|
14
|
+
- `String`
|
|
15
|
+
- `Array`
|
|
16
|
+
- `Hash`
|
|
17
|
+
- `FalseClass`
|
|
18
|
+
- `TrueClass`
|
|
19
|
+
- `NilClass`
|
|
20
|
+
|
|
21
|
+
Furthermore, serialization adheres to the [CTAP2 canonical CBOR encoding form](https://fidoalliance.org/specs/fido-v2.0-ps-20190130/fido-client-to-authenticator-protocol-v2.0-ps-20190130.html#ctap2-canonical-cbor-encoding-form), i.e.:
|
|
22
|
+
|
|
23
|
+
- Integers are encoded as small as possible.
|
|
24
|
+
- The expression of lengths is encoded as small as possible.
|
|
25
|
+
- No support for indefinite-length items.
|
|
26
|
+
- Keys of Hashes/Maps are sorted lowest value to highest. Sorting rules are:
|
|
27
|
+
- If the major types are different, the one with the lower value in numerical order sorts earlier.
|
|
28
|
+
- If two keys have different lengths, the shorter one sorts earlier.
|
|
29
|
+
- If two keys have the same length, the one with the lower value in (byte-wise) lexical order sorts earlier.
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
Requiring `rbor` exposes two methods for the aforementioned classes: `cbor_serialize`
|
|
34
|
+
and `cbor_deserialize`. Use `cbor_serialize` to translate an object into CBOR and
|
|
35
|
+
`cbor_deserialize` to de-serialize CBOR data (`String` or `Array`) into a Ruby object.
|
|
36
|
+
|
|
37
|
+
```irb
|
|
38
|
+
3.3.5 :001 > require 'rbor'
|
|
39
|
+
=> true
|
|
40
|
+
3.3.5 :002 > {1 => 2, 3 => 3}.cbor_serialize
|
|
41
|
+
=> "\xA2\x01\x02\x03\x03"
|
|
42
|
+
3.3.5 :003 > "\xA2\x01\x02\x03\x03".cbor_deserialize
|
|
43
|
+
=> [{1=>2, 3=>3}, []]
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The `cbor_deserialize` method return an `Array` with two values: a de-serialized Ruby object
|
|
47
|
+
and an `Array` representing the remaining bytes.
|
|
48
|
+
|
|
49
|
+
## Build
|
|
50
|
+
|
|
51
|
+
### Build gem
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
gem build rbor.gemspec
|
|
55
|
+
gem push rbor-x.y.z.gem
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Docs
|
|
59
|
+
|
|
60
|
+
The project uses Yard to build the documentation. You can install it using
|
|
61
|
+
the `gem` command.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
gem install yard
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
To build the documentation run:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
yard
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Testing
|
|
74
|
+
|
|
75
|
+
You can run tests with [rspec](https://rspec.info/):
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
rspec --format doc
|
|
79
|
+
```
|
data/lib/rbor.rb
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# (RFC8949). It is used in different protocols like the Client to Authenticator
|
|
5
5
|
# Protocol CTAP2 which is a essential part of FIDO2 authenticators/ Passkeys.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
module Cbor
|
|
8
8
|
|
|
9
9
|
end
|
|
10
10
|
|
|
@@ -13,3 +13,4 @@ require_relative 'rbor/string.rb'
|
|
|
13
13
|
require_relative 'rbor/array.rb'
|
|
14
14
|
require_relative 'rbor/hash.rb'
|
|
15
15
|
require_relative 'rbor/bool.rb'
|
|
16
|
+
require_relative 'rbor/streaming.rb'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rbor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David P. Sugar
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-09-
|
|
11
|
+
date: 2024-09-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: The Concise Binary Object Representation (CBOR) is a data format whose
|
|
14
14
|
design goals include the possibility of extremely small code size, fairly small
|
|
@@ -18,8 +18,10 @@ description: The Concise Binary Object Representation (CBOR) is a data format wh
|
|
|
18
18
|
email: david@thesugar.de
|
|
19
19
|
executables: []
|
|
20
20
|
extensions: []
|
|
21
|
-
extra_rdoc_files:
|
|
21
|
+
extra_rdoc_files:
|
|
22
|
+
- README.md
|
|
22
23
|
files:
|
|
24
|
+
- README.md
|
|
23
25
|
- lib/rbor.rb
|
|
24
26
|
- lib/rbor/array.rb
|
|
25
27
|
- lib/rbor/bool.rb
|
|
@@ -29,7 +31,8 @@ files:
|
|
|
29
31
|
homepage: https://rubygems.org/gems/rbor
|
|
30
32
|
licenses:
|
|
31
33
|
- MIT
|
|
32
|
-
metadata:
|
|
34
|
+
metadata:
|
|
35
|
+
source_code_uri: https://github.com/r4gus/rbor
|
|
33
36
|
post_install_message:
|
|
34
37
|
rdoc_options: []
|
|
35
38
|
require_paths:
|