Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/adonisjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { createServer } from 'node:http'
import { Logger } from '@adonisjs/logger'
import { Emitter } from '@adonisjs/events'
import { Encryption } from '@adonisjs/encryption'
import { Encryption } from '@boringnode/encryption'
import { Application } from '@adonisjs/application'

import { defineConfig, Server } from '../build/index.js'
Expand Down
4 changes: 2 additions & 2 deletions factories/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import { Socket } from 'node:net'
import proxyAddr from 'proxy-addr'
import { randomUUID } from 'node:crypto'
import type { Encryption } from '@adonisjs/encryption'
import type { Encryption } from '@boringnode/encryption'
import { IncomingMessage, ServerResponse } from 'node:http'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'

import { HttpRequest } from '../src/request.ts'
import { QsParserFactory } from './qs_parser_factory.ts'
Expand Down
4 changes: 2 additions & 2 deletions factories/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*/

import { Socket } from 'node:net'
import type { Encryption } from '@adonisjs/encryption'
import type { Encryption } from '@boringnode/encryption'
import { IncomingMessage, ServerResponse } from 'node:http'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'

import { RouterFactory } from './router.ts'
import { HttpResponse } from '../src/response.ts'
Expand Down
4 changes: 2 additions & 2 deletions factories/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
* file that was distributed with this source code.
*/

import type { Encryption } from '@adonisjs/encryption'
import type { Encryption } from '@boringnode/encryption'
import type { Application } from '@adonisjs/application'
import { AppFactory } from '@adonisjs/application/factories'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'

import { Router } from '../src/router/main.ts'
import { QsParserFactory } from './qs_parser_factory.ts'
Expand Down
4 changes: 2 additions & 2 deletions factories/server_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

import { Logger } from '@adonisjs/logger'
import { Emitter } from '@adonisjs/events'
import type { Encryption } from '@adonisjs/encryption'
import type { Encryption } from '@boringnode/encryption'
import type { Application } from '@adonisjs/application'
import { AppFactory } from '@adonisjs/application/factories'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'

import { Server } from '../src/server/main.ts'
import { defineConfig } from '../src/define_config.ts'
Expand Down
4 changes: 2 additions & 2 deletions factories/url_builder_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* file that was distributed with this source code.
*/

import type { Encryption } from '@adonisjs/encryption'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import type { Encryption } from '@boringnode/encryption'
import { EncryptionFactory } from '@boringnode/encryption/factories'

import { RouterFactory } from './router.ts'
import type { Router } from '../src/router/main.ts'
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
"license": "MIT",
"devDependencies": {
"@adonisjs/application": "^9.0.0-next.4",
"@adonisjs/encryption": "^7.0.0-next.1",
"@adonisjs/eslint-config": "^3.0.0-next.1",
"@adonisjs/events": "^10.1.0-next.2",
"@adonisjs/fold": "^11.0.0-next.2",
"@adonisjs/logger": "^7.1.0-next.0",
"@adonisjs/prettier-config": "^1.4.5",
"@adonisjs/tsconfig": "^2.0.0-next.0",
"@boringnode/encryption": "^0.2.2",
"@fastify/middie": "^9.0.3",
"@japa/assert": "^4.1.1",
"@japa/expect-type": "^2.0.3",
Expand Down Expand Up @@ -117,7 +117,6 @@
},
"peerDependencies": {
"@adonisjs/application": "^9.0.0-next.4",
"@adonisjs/encryption": "^7.0.0-next.1",
"@adonisjs/events": "^10.1.0-next.2",
"@adonisjs/fold": "^11.0.0-next.2",
"@adonisjs/logger": "^7.1.0-next.0",
Expand Down
2 changes: 1 addition & 1 deletion src/cookies/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/

import type { Encryption } from '@adonisjs/encryption'
import type { Encryption } from '@boringnode/encryption'

import * as plainCookiesDriver from './drivers/plain.ts'
import * as signedCookiesDriver from './drivers/signed.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/cookies/drivers/encrypted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/

import type { Encryption } from '@adonisjs/encryption'
import type { Encryption } from '@boringnode/encryption'

/**
* Encrypt a value to be set as cookie
Expand Down
6 changes: 3 additions & 3 deletions src/cookies/drivers/signed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/

import type { Encryption } from '@adonisjs/encryption'
import type { Encryption } from '@boringnode/encryption'

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

/**
Expand Down Expand Up @@ -51,5 +51,5 @@ export function unpack(key: string, signedValue: string, encryption: Encryption)
return null
}

return encryption.verifier.unsign(value, key)
return encryption.getMessageVerifier().unsign(value, key)
}
2 changes: 1 addition & 1 deletion src/cookies/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { parse } from 'cookie-es'
import type { Encryption } from '@adonisjs/encryption'
import type { Encryption } from '@boringnode/encryption'

import { CookieClient } from './client.ts'

Expand Down
2 changes: 1 addition & 1 deletion src/cookies/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/

import type { Encryption } from '@adonisjs/encryption'
import type { Encryption } from '@boringnode/encryption'

import { CookieClient } from './client.ts'
import { serializeCookie } from '../helpers.ts'
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { serialize } from 'cookie-es'
// @ts-expect-error
import matchit from '@poppinss/matchit'
import string from '@poppinss/utils/string'
import { type Encryption } from '@adonisjs/encryption'
import { type Encryption } from '@boringnode/encryption'
import { parseBindingReference } from '@adonisjs/fold'

import { type Qs } from './qs.ts'
Expand Down Expand Up @@ -103,7 +103,7 @@ export function createSignedURL(
* on their 2 different domains, but we ignore that case for now and can consider
* it later (when someone asks for it)
*/
const signature = encryption.verifier.sign(
const signature = encryption.getMessageVerifier().sign(
createURL(identifier, tokens, searchParamsStringifier, params, {
...options,
prefixUrl: undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import proxyaddr from 'proxy-addr'
import { safeEqual } from '@poppinss/utils'
import Macroable from '@poppinss/macroable'
import lodash from '@poppinss/utils/lodash'
import type { Encryption } from '@adonisjs/encryption'
import type { Encryption } from '@boringnode/encryption'
import { type ServerResponse, type IncomingMessage, type IncomingHttpHeaders } from 'node:http'

import type { Qs } from './qs.ts'
Expand Down Expand Up @@ -1043,7 +1043,7 @@ export class HttpRequest extends Macroable {
/*
* Return false when signature fails
*/
const signedUrl = this.#encryption.verifier.unsign(signature, purpose)
const signedUrl = this.#encryption.getMessageVerifier().unsign(signature, purpose)
if (!signedUrl) {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion src/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { stat } from 'node:fs/promises'
import Macroable from '@poppinss/macroable'
import { createReadStream } from 'node:fs'
import contentDisposition from 'content-disposition'
import type { Encryption } from '@adonisjs/encryption'
import type { Encryption } from '@boringnode/encryption'
import { RuntimeException } from '@poppinss/utils/exception'
import { type ServerResponse, type IncomingMessage, type OutgoingHttpHeaders } from 'node:http'

Expand Down
2 changes: 1 addition & 1 deletion src/router/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import is from '@sindresorhus/is'
import { moduleImporter } from '@adonisjs/fold'
import type { Encryption } from '@adonisjs/encryption'
import type { Encryption } from '@boringnode/encryption'
import type { Application } from '@adonisjs/application'
import { RuntimeException } from '@poppinss/utils/exception'
import type { Constructor, LazyImport } from '@poppinss/utils/types'
Expand Down
2 changes: 1 addition & 1 deletion src/router/signed_url_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/

import type { Encryption } from '@adonisjs/encryption'
import type { Encryption } from '@boringnode/encryption'

import { type Router } from './main.ts'
import { createSignedURL } from '../helpers.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import onFinished from 'on-finished'
import Middleware from '@poppinss/middleware'
import type { Logger } from '@adonisjs/logger'
import type { LazyImport } from '@poppinss/utils/types'
import type { Encryption } from '@adonisjs/encryption'
import type { Encryption } from '@boringnode/encryption'
import type { Server as HttpsServer } from 'node:https'
import type { Application } from '@adonisjs/application'
import type { EmitterLike } from '@adonisjs/events/types'
Expand Down
2 changes: 1 addition & 1 deletion tests/cookies/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { test } from '@japa/runner'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'

import { CookieClient } from '../../src/cookies/client.ts'

Expand Down
2 changes: 1 addition & 1 deletion tests/cookies/drivers/encrypted.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import { test } from '@japa/runner'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'
import { pack, unpack, canUnpack } from '../../../src/cookies/drivers/encrypted.ts'

const encryption = new EncryptionFactory().create()
Expand Down
2 changes: 1 addition & 1 deletion tests/cookies/drivers/signed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import { test } from '@japa/runner'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'
import { pack, unpack, canUnpack } from '../../../src/cookies/drivers/signed.ts'

const encryption = new EncryptionFactory().create()
Expand Down
2 changes: 1 addition & 1 deletion tests/cookies/parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { test } from '@japa/runner'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'

import { CookieParser } from '../../src/cookies/parser.ts'
import { CookieSerializer } from '../../src/cookies/serializer.ts'
Expand Down
2 changes: 1 addition & 1 deletion tests/cookies/serializer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { test } from '@japa/runner'
import { setTimeout } from 'node:timers/promises'
import { MessageBuilder } from '@poppinss/utils'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'

import { CookieSerializer } from '../../src/cookies/serializer.ts'
import base64 from '@poppinss/utils/base64'
Expand Down
2 changes: 1 addition & 1 deletion tests/redirect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import supertest from 'supertest'
import { test } from '@japa/runner'
import { AppFactory } from '@adonisjs/application/factories'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'

import { RouterFactory } from '../factories/router.ts'
import { httpServer } from '../factories/http_server.ts'
Expand Down
2 changes: 1 addition & 1 deletion tests/request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import proxyAddr from 'proxy-addr'
import { test } from '@japa/runner'
import Middleware from '@poppinss/middleware'
import { createServer as httpsServer } from 'node:https'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'

import { RouterFactory } from '../factories/router.ts'
import { HttpRequestFactory } from '../factories/request.ts'
Expand Down
2 changes: 1 addition & 1 deletion tests/response.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Readable } from 'node:stream'
import { fileURLToPath } from 'node:url'
import { AppFactory } from '@adonisjs/application/factories'
import { createWriteStream, createReadStream } from 'node:fs'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'

import { RouterFactory } from '../factories/router.ts'
import { CookieParser } from '../src/cookies/parser.ts'
Expand Down
2 changes: 1 addition & 1 deletion tests/router/legacy_url_builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import { test } from '@japa/runner'
import { AppFactory } from '@adonisjs/application/factories'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'

import { Router } from '../../src/router/main.ts'
import { HttpRequestFactory } from '../../factories/request.ts'
Expand Down
14 changes: 7 additions & 7 deletions tests/router/router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import { parse } from 'qs'
import { test } from '@japa/runner'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'

import { RouterFactory } from '../../factories/router.ts'

Expand Down Expand Up @@ -885,7 +885,7 @@ test.group('Make signed url', () => {

const url = router.makeSignedUrl('/posts/:id', { id: 1 })!
const qs = parse(url.split('?')[1])
assert.equal(encryption.verifier.unsign(qs.signature as string), '/posts/1')
assert.equal(encryption.getMessageVerifier().unsign(qs.signature as string), '/posts/1')
})

test("make signed url to a given route by it's name", ({ assert }) => {
Expand All @@ -897,7 +897,7 @@ test.group('Make signed url', () => {

const url = router.makeSignedUrl('showPost', { id: 1 })!
const qs = parse(url.split('?')[1])
assert.equal(encryption.verifier.unsign(qs.signature as string), '/posts/1')
assert.equal(encryption.getMessageVerifier().unsign(qs.signature as string), '/posts/1')
})

test("make signed url to a given route by it's controller method", ({ assert }) => {
Expand All @@ -909,7 +909,7 @@ test.group('Make signed url', () => {

const url = router.makeSignedUrl('#controllers/posts.index', { id: 1 })!
const qs = parse(url.split('?')[1])
assert.equal(encryption.verifier.unsign(qs.signature as string), '/posts/1')
assert.equal(encryption.getMessageVerifier().unsign(qs.signature as string), '/posts/1')
})

test('make url for a specific domain', ({ assert }) => {
Expand All @@ -932,7 +932,7 @@ test.group('Make signed url', () => {
}
)!
const qs = parse(url.split('?')[1])
assert.equal(encryption.verifier.unsign(qs.signature as string), '/articles/1')
assert.equal(encryption.getMessageVerifier().unsign(qs.signature as string), '/articles/1')
})

test('make signed url with expiry', ({ assert }) => {
Expand All @@ -945,7 +945,7 @@ test.group('Make signed url', () => {
const url = router.makeSignedUrl('PostsController.index', { id: 1, expiresIn: '1m' })!
const qs = parse(url.split('?')[1])

assert.equal(encryption.verifier.unsign(qs.signature as string), '/posts/1')
assert.equal(encryption.getMessageVerifier().unsign(qs.signature as string), '/posts/1')
})

test('make signed url with custom query string', ({ assert }) => {
Expand All @@ -960,7 +960,7 @@ test.group('Make signed url', () => {
})!
const qs = parse(url.split('?')[1])

assert.equal(encryption.verifier.unsign(qs.signature as string), '/posts/1?page=1')
assert.equal(encryption.getMessageVerifier().unsign(qs.signature as string), '/posts/1?page=1')
assert.equal(Number(qs.page), 1)
})

Expand Down
2 changes: 1 addition & 1 deletion tests/router/url_builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { test } from '@japa/runner'
import { EncryptionFactory } from '@adonisjs/encryption/factories'
import { EncryptionFactory } from '@boringnode/encryption/factories'

import { RouterFactory } from '../../factories/router.ts'
import { HttpRequestFactory } from '../../factories/request.ts'
Expand Down