How to use the pvtsutils.BufferSourceConverter.isBufferSource function in pvtsutils

To help you get started, we’ve selected a few pvtsutils 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 PeculiarVentures / webcrypto-liner / src / subtle.ts View on Github external
private fixNativeArguments(method: SubtleMethods, args: any[]) {
    const res = [...args];
    if (method === "importKey") {
      if (res[0]?.toLowerCase?.() === "jwk" && !BufferSourceConverter.isBufferSource(res[1])) {
        // IE11 uses ArrayBuffer instead of JSON object
        res[1] = Convert.FromUtf8String(JSON.stringify(res[1]));
      }
    }

    if (this.browserInfo.name === Browser.IE && args[1] instanceof WrappedNativeCryptoKey) {
      // Fix algs for IE11
      switch (method) {
        case "sign":
        case "verify":
        case "encrypt":
        case "decrypt":
          res[0] = { ...this.prepareAlgorithm(res[0]), hash: (res[1]?.algorithm as RsaHashedKeyAlgorithm)?.hash?.name };
          break;
        case "wrapKey":
        case "unwrapKey":