@cocreate/api 1.25.0 → 1.27.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.
@@ -9,33 +9,36 @@ jobs:
9
9
  about:
10
10
  runs-on: ubuntu-latest
11
11
  steps:
12
- - name: Checkout
13
- uses: actions/checkout@v3
14
- - name: Setup Node.js
15
- uses: actions/setup-node@v3
16
- with:
17
- node-version: 16
18
- - name: Jaid/action-sync-node-meta
19
- uses: jaid/action-sync-node-meta@v1.4.0
20
- with:
21
- direction: overwrite-github
22
- githubToken: "${{ secrets.GITHUB }}"
12
+ - name: Checkout repository
13
+ uses: actions/checkout@v7
14
+
15
+ - name: Sync package.json description to GitHub About
16
+ env:
17
+ GITHUB_TOKEN: ${{ secrets.GITHUB }}
18
+ run: |
19
+ DESC=$(jq -r '.description // empty' package.json)
20
+ if [ -n "$DESC" ]; then
21
+ echo "Updating repository description to: $DESC"
22
+ gh api -X PATCH repos/${{ github.repository }} -f description="$DESC"
23
+ else
24
+ echo "No description found in package.json."
25
+ fi
23
26
 
24
27
  release:
25
28
  runs-on: ubuntu-latest
26
29
  steps:
27
- - name: Checkout
28
- uses: actions/checkout@v4
30
+ - name: Checkout repository
31
+ uses: actions/checkout@v7
29
32
  with:
30
- fetch-depth: 0 # Required so semantic-release can trace git tags/history
33
+ fetch-depth: 0
34
+ token: ${{ secrets.GITHUB }} # Authenticates git CLI for tag/commit pushes
31
35
 
32
36
  - name: Setup Node.js
33
- uses: actions/setup-node@v4
37
+ uses: actions/setup-node@v7
34
38
  with:
35
- node-version: 22
39
+ node-version: '24'
36
40
 
37
41
  - name: Install Semantic Release & Plugins
38
- # Installs semantic-release and its plugins on the runner
39
42
  run: |
40
43
  npm install -g semantic-release \
41
44
  @semantic-release/changelog \
@@ -43,12 +46,11 @@ jobs:
43
46
  @semantic-release/github \
44
47
  @semantic-release/git
45
48
 
46
- - name: Run Semantic Release (Native)
49
+ - name: Run Semantic Release
47
50
  id: semantic
48
- # This will automatically pick up your export default config file in the repository root
49
51
  run: npx semantic-release
50
52
  env:
51
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
53
+ GITHUB_TOKEN: "${{ secrets.GITHUB }}"
52
54
  NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
53
55
 
54
56
  outputs:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/api",
3
- "version": "1.25.0",
3
+ "version": "1.27.0",
4
4
  "description": "A secure, multi-tenant API execution gateway and proxy layer that dynamically resolves endpoint actions, processes AST micro-operators, handles webhooks, and manages third-party integrations with strict tenant environment isolation.",
5
5
  "keywords": [
6
6
  "api-orchestration",
@@ -51,15 +51,15 @@
51
51
  }
52
52
  },
53
53
  "dependencies": {
54
- "@cocreate/actions": "^1.22.3",
55
- "@cocreate/crud-client": "^1.35.2",
56
- "@cocreate/element-prototype": "^1.33.2",
57
- "@cocreate/render": "^1.48.2",
58
- "@cocreate/socket-client": "^1.41.2",
59
- "@cocreate/utils": "^1.44.3"
54
+ "@cocreate/actions": "^1.23.0",
55
+ "@cocreate/crud-client": "^1.36.0",
56
+ "@cocreate/element-prototype": "^1.34.0",
57
+ "@cocreate/render": "^1.49.0",
58
+ "@cocreate/socket-client": "^1.42.0",
59
+ "@cocreate/utils": "^1.46.0"
60
60
  },
61
61
  "devDependencies": {
62
- "@cocreate/webpack": "^1.6.2"
62
+ "@cocreate/webpack": "^1.7.0"
63
63
  },
64
64
  "allowScripts": {
65
65
  "@cocreate/actions@1.21.4": true,
package/src/server.js CHANGED
@@ -21,9 +21,8 @@
21
21
  // you must obtain a commercial license from CoCreate LLC.
22
22
  // For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app.
23
23
 
24
- import crypto from 'node:crypto';
25
24
  import { URL } from 'node:url';
26
- import { getValueFromObject, objectToSearchParams, astAsync } from '@cocreate/utils';
25
+ import { getValueFromObject, objectToSearchParams, astAsync, generateJWT, verifySignature, buildAuthHeaders } from '@cocreate/utils';
27
26
 
28
27
  // Core module references bound dynamically upon initialization
29
28
  let server = null;
@@ -162,9 +161,9 @@ function createSandbox(context) {
162
161
  }
163
162
  },
164
163
  jwt: (args) => {
165
- const privateKey = args?.privateKey;
164
+ const privateKey = args?.privateKey || args?.secret;
166
165
  if (!privateKey) throw new Error("Missing cryptographic signing key inside $jwt context parameters");
167
- return generateJWT(args, privateKey);
166
+ return generateJWT(args, privateKey, args.alg || 'HS256');
168
167
  }
169
168
  };
170
169
 
@@ -449,52 +448,8 @@ export async function request(req, res) {
449
448
  }
450
449
  }
451
450
 
452
- export function generateJWT(config, secret) {
453
- try {
454
- const header = config.header || { alg: 'HS256', typ: 'JWT' };
455
- const payload = config.payload || {};
456
-
457
- const encodedHeader = Buffer.from(JSON.stringify(header)).toString('base64url');
458
- const encodedPayload = Buffer.from(JSON.stringify(payload)).toString('base64url');
459
-
460
- const signatureInput = `${encodedHeader}.${encodedPayload}`;
461
-
462
- const hmac = crypto.createHmac('sha256', secret);
463
- hmac.update(signatureInput);
464
- const signature = hmac.digest('base64url');
465
-
466
- return `${signatureInput}.${signature}`;
467
- } catch (err) {
468
- console.error('[@cocreate/api] Failed to generate JWT:', err);
469
- throw err;
470
- }
471
- }
472
-
473
- export function verifySignature(payload, signature, secret, algorithm = 'sha256') {
474
- try {
475
- if (!payload || !signature || !secret) return false;
476
-
477
- const hmac = crypto.createHmac(algorithm, secret);
478
- hmac.update(payload);
479
-
480
- const expectedSignature = hmac.digest();
481
- let receivedSignature = Buffer.isBuffer(signature) ? signature : Buffer.from(signature, 'hex');
482
-
483
- if (receivedSignature.length !== expectedSignature.length) {
484
- receivedSignature = Buffer.from(signature, 'base64');
485
- }
486
-
487
- if (receivedSignature.length !== expectedSignature.length) {
488
- console.warn('[@cocreate/api] Signature verification rejected immediately due to byte-length mismatch.');
489
- return false;
490
- }
491
-
492
- return crypto.timingSafeEqual(expectedSignature, receivedSignature);
493
- } catch (err) {
494
- console.error('[@cocreate/api] Failed signature verification:', err.message);
495
- return false;
496
- }
497
- }
451
+ // Unified re-exports from security helper module to prevent duplicate function definitions
452
+ export { generateJWT, verifySignature, buildAuthHeaders };
498
453
 
499
454
  export async function makeHttpRequest(url, options) {
500
455
  let controller, timeoutId;