Skip to content

Commit

Permalink
Merge pull request #67 from achingbrain/fix/import-buffer
Browse files Browse the repository at this point in the history
fix: import Buffer before use
  • Loading branch information
microshine authored Jan 16, 2024
2 parents 49f7b85 + 09d7d33 commit ad3a364
Show file tree
Hide file tree
Showing 25 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/converters/base64_url.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import { IJsonConverter } from "@peculiar/json-schema";
import { Convert } from "pvtsutils";

Expand Down
1 change: 1 addition & 0 deletions src/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import crypto from "crypto";
import * as core from "webcrypto-core";
import { SubtleCrypto } from "./subtle";
Expand Down
1 change: 1 addition & 0 deletions src/keys/key.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import { JsonProp, JsonPropTypes } from "@peculiar/json-schema";
import * as core from "webcrypto-core";

Expand Down
1 change: 1 addition & 0 deletions src/mechs/aes/aes_cmac.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import * as crypto from "crypto";
import * as core from "webcrypto-core";
import { AesCrypto } from "./crypto";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/aes/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import crypto, { CipherGCM, DecipherGCM } from "crypto";
import { JsonParser, JsonSerializer } from "@peculiar/json-schema";
import * as core from "webcrypto-core";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/aes/key.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Buffer } from "buffer";
import { JsonProp } from "@peculiar/json-schema";
import * as core from "webcrypto-core";
import { JsonBase64UrlConverter } from "../../converters";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/des/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import crypto from "crypto";
import { JsonParser, JsonSerializer } from "@peculiar/json-schema";
import * as core from "webcrypto-core";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/des/key.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Buffer } from "buffer";
import { JsonProp } from "@peculiar/json-schema";
import * as core from "webcrypto-core";
import { JsonBase64UrlConverter } from "../../converters";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/ec/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import crypto from "crypto";
import { AsnParser, AsnSerializer } from "@peculiar/asn1-schema";
import { JsonParser, JsonSerializer } from "@peculiar/json-schema";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/ec/private_key.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import { AsnParser, AsnSerializer } from "@peculiar/asn1-schema";
import { IJsonConvertible, JsonParser, JsonSerializer } from "@peculiar/json-schema";
import * as core from "webcrypto-core";
Expand Down
7 changes: 4 additions & 3 deletions src/mechs/ed/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import crypto from "crypto";
import { AsnParser } from "@peculiar/asn1-schema";
import { JsonParser, JsonSerializer } from "@peculiar/json-schema";
Expand Down Expand Up @@ -141,14 +142,14 @@ export class EdCrypto {
crv: algorithm.namedCurve,
d: Convert.ToBase64Url(asnKey.d),
});

key.algorithm = Object.assign({}, algorithm) as EcKeyAlgorithm;
key.extractable = extractable;
key.usages = keyUsages;

return key;
}

protected static async importPublicKey(asnKey: ArrayBuffer, algorithm: EcKeyImportParams, extractable: boolean, keyUsages: KeyUsage[]) {
const key = new EdPublicKey();
key.fromJSON({
Expand Down
1 change: 1 addition & 0 deletions src/mechs/ed/private_key.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import { AsnParser, AsnSerializer } from "@peculiar/asn1-schema";
import { IJsonConvertible, JsonParser, JsonSerializer } from "@peculiar/json-schema";
import * as core from "webcrypto-core";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/ed/public_key.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import { AsnParser, AsnSerializer } from "@peculiar/asn1-schema";
import { IJsonConvertible } from "@peculiar/json-schema";
import { Convert } from "pvtsutils";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/hkdf/hkdf.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import crypto from "crypto";
import * as core from "webcrypto-core";
import { BufferSourceConverter, CryptoKey } from "webcrypto-core";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/hkdf/key.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Buffer } from "buffer";
import { CryptoKey } from "../../keys";

export class HkdfCryptoKey extends CryptoKey {
Expand Down
1 change: 1 addition & 0 deletions src/mechs/hmac/hmac.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import crypto from "crypto";
import { JsonParser, JsonSerializer } from "@peculiar/json-schema";
import * as core from "webcrypto-core";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/hmac/key.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Buffer } from "buffer";
import { JsonProp } from "@peculiar/json-schema";
import { JsonBase64UrlConverter } from "../../converters";
import { CryptoKey } from "../../keys";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/pbkdf/pbkdf2.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import crypto from "crypto";
import * as core from "webcrypto-core";
import { PbkdfCryptoKey } from "./key";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/rsa/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import crypto from "crypto";
import { AsnParser, AsnSerializer } from "@peculiar/asn1-schema";
import { JsonParser, JsonSerializer } from "@peculiar/json-schema";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/rsa/private_key.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import { AsnParser, AsnSerializer } from "@peculiar/asn1-schema";
import { JsonParser, JsonSerializer } from "@peculiar/json-schema";
import * as core from "webcrypto-core";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/rsa/public_key.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import { AsnParser, AsnSerializer } from "@peculiar/asn1-schema";
import { JsonParser, JsonSerializer } from "@peculiar/json-schema";
import * as core from "webcrypto-core";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/rsa/rsa_oaep.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import crypto from "crypto";
import * as core from "webcrypto-core";
import { RsaCrypto } from "./crypto";
Expand Down
1 change: 1 addition & 0 deletions src/mechs/sha/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import crypto from "crypto";

export class ShaCrypto {
Expand Down
1 change: 1 addition & 0 deletions src/mechs/shake/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import crypto from "crypto";
import * as core from "webcrypto-core";

Expand Down
1 change: 1 addition & 0 deletions test/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from "buffer";
import assert from "node:assert";
import nodeCrypto from "node:crypto";
import process from "node:process";
Expand Down

0 comments on commit ad3a364

Please sign in to comment.