-
Notifications
You must be signed in to change notification settings - Fork 197
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(askar): improved hardware key support #1968
feat(askar): improved hardware key support #1968
Conversation
Signed-off-by: Berend Sliedrecht <[email protected]>
|
keyId: kid, | ||
}) | ||
|
||
return new Key(publicKeyBytes, keyType, keyId) |
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.
Should be kid
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.
This looks good to me 👍 Will you remove the secure env integration from askar again?
@@ -44,6 +45,7 @@ | |||
"typescript": "~5.5.2" | |||
}, | |||
"peerDependencies": { | |||
"@hyperledger/aries-askar-shared": "^0.2.3" | |||
"@hyperledger/aries-askar-shared": "^0.2.3", | |||
"@animo-id/expo-secure-environment": "^0.0.1-alpha.0" |
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.
Can we add it as optional peer dependency? https://pnpm.io/next/package_json#peerdependenciesmetaoptional
const secureEnvironment = require('@animo-id/expo-secure-environment') as { | ||
sign: typeof sign | ||
generateKeypair: typeof generateKeypair | ||
getPublicBytesForKeyId: typeof getPublicBytesForKeyId | ||
} |
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.
the type is not really needed, as you never import from the .native.ts file. So it doesn't really matter to add the typing here (And it'll probably get out of date). If you do want to have the typying, i'd recommend to use import syntax:
const secureEnvironment = require('@animo-id/expo-secure-environment') as { | |
sign: typeof sign | |
generateKeypair: typeof generateKeypair | |
getPublicBytesForKeyId: typeof getPublicBytesForKeyId | |
} | |
const secureEnvironment = require('@animo-id/expo-secure-environment') as typeof import('@animo-id/expo-secure-environment') |
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.
However this still may give issues in envs where the package is not imported and then TS will complain that it can't find the types. So we should either always install the dep and only import it in native. Or we should not always install the dep, but then we should also not import the types form the package at all
generateKeypair: (id: string) => void | ||
} { | ||
throw new Error( | ||
'expo-secure-environment cannot be imported in Node.js. Currently, there is no hardware key support for node.js' |
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.
'expo-secure-environment cannot be imported in Node.js. Currently, there is no hardware key support for node.js' | |
'@animo.id/expo-secure-environment cannot be imported in Node.js. Currently, there is no hardware key support for node.js' |
private async doesSecureEnvironmentKeyExist(keyId: string): Promise<boolean> { | ||
try { | ||
const entryObject = await this.withSession((session) => | ||
session.fetch({ category: 'SecureEnvironmentRecord', name: keyId }) |
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.
session.fetch({ category: 'SecureEnvironmentRecord', name: keyId }) | |
session.fetch({ category: 'SecureEnvironmentKeyRecord', name: keyId }) |
@@ -509,4 +557,28 @@ export abstract class AskarBaseWallet implements Wallet { | |||
throw new WalletError('Error saving KeyPair record', { cause: error }) | |||
} | |||
} | |||
|
|||
private async storeHardwareKeyById(options: { |
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.
incosistent naming hardwareKey vs secureEnvironmentKey
@@ -8,10 +8,12 @@ import { getKeyTypeByMultiCodecPrefix, getMultiCodecPrefixByKeyType } from './mu | |||
export class Key { | |||
public readonly publicKey: Buffer | |||
public readonly keyType: KeyType | |||
public keyId: 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.
public keyId: string | |
/** the identifier of the key. If not provided in the constructor the base58 encoded public key will be used as the key identifier by default | |
*/ | |
public keyId: string |
Yes, can pick that up later. |
Signed-off-by: Berend Sliedrecht <[email protected]>
1a941e7
into
openwallet-foundation:main
Signed-off-by: Berend Sliedrecht [email protected]