Skip to content

Commit 36a7166

Browse files
authored
chore: Fix lint reversion in common-identity (#512)
1 parent 6cb32d9 commit 36a7166

File tree

6 files changed

+17
-19
lines changed

6 files changed

+17
-19
lines changed

typescript/packages/common-identity/src/ed25519/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ export class Ed25519Signer<ID extends DIDKey> implements Signer<ID> {
6666
static async generateMnemonic<ID extends DIDKey>(): Promise<
6767
[Ed25519Signer<ID>, string]
6868
> {
69-
let mnemonic = bip39.generateMnemonic(wordlist, 256);
69+
const mnemonic = bip39.generateMnemonic(wordlist, 256);
7070
return [await Ed25519Signer.fromMnemonic(mnemonic), mnemonic];
7171
}
7272

7373
static async fromMnemonic<ID extends DIDKey>(
7474
mnemonic: string,
7575
): Promise<Ed25519Signer<ID>> {
76-
let bytes = bip39.mnemonicToEntropy(mnemonic, wordlist);
76+
const bytes = bip39.mnemonicToEntropy(mnemonic, wordlist);
7777
return await Ed25519Signer.fromRaw(bytes);
7878
}
7979

typescript/packages/common-identity/src/ed25519/native.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,27 @@ export class NativeEd25519Signer<ID extends DIDKey> implements Signer<ID> {
122122
"verify",
123123
],
124124
);
125-
let did = bytesToDid(new Uint8Array(rawPublic));
125+
const did = bytesToDid(new Uint8Array(rawPublic));
126126
return new NativeEd25519Signer({ publicKey, privateKey }, did as ID);
127127
}
128128

129129
static async generate<ID extends DIDKey>(): Promise<NativeEd25519Signer<ID>> {
130130
// This notably sets only the public key as extractable, ideal as we need
131131
// access to the public key for DID generation.
132-
let keypair = await globalThis.crypto.subtle.generateKey(
132+
const keypair = await globalThis.crypto.subtle.generateKey(
133133
ED25519_ALG,
134134
false,
135135
[
136136
"sign",
137137
"verify",
138138
],
139139
);
140-
let did = await didFromPublicKey(keypair.publicKey);
140+
const did = await didFromPublicKey(keypair.publicKey);
141141
return new NativeEd25519Signer(keypair, did as ID);
142142
}
143143

144144
static async deserialize<ID extends DIDKey>(keypair: CryptoKeyPair) {
145-
let did = await didFromPublicKey(keypair.publicKey);
145+
const did = await didFromPublicKey(keypair.publicKey);
146146
return new NativeEd25519Signer(keypair, did as ID);
147147
}
148148
}
@@ -179,14 +179,14 @@ export class NativeEd25519Verifier<ID extends DIDKey> implements Verifier<ID> {
179179
static async fromDid<ID extends DIDKey>(
180180
did: ID,
181181
): Promise<NativeEd25519Verifier<ID>> {
182-
let bytes = didToBytes(did);
182+
const bytes = didToBytes(did);
183183
return await NativeEd25519Verifier.fromRaw(bytes);
184184
}
185185

186186
static async fromRaw<ID extends DIDKey>(
187187
rawPublicKey: Uint8Array,
188188
): Promise<NativeEd25519Verifier<ID>> {
189-
let did = bytesToDid(new Uint8Array(rawPublicKey)) as ID;
189+
const did = bytesToDid(new Uint8Array(rawPublicKey)) as ID;
190190
// Set the public key to be extractable for DID generation.
191191
const publicKey = await globalThis.crypto.subtle.importKey(
192192
"raw",
@@ -233,6 +233,6 @@ function ed25519RawToPkcs8(rawSignerKey: Uint8Array): Uint8Array {
233233
}
234234

235235
async function didFromPublicKey(publicKey: CryptoKey): Promise<DIDKey> {
236-
let rawPublicKey = await globalThis.crypto.subtle.exportKey("raw", publicKey);
236+
const rawPublicKey = await globalThis.crypto.subtle.exportKey("raw", publicKey);
237237
return bytesToDid(new Uint8Array(rawPublicKey));
238238
}

typescript/packages/common-identity/src/ed25519/noble.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ export class NobleEd25519Signer<ID extends DIDKey> implements Signer<ID> {
5252
}
5353

5454
static async generate<ID extends DIDKey>(): Promise<NobleEd25519Signer<ID>> {
55-
let privateKey = ed25519.utils.randomPrivateKey();
55+
const privateKey = ed25519.utils.randomPrivateKey();
5656
return await NobleEd25519Signer.fromRaw(privateKey);
5757
}
5858

59-
static async deserialize<ID extends DIDKey>(keypair: InsecureCryptoKeyPair) {
60-
return new NobleEd25519Signer<ID>(keypair);
59+
static deserialize<ID extends DIDKey>(keypair: InsecureCryptoKeyPair) {
60+
return Promise.resolve(new NobleEd25519Signer<ID>(keypair));
6161
}
6262
}
6363

@@ -86,13 +86,13 @@ export class NobleEd25519Verifier<ID extends DIDKey> implements Verifier<ID> {
8686
static async fromDid<ID extends DIDKey>(
8787
did: ID,
8888
): Promise<NobleEd25519Verifier<ID>> {
89-
let bytes = didToBytes(did);
89+
const bytes = didToBytes(did);
9090
return await NobleEd25519Verifier.fromRaw(bytes);
9191
}
9292

93-
static async fromRaw<ID extends DIDKey>(
93+
static fromRaw<ID extends DIDKey>(
9494
rawPublicKey: Uint8Array,
9595
): Promise<NobleEd25519Verifier<ID>> {
96-
return new NobleEd25519Verifier(rawPublicKey);
96+
return Promise.resolve(new NobleEd25519Verifier(rawPublicKey));
9797
}
9898
}

typescript/packages/common-identity/src/ed25519/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function ed25519RawToPkcs8(rawPrivateKey: Uint8Array): Uint8Array {
4343

4444
// Convert public key bytes into a `did:key:z...`.
4545
export function bytesToDid(publicKey: Uint8Array): DIDKey {
46-
let bytes = new Uint8Array(ED25519_PUB_KEY_TAGGED_SIZE);
46+
const bytes = new Uint8Array(ED25519_PUB_KEY_TAGGED_SIZE);
4747
varint.encodeTo(ED25519_CODE, bytes);
4848
bytes.set(publicKey, ED25519_PUB_KEY_TAG_SIZE);
4949
return `did:key:${base58btc.encode(bytes)}`;

typescript/packages/common-identity/src/interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface Signature<Payload> extends Uint8Array {
2929
valueOf(): this & Signature<Payload>;
3030
}
3131

32-
export type Unit = {};
32+
export type Unit = NonNullable<unknown>;
3333

3434
export type Await<T> = PromiseLike<T> | T;
3535
export type AwaitResult<T extends Unit = Unit, E extends Error = Error> = Await<

typescript/packages/common-identity/test/ed25519.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,9 @@ function testBothImpls(
145145
fn: (signer: SignerClass, verifier: VerifierClass) => void | Promise<void>,
146146
) {
147147
Deno.test(`(native) ${name}`, async () => {
148-
// @ts-expect-error
149148
return await fn(NativeEd25519Signer, NativeEd25519Verifier);
150149
});
151150
Deno.test(`(noble) ${name}`, async () => {
152-
// @ts-expect-error
153151
return await fn(NobleEd25519Signer, NobleEd25519Verifier);
154152
});
155153
}

0 commit comments

Comments
 (0)