Skip to content

Commit

Permalink
Enforcing type imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
armfazh committed Jun 28, 2024
1 parent 884f807 commit 2c91200
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 70 deletions.
7 changes: 5 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
"sourceType": "module",
"project": true
},
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
Expand Down Expand Up @@ -90,7 +91,9 @@
{
"argsIgnorePattern": "^_"
}
]
],
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/consistent-type-exports": "error"
}
}
]
Expand Down
5 changes: 3 additions & 2 deletions src/3dh_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
// Licensed under the BSD-3-Clause license found in the LICENSE file or
// at https://opensource.org/licenses/BSD-3-Clause

import { AuthFinish, AuthRequest, CredentialRequest, KE1, KE2 } from './messages.js'
import type { CredentialRequest, KE2 } from './messages.js'
import { AuthFinish, AuthRequest, KE1 } from './messages.js'
import { deriveKeys, preambleBuild, tripleDH_IKM } from './common.js'

import { Config } from './config.js'
import type { Config } from './config.js'
import { joinAll } from './util.js'

export class AKE3DHClient {
Expand Down
11 changes: 3 additions & 8 deletions src/3dh_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@
// Licensed under the BSD-3-Clause license found in the LICENSE file or
// at https://opensource.org/licenses/BSD-3-Clause

import {
AuthFinish,
AuthResponse,
CredentialResponse,
ExpectedAuthResult,
KE1
} from './messages.js'
import type { AuthFinish, CredentialResponse, KE1 } from './messages.js'
import { AuthResponse, ExpectedAuthResult } from './messages.js'
import { ctEqual, joinAll } from './util.js'
import { deriveKeys, preambleBuild, tripleDH_IKM } from './common.js'

import { Config } from './config.js'
import type { Config } from './config.js'

export class AKE3DHServer {
private expected?: ExpectedAuthResult
Expand Down
8 changes: 4 additions & 4 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
// Licensed under the BSD-3-Clause license found in the LICENSE file or
// at https://opensource.org/licenses/BSD-3-Clause

import { AKEFn, AKEKeyPair, OPRFFn } from './thecrypto.js'
import type { AKEFn, AKEKeyPair, OPRFFn } from './thecrypto.js'
import type { SuiteID } from '@cloudflare/voprf-ts'
import {
Evaluation,
EvaluationRequest,
FinalizeData,
OPRFClient,
OPRFServer,
Oprf,
SuiteID,
deriveKeyPair,
generateKeyPair,
getKeySizes
} from '@cloudflare/voprf-ts'
import { CredentialResponse, KE1 } from './messages.js'
import type { CredentialResponse, KE1 } from './messages.js'
import { encode_number, encode_vector_16, encode_vector_8, joinAll } from './util.js'

import { Config } from './config.js'
import type { Config } from './config.js'

export type Ok<T> = { ok: true; value: T }
export type Err<E> = { ok: false; error: E }
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Licensed under the BSD-3-Clause license found in the LICENSE file or
// at https://opensource.org/licenses/BSD-3-Clause

import { AKEFn, HashFn, KDFFn, MACFn, OPRFFn, PrngFn } from './thecrypto.js'
import type { AKEFn, HashFn, KDFFn, MACFn, OPRFFn, PrngFn } from './thecrypto.js'

export interface Config {
readonly constants: {
Expand Down
15 changes: 5 additions & 10 deletions src/core_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
// Licensed under the BSD-3-Clause license found in the LICENSE file or
// at https://opensource.org/licenses/BSD-3-Clause

import { AKEKeyPair, KSFFn, ScryptKSFFn } from './thecrypto.js'
import {
CredentialRequest,
CredentialResponse,
Envelope,
RegistrationRecord,
RegistrationRequest,
RegistrationResponse
} from './messages.js'
import type { AKEKeyPair, KSFFn } from './thecrypto.js'
import { ScryptKSFFn } from './thecrypto.js'
import type { CredentialResponse, RegistrationResponse } from './messages.js'
import { CredentialRequest, Envelope, RegistrationRecord, RegistrationRequest } from './messages.js'
import { checked_vector, encode_vector_16, joinAll, xor } from './util.js'

import { Config } from './config.js'
import type { Config } from './config.js'
import { LABELS } from './common.js'

class CleartextCredentials {
Expand Down
12 changes: 3 additions & 9 deletions src/core_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@
// Licensed under the BSD-3-Clause license found in the LICENSE file or
// at https://opensource.org/licenses/BSD-3-Clause

import {
CredentialRequest,
CredentialResponse,
Envelope,
RegistrationRecord,
RegistrationRequest,
RegistrationResponse
} from './messages.js'
import type { CredentialRequest, RegistrationRecord, RegistrationRequest } from './messages.js'
import { CredentialResponse, Envelope, RegistrationResponse } from './messages.js'
import { checked_vector, joinAll, xor } from './util.js'

import { Config } from './config.js'
import type { Config } from './config.js'
import { LABELS } from './common.js'

export class OpaqueCoreServer {
Expand Down
2 changes: 1 addition & 1 deletion src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { checked_vector, decode_vector_16, encode_vector_16, joinAll } from './util.js'

import { Config } from './config.js'
import type { Config } from './config.js'

export abstract class Serializable {
abstract serialize(): number[]
Expand Down
9 changes: 5 additions & 4 deletions src/opaque_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
// Licensed under the BSD-3-Clause license found in the LICENSE file or
// at https://opensource.org/licenses/BSD-3-Clause

import {
import type {
KE1,
KE2,
KE3,
RegistrationRecord,
RegistrationRequest,
RegistrationResponse
} from './messages.js'
import { KSFFn, ScryptKSFFn } from './thecrypto.js'
import { KE3 } from './messages.js'
import type { KSFFn } from './thecrypto.js'
import { ScryptKSFFn } from './thecrypto.js'

import { AKE3DHClient } from './3dh_client.js'
import { Config } from './config.js'
import type { Config } from './config.js'
import { OpaqueCoreClient } from './core_client.js'

export interface RegistrationClient {
Expand Down
11 changes: 5 additions & 6 deletions src/opaque_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
// Licensed under the BSD-3-Clause license found in the LICENSE file or
// at https://opensource.org/licenses/BSD-3-Clause

import { AKEExportKeyPair, AKEKeyPair } from './thecrypto.js'
import {
import type { AKEExportKeyPair, AKEKeyPair } from './thecrypto.js'
import type {
KE1,
KE2,
KE3,
RegistrationRecord,
RegistrationRequest,
RegistrationResponse,
Serializable
RegistrationResponse
} from './messages.js'
import { KE2, Serializable } from './messages.js'

import { AKE3DHServer } from './3dh_server.js'
import { Config } from './config.js'
import type { Config } from './config.js'
import { OpaqueCoreServer } from './core_server.js'

export interface RegistrationServer {
Expand Down
11 changes: 7 additions & 4 deletions src/suites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
// Licensed under the BSD-3-Clause license found in the LICENSE file or
// at https://opensource.org/licenses/BSD-3-Clause

import { AKE3DH, Err, OPRFBaseMode, Ok, Result } from './common.js'
import { AKEFn, Hash, HashFn, Hkdf, Hmac, KDFFn, MACFn, OPRFFn, Prng, PrngFn } from './thecrypto.js'
import { Oprf, SuiteID } from '@cloudflare/voprf-ts'
import type { Result } from './common.js'
import { AKE3DH, Err, OPRFBaseMode, Ok } from './common.js'
import type { AKEFn, HashFn, KDFFn, MACFn, OPRFFn, PrngFn } from './thecrypto.js'
import { Hash, Hkdf, Hmac, Prng } from './thecrypto.js'
import type { SuiteID } from '@cloudflare/voprf-ts'
import { Oprf } from '@cloudflare/voprf-ts'

import { Config } from './config.js'
import type { Config } from './config.js'

export enum OpaqueID {
OPAQUE_P256 = 'P256-SHA256',
Expand Down
10 changes: 6 additions & 4 deletions test/credentials.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
// Licensed under the BSD-3-Clause license found in the LICENSE file or
// at https://opensource.org/licenses/BSD-3-Clause

import {
import type {
AKEExportKeyPair,
Config,
RegistrationClient,
RegistrationServer
} from '../src/index.js'
import {
CredentialFile,
OpaqueClient,
OpaqueConfig,
OpaqueID,
OpaqueServer,
RegistrationClient,
RegistrationRecord,
RegistrationRequest,
RegistrationResponse,
RegistrationServer
RegistrationResponse
} from '../src/index.js'

import { KVStorage } from './common.js'
Expand Down
10 changes: 2 additions & 8 deletions test/opaque_core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
// Licensed under the BSD-3-Clause license found in the LICENSE file or
// at https://opensource.org/licenses/BSD-3-Clause

import {
AKEKeyPair,
Config,
CredentialFile,
OpaqueConfig,
OpaqueID,
RegistrationRecord
} from '../src/index.js'
import type { AKEKeyPair, Config, RegistrationRecord } from '../src/index.js'
import { CredentialFile, OpaqueConfig, OpaqueID } from '../src/index.js'

import { KVStorage } from './common.js'
import { OpaqueCoreClient } from '../src/core_client.js'
Expand Down
10 changes: 6 additions & 4 deletions test/opaque_full.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
// Licensed under the BSD-3-Clause license found in the LICENSE file or
// at https://opensource.org/licenses/BSD-3-Clause

import {
import type {
AKEExportKeyPair,
AuthClient,
AuthServer,
Config,
RegistrationClient,
RegistrationServer
} from '../src/index.js'
import {
CredentialFile,
KE1,
KE2,
Expand All @@ -16,11 +20,9 @@ import {
OpaqueConfig,
OpaqueID,
OpaqueServer,
RegistrationClient,
RegistrationRecord,
RegistrationRequest,
RegistrationResponse,
RegistrationServer
RegistrationResponse
} from '../src/index.js'

import { KVStorage } from './common.js'
Expand Down
6 changes: 3 additions & 3 deletions test/vectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
// Licensed under the BSD-3-Clause license found in the LICENSE file or
// at https://opensource.org/licenses/BSD-3-Clause

import type { Config, KSFFn } from '../src/index.js'
import {
AKE3DH,
Config,
CredentialFile,
IdentityKSFFn,
KE1,
KE2,
KE3,
KSFFn,
OpaqueClient,
OpaqueConfig,
OpaqueServer,
RegistrationRecord,
isOk
} from '../src/index.js'
import { KVStorage, fromHex, fromHexString, notNullHex, notNullHexString, toHex } from './common.js'
import { OPRFClient, Oprf, SuiteID } from '@cloudflare/voprf-ts'
import type { SuiteID } from '@cloudflare/voprf-ts'
import { OPRFClient, Oprf } from '@cloudflare/voprf-ts'

import { jest } from '@jest/globals'
import { readFileSync } from 'node:fs'
Expand Down

0 comments on commit 2c91200

Please sign in to comment.