-
Notifications
You must be signed in to change notification settings - Fork 5
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
Draft: full id service #57
Open
guimard
wants to merge
636
commits into
master
Choose a base branch
from
full-id-service
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 31 commits
Commits
Show all changes
636 commits
Select commit
Hold shift + click to select a range
38eb230
chore : fix merge conflict
BichraiX d0aea7a
feat : added GET/login endpoint, started POST/login. Added option to …
BichraiX c34bd95
feat : added /add endpoint to add threepid to a matrix user Id. Modif…
BichraiX 7db6862
fix : merge conflicts
BichraiX 9eb5b22
feat : added GET/login endpoint, started POST/login. Added option to …
BichraiX 6f46d2a
feat : added GET/login endpoint, started POST/login. Added option to …
BichraiX 1f1fc9f
feat: corrected code and adding comments and to do's
Mathixx 11d58ce
fix: fixed code for tests
Mathixx 11df40c
fix: added comments and correction cf MR #119
Mathixx 5b02b4b
feat : added GET/login endpoint, started POST/login. Added option to …
BichraiX 314f5b5
feat : added /add endpoint to add threepid to a matrix user Id. Modif…
BichraiX 6ed2c7f
chore : fixed config
BichraiX 19094a2
fix : wrong type
BichraiX 7ed8af8
chore : prettier
BichraiX e268b51
fix : type of params
BichraiX e4c2cf3
fix : added comment and removed duplicate line
BichraiX 3ce0292
feat : added /bind endpoint. Update register function to handle guest…
BichraiX 525f938
feat : finished tests for register and add, updated config to comply …
BichraiX 013697c
Merge branch 'full-id-service' into client-server-bind
BichraiX 557e835
fix : tests wrong file because of messed up merge
BichraiX 5c336ca
feat : added a strict version of validateParameters which do not acce…
h1ppox99 6a9e37d
fix : corrected name for new error
h1ppox99 37437fc
Merge pull request #124 from linagora/modify-validate-parameters
h1ppox99 7a7e3a9
feat : added /refresh endpoint
BichraiX 867da98
feat : added tests for refresh and fixed authenticate
BichraiX 174f8bf
feat : implemented openid/requesttoken
BichraiX 30bf8a1
feat : added new auxiliary function to setup authentication tokens in…
BichraiX 28be5ab
feat : added the possibility to directly log errors/infos via the sen…
h1ppox99 60fd1e0
feat : integrated logger in send for /room directory
h1ppox99 ee5ada4
fix : updated send for /user directory
h1ppox99 3a9776b
feat : updated /utils directory for send
h1ppox99 6d7755b
fix : added logger to send calls in /register directory
h1ppox99 7b9c22d
fix : updated fix for /profiles directory
h1ppox99 e9ed724
feat : added type and value verification on send_attempt for requestT…
BichraiX 29e06e3
feat : added test on requestBody content in putStatus
BichraiX 082b82e
feat : added checks for content sent by the client in account data en…
BichraiX b211098
fix : updated send for the /presence directory
h1ppox99 538c210
fix : added tests for send method
h1ppox99 1a3a7ba
fix : updated send calls for /admin /devices and /login directories
h1ppox99 b75bd13
fix : updated send calls for /account directory
h1ppox99 b0d2ccd
Merge pull request #127 from linagora/integrate-logger-in-send-method
guimard 32bbda1
fix: fixed the inserts of some functions // added checks in endponts …
Mathixx e932f5e
fix : added a constant for maximum send attempts in requesttoken
BichraiX ea687a0
fix : changed generateToken to generateAndSendToken in refresh
BichraiX 88aa4ac
Merge branch 'full-id-service' into client-server-refresh
BichraiX 2b59397
Merge branch 'full-id-service' into client-server-bind
BichraiX c260d5e
Merge pull request #128 from linagora/correction->inserting_checks
guimard 9709354
feat : added loggers to send calls and renamed fillTables to fillTabl…
BichraiX bffa57f
Merge pull request #126 from linagora/client-server-refresh
guimard d94a9f9
Merge branch 'full-id-service' into client-server-bind
BichraiX 4ff0998
feat : added /bind endpoint. Update register function to handle guest…
BichraiX fc27fa5
fix : added a field phone
h1ppox99 4f8a4c4
feat : added GET/login endpoint, started POST/login. Added option to …
BichraiX a3511ca
fix : register to its current version
BichraiX d5ded50
fix : merge conflicts
BichraiX 607972e
chore : fix merge conflict
BichraiX 95d6fe1
feat : added /add endpoint to add threepid to a matrix user Id. Modif…
BichraiX 90d9c1e
fix : merge conflicts
BichraiX 564e4c2
feat : added GET/login endpoint, started POST/login. Added option to …
BichraiX ad70315
feat : added /bind endpoint. Update register function to handle guest…
BichraiX 3570661
feat : added matrixResolve in bind to make calls to identity server
BichraiX cefa7b3
chore : prettier
BichraiX f6de156
feat : added readme file for UiAuthentication usage
BichraiX d246b6d
chore : removed date from sms name in smsSender class to fix bugs dur…
BichraiX 412891e
feat : added the possibility to directly log errors/infos via the sen…
h1ppox99 da245b7
feat : integrated logger in send for /room directory
h1ppox99 05b81e8
fix : updated send for /user directory
h1ppox99 d80b54a
feat : updated /utils directory for send
h1ppox99 a53e861
fix : added logger to send calls in /register directory
h1ppox99 bc64602
fix : updated fix for /profiles directory
h1ppox99 1eed082
fix : updated send for the /presence directory
h1ppox99 d3fd8c9
fix : added tests for send method
h1ppox99 5028269
fix : updated send calls for /admin /devices and /login directories
h1ppox99 6a1ed70
fix : updated send calls for /account directory
h1ppox99 573715d
fix: fixed the inserts of some functions // added checks in endponts …
Mathixx 82abc87
feat : added /refresh endpoint
BichraiX 9f03c1e
feat : added tests for refresh and fixed authenticate
BichraiX 459c794
feat : added new auxiliary function to setup authentication tokens in…
BichraiX 6316272
feat : added type and value verification on send_attempt for requestT…
BichraiX 3f7e986
feat : added test on requestBody content in putStatus
BichraiX 583589a
feat : added checks for content sent by the client in account data en…
BichraiX b2cd26f
fix : added a constant for maximum send attempts in requesttoken
BichraiX 1c32557
fix : changed generateToken to generateAndSendToken in refresh
BichraiX a52e84d
feat : added loggers to send calls and renamed fillTables to fillTabl…
BichraiX 8618e47
feat : implemented openid/requesttoken
BichraiX 5e4a0aa
feat : added tests for openidRequestToken
BichraiX f75e006
Merge branch 'full-id-service' into client-server-openid
BichraiX 4be8cbf
feat : added /available endpoint and related tests
BichraiX 5f6b592
feat: added filter implementaton to support lazy-loading
Mathixx 60e54d0
fix: correcting event_type distribution
Mathixx d55c8e3
feat : implemented content verification when creating filters
h1ppox99 a026cb2
feat : reorganised and tested completely the filter implementation
h1ppox99 a00a694
feat : added a regex list in utils to refer to
h1ppox99 86ea1fa
chore : deleted draft of sync.ts in order to complete mr
h1ppox99 c558216
Merge pull request #131 from linagora/client-server/sync
guimard c081d15
feat : added doc concerning size limits
h1ppox99 400f666
feat : added new types for filters and room events
h1ppox99 c8ed016
feat : added post and get Filter
h1ppox99 364f641
chore : moved tests to the correct file
h1ppox99 3773dcc
fix : modified usage of db configuration files to limit creation of n…
h1ppox99 ff62baa
feat : created new test file for user/:userId endpoints (limiting the…
h1ppox99 1acda35
fix : deleted last useless conf - using registerConf as base conf
h1ppox99 318fd61
fix : corrected issues with config for tests and wrote tests for post…
h1ppox99 e124093
feat : created tests for get and post filter
h1ppox99 364eb2b
fix : used validateParametersStrict for postfilter
h1ppox99 71828fb
fix : corrected wrong callabck call on validateParametersStrict and w…
h1ppox99 28402ff
fix : reorganised files for easier future merges
h1ppox99 45de0ff
fix : updated post filter and tests with new filter implementation
h1ppox99 e8a16f5
fix : Error message
BichraiX 8544155
Merge pull request #125 from linagora/feat-add-profiles
guimard 111051d
fix : added tests before insert and TODO in delete
BichraiX 4c8f904
Merge remote-tracking branch 'origin/full-id-service' into client-ser…
BichraiX e19c374
Merge branch 'full-id-service' into client-server-bind
BichraiX dd14fd5
Merge pull request #123 from linagora/client-server-bind
BichraiX e801527
fix : added _ in eventType Regex
h1ppox99 4ab5890
feat : added rate limiting
BichraiX 8565aee
Merge branch 'full-id-service' into client-server-available
BichraiX 6a12b34
Merge branch 'full-id-service' into client-server-openid
BichraiX 9fd0bff
fix : merge mistake
BichraiX 2efdfae
Merge pull request #130 from linagora/client-server-available
guimard cf0b7a8
feat : added SafeClient event class and redact method
h1ppox99 bc8841d
Merge branch 'full-id-service' into client-server-openid
BichraiX 5a6f7b9
Merge pull request #129 from linagora/client-server-openid
BichraiX a51d1fb
Resolve conflicts after rebase
BichraiX 80f89cf
feat: corrected 7.7 of matrix client server spec by looking over syna…
Mathixx aa2231c
feat: completed testing files and added documentation
Mathixx d706531
Merge pull request #133 from linagora/add-redaction
guimard a73780c
Merge pull request #132 from linagora/SendingEvents
guimard fdda8f5
feat : added length checking in addition to regex
h1ppox99 af9359c
fix : fixed type syntax
h1ppox99 8c4c0c2
feat : added tests for regex
h1ppox99 c73a126
feat : Updated Ui Authentication. Added a readme to clarify usage. mo…
BichraiX b33ef15
chore : prettier
BichraiX 0329bb9
Merge branch 'full-id-service' into client-server-ui-auth-register
BichraiX cc05102
feat : refactored the code for /register and added tests
BichraiX bbc121e
chore : prettier
BichraiX b6f27f1
Merge pull request #134 from linagora/add-length-checking
guimard 3c2d212
feat : added function to get allowedFlows from the config for the reg…
BichraiX 74e3831
chore : prettier
BichraiX 2d2a9f7
feat : corrected toMatrixId function to comply with the spec. Added h…
BichraiX 2d9d18d
chore : prettier
BichraiX f7f66c1
feat: added getcapabilities endpoint
Mathixx 5792f35
feat: added capability checks in profiles related endpoints // ensure…
Mathixx b3467cc
Merge pull request #137 from linagora/client-server_capabilities
guimard 2ef3461
Decrease log level
guimard 7a41b68
feat: added version API
Mathixx 65a2186
feat: added versions endpoint and updated the capabilities one with n…
Mathixx 11056ab
Fix test
guimard f2b4e83
Merge pull request #138 from linagora/client-server_versions
guimard 0ff736d
Fix some istanbul hooks
guimard dd4ae01
finalized UiAuth and register
BichraiX 2bc3ede
feat : added length checking in addition to regex
h1ppox99 9f9ae6f
fix : fixed type syntax
h1ppox99 d8e8324
feat : added tests for regex
h1ppox99 227d066
feat: added getcapabilities endpoint
Mathixx 0b03293
feat: added capability checks in profiles related endpoints // ensure…
Mathixx 8e2140b
Decrease log level
guimard 6b3b85f
Fix test
guimard 69bdf7f
feat: added version API
Mathixx a9022c6
feat: added versions endpoint and updated the capabilities one with n…
Mathixx c245bc4
Fix some istanbul hooks
guimard 6adaafa
Resolve conflicts after rebase
BichraiX bc06840
feat : Updated Ui Authentication. Added a readme to clarify usage. mo…
BichraiX e9ef8c3
feat : refactored the code for /register and added tests
BichraiX d4b7e78
feat : added function to get allowedFlows from the config for the reg…
BichraiX e630767
chore : prettier
BichraiX 3e6ba47
fix : merge mistake
BichraiX f3060f0
fix : merge mistakes
BichraiX f8da622
Merge branch 'full-id-service' into client-server-ui-auth-register
BichraiX 5da008b
fix : incorrect config file in login tests
BichraiX 2314777
fix : removed useless token in db setup
BichraiX 50eb7d6
fix : moved setupTokens to testData
BichraiX 4868a18
fix : path to setupTokens in test file
BichraiX 17026b9
Merge pull request #135 from linagora/client-server-ui-auth-register
BichraiX 7d6dc9e
feat : added delete endpoint
BichraiX 789086c
fix : await in response.json and added user name in error response
BichraiX 05c9c30
fix : added promise.resolve in mock calls
BichraiX 8b16ee6
feat : added getAccessToken function in utils to get the access token…
BichraiX 3fceda6
fix : changed "token" to data in authenticate to prevent confusion wi…
BichraiX c011be3
fix : filled empty catch statements
BichraiX 4d6c089
feat : added function that returns whether a user is an admin or not …
BichraiX de71e74
chore : prettier
BichraiX f3b7925
feat : added endpoint to change user's password
BichraiX aa54f44
chore : added spec link
BichraiX 9f19854
Merge pull request #139 from linagora/client-server-delete
guimard 61311a6
fix : console to logger
BichraiX 0599b3c
feat: added sql requests in sqlite and PG for the user_directory_dear…
Mathixx c19349b
fix: reorganized profiles and user_directory
Mathixx 600d2ed
feat: added tests fro the search API, as well as for the added functi…
Mathixx b3ce0f9
feat: finish doc for the user_directory API
Mathixx 62e3e96
fix: completed doc
Mathixx adeeaec
feat : added delete endpoint
BichraiX a47f4df
fix : await in response.json and added user name in error response
BichraiX 1c10c89
fix : added promise.resolve in mock calls
BichraiX a0aa4c3
Merge pull request #141 from linagora/client-server/user-directory
Mathixx 3154949
feat : added endpoint to change user's password
BichraiX 9a69fbe
feat : added delete endpoint
BichraiX 384ae30
feat: added sql requests in sqlite and PG for the user_directory_dear…
Mathixx ad7c756
fix: reorganized profiles and user_directory
Mathixx 4e4e6f9
feat: added tests fro the search API, as well as for the added functi…
Mathixx cda3302
feat: finish doc for the user_directory API
Mathixx 8d2622d
fix: completed doc
Mathixx ce95968
feat : added endpoint to change user's password
BichraiX 2928c07
feat : added delete endpoint
BichraiX c7d8a66
feat : added endpoint to change user's password
BichraiX f3e9e2e
fix : merge issue
BichraiX 104f811
fix : merge issues
BichraiX bd72ad9
chore : prettier
BichraiX abcb155
Merge branch 'full-id-service' into client-server-password-reset
BichraiX 4d8b130
Merge pull request #140 from linagora/client-server-password-reset
guimard 026ab01
feat : endpoint to deactivate account, not finished
BichraiX d017557
chore : prettier
BichraiX f47140a
fix : removed unnecessary console.log
h1ppox99 4c4e619
fix : ensuring better cleaning of conf.federated_identity_services in…
h1ppox99 c725024
fix : fixed error returned and istanbul ignored unaccessible lines
h1ppox99 06325ee
fix : fixed fillPolicies method to return a promise
h1ppox99 96014aa
fix : fixed useless code in Postterms - fixed fillPolicies method
h1ppox99 0969273
fix : fixed tests for terms
h1ppox99 188be42
fix : added comment to justify istanbul ignore
h1ppox99 925d658
fix : using correct method to get from the db
h1ppox99 209f7e8
fix : placed existing istanbul ignore at the correct place
h1ppox99 8dadd2a
fix : rewrote todo to appear in github security checks
h1ppox99 faae8bd
fix : added comment relating to TODO and fixed minor pbs
h1ppox99 6739acc
fix : ensuring to reject errors when catching
h1ppox99 b2b9780
fix : deleted useless key in tests
h1ppox99 9569f8d
fix : fixing forgotten ! in previous commit
h1ppox99 1ff0e76
fix : fixed related to previous comments on pr
h1ppox99 e0b8642
feat : almost complete implementation of deactivate endpoint, no test…
BichraiX 0e099ab
chore : added comment
BichraiX 31b8e64
fix : removed useless argument in UIAuth
BichraiX 5ea5692
fix : removed the fetch in /delete and replaced it with auxiliary fun…
BichraiX d0c4194
Merge pull request #142 from linagora/client-server-fix-delete
guimard e8039f9
fix : removed the fetch in /delete and replaced it with auxiliary fun…
BichraiX 1fc2852
feat : changed e to e.toString in errMsg so that the logger logs the …
BichraiX cd0ca1b
feat : added TODO in register and added more promises to remove devic…
BichraiX 71595b8
feat : added todo in register for the future
BichraiX bcd0e19
Merge branch 'full-id-service' into client-server-deactivate
BichraiX 909e13f
fix : incorrect queries to build matrixDb
BichraiX 14f11fc
Merge pull request #136 from linagora/clean-identity-server
guimard d3202da
Merge pull request #143 from linagora/client-server-deactivate
guimard cf00e05
feat : added endpoint to delete devices, added checks for the request…
BichraiX 34e91ac
feat : added function to get stream_ids by batches. Added device mess…
BichraiX 1f9fa28
feat : added delete a single device endpoint
BichraiX 786eb8c
fix : removed useless console logs
BichraiX 76d3ee5
Merge pull request #144 from linagora/client-server-delete-devices
guimard 121019b
feat : fixed store-invite with fetch to self and other mistakes
BichraiX 3fd5049
Merge pull request #145 from linagora/fix-store-invite
BichraiX 75f8c43
feat : added todos where needed. Deleted postLogin since it was not d…
BichraiX d5f05a8
Merge pull request #146 from linagora/add-todos-where-not-sure
guimard 1c44a57
Update packages
guimard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ node_modules/ | |
packages/*/example/*.js* | ||
*.map | ||
.nx/ | ||
packages/matrix-identity-server/matrix-server/synapse-data |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
import { Hash, randomString } from './index' | ||
import { | ||
Hash, | ||
randomString, | ||
generateKeyPair, | ||
canonicalJson, | ||
signJson | ||
} from './index' | ||
|
||
const sha256Results: Record<string, string> = { | ||
'[email protected] email matrixrocks': | ||
|
@@ -39,3 +45,177 @@ test('randomString', () => { | |
const res = randomString(64) | ||
expect(res).toMatch(/^[a-zA-Z0-9]{64}$/) | ||
}) | ||
|
||
describe('generateKeyPair', () => { | ||
it('should generate a valid Ed25519 key pair and key ID', () => { | ||
const { publicKey, privateKey, keyId } = generateKeyPair('ed25519') | ||
expect(publicKey).toMatch(/^[A-Za-z0-9_-]+$/) // Unpadded Base64 URL encoded string | ||
expect(privateKey).toMatch(/^[A-Za-z0-9_-]+$/) // Unpadded Base64 URL encoded string | ||
expect(keyId).toMatch(/^ed25519:[A-Za-z0-9_-]+$/) // Key ID format | ||
}) | ||
|
||
it('should generate a valid Curve25519 key pair and key ID', () => { | ||
const { publicKey, privateKey, keyId } = generateKeyPair('curve25519') | ||
expect(publicKey).toMatch(/^[A-Za-z0-9_-]+$/) // Unpadded Base64 URL encoded string | ||
expect(privateKey).toMatch(/^[A-Za-z0-9_-]+$/) // Unpadded Base64 URL encoded string | ||
expect(keyId).toMatch(/^curve25519:[A-Za-z0-9_-]+$/) // Key ID format | ||
}) | ||
}) | ||
|
||
describe('canonicalJson', () => { | ||
test('should handle empty object', () => { | ||
const input = {} | ||
const expectedOutput = '{}' | ||
expect(canonicalJson(input)).toEqual(expectedOutput) | ||
}) | ||
|
||
test('should handle simple object with different key types', () => { | ||
const input = { one: 1, two: 'Two' } | ||
const expectedOutput = '{"one":1,"two":"Two"}' | ||
expect(canonicalJson(input)).toEqual(expectedOutput) | ||
}) | ||
|
||
test('should handle object with keys in reverse order', () => { | ||
const input = { b: '2', a: '1' } | ||
const expectedOutput = '{"a":"1","b":"2"}' | ||
expect(canonicalJson(input)).toEqual(expectedOutput) | ||
}) | ||
|
||
test('should handle nested objects with arrays', () => { | ||
const input = { | ||
auth: { | ||
success: true, | ||
mxid: '@john.doe:example.com', | ||
profile: { | ||
display_name: 'John Doe', | ||
three_pids: [ | ||
{ | ||
medium: 'email', | ||
address: '[email protected]' | ||
}, | ||
{ | ||
medium: 'msisdn', | ||
address: '123456789' | ||
} | ||
] | ||
} | ||
} | ||
} | ||
const expectedOutput = | ||
'{"auth":{"mxid":"@john.doe:example.com","profile":{"display_name":"John Doe","three_pids":[{"address":"[email protected]","medium":"email"},{"address":"123456789","medium":"msisdn"}]},"success":true}}' | ||
expect(canonicalJson(input)).toEqual(expectedOutput) | ||
}) | ||
|
||
test('should handle object with non-ASCII characters', () => { | ||
const input = { a: '日本語' } | ||
const expectedOutput = '{"a":"日本語"}' | ||
expect(canonicalJson(input)).toEqual(expectedOutput) | ||
}) | ||
|
||
test('should handle object with non-ASCII keys', () => { | ||
const input = { 本: 2, 日: 1 } | ||
const expectedOutput = '{"日":1,"本":2}' | ||
expect(canonicalJson(input)).toEqual(expectedOutput) | ||
}) | ||
|
||
test('should handle object with unicode escape sequences', () => { | ||
const input = { a: '\u65E5' } | ||
const expectedOutput = '{"a":"日"}' | ||
expect(canonicalJson(input)).toEqual(expectedOutput) | ||
}) | ||
|
||
test('should handle object with null values', () => { | ||
const input = { a: null } | ||
const expectedOutput = '{"a":null}' | ||
expect(canonicalJson(input)).toEqual(expectedOutput) | ||
}) | ||
|
||
test('should handle object with special numeric values', () => { | ||
const input = { a: -0, b: 1e10 } | ||
const expectedOutput = '{"a":0,"b":10000000000}' | ||
expect(canonicalJson(input)).toEqual(expectedOutput) | ||
}) | ||
}) | ||
|
||
describe('signJson', () => { | ||
const testKey = generateKeyPair('ed25519') | ||
const signingKey = testKey.privateKey | ||
const signingName = 'testSigningName' | ||
const keyId = testKey.keyId | ||
|
||
it('should add signature to a simple object', () => { | ||
const jsonObj = { a: 1, b: 'string' } | ||
const result = signJson(jsonObj, signingKey, signingName, keyId) | ||
|
||
expect(result).toHaveProperty('signatures') | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
expect(result.signatures).toHaveProperty(signingName) | ||
expect(result.signatures?.[signingName]).toHaveProperty(keyId) | ||
expect(result).toMatchObject({ | ||
a: 1, | ||
b: 'string', | ||
signatures: expect.any(Object) | ||
}) | ||
}) | ||
|
||
it('should preserve existing signatures', () => { | ||
const jsonObj = { | ||
a: 1, | ||
b: 'string', | ||
signatures: { | ||
existingSignature: { | ||
existingKeyId: 'existingSignatureValue' | ||
} | ||
} | ||
} | ||
const result = signJson(jsonObj, signingKey, signingName, keyId) | ||
|
||
expect(result.signatures).toHaveProperty('existingSignature') | ||
expect(result.signatures?.existingSignature).toHaveProperty('existingKeyId') | ||
expect(result.signatures).toHaveProperty(signingName) | ||
expect(result.signatures?.[signingName]).toHaveProperty(keyId) | ||
}) | ||
|
||
it('should handle unsigned field correctly', () => { | ||
const jsonObj = { a: 1, b: 'string', unsigned: { c: 2 } } | ||
const result = signJson(jsonObj, signingKey, signingName, keyId) | ||
|
||
expect(result).toHaveProperty('unsigned') | ||
expect(result.unsigned).toEqual({ c: 2 }) | ||
}) | ||
|
||
it('should not include `unsigned` field if not present', () => { | ||
const jsonObj = { a: 1, b: 'string' } | ||
const result = signJson(jsonObj, signingKey, signingName, keyId) | ||
|
||
expect(result).not.toHaveProperty('unsigned') | ||
}) | ||
|
||
it('should handle complex nested objects', () => { | ||
const jsonObj = { a: { b: { c: 1 } }, d: ['e', 'f', { g: 'h' }] } | ||
const result = signJson(jsonObj, signingKey, signingName, keyId) | ||
|
||
expect(result).toHaveProperty('signatures') | ||
expect(result.signatures).toHaveProperty(signingName) | ||
expect(result.signatures?.[signingName]).toHaveProperty(keyId) | ||
expect(result).toMatchObject({ | ||
a: { b: { c: 1 } }, | ||
d: ['e', 'f', { g: 'h' }], | ||
signatures: expect.any(Object) | ||
}) | ||
}) | ||
|
||
it('should handle objects with null values', () => { | ||
const jsonObj = { a: null, b: 'string' } | ||
const result = signJson(jsonObj, signingKey, signingName, keyId) | ||
|
||
expect(result).toHaveProperty('signatures') | ||
expect(result.signatures).toHaveProperty(signingName) | ||
expect(result.signatures?.[signingName]).toHaveProperty(keyId) | ||
expect(result).toMatchObject({ | ||
a: null, | ||
b: 'string', | ||
signatures: expect.any(Object) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# @twake/matrix-client-server | ||
|
||
Node.js library that implements | ||
[Matrix Client Server API](https://spec.matrix.org/v1.10/client-server-api/). | ||
|
||
## Synopsis | ||
|
||
Example using [express](https://www.npmjs.com/package/express): | ||
|
||
``js | ||
// Add example which will be similar to the one inside packages/matrix-identity-server/README.md | ||
``` | ||
|
||
## Configuration file | ||
|
||
Configuration file is a JSON file. The default values are | ||
in [src/config.json](./src/config.json). | ||
|
||
## Copyright and license | ||
|
||
Copyright (c) 2023-present Linagora <https://linagora.com> | ||
|
||
License: [GNU AFFERO GENERAL PUBLIC LICENSE](https://ci.linagora.com/publicgroup/oss/twake/tom-server/-/blob/master/LICENSE) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / devskim
Generic: Hard-coded Elliptic Curve Note