Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMN-522 Client-assertion validation #956

Merged
merged 411 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
411 commits
Select commit Hold shift + click to select a range
cc93507
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 5, 2024
43c2d97
Remove comments
taglioni-r Sep 5, 2024
d94247d
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 5, 2024
2b048fe
Remove console.log
shuyec Sep 5, 2024
2f9d377
Merge branch 'IMN-797_catalog-platformstate-writer-v1' of https://git…
shuyec Sep 5, 2024
6e51bd1
Remove comments
shuyec Sep 5, 2024
374d3ec
Minor improvement
taglioni-r Sep 5, 2024
4e8a362
Fix import
taglioni-r Sep 5, 2024
bea13d4
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
shuyec Sep 5, 2024
a6d8d65
Add api spec
taglioni-r Sep 5, 2024
b414e18
Adjust types
shuyec Sep 5, 2024
6470dcf
Fix client kind type
shuyec Sep 5, 2024
560330b
Fix tests
shuyec Sep 5, 2024
c992846
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 6, 2024
535e6de
Draft
taglioni-r Sep 6, 2024
a7a8efe
Resolve PR comments
shuyec Sep 6, 2024
7a17057
Fix
taglioni-r Sep 6, 2024
a938106
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Sep 6, 2024
1e6d50a
Remove comment
taglioni-r Sep 6, 2024
f891ff1
Renaming
taglioni-r Sep 6, 2024
b046603
Fix
taglioni-r Sep 6, 2024
f7c21e1
Fix logic
taglioni-r Sep 6, 2024
6d009cf
Add tests
taglioni-r Sep 6, 2024
77d55d2
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 6, 2024
72a6177
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 6, 2024
5312b34
Draft
taglioni-r Sep 6, 2024
9c9bf27
Refactor tables setup
taglioni-r Sep 6, 2024
6fa4866
Add pagination
shuyec Sep 9, 2024
ba70501
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
shuyec Sep 9, 2024
135b036
WIP: add errors
shuyec Sep 9, 2024
ecc1093
Update package imports
shuyec Sep 9, 2024
1eb3762
Draft
taglioni-r Sep 10, 2024
a26f95d
WIP: add errors
shuyec Sep 10, 2024
e22b041
Update errors
taglioni-r Sep 10, 2024
b34ed35
Update utils
taglioni-r Sep 10, 2024
3c5ad7c
Draft test
taglioni-r Sep 10, 2024
02eeeb4
Add placeholders for tests
taglioni-r Sep 10, 2024
8562a57
Add type
taglioni-r Sep 10, 2024
060e2b7
Refactor
taglioni-r Sep 10, 2024
43d252a
Update tests
taglioni-r Sep 10, 2024
d09d7a2
Update comment
taglioni-r Sep 10, 2024
3bf72b3
Fix errors data
shuyec Sep 11, 2024
facb19c
Refactor
taglioni-r Sep 11, 2024
331b6b1
Merge branch 'IMN-522_client-assertion-validation' of https://github.…
taglioni-r Sep 11, 2024
59f0aa5
Update comment
taglioni-r Sep 11, 2024
c1c4c3e
Fix checks
taglioni-r Sep 11, 2024
b72c5dc
Update test utils
taglioni-r Sep 11, 2024
9ba64f6
Draft tests
taglioni-r Sep 11, 2024
feddfe6
Add errors
shuyec Sep 11, 2024
659d4d1
Fix algorithm error
shuyec Sep 11, 2024
8f774eb
Refactor validateSub
taglioni-r Sep 11, 2024
3991d66
Fix mock
taglioni-r Sep 11, 2024
c97619f
Update tests
taglioni-r Sep 11, 2024
5a49356
Remove printed errors
taglioni-r Sep 11, 2024
b12a6ea
Add errors
shuyec Sep 11, 2024
2060029
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 12, 2024
e2d2de3
Fix tests
shuyec Sep 12, 2024
c73ddf5
Merge branch 'IMN-522_client-assertion-validation' of https://github.…
shuyec Sep 12, 2024
0105452
Improvements
shuyec Sep 12, 2024
98784fc
Improvements
shuyec Sep 12, 2024
04c7aa4
Fix
taglioni-r Sep 12, 2024
762d65b
Fix import
taglioni-r Sep 12, 2024
8ea2212
Refactor
taglioni-r Sep 12, 2024
2fa65e0
Add check
taglioni-r Sep 12, 2024
1f8aa0e
Fix test
taglioni-r Sep 12, 2024
4784b7c
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Sep 12, 2024
c3814e1
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 12, 2024
edcfd79
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 12, 2024
9a19717
Fix
taglioni-r Sep 12, 2024
6a08e96
Merge branch 'IMN-522_client-assertion-validation' of https://github.…
taglioni-r Sep 12, 2024
d212b09
Refactor
taglioni-r Sep 12, 2024
e2e50a3
Add tests
taglioni-r Sep 12, 2024
8b16304
Remove comment
taglioni-r Sep 12, 2024
4a44eb0
Refactor
taglioni-r Sep 13, 2024
8519e60
Refactor
taglioni-r Sep 13, 2024
9a72065
Add util tests
taglioni-r Sep 13, 2024
f4e37aa
Add test
taglioni-r Sep 13, 2024
7a8205f
Fix
taglioni-r Sep 13, 2024
5f62de0
Remove hardcoded string
taglioni-r Sep 13, 2024
7788383
Update comments
taglioni-r Sep 16, 2024
c27e3ad
Fix
taglioni-r Sep 16, 2024
ba9609f
Refactor
taglioni-r Sep 16, 2024
f9ba9db
Refactor
taglioni-r Sep 16, 2024
9bdea36
Renaming
taglioni-r Sep 17, 2024
7d5e486
Refactor
taglioni-r Sep 18, 2024
519870b
Fix tests
taglioni-r Sep 18, 2024
bf36128
Refactor
taglioni-r Sep 18, 2024
d8a2dcc
Comment function
taglioni-r Sep 18, 2024
7724295
Fix GSIPK_agreementTimestamp typo
shuyec Sep 20, 2024
97872cd
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
shuyec Sep 20, 2024
db0de47
Revert "Fix GSIPK_agreementTimestamp typo"
shuyec Sep 20, 2024
fd04e3b
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
shuyec Sep 20, 2024
ab92c54
Remove unused line
taglioni-r Sep 24, 2024
2ed47eb
Refactor
taglioni-r Sep 24, 2024
bb0ee8d
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Sep 24, 2024
1860616
Refactor tables setup
taglioni-r Sep 24, 2024
f6e9a08
Update model
taglioni-r Sep 24, 2024
5dbf0bd
Update platform-states table
taglioni-r Sep 24, 2024
3d9664b
Fix
taglioni-r Sep 24, 2024
4f9904a
Update token-generation-states table
taglioni-r Sep 24, 2024
abc158a
Update aws config
taglioni-r Sep 24, 2024
8b6db83
Rename descriptorStateToItemState function
shuyec Sep 24, 2024
3d12bff
Update key types usage
taglioni-r Sep 24, 2024
fda73c2
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Sep 24, 2024
7a3fc3e
Merge branch 'IMN-798_catalog-platformstate-writer-v2' of https://git…
taglioni-r Sep 24, 2024
6ad6e6f
Fix
taglioni-r Sep 24, 2024
b9b3c4b
Fix test split
taglioni-r Sep 24, 2024
80fd523
Remove describe utils in test file
shuyec Sep 24, 2024
2061be8
Merge branch 'IMN-798_catalog-platformstate-writer-v2' of https://git…
shuyec Sep 24, 2024
ddd4bdc
Minor fix
taglioni-r Sep 24, 2024
8e58388
Fix test structure
taglioni-r Sep 24, 2024
ab04510
Fix tests
taglioni-r Sep 24, 2024
3e3769f
Fix
taglioni-r Sep 24, 2024
daddb4b
Improve tests
taglioni-r Sep 24, 2024
c875827
Refactor
taglioni-r Sep 24, 2024
b2fe9a8
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 24, 2024
0b27fbe
Refactor test
taglioni-r Sep 24, 2024
d8a6f37
Rename test file for events V2
shuyec Sep 24, 2024
3d8d605
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 24, 2024
4c4d753
Fix typo
shuyec Sep 24, 2024
609b392
Fix
taglioni-r Sep 24, 2024
0f51a67
Update tests
taglioni-r Sep 24, 2024
ca4eac5
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 24, 2024
b0a0be9
Remove api spec
taglioni-r Sep 24, 2024
1b8b684
Refactor
taglioni-r Sep 24, 2024
0a046dc
Remove comment
taglioni-r Sep 24, 2024
b39d50f
Remove commented code
taglioni-r Sep 24, 2024
2780594
Fix comments
taglioni-r Sep 24, 2024
4bfcfd7
Revert string literal
taglioni-r Sep 24, 2024
6c445ed
Add env var
taglioni-r Sep 24, 2024
6917d52
WIP, broken commit
Carminepo2 Sep 24, 2024
09e27ea
Fix types
Carminepo2 Sep 25, 2024
1bbe00c
Revert "Fix types"
taglioni-r Sep 25, 2024
2b59066
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 25, 2024
ebb6db9
Revert "WIP, broken commit"
taglioni-r Sep 25, 2024
c745838
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 25, 2024
f05c1c7
Fix model
taglioni-r Sep 25, 2024
386639f
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Sep 25, 2024
460fc94
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 25, 2024
f0a2a87
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 25, 2024
905aa06
Fix agreementDescriptorId type
shuyec Sep 25, 2024
b2810da
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
shuyec Sep 25, 2024
03426ba
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
shuyec Sep 25, 2024
ed4cb24
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
shuyec Sep 25, 2024
c3f442d
Update tables setup
taglioni-r Sep 25, 2024
121fdb8
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 25, 2024
fbb1c7c
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 25, 2024
b492bcf
Merge branch 'feature/IMN-517_authorization-server' into IMN-796_cata…
taglioni-r Sep 26, 2024
0ddcd8e
Move tables definition
taglioni-r Sep 26, 2024
c5ea4c1
Update test utils
taglioni-r Sep 26, 2024
5acb0f4
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Sep 26, 2024
a38d762
Remove unused error
taglioni-r Sep 26, 2024
ad1dac8
Fix digest type
taglioni-r Sep 26, 2024
fcdb6c0
Fix types in validation request
taglioni-r Sep 26, 2024
4a5c9d6
Remove comments
taglioni-r Sep 26, 2024
ac9b00f
Fix validateSub
taglioni-r Sep 26, 2024
74b2612
Fix check on digest
taglioni-r Sep 26, 2024
1a394e4
Partial revert
taglioni-r Sep 26, 2024
0609f35
Fix digest errors
taglioni-r Sep 26, 2024
b37c400
Remove comment
taglioni-r Sep 26, 2024
7c4e32c
Fix check on strings
taglioni-r Sep 26, 2024
92972b5
Fix checks
taglioni-r Sep 26, 2024
a02f448
Renaming
taglioni-r Sep 26, 2024
207b048
Remove digest from mock
taglioni-r Sep 26, 2024
8edfd7f
Add tests
taglioni-r Sep 26, 2024
d4662d4
Update kid regex
taglioni-r Sep 27, 2024
ea45031
Add type checks
taglioni-r Sep 27, 2024
8e84a58
Add comment
taglioni-r Sep 27, 2024
58dd973
Add tests
taglioni-r Sep 27, 2024
2896889
Merge similar tests
taglioni-r Sep 27, 2024
263e59c
Update test title
taglioni-r Sep 27, 2024
f369a39
Renaming
taglioni-r Sep 27, 2024
20e5711
Renaming
taglioni-r Sep 27, 2024
98a5387
Renaming
taglioni-r Sep 27, 2024
0e24d73
Improve error
taglioni-r Sep 27, 2024
db141fe
Update error message
taglioni-r Sep 27, 2024
ba8178b
Update signature errors
taglioni-r Sep 27, 2024
294c349
Refactor branded ids
taglioni-r Sep 27, 2024
ce476f0
Fix import
taglioni-r Sep 27, 2024
7d9ca9c
Fix typos
shuyec Sep 27, 2024
c032bcd
Fix GSI names
taglioni-r Sep 27, 2024
28402dc
Update aws region
taglioni-r Sep 27, 2024
86f08e3
Update aws region
taglioni-r Sep 27, 2024
fa46fd7
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Sep 27, 2024
d5a28bd
Refactor
taglioni-r Sep 27, 2024
7040666
Merge branch 'IMN-798_catalog-platformstate-writer-v2' of https://git…
taglioni-r Sep 27, 2024
7a84286
Fix GSI name
taglioni-r Sep 27, 2024
149a7ec
Remove commented code
taglioni-r Sep 27, 2024
178296c
Fix GSI names
taglioni-r Sep 27, 2024
ccc27d2
Minor improvement
taglioni-r Sep 27, 2024
fd81ebb
Fix mock
taglioni-r Sep 27, 2024
44cc824
Rename tests
taglioni-r Sep 27, 2024
df2b57b
Update aws region
taglioni-r Sep 27, 2024
6dc781a
Update descriptor audience
taglioni-r Sep 27, 2024
3015935
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 30, 2024
aa2cbfa
Fix
taglioni-r Sep 30, 2024
b52c801
Refactor
taglioni-r Sep 30, 2024
cc0ea48
Rename tests
taglioni-r Sep 30, 2024
f76e677
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 30, 2024
97fb884
Refactor
taglioni-r Sep 30, 2024
d84473f
Refactor
taglioni-r Sep 30, 2024
b7467cd
Remove types check
taglioni-r Sep 30, 2024
33b1014
Add check
taglioni-r Sep 30, 2024
ca6b288
Add test
taglioni-r Sep 30, 2024
cee7db9
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Oct 1, 2024
3122d67
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Oct 1, 2024
0cfd319
Fix
taglioni-r Oct 1, 2024
abf77f0
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Oct 1, 2024
4e3b338
Remove env vars
taglioni-r Oct 1, 2024
865c4c8
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Oct 1, 2024
6135980
Fix
taglioni-r Oct 1, 2024
bac370e
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Oct 1, 2024
e6bbca3
Fix
taglioni-r Oct 1, 2024
6c3d128
Fix
taglioni-r Oct 1, 2024
cc1dccd
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Oct 1, 2024
f4e3ca0
Remove not needed params
taglioni-r Oct 1, 2024
6b2643e
Rename container
taglioni-r Oct 1, 2024
573ed39
Refactor
taglioni-r Oct 1, 2024
5adc54b
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Oct 1, 2024
ba7233f
Fix import
taglioni-r Oct 1, 2024
0e8f1b5
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Oct 1, 2024
f5376ce
Refactor
taglioni-r Oct 1, 2024
c191fd8
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Oct 1, 2024
2078571
Update error
taglioni-r Oct 1, 2024
497ce62
Improve test
taglioni-r Oct 1, 2024
b71eec3
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Oct 1, 2024
6353335
Fix
taglioni-r Oct 1, 2024
c23596a
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Oct 1, 2024
686aa59
Adjust key utils
taglioni-r Oct 3, 2024
059e489
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Oct 3, 2024
f5dbec0
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Oct 3, 2024
f6cb113
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Oct 3, 2024
4b25577
Merge branch 'main' into IMN-796_catalog-platform-state-writer-scaffold
taglioni-r Oct 3, 2024
d91995c
Merge branch 'main' into IMN-796_catalog-platform-state-writer-scaffold
taglioni-r Oct 3, 2024
a8fa124
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Oct 3, 2024
5a36f89
Add typ
taglioni-r Oct 3, 2024
2127e68
Remove todo
taglioni-r Oct 3, 2024
e8dc415
Merge branch 'main' into IMN-798_catalog-platformstate-writer-v2
taglioni-r Oct 3, 2024
8229176
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Oct 3, 2024
f2212d9
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Oct 3, 2024
2baf099
Merge branch 'main' into IMN-798_catalog-platformstate-writer-v2
taglioni-r Oct 4, 2024
7c8da7d
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Oct 4, 2024
ae133dc
Merge branch 'main' into IMN-797_catalog-platformstate-writer-v1
taglioni-r Oct 4, 2024
fccb758
Remove sample test
taglioni-r Oct 4, 2024
f9b7271
Merge branch 'IMN-797_catalog-platformstate-writer-v1' of https://git…
taglioni-r Oct 4, 2024
e215a13
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
shuyec Oct 4, 2024
e884969
Merge branch 'main' into IMN-522_client-assertion-validation
taglioni-r Oct 4, 2024
5d2f028
Fix
taglioni-r Oct 4, 2024
abdbeca
Update comments
taglioni-r Oct 4, 2024
0f5ddcd
Improve typing
taglioni-r Oct 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/client-assertion-validation/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CLIENT_ASSERTION_AUDIENCE="test.interop.pagopa.it"
37 changes: 37 additions & 0 deletions packages/client-assertion-validation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "pagopa-interop-client-assertion-validation",
"private": true,
"version": "1.0.0",
"description": "PagoPA Interoperability utility to validate client assertion",
"main": "dist",
"type": "module",
"exports": {
".": "./dist/index.js"
},
"scripts": {
"test": "vitest",
"lint": "eslint . --ext .ts,.tsx",
"lint:autofix": "eslint . --ext .ts,.tsx --fix",
"format:check": "prettier --check src",
"format:write": "prettier --write src",
"build": "tsc",
"check": "tsc --project tsconfig.check.json"
},
"license": "Apache-2.0",
"dependencies": {
"jsonwebtoken": "9.0.2",
"pagopa-interop-commons-test": "workspace:*",
"pagopa-interop-models": "workspace:*",
"pagopa-interop-commons": "workspace:*",
"ts-pattern": "5.2.0",
"zod": "3.23.8"
},
"devDependencies": {
"@types/jsonwebtoken": "9.0.6",
"@types/node": "20.14.6",
"eslint": "8.57.0",
"prettier": "2.8.8",
"typescript": "5.4.5",
"vitest": "1.6.0"
}
}
11 changes: 11 additions & 0 deletions packages/client-assertion-validation/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { z } from "zod";

const ClientAssertionValidationConfig = z
.object({
CLIENT_ASSERTION_AUDIENCE: z.string(),
})
.transform((c) => ({
clientAssertionAudience: c.CLIENT_ASSERTION_AUDIENCE,
}));

export const config = ClientAssertionValidationConfig.parse(process.env);
325 changes: 325 additions & 0 deletions packages/client-assertion-validation/src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
import { ApiError } from "pagopa-interop-models";

export const errorCodes = {
clientAssertionValidationFailure: "0001",
unexpectedClientAssertionSignatureVerificationError: "0002",
invalidAssertionType: "0003",
invalidGrantType: "0004",
invalidAudienceFormat: "0005",
invalidAudience: "0006",
invalidClientAssertionFormat: "0007",
unexpectedClientAssertionPayload: "0008",
jtiNotFound: "0009",
issuedAtNotFound: "0010",
expNotFound: "0011",
issuerNotFound: "0012",
subjectNotFound: "0013",
invalidSubject: "0014",
invalidPurposeIdClaimFormat: "0015",
kidNotFound: "0016",
invalidClientAssertionSignatureType: "0017",
tokenExpiredError: "0018",
jsonWebTokenError: "0019",
notBeforeError: "0020",
inactivePurpose: "0021",
inactiveAgreement: "0022",
inactiveEService: "0023",
invalidClientIdFormat: "0024",
invalidSubjectFormat: "0025",
digestClaimNotFound: "0026",
invalidHashLength: "0027",
invalidHashAlgorithm: "0028",
algorithmNotFound: "0029",
algorithmNotAllowed: "0030",
purposeIdNotProvided: "0031",
invalidKidFormat: "0032",
clientAssertionInvalidClaims: "0033",
invalidSignature: "0034",
};

export type ErrorCodes = keyof typeof errorCodes;

export function clientAssertionValidationFailure(
details: string
): ApiError<ErrorCodes> {
return new ApiError({
detail: `Client assertion validation failed: ${details}`,
code: "clientAssertionValidationFailure",
title: "Client assertion validation failed",
});
}

export function unexpectedClientAssertionSignatureVerificationError(): ApiError<ErrorCodes> {
return new ApiError({
detail: `Unexpected client assertion signature verification error`,
code: "unexpectedClientAssertionSignatureVerificationError",
title: "Unexpected client assertion signature verification error",
});
}

export function invalidAssertionType(
assertionType: string
): ApiError<ErrorCodes> {
return new ApiError({
detail: `Assertion type not valid: ${assertionType}`,
code: "invalidAssertionType",
title: "Assertion type not valid",
});
}

export function invalidGrantType(grantType: string): ApiError<ErrorCodes> {
return new ApiError({
detail: `Grant type not valid: ${grantType}`,
code: "invalidGrantType",
title: "Grant type not valid",
});
}

export function invalidAudienceFormat(): ApiError<ErrorCodes> {
return new ApiError({
detail: `Audience must be an array`,
code: "invalidAudienceFormat",
title: "Invalid audience format",
});
}

export function invalidAudience(): ApiError<ErrorCodes> {
return new ApiError({
detail: "Unexpected client assertion audience",
code: "invalidAudience",
title: "Invalid audience",
});
}

export function invalidClientAssertionFormat(): ApiError<ErrorCodes> {
return new ApiError({
detail: `Invalid format for Client assertion`,
code: "invalidClientAssertionFormat",
title: "Invalid format for Client assertion",
});
}

export function unexpectedClientAssertionPayload(
message: string
): ApiError<ErrorCodes> {
return new ApiError({
detail: `Unexpected client assertion payload: ${message}`,
code: "unexpectedClientAssertionPayload",
title: "Invalid client assertion payload",
});
}

export function jtiNotFound(): ApiError<ErrorCodes> {
return new ApiError({
detail: `JTI not found in client assertion`,
code: "jtiNotFound",
title: "JTI not found",
});
}

export function issuedAtNotFound(): ApiError<ErrorCodes> {
return new ApiError({
detail: `IAT not found in client assertion`,
code: "issuedAtNotFound",
title: "IAT not found",
});
}

export function expNotFound(): ApiError<ErrorCodes> {
return new ApiError({
detail: `EXP not found in client assertion`,
code: "expNotFound",
title: "EXP not found",
});
}

export function issuerNotFound(): ApiError<ErrorCodes> {
return new ApiError({
detail: `Issuer not found in client assertion`,
code: "issuerNotFound",
title: "ISS not found",
});
}

export function subjectNotFound(): ApiError<ErrorCodes> {
return new ApiError({
detail: "Subject not found in client assertion",
code: "subjectNotFound",
title: "Subject not found",
});
}

export function invalidSubject(subject?: string): ApiError<ErrorCodes> {
return new ApiError({
detail: `Subject claim value ${subject} does not correspond to provided client_id parameter`,
code: "invalidSubject",
title: "Invalid subject",
});
}

export function invalidPurposeIdClaimFormat(
purposeId: string
): ApiError<ErrorCodes> {
return new ApiError({
detail: `Purpose Id claim ${purposeId} is not a valid UUID`,
code: "invalidPurposeIdClaimFormat",
title: "Invalid purposeId claim format",
});
}

export function kidNotFound(): ApiError<ErrorCodes> {
return new ApiError({
detail: `KID not found in client assertion`,
code: "kidNotFound",
title: "KID not found",
});
}

export function invalidClientAssertionSignatureType(
clientAssertionSignatureType: string
): ApiError<ErrorCodes> {
return new ApiError({
detail: `Client assertion signature's type not valid: ${clientAssertionSignatureType}`,
code: "invalidClientAssertionSignatureType",
title: "Token expired in client assertion signature validation",
});
}

export function tokenExpiredError(): ApiError<ErrorCodes> {
return new ApiError({
detail: "Token expired in client assertion signature validation",
code: "tokenExpiredError",
title: "Token expired",
});
}

export function jsonWebTokenError(errorMessage: string): ApiError<ErrorCodes> {
return new ApiError({
detail: `Invalid JWT format in client assertion signature validation. Reason: ${errorMessage}`,
code: "jsonWebTokenError",
title: "Invalid JWT format",
});
}

export function notBeforeError(): ApiError<ErrorCodes> {
return new ApiError({
detail:
"Current time is before not before time in client assertion signature validation",
code: "notBeforeError",
title: "Current time is before not before time",
});
}

export function inactivePurpose(): ApiError<ErrorCodes> {
return new ApiError({
detail: "Purpose is not active",
code: "inactivePurpose",
title: "Purpose is not active",
});
}

export function inactiveEService(): ApiError<ErrorCodes> {
return new ApiError({
detail: "E-Service is not active",
code: "inactiveEService",
title: "E-Service is not active",
});
}

export function inactiveAgreement(): ApiError<ErrorCodes> {
return new ApiError({
detail: "Agreement is not active",
code: "inactiveAgreement",
title: "Agreement is not active",
});
}

export function invalidClientIdFormat(clientId: string): ApiError<ErrorCodes> {
return new ApiError({
detail: `Client id ${clientId} is not a valid UUID`,
code: "invalidClientIdFormat",
title: "Invalid client id format",
});
}

export function invalidSubjectFormat(subject: string): ApiError<ErrorCodes> {
return new ApiError({
detail: `Subject claim ${subject} is not a valid UUID`,
code: "invalidSubjectFormat",
title: "Invalid subject format",
});
}

export function digestClaimNotFound(message: string): ApiError<ErrorCodes> {
return new ApiError({
detail: `Digest claim not found. Reason: ${message}`,
code: "digestClaimNotFound",
title: "Digest claim not found",
});
}

export function invalidHashLength(alg: string): ApiError<ErrorCodes> {
return new ApiError({
detail: `Invalid hash length for algorithm ${alg}`,
code: "invalidHashLength",
title: "Invalid hash length",
});
}

export function invalidHashAlgorithm(): ApiError<ErrorCodes> {
return new ApiError({
detail: "Invalid hash algorithm",
code: "invalidHashAlgorithm",
title: "Invalid hash algorithm",
});
}

export function algorithmNotFound(): ApiError<ErrorCodes> {
return new ApiError({
detail: "ALG not found in client assertion",
code: "algorithmNotFound",
title: "ALG not found",
});
}

export function algorithmNotAllowed(algorithm: string): ApiError<ErrorCodes> {
return new ApiError({
detail: `Algorithm ${algorithm} is not allowed`,
code: "algorithmNotAllowed",
title: "ALG not allowed",
});
}

export function purposeIdNotProvided(): ApiError<ErrorCodes> {
return new ApiError({
detail: "Claim purposeId does not exist in this assertion",
code: "purposeIdNotProvided",
title: "Purpose Id not provided",
});
}

export function invalidKidFormat(): ApiError<ErrorCodes> {
return new ApiError({
detail: "Unexpected format for kid",
code: "invalidKidFormat",
title: "Invalid KID format",
});
}

export function clientAssertionInvalidClaims(
details: string
): ApiError<ErrorCodes> {
return new ApiError({
detail: `Client assertion validation failure. Reason: ${details}`,
code: "clientAssertionInvalidClaims",
title: "Invalid claims in header or payload",
});
}

export function invalidSignature(): ApiError<ErrorCodes> {
return new ApiError({
detail: "Client assertion signature is invalid",
code: "invalidSignature",
title: "Invalid signature",
});
}
2 changes: 2 additions & 0 deletions packages/client-assertion-validation/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./validation.js";
export * from "./types.js";
Loading