diff --git a/.github/workflows/js_sdk_ci.yml b/.github/workflows/js_sdk_ci.yml index 4fc8e831..97f31c87 100644 --- a/.github/workflows/js_sdk_ci.yml +++ b/.github/workflows/js_sdk_ci.yml @@ -22,9 +22,9 @@ jobs: - uses: actions/cache@v2 with: path: ~/.npm - key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-v1-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} restore-keys: | - ${{ runner.os }}-node-${{ matrix.node-version }} + ${{ runner.os }}-v1-node-${{ matrix.node-version }} - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 diff --git a/src/__test__/unit/air.spec.ts b/src/__test__/unit/air.spec.ts index 92a5f4f9..2f4fd753 100644 --- a/src/__test__/unit/air.spec.ts +++ b/src/__test__/unit/air.spec.ts @@ -1,4 +1,5 @@ import { createLocalClient } from '../connection'; +import {subscribeForErrors} from "../../api"; describe('== AIR suite', () => { it('check init_peer_id', async function () { @@ -59,7 +60,7 @@ describe('== AIR suite', () => { it('call script without ttl', async function () { // arrange const client = await createLocalClient(); - const script = `(call %init_peer_id% ("" "") [""])`; + const script = `(call %init_peer_id% ("op" "identity") [""])`; // act const promise = client.sendScript(script, undefined, 1); diff --git a/src/internal/particle.ts b/src/internal/particle.ts index c622e3ae..0bc949ef 100644 --- a/src/internal/particle.ts +++ b/src/internal/particle.ts @@ -147,12 +147,11 @@ export async function build( timestamp: currentTime, ttl: ttl, script: script, + // TODO: sign particle signature: '', data: Buffer.from([]), }; - particle.signature = await signParticle(peerId, particle); - return particle; } @@ -187,33 +186,6 @@ export function parseParticle(str: string): ParticleDto { }; } -export function canonicalBytes(particle: ParticleDto) { - let peerIdBuf = Buffer.from(particle.init_peer_id, 'utf8'); - let idBuf = Buffer.from(particle.id, 'utf8'); - - let tsArr = new ArrayBuffer(8); - new DataView(tsArr).setBigUint64(0, BigInt(particle.timestamp)); - let tsBuf = Buffer.from(tsArr); - - let ttlArr = new ArrayBuffer(4); - new DataView(ttlArr).setUint32(0, particle.ttl); - let ttlBuf = Buffer.from(ttlArr); - - let scriptBuf = Buffer.from(particle.script, 'utf8'); - - return Buffer.concat([peerIdBuf, idBuf, tsBuf, ttlBuf, scriptBuf]); -} - -/** - * Sign a particle with a private key from peerId. - */ -export async function signParticle(peerId: PeerId, particle: ParticleDto): Promise { - let bufToSign = canonicalBytes(particle); - - let signature = await peerId.privKey.sign(bufToSign); - return encode(signature); -} - export function genUUID() { return uuidv4(); }