volter 0.0.1 → 0.0.15
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.
- package/package.json +1 -1
- package/receive.ts +33 -0
- package/utils.ts +1 -1
package/package.json
CHANGED
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
|
@@ -10,8 +10,8 @@ export function createPIN(): string {
|
|
|
10
10
|
}
|
|
11
11
|
export const createID = cuid2.init({ length: 32 })
|
|
12
12
|
|
|
13
|
-
const hasher = new Bun.CryptoHasher("sha256")
|
|
14
13
|
export function hash(password: string): string {
|
|
14
|
+
const hasher = new Bun.CryptoHasher("sha256")
|
|
15
15
|
return hasher.update(password).digest("hex")
|
|
16
16
|
}
|
|
17
17
|
|