Skip to content

Commit

Permalink
fix: replace headers map with axios header
Browse files Browse the repository at this point in the history
  • Loading branch information
frdomovic committed Jun 18, 2024
1 parent c4194d8 commit 76330b9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/calimero-sdk/src/crypto/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import bs58 from 'bs58';
import { WalletType } from '../api/nodeApi';
import { ClientKey } from '../types/storage';
import { getStorageClientKey } from '../storage/storage';
import { Header } from '../api/httpClient';

export interface AxiosHeader {
[key: string]: string;
}

export async function createAuthHeader(
payload: string,
): Promise<Header[] | null> {
): Promise<AxiosHeader | null> {
const privateKey: PrivateKey = await getPrivateKey();

if (!privateKey) {
Expand All @@ -27,12 +30,12 @@ export async function createAuthHeader(
const signatureBase58 = bs58.encode(signature);
const contentBase58 = bs58.encode(hashArray);

const headers: Header[] = [
{ key: 'wallet_type', value: JSON.stringify(WalletType.NEAR) },
{ key: 'signing_key', value: signing_key },
{ key: 'signature', value: signatureBase58 },
{ key: 'challenge', value: contentBase58 },
];
const headers: AxiosHeader = {
wallet_type: JSON.stringify(WalletType.NEAR),
signing_key: signing_key,
signature: signatureBase58,
challenge: contentBase58,
};

return headers;
}
Expand Down

0 comments on commit 76330b9

Please sign in to comment.