Skip to content

Commit eabc43e

Browse files
committed
refactor: rename error to E_BLIND_INDEX_NOT_SUPPORTED
1 parent b85978c commit eabc43e

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

modules/encryption/drivers/legacy.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
* file that was distributed with this source code.
88
*/
99

10-
import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto'
10+
import { errors } from '@boringnode/encryption'
1111
import { MessageBuilder, type Secret } from '@poppinss/utils'
12+
import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto'
1213
import { BaseDriver, Hmac, base64UrlDecode, base64UrlEncode } from '@boringnode/encryption'
1314
import type {
14-
EncryptionDriverContract,
1515
CypherText,
1616
EncryptOptions,
17+
EncryptionDriverContract,
1718
} from '@boringnode/encryption/types'
18-
import { errors } from '@boringnode/encryption'
19-
import { E_LEGACY_BLIND_INDEX_NOT_SUPPORTED } from '../errors.ts'
19+
import { E_BLIND_INDEX_NOT_SUPPORTED } from '../errors.ts'
2020

2121
/**
2222
* Configuration for the Legacy encryption driver.
@@ -189,13 +189,13 @@ export class Legacy extends BaseDriver implements EncryptionDriverContract {
189189
* Legacy driver does not support blind indexes.
190190
*/
191191
blindIndex(_payload: any, _purpose: string): string {
192-
throw new E_LEGACY_BLIND_INDEX_NOT_SUPPORTED()
192+
throw new E_BLIND_INDEX_NOT_SUPPORTED(['legacy'])
193193
}
194194

195195
/**
196196
* Legacy driver does not support blind indexes.
197197
*/
198198
blindIndexes(_payload: any, _purpose: string): string[] {
199-
throw new E_LEGACY_BLIND_INDEX_NOT_SUPPORTED()
199+
throw new E_BLIND_INDEX_NOT_SUPPORTED(['legacy'])
200200
}
201201
}

modules/encryption/errors.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import { errors as boringnodeErrors } from '@boringnode/encryption'
1313
/**
1414
* Raised when attempting to compute blind indexes using the legacy driver.
1515
*/
16-
export const E_LEGACY_BLIND_INDEX_NOT_SUPPORTED = createError(
17-
'Blind indexes are not supported by the legacy encryption driver',
18-
'E_LEGACY_BLIND_INDEX_NOT_SUPPORTED'
16+
export const E_BLIND_INDEX_NOT_SUPPORTED = createError<[string]>(
17+
'Blind indexes are not supported by the "%s" encryption driver',
18+
'E_BLIND_INDEX_NOT_SUPPORTED'
1919
)
2020

2121
/**
2222
* Encryption errors exposed by this package.
2323
*/
2424
export const errors = {
2525
...boringnodeErrors,
26-
E_LEGACY_BLIND_INDEX_NOT_SUPPORTED,
26+
E_BLIND_INDEX_NOT_SUPPORTED,
2727
}

tests/encryption/legacy.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import { test } from '@japa/runner'
1111
import { setTimeout } from 'node:timers/promises'
1212

13+
import type { ApplicationService } from '../../src/types.ts'
1314
import { Legacy, legacy } from '../../modules/encryption/drivers/legacy.ts'
1415
import { drivers, defineConfig } from '../../modules/encryption/define_config.ts'
15-
import type { ApplicationService } from '../../src/types.ts'
1616

1717
const SECRET_KEY = 'averylongsecretkeythatshouldbe32'
1818

@@ -279,7 +279,7 @@ test.group('Legacy | blind indexes', () => {
279279

280280
assert.throws(
281281
() => encryption.blindIndex('foo@example.com', 'users.email'),
282-
'Blind indexes are not supported by the legacy encryption driver'
282+
'Blind indexes are not supported by the "legacy" encryption driver'
283283
)
284284
})
285285

@@ -288,7 +288,7 @@ test.group('Legacy | blind indexes', () => {
288288

289289
assert.throws(
290290
() => encryption.blindIndexes('foo@example.com', 'users.email'),
291-
'Blind indexes are not supported by the legacy encryption driver'
291+
'Blind indexes are not supported by the "legacy" encryption driver'
292292
)
293293
})
294294
})

0 commit comments

Comments
 (0)