volter 0.0.1 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/receive.ts +33 -0
  3. package/utils.ts +10 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volter",
3
- "version": "0.0.1",
3
+ "version": "0.0.16",
4
4
  "description": "Secure, lightweight, and user-friendly modern JavaScript toolchain optimized for performance and minimalism.",
5
5
  "main": "index.ts",
6
6
  "module": "index.ts",
package/receive.ts ADDED
@@ -0,0 +1,33 @@
1
+ export interface Email {
2
+ from: string
3
+ to: string[]
4
+ subject: string
5
+ bcc?: string[]
6
+ cc?: string[]
7
+ scheduled_at?: Date
8
+ reply_to?: string[]
9
+ html?: string
10
+ text?: string
11
+ tags?: {
12
+ name: string
13
+ value: string
14
+ }[]
15
+ created_at: Date
16
+ }
17
+
18
+ export class Receive {
19
+ constructor(key?: string) {
20
+ this.key = key
21
+ }
22
+ key?: string
23
+ emails(listener: (email: Email) => void) {
24
+ const ws = new WebSocket("wss://mail.modlin.dev:84/emails", {
25
+ headers: {
26
+ authorization: this.key ? `Basic ${this.key}` : undefined,
27
+ },
28
+ })
29
+ ws.onmessage = ev => listener(JSON.parse(ev.data))
30
+ }
31
+ }
32
+
33
+ export default Receive
package/utils.ts CHANGED
@@ -2,6 +2,15 @@ import { privateDecrypt, publicEncrypt, randomInt } from "node:crypto"
2
2
  import os from "node:os"
3
3
  import chalk from "chalk"
4
4
  import cuid2 from "@paralleldrive/cuid2"
5
+ import { generateKeyPairSync } from "node:crypto"
6
+ import z from "zod"
7
+ import type { SocketAddress } from "node:net"
8
+
9
+ declare global {
10
+ interface Request {
11
+ ip: SocketAddress
12
+ }
13
+ }
5
14
 
6
15
  export const pin = z.string().min(6).max(6).regex(/\d{6}/)
7
16
 
@@ -10,8 +19,8 @@ export function createPIN(): string {
10
19
  }
11
20
  export const createID = cuid2.init({ length: 32 })
12
21
 
13
- const hasher = new Bun.CryptoHasher("sha256")
14
22
  export function hash(password: string): string {
23
+ const hasher = new Bun.CryptoHasher("sha256")
15
24
  return hasher.update(password).digest("hex")
16
25
  }
17
26
 
@@ -102,9 +111,6 @@ export function listAdapters(): Adapter[] {
102
111
  return results
103
112
  }
104
113
 
105
- import { generateKeyPairSync } from "node:crypto"
106
- import z from "zod"
107
-
108
114
  type KeyPair = {
109
115
  public: string
110
116
  private: string