@sorisdk/web-audio 0.6.1 → 0.6.3
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 +90 -1
- package/dist/generated/window_bg.wasm +0 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -13,7 +13,96 @@ Public integration guide: https://docs.soriapi.com/ko/integration/web
|
|
|
13
13
|
- An ephemeral key issued by your server
|
|
14
14
|
- Microphone permission granted by the user
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## Standalone CDN
|
|
17
|
+
|
|
18
|
+
For a browser application that does not use npm or a bundler, import the
|
|
19
|
+
versioned standalone module directly. No package installation, Vite/webpack
|
|
20
|
+
configuration, or Node-based asset server is required:
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<script type="module">
|
|
24
|
+
import { AudioRecognizer } from
|
|
25
|
+
"https://cdn.iplateia.com/web/sorisdk/v0.6.3/sori-web-audio.mjs";
|
|
26
|
+
|
|
27
|
+
const recognizer = new AudioRecognizer({
|
|
28
|
+
appId: "YOUR_APP_ID",
|
|
29
|
+
ephemeralKey: async () => {
|
|
30
|
+
const response = await fetch("/api/ephemeral-key", {
|
|
31
|
+
method: "POST"
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
throw new Error(`Ephemeral key request failed: HTTP ${response.status}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const { ephemeral_key } = await response.json();
|
|
39
|
+
return ephemeral_key;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
recognizer.on("campaign", (event) => {
|
|
44
|
+
console.log(event.campaign);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
await recognizer.start();
|
|
48
|
+
</script>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Static URL imports are valid inside `<script type="module">`. Dynamic
|
|
52
|
+
`await import("https://cdn.iplateia.com/web/sorisdk/v0.6.3/sori-web-audio.mjs")`
|
|
53
|
+
is an optional alternative when the SDK should be loaded conditionally.
|
|
54
|
+
|
|
55
|
+
Pin an exact version in production. Do not construct a mutable `latest` URL.
|
|
56
|
+
The module loads its versioned WASM assets and the shared
|
|
57
|
+
`https://cdn.iplateia.com/web/sorisdk/model.pack` automatically.
|
|
58
|
+
|
|
59
|
+
The standalone module removes the frontend build/server requirement, but it
|
|
60
|
+
does not remove the trusted server requirement for ephemeral credentials.
|
|
61
|
+
Provide a backend or serverless endpoint for the `ephemeralKey` callback, and
|
|
62
|
+
never place a long-lived application secret in browser code.
|
|
63
|
+
|
|
64
|
+
The application operator is responsible for protecting that endpoint with the
|
|
65
|
+
authentication or anonymous-user verification appropriate to the product,
|
|
66
|
+
plus per-user/IP/session rate limits, issuance quotas, and abuse monitoring. A
|
|
67
|
+
public endpoint that returns a reusable key to every POST request can let an
|
|
68
|
+
anonymous caller consume recognition quota. CORS is required when the endpoint
|
|
69
|
+
is on a different origin, but CORS is not authentication and does not stop
|
|
70
|
+
scripts, bots, or non-browser clients from calling the endpoint.
|
|
71
|
+
|
|
72
|
+
Production billing and abuse protection must also rely on server-enforced key
|
|
73
|
+
expiry, app/session scope, revocation, and usage quotas. Do not treat the word
|
|
74
|
+
“ephemeral” or secrecy of a browser-visible key as the security boundary.
|
|
75
|
+
|
|
76
|
+
For a strict Content Security Policy, allow WebAssembly compilation with
|
|
77
|
+
`'wasm-unsafe-eval'`, allow `https://cdn.iplateia.com` in `script-src` and
|
|
78
|
+
`connect-src`, and add the SORI API plus ephemeral-key endpoint origins to
|
|
79
|
+
`connect-src`. For example:
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
script-src 'self' 'wasm-unsafe-eval' https://cdn.iplateia.com;
|
|
83
|
+
connect-src 'self' https://cdn.iplateia.com https://console.soriapi.com;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
If the module script is inline as in the example above, authorize that script
|
|
87
|
+
with a nonce or hash (or move it into an allowed external script) instead of
|
|
88
|
+
adding `'unsafe-inline'`.
|
|
89
|
+
|
|
90
|
+
An import map can give the standalone URL the npm package name:
|
|
91
|
+
|
|
92
|
+
```html
|
|
93
|
+
<script type="importmap">
|
|
94
|
+
{
|
|
95
|
+
"imports": {
|
|
96
|
+
"@sorisdk/web-audio": "https://cdn.iplateia.com/web/sorisdk/v0.6.3/sori-web-audio.mjs"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
</script>
|
|
100
|
+
<script type="module">
|
|
101
|
+
import { AudioRecognizer } from "@sorisdk/web-audio";
|
|
102
|
+
</script>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## npm installation
|
|
17
106
|
|
|
18
107
|
```bash
|
|
19
108
|
npm install @sorisdk/web-audio
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sorisdk/web-audio",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Web SDK for browser-based audio recognition with SORI API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
35
35
|
"homepage": "https://docs.soriapi.com/ko/integration/web",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@sorisdk/
|
|
38
|
-
"@sorisdk/
|
|
37
|
+
"@sorisdk/matcher": "0.6.3",
|
|
38
|
+
"@sorisdk/afpgen": "0.6.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"tsup": "^8.5.1",
|
|
@@ -45,6 +45,8 @@
|
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build:wasm": "node ../../scripts/build-wasm-package.mjs web-audio",
|
|
47
47
|
"build": "tsup src/index.ts --format esm --dts && pnpm run build:wasm && node ../../scripts/write-default-loader.mjs packages/web-audio ./generated/window.js",
|
|
48
|
+
"build:standalone": "pnpm --dir ../afpgen build && pnpm --dir ../matcher build && pnpm run build && vite build --config vite.standalone.config.ts && node ../../scripts/write-standalone-manifest.mjs && node ../../scripts/check-standalone-distribution.mjs",
|
|
49
|
+
"check:standalone": "node ../../scripts/check-standalone-distribution.mjs",
|
|
48
50
|
"test": "vitest run",
|
|
49
51
|
"test:watch": "vitest"
|
|
50
52
|
}
|