Skip to content

Commit f683cfe

Browse files
authored
refactor(encryption): replace adonisjs module with boringnode (#113)
1 parent fb79b12 commit f683cfe

29 files changed

Lines changed: 44 additions & 45 deletions

benchmarks/adonisjs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import { createServer } from 'node:http'
1111
import { Logger } from '@adonisjs/logger'
1212
import { Emitter } from '@adonisjs/events'
13-
import { Encryption } from '@adonisjs/encryption'
13+
import { Encryption } from '@boringnode/encryption'
1414
import { Application } from '@adonisjs/application'
1515

1616
import { defineConfig, Server } from '../build/index.js'

factories/request.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import { Socket } from 'node:net'
1111
import proxyAddr from 'proxy-addr'
1212
import { randomUUID } from 'node:crypto'
13-
import type { Encryption } from '@adonisjs/encryption'
13+
import type { Encryption } from '@boringnode/encryption'
1414
import { IncomingMessage, ServerResponse } from 'node:http'
15-
import { EncryptionFactory } from '@adonisjs/encryption/factories'
15+
import { EncryptionFactory } from '@boringnode/encryption/factories'
1616

1717
import { HttpRequest } from '../src/request.ts'
1818
import { QsParserFactory } from './qs_parser_factory.ts'

factories/response.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
*/
99

1010
import { Socket } from 'node:net'
11-
import type { Encryption } from '@adonisjs/encryption'
11+
import type { Encryption } from '@boringnode/encryption'
1212
import { IncomingMessage, ServerResponse } from 'node:http'
13-
import { EncryptionFactory } from '@adonisjs/encryption/factories'
13+
import { EncryptionFactory } from '@boringnode/encryption/factories'
1414

1515
import { RouterFactory } from './router.ts'
1616
import { HttpResponse } from '../src/response.ts'

factories/router.ts

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

10-
import type { Encryption } from '@adonisjs/encryption'
10+
import type { Encryption } from '@boringnode/encryption'
1111
import type { Application } from '@adonisjs/application'
1212
import { AppFactory } from '@adonisjs/application/factories'
13-
import { EncryptionFactory } from '@adonisjs/encryption/factories'
13+
import { EncryptionFactory } from '@boringnode/encryption/factories'
1414

1515
import { Router } from '../src/router/main.ts'
1616
import { QsParserFactory } from './qs_parser_factory.ts'

factories/server_factory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
import { Logger } from '@adonisjs/logger'
1111
import { Emitter } from '@adonisjs/events'
12-
import type { Encryption } from '@adonisjs/encryption'
12+
import type { Encryption } from '@boringnode/encryption'
1313
import type { Application } from '@adonisjs/application'
1414
import { AppFactory } from '@adonisjs/application/factories'
15-
import { EncryptionFactory } from '@adonisjs/encryption/factories'
15+
import { EncryptionFactory } from '@boringnode/encryption/factories'
1616

1717
import { Server } from '../src/server/main.ts'
1818
import { defineConfig } from '../src/define_config.ts'

factories/url_builder_factory.ts

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

10-
import type { Encryption } from '@adonisjs/encryption'
11-
import { EncryptionFactory } from '@adonisjs/encryption/factories'
10+
import type { Encryption } from '@boringnode/encryption'
11+
import { EncryptionFactory } from '@boringnode/encryption/factories'
1212

1313
import { RouterFactory } from './router.ts'
1414
import type { Router } from '../src/router/main.ts'

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@
4444
"license": "MIT",
4545
"devDependencies": {
4646
"@adonisjs/application": "^9.0.0-next.4",
47-
"@adonisjs/encryption": "^7.0.0-next.1",
4847
"@adonisjs/eslint-config": "^3.0.0-next.1",
4948
"@adonisjs/events": "^10.1.0-next.2",
5049
"@adonisjs/fold": "^11.0.0-next.2",
5150
"@adonisjs/logger": "^7.1.0-next.0",
5251
"@adonisjs/prettier-config": "^1.4.5",
5352
"@adonisjs/tsconfig": "^2.0.0-next.0",
53+
"@boringnode/encryption": "^0.2.2",
5454
"@fastify/middie": "^9.0.3",
5555
"@japa/assert": "^4.1.1",
5656
"@japa/expect-type": "^2.0.3",
@@ -116,7 +116,6 @@
116116
},
117117
"peerDependencies": {
118118
"@adonisjs/application": "^9.0.0-next.4",
119-
"@adonisjs/encryption": "^7.0.0-next.1",
120119
"@adonisjs/events": "^10.1.0-next.2",
121120
"@adonisjs/fold": "^11.0.0-next.2",
122121
"@adonisjs/logger": "^7.1.0-next.0",

src/cookies/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* file that was distributed with this source code.
88
*/
99

10-
import type { Encryption } from '@adonisjs/encryption'
10+
import type { Encryption } from '@boringnode/encryption'
1111

1212
import * as plainCookiesDriver from './drivers/plain.ts'
1313
import * as signedCookiesDriver from './drivers/signed.ts'

src/cookies/drivers/encrypted.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* file that was distributed with this source code.
88
*/
99

10-
import type { Encryption } from '@adonisjs/encryption'
10+
import type { Encryption } from '@boringnode/encryption'
1111

1212
/**
1313
* Encrypt a value to be set as cookie

src/cookies/drivers/signed.ts

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

10-
import type { Encryption } from '@adonisjs/encryption'
10+
import type { Encryption } from '@boringnode/encryption'
1111

1212
/**
1313
* Signs a value to be shared as a cookie. The signed output has a
@@ -22,7 +22,7 @@ export function pack(key: string, value: any, encryption: Encryption): null | st
2222
if (value === undefined || value === null) {
2323
return null
2424
}
25-
return `s:${encryption.verifier.sign(value, undefined, key)}`
25+
return `s:${encryption.getMessageVerifier().sign(value, undefined, key)}`
2626
}
2727

2828
/**
@@ -51,5 +51,5 @@ export function unpack(key: string, signedValue: string, encryption: Encryption)
5151
return null
5252
}
5353

54-
return encryption.verifier.unsign(value, key)
54+
return encryption.getMessageVerifier().unsign(value, key)
5555
}

0 commit comments

Comments
 (0)