All files / src storage-shared-key-credential.ts

71.42% Statements 5/7
50% Branches 2/4
100% Functions 2/2
71.42% Lines 5/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24              13x       13x       13x 13x       7x      
import { createHmacSigner } from './internal/storage-encoding'
 
export class StorageSharedKeyCredential {
  public readonly accountName: string
  private readonly sign: (text: string) => Promise<string>
 
  public constructor(accountName: string, accountKey: string) {
    Iif (accountName.length === 0) {
      throw new TypeError('accountName is required')
    }
 
    Iif (accountKey.length === 0) {
      throw new TypeError('accountKey is required')
    }
 
    this.accountName = accountName
    this.sign = createHmacSigner(accountKey)
  }
 
  public async computeHMACSHA256(stringToSign: string): Promise<string> {
    return await this.sign(stringToSign)
  }
}