@jokio/sdk 0.1.4 → 0.1.6
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/README.md +7 -6
- package/dist/jokio.sdk.umd.js +1 -1
- package/package-lock.json +1062 -0
- package/package.json +1 -1
- package/src/auth.service.ts +2 -1
- package/dist/auth.service.d.ts +0 -21
- package/dist/common/playAudioFromBuffer.d.ts +0 -1
- package/dist/crypto.service.d.ts +0 -9
- package/dist/index.d.ts +0 -18
- package/dist/index.html +0 -106
- package/dist/jokio.sdk.es.js +0 -8526
- package/dist/nats.service.d.ts +0 -45
- package/dist/tts.service.d.ts +0 -13
- package/dist/voicevoxTts.d.ts +0 -11
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jokio/sdk",
|
|
3
3
|
"description": "pure js/ts sdk for building decentralised localfirst web apps. Provides tts ai model integrations, realtime p2p communication & crypto encryptions.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.6",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/jokio.sdk.umd.js",
|
|
7
7
|
"keywords": [
|
package/src/auth.service.ts
CHANGED
|
@@ -39,13 +39,14 @@ export class AuthService {
|
|
|
39
39
|
|
|
40
40
|
async requestPasskeyLogin(
|
|
41
41
|
displayName: string = '',
|
|
42
|
+
isRegistration: boolean = !!displayName,
|
|
42
43
|
addAsAdditionalDevice = false,
|
|
43
44
|
) {
|
|
44
45
|
// 1. get challenge options
|
|
45
46
|
const opts = await fetch(
|
|
46
47
|
this.config.authUrl +
|
|
47
48
|
`/webauth-challenge-request?registration=${
|
|
48
|
-
|
|
49
|
+
isRegistration ? 'true' : ''
|
|
49
50
|
}&displayName=${displayName}`,
|
|
50
51
|
{ credentials: 'include' },
|
|
51
52
|
).then(processResponse)
|
package/dist/auth.service.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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, addAsAdditionalDevice?: boolean): Promise<IdentityUser>;
|
|
10
|
-
guestSignIn(): Promise<IdentityUser>;
|
|
11
|
-
clearLoginData(): Promise<void>;
|
|
12
|
-
getLastLoginData(): any;
|
|
13
|
-
}
|
|
14
|
-
export type IdentityUser = {
|
|
15
|
-
name: string;
|
|
16
|
-
email: string;
|
|
17
|
-
userId: string;
|
|
18
|
-
sessionId: string;
|
|
19
|
-
verified: boolean;
|
|
20
|
-
};
|
|
21
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function playAudioFromBuffer(buffer: ArrayBuffer): HTMLAudioElement;
|
package/dist/crypto.service.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AuthService } from './auth.service';
|
|
2
|
-
import { CryptoService } from './crypto.service';
|
|
3
|
-
import { NatsService } from './nats.service';
|
|
4
|
-
import { EdgeTtsService } from './tts.service';
|
|
5
|
-
export { NatsService } from './nats.service';
|
|
6
|
-
export { VoicevoxTtsService } from './voicevoxTts';
|
|
7
|
-
type Config = {
|
|
8
|
-
debug: boolean;
|
|
9
|
-
authUrl: string;
|
|
10
|
-
natsUrl: string;
|
|
11
|
-
};
|
|
12
|
-
export declare const jok: {
|
|
13
|
-
setup(config: Partial<Config>): void;
|
|
14
|
-
auth: AuthService;
|
|
15
|
-
tts: EdgeTtsService;
|
|
16
|
-
nats: NatsService<unknown>;
|
|
17
|
-
crypto: CryptoService;
|
|
18
|
-
};
|
package/dist/index.html
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
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()">TTS</button>
|
|
13
|
-
<button onclick="playAudio2()">Voicevox TTS</button>
|
|
14
|
-
|
|
15
|
-
<script type="module">
|
|
16
|
-
// import { jok } from 'https://esm.run/@jokio/sdk';
|
|
17
|
-
import { jok, VoicevoxTtsService } from './dist/jokio.sdk.es.js';
|
|
18
|
-
|
|
19
|
-
window.jok = jok
|
|
20
|
-
|
|
21
|
-
window.getVoicevoxVoices = async function () {
|
|
22
|
-
const voices = await jok.voicevoxTts.getVoices()
|
|
23
|
-
|
|
24
|
-
console.log(voices)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
window.getVoices = async function () {
|
|
28
|
-
const voices = await jok.tts.getVoices()
|
|
29
|
-
|
|
30
|
-
console.log(voices)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
window.playAudio = async function () {
|
|
34
|
-
const audio = await jok.tts.getAudio("Hello there, how are you?", "en-US-AvaNeural")
|
|
35
|
-
|
|
36
|
-
audio.play()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
window.playAudio2 = async function () {
|
|
40
|
-
const tts = new VoicevoxTtsService({ voicevoxUrl: 'https://voicevox.fly.dev' })
|
|
41
|
-
|
|
42
|
-
const audio = await tts.getAudio("こんにちわ、おげんきですか?あなたはあたまがいいですね。", 3)
|
|
43
|
-
|
|
44
|
-
audio.play()
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
window.requestEmailLogin = async function (email) {
|
|
48
|
-
const res = await jok.auth.requestEmailLogin(email, 'https://localhost:5173')
|
|
49
|
-
|
|
50
|
-
return res
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
window.completeEmailLogin = async function (email, otpCode) {
|
|
54
|
-
const res = await jok.auth.completeEmailLogin(email, otpCode)
|
|
55
|
-
|
|
56
|
-
return res
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
window.passkeyLogin = async function (displayName) {
|
|
60
|
-
const res = await jok.auth.requestPasskeyLogin(displayName)
|
|
61
|
-
|
|
62
|
-
return res
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
window.natsConnect = async function () {
|
|
66
|
-
await jok.nats.connect()
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
window.natsSubscribe = async function () {
|
|
70
|
-
await jok.nats.on('dev.test', (data, ctx) => {
|
|
71
|
-
console.lg({ data, ctx })
|
|
72
|
-
})
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
window.natsPublish = async function () {
|
|
76
|
-
await jok.nats.publish('dev.test', { name: 'User', age: 11 })
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
window.p2pChat = async function () {
|
|
80
|
-
const kp1 = await jok.crypto.createSessionKeyPair()
|
|
81
|
-
const kp2 = await jok.crypto.createSessionKeyPair()
|
|
82
|
-
|
|
83
|
-
const p1 = await jok.crypto.exportPublicKey(kp1.publicKey)
|
|
84
|
-
const p2 = await jok.crypto.exportPublicKey(kp2.publicKey)
|
|
85
|
-
|
|
86
|
-
console.log({ p1, p2 })
|
|
87
|
-
|
|
88
|
-
const shared1 = await jok.crypto.deriveAESKey(kp1.privateKey, p2)
|
|
89
|
-
const shared2 = await jok.crypto.deriveAESKey(kp2.privateKey, p1)
|
|
90
|
-
|
|
91
|
-
const originalText = "Hello World"
|
|
92
|
-
|
|
93
|
-
const encrypted = await jok.crypto.encrypt(originalText, shared1)
|
|
94
|
-
const decrypted = await jok.crypto.decrypt(encrypted, shared2)
|
|
95
|
-
|
|
96
|
-
console.log({
|
|
97
|
-
match: originalText === decrypted,
|
|
98
|
-
originalText,
|
|
99
|
-
decrypted,
|
|
100
|
-
})
|
|
101
|
-
}
|
|
102
|
-
</script>
|
|
103
|
-
|
|
104
|
-
</body>
|
|
105
|
-
|
|
106
|
-
</html>
|