Skip to content

Commit e01c309

Browse files
authored
Merge pull request #143 from filip26/feat/v07-prerelease
v0.7.0
2 parents ac4f3af + 82e7f24 commit e01c309

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1230
-248
lines changed

.github/workflows/java17-publish.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,25 @@ on:
88
jobs:
99
publish:
1010
runs-on: ubuntu-latest
11-
environment: RELEASE
11+
environment: maven-central
1212
steps:
1313
- uses: actions/checkout@v4
1414
- name: Set up JDK 17
1515
uses: actions/setup-java@v4
1616
with:
1717
java-version: '17'
1818
distribution: 'temurin'
19-
server-id: ossrh
20-
- name: Import GPG Key
21-
uses: crazy-max/ghaction-import-gpg@v6
22-
with:
23-
gpg_private_key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
24-
passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
19+
cache: 'maven'
20+
server-id: central
21+
server-username: CENTRAL_TOKEN_ID
22+
server-password: CENTRAL_TOKEN_SECRET
23+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
24+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
2525
- name: Publish package
26-
run: mvn -B -Pmaven-central -Dgpg.passphrase=${{secrets.MAVEN_GPG_PASSPHRASE}} -s maven-settings.xml deploy
26+
run: mvn -B -Pmaven-central deploy
2727
env:
28-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
29-
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
28+
CENTRAL_TOKEN_ID: ${{ secrets.CENTRAL_TOKEN_ID }}
29+
CENTRAL_TOKEN_SECRET: ${{ secrets.CENTRAL_TOKEN_SECRET }}
30+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
31+
MAVEN_GPG_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
32+

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,9 @@ var dictionary = DocumentDictionaryBuilder
8787
.set("ecdsa-sd-2023", 2)
8888
.set("eddsa-rdfc-2022", 3)
8989
.set("ecdsa-xi-2023", 4))
90-
.uri("did:key:zDnaeWjKfs1ob9QcgasjYSPEMkwq31hmvSAWPVAgnrt1e9GKj", 1)
91-
.uri("did:key:zDnaeWjKfs1ob9QcgasjYSPEMkwq31hmvSAWPVAgnrt1e9GKj#zDnaeWjKfs1ob9QcgasjYSPEMkwq31hmvSAWPVAgnrt1e9GKj", 2)
92-
.uri("https://sandbox.platform.veres.dev/statuses/z19rJ4oGrbFCqf3cNTVDHSbNd/status-lists", 3)
93-
.uri("did:key:zDnaeZSD9XcuULaS8qmgDUa6TMg2QjF9xABnZK42awDH3BEzj", 4)
90+
.uri("did:key:zD...", 1)
91+
.uri("did:key:zD...", 2)
92+
.uri("https://example.../status-lists", 3)
9493
.build();
9594

9695
// use with encoder
@@ -167,8 +166,6 @@ Java 17+
167166

168167
```
169168

170-
Iridium CBOR-LD for Android is distributed under a commercial license. [Contact](mailto:filip26@gmail.com)
171-
172169
#### JSON-P Provider
173170

174171
Add JSON-P provider, if it is not on the classpath already.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>com.apicatalog</groupId>
99
<artifactId>iridium-cbor-ld</artifactId>
10-
<version>0.7.0-SNAPSHOT</version>
10+
<version>0.7.0</version>
1111

1212
<packaging>jar</packaging>
1313
<name>Iridium CBOR-LD</name>

src/main/java/com/apicatalog/cbor/CborComparison.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
public class CborComparison {
1414

15+
protected CborComparison() {
16+
// protected
17+
}
18+
1519
public static final boolean equals(byte[] value1, byte[] value2) throws CborException {
1620

1721
if (value1 == null || value2 == null) {

src/main/java/com/apicatalog/cborld/CborLd.java

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
11
package com.apicatalog.cborld;
22

33
import com.apicatalog.cborld.config.ConfigV1;
4+
import com.apicatalog.cborld.decoder.Decoder;
45
import com.apicatalog.cborld.decoder.DecoderBuilder;
56
import com.apicatalog.cborld.decoder.DecoderConfig;
7+
import com.apicatalog.cborld.encoder.Encoder;
68
import com.apicatalog.cborld.encoder.EncoderBuilder;
79
import com.apicatalog.cborld.encoder.EncoderConfig;
810

911
/**
10-
* High level API to process CBOR-LD.
12+
* High-level entry point for working with CBOR-LD.
13+
* <p>
14+
* Provides static factory methods to configure and create CBOR-LD
15+
* {@link Encoder} and {@link Decoder} instances.
1116
*/
1217
public class CborLd {
1318

14-
public static final byte LEADING_BYTE = (byte) 0xD9; // tag
19+
/** CBOR tag leading byte. */
20+
public static final byte LEADING_BYTE = (byte) 0xD9;
1521

16-
public static final byte[] VERSION_1_BYTES = new byte[] { (byte) 0xCB, 0x1D };
17-
public static final byte VERSION_06_BYTE = (byte) 0x06;
18-
public static final byte VERSION_05_BYTE = (byte) 0x05;
22+
/** CBOR-LD version 1 identifier. */
23+
static final byte[] VERSION_1_BYTES = new byte[] { (byte) 0xCB, 0x1D };
24+
/** CBOR-LD legacy version 0.6 identifier. */
25+
static final byte VERSION_06_BYTE = (byte) 0x06;
26+
/** CBOR-LD legacy version 0.5 identifier. */
27+
static final byte VERSION_05_BYTE = (byte) 0x05;
1928

29+
/** Utility class — not meant to be instantiated. */
2030
protected CborLd() {
2131
/* protected */ }
2232

2333
/**
2434
* Creates a new {@link DecoderBuilder} instance with default configuration.
2535
* <p>
26-
* The builder is initialized with all available format version decoders.
36+
* The builder is initialized with default settings provided by
37+
* {@link ConfigV1}.
2738
*
2839
* @return a new {@link DecoderBuilder} instance
2940
*/
@@ -32,13 +43,13 @@ public static DecoderBuilder createDecoder() {
3243
}
3344

3445
/**
35-
* Creates a new {@link DecoderBuilder} instance with the specified decoder
36-
* configurations.
46+
* Creates a new {@link DecoderBuilder} instance using the provided decoder
47+
* configuration(s).
3748
* <p>
38-
* This method allows initializing the builder with one or more custom
39-
* {@link DecoderConfig} options to control decoding behavior.
49+
* This allows customization of decoding behavior by specifying one or more
50+
* {@link DecoderConfig} options.
4051
*
41-
* @param config one or more initial decoder configurations
52+
* @param config one or more decoder configurations
4253
* @return a new {@link DecoderBuilder} instance
4354
*/
4455
public static DecoderBuilder createDecoder(DecoderConfig... config) {
@@ -49,8 +60,8 @@ public static DecoderBuilder createDecoder(DecoderConfig... config) {
4960
* Creates a new {@link DecoderBuilder} instance for the specified CBOR-LD
5061
* format version(s).
5162
* <p>
52-
* This method allows initializing the builder with support for specific
53-
* {@link CborLdVersion}s only.
63+
* Use this method to explicitly support only certain {@link CborLdVersion}s
64+
* during decoding.
5465
*
5566
* @param version one or more supported CBOR-LD format versions
5667
* @return a new {@link DecoderBuilder} instance
@@ -60,27 +71,35 @@ public static DecoderBuilder createDecoder(CborLdVersion... version) {
6071
}
6172

6273
/**
63-
* Create a new {@link EncoderBuilder} allowing to configure an encoder. The
64-
* builder is initialized by {@link ConfigV1}.
65-
*
74+
* Creates a new {@link EncoderBuilder} instance using the default
75+
* configuration.
76+
* <p>
77+
* The builder is initialized with default settings provided by
78+
* {@link ConfigV1}.
79+
*
6680
* @return a new {@link EncoderBuilder} instance
67-
*
6881
*/
6982
public static EncoderBuilder createEncoder() {
7083
return createEncoder(ConfigV1.INSTANCE);
7184
}
7285

7386
/**
74-
* Create a new {@link EncoderBuilder} allowing to configure an encoder.
75-
*
76-
* @param config an initial configuration
87+
* Creates a new {@link EncoderBuilder} instance with a custom configuration.
88+
*
89+
* @param config the encoder configuration to apply
7790
* @return a new {@link EncoderBuilder} instance
78-
*
7991
*/
8092
public static EncoderBuilder createEncoder(EncoderConfig config) {
8193
return EncoderBuilder.of(config);
8294
}
8395

96+
/**
97+
* Creates a new {@link EncoderBuilder} instance for the specified CBOR-LD
98+
* format version.
99+
*
100+
* @param version the CBOR-LD version to use
101+
* @return a new {@link EncoderBuilder} instance
102+
*/
84103
public static EncoderBuilder createEncoder(CborLdVersion version) {
85104
return EncoderBuilder.of(version);
86105
}

src/main/java/com/apicatalog/cborld/CborLdVersion.java

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@
33
import java.util.Arrays;
44
import java.util.Objects;
55

6+
/**
7+
* Supported CBOR-LD format versions.
8+
* <p>
9+
* Each version is represented by a unique byte signature that can be used to
10+
* identify the encoded format.
11+
*/
612
public enum CborLdVersion {
713

14+
/** CBOR-LD version 1.0 */
815
V1(CborLd.VERSION_1_BYTES),
916

10-
// legacy
17+
/** Legacy version 0.6 */
1118
V06(new byte[] { CborLd.VERSION_06_BYTE }),
19+
20+
/** Legacy version 0.5 */
1221
V05(new byte[] { CborLd.VERSION_05_BYTE });
1322

1423
private final byte[] bytes;
@@ -17,16 +26,26 @@ public enum CborLdVersion {
1726
this.bytes = bytes;
1827
}
1928

29+
/**
30+
* Returns the version signature bytes associated with this CBOR-LD version.
31+
*
32+
* @return the version identifier bytes
33+
*/
2034
public byte[] bytes() {
2135
return bytes;
2236
}
2337

2438
/**
25-
* Identifies the CborLdVersion from a given byte array and offset.
39+
* Determines the {@link CborLdVersion} based on the content of a byte array
40+
* starting at the given offset.
41+
* <p>
42+
* This method compares the input bytes against all known version identifiers.
2643
*
27-
* @param bytes The input byte array
28-
* @param offset The offset to start checking from
29-
* @return Matching CborLdVersion or {@code null} if not found
44+
* @param bytes the byte array containing the encoded CBOR-LD data
45+
* @param offset the starting offset to compare the version bytes
46+
* @return the matching {@code CborLdVersion}, or {@code null} if no match is
47+
* found
48+
* @throws NullPointerException if {@code bytes} is {@code null}
3049
*/
3150
public static CborLdVersion of(byte[] bytes, int offset) {
3251
Objects.requireNonNull(bytes);
@@ -35,10 +54,12 @@ public static CborLdVersion of(byte[] bytes, int offset) {
3554
var versionBytes = version.bytes;
3655
int end = offset + versionBytes.length;
3756

38-
if (end <= bytes.length && Arrays.mismatch(versionBytes, 0, versionBytes.length, bytes, offset, end) == -1) {
57+
if (end <= bytes.length &&
58+
Arrays.mismatch(versionBytes, 0, versionBytes.length, bytes, offset, end) == -1) {
3959
return version;
4060
}
4161
}
62+
4263
return null;
4364
}
4465
}

src/main/java/com/apicatalog/cborld/context/ObjectExpansion.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,6 @@ private String processTypeScoped(final ActiveContext typeContext) throws JsonLdE
223223
.map(JsonString::getString)
224224
.sorted()
225225
.collect(Collectors.toList());
226-
// entry.save();
227-
// final List<String> terms = ValueCursor
228-
// .toStream(entry.mapKey(key))
229-
// .filter(ValueCursor::isString)
230-
// .map(ValueCursor::stringValue)
231-
// .sorted()
232-
// .collect(Collectors.toList());
233-
234-
// entry.restore();
235226

236227
for (final String term : terms) {
237228

src/main/java/com/apicatalog/cborld/context/mapping/DecoderContextMapping.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ class DecoderContextMapping implements Mapping {
4141

4242
final DataItem decodeValue(final DataItem value, String term) {
4343

44-
Collection<String> TYPE = Arrays.asList(Keywords.TYPE);
44+
var type = Arrays.asList(Keywords.TYPE);
4545

4646
for (final ValueDecoder decoder : valueDecoders) {
4747
try {
4848
final JsonValue decoded = decoder.decode(this, value, term,
4949
typeKeyNameMap.isTypeKey(term)
50-
? TYPE
50+
? type
5151
: Collections.emptySet());
5252

5353
if (decoded == null) {

0 commit comments

Comments
 (0)