-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ebab3d
commit 58480f8
Showing
8 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../.npmignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "@slangroom/zencode", | ||
"version": "1.12.0", | ||
"dependencies": { | ||
"@slangroom/core": "workspace:*", | ||
"@slangroom/shared": "workspace:*" | ||
}, | ||
"repository": "https://github.com/dyne/slangroom", | ||
"license": "AGPL-3.0-only", | ||
"type": "module", | ||
"main": "./build/esm/src/index.js", | ||
"types": "./build/esm/src/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./build/esm/src/index.d.ts", | ||
"default": "./build/esm/src/index.js" | ||
} | ||
}, | ||
"./*": { | ||
"import": { | ||
"types": "./build/esm/src/*.d.ts", | ||
"default": "./build/esm/src/*.js" | ||
} | ||
} | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@slangroom/zencode/plugin'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Plugin } from '@slangroom/core'; | ||
import type { JsonableObject } from '@slangroom/shared'; | ||
import { zencodeExec } from '@slangroom/shared'; | ||
|
||
const p = new Plugin(); | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const zencodeExecPlugin = p.new(['script', 'data', 'keys', 'extra', 'conf'], 'execute zencode', async (ctx) => { | ||
const script = ctx.fetch('script') as string; | ||
const data = (ctx.get('data') || {}) as JsonableObject; | ||
const keys = (ctx.get('keys') || {}) as JsonableObject; | ||
const extra = (ctx.get('extra') || {}) as JsonableObject; | ||
const conf = (ctx.get('conf') || "") as string; | ||
|
||
const zout = await zencodeExec(script, { data, keys, extra, conf }); | ||
|
||
return ctx.pass(zout.result) | ||
}); | ||
|
||
|
||
|
||
export const zencode = p; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import test from 'ava'; | ||
import { Slangroom } from '@slangroom/core'; | ||
import { zencode } from '@slangroom/zencode'; | ||
import type { JsonableObject } from '@slangroom/shared'; | ||
|
||
|
||
test('run zencode', async (t) => { | ||
const scriptCreate = ` | ||
Rule unknown ignore | ||
Given I send keys 'neo_keys' and send script 'neo_script' and send data 'neo_data' and send conf 'neo_conf' and send extra 'neo_extra' and execute zencode and output into 'ecdh_public_key' | ||
Given I have a 'string dictionary' named 'ecdh_public_key' | ||
Then print data | ||
`; | ||
const slangroom = new Slangroom(zencode); | ||
const res = await slangroom.execute(scriptCreate, { | ||
keys: { | ||
neo_keys: { | ||
keyring: { | ||
ecdh: "FJ5Esc1koLSH+9pKSdI65tcyH2HowzXMe0UdsqktmZU=", | ||
} | ||
}, | ||
neo_conf: "", | ||
neo_data: {}, | ||
neo_extra: {}, | ||
neo_script: ` | ||
Scenario 'ecdh': Create the public key | ||
Given I have the 'keyring' | ||
When I create the ecdh public key | ||
Then print the 'ecdh public key' | ||
` | ||
}, | ||
}); | ||
t.deepEqual((res.result['ecdh_public_key'] as JsonableObject), { | ||
ecdh_public_key: "BLOYXryyAI7rPuyNbI0/1CfLFd7H/NbX+osqyQHjPR9BPK1lYSPOixZQWvFK+rkkJ+aJbYp6kii2Y3+fZ5vl2MA=" | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../tsconfig.json |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.