Skip to content

Commit ea00998

Browse files
committed
chore: prepare config for publishing
1 parent ce11974 commit ea00998

14 files changed

Lines changed: 1417 additions & 45 deletions

index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* @boringnode/encryption
3+
*
4+
* @license MIT
5+
* @copyright Boring Node
6+
*/
7+
8+
export { EncryptionManager } from './src/encryption_manager.ts'

package.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77
},
88
"main": "build/index.js",
99
"type": "module",
10-
"exports": {},
10+
"exports": {
11+
".": "./build/index.js",
12+
"./drivers/*": "./build/src/drivers/*.js",
13+
"./types": "./build/src/types/*.js"
14+
},
1115
"scripts": {
16+
"build": "yarn clean && tsup-node",
17+
"clean": "del-cli build",
1218
"lint": "eslint .",
1319
"pretest": "yarn lint",
1420
"quick:test": "yarn node --enable-source-maps --import=ts-node-maintained/register/esm bin/test.ts",
@@ -28,10 +34,12 @@
2834
"@swc/core": "^1.11.31",
2935
"@types/node": "^22.8.1",
3036
"c8": "^10.1.3",
37+
"del-cli": "^6.0.0",
3138
"eslint": "^9.28.0",
3239
"prettier": "^3.5.3",
3340
"release-it": "^18.1.2",
3441
"ts-node-maintained": "^10.9.5",
42+
"tsup": "^8.5.0",
3543
"typescript": "^5.8.3"
3644
},
3745
"author": "Romain Lanz <romain.lanz@pm.me>",
@@ -44,5 +52,21 @@
4452
"crypto"
4553
],
4654
"prettier": "@adonisjs/prettier-config",
55+
"publishConfig": {
56+
"access": "public",
57+
"tag": "latest"
58+
},
59+
"release-it": {
60+
"git": {
61+
"commitMessage": "chore(release): ${version}",
62+
"tagAnnotation": "v${version}",
63+
"tagName": "v${version}"
64+
},
65+
"github": {
66+
"release": true,
67+
"releaseName": "v${version}",
68+
"web": true
69+
}
70+
},
4771
"packageManager": "yarn@4.9.2+sha512.1fc009bc09d13cfd0e19efa44cbfc2b9cf6ca61482725eb35bbc5e257e093ebf4130db6dfe15d604ff4b79efd8e1e8e99b25fa7d0a6197c9f9826358d4d65c3c"
4872
}

src/drivers/aes_256_cbc.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
import { createCipheriv, createDecipheriv, hkdfSync, randomBytes } from 'node:crypto'
99
import { MessageBuilder } from '@poppinss/utils'
10-
import { BaseDriver } from './base_driver.js'
11-
import { Hmac } from '../hmac.js'
12-
import * as errors from '../exceptions.js'
13-
import type { AES256CBCConfig, CypherText, EncryptionDriverContract } from '../types/main.js'
14-
import { base64UrlDecode, base64UrlEncode } from '../base64.js'
10+
import { BaseDriver } from './base_driver.ts'
11+
import { Hmac } from '../hmac.ts'
12+
import * as errors from '../exceptions.ts'
13+
import type { AES256CBCConfig, CypherText, EncryptionDriverContract } from '../types/main.ts'
14+
import { base64UrlDecode, base64UrlEncode } from '../base64.ts'
1515

1616
export class AES256CBC extends BaseDriver implements EncryptionDriverContract {
1717
#config: AES256CBCConfig

src/drivers/aes_256_gcm.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto'
99
import { MessageBuilder } from '@poppinss/utils'
10-
import { BaseDriver } from './base_driver.js'
11-
import * as errors from '../exceptions.js'
12-
import { base64UrlDecode, base64UrlEncode } from '../base64.js'
13-
import type { AES256GCMConfig, CypherText, EncryptionDriverContract } from '../types/main.js'
10+
import { BaseDriver } from './base_driver.ts'
11+
import * as errors from '../exceptions.ts'
12+
import { base64UrlDecode, base64UrlEncode } from '../base64.ts'
13+
import type { AES256GCMConfig, CypherText, EncryptionDriverContract } from '../types/main.ts'
1414

1515
export class AES256GCM extends BaseDriver implements EncryptionDriverContract {
1616
#config: AES256GCMConfig

src/drivers/base_driver.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
*/
77

88
import { createHash } from 'node:crypto'
9-
import * as errors from '../exceptions.js'
10-
import { MessageVerifier } from '../message_verifier.js'
11-
import type { BaseConfig, CypherText } from '../types/main.js'
9+
import * as errors from '../exceptions.ts'
10+
import { MessageVerifier } from '../message_verifier.ts'
11+
import type { BaseConfig, CypherText } from '../types/main.ts'
1212

1313
export abstract class BaseDriver {
1414
/**
@@ -49,15 +49,19 @@ export abstract class BaseDriver {
4949
}
5050
}
5151

52-
computeReturns(values: string[]) {
52+
protected computeReturns(values: string[]) {
5353
return values.join(this.separator) as CypherText
5454
}
5555

56-
getFirstKey() {
56+
protected getFirstKey() {
5757
const [firstKey] = this.cryptoKeys
5858
return firstKey
5959
}
6060

61+
getMessageVerifier() {
62+
return this.getFirstKey().verifier
63+
}
64+
6165
/**
6266
* Encrypt a given piece of value using the app secret. A wide range of
6367
* data types are supported.

src/drivers/chacha20_poly1305.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto'
99
import { MessageBuilder } from '@poppinss/utils'
10-
import { BaseDriver } from './base_driver.js'
11-
import * as errors from '../exceptions.js'
12-
import type { ChaCha20Poly1305Config, CypherText, EncryptionDriverContract } from '../types/main.js'
13-
import { base64UrlDecode, base64UrlEncode } from '../base64.js'
10+
import { BaseDriver } from './base_driver.ts'
11+
import * as errors from '../exceptions.ts'
12+
import type { ChaCha20Poly1305Config, CypherText, EncryptionDriverContract } from '../types/main.ts'
13+
import { base64UrlDecode, base64UrlEncode } from '../base64.ts'
1414

1515
export class ChaCha20Poly1305 extends BaseDriver implements EncryptionDriverContract {
1616
#config: ChaCha20Poly1305Config

src/drivers/legacy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import { createCipheriv, createDecipheriv } from 'node:crypto'
99
import string from '@poppinss/utils/string'
1010
import { base64, MessageBuilder } from '@poppinss/utils'
11-
import { BaseDriver } from './base_driver.js'
12-
import { Hmac } from '../hmac.js'
13-
import type { EncryptionDriverContract, LegacyConfig } from '../types/main.js'
11+
import { BaseDriver } from './base_driver.ts'
12+
import { Hmac } from '../hmac.ts'
13+
import type { EncryptionDriverContract, LegacyConfig } from '../types/main.ts'
1414

1515
/**
1616
* This driver was mainly created to maintain compatibility

src/encryption_manager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
*/
77

88
import { RuntimeException } from '@poppinss/utils'
9-
import debug from './debug.js'
10-
import { MessageVerifier } from './message_verifier.js'
11-
import type { CypherText, EncryptionDriverContract, ManagerDriverFactory } from './types/main.js'
9+
import debug from './debug.ts'
10+
import { MessageVerifier } from './message_verifier.ts'
11+
import type { CypherText, EncryptionDriverContract, ManagerDriverFactory } from './types/main.ts'
1212

1313
export class EncryptionManager<KnownEncryptionDriver extends Record<string, ManagerDriverFactory>>
1414
implements EncryptionDriverContract

src/hmac.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77

88
import { createHmac } from 'node:crypto'
9-
import { safeEqual } from './safe_equal.js'
10-
import { base64UrlEncode } from './base64.js'
9+
import { safeEqual } from './safe_equal.ts'
10+
import { base64UrlEncode } from './base64.ts'
1111

1212
/**
1313
* A generic class for generating SHA-256 Hmac for verifying the value

src/message_verifier.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { createHash } from 'node:crypto'
99
import { base64, MessageBuilder, RuntimeException } from '@poppinss/utils'
10-
import { Hmac } from './hmac.js'
10+
import { Hmac } from './hmac.ts'
1111

1212
/**
1313
* Message verifier is similar to the encryption. However, the actual payload

0 commit comments

Comments
 (0)