Skip to content

Commit

Permalink
chore: convert buffer into uint8array
Browse files Browse the repository at this point in the history
Signed-off-by: Berend Sliedrecht <berend@animo.id>
  • Loading branch information
berendsliedrecht committed Feb 3, 2025
1 parent 6ed8a71 commit 3a5b77f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/askar/src/wallet/AskarBaseWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export abstract class AskarBaseWallet implements Wallet {
// This will be fixed once we use the new 'using' syntax
key = _key

const keyPublicBytes = key.publicBytes
const keyPublicBytes = expandIfPossible(key.publicBytes, keyType)

// Store key
await this.withSession((session) =>
Expand Down Expand Up @@ -352,7 +352,7 @@ export abstract class AskarBaseWallet implements Wallet {
if (!isError(error)) {
throw new CredoError('Attempted to throw error, but it was not of type Error', { cause: error })
}
throw new WalletError(`Error signing data with verkey ${key.publicKeyBase58}. ${error.message}`, { cause: error })
throw new WalletError(`Error signing data with key associated with ${key.publicKeyBase58}. ${error.message}`, { cause: error })

Check failure on line 355 in packages/askar/src/wallet/AskarBaseWallet.ts

View workflow job for this annotation

GitHub Actions / Validate

Replace `·cause:·error` with `⏎········cause:·error,⏎·····`
} finally {
askarKey?.handle.free()
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/crypto/Key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class Key {
}

public static fromPublicKeyBase58(publicKey: string, keyType: KeyType) {
const publicKeyBytes = TypedArrayEncoder.fromBase58(publicKey)
const publicKeyBytes = Uint8Array.from(TypedArrayEncoder.fromBase58(publicKey))

return Key.fromPublicKey(publicKeyBytes, keyType)
}
Expand Down Expand Up @@ -70,7 +70,7 @@ export class Key {

// We return an object structure based on the key, so that when this object is
// serialized to JSON it will be nicely formatted instead of the bytes printed
public toJSON() {
private toJSON() {
return {
keyType: this.keyType,
publicKeyBase58: this.publicKeyBase58,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Ed25519JWk', () => {
expect(jwk.kty).toEqual('OKP')
expect(jwk.crv).toEqual('Ed25519')
expect(jwk.keyType).toEqual(KeyType.Ed25519)
expect(jwk.publicKey).toEqual(TypedArrayEncoder.fromBase64(jwkJson.x))
expect(jwk.publicKey).toEqual(Uint8Array.from(TypedArrayEncoder.fromBase64(jwkJson.x)))
expect(jwk.supportedEncryptionAlgorithms).toEqual([])
expect(jwk.supportedSignatureAlgorithms).toEqual(['EdDSA'])
expect(jwk.key.keyType).toEqual(KeyType.Ed25519)
Expand All @@ -26,7 +26,7 @@ describe('Ed25519JWk', () => {
const jwk = Ed25519Jwk.fromJson(jwkJson)
expect(jwk.x).toEqual(jwkJson.x)

expect(() => Ed25519Jwk.fromJson({ ...jwkJson, kty: 'test' })).toThrowError("Invalid 'Ed25519' JWK.")
expect(() => Ed25519Jwk.fromJson({ ...jwkJson, kty: 'test' })).toThrow("Invalid 'Ed25519' JWK.")
})

test('fromPublicKey', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/crypto/jose/jwk/__tests__/X25519Jwk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('X25519JWk', () => {
expect(jwk.kty).toEqual('OKP')
expect(jwk.crv).toEqual('X25519')
expect(jwk.keyType).toEqual(KeyType.X25519)
expect(jwk.publicKey).toEqual(TypedArrayEncoder.fromBase64(jwkJson.x))
expect(jwk.publicKey).toEqual(Uint8Array.from(TypedArrayEncoder.fromBase64(jwkJson.x)))
expect(jwk.supportedEncryptionAlgorithms).toEqual(['ECDH-ES+A128KW', 'ECDH-ES+A192KW', 'ECDH-ES+A256KW', 'ECDH-ES'])
expect(jwk.supportedSignatureAlgorithms).toEqual([])
expect(jwk.key.keyType).toEqual(KeyType.X25519)
Expand All @@ -26,7 +26,7 @@ describe('X25519JWk', () => {
const jwk = X25519Jwk.fromJson(jwkJson)
expect(jwk.x).toEqual(jwkJson.x)

expect(() => X25519Jwk.fromJson({ ...jwkJson, kty: 'test' })).toThrowError("Invalid 'X25519' JWK.")
expect(() => X25519Jwk.fromJson({ ...jwkJson, kty: 'test' })).toThrow("Invalid 'X25519' JWK.")
})

test('fromPublicKey', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/wallet/Wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export interface Wallet extends Disposable {

export interface WalletCreateKeyOptions {
keyType: KeyType
seed?: Uint8Array
privateKey?: Uint8Array
seed?: Buffer
privateKey?: Buffer
keyBackend?: KeyBackend
keyId?: string
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ describe('MediationRecipientService', () => {

expect(extendedRouting).toMatchObject({
endpoints: ['https://a-mediator-endpoint.com'],
routingKeys: [routingKey],
routingKeys: routing.routingKeys,
})
expect(mediationRepository.findSingleByQuery).toHaveBeenCalledWith(agentContext, { default: true })
})
Expand Down

0 comments on commit 3a5b77f

Please sign in to comment.