Skip to content

Commit 8a32a1f

Browse files
committed
Merge branch 'develop'
- Introduce flag to disable config file validation during startup (useful for testing) - Allow injection of salt file during config load for better security - Publish library to GitHub packages - Add structured logging support throughout --> use cid::engine::* for debug logs
2 parents 41521a4 + 363442d commit 8a32a1f

51 files changed

Lines changed: 1546 additions & 1037 deletions

Some content is hidden

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

.github/workflows/publish.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish @wfp/common-identifier-algorithm-shared
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
- "v*.*.*-*"
8+
9+
permissions:
10+
checks: write
11+
contents: read
12+
packages: write
13+
pull-requests: read
14+
15+
jobs:
16+
test:
17+
uses: "./.github/workflows/test.yaml"
18+
publish:
19+
runs-on: ubuntu-latest
20+
needs:
21+
- test
22+
steps:
23+
- name: Checkout source
24+
uses: actions/checkout@v4
25+
26+
- name: Setup nodeJS
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: "24"
30+
registry-url: "https://npm.pkg.github.com"
31+
scope: "@wfp"
32+
33+
- name: Install dependencies
34+
run: npm install
35+
36+
- name: Build package
37+
run: npm run build
38+
39+
- name: Publish to GitHub packages
40+
run: npm publish
41+
env:
42+
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
name: RunTests
22
on:
33
push:
4-
branches: ['main', 'develop']
4+
branches:
5+
- main
6+
- develop
7+
- feat/*
58
pull_request:
69
branches: ['main']
710
types: [opened, reopened, edited]
11+
workflow_call:
12+
13+
permissions:
14+
checks: write
15+
contents: read
16+
pull-requests: read
817

918
jobs:
1019
RunTestSuite:
@@ -19,7 +28,7 @@ jobs:
1928
- name: Install NodeJS
2029
uses: actions/setup-node@v4
2130
with:
22-
node-version: 20
31+
node-version: 24
2332

2433
- name: Install node packages
2534
run: npm install

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ coverage
66

77
/lib
88
output/
9+
**/scratch/**
910
scratch.*

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@wfp:registry=https://npm.pkg.github.com
2+
//npm.pkg.github.com/:_authToken=${NPM_TOKEN}

examples/example_algorithm/_generic_hasher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import { joinFieldsForHash, cleanValueList, extractAlgoColumnsFromObject, BaseHasher } from 'common-identifier-algorithm-shared';
18-
import type { Config, Validator, makeHasherFunction } from 'common-identifier-algorithm-shared';
17+
import { joinFieldsForHash, cleanValueList, extractAlgoColumnsFromObject, BaseHasher } from '../../src';
18+
import type { Config, Validator, makeHasherFunction } from '../../src';
1919

2020
class GenericHasher extends BaseHasher {
2121
constructor(config: Config.CoreConfiguration["algorithm"]) {

examples/example_algorithm/config.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[meta]
22
id="ANY"
33
version="1.0.0"
4-
signature="f51f7b694f62d9bb1c6ece9dd8a85790"
4+
signature="a36d008f81060928709a6704da61bbd6"
55

66
[source]
77
columns = [
@@ -31,10 +31,6 @@ reference = []
3131
[algorithm.hash]
3232
strategy = "SHA256"
3333

34-
[algorithm.salt]
35-
source = "STRING"
36-
value = "{{ some_random_salt_value }}"
37-
3834
[destination]
3935
columns = [
4036
{ name = "Common Identifier", alias = "hashed_id" },

examples/file_based_usage.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ const OUTPUT_PATH = join(__dirname, 'output', 'output_10.csv');
1313
const VALIDATION_ERRORS_PATH = join(__dirname, 'output', 'validation_errors.csv');
1414

1515
// load configuration from file
16-
const configLoadResult = loadConfig(CONFIG_PATH, ALGORITHM_ID);
16+
const configLoadResult = loadConfig({
17+
configPath: CONFIG_PATH,
18+
algorithmId: ALGORITHM_ID,
19+
validateConfig: true,
20+
embeddedSalt: { source: "STRING", value: "SOME_SALT_VALUE" }
21+
});
1722
if (!configLoadResult.success) throw new Error(`ERROR: Unable to load configuration file >> ${configLoadResult.error}`);
1823

1924
// validate the input file against all configured validation rules.

examples/programmatic_usage.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ const config: Config.CoreConfiguration = {
3232
},
3333
algorithm: {
3434
hash: { strategy: "SHA256" },
35-
salt: { source: "STRING", value: "testSalt" },
35+
// NOTE: For procedural use, only salt values with source: "STRING" are permitted
36+
salt: { source: "STRING", value: "SOME_VALUE" },
3637
columns: {
3738
process: [],
3839
reference: [],

package-lock.json

Lines changed: 58 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)