Skip to content

Commit

Permalink
Merge pull request #721 from nevermined-io/feat/key_aud
Browse files Browse the repository at this point in the history
feat: adding subject of the key hash
  • Loading branch information
aaitor authored Oct 4, 2024
2 parents d9e752c + 3d976fb commit 19fc2a9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
22 changes: 15 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v3.0.38](https://github.com/nevermined-io/sdk-js/compare/v3.0.37...v3.0.38)

> 4 October 2024
- docs: updating documentation [skip actions] [`d9e752c`](https://github.com/nevermined-io/sdk-js/commit/d9e752cab1d68be36ce515713eb2c88382ce4132)
- Automated CHANGELOG.md update [`414db5f`](https://github.com/nevermined-io/sdk-js/commit/414db5fba135665acbeecfc29b3292c8e9044af7)
- feat: adding subject of the key hash [`ec2f8eb`](https://github.com/nevermined-io/sdk-js/commit/ec2f8eb5236625af71fc62fe79ef56884178de22)

#### [v3.0.37](https://github.com/nevermined-io/sdk-js/compare/v3.0.36...v3.0.37)

> 2 October 2024
Expand Down Expand Up @@ -497,7 +505,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- fix: wait tx for session keys an use bigint for blocknumbers in all the places [`a6188e7`](https://github.com/nevermined-io/sdk-js/commit/a6188e78eaeecb346ff0b067335c4c7783dfefb0)
- chore: adding v3.0.0 Changelog updates [`bcc2d13`](https://github.com/nevermined-io/sdk-js/commit/bcc2d13c3da67cee187b2bb1b8e2c74ebec40bb4)

### [v3.0.0](https://github.com/nevermined-io/sdk-js/compare/v3.0.0-rc9...v3.0.0)
#### [v3.0.0](https://github.com/nevermined-io/sdk-js/compare/v3.0.0-rc9...v3.0.0)

> 2 May 2024
Expand Down Expand Up @@ -984,7 +992,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- feat: add as an option in the config [`6f610b4`](https://github.com/nevermined-io/sdk-js/commit/6f610b4d6372c0d0843b70083b7018708f5a948d)
- chore: adding v2.0.0 Changelog updates [`4ddbf3d`](https://github.com/nevermined-io/sdk-js/commit/4ddbf3de548ed94c0a79341961693510151ce9bd)

### [v2.0.0](https://github.com/nevermined-io/sdk-js/compare/v2.0.0-rc9...v2.0.0)
#### [v2.0.0](https://github.com/nevermined-io/sdk-js/compare/v2.0.0-rc9...v2.0.0)

> 20 October 2023
Expand Down Expand Up @@ -1580,7 +1588,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- ci: testing with https services [`bb96077`](https://github.com/nevermined-io/sdk-js/commit/bb96077c9403ea7ae26195a51d8a92e144cea384)
- linting [`d2547ed`](https://github.com/nevermined-io/sdk-js/commit/d2547edfbfebb49b488c97c4ce9e6d6f2ee849e4)

### [v1.0.0](https://github.com/nevermined-io/sdk-js/compare/v1.0.0-rc9...v1.0.0)
#### [v1.0.0](https://github.com/nevermined-io/sdk-js/compare/v1.0.0-rc9...v1.0.0)

> 14 February 2023
Expand Down Expand Up @@ -2319,7 +2327,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

> 2 May 2022
- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248)
- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248)
- Adding v0.19.21 Changelog updates [`c93cdc5`](https://github.com/nevermined-io/sdk-js/commit/c93cdc55f139a43db4130ccb0f80924d2645a931)

#### [v0.19.21](https://github.com/nevermined-io/sdk-js/compare/v0.19.20...v0.19.21)
Expand Down Expand Up @@ -2582,7 +2590,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

> 18 January 2022
- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186)
- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186)
- [wip] Create agreement+pay in one transaction [`#183`](https://github.com/nevermined-io/sdk-js/pull/183)
- Adapting to contracts `v1.3.3` [`#177`](https://github.com/nevermined-io/sdk-js/pull/177)
- Adding v0.17.2 Changelog updates [`5eddda4`](https://github.com/nevermined-io/sdk-js/commit/5eddda43954e013e6e6f7344c9a877d801aacb5c)
Expand Down Expand Up @@ -3088,7 +3096,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Feature/sync develop [`#268`](https://github.com/nevermined-io/sdk-js/pull/268)
- Quick fix for non-eip1559 networks [`#266`](https://github.com/nevermined-io/sdk-js/pull/266)
- integrate Permissions and refactor search query [`#264`](https://github.com/nevermined-io/sdk-js/pull/264)
- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248)
- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248)
- Get the keeper version from the artifacts instead of package version [`#244`](https://github.com/nevermined-io/sdk-js/pull/244)
- replace `metadata-api` url by `marketplace-api` and sort type [`#243`](https://github.com/nevermined-io/sdk-js/pull/243)
- fixing issues with BigNumbers [`#246`](https://github.com/nevermined-io/sdk-js/pull/246)
Expand Down Expand Up @@ -3127,7 +3135,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Feature/190 add did to sec markets [`#191`](https://github.com/nevermined-io/sdk-js/pull/191)
- Adding utility methods for getting nft token uri [`#189`](https://github.com/nevermined-io/sdk-js/pull/189)
- Lint ... [`#187`](https://github.com/nevermined-io/sdk-js/pull/187)
- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186)
- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186)
- [wip] Create agreement+pay in one transaction [`#183`](https://github.com/nevermined-io/sdk-js/pull/183)
- Adapting to contracts `v1.3.3` [`#177`](https://github.com/nevermined-io/sdk-js/pull/177)
- Correct typo in route [`#184`](https://github.com/nevermined-io/sdk-js/pull/184)
Expand Down
1 change: 0 additions & 1 deletion integration/nevermined/NVMApiKey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ describe('Nevermined API Key', () => {
const publicKey =
'0x04c19e8524f8080e0f9a5ef54c87b7596a2c93a992e986f713d02e091142d7d57f3094c34a265fc5dfd098e2143cb8eaf325e5621a7572ba00997654a19a819b35'
// We should get the private key from the node (STAGING)
// const privateKey = '0x9bf5d7e4978ed5206f760e6daded34d657572bd49fa5b3fe885679329fb16b16'

encryptedNvmApiKey = await NvmApiKey.generate(
nvm.utils.signature,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nevermined-io/sdk",
"version": "3.0.37",
"version": "3.0.38",
"description": "Javascript SDK for connecting with Nevermined Data Platform ",
"main": "./dist/node/sdk.js",
"typings": "./dist/node/sdk.d.ts",
Expand Down
11 changes: 6 additions & 5 deletions src/models/NvmApiKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { bytesToHex } from 'viem/utils'

export class NvmApiKey implements JWTPayload {
/**
* The public address of the account issuing the key
* The public address of the account issuing the key.
*/
iss: string

Expand All @@ -18,7 +18,7 @@ export class NvmApiKey implements JWTPayload {
aud: string

/**
* The public address of the account the key is issued for. Typically the address of the Node/Backend who can process the key
* The public address of the account the key is issued for.
*/
sub: string

Expand Down Expand Up @@ -199,11 +199,12 @@ export class NvmApiKey implements JWTPayload {
* @returns a JWT string representing the hash of the NvmApiKey
*/
public async hashJWT(signatureUtils: SignatureUtils, issuerAccount: NvmAccount): Promise<string> {
const address = getChecksumAddress(issuerAccount.getId())
const issuerAddress = getChecksumAddress(issuerAccount.getId())

return new EthSignJWT({
iss: address,
sub: this.hash(),
iss: issuerAddress, // the account generating the hash (node/provider, etc) is the issuer of the hash
sub: this.iss, // the issuer of the NVMApiKey (the user) is the subject of the hash
jti: this.hash(),
exp: this.exp,
})
.setProtectedHeader({ alg: 'ES256K' })
Expand Down

0 comments on commit 19fc2a9

Please sign in to comment.