@sorisdk/web-audio 0.1.0 → 0.1.2

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/LICENSE.md ADDED
@@ -0,0 +1,50 @@
1
+ Software Use License Agreement
2
+
3
+ Copyright (c) iPlateia Inc. All rights reserved.
4
+
5
+ This Software Use License Agreement ("Agreement") is a binding agreement between iPlateia Inc. ("Company") and the person or entity that installs, accesses, or uses this package ("Licensee").
6
+
7
+ By installing, copying, accessing, or using the package, Licensee agrees to be bound by this Agreement. If Licensee does not agree, Licensee must not install, access, or use the package.
8
+
9
+ 1. Grant of License
10
+
11
+ Subject to Licensee's full compliance with this Agreement, the Company grants Licensee a limited, non-exclusive, non-transferable, non-sublicensable, revocable license to use the package in object code or compiled form solely for Licensee's internal business use or other use expressly authorized by the Company.
12
+
13
+ 2. Restrictions
14
+
15
+ Licensee must not, and must not permit any third party to:
16
+
17
+ - modify, adapt, translate, alter, or create derivative works of the package;
18
+ - reverse engineer, decompile, disassemble, decode, or otherwise attempt to derive the source code, underlying ideas, algorithms, file formats, or trade secrets of the package, except to the limited extent such restriction is prohibited by mandatory law;
19
+ - copy, publish, distribute, transmit, disclose, sublicense, assign, sell, rent, lease, lend, transfer, pledge, or otherwise make the package available to any third party;
20
+ - remove, obscure, or alter any copyright, trademark, confidentiality, or proprietary notice contained in the package;
21
+ - use the package in violation of applicable law, public policy, or the Company's usage conditions;
22
+ - use the package to disclose survey content, logs, technical information, or other service-related information to any third party.
23
+
24
+ 3. Ownership and Reservation of Rights
25
+
26
+ The package is licensed, not sold. The package, including all intellectual property rights in and to the package, remains the exclusive property of the Company and its licensors. No rights are granted except as expressly stated in this Agreement.
27
+
28
+ 4. Confidentiality
29
+
30
+ Any non-public information obtained through access to or use of the package, including technical materials, performance information, documentation, data formats, and service-related content, is confidential. Licensee must keep such information strictly confidential and must not disclose it to any third party without the Company's prior written consent.
31
+
32
+ 5. Changes, Suspension, and Termination
33
+
34
+ The Company may modify, suspend, restrict, or discontinue all or part of the package at any time if reasonably required for operational, technical, security, or business reasons. If Licensee breaches this Agreement, the Company may immediately suspend or terminate this Agreement and Licensee's right to use the package. Upon termination, Licensee must immediately stop using the package and delete all copies in Licensee's possession or control.
35
+
36
+ 6. Disclaimer
37
+
38
+ To the maximum extent permitted by law, the package is provided on an "as is" and "as available" basis without warranties of any kind, whether express, implied, statutory, or otherwise, including any implied warranties of merchantability, fitness for a particular purpose, title, non-infringement, accuracy, availability, or uninterrupted operation.
39
+
40
+ 7. Limitation of Liability
41
+
42
+ To the maximum extent permitted by law, the Company will not be liable for any indirect, incidental, special, consequential, exemplary, or punitive damages, or for any loss of profits, revenues, business, goodwill, data, or use, arising out of or related to this Agreement or the package, even if advised of the possibility of such damages.
43
+
44
+ 8. Governing Law
45
+
46
+ This Agreement is governed by the laws of the Republic of Korea, without regard to conflict of laws principles.
47
+
48
+ 9. Entire Agreement
49
+
50
+ This Agreement constitutes the entire agreement between Licensee and the Company regarding the package and supersedes all prior or contemporaneous understandings relating to the package.
package/README.md CHANGED
@@ -1,98 +1,83 @@
1
1
  # @sorisdk/web-audio
2
2
 
3
- Browser microphone capture and real-time matching SDK for NADA.
3
+ Web SDK for integrating SORI audio recognition into browser-based services.
4
4
 
5
- ## Purpose
5
+ This package provides the browser-side flow needed for web recognition, including authentication bootstrap, pack caching, microphone input, audio fingerprint generation, matching, and campaign events.
6
6
 
7
- This package owns browser-only concerns that do not belong in `@sorisdk/matcher`:
7
+ Public integration guide: https://docs.soriapi.com/ko/integration/web
8
8
 
9
- - microphone permission and `getUserMedia`
10
- - Web Audio graph setup
11
- - PCM chunk capture
12
- - rolling fingerprint generation with `@sorisdk/afpgen`
13
- - rolling query matching with `@sorisdk/matcher`
9
+ ## Requirements
14
10
 
15
- ## API
11
+ - A secure context such as `https://` or `http://localhost`
12
+ - A modern browser with `AudioContext` and `MediaDevices.getUserMedia()`
13
+ - An ephemeral key issued by your server
14
+ - Microphone permission granted by the user
16
15
 
17
- ```ts
18
- import { AudioRecognizer } from "@sorisdk/web-audio";
19
-
20
- const recognizer = new AudioRecognizer({
21
- appId: "app-1",
22
- ephemeralKeyEndpoint: "https://site.example.com/api/ephemeral-key"
23
- });
24
-
25
- recognizer.on("campaign", (event) => {
26
- console.log(event.campaign);
27
- });
16
+ ## Installation
28
17
 
29
- await recognizer.start();
30
- await recognizer.stop();
31
- await recognizer.destroy();
18
+ ```bash
19
+ npm install @sorisdk/web-audio
32
20
  ```
33
21
 
34
- By default, `AudioRecognizer` uses the SORI API prefix `https://console.soriapi.com/api`
35
- and derives:
36
-
37
- - auth: `/auth`
38
- - activity: `/activity/`
39
-
40
- So direct ephemeral key usage can be as small as:
22
+ Vite-based apps need `vite-plugin-wasm`.
41
23
 
42
24
  ```ts
43
- const recognizer = new AudioRecognizer({
44
- appId: "app-1",
45
- ephemeralKey: "ek-..."
46
- });
47
- ```
25
+ import wasm from "vite-plugin-wasm";
48
26
 
49
- ## Notes
27
+ export default {
28
+ plugins: [wasm()]
29
+ };
30
+ ```
50
31
 
51
- - This package is browser-only.
52
- - It uses `AudioWorkletNode` when available and falls back to `ScriptProcessorNode`.
53
- - Matching window size and matching-quality-sensitive runtime tuning stay internal to the SDK.
32
+ ## Minimal example
54
33
 
55
- ## Session Utility
34
+ ```ts
35
+ import { AudioRecognizer } from "@sorisdk/web-audio";
56
36
 
57
- When you need direct control over the browser session identifier, use the built-in
58
- session manager instead of handling `localStorage` yourself:
37
+ const recognizer = new AudioRecognizer({
38
+ appId: "YOUR_APP_ID",
39
+ ephemeralKey: async () => {
40
+ const response = await fetch("/api/ephemeral-key", {
41
+ method: "POST"
42
+ });
43
+
44
+ if (!response.ok) {
45
+ throw new Error(`Ephemeral key request failed: HTTP ${response.status}`);
46
+ }
47
+
48
+ const { ephemeral_key } = await response.json();
49
+ return ephemeral_key;
50
+ }
51
+ });
59
52
 
60
- ```ts
61
- import { createLocalStorageSessionManager } from "@sorisdk/web-audio";
53
+ recognizer.on("campaign", (event) => {
54
+ console.log(event.campaign);
55
+ });
62
56
 
63
- const sessions = createLocalStorageSessionManager({
64
- key: "sorisdk:web-audio:session:app-1"
57
+ recognizer.on("error", ({ error }) => {
58
+ console.error(error);
65
59
  });
66
60
 
67
- const sessionId = sessions.getSessionId();
61
+ await recognizer.start();
68
62
  ```
69
63
 
70
- ## Low-Level Auth Cache Helper
71
-
72
- When `/api/auth` requires a `v` value, the browser package can keep the last successful
73
- `version + packUrl` metadata in `localStorage` while leaving the actual audiopack bytes to
74
- the browser HTTP cache:
64
+ Call `stop()` or `destroy()` when recognition should end or when the page is being cleaned up.
75
65
 
76
66
  ```ts
77
- import {
78
- authenticateAndLoadAudioPack,
79
- createLocalStorageAudioPackStore
80
- } from "@sorisdk/web-audio";
67
+ await recognizer.stop();
68
+ await recognizer.destroy();
69
+ ```
81
70
 
82
- const store = createLocalStorageAudioPackStore({
83
- key: "sorisdk:matcher:app-1"
84
- });
71
+ ## Integration flow
85
72
 
86
- const result = await authenticateAndLoadAudioPack({
87
- loader: microphoneMatcher,
88
- auth: {
89
- endpoint: "https://console.example.com/api/auth",
90
- appId: "app-1",
91
- ephemeralKey: "ek-...",
92
- sessionId: "browser-device-1"
93
- },
94
- store
95
- });
73
+ 1. Prepare your `appId` and ephemeral key flow.
74
+ 2. Create an `AudioRecognizer`.
75
+ 3. Subscribe to the events you need, such as `campaign`, `match`, and `error`.
76
+ 4. Call `start()` to begin recognition.
77
+ 5. Call `stop()` or `destroy()` when leaving the page or stopping capture.
96
78
 
97
- console.log(result.token, result.loadedPackUrl, result.persistedVersion);
98
- ```
79
+ ## Recommendations
80
+
81
+ - Do not hardcode ephemeral keys in the browser. Issue them from your server.
82
+ - Show clear UI while the microphone is active.
83
+ - Use the public documentation for full setup details and caveats.
@@ -51,11 +51,11 @@ export class WasmFingerprintMatchWindow {
51
51
  }
52
52
  }
53
53
  if (Symbol.dispose) WasmFingerprintMatchWindow.prototype[Symbol.dispose] = WasmFingerprintMatchWindow.prototype.free;
54
- export function __wbg_Error_83742b46f01ce22d(arg0, arg1) {
54
+ export function __wbg_Error_2e59b1b37a9a34c3(arg0, arg1) {
55
55
  const ret = Error(getStringFromWasm0(arg0, arg1));
56
56
  return ret;
57
57
  }
58
- export function __wbg_Number_a5a435bd7bbec835(arg0) {
58
+ export function __wbg_Number_e6ffdb596c888833(arg0) {
59
59
  const ret = Number(arg0);
60
60
  return ret;
61
61
  }
@@ -66,46 +66,46 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
66
66
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
67
67
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
68
68
  }
69
- export function __wbg___wbindgen_boolean_get_c0f3f60bac5a78d1(arg0) {
69
+ export function __wbg___wbindgen_boolean_get_a86c216575a75c30(arg0) {
70
70
  const v = arg0;
71
71
  const ret = typeof(v) === 'boolean' ? v : undefined;
72
72
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
73
73
  }
74
- export function __wbg___wbindgen_debug_string_5398f5bb970e0daa(arg0, arg1) {
74
+ export function __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57(arg0, arg1) {
75
75
  const ret = debugString(arg1);
76
76
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
77
77
  const len1 = WASM_VECTOR_LEN;
78
78
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
79
79
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
80
80
  }
81
- export function __wbg___wbindgen_in_41dbb8413020e076(arg0, arg1) {
81
+ export function __wbg___wbindgen_in_4bd7a57e54337366(arg0, arg1) {
82
82
  const ret = arg0 in arg1;
83
83
  return ret;
84
84
  }
85
- export function __wbg___wbindgen_is_null_0b605fc6b167c56f(arg0) {
85
+ export function __wbg___wbindgen_is_null_344c8750a8525473(arg0) {
86
86
  const ret = arg0 === null;
87
87
  return ret;
88
88
  }
89
- export function __wbg___wbindgen_is_object_781bc9f159099513(arg0) {
89
+ export function __wbg___wbindgen_is_object_40c5a80572e8f9d3(arg0) {
90
90
  const val = arg0;
91
91
  const ret = typeof(val) === 'object' && val !== null;
92
92
  return ret;
93
93
  }
94
- export function __wbg___wbindgen_is_undefined_52709e72fb9f179c(arg0) {
94
+ export function __wbg___wbindgen_is_undefined_c0cca72b82b86f4d(arg0) {
95
95
  const ret = arg0 === undefined;
96
96
  return ret;
97
97
  }
98
- export function __wbg___wbindgen_jsval_loose_eq_5bcc3bed3c69e72b(arg0, arg1) {
98
+ export function __wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944(arg0, arg1) {
99
99
  const ret = arg0 == arg1;
100
100
  return ret;
101
101
  }
102
- export function __wbg___wbindgen_number_get_34bb9d9dcfa21373(arg0, arg1) {
102
+ export function __wbg___wbindgen_number_get_7579aab02a8a620c(arg0, arg1) {
103
103
  const obj = arg1;
104
104
  const ret = typeof(obj) === 'number' ? obj : undefined;
105
105
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
106
106
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
107
107
  }
108
- export function __wbg___wbindgen_string_get_395e606bd0ee4427(arg0, arg1) {
108
+ export function __wbg___wbindgen_string_get_914df97fcfa788f2(arg0, arg1) {
109
109
  const obj = arg1;
110
110
  const ret = typeof(obj) === 'string' ? obj : undefined;
111
111
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -113,14 +113,14 @@ export function __wbg___wbindgen_string_get_395e606bd0ee4427(arg0, arg1) {
113
113
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
114
114
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
115
115
  }
116
- export function __wbg___wbindgen_throw_6ddd609b62940d55(arg0, arg1) {
116
+ export function __wbg___wbindgen_throw_81fc77679af83bc6(arg0, arg1) {
117
117
  throw new Error(getStringFromWasm0(arg0, arg1));
118
118
  }
119
119
  export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
120
120
  const ret = arg0[arg1];
121
121
  return ret;
122
122
  }
123
- export function __wbg_instanceof_ArrayBuffer_101e2bf31071a9f6(arg0) {
123
+ export function __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a(arg0) {
124
124
  let result;
125
125
  try {
126
126
  result = arg0 instanceof ArrayBuffer;
@@ -130,7 +130,7 @@ export function __wbg_instanceof_ArrayBuffer_101e2bf31071a9f6(arg0) {
130
130
  const ret = result;
131
131
  return ret;
132
132
  }
133
- export function __wbg_instanceof_Uint8Array_740438561a5b956d(arg0) {
133
+ export function __wbg_instanceof_Uint8Array_4b8da683deb25d72(arg0) {
134
134
  let result;
135
135
  try {
136
136
  result = arg0 instanceof Uint8Array;
@@ -140,23 +140,23 @@ export function __wbg_instanceof_Uint8Array_740438561a5b956d(arg0) {
140
140
  const ret = result;
141
141
  return ret;
142
142
  }
143
- export function __wbg_isSafeInteger_ecd6a7f9c3e053cd(arg0) {
143
+ export function __wbg_isSafeInteger_ea83862ba994770c(arg0) {
144
144
  const ret = Number.isSafeInteger(arg0);
145
145
  return ret;
146
146
  }
147
- export function __wbg_length_ea16607d7b61445b(arg0) {
147
+ export function __wbg_length_0c32cb8543c8e4c8(arg0) {
148
148
  const ret = arg0.length;
149
149
  return ret;
150
150
  }
151
- export function __wbg_new_5f486cdf45a04d78(arg0) {
151
+ export function __wbg_new_a560378ea1240b14(arg0) {
152
152
  const ret = new Uint8Array(arg0);
153
153
  return ret;
154
154
  }
155
- export function __wbg_new_from_slice_22da9388ac046e50(arg0, arg1) {
155
+ export function __wbg_new_from_slice_2580ff33d0d10520(arg0, arg1) {
156
156
  const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
157
157
  return ret;
158
158
  }
159
- export function __wbg_prototypesetcall_d62e5099504357e6(arg0, arg1, arg2) {
159
+ export function __wbg_prototypesetcall_3e05eb9545565046(arg0, arg1, arg2) {
160
160
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
161
161
  }
162
162
  export function __wbindgen_cast_0000000000000001(arg0, arg1) {
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sorisdk/web-audio",
3
- "version": "0.1.0",
4
- "description": "Browser microphone capture and real-time matching SDK for NADA",
3
+ "version": "0.1.2",
4
+ "description": "Web SDK for browser-based audio recognition with SORI API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -31,19 +31,11 @@
31
31
  "matcher"
32
32
  ],
33
33
  "author": "comfuture",
34
- "license": "MIT",
35
- "repository": {
36
- "type": "git",
37
- "url": "git+https://github.com/iplateia/nada.git",
38
- "directory": "packages/web-audio"
39
- },
40
- "homepage": "https://github.com/iplateia/nada/tree/main/packages/web-audio",
41
- "bugs": {
42
- "url": "https://github.com/iplateia/nada/issues"
43
- },
34
+ "license": "SEE LICENSE IN LICENSE.md",
35
+ "homepage": "https://docs.soriapi.com/ko/integration/web",
44
36
  "dependencies": {
45
- "@sorisdk/afpgen": "0.1.0",
46
- "@sorisdk/matcher": "0.1.0"
37
+ "@sorisdk/afpgen": "0.1.2",
38
+ "@sorisdk/matcher": "0.1.2"
47
39
  },
48
40
  "devDependencies": {
49
41
  "tsup": "^8.5.1",