-
Notifications
You must be signed in to change notification settings - Fork 204
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
Conversation
Thanks, @an-uhryn. Could you please fix the linter error? I think we can disable |
Codecov Report
@@ 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
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this 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)?
packages/core/src/types.ts
Outdated
@@ -26,6 +26,7 @@ export interface WalletConfig { | |||
type: string | |||
[key: string]: unknown | |||
} | |||
masterSecretId?: 'string' |
There was a problem hiding this comment.
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
masterSecretId?: 'string' | |
masterSecretId?: string |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Signed-off-by: Andrii Uhryn <[email protected]>
Signed-off-by: Andrii Uhryn <[email protected]>
…cretKey dummy value) Signed-off-by: Andrii Uhryn <[email protected]>
2124a26
to
7dabaee
Compare
Signed-off-by: Andrii Uhryn <[email protected]>
@jakubkoci @genaris @blu3beri Thanks for your review and suggestions. I made all changes. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sure!
There was a problem hiding this comment.
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
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. |
Makes sense! 👍 |
…llet id check, extended unit tests) Signed-off-by: Andrii Uhryn <[email protected]>
packages/core/tests/helpers.ts
Outdated
export function getBaseConfig(name: string, extraConfig: Partial<InitConfig> = {}) { | ||
export function getBaseConfig( | ||
name: string, | ||
extraConfig: Partial<InitConfig> = {}, |
There was a problem hiding this comment.
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'
}
})
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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',
},
})
There's some prettier errors, can you fix those? |
Signed-off-by: Andrii Uhryn <[email protected]>
* 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]>
* 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]>
No description provided.