@jokio/sdk 0.0.1

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/.prettierrc ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "singleQuote": true,
3
+ "tabWidth": 2,
4
+ "useTabs": false,
5
+ "endOfLine": "auto",
6
+ "semi": false,
7
+ "printWidth": 70,
8
+ "arrowParens": "avoid",
9
+ "bracketSpacing": true,
10
+ "quoteProps": "as-needed",
11
+ "trailingComma": "all"
12
+ }
@@ -0,0 +1,19 @@
1
+ type Config = {
2
+ authUrl: string;
3
+ };
4
+ export declare class AuthService {
5
+ private config;
6
+ constructor(config: Config);
7
+ requestEmailLogin(email: string, returnUrl: string): Promise<boolean>;
8
+ completeEmailLogin(email: string, otpCode: string): Promise<IdentityUser>;
9
+ requestPasskeyLogin(displayName?: string, isRegistration?: boolean, addAsAdditionalDevice?: boolean): Promise<IdentityUser>;
10
+ signOut(): Promise<IdentityUser>;
11
+ }
12
+ export type IdentityUser = {
13
+ name: string;
14
+ email: string;
15
+ userId: string;
16
+ sessionId: string;
17
+ verified: boolean;
18
+ };
19
+ export {};
@@ -0,0 +1 @@
1
+ export declare function playAudioFromBuffer(buffer: ArrayBuffer): HTMLAudioElement;
@@ -0,0 +1,9 @@
1
+ export declare class CryptoService {
2
+ createSessionKeyPair(): Promise<CryptoKeyPair>;
3
+ exportPublicKey(publicKey: CryptoKey): Promise<string>;
4
+ deriveAESKey(privateKey: CryptoKey, publicKeyString: string): Promise<CryptoKey>;
5
+ exportRawKey(key: CryptoKey): Promise<string>;
6
+ encrypt(text: string, key: CryptoKey): Promise<string>;
7
+ decrypt(encryptedText: string, key: CryptoKey): Promise<string>;
8
+ hashString(text: string): Promise<string>;
9
+ }
@@ -0,0 +1,13 @@
1
+ export declare class EdgeTtsService {
2
+ getAudioBuffer(text: string, voice: string, options?: {
3
+ pitch?: string;
4
+ rate?: string;
5
+ volume?: string;
6
+ }): Promise<ArrayBuffer>;
7
+ getAudio(text: string, voice: string, options?: {
8
+ pitch?: string;
9
+ rate?: string;
10
+ volume?: string;
11
+ }): Promise<HTMLAudioElement>;
12
+ getVoices(): Promise<any[]>;
13
+ }
@@ -0,0 +1,19 @@
1
+ import { AuthService } from './auth.service';
2
+ import { CryptoService } from './crypto.service';
3
+ import { EdgeTtsService } from './edgeTts.service';
4
+ import { NatsService } from './nats.service';
5
+ import { VoicevoxTtsService } from './tts.service';
6
+ export { NatsService } from './nats.service';
7
+ type Config = {
8
+ debug: boolean;
9
+ authUrl: string;
10
+ voicevoxUrl: string;
11
+ };
12
+ export declare const jok: {
13
+ setup(config: Partial<Config>): void;
14
+ auth: AuthService;
15
+ edgeTts: EdgeTtsService;
16
+ voicevoxTts: VoicevoxTtsService;
17
+ nats: NatsService<unknown>;
18
+ crypto: CryptoService;
19
+ };
@@ -0,0 +1,63 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <title>MyLibrary Test</title>
7
+ </head>
8
+
9
+ <body>
10
+ <h1>Library Test</h1>
11
+
12
+ <button onclick="playAudio()">Edge TTS</button>
13
+
14
+ <button onclick="playAudio2()">Voicevox TTS</button>
15
+
16
+ <script type="module">
17
+ import { jok } from './dist/jokio.sdk.es.js';
18
+ window.jok = jok
19
+ // jok.voicevoxTts.getVoices().then(console.log)
20
+ // document.body.innerHTML += `<p>${}</p>`;
21
+
22
+ window.playAudio = async function () {
23
+ const audio = await jok.edgeTts.getAudio("Hello there, how are you?", "en-US-AvaNeural")
24
+
25
+ audio.play()
26
+ }
27
+
28
+
29
+ window.playAudio2 = async function () {
30
+ const audio = await jok.voicevoxTts.getAudio("こんにちわ、おげんきですか?あなたはあたまがいいですね。", 3)
31
+
32
+ audio.play()
33
+ }
34
+
35
+
36
+ window.p2pChat = async function () {
37
+ const k1 = await jok.crypto.createSessionKeyPair()
38
+ const k2 = await jok.crypto.createSessionKeyPair()
39
+
40
+ const p1 = await jok.crypto.exportPublicKey(k1.publicKey)
41
+ const p2 = await jok.crypto.exportPublicKey(k2.publicKey)
42
+
43
+ console.log({ p1, p2 })
44
+
45
+ const shared1 = await jok.crypto.deriveAESKey(k1.privateKey, p2)
46
+ const shared2 = await jok.crypto.deriveAESKey(k2.privateKey, p1)
47
+
48
+ const originalText = "Hello World"
49
+
50
+ const encrypted = await jok.crypto.encrypt(originalText, shared1)
51
+ const decrypted = await jok.crypto.decrypt(encrypted, shared2)
52
+
53
+ console.log({
54
+ match: originalText === decrypted,
55
+ originalText,
56
+ decrypted,
57
+ })
58
+ }
59
+ </script>
60
+
61
+ </body>
62
+
63
+ </html>