How to use the @aws-sdk/util-base64-browser.fromBase64 function in @aws-sdk/util-base64-browser

To help you get started, we’ve selected a few @aws-sdk/util-base64-browser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-encryption-sdk-javascript / modules / material-management-browser / src / browser_cryptographic_materials_manager.ts View on Github external
/* Precondition: WebCryptoDefaultCryptographicMaterialsManager If the algorithm suite specification requires a signatureCurve a context must exist. */
    if (!encryptionContext) throw new Error('Encryption context does not contain required public key.')

    const { [ENCODED_SIGNER_KEY]: compressPoint } = encryptionContext

    /* Precondition: WebCryptoDefaultCryptographicMaterialsManager The context must contain the public key. */
    needs(compressPoint, 'Context does not contain required public key.')

    const backend = await getWebCryptoBackend()
    const subtle = getNonZeroByteBackend(backend)
    const webCryptoAlgorithm = { name: 'ECDSA', namedCurve }
    const extractable = false
    const usages = ['verify']
    const format = 'raw'

    const publicKeyBytes = VerificationKey.decodeCompressPoint(fromBase64(compressPoint), suite)
    const publicKey = await subtle.importKey(format, publicKeyBytes, webCryptoAlgorithm, extractable, usages)

    return new WebCryptoDecryptionMaterial(suite, encryptionContext)
      .setVerificationKey(new VerificationKey(publicKey, suite))
  }
}
github aws / aws-sdk-js-v3 / packages / util-base64-universal / src / index.ts View on Github external
export function fromBase64(input: string): Uint8Array {
  if (isNode()) {
    return nodeFromBase64(input);
  }

  return browserFromBase64(input);
}
github aws / aws-encryption-sdk-javascript / modules / integration-browser / src / decrypt_materials_manager_web_crypto.ts View on Github external
async function aesKeyring (keyInfo:AesKeyInfo, key: AESKey) {
  const keyName = key['key-id']
  const keyNamespace = keyInfo['provider-id']
  const { encoding, material } = key
  needs(encoding === 'base64', 'Unsupported encoding')
  const rawKey = fromBase64(material)
  if (!Bits2RawAesWrappingSuiteIdentifier[key.bits]) throw new Error('Unsupported right now')
  const wrappingSuite = Bits2RawAesWrappingSuiteIdentifier[key.bits]
  const masterKey = await RawAesKeyringWebCrypto.importCryptoKey(rawKey, wrappingSuite)
  return new RawAesKeyringWebCrypto({ keyName, keyNamespace, masterKey, wrappingSuite })
}

@aws-sdk/util-base64-browser

A pure JS Base64 <-> UInt8Array converter

Apache-2.0
Latest version published 1 year ago

Package Health Score

72 / 100
Full package analysis

Similar packages