@@ 2,6 2,4 @@ package js
// Autogenerated ; DO NOT EDIT
-var files = map[string]string{
- "webauthn.js": "// Base64 to ArrayBuffer\nlet bufferDecode = value => {\n return Uint8Array.from(atob(value), c => c.charCodeAt(0));\n}\n \n// ArrayBuffer to URLBase64\nlet bufferEncode = value => {\n return btoa(String.fromCharCode.apply(null, new Uint8Array(value)))\n .replace(/\\+/g, \"-\")\n .replace(/\\//g, \"_\")\n .replace(/=/g, \"\");;\n}\n\n// Webauthn module that makes it easy to work with BlobStash apps Webauthn API\nvar Webauthn = {\n login: (credentialRequestOptions, cb) => { \n credentialRequestOptions.publicKey.challenge = bufferDecode(credentialRequestOptions.publicKey.challenge);\n credentialRequestOptions.publicKey.allowCredentials.forEach(listItem => { listItem.id = bufferDecode(listItem.id) });\n\n navigator.credentials.get({\n publicKey: credentialRequestOptions.publicKey,\n }).then(assertion => {\n let authData = assertion.response.authenticatorData;\n let clientDataJSON = assertion.response.clientDataJSON;\n let rawId = assertion.rawId;\n let sig = assertion.response.signature;\n let userHandle = assertion.response.userHandle;\n let payload = {\n id: assertion.id,\n rawId: bufferEncode(rawId),\n type: assertion.type,\n response: { \n authenticatorData: bufferEncode(authData),\n clientDataJSON: bufferEncode(clientDataJSON),\n signature: bufferEncode(sig),\n userHandle: bufferEncode(userHandle),\n },\n };\n cb(payload);\n });\n },\n register: (credentialCreationOptions, cb) => {\n credentialCreationOptions.publicKey.challenge = bufferDecode(credentialCreationOptions.publicKey.challenge);\n credentialCreationOptions.publicKey.user.id = bufferDecode(credentialCreationOptions.publicKey.user.id);\n if (credentialCreationOptions.publicKey.excludeCredentials) {\n for (var i = 0; i < credentialCreationOptions.publicKey.excludeCredentials.length; i++) {\n credentialCreationOptions.publicKey.excludeCredentials[i].id = bufferDecode(credentialCreationOptions.publicKey.excludeCredentials[i].id);\n }\n }\n\n navigator.credentials.create({\n publicKey: credentialCreationOptions.publicKey\n }).then(credential => {\n let attestationObject = credential.response.attestationObject;\n let clientDataJSON = credential.response.clientDataJSON;\n let rawId = credential.rawId;\n let payload = {\n id: credential.id,\n rawId: bufferEncode(rawId),\n type: credential.type,\n response: {\n attestationObject: bufferEncode(attestationObject),\n clientDataJSON: bufferEncode(clientDataJSON),\n\t },\n };\n cb(payload);\n });\n },\n}\n",
-}
+var files = map[string]string{"webauthn.js": "// Base64 to ArrayBuffer\nlet bufferDecode = value => {\n return Uint8Array.from(atob(value), c => c.charCodeAt(0));\n}\n \n// ArrayBuffer to URLBase64\nlet bufferEncode = value => {\n return btoa(String.fromCharCode.apply(null, new Uint8Array(value)))\n .replace(/\\+/g, \"-\")\n .replace(/\\//g, \"_\")\n .replace(/=/g, \"\");;\n}\n\n// Webauthn module that makes it easy to work with BlobStash apps Webauthn API\nvar Webauthn = {\n login: (credentialRequestOptions, cb) => { \n credentialRequestOptions.publicKey.challenge = bufferDecode(credentialRequestOptions.publicKey.challenge);\n credentialRequestOptions.publicKey.allowCredentials.forEach(listItem => { listItem.id = bufferDecode(listItem.id) });\n\n navigator.credentials.get({\n publicKey: credentialRequestOptions.publicKey,\n }).then(assertion => {\n let authData = assertion.response.authenticatorData;\n let clientDataJSON = assertion.response.clientDataJSON;\n let rawId = assertion.rawId;\n let sig = assertion.response.signature;\n let userHandle = assertion.response.userHandle;\n let payload = {\n id: assertion.id,\n rawId: bufferEncode(rawId),\n type: assertion.type,\n response: { \n authenticatorData: bufferEncode(authData),\n clientDataJSON: bufferEncode(clientDataJSON),\n signature: bufferEncode(sig),\n userHandle: bufferEncode(userHandle),\n },\n };\n cb(payload);\n });\n },\n register: (credentialCreationOptions, cb) => {\n credentialCreationOptions.publicKey.challenge = bufferDecode(credentialCreationOptions.publicKey.challenge);\n credentialCreationOptions.publicKey.user.id = bufferDecode(credentialCreationOptions.publicKey.user.id);\n if (credentialCreationOptions.publicKey.excludeCredentials) {\n for (var i = 0; i < credentialCreationOptions.publicKey.excludeCredentials.length; i++) {\n credentialCreationOptions.publicKey.excludeCredentials[i].id = bufferDecode(credentialCreationOptions.publicKey.excludeCredentials[i].id);\n }\n }\n\n navigator.credentials.create({\n publicKey: credentialCreationOptions.publicKey\n }).then(credential => {\n let attestationObject = credential.response.attestationObject;\n let clientDataJSON = credential.response.clientDataJSON;\n let rawId = credential.rawId;\n let payload = {\n id: credential.id,\n rawId: bufferEncode(rawId),\n type: credential.type,\n response: {\n attestationObject: bufferEncode(attestationObject),\n clientDataJSON: bufferEncode(clientDataJSON),\n\t },\n };\n cb(payload);\n });\n },\n}\n"}
@@ 0,0 1,29 @@
+package main
+
+import (
+ "io/ioutil"
+ "path/filepath"
+ "strings"
+
+ . "github.com/dave/jennifer/jen"
+)
+
+func main() {
+ files, err := filepath.Glob("js/*.js")
+ if err != nil {
+ panic(err)
+ }
+ f := NewFile("js")
+ f.Comment("Autogenerated ; DO NOT EDIT")
+ f.Line()
+ f.Var().Id("files").Op("=").Map(String()).String().Values(DictFunc(func(d Dict) {
+ for _, fi := range files {
+ dat, err := ioutil.ReadFile(fi)
+ if err != nil {
+ panic(err)
+ }
+ d[Lit(strings.Replace(fi, "js/", "", 1))] = Lit(string(dat))
+ }
+ }))
+ f.Save("pkg/js/files.go")
+}