node-osc 9.0.0 → 9.0.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.
@@ -33,7 +33,7 @@ jobs:
33
33
  # run that runs on: tag. (Using the GitHub token would
34
34
  # not run the workflow to prevent infinite recursion.)
35
35
  - name: Check out source
36
- uses: actions/checkout@v2
36
+ uses: actions/checkout@v3
37
37
  with:
38
38
  ssh-key: ${{ secrets.DEPLOY_KEY }}
39
39
 
@@ -54,7 +54,7 @@ jobs:
54
54
  git config user.signingKey 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFtQmrz647zOGumjiqGirj1G9brj/QbwJQ5S3gHRmcfl myles.borins@gmail.com'
55
55
 
56
56
  - name: bump version
57
- run: npm version ${{ github.event.inputs.version }}
57
+ run: npm version ${{ github.event.inputs.version }} --sign-git-tag
58
58
 
59
59
  - name: Push latest version
60
60
  run: git push origin main --follow-tags
@@ -2,7 +2,7 @@
2
2
 
3
3
  var node_dgram = require('node:dgram');
4
4
  var node_events = require('node:events');
5
- var decode = require('./internal/decode.js');
5
+ var decode = require('#decode');
6
6
 
7
7
  class Server extends node_events.EventEmitter {
8
8
  constructor(port, host='127.0.0.1', cb) {
@@ -27,6 +27,9 @@ function decode(data) {
27
27
  else if (decoded.oscType === 'message') {
28
28
  return sanitizeMessage(decoded);
29
29
  }
30
+ else {
31
+ throw new Error ('Malformed Packet');
32
+ }
30
33
  }
31
34
 
32
35
  module.exports = decode;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var tap = require('tap');
4
- var decode = require('../lib/internal/decode.js');
4
+ var decode = require('#decode');
5
5
 
6
6
  tap.test('decode: valid', (t) => {
7
7
  const buf = Buffer.from('/test\0\0\0,s\0,testing\0');
@@ -15,6 +15,14 @@ tap.test('decode: valid', (t) => {
15
15
  t.end();
16
16
  });
17
17
 
18
+ tap.test('decode: malformed packet', (t) => {
19
+ t.throws(() => {
20
+ const buf = Buffer.from('/test\0\0');
21
+ decode(buf);
22
+ }, /Malformed Packet/);
23
+ t.end();
24
+ });
25
+
18
26
  tap.test('decode: invalid typetags', (t) => {
19
27
  t.throws(() => {
20
28
  const buf = Buffer.from('/test\0\0\0,R\0');
package/lib/Server.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createSocket } from 'node:dgram';
2
2
  import { EventEmitter } from 'node:events';
3
3
 
4
- import decode from './internal/decode.mjs';
4
+ import decode from '#decode';
5
5
 
6
6
  class Server extends EventEmitter {
7
7
  constructor(port, host='127.0.0.1', cb) {
@@ -25,6 +25,9 @@ function decode(data) {
25
25
  else if (decoded.oscType === 'message') {
26
26
  return sanitizeMessage(decoded);
27
27
  }
28
+ else {
29
+ throw new Error ('Malformed Packet');
30
+ }
28
31
  }
29
32
 
30
33
  export default decode;
package/package.json CHANGED
@@ -1,11 +1,17 @@
1
1
  {
2
2
  "name": "node-osc",
3
3
  "description": "pyOSC inspired library for sending and receiving OSC messages",
4
- "version": "9.0.0",
4
+ "version": "9.0.2",
5
5
  "exports": {
6
6
  "require": "./dist/lib/index.js",
7
7
  "default": "./lib/index.mjs"
8
8
  },
9
+ "imports": {
10
+ "#decode": {
11
+ "require": "./dist/lib/internal/decode.js",
12
+ "default": "./lib/internal/decode.mjs"
13
+ }
14
+ },
9
15
  "author": {
10
16
  "name": "Myles Borins",
11
17
  "email": "myles.borins@gmail.com"
package/rollup.config.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { readdirSync as readdir, statSync as stat } from 'fs';
2
+ import { join } from 'path';
2
3
 
3
4
  // Borrowed from the rollup docs
4
5
  // https://github.com/rollup/rollup/blob/d0db53459be43c5cc806cb91f14e82217950ba42/docs/05-plugin-development.md#renderdynamicimport
@@ -30,8 +31,8 @@ function walk(root, result=[]) {
30
31
  }
31
32
  else {
32
33
  result.push({
33
- input: `${root}${path}`,
34
- dir: `dist/${root}`
34
+ input: join(root, path),
35
+ dir: join('dist/', root)
35
36
  });
36
37
  }
37
38
  }
@@ -54,7 +55,8 @@ function walkLib(config) {
54
55
  'node:dgram',
55
56
  'node:events',
56
57
  'osc-min',
57
- 'jspack'
58
+ 'jspack',
59
+ '#decode'
58
60
  ]
59
61
  });
60
62
  });
@@ -62,6 +64,7 @@ function walkLib(config) {
62
64
 
63
65
  function walkTest(config) {
64
66
  const tests = walk('./test/');
67
+ console.log(tests)
65
68
  tests.forEach(({input, dir}) => {
66
69
  config.push({
67
70
  input,
@@ -78,7 +81,8 @@ function walkTest(config) {
78
81
  'get-port',
79
82
  'node-osc',
80
83
  'osc-min',
81
- 'tap'
84
+ 'tap',
85
+ '#decode'
82
86
  ]
83
87
  })
84
88
  });
@@ -1,6 +1,6 @@
1
1
  import { test } from 'tap';
2
2
 
3
- import decode from '../lib/internal/decode.mjs';
3
+ import decode from '#decode';
4
4
 
5
5
  test('decode: valid', (t) => {
6
6
  const buf = Buffer.from('/test\0\0\0,s\0,testing\0');
@@ -14,6 +14,14 @@ test('decode: valid', (t) => {
14
14
  t.end();
15
15
  });
16
16
 
17
+ test('decode: malformed packet', (t) => {
18
+ t.throws(() => {
19
+ const buf = Buffer.from('/test\0\0');
20
+ decode(buf);
21
+ }, /Malformed Packet/);
22
+ t.end();
23
+ });
24
+
17
25
  test('decode: invalid typetags', (t) => {
18
26
  t.throws(() => {
19
27
  const buf = Buffer.from('/test\0\0\0,R\0');
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- var oscMin = require('osc-min');
4
-
5
- function sanitizeMessage(decoded) {
6
- const message = [];
7
- message.push(decoded.address);
8
- decoded.args.forEach(arg => {
9
- message.push(arg.value);
10
- });
11
- return message;
12
- }
13
-
14
- function sanitizeBundle(decoded) {
15
- decoded.elements = decoded.elements.map(element => {
16
- if (element.oscType === 'bundle') return sanitizeBundle(element);
17
- else if (element.oscType === 'message') return sanitizeMessage(element);
18
- });
19
- return decoded;
20
- }
21
-
22
- function decode(data) {
23
- const decoded = oscMin.fromBuffer(data);
24
- if (decoded.oscType === 'bundle') {
25
- return sanitizeBundle(decoded);
26
- }
27
- else if (decoded.oscType === 'message') {
28
- return sanitizeMessage(decoded);
29
- }
30
- }
31
-
32
- module.exports = decode;