@ariacompute/engine-rn 1.19.2 → 1.20.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/setup.js +28 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariacompute/engine-rn",
3
- "version": "1.19.2",
3
+ "version": "1.20.0",
4
4
  "description": "React Native binding for Aria Engine",
5
5
  "main": "src/index.js",
6
6
  "license": "MIT",
package/src/setup.js CHANGED
@@ -7,8 +7,13 @@ const CN_UPGRADE = 'https://gitee.com/ariacompute';
7
7
 
8
8
  function defaultSetupConfig() {
9
9
  return {
10
+ // Local (router registration)
10
11
  router: '',
11
12
  router_api_key: '',
13
+ // OAuth (Aria Compute)
14
+ serve_site: '',
15
+ serve_api_key: '',
16
+ // Hub / compute
12
17
  site_url: '',
13
18
  upgrade_url: '',
14
19
  compute: 'auto',
@@ -38,6 +43,27 @@ function fillSetupUrls(cfg) {
38
43
  return out;
39
44
  }
40
45
 
46
+ function validateRouterApiKey(key) {
47
+ const t = (key || '').trim();
48
+ if (!t) return;
49
+ if (t.startsWith('bfvk-')) {
50
+ throw new Error(
51
+ 'OAuth key detected (bfvk-); use serve_api_key / [2/2] OAuth (Aria Compute)',
52
+ );
53
+ }
54
+ }
55
+
56
+ function validateServeApiKey(key) {
57
+ const t = (key || '').trim();
58
+ if (!t) return;
59
+ if (t.startsWith('sk-aria_')) {
60
+ throw new Error('Local router key detected (sk-aria_); use router_api_key / [1/2] Local');
61
+ }
62
+ if (!t.startsWith('bfvk-')) {
63
+ throw new Error('serve_api_key must start with bfvk-');
64
+ }
65
+ }
66
+
41
67
  function applySetup(existing, updates) {
42
68
  const out = { ...existing };
43
69
  for (const [k, v] of Object.entries(updates || {})) {
@@ -47,6 +73,8 @@ function applySetup(existing, updates) {
47
73
  if (!['auto', 'cpu', 'cuda'].includes(out.compute)) {
48
74
  throw new Error(`invalid compute: ${out.compute}`);
49
75
  }
76
+ validateRouterApiKey(out.router_api_key);
77
+ validateServeApiKey(out.serve_api_key);
50
78
  return fillSetupUrls(out);
51
79
  }
52
80