mirror of
https://github.com/tlsnotary/TLSN-plugin-gen.git
synced 2026-01-06 20:03:51 -05:00
Add : tlsn-plugin-gen compiler using github CI/CD. allows to generate wasm from the plugin code generated by tlsn-plugin-gen
This commit is contained in:
BIN
TLSN-plugin-compiler/.DS_Store
vendored
Normal file
BIN
TLSN-plugin-compiler/.DS_Store
vendored
Normal file
Binary file not shown.
74
TLSN-plugin-compiler/.github/workflows/build-pipeline.yml
vendored
Normal file
74
TLSN-plugin-compiler/.github/workflows/build-pipeline.yml
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
name: TLSN Plugin Compiler Pipeline
|
||||
|
||||
on:
|
||||
workflow_dispatch: # Allows manual trigger for testing
|
||||
repository_dispatch: # Triggered by external POST request
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Show current directory and files (initial)
|
||||
run: |
|
||||
echo "Current working directory:"
|
||||
pwd
|
||||
echo "Directory structure:"
|
||||
ls -la
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '18.x'
|
||||
|
||||
- name: Replace files with incoming payload
|
||||
if: github.event.client_payload != null
|
||||
run: |
|
||||
# Ensure directories exist
|
||||
mkdir -p src/utils
|
||||
|
||||
# Replace config.json
|
||||
echo "${{ github.event.client_payload['config.json'] }}" | base64 -d > config.json
|
||||
echo "Replaced config.json:"
|
||||
cat config.json
|
||||
|
||||
# Replace index.d.ts
|
||||
echo "${{ github.event.client_payload['index.d.ts'] }}" | base64 -d > src/index.d.ts
|
||||
echo "Replaced src/index.d.ts:"
|
||||
cat src/index.d.ts
|
||||
|
||||
# Replace index.ts
|
||||
echo "${{ github.event.client_payload['index.ts'] }}" | base64 -d > src/index.ts
|
||||
echo "Replaced src/index.ts:"
|
||||
cat src/index.ts
|
||||
|
||||
# Debugging: Show updated directory structure
|
||||
echo "Directory structure after replacing files:"
|
||||
ls -la
|
||||
echo "Tree structure:"
|
||||
sudo apt-get install -y tree
|
||||
tree .
|
||||
|
||||
- name: Install Extism
|
||||
run: |
|
||||
curl -O https://raw.githubusercontent.com/extism/js-pdk/main/install.sh
|
||||
chmod +x install.sh
|
||||
./install.sh
|
||||
echo "Installed Extism."
|
||||
|
||||
- name: Install dependencies and build project
|
||||
run: |
|
||||
npm install
|
||||
npm run build
|
||||
echo "Build complete."
|
||||
echo "Contents of src/index.ts (post-build):"
|
||||
cat src/index.ts
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: wasm-artifact
|
||||
path: ./dist/*.wasm
|
||||
133
TLSN-plugin-compiler/.gitignore
vendored
Normal file
133
TLSN-plugin-compiler/.gitignore
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# env
|
||||
.env
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
.cache
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
201
TLSN-plugin-compiler/LICENSE
Normal file
201
TLSN-plugin-compiler/LICENSE
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
156
TLSN-plugin-compiler/README.md
Normal file
156
TLSN-plugin-compiler/README.md
Normal file
@@ -0,0 +1,156 @@
|
||||
# TLSN-plugin-compiler
|
||||
A base repo on tlsnotary plugin. Takes in a JSON code and returns wasm in artifacts
|
||||
|
||||
## How to Use the Project
|
||||
|
||||
This project is designed to compile TLSNotary plugins from JSON code and return WebAssembly (WASM) artifacts. Follow the steps below to use the project:
|
||||
|
||||
1. Clone the repository:
|
||||
```sh
|
||||
git clone tlsn-plugin-compiler
|
||||
```
|
||||
cd TLSN-plugin-compiler
|
||||
```
|
||||
|
||||
2. Install dependencies:
|
||||
```sh
|
||||
npm install
|
||||
```
|
||||
|
||||
3. Build the project:
|
||||
```sh
|
||||
npm run build
|
||||
```
|
||||
|
||||
4. The compiled WASM artifacts will be available in the `dist` directory.
|
||||
|
||||
## Pipeline Actions
|
||||
|
||||
The pipeline actions for this project are defined in the `.github/workflows/build-pipeline.yml` file. The pipeline can be triggered manually or by an external POST request.
|
||||
|
||||
### Manual Trigger ( don't do that but you can do it)
|
||||
|
||||
To manually trigger the pipeline, navigate to the Actions tab in your GitHub repository, select the desired workflow, and click on the "Run workflow" button. Make sure you replace the default existing files with your plugin code. You have to replace config.json, index.d.ts and index.ts with your plugin code.
|
||||
|
||||
### External POST Request
|
||||
|
||||
The pipeline can also be triggered by sending a POST request to the GitHub API. The expected format for the POST request is described in the next section. You have to use your own access token for that.
|
||||
|
||||
## Expected POST Request Format
|
||||
|
||||
To trigger the pipeline using an external POST request, send a request to the following URL:
|
||||
```
|
||||
https://api.github.com/repos/hackertron/TLSN-plugin-compiler/dispatches
|
||||
```
|
||||
|
||||
The request should include the following headers:
|
||||
```
|
||||
Accept: application/vnd.github.v3+json
|
||||
Authorization: token YOUR_GITHUB_PERSONAL_ACCESS_TOKEN
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
The body of the request should be in JSON format and include the `event_type` and `client_payload` fields. Here is an example:
|
||||
|
||||
```json
|
||||
{
|
||||
"event_type": "build_pipeline",
|
||||
"client_payload": {
|
||||
"config.json": {
|
||||
"title": "Anime Quote Notarization",
|
||||
"description": "Notarize the response from the Anime Quote API",
|
||||
"steps": [
|
||||
{
|
||||
"title": "Fetch a random anime quote",
|
||||
"cta": "Get Quote",
|
||||
"action": "start"
|
||||
},
|
||||
{
|
||||
"title": "Collect API response",
|
||||
"description": "Retrieve the quote from the API",
|
||||
"cta": "Check response",
|
||||
"action": "two"
|
||||
},
|
||||
{
|
||||
"title": "Notarize the quote",
|
||||
"cta": "Notarize",
|
||||
"action": "three",
|
||||
"prover": true
|
||||
}
|
||||
],
|
||||
"hostFunctions": [
|
||||
"redirect",
|
||||
"notarize"
|
||||
],
|
||||
"cookies": [],
|
||||
"headers": [
|
||||
"animechan.io"
|
||||
],
|
||||
"requests": [
|
||||
{
|
||||
"url": "https://animechan.io/api/v1/quotes/random",
|
||||
"method": "GET"
|
||||
}
|
||||
]
|
||||
},
|
||||
"index.d.ts": "declare module 'main' {\\n export function start(): I32;\\n export function two(): I32;\\n export function parseAnimeQuoteResp(): I32;\\n export function three(): I32;\\n export function config(): I32;\\n}\\n\\ndeclare module 'extism:host' {\\n interface user {\\n redirect(ptr: I64): void;\\n notarize(ptr: I64): I64;\\n }\\n}",
|
||||
"index.ts": "import icon from '../assets/icon.png';\\nimport config_json from '../config.json';\\nimport { redirect, notarize, outputJSON, getCookiesByHost, getHeadersByHost } from './utils/hf.js';\\n\\nexport function config() {\\n outputJSON({\\n ...config_json,\\n icon: icon\\n });\\n}\\n\\nfunction isValidHost(urlString: string) {\\n const url = new URL(urlString);\\n return url.hostname === 'animechan.io';\\n}\\n\\nexport function start() {\\n if (!isValidHost(Config.get('tabUrl'))) {\\n redirect('https://animechan.io');\\n outputJSON(false);\\n return;\\n }\\n outputJSON(true);\\n}\\n\\nexport function two() {\\n const headers = getHeadersByHost('animechan.io');\\n\\n outputJSON({\\n url: 'https://animechan.io/api/v1/quotes/random',\\n method: 'GET',\\n headers: {\\n 'Accept': 'application/json',\\n },\\n });\\n}\\n\\nexport function parseAnimeQuoteResp() {\\n const bodyString = Host.inputString();\\n const params = JSON.parse(bodyString);\\n\\n if (params.data) {\\n outputJSON(params.data);\\n } else {\\n outputJSON(false);\\n }\\n}\\n\\nexport function three() {\\n const params = JSON.parse(Host.inputString());\\n\\n if (!params) {\\n outputJSON(false);\\n } else {\\n const id = notarize({\\n ...params,\\n getSecretResponse: 'parseAnimeQuoteResp',\\n });\\n outputJSON(id);\\n }\\n}",
|
||||
"utils/hf.js": "function redirect(url) {\\n const { redirect } = Host.getFunctions();\\n const mem = Memory.fromString(url);\\n redirect(mem.offset);\\n}\\n\\nfunction notarize(options) {\\n const { notarize } = Host.getFunctions();\\n const mem = Memory.fromString(JSON.stringify(options));\\n const idOffset = notarize(mem.offset);\\n const id = Memory.find(idOffset).readString();\\n return id;\\n}\\n\\nfunction outputJSON(json) {\\n Host.outputString(\\n JSON.stringify(json),\\n );\\n}\\n\\nfunction getHeadersByHost(hostname) {\\n const headers = JSON.parse(Config.get('headers'));\\n if (!headers[hostname]) throw new Error(`cannot find headers for ${hostname}`);\\n return headers[hostname];\\n}\\n\\nmodule.exports = {\\n redirect,\\n notarize,\\n outputJSON,\\n getHeadersByHost,\\n};"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Example Payload Structure and Usage
|
||||
|
||||
The `payload.json` file contains an example payload that can be used to trigger the pipeline. Here is the structure and usage of the example payload:
|
||||
|
||||
```json
|
||||
{
|
||||
"config": {
|
||||
"title": "Anime Quote Notarization",
|
||||
"description": "Notarize the response from the Anime Quote API",
|
||||
"steps": [
|
||||
{
|
||||
"title": "Fetch a random anime quote",
|
||||
"cta": "Get Quote",
|
||||
"action": "start"
|
||||
},
|
||||
{
|
||||
"title": "Collect API response",
|
||||
"description": "Retrieve the quote from the API",
|
||||
"cta": "Check response",
|
||||
"action": "two"
|
||||
},
|
||||
{
|
||||
"title": "Notarize the quote",
|
||||
"cta": "Notarize",
|
||||
"action": "three",
|
||||
"prover": true
|
||||
}
|
||||
],
|
||||
"hostFunctions": [
|
||||
"redirect",
|
||||
"notarize"
|
||||
],
|
||||
"cookies": [],
|
||||
"headers": [
|
||||
"animechan.io"
|
||||
],
|
||||
"requests": [
|
||||
{
|
||||
"url": "https://animechan.io/api/v1/quotes/random",
|
||||
"method": "GET"
|
||||
}
|
||||
]
|
||||
},
|
||||
"index.d.ts": "declare module 'main' {\\n export function start(): I32;\\n export function two(): I32;\\n export function parseAnimeQuoteResp(): I32;\\n export function three(): I32;\\n export function config(): I32;\\n}\\n\\ndeclare module 'extism:host' {\\n interface user {\\n redirect(ptr: I64): void;\\n notarize(ptr: I64): I64;\\n }\\n}",
|
||||
"index.ts": "import icon from '../assets/icon.png';\\nimport config_json from '../config.json';\\nimport { redirect, notarize, outputJSON, getCookiesByHost, getHeadersByHost } from './utils/hf.js';\\n\\nexport function config() {\\n outputJSON({\\n ...config_json,\\n icon: icon\\n });\\n}\\n\\nfunction isValidHost(urlString: string) {\\n const url = new URL(urlString);\\n return url.hostname === 'animechan.io';\\n}\\n\\nexport function start() {\\n if (!isValidHost(Config.get('tabUrl'))) {\\n redirect('https://animechan.io');\\n outputJSON(false);\\n return;\\n }\\n outputJSON(true);\\n}\\n\\nexport function two() {\\n const headers = getHeadersByHost('animechan.io');\\n\\n outputJSON({\\n url: 'https://animechan.io/api/v1/quotes/random',\\n method: 'GET',\\n headers: {\\n 'Accept': 'application/json',\\n },\\n });\\n}\\n\\nexport function parseAnimeQuoteResp() {\\n const bodyString = Host.inputString();\\n const params = JSON.parse(bodyString);\\n\\n if (params.data) {\\n outputJSON(params.data);\\n } else {\\n outputJSON(false);\\n }\\n}\\n\\nexport function three() {\\n const params = JSON.parse(Host.inputString());\\n\\n if (!params) {\\n outputJSON(false);\\n } else {\\n const id = notarize({\\n ...params,\\n getSecretResponse: 'parseAnimeQuoteResp',\\n });\\n outputJSON(id);\\n }\\n}",
|
||||
"utils/hf.js": "function redirect(url) {\\n const { redirect } = Host.getFunctions();\\n const mem = Memory.fromString(url);\\n redirect(mem.offset);\\n}\\n\\nfunction notarize(options) {\\n const { notarize } = Host.getFunctions();\\n const mem = Memory.fromString(JSON.stringify(options));\\n const idOffset = notarize(mem.offset);\\n const id = Memory.find(idOffset).readString();\\n return id;\\n}\\n\\nfunction outputJSON(json) {\\n Host.outputString(\\n JSON.stringify(json),\\n );\\n}\\n\\nfunction getHeadersByHost(hostname) {\\n const headers = JSON.parse(Config.get('headers'));\\n if (!headers[hostname]) throw new Error(`cannot find headers for ${hostname}`);\\n return headers[hostname];\\n}\\n\\nmodule.exports = {\\n redirect,\\n notarize,\\n outputJSON,\\n getHeadersByHost,\\n};"
|
||||
}
|
||||
```
|
||||
|
||||
To trigger the pipeline using this payload, you can use the `triggerpipeline.js` script provided in the repository. Update the `GITHUB_TOKEN` variable with your GitHub personal access token and run the script:
|
||||
|
||||
```sh
|
||||
node triggerpipeline.js
|
||||
```
|
||||
BIN
TLSN-plugin-compiler/assets/icon.png
Normal file
BIN
TLSN-plugin-compiler/assets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
39
TLSN-plugin-compiler/config.json
Normal file
39
TLSN-plugin-compiler/config.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"title": "Twitter Profile",
|
||||
"description": "Notarize ownership of a twitter profile",
|
||||
"steps": [
|
||||
{
|
||||
"title": "Visit Twitter website",
|
||||
"cta": "Go to x.com",
|
||||
"action": "start"
|
||||
},
|
||||
{
|
||||
"title": "Collect credentials",
|
||||
"description": "Login to your account if you haven't already",
|
||||
"cta": "Check cookies",
|
||||
"action": "two"
|
||||
},
|
||||
{
|
||||
"title": "Notarize twitter profile",
|
||||
"cta": "Notarize",
|
||||
"action": "three",
|
||||
"prover": true
|
||||
}
|
||||
],
|
||||
"hostFunctions": [
|
||||
"redirect",
|
||||
"notarize"
|
||||
],
|
||||
"cookies": [
|
||||
"api.x.com"
|
||||
],
|
||||
"headers": [
|
||||
"api.x.com"
|
||||
],
|
||||
"requests": [
|
||||
{
|
||||
"url": "https://api.x.com/1.1/account/settings.json",
|
||||
"method": "GET"
|
||||
}
|
||||
]
|
||||
}
|
||||
36
TLSN-plugin-compiler/esbuild.js
Normal file
36
TLSN-plugin-compiler/esbuild.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const esbuild = require('esbuild');
|
||||
const path = require('path');
|
||||
const { name } = require('./package.json');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
const outputDir = 'dist';
|
||||
const entryFile = 'src/index.ts';
|
||||
const outputFile = path.join(outputDir, 'index.js');
|
||||
const outputWasm = path.join(outputDir, `${name}.tlsn.wasm`);
|
||||
|
||||
async function build() {
|
||||
try {
|
||||
await esbuild.build({
|
||||
entryPoints: [entryFile],
|
||||
bundle: true,
|
||||
outdir: outputDir, // Use outdir for directory output
|
||||
sourcemap: true,
|
||||
minify: false, // might want to use true for production build
|
||||
format: 'cjs', // needs to be CJS for now
|
||||
target: ['es2020'], // don't go over es2020 because quickjs doesn't support it
|
||||
loader: {'.png': 'dataurl'}
|
||||
});
|
||||
|
||||
console.log('esbuild completed successfully.');
|
||||
|
||||
// Run extism-js to generate the wasm file
|
||||
const extismCommand = `extism-js ${outputFile} -i src/index.d.ts -o ${outputWasm}`;
|
||||
execSync(extismCommand, { stdio: 'inherit' });
|
||||
console.log('extism-js completed successfully.');
|
||||
} catch (error) {
|
||||
console.error('Build process failed:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
build();
|
||||
649
TLSN-plugin-compiler/package-lock.json
generated
Normal file
649
TLSN-plugin-compiler/package-lock.json
generated
Normal file
@@ -0,0 +1,649 @@
|
||||
{
|
||||
"name": "twitter_profile",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "twitter_profile",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@extism/js-pdk": "^1.0.1",
|
||||
"esbuild": "^0.19.6",
|
||||
"typescript": "^5.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/aix-ppc64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.12.tgz",
|
||||
"integrity": "sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"aix"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.12.tgz",
|
||||
"integrity": "sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.12.tgz",
|
||||
"integrity": "sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-arm64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz",
|
||||
"integrity": "sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/freebsd-arm64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.12.tgz",
|
||||
"integrity": "sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/freebsd-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-arm": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.12.tgz",
|
||||
"integrity": "sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-arm64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.12.tgz",
|
||||
"integrity": "sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-ia32": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.12.tgz",
|
||||
"integrity": "sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-loong64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.12.tgz",
|
||||
"integrity": "sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==",
|
||||
"cpu": [
|
||||
"loong64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-mips64el": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.12.tgz",
|
||||
"integrity": "sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==",
|
||||
"cpu": [
|
||||
"mips64el"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-ppc64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.12.tgz",
|
||||
"integrity": "sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-riscv64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.12.tgz",
|
||||
"integrity": "sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-s390x": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.12.tgz",
|
||||
"integrity": "sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/netbsd-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"netbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openbsd-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/sunos-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"sunos"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-arm64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.12.tgz",
|
||||
"integrity": "sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-ia32": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.12.tgz",
|
||||
"integrity": "sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@extism/js-pdk": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@extism/js-pdk/-/js-pdk-1.0.1.tgz",
|
||||
"integrity": "sha512-YJWfHGeOuJnQw4V8NPNHvbSr6S8iDd2Ga6VEukwlRP7tu62ozTxIgokYw8i+rajD/16zz/gK0KYARBpm2qPAmQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.12.tgz",
|
||||
"integrity": "sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/aix-ppc64": "0.19.12",
|
||||
"@esbuild/android-arm": "0.19.12",
|
||||
"@esbuild/android-arm64": "0.19.12",
|
||||
"@esbuild/android-x64": "0.19.12",
|
||||
"@esbuild/darwin-arm64": "0.19.12",
|
||||
"@esbuild/darwin-x64": "0.19.12",
|
||||
"@esbuild/freebsd-arm64": "0.19.12",
|
||||
"@esbuild/freebsd-x64": "0.19.12",
|
||||
"@esbuild/linux-arm": "0.19.12",
|
||||
"@esbuild/linux-arm64": "0.19.12",
|
||||
"@esbuild/linux-ia32": "0.19.12",
|
||||
"@esbuild/linux-loong64": "0.19.12",
|
||||
"@esbuild/linux-mips64el": "0.19.12",
|
||||
"@esbuild/linux-ppc64": "0.19.12",
|
||||
"@esbuild/linux-riscv64": "0.19.12",
|
||||
"@esbuild/linux-s390x": "0.19.12",
|
||||
"@esbuild/linux-x64": "0.19.12",
|
||||
"@esbuild/netbsd-x64": "0.19.12",
|
||||
"@esbuild/openbsd-x64": "0.19.12",
|
||||
"@esbuild/sunos-x64": "0.19.12",
|
||||
"@esbuild/win32-arm64": "0.19.12",
|
||||
"@esbuild/win32-ia32": "0.19.12",
|
||||
"@esbuild/win32-x64": "0.19.12"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.5.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz",
|
||||
"integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@esbuild/aix-ppc64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.12.tgz",
|
||||
"integrity": "sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/android-arm": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.12.tgz",
|
||||
"integrity": "sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/android-arm64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.12.tgz",
|
||||
"integrity": "sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/android-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/darwin-arm64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz",
|
||||
"integrity": "sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/darwin-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/freebsd-arm64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.12.tgz",
|
||||
"integrity": "sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/freebsd-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/linux-arm": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.12.tgz",
|
||||
"integrity": "sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/linux-arm64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.12.tgz",
|
||||
"integrity": "sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/linux-ia32": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.12.tgz",
|
||||
"integrity": "sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/linux-loong64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.12.tgz",
|
||||
"integrity": "sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/linux-mips64el": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.12.tgz",
|
||||
"integrity": "sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/linux-ppc64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.12.tgz",
|
||||
"integrity": "sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/linux-riscv64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.12.tgz",
|
||||
"integrity": "sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/linux-s390x": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.12.tgz",
|
||||
"integrity": "sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/linux-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/netbsd-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/openbsd-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/sunos-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/win32-arm64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.12.tgz",
|
||||
"integrity": "sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/win32-ia32": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.12.tgz",
|
||||
"integrity": "sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@esbuild/win32-x64": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz",
|
||||
"integrity": "sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@extism/js-pdk": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@extism/js-pdk/-/js-pdk-1.0.1.tgz",
|
||||
"integrity": "sha512-YJWfHGeOuJnQw4V8NPNHvbSr6S8iDd2Ga6VEukwlRP7tu62ozTxIgokYw8i+rajD/16zz/gK0KYARBpm2qPAmQ==",
|
||||
"dev": true
|
||||
},
|
||||
"esbuild": {
|
||||
"version": "0.19.12",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.12.tgz",
|
||||
"integrity": "sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@esbuild/aix-ppc64": "0.19.12",
|
||||
"@esbuild/android-arm": "0.19.12",
|
||||
"@esbuild/android-arm64": "0.19.12",
|
||||
"@esbuild/android-x64": "0.19.12",
|
||||
"@esbuild/darwin-arm64": "0.19.12",
|
||||
"@esbuild/darwin-x64": "0.19.12",
|
||||
"@esbuild/freebsd-arm64": "0.19.12",
|
||||
"@esbuild/freebsd-x64": "0.19.12",
|
||||
"@esbuild/linux-arm": "0.19.12",
|
||||
"@esbuild/linux-arm64": "0.19.12",
|
||||
"@esbuild/linux-ia32": "0.19.12",
|
||||
"@esbuild/linux-loong64": "0.19.12",
|
||||
"@esbuild/linux-mips64el": "0.19.12",
|
||||
"@esbuild/linux-ppc64": "0.19.12",
|
||||
"@esbuild/linux-riscv64": "0.19.12",
|
||||
"@esbuild/linux-s390x": "0.19.12",
|
||||
"@esbuild/linux-x64": "0.19.12",
|
||||
"@esbuild/netbsd-x64": "0.19.12",
|
||||
"@esbuild/openbsd-x64": "0.19.12",
|
||||
"@esbuild/sunos-x64": "0.19.12",
|
||||
"@esbuild/win32-arm64": "0.19.12",
|
||||
"@esbuild/win32-ia32": "0.19.12",
|
||||
"@esbuild/win32-x64": "0.19.12"
|
||||
}
|
||||
},
|
||||
"typescript": {
|
||||
"version": "5.5.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz",
|
||||
"integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
17
TLSN-plugin-compiler/package.json
Normal file
17
TLSN-plugin-compiler/package.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "tlsnotary_website_plugin",
|
||||
"version": "1.0.0",
|
||||
"description": "WASM TLSNotary plugin to notarize the users website",
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
"build": "node esbuild.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "TLSNotary",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@extism/js-pdk": "^1.0.1",
|
||||
"esbuild": "^0.19.6",
|
||||
"typescript": "^5.3.2"
|
||||
}
|
||||
}
|
||||
42
TLSN-plugin-compiler/payload.json
Normal file
42
TLSN-plugin-compiler/payload.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"config": {
|
||||
"title": "Anime Quote Notarization",
|
||||
"description": "Notarize the response from the Anime Quote API",
|
||||
"steps": [
|
||||
{
|
||||
"title": "Fetch a random anime quote",
|
||||
"cta": "Get Quote",
|
||||
"action": "start"
|
||||
},
|
||||
{
|
||||
"title": "Collect API response",
|
||||
"description": "Retrieve the quote from the API",
|
||||
"cta": "Check response",
|
||||
"action": "two"
|
||||
},
|
||||
{
|
||||
"title": "Notarize the quote",
|
||||
"cta": "Notarize",
|
||||
"action": "three",
|
||||
"prover": true
|
||||
}
|
||||
],
|
||||
"hostFunctions": [
|
||||
"redirect",
|
||||
"notarize"
|
||||
],
|
||||
"cookies": [],
|
||||
"headers": [
|
||||
"animechan.io"
|
||||
],
|
||||
"requests": [
|
||||
{
|
||||
"url": "https://animechan.io/api/v1/quotes/random",
|
||||
"method": "GET"
|
||||
}
|
||||
]
|
||||
},
|
||||
"index.d.ts": "declare module 'main' {\n export function start(): I32;\n export function two(): I32;\n export function parseAnimeQuoteResp(): I32;\n export function three(): I32;\n export function config(): I32;\n}\n\ndeclare module 'extism:host' {\n interface user {\n redirect(ptr: I64): void;\n notarize(ptr: I64): I64;\n }\n}",
|
||||
"index.ts": "import icon from '../assets/icon.png';\nimport config_json from '../config.json';\nimport { redirect, notarize, outputJSON, getCookiesByHost, getHeadersByHost } from './utils/hf.js';\n\nexport function config() {\n outputJSON({\n ...config_json,\n icon: icon\n });\n}\n\nfunction isValidHost(urlString: string) {\n const url = new URL(urlString);\n return url.hostname === 'animechan.io';\n}\n\nexport function start() {\n if (!isValidHost(Config.get('tabUrl'))) {\n redirect('https://animechan.io');\n outputJSON(false);\n return;\n }\n outputJSON(true);\n}\n\nexport function two() {\n const headers = getHeadersByHost('animechan.io');\n\n outputJSON({\n url: 'https://animechan.io/api/v1/quotes/random',\n method: 'GET',\n headers: {\n 'Accept': 'application/json',\n },\n });\n}\n\nexport function parseAnimeQuoteResp() {\n const bodyString = Host.inputString();\n const params = JSON.parse(bodyString);\n\n if (params.data) {\n outputJSON(params.data);\n } else {\n outputJSON(false);\n }\n}\n\nexport function three() {\n const params = JSON.parse(Host.inputString());\n\n if (!params) {\n outputJSON(false);\n } else {\n const id = notarize({\n ...params,\n getSecretResponse: 'parseAnimeQuoteResp',\n });\n outputJSON(id);\n }\n}",
|
||||
"utils/hf.js": "function redirect(url) {\n const { redirect } = Host.getFunctions();\n const mem = Memory.fromString(url);\n redirect(mem.offset);\n}\n\nfunction notarize(options) {\n const { notarize } = Host.getFunctions();\n const mem = Memory.fromString(JSON.stringify(options));\n const idOffset = notarize(mem.offset);\n const id = Memory.find(idOffset).readString();\n return id;\n}\n\nfunction outputJSON(json) {\n Host.outputString(\n JSON.stringify(json),\n );\n}\n\nfunction getHeadersByHost(hostname) {\n const headers = JSON.parse(Config.get('headers'));\n if (!headers[hostname]) throw new Error(`cannot find headers for ${hostname}`);\n return headers[hostname];\n}\n\nmodule.exports = {\n redirect,\n notarize,\n outputJSON,\n getHeadersByHost,\n};"
|
||||
}
|
||||
15
TLSN-plugin-compiler/src/index.d.ts
vendored
Normal file
15
TLSN-plugin-compiler/src/index.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
declare module 'main' {
|
||||
// Extism exports take no params and return an I32
|
||||
export function start(): I32;
|
||||
export function two(): I32;
|
||||
export function parseTwitterResp(): I32;
|
||||
export function three(): I32;
|
||||
export function config(): I32;
|
||||
}
|
||||
|
||||
declare module 'extism:host' {
|
||||
interface user {
|
||||
redirect(ptr: I64): void;
|
||||
notarize(ptr: I64): I64;
|
||||
}
|
||||
}
|
||||
116
TLSN-plugin-compiler/src/index.ts
Normal file
116
TLSN-plugin-compiler/src/index.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import icon from '../assets/icon.png';
|
||||
import config_json from '../config.json';
|
||||
import { redirect, notarize, outputJSON, getCookiesByHost, getHeadersByHost } from './utils/hf.js';
|
||||
|
||||
/**
|
||||
* Plugin configuration
|
||||
* This configurations defines the plugin, most importantly:
|
||||
* * the different steps
|
||||
* * the user data (headers, cookies) it will access
|
||||
* * the web requests it will query (or notarize)
|
||||
*/
|
||||
export function config() {
|
||||
outputJSON({
|
||||
...config_json,
|
||||
icon: icon
|
||||
});
|
||||
}
|
||||
|
||||
function isValidHost(urlString: string) {
|
||||
const url = new URL(urlString);
|
||||
return url.hostname === 'twitter.com' || url.hostname === 'x.com';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of the first (start) plugin step
|
||||
*/
|
||||
export function start() {
|
||||
if (!isValidHost(Config.get('tabUrl'))) {
|
||||
redirect('https://x.com');
|
||||
outputJSON(false);
|
||||
return;
|
||||
}
|
||||
outputJSON(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of step "two".
|
||||
* This step collects and validates authentication cookies and headers for 'api.x.com'.
|
||||
* If all required information, it creates the request object.
|
||||
* Note that the url needs to be specified in the `config` too, otherwise the request will be refused.
|
||||
*/
|
||||
export function two() {
|
||||
const cookies = getCookiesByHost('api.x.com');
|
||||
const headers = getHeadersByHost('api.x.com');
|
||||
|
||||
if (
|
||||
!cookies.auth_token ||
|
||||
!cookies.ct0 ||
|
||||
!headers['x-csrf-token'] ||
|
||||
!headers['authorization']
|
||||
) {
|
||||
outputJSON(false);
|
||||
return;
|
||||
}
|
||||
|
||||
outputJSON({
|
||||
url: 'https://api.x.com/1.1/account/settings.json',
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'x-twitter-client-language': 'en',
|
||||
'x-csrf-token': headers['x-csrf-token'],
|
||||
Host: 'api.x.com',
|
||||
authorization: headers.authorization,
|
||||
Cookie: `lang=en; auth_token=${cookies.auth_token}; ct0=${cookies.ct0}`,
|
||||
'Accept-Encoding': 'identity',
|
||||
Connection: 'close',
|
||||
},
|
||||
secretHeaders: [
|
||||
`x-csrf-token: ${headers['x-csrf-token']}`,
|
||||
`cookie: lang=en; auth_token=${cookies.auth_token}; ct0=${cookies.ct0}`,
|
||||
`authorization: ${headers.authorization}`,
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to parse the Twitter response and specify what information is revealed (i.e. **not** redacted)
|
||||
* This method is optional in the notarization request. When it is not specified nothing is redacted.
|
||||
*
|
||||
* In this example it locates the `screen_name` and excludes that range from the revealed response.
|
||||
*/
|
||||
export function parseTwitterResp() {
|
||||
const bodyString = Host.inputString();
|
||||
const params = JSON.parse(bodyString);
|
||||
|
||||
if (params.screen_name) {
|
||||
const revealed = `"screen_name":"${params.screen_name}"`;
|
||||
const selectionStart = bodyString.indexOf(revealed);
|
||||
const selectionEnd =
|
||||
selectionStart + revealed.length;
|
||||
const secretResps = [
|
||||
bodyString.substring(0, selectionStart),
|
||||
bodyString.substring(selectionEnd, bodyString.length),
|
||||
];
|
||||
outputJSON(secretResps);
|
||||
} else {
|
||||
outputJSON(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 3: calls the `notarize` host function
|
||||
*/
|
||||
export function three() {
|
||||
const params = JSON.parse(Host.inputString());
|
||||
|
||||
if (!params) {
|
||||
outputJSON(false);
|
||||
} else {
|
||||
const id = notarize({
|
||||
...params,
|
||||
getSecretResponse: 'parseTwitterResp',
|
||||
});
|
||||
outputJSON(id);
|
||||
}
|
||||
}
|
||||
39
TLSN-plugin-compiler/src/utils/hf.js
Normal file
39
TLSN-plugin-compiler/src/utils/hf.js
Normal file
@@ -0,0 +1,39 @@
|
||||
function redirect(url) {
|
||||
const { redirect } = Host.getFunctions();
|
||||
const mem = Memory.fromString(url);
|
||||
redirect(mem.offset);
|
||||
}
|
||||
|
||||
function notarize(options) {
|
||||
const { notarize } = Host.getFunctions();
|
||||
const mem = Memory.fromString(JSON.stringify(options));
|
||||
const idOffset = notarize(mem.offset);
|
||||
const id = Memory.find(idOffset).readString();
|
||||
return id;
|
||||
}
|
||||
|
||||
function outputJSON(json) {
|
||||
Host.outputString(
|
||||
JSON.stringify(json),
|
||||
);
|
||||
}
|
||||
|
||||
function getCookiesByHost(hostname) {
|
||||
const cookies = JSON.parse(Config.get('cookies'));
|
||||
if (!cookies[hostname]) throw new Error(`cannot find cookies for ${hostname}`);
|
||||
return cookies[hostname];
|
||||
}
|
||||
|
||||
function getHeadersByHost(hostname) {
|
||||
const headers = JSON.parse(Config.get('headers'));
|
||||
if (!headers[hostname]) throw new Error(`cannot find headers for ${hostname}`);
|
||||
return headers[hostname];
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
redirect,
|
||||
notarize,
|
||||
outputJSON,
|
||||
getCookiesByHost,
|
||||
getHeadersByHost,
|
||||
};
|
||||
77
TLSN-plugin-compiler/triggerpipeline.js
Normal file
77
TLSN-plugin-compiler/triggerpipeline.js
Normal file
@@ -0,0 +1,77 @@
|
||||
const axios = require('axios');
|
||||
|
||||
// Replace with your actual repository owner, repo, and personal access token
|
||||
const GITHUB_OWNER = 'hackertron';
|
||||
const GITHUB_REPO = 'TLSN-plugin-compiler';
|
||||
const GITHUB_TOKEN = 'GITHUB_PERSONAL_ACCESS_TOKEN';
|
||||
|
||||
const triggerPipeline = async (payload) => {
|
||||
const url = `https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/dispatches`;
|
||||
|
||||
try {
|
||||
const response = await axios.post(
|
||||
url,
|
||||
{
|
||||
event_type: 'build_pipeline',
|
||||
client_payload: payload
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'Accept': 'application/vnd.github.v3+json',
|
||||
'Authorization': `token ${GITHUB_TOKEN}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
console.log('Pipeline triggered successfully:', response.status);
|
||||
} catch (error) {
|
||||
console.error('Error triggering the pipeline:', error.response ? error.response.data : error.message);
|
||||
}
|
||||
};
|
||||
|
||||
// Example payload to send
|
||||
const payload = {
|
||||
"config.json": {
|
||||
"title": "Anime Quote Notarization",
|
||||
"description": "Notarize the response from the Anime Quote API",
|
||||
"steps": [
|
||||
{
|
||||
"title": "Fetch a random anime quote",
|
||||
"cta": "Get Quote",
|
||||
"action": "start"
|
||||
},
|
||||
{
|
||||
"title": "Collect API response",
|
||||
"description": "Retrieve the quote from the API",
|
||||
"cta": "Check response",
|
||||
"action": "two"
|
||||
},
|
||||
{
|
||||
"title": "Notarize the quote",
|
||||
"cta": "Notarize",
|
||||
"action": "three",
|
||||
"prover": true
|
||||
}
|
||||
],
|
||||
"hostFunctions": [
|
||||
"redirect",
|
||||
"notarize"
|
||||
],
|
||||
"cookies": [],
|
||||
"headers": [
|
||||
"animechan.io"
|
||||
],
|
||||
"requests": [
|
||||
{
|
||||
"url": "https://animechan.io/api/v1/quotes/random",
|
||||
"method": "GET"
|
||||
}
|
||||
]
|
||||
},
|
||||
"index.d.ts": "declare module 'main' {\n export function start(): I32;\n export function two(): I32;\n export function parseAnimeQuoteResp(): I32;\n export function three(): I32;\n export function config(): I32;\n}\n\ndeclare module 'extism:host' {\n interface user {\n redirect(ptr: I64): void;\n notarize(ptr: I64): I64;\n }\n}",
|
||||
"index.ts": "import icon from '../assets/icon.png';\nimport config_json from '../config.json';\nimport { redirect, notarize, outputJSON, getCookiesByHost, getHeadersByHost } from './utils/hf.js';\n\nexport function config() {\n outputJSON({\n ...config_json,\n icon: icon\n });\n}\n\nfunction isValidHost(urlString: string) {\n const url = new URL(urlString);\n return url.hostname === 'animechan.io';\n}\n\nexport function start() {\n if (!isValidHost(Config.get('tabUrl'))) {\n redirect('https://animechan.io');\n outputJSON(false);\n return;\n }\n outputJSON(true);\n}\n\nexport function two() {\n const headers = getHeadersByHost('animechan.io');\n\n outputJSON({\n url: 'https://animechan.io/api/v1/quotes/random',\n method: 'GET',\n headers: {\n 'Accept': 'application/json',\n },\n });\n}\n\nexport function parseAnimeQuoteResp() {\n const bodyString = Host.inputString();\n const params = JSON.parse(bodyString);\n\n if (params.data) {\n outputJSON(params.data);\n } else {\n outputJSON(false);\n }\n}\n\nexport function three() {\n const params = JSON.parse(Host.inputString());\n\n if (!params) {\n outputJSON(false);\n } else {\n const id = notarize({\n ...params,\n getSecretResponse: 'parseAnimeQuoteResp',\n });\n outputJSON(id);\n }\n}",
|
||||
"utils/hf.js": "function redirect(url) {\n const { redirect } = Host.getFunctions();\n const mem = Memory.fromString(url);\n redirect(mem.offset);\n}\n\nfunction notarize(options) {\n const { notarize } = Host.getFunctions();\n const mem = Memory.fromString(JSON.stringify(options));\n const idOffset = notarize(mem.offset);\n const id = Memory.find(idOffset).readString();\n return id;\n}\n\nfunction outputJSON(json) {\n Host.outputString(\n JSON.stringify(json),\n );\n}\n\nfunction getHeadersByHost(hostname) {\n const headers = JSON.parse(Config.get('headers'));\n if (!headers[hostname]) throw new Error(`cannot find headers for ${hostname}`);\n return headers[hostname];\n}\n\nmodule.exports = {\n redirect,\n notarize,\n outputJSON,\n getHeadersByHost,\n};"
|
||||
};
|
||||
|
||||
triggerPipeline(payload);
|
||||
14
TLSN-plugin-compiler/tsconfig.json
Normal file
14
TLSN-plugin-compiler/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": [],
|
||||
"types": [
|
||||
"@extism/js-pdk"
|
||||
],
|
||||
"noEmit": true,
|
||||
"resolveJsonModule": true,
|
||||
"esModuleInterop": true,
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user