-
Notifications
You must be signed in to change notification settings - Fork 21
TLSN Provider API
This page is a reference for the TLSN Extension's Provider API. TLSN Extension injects the provider API into websites visited by its users using the window.tlsn
provider object.
This method is used to request a website to be connected to the extension. Once a provider is connected, a website can use the provider API to suggest actions to the extension.
None.
A promise that resolves to the full provider API object.
const client = await tlsn.connect();
This method is used to request proof history from the extension.
-
method
: a glob pattern matching request method of the proof. (e.g.get
,{get,post}
,*
) -
url
: a pattern matching request url of the proof. (e.g.**
,https://swapi.dev/**
) -
metadata
: an object containing glob patterns of matching metadata about the request. (e.g.{id: "swapi-proof-1"}
)
A promise that resolves to an array of proof header data.
type ProofHeader = {
id: string;
method: string;
notaryUrl: string;
time: string;
url: string;
websocketProxyUrl: string;
}
const proofs = await client.getHistory('*', '**', {id: '0x1234567890'});
This method is used to request full data of a specific proof id.
-
id
: id of a proof
A promise that resolves to the proof data or null.
type ProofData = {
notaryUrl: string;
session: Session; // https:/tlsnotary/tlsn-js/blob/main/src/types.ts#L7-L11;
substrings: Substrings; // https:/tlsnotary/tlsn-js/blob/main/src/types.ts#L73-L76
}
const proof = await client.getProof('FE512M1.72007336176400000000000000000000');
This method is used to request notarization of a request.
-
url
: url of the request -
requestOptions
: An object containing the following:-
method
:GET
,POST
,PUT
, etc -
headers
: a map of headers -
body
: string content of the request body
-
-
proofConfig
: An object containing the following:-
notaryUrl
: url of the notary (default to the extension setting) -
websocketProxyUrl
: url of the websocket proxy (default to extension setting) -
maxSentData
: Max Sent Data allowed (default to extension setting) -
maxRecvData
Max Recv Data allowed (default to extension setting) -
maxTranscriptSize
: Max transcript size allowed (default to extension setting) -
metadata
: a object of metadata
-
A promise that resolves to the proof data.
type ProofData = {
notaryUrl: string;
session: Session; // https:/tlsnotary/tlsn-js/blob/main/src/types.ts#L7-L11;
substrings: Substrings; // https:/tlsnotary/tlsn-js/blob/main/src/types.ts#L73-L76
}
const proof = await client.notarize(
'https://swapi.dev/api/planets/9',
{
method: 'get',
headers: {
"Accept": "application/json",
"Accept-Encoding": "identity",
"Connection": "close",
"Cookie": "csrftoken=blahblahblah",
}
},
{
metadata: {id: 'test-1'},
}
);
This method is used to request installation of a plugin.
-
url
: url to the plugin wasm file -
metadata
: a object of metadata about the plugin
A promise that resolves to plugin id.
const pluginId = await client.installPlugin(
'https:/tlsnotary/tlsn-extension/raw/main/plugins/twitter_profile/index.wasm',
{ id: 'demo-plugin-1' }
);
This method is used to request installation of a plugin.
-
url
: a glob pattern matching url to the plugin wasm file -
origin
: a glob pattern matching origin that request installation of the plugin -
metadata
: a object of glob patterns matching metadata about the plugin
A promise that resolves to plugin config.
type PluginConfig = {
hash: string;
title: string;
description: string;
icon?: string;
steps?: StepConfig[];
hostFunctions?: string[];
cookies?: string[];
headers?: string[];
requests: { method: string; url: string }[];
notaryUrls?: string[];
proxyUrls?: string[];
};
const plugin = await client.getPlugins('**', 'https://swapi.dev', {id: 'demo-plugin-1'});
This method is used to request execution of a plugin.
-
id
: id of a plugin
A promise that resolves to the proof data.
type ProofData = {
notaryUrl: string;
session: Session; // https:/tlsnotary/tlsn-js/blob/main/src/types.ts#L7-L11;
substrings: Substrings; // https:/tlsnotary/tlsn-js/blob/main/src/types.ts#L73-L76
}
const plugin = await client.runPlugin("6931d2ad63340d3a1fb1a5c1e3f4454c5a518164d6de5ad272e744832355ee02");