Skip to content

Commit

Permalink
chore: Merge branch 'release/v9.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuthor committed Dec 11, 2023
2 parents cb8ffc5 + 5eb16c3 commit e38869d
Show file tree
Hide file tree
Showing 31 changed files with 1,544 additions and 1,986 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
subcommands: |
python3 scripts/download_wasm.py
npm install
kms-version: 4.9.1
kms-version: 4.10.0
findex-cloud-version: 0.3.1

lint:
Expand All @@ -34,7 +34,7 @@ jobs:
with:
subcommands: |
npm test
kms-version: 4.9.1
kms-version: 4.10.0
kms-jwe-key:
'{"kty": "OKP","d": "MPEVJwdRqGM_qhJOUb5hR0Xr9EvwMLZGnkf-eDj5fU8","use": "enc","crv": "X25519","kid": "DX3GC+Fx3etxfRJValQNbqaB0gs=","x":
"gdF-1TtAjsFqNWr9nwhGUlFG38qrDUqYgcILgtYrpTY","alg": "ECDH-ES"}'
Expand All @@ -48,8 +48,8 @@ jobs:
needs: test
uses: Cosmian/reusable_workflows/.github/workflows/cloudproof_kms_js.yml@develop
with:
branch: v2.0.0
kms-version: 4.9.1
branch: v3.0.0
kms-version: 4.10.0

cloudproof_java:
needs: test
Expand All @@ -60,7 +60,7 @@ jobs:
extension: so
destination: linux-x86-64
os: ubuntu-20.04
kms-version: 4.9.1
kms-version: 4.10.0
findex-cloud-version: 0.3.1
copy_fresh_build: false
copy_regression_files: |
Expand All @@ -74,7 +74,8 @@ jobs:
with:
branch: develop
target: x86_64-unknown-linux-gnu
kms-version: 4.9.1
kms-version: 4.10.0
findex-cloud-version: 0.3.1
copy_fresh_build: false
copy_regression_files: |
cp ./cloudproof_js/non_regression_vector.json tests/data/cover_crypt/non_regression/js_non_regression_vector.json
Expand Down Expand Up @@ -106,7 +107,7 @@ jobs:
sleep 5
cd ../test
node chrome.mjs http://localhost:8090 http://kms:9998
kms-version: 4.9.1
kms-version: 4.10.0
findex-cloud-version: 0.3.1

example_reactjs:
Expand All @@ -122,7 +123,7 @@ jobs:
sleep 5
cd ../test
node chrome.mjs http://localhost:8090 http://kms:9998
kms-version: 4.9.1
kms-version: 4.10.0
findex-cloud-version: 0.3.1

example_browser:
Expand All @@ -136,7 +137,7 @@ jobs:
python3 -m http.server &
sleep 3
node test.mjs
kms-version: 4.9.1
kms-version: 4.10.0
findex-cloud-version: 0.3.1

example_webpack:
Expand All @@ -158,7 +159,7 @@ jobs:
cd examples/nodejs
npm install
node test.mjs 10
kms-version: 4.9.1
kms-version: 4.10.0
findex-cloud-version: 0.3.1
secrets: inherit

Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ repos:
- id: dockerfile_lint
- id: markdown-toc

- repo: https://github.com/tcort/markdown-link-check
rev: v3.11.2
hooks:
- id: markdown-link-check
args: [-q]

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

All notable changes to this project will be documented in this file.

## [9.6.0] - 2023-12-11

### Bug Fixes

- Support Findex v6

### Documentation

- CI badge
- Update readme and changelog (#155)

## [9.5.1] - 2023-11-14

### Bug Fixes
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cloudproof Javascript Library

![Build status](https://github.com/Cosmian/cloudproof_js/actions/workflows/ci.yml/badge.svg)
![Build status](https://github.com/Cosmian/cloudproof_js/actions/workflows/ci.yml/badge.svg?branch=main)

The library provides a Typescript-friendly API to the **Cloudproof Encryption** product of the [Cosmian Ubiquitous Encryption platform](https://cosmian.com).

Expand Down Expand Up @@ -36,7 +36,7 @@ The library is based on:

## Getting started

Please [check the online documentation](https://docs.cosmian.com/cloudproof_encryption/use_cases_benefits/) for details on using the CloudProof APIs.
Please [check the online documentation](https://docs.cosmian.com/) for details on using the CloudProof APIs.

You can also look the [`examples` directory](./examples) for examples with multiple JS frameworks/technologies (the [`README`](./examples/README.md) of the [`examples`](./examples) folder can guide you to the best example for you use case).

Expand Down Expand Up @@ -65,7 +65,7 @@ Local encryption and decryption with [CoverCrypt](https://github.com/Cosmian/cov
This table shows the minimum version correspondence between the various components.

| `cloudproof_js` | CoverCrypt lib | Findex | KMS Server |
| --------------- | -------------- | ------ | ---------- |
|-----------------|----------------|--------|------------|
| 1.0.6 | 6.0.1 | 0.5.0 | 2.2.0 |
| 3.1.0 | 6.0.7 | 0.7.0 | 2.3.0 |
| 3.1.0, 4.\* | 6.0.7 | 0.7.0 | 2.3.0 |
Expand All @@ -77,7 +77,7 @@ This table shows the minimum version correspondence between the various componen
From the version 8.0.0, `cloudproof_js` depends on [cloudproof_rust](https://github.com/Cosmian/cloudproof_rust) which wraps the interfaces of `CoverCrypt` and `Findex`.

| `cloudproof_js` | Cloudproof Rust lib | KMS Server |
| --------------- | ------------------- | ---------- |
|-----------------|---------------------|------------|
| 8.0.0 | 1.0.0 | 4.2.0 |
| 8.1.0 | 1.1.0 | 4.3.0 |
| 9.0.0 | 2.0.1 | 4.3.0 |
Expand All @@ -87,3 +87,4 @@ From the version 8.0.0, `cloudproof_js` depends on [cloudproof_rust](https://git
| 9.4.0,9.4.1 | 2.2.4 | 4.7.0 |
| 9.5.0 | 2.3.0 | 4.9.0 |
| 9.5.1 | 2.3.0 | 4.9.1 |
| 9.6.0 | 2.4.0 | 4.10.0 |
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: "3"
services:
kms:
container_name: kms
image: ghcr.io/cosmian/kms:4.9.1
image: ghcr.io/cosmian/kms:4.10.0
ports:
- 9998:9998
environment:
Expand Down
76 changes: 22 additions & 54 deletions examples/full_text_search/index.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import fs from "fs"
import readline from "readline"
import {
Location,
Findex,
FindexKey,
Label,
callbacksExamplesBetterSqlite3,
Keyword,
} from "cloudproof_js"
import { Data, Findex, Keyword, sqliteDbInterfaceExample } from "cloudproof_js"
import path from "path"
import { fileURLToPath } from "url"
import { randomBytes } from "crypto"
Expand All @@ -31,12 +24,15 @@ for (const file of files) {
}

// Init Findex with random key and random label
const { upsert, search } = await Findex()
const masterKey = new FindexKey(randomBytes(16))
const label = new Label(randomBytes(10))

const key = randomBytes(16)
const label = randomBytes(10).toString()
const db = new Database(":memory:")
const callbacks = callbacksExamplesBetterSqlite3(db)
const interfaces = await sqliteDbInterfaceExample(db)
const findex = new Findex(key, label)
await findex.instantiateCustomInterface(
interfaces.entryInterface,
interfaces.chainInterface,
)

const uniqueWords = new Set()

Expand Down Expand Up @@ -69,48 +65,34 @@ for (const [name, content] of Object.entries(contents)) {

positions.push(index)
start = index + word.length
const locationBytes = Uint8Array.from([
const dataBytes = Uint8Array.from([
...encode(nameBytes.length),
...nameBytes,
...encode(index),
...encode(index + word.length),
])

toUpsert.push({
indexedValue: new Location(locationBytes),
indexedValue: new Data(dataBytes),
keywords: [word],
})
}
}

await upsert(
masterKey,
label,
toUpsert,
[],
callbacks.fetchEntries,
callbacks.upsertEntries,
callbacks.insertChains,
)
await findex.add(toUpsert)
}

console.log("---")
console.log(`Add aliases from word's stem to word…`)
console.log("---")
await upsert(
masterKey,
label,
await findex.add(
Array.from(uniqueWords)
.map((word) => ({ word, stem: natural.PorterStemmer.stem(word) }))
.filter(({ word, stem }) => word !== stem)
.map(({ word, stem }) => ({
indexedValue: Keyword.fromString(word),
keywords: [stem],
})),
[],
callbacks.fetchEntries,
callbacks.upsertEntries,
callbacks.insertChains,
)

console.log("---")
Expand All @@ -119,25 +101,17 @@ console.log("---")
// Since phonetic is not a correct word (for example the phonetic for "Phrase" is "FRS")
// we don't want a search for "FRS" to return "Phrase". To prevent that, we'll add a prefix to "FRS"
// which will make searching for it highly unlikely. We'll use this prefix in our search below.
await upsert(
masterKey,
label,
await findex.add(
Array.from(uniqueWords).map((word) => ({
indexedValue: Keyword.fromString(word),
keywords: ["phonetic_prefix_" + natural.Metaphone.process(word)],
})),
[],
callbacks.fetchEntries,
callbacks.upsertEntries,
callbacks.insertChains,
)

console.log("---")
console.log(`Add aliases from word's synonyms to word…`)
console.log("---")
await upsert(
masterKey,
label,
await findex.add(
Array.from(uniqueWords)
.map((word) => {
const wordSynonyms = synonyms(word)
Expand All @@ -151,10 +125,6 @@ await upsert(
}
})
.filter((synonymsToUpsert) => synonymsToUpsert !== null),
[],
callbacks.fetchEntries,
callbacks.upsertEntries,
callbacks.insertChains,
)

const rl = readline.createInterface({
Expand All @@ -171,20 +141,18 @@ while (true) {
const stem = natural.PorterStemmer.stem(query)
const phonetic = natural.Metaphone.process(query)

const rawResults = await search(
masterKey,
label,
[query, stem, "phonetic_prefix_" + phonetic],
callbacks.fetchEntries,
callbacks.fetchChains,
)
const rawResults = await findex.search([
query,
stem,
"phonetic_prefix_" + phonetic,
])

console.log(
`Searching for ${query} (${stem}, ${phonetic}), ${rawResults.total()} results.`,
)

// Parse locations and compute distances
const results = rawResults.locations().map((result) => {
// Parse data and compute distances
const results = rawResults.data().map((result) => {
const { result: filenameLength, tail } = decode(result.bytes)
const filename = new TextDecoder().decode(tail.slice(0, filenameLength))

Expand Down
40 changes: 12 additions & 28 deletions examples/nodejs_search_imdb/index.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import fs from "fs"
import readline from "readline"
import {
Location,
Findex,
FindexKey,
Label,
callbacksExamplesBetterSqlite3,
} from "cloudproof_js"
import { Data, Findex, sqliteDbInterfaceExample } from "cloudproof_js"
import path from "path"
import { fileURLToPath } from "url"
import { randomBytes } from "crypto"
Expand Down Expand Up @@ -37,12 +31,16 @@ if (!fs.existsSync(dataFilename)) {
const input = fs.createReadStream(dataFilename)

// Init Findex with random key and random label
const { upsert, search } = await Findex()
const masterKey = new FindexKey(randomBytes(16))
const label = new Label(randomBytes(10))
const key = randomBytes(16)
const label = randomBytes(10).toString()

const db = new Database(":memory:")
const callbacks = callbacksExamplesBetterSqlite3(db)
const interfaces = await sqliteDbInterfaceExample(db)
const findex = new Findex(key, label)
await findex.instantiateCustomInterface(
interfaces.entryInterface,
interfaces.chainInterface,
)

// Number of movies to index in a single `upsert` call
let numberOfMoviesIndexedSoFar = 0
Expand Down Expand Up @@ -73,7 +71,7 @@ for await (const line of readline.createInterface({ input })) {
}

toUpsert.push({
indexedValue: Location.fromString(info[0]),
indexedValue: Data.fromString(info[0]),
keywords,
})

Expand All @@ -89,15 +87,7 @@ for await (const line of readline.createInterface({ input })) {
}

if (toUpsert.length >= MAX_UPSERT_LINES || end) {
await upsert(
masterKey,
label,
toUpsert,
[],
callbacks.fetchEntries,
callbacks.upsertEntries,
callbacks.insertChains,
)
await findex.add(toUpsert)

toUpsert = []

Expand All @@ -120,13 +110,7 @@ process.stdout.write("Search for: ")
for await (const query of queries) {
console.log(query)

const results = await search(
masterKey,
label,
[query],
callbacks.fetchEntries,
callbacks.fetchChains,
)
const results = await findex.search([query])

console.log(`Searching for ${query} returned ${results.total()} results:`)
for (const result of results) {
Expand Down
Loading

0 comments on commit e38869d

Please sign in to comment.