diff --git a/examples/TicketTemplate/Makefile b/examples/TicketTemplate/Makefile new file mode 100644 index 00000000..f23ccd51 --- /dev/null +++ b/examples/TicketTemplate/Makefile @@ -0,0 +1,38 @@ +XMLSECTOOL=xmlsectool +KEYSTORE= +KEY=1 +KEYPASSWORD= +SIGNATURE_ALGORITHM=rsa-sha256 + +help: + # Needs a target, example: $$ make EntryToken.canonicalized.xml + # + # Let's say you have a TokenScript "EntryToken.xml" + #- to validate and canonicalize, add 'canonicalized' in the filename + @echo $$ make EntryToken.canonicalized.xml + # - to sign, use tsml as file extension: + @echo $$ make EntryToken.tsml + +%.canonicalized.xml : %.xml + # xmlsectool canonicalises automatically when needed, but leaving an xml:base attribute which creates trouble later. + # xmlstarlet does it neatly + # XML Canonicalization + xmlstarlet c14n $^ > $@ + # xmlsectool validates too, albeit adding xml:base with breaks schema. Example: + # JVMOPTS=-Djavax.xml.accessExternalDTD=all /opt/xmlsectool-2.0.0/xmlsectool.sh --validateSchema --xsd --schemaDirectory ../../schema --inFile $^ + # XML Validation + # if INVALID, run validation again with xmllint to get meaningful error + # then delete the canonicalized file + -xmlstarlet val --xsd http://tokenscript.org/2019/10/tokenscript/tokenscript.xsd $@ || (mv $@ $@.INVALID; xmllint --noout --schema http://tokenscript.org/2019/10/tokenscript/tokenscript.xsd $@.INVALID) + +%.tsml: %.canonicalized.xml +ifeq (,$(KEYSTORE)) + @echo ---------------- Keystore missing. Try this ---------------- + @echo $$ make KEYSTORE=shong.wang.p12 KEYPASSWORD=shong.wang $@ + @echo replace it with your .p12 file and your password + rm $^ +else + $(XMLSECTOOL) --sign --keyInfoKeyName 'AliPay' --digest SHA-256 --signatureAlgorithm http://www.w3.org/2001/04/xmldsig-more#$(SIGNATURE_ALGORITHM) --inFile $^ --outFile $@ --keystore $(KEYSTORE) --keystoreType PKCS12 --key $(KEY) --keyPassword $(KEYPASSWORD) --signaturePosition LAST + # removing the canonicalized created for validation + rm $^ +endif diff --git a/examples/TicketTemplate/TicketTemplate.en.shtml b/examples/TicketTemplate/TicketTemplate.en.shtml new file mode 100644 index 00000000..7a318baa --- /dev/null +++ b/examples/TicketTemplate/TicketTemplate.en.shtml @@ -0,0 +1,39 @@ + +
+ \ No newline at end of file diff --git a/examples/TicketTemplate/TicketTemplate.xml b/examples/TicketTemplate/TicketTemplate.xml new file mode 100644 index 00000000..3bf66283 --- /dev/null +++ b/examples/TicketTemplate/TicketTemplate.xml @@ -0,0 +1,93 @@ + + + + ]> + + + + An Example TokenScript Ticket + Some Example TokenScript Tickets + + + + + + 0x5e8c614cac6d140fbd5a454f41a1d5dc5da1a218 + + + + + + + + + + + + + &TicketTemplate.en; + + + &TicketTemplate.en; + + + + + + + + + TokenScript Template + + + + + + + + + + A blank template for Tokenscript + + + + + + Shanghai + + + London + + + + + + + + + You can fill this in later + + + + + + Shanghai Pudong Airport + + + London Heathrow Airport + + + + + + + + + diff --git a/examples/TicketTemplate/shared.css b/examples/TicketTemplate/shared.css new file mode 100644 index 00000000..99d8f9d4 --- /dev/null +++ b/examples/TicketTemplate/shared.css @@ -0,0 +1,84 @@ +/* + These are the key CSS attributes that will make a + Tokenscript card appear on Android and iOS +*/ + +html { + min-height: 10px; +} +body { + min-height: 10px; +} +.subtitle { + font-family: "SourceSansPro"; + font-weight: lighter; + font-size: 15px; + vertical-align: middle; + color: white; +} + +.ticket { + background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMzQ0cHgiIGhlaWdodD0iMTg0cHgiIHZpZXdCb3g9IjAgMCAzNDQgMTg0IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPCEtLSBHZW5lcmF0b3I6IFNrZXRjaCA2MSAoODk1ODEpIC0gaHR0cHM6Ly9za2V0Y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xZS0xNCwxMDcgTDAuMzEzODI4MTUzLDEwNi45OTY3ODIgQzguNDUzMjEzNjMsMTA2LjgyOTczIDE1LDEwMC4xNzk0MDcgMTUsOTIgQzE1LDgzLjcxNTcyODggOC4yODQyNzEyNSw3NyAtNC4yNjMyNTY0MWUtMTQsNzcgTC00LjI2MzI1NjQxZS0xNCw3NyBMLTQuMjYzMjU2NDFlLTE0LDE2IFoiIGlkPSJDb21iaW5lZC1TaGFwZSI+PC9wYXRoPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+'); + border-radius: 15px; + flex-direction: column; + background-size: contain; + width: 100%; + background-repeat: no-repeat; + /* Keep this height */ + height: 52.7vw; +} +.title { + font-family: "SourceSansPro"; + font-weight: 800; + font-size: 20px; + color: white; + width: 100%; + display: block; + margin-left: 5%; +} + +.bottom-section { + display: block; + padding-left: 12%; + padding-top: 7%; + align-items: center; + flex: 50%; + width: auto; +} + +.top-section { + display: flex; + flex-direction: row; + padding-top: 2%; + width: auto; +} + +.footer { + font-family: "SourceSansPro"; + font-weight: 500; + font-size: 14px; + color: white; + width: 100%; + display: block; + padding-top: 3%; + padding-bottom: 3%; +} + +/* flex row */ +.content { + display: flex; + flex-flow: row wrap; + justify-content: flex-start; +} + +.left-content { + width: 75%; +} + +.right-content { + background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMnB4IiBoZWlnaHQ9IjE4NHB4IiB2aWV3Qm94PSIwIDAgMiAxODQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDYxICg4OTU4MSkgLSBodHRwczovL3NrZXRjaC5jb20gLS0+CiAgICA8dGl0bGU+U2VwYXJhdG9ycy9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4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+'); + background-repeat: repeat-y; + margin-left: 3%; + height: 100%; + width: 20%; +} \ No newline at end of file