Status: idea → lose draft → draft → proposal → final review → stable
B://inject v1
High-level description:
If you provide content from the blockchain you are compatible with the B://inject protocol v1 if
The text
{{B://[TX]}}
will be replaced with the raw/unprocessed content of TXThe text
{{B://[TX]/}}
will be replaced with the processed content of the TX (nested injections)
Please share inputs and comments or see binject.bico.media for more information.
Introduction
The B://inject protocol v1 describes the concept "direct injection". It is a structured way of replacing a specific part of the content in one transaction with the full content of a specific other transaction.
Context
-
Content: When referencing
content
orcontent of a transaction
it is referring to data stored in a blockchain transaction after anOP_RETURN
code. -
Content provider: any website (often http(s) based) letting clients access files made from data on the blockchain.
-
TX: A transaction ID on the BSV blockchain. Also known as TXID. Consists of 64 hexadecimal signs. They will be referred to as
TX
or[TX]
. -
Current TX: The data of the transaction the client have asked for.
-
Parent TX: The data of the transaction referencing another transaction.
-
Target TX: The data of a transaction referenced to by content in another transaction.
Description
An "injection tag" is a text string consisting of a 'moustache' like syntax of {{...}}
directly surrounding a URL starting with B://
followed by a 64 chars hexadecimal transaction ID. Bandlebars are case insensitive.
Injection tags for v1 comes in 2 versions. One for raw data and one for processed data.
Raw data
Injection tags for raw data are formatted like {{B://[TX]}}
and indicates that the raw untreated data of the target TX must replace the tag. The replacement must be binary safe and there can be no added content like space or lines.
Processed data
Injection tags for processed data are formatted like {{B://[TX]/}}
and indicates that the content provider shall process the data before injectionig. The processing must include replacing aspects described in B://inject v1. The content provider is free to do any other processing of the content as long as its consistent with what would be presented had the client originally requested the target TX.
Hint
Inject tags for processed data may have added a hint at the end of the url to indicate to the content provider what the processing must include. In v1 there are two possible hint that can be given:
B64
formatted like{{B://[TX]/B64}}
B64/
formatted like{{B://[TX]/B64/}}
Processing a B64
hint
A B64
hint shall be processed by the following sequence before injecting it into the content of the current TX:
- If data is formatted like a dataURL all data up until and including first
,
must be discarded. - Data is base 64 decoded
Processing a B64/
hint
A B64/
hint shall be processed by the following sequence before injecting it into the content of the current TX:
- Any injections tags are processed as specified in v1
- If data is formatted like a dataURL all data up until and including first
,
must be discarded. - Data is base 64 decoded
- Any bandlebars are processed as specified in v1
Other aspects
Errors
If any error happens during the processing this must be signalled to the client by replacing the //
part of the url in the bandlebar with an emoji. Example:
{{B:❌66a6e1eb5ebecca707a03740069461a6b8fa9cca3753d00009f47d1d68a15d25}}
It is suggested to use "Cross Mark" as the default emoji but each content provider is free to select other emojis to indicate problems as they see fit. Examples could be 🔥 for internal server errors, ⌛ for timeouts and ☠️ if a base64 decoding fails based on a B64
hint.
Encoding
There shall be no encoding transformation during the flow of processing. This will result in all data being presented in the encoding of the current TX.
Implementation inputs
Any string that matches the following regular expression is a v1 bandlebar:
/\{\{B:\/\/[a-f\d]{64}(\/(B64\/?)?)?\}\}/ig
Examples:
-
✅
{{B://66a6e1eb5ebecca707a03740069461a6b8fa9cca3753d00009f49d1d68a15d25}}
-
✅
{{b://66A6E1eb5ebeccA707A03740069461a6b8fa9cca3753d00009f49d1d68a15d25}}
-
✖️
{{B://66a6e1eb5ebecca707a03740069461a6b8fa9cca3753d00009f49d1d68a15d25 }}
-
✖️
{ {B://66a6e1eb5ebecca707a03740069461a6b8fa9cca3753d00009f49d1d68a15d25} }
-
✅
{{B://66A6E1eb5ebeccA707A03740069461a6b8fa9cca3753d00009f49d1d68a15d25/}}
-
✖️
{{B://66a6e1eb5ebecca707a03740069461a6b8fa9cca3753d00009f49d1d68a15d25/ }}
-
✅
{{b://66A6E1eb5ebeccA707A03740069461a6b8fa9cca3753d00009f49d1d68a15d25/b64}}
-
✖️
{{B://66a6e1eb5ebecca707a03740069461a6b8fa9cca3753d00009f49d1d68a15d25/jpg}}
Base 64 and data urls
Data urls becomes pure content if the following is replaced with an empty string:
/^\s*data:[^,],/i
Please note that the original information about encoding is ignored and that v1 only supports base64.
Loops
As the content can only refer to previous transactions there will be no problem with circular references.
Please share inputs and comments or see binject.bico.media for more information.