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

feat: possibility to set masterSecretId inside of WalletConfig #1043

Merged
merged 8 commits into from
Oct 7, 2022

Conversation

an-uhryn
Copy link
Contributor

@an-uhryn an-uhryn commented Oct 4, 2022

No description provided.

@an-uhryn an-uhryn requested a review from a team as a code owner October 4, 2022 15:48
@jakubkoci
Copy link
Contributor

Thanks, @an-uhryn. Could you please fix the linter error? I think we can disable @typescript-eslint/no-non-null-assertion for the whole Wallet.test.ts file.

@genaris
Copy link
Contributor

genaris commented Oct 4, 2022

Thanks, @an-uhryn. Could you please fix the linter error? I think we can disable @typescript-eslint/no-non-null-assertion for the whole Wallet.test.ts file.

Yes, and don't forget the DCO issue following the instructions from here.

@codecov-commenter
Copy link

codecov-commenter commented Oct 4, 2022

Codecov Report

Merging #1043 (08a9440) into main (a230841) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1043      +/-   ##
==========================================
+ Coverage   88.72%   88.77%   +0.04%     
==========================================
  Files         523      523              
  Lines       12173    12173              
  Branches     1913     1914       +1     
==========================================
+ Hits        10801    10806       +5     
+ Misses       1368     1363       -5     
  Partials        4        4              
Impacted Files Coverage Δ
packages/core/src/types.ts 100.00% <ø> (ø)
packages/core/src/wallet/IndyWallet.ts 71.18% <100.00%> (+0.56%) ⬆️
packages/core/src/storage/IndyStorageService.ts 95.08% <0.00%> (+0.81%) ⬆️
packages/core/src/error/IndySdkError.ts 100.00% <0.00%> (+60.00%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@genaris genaris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @an-uhryn!

I'm not an expert on this topic so consider some of my comments more as suggestions than changes requested.

I guess this PR tackles mainly scenarios where wallet has been created externally, but the resulting code left me a doubt regarding usage of this masterSecretId when it is created within the framework: in the method createAndOpen from IndyWallet.ts I see:

      await this.createMasterSecret(this.handle, walletConfig.id)

Shouldn't be walletConfig.masterSecretId used in this case unless not specified (in which case walletConfig.id would be used instead)?

@@ -26,6 +26,7 @@ export interface WalletConfig {
type: string
[key: string]: unknown
}
masterSecretId?: 'string'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing something but I think it should be string without quotes

Suggested change
masterSecretId?: 'string'
masterSecretId?: string

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this only allows the string literal string. Any other string is not allowed.

@@ -56,6 +56,10 @@ export class IndyWallet implements Wallet {
}

public get masterSecretId() {
if (this.walletConfig?.masterSecretId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering the checks that are done in line 63, for consistency with other conditions, maybe we could avoid this if sentence and simply return this.walletConfig.masterSecretId ?? this.walletConfig.id

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. We found out that !this.walletConfig?.id is not needed if we're not mistaken. It should not get into a state where the walletConfig.id is missing but isInitialized is true.

@an-uhryn
Copy link
Contributor Author

an-uhryn commented Oct 5, 2022

@jakubkoci @genaris @blu3beri Thanks for your review and suggestions. I made all changes.

@an-uhryn an-uhryn requested review from jakubkoci, berendsliedrecht and genaris and removed request for jakubkoci and berendsliedrecht October 5, 2022 13:05
Copy link
Contributor

@TimoGlastra TimoGlastra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the masterSecret is still created when you create the wallet, what is the use case of this feature?

Fine to merge, just curious as to why you'd want this

throw new AriesFrameworkError(
'Wallet has not been initialized yet. Make sure to await agent.initialize() before using the agent.'
)
}

return this.walletConfig.id
return this.walletConfig?.masterSecretId ?? this.walletConfig?.id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can lead to undefined being returned, which wasn't possible before. We should probably check if either have a value and throw an error otherwise

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good question. I'm not sure but is it possible case that isInitialized is true but we don't have this.walletConfig.id?
It seems like we have to open wallet to make isInitialized to be true, but we can't open wallet without wallet id.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the reason why CI is failing (a few lines in IndyHolderService.ts are expecting it to be always defined, something that makes sense because otherwise it cannot work).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I returned back this check and also aded for masterSecretId. Hope now everything will be fine 🙂

beforeEach(() => {
config = getAgentConfig('WalletTest')
configWithMasterSecretId = getAgentConfig('WalletTestWithMasterSecretId')
configWithMasterSecretId.walletConfig!.masterSecretId = 'customMasterSecretId'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can extend the getAgentConfig method and pass the masterSecretId to that method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sure!

Copy link
Contributor Author

@an-uhryn an-uhryn Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with extending of getAgentConfig

@an-uhryn
Copy link
Contributor Author

an-uhryn commented Oct 5, 2022

As the masterSecret is still created when you create the wallet, what is the use case of this feature?

Fine to merge, just curious as to why you'd want this

Hey @TimoGlastra. We are migrating from VCX Library to Aries Framework JavaScript. We have some credentials which were created with VCX Library (with masterSecretId) and after credentials migrating we can't accept proof request without setting masterSecretId.

@TimoGlastra
Copy link
Contributor

Makes sense! 👍

…llet id check, extended unit tests)

Signed-off-by: Andrii Uhryn <[email protected]>
export function getBaseConfig(name: string, extraConfig: Partial<InitConfig> = {}) {
export function getBaseConfig(
name: string,
extraConfig: Partial<InitConfig> = {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm extraConfig can already take the wallet config, so not so sure on adding it as a separate property. I understand that if we take it from extraConfig, we will also have to provide the walletConfig object in whole, but I don't think that is necesarily bad.

So call getBaseConfig like this:

getBaseConfig({
    walletConfig: {
      id: `Wallet: Name of the test`,
      key: `Key: Name of the test`,
      masterSecretId: 'the key'
    }
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah thanks, I missed that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean getAgentConfig?

getAgentConfig('WalletTestWithMasterSecretId', {
    walletConfig: {
        id: `Wallet: WalletTestWithMasterSecretId`,
        key: `Key: WalletTestWithMasterSecretId`,
        masterSecretId: 'customMasterSecretId',
    },
})

@TimoGlastra
Copy link
Contributor

There's some prettier errors, can you fix those?

@genaris genaris merged commit 8a89ad2 into openwallet-foundation:main Oct 7, 2022
TimoGlastra added a commit that referenced this pull request Oct 11, 2022
* feat: OOB public did (#930)

Signed-off-by: Pavel Zarecky <[email protected]>

* feat(routing): manual mediator pickup lifecycle management (#989)

Signed-off-by: Ariel Gentile <[email protected]>

* docs(demo): faber creates invitation (#995)

Signed-off-by: conanoc <[email protected]>

* chore(release): v0.2.3 (#999)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(question-answer): question answer protocol state/role check (#1001)

Signed-off-by: Ariel Gentile <[email protected]>

* feat: Action Menu protocol (Aries RFC 0509) implementation (#974)

Signed-off-by: Ariel Gentile <[email protected]>

* fix(ledger): remove poolConnected on pool close (#1011)

Signed-off-by: Niall Shaw <[email protected]>

* fix(ledger): check taa version instad of aml version (#1013)

Signed-off-by: Jakub Koci <[email protected]>

* chore: add @janrtvld to maintainers (#1016)

Signed-off-by: Timo Glastra <[email protected]>

* feat(routing): add settings to control back off strategy on mediator reconnection (#1017)

Signed-off-by: Sergi Garreta <[email protected]>

* fix: avoid crash when an unexpected message arrives (#1019)

Signed-off-by: Pavel Zarecky <[email protected]>

* chore(release): v0.2.4 (#1024)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* style: fix some lint errors

Signed-off-by: Ariel Gentile <[email protected]>

* feat: use did:key flag (#1029)

Signed-off-by: Ariel Gentile <[email protected]>

* ci: set default rust version (#1036)

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

* fix(oob): allow encoding in content type header (#1037)

Signed-off-by: Timo Glastra <[email protected]>

* feat: connection type (#994)

Signed-off-by: KolbyRKunz <[email protected]>

* chore(module-tenants): match package versions

Signed-off-by: Ariel Gentile <[email protected]>

* feat: improve sending error handling (#1045)

Signed-off-by: Ariel Gentile <[email protected]>

* feat: expose findAllByQuery method in modules and services (#1044)

Signed-off-by: Jim Ezesinachi <[email protected]>

* feat: possibility to set masterSecretId inside of WalletConfig (#1043)

Signed-off-by: Andrii Uhryn <[email protected]>

* fix(oob): set connection alias when creating invitation (#1047)

Signed-off-by: Jakub Koci <[email protected]>

* build: fix missing parameter

Signed-off-by: Ariel Gentile <[email protected]>

Signed-off-by: Pavel Zarecky <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: conanoc <[email protected]>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: Niall Shaw <[email protected]>
Signed-off-by: Jakub Koci <[email protected]>
Signed-off-by: Timo Glastra <[email protected]>
Signed-off-by: Sergi Garreta <[email protected]>
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
Signed-off-by: KolbyRKunz <[email protected]>
Signed-off-by: Jim Ezesinachi <[email protected]>
Signed-off-by: Andrii Uhryn <[email protected]>
Co-authored-by: Iskander508 <[email protected]>
Co-authored-by: conanoc <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Niall Shaw <[email protected]>
Co-authored-by: jakubkoci <[email protected]>
Co-authored-by: Timo Glastra <[email protected]>
Co-authored-by: Sergi Garreta Serra <[email protected]>
Co-authored-by: Sai Ranjit Tummalapalli <[email protected]>
Co-authored-by: KolbyRKunz <[email protected]>
Co-authored-by: Jim Ezesinachi <[email protected]>
Co-authored-by: an-uhryn <[email protected]>
genaris added a commit to 2060-io/aries-framework-javascript that referenced this pull request Oct 13, 2022
* feat: OOB public did (openwallet-foundation#930)

Signed-off-by: Pavel Zarecky <[email protected]>

* feat(routing): manual mediator pickup lifecycle management (openwallet-foundation#989)

Signed-off-by: Ariel Gentile <[email protected]>

* docs(demo): faber creates invitation (openwallet-foundation#995)

Signed-off-by: conanoc <[email protected]>

* chore(release): v0.2.3 (openwallet-foundation#999)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(question-answer): question answer protocol state/role check (openwallet-foundation#1001)

Signed-off-by: Ariel Gentile <[email protected]>

* feat: Action Menu protocol (Aries RFC 0509) implementation (openwallet-foundation#974)

Signed-off-by: Ariel Gentile <[email protected]>

* fix(ledger): remove poolConnected on pool close (openwallet-foundation#1011)

Signed-off-by: Niall Shaw <[email protected]>

* fix(ledger): check taa version instad of aml version (openwallet-foundation#1013)

Signed-off-by: Jakub Koci <[email protected]>

* chore: add @janrtvld to maintainers (openwallet-foundation#1016)

Signed-off-by: Timo Glastra <[email protected]>

* feat(routing): add settings to control back off strategy on mediator reconnection (openwallet-foundation#1017)

Signed-off-by: Sergi Garreta <[email protected]>

* fix: avoid crash when an unexpected message arrives (openwallet-foundation#1019)

Signed-off-by: Pavel Zarecky <[email protected]>

* chore(release): v0.2.4 (openwallet-foundation#1024)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* style: fix some lint errors

Signed-off-by: Ariel Gentile <[email protected]>

* feat: use did:key flag (openwallet-foundation#1029)

Signed-off-by: Ariel Gentile <[email protected]>

* ci: set default rust version (openwallet-foundation#1036)

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

* fix(oob): allow encoding in content type header (openwallet-foundation#1037)

Signed-off-by: Timo Glastra <[email protected]>

* feat: connection type (openwallet-foundation#994)

Signed-off-by: KolbyRKunz <[email protected]>

* chore(module-tenants): match package versions

Signed-off-by: Ariel Gentile <[email protected]>

* feat: improve sending error handling (openwallet-foundation#1045)

Signed-off-by: Ariel Gentile <[email protected]>

* feat: expose findAllByQuery method in modules and services (openwallet-foundation#1044)

Signed-off-by: Jim Ezesinachi <[email protected]>

* feat: possibility to set masterSecretId inside of WalletConfig (openwallet-foundation#1043)

Signed-off-by: Andrii Uhryn <[email protected]>

* fix(oob): set connection alias when creating invitation (openwallet-foundation#1047)

Signed-off-by: Jakub Koci <[email protected]>

* build: fix missing parameter

Signed-off-by: Ariel Gentile <[email protected]>

Signed-off-by: Pavel Zarecky <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: conanoc <[email protected]>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: Niall Shaw <[email protected]>
Signed-off-by: Jakub Koci <[email protected]>
Signed-off-by: Timo Glastra <[email protected]>
Signed-off-by: Sergi Garreta <[email protected]>
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
Signed-off-by: KolbyRKunz <[email protected]>
Signed-off-by: Jim Ezesinachi <[email protected]>
Signed-off-by: Andrii Uhryn <[email protected]>
Co-authored-by: Iskander508 <[email protected]>
Co-authored-by: conanoc <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Niall Shaw <[email protected]>
Co-authored-by: jakubkoci <[email protected]>
Co-authored-by: Timo Glastra <[email protected]>
Co-authored-by: Sergi Garreta Serra <[email protected]>
Co-authored-by: Sai Ranjit Tummalapalli <[email protected]>
Co-authored-by: KolbyRKunz <[email protected]>
Co-authored-by: Jim Ezesinachi <[email protected]>
Co-authored-by: an-uhryn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants