From 235d36f878ee7dae913097e6fca527bde4b1712e Mon Sep 17 00:00:00 2001 From: jndaniels Date: Fri, 6 Dec 2024 16:38:58 -0600 Subject: [PATCH] MIGRATION moving to couchDB + pouchDB --- .../DB/20241206023559_Point Data setup.js | 17 + .wappler/project.json | 58 +- .../app/modules/connections/dbCouch.json | 19 + .../targets/Development/databases/DB.json | 119 +- .../Development/databases/dbCouch.json | 57 + .../files/js/connections/dbCouch.js | 2 + app/api/insert.json | 18 +- app/api/qUpsert.json | 87 +- app/modules/connections/dbCouch.json | 19 + package.json | 3 +- public/ERTSQlite.db | Bin 98304 -> 102400 bytes public/PDF/dummyFunctions.js | 4 + public/js/bundle.js | 1069 +++++++++++++++++ public/js/connections/dbCouch.js | 2 + public/js/extraFunctions.js | 9 + public/js/libProcessScript.js | 2 +- views/success.ejs | 3 +- 17 files changed, 1329 insertions(+), 159 deletions(-) create mode 100644 .wappler/migrations/DB/20241206023559_Point Data setup.js create mode 100644 .wappler/targets/Development/app/modules/connections/dbCouch.json create mode 100644 .wappler/targets/Development/databases/dbCouch.json create mode 100644 .wappler/targets/Development/files/js/connections/dbCouch.js create mode 100644 app/modules/connections/dbCouch.json create mode 100644 public/js/bundle.js create mode 100644 public/js/connections/dbCouch.js create mode 100644 public/js/extraFunctions.js diff --git a/.wappler/migrations/DB/20241206023559_Point Data setup.js b/.wappler/migrations/DB/20241206023559_Point Data setup.js new file mode 100644 index 0000000..bc24da1 --- /dev/null +++ b/.wappler/migrations/DB/20241206023559_Point Data setup.js @@ -0,0 +1,17 @@ + +exports.up = function(knex) { + return knex.schema + .table('ertPointData', async function (table) { + table.boolean('remove').comment('true means ready to delete').alter(); + table.string('recordID').comment('generateRandomIdentifier'); + }) + +}; + +exports.down = function(knex) { + return knex.schema + .table('ertPointData', async function (table) { + table.text('remove').comment('').alter(); + table.dropColumn('recordID'); + }) +}; diff --git a/.wappler/project.json b/.wappler/project.json index b0dd11f..8f2070b 100644 --- a/.wappler/project.json +++ b/.wappler/project.json @@ -97,8 +97,7 @@ "id": 44250508, "ssh-key-file": "/.wappler/.ssh/ertfastfiller_ed25519.pub", "fingerprint": "64:50:e4:41:ed:26:78:df:fb:27:4a:cf:a7:58:02:2a", - "type": "ed25519", - "name": "ertfastfiller_ed25519" + "type": "ed25519" }, "ertfastfiller_rsa": { "id": 44250710, @@ -126,32 +125,77 @@ "ssh-key-file": "/.wappler/.ssh/ertfastfiller_ed25519.pub", "fingerprint": "64:50:e4:41:ed:26:78:df:fb:27:4a:cf:a7:58:02:2a", "type": "ed25519", - "name": "ertfastfiller_ed25519" + "name": "ertfastfiller_ed25519", + "fa": { + "prefix": "fas", + "iconName": "user-lock", + "classes": [ + "fa-lg", + "color-orange" + ], + "transform": {} + } }, { "id": 43691420, "public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK/IniPilvW2mZhH12xp+bw3GUKNtpQtZ8EMLQGkWT3z id_ed25519.pub", "name": "jndaned25519", - "fingerprint": "6e:95:fc:ae:d5:d1:9c:a0:06:d8:99:98:f4:16:84:f4" + "fingerprint": "6e:95:fc:ae:d5:d1:9c:a0:06:d8:99:98:f4:16:84:f4", + "fa": { + "prefix": "fas", + "iconName": "key", + "classes": [ + "fa-lg", + "color-blue" + ], + "transform": {} + } }, { "id": 44250710, "fingerprint": "9f:0e:25:d8:10:fc:e5:d4:94:38:92:74:8a:81:cd:16", "ssh-key-file": "/.wappler/.ssh/ertfastfiller_rsa.pub", "type": "rsa", - "name": "ertfastfiller_rsa" + "name": "ertfastfiller_rsa", + "fa": { + "prefix": "fas", + "iconName": "user-lock", + "classes": [ + "fa-lg", + "color-orange" + ], + "transform": {} + } }, { "id": 38166791, "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDixLL6TG8sd67jEkoHjtgXO1K9ScOHtGyX6n1mTl2CLoMeBE1ZwR6TOU7cjwcJ+crKUZMJfyB99h01qhD3DrBE388cE0NEu/ytUnbnys5ecD/NUiOAHL/ZMxJ7Yn6ceoband1C/Gz1GYA/guU2qMu1KA81jqDFA7ytR/riFoJq3fICuTy1++g6/T0EZqxaxzlM2OJNBn89UAhbAKWCRz7hYFhE53dXxI76rwiOm6Fyn9ksxA9G2zW31Ziy6JDUJVy9mahEzTjU4cJNALf61fblWLlxzTTh6c0Yjq2Ontwdp8xqr1NOERMKNraolXHcy7ml2T0spx9DAt13LtAfDubF\n", "name": "DODriverSignin-wappler-prod", - "fingerprint": "f8:b4:24:a1:77:4f:02:4b:97:8a:c4:b1:12:88:4b:59" + "fingerprint": "f8:b4:24:a1:77:4f:02:4b:97:8a:c4:b1:12:88:4b:59", + "fa": { + "prefix": "fas", + "iconName": "key", + "classes": [ + "fa-lg", + "color-blue" + ], + "transform": {} + } }, { "id": 44250460, "public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGsEr/uTng6hsmeec9KZNZ/G5QMqynZ3bOpGm6r/FyXz jndan@DESKTOP-N026HO3", "name": "DO_Developer_12_2024", - "fingerprint": "f2:60:83:0a:b3:4e:c7:7b:51:d1:a8:28:88:10:1b:07" + "fingerprint": "f2:60:83:0a:b3:4e:c7:7b:51:d1:a8:28:88:10:1b:07", + "fa": { + "prefix": "fas", + "iconName": "key", + "classes": [ + "fa-lg", + "color-blue" + ], + "transform": {} + } } ] } diff --git a/.wappler/targets/Development/app/modules/connections/dbCouch.json b/.wappler/targets/Development/app/modules/connections/dbCouch.json new file mode 100644 index 0000000..42d47b0 --- /dev/null +++ b/.wappler/targets/Development/app/modules/connections/dbCouch.json @@ -0,0 +1,19 @@ +{ + "name": "dbCouch", + "module": "dbconnector", + "action": "connect", + "options": { + "client": "couchdb", + "connection": { + "host": "host.docker.internal", + "port": 9913, + "user": "trainer", + "password": "sGynUdlM9cuLtUdc", + "database": "db_training" + }, + "databaseResource": "Local / dbCouch", + "cloudDatabaseName": "db_training", + "tz": "utc" + }, + "fileName": "dbCouch.json" +} \ No newline at end of file diff --git a/.wappler/targets/Development/databases/DB.json b/.wappler/targets/Development/databases/DB.json index 50cc3cd..0b5295c 100644 --- a/.wappler/targets/Development/databases/DB.json +++ b/.wappler/targets/Development/databases/DB.json @@ -55,71 +55,6 @@ } } }, - "ertPointData": { - "db": {}, - "columns": { - "ID": { - "db": { - "type": "integer", - "primary": true, - "unique": false, - "nullable": false - } - }, - "Owner": { - "db": { - "type": "text", - "primary": false, - "unique": false, - "nullable": true - } - }, - "numSection": { - "db": { - "type": "text", - "primary": false, - "unique": false, - "nullable": true - } - }, - "numSectionValue": { - "db": { - "type": "text", - "primary": false, - "unique": false, - "nullable": true - } - }, - "remove": { - "db": { - "type": "text", - "primary": false, - "unique": false, - "nullable": true - }, - "db_edits": { - "type": "boolean", - "comment": "true means ready to delete" - }, - "status": { - "modified": true - } - }, - "recordID": { - "db_edits": { - "type": "string", - "name": "recordID", - "comment": "generateRandomIdentifier" - }, - "status": { - "new": true - } - } - }, - "status": { - "children_modified": true - } - }, "security": { "columns": { "id": { @@ -248,6 +183,60 @@ } } } + }, + "ertPointData": { + "db": {}, + "columns": { + "ID": { + "db": { + "type": "integer", + "primary": true, + "unique": false, + "nullable": false + } + }, + "Owner": { + "db": { + "type": "text", + "primary": false, + "unique": false, + "nullable": true + } + }, + "numSection": { + "db": { + "type": "text", + "primary": false, + "unique": false, + "nullable": true + } + }, + "numSectionValue": { + "db": { + "type": "text", + "primary": false, + "unique": false, + "nullable": true + } + }, + "remove": { + "db": { + "type": "boolean", + "primary": false, + "unique": false, + "nullable": true + } + }, + "recordID": { + "db": { + "type": "string", + "maxLength": 255, + "primary": false, + "unique": false, + "nullable": true + } + } + } } }, "views": {} diff --git a/.wappler/targets/Development/databases/dbCouch.json b/.wappler/targets/Development/databases/dbCouch.json new file mode 100644 index 0000000..4455a11 --- /dev/null +++ b/.wappler/targets/Development/databases/dbCouch.json @@ -0,0 +1,57 @@ +{ + "type": "couchdb", + "connection": { + "host": "host.docker.internal", + "port": 9913, + "user": "trainer", + "password": "sGynUdlM9cuLtUdc", + "database": "db_training" + }, + "direct": true, + "databaseResource": "Local / dbCouch", + "cloudDatabaseName": "db_training", + "schema": { + "partitioned": false, + "tables": { + "da": { + "meta": [ + { + "name": "_id", + "type": "objectId" + }, + { + "name": "db_fullName", + "type": "text" + }, + { + "name": "db_licenseNumber", + "type": "text" + }, + { + "name": "db_employeeID", + "type": "text" + } + ] + }, + "ert": { + "meta": [ + { + "name": "_id", + "type": "objectId" + }, + { + "name": "docPDF", + "type": "file" + } + ], + "status": { + "modified": true + }, + "db_edits": { + "name": "daData" + } + } + }, + "views": {} + } +} diff --git a/.wappler/targets/Development/files/js/connections/dbCouch.js b/.wappler/targets/Development/files/js/connections/dbCouch.js new file mode 100644 index 0000000..49e0325 --- /dev/null +++ b/.wappler/targets/Development/files/js/connections/dbCouch.js @@ -0,0 +1,2 @@ +dmx.databases = dmx.databases || {}; +dmx.databases['dbCouch'] = {type: "pouchdb", remote: "http://host.docker.internal:9913/db_training"} \ No newline at end of file diff --git a/app/api/insert.json b/app/api/insert.json index be8d5ce..f61c2e3 100644 --- a/app/api/insert.json +++ b/app/api/insert.json @@ -85,37 +85,43 @@ "table": "da", "column": "db_fullName", "type": "text", - "value": "{{$_POST.db_fullName}}" + "value": "{{$_POST.db_fullName}}", + "recid": 1 }, { "table": "da", "column": "db_licenseNumber", "type": "text", - "value": "{{$_POST.db_licenseNumber}}" + "value": "{{$_POST.db_licenseNumber}}", + "recid": 2 }, { "table": "da", "column": "db_stateIssue", "type": "text", - "value": "{{$_POST.db_stateIssue}}" + "value": "{{$_POST.db_stateIssue}}", + "recid": 3 }, { "table": "da", "column": "db_employeeID", "type": "number", - "value": "{{$_POST.db_employeeID}}" + "value": "{{$_POST.db_employeeID}}", + "recid": 4 }, { "table": "da", "column": "owner", "type": "text", - "value": "{{$_POST.owner}}" + "value": "{{$_POST.owner}}", + "recid": 5 }, { "table": "da", "column": "db_SignatureData", "type": "text", - "value": "{{$_POST.db_signatureData}}" + "value": "{{$_POST.db_signatureData}}", + "recid": 6 } ], "table": "da", diff --git a/app/api/qUpsert.json b/app/api/qUpsert.json index 4d09b6c..5af5269 100644 --- a/app/api/qUpsert.json +++ b/app/api/qUpsert.json @@ -26,85 +26,16 @@ { "type": "text", "name": "remove" + }, + { + "type": "text", + "name": "recordID" + }, + { + "type": "number", + "name": "ID" } ] }, - "exec": { - "steps": { - "name": "insert", - "module": "dbupdater", - "action": "insert", - "options": { - "connection": "DB", - "sql": { - "type": "insert", - "values": [ - { - "table": "ertPointData", - "column": "Owner", - "type": "text", - "value": "{{$_POST.Owner}}" - }, - { - "table": "ertPointData", - "column": "numSection", - "type": "text", - "value": "{{$_POST.numSection}}" - }, - { - "table": "ertPointData", - "column": "numSectionValue", - "type": "text", - "value": "{{$_POST.numSectionValue}}" - }, - { - "table": "ertPointData", - "column": "remove", - "type": "text", - "value": "{{$_POST.remove}}" - } - ], - "table": "ertPointData", - "returning": "ID", - "query": "insert into `ertPointData` (`Owner`, `numSection`, `numSectionValue`, `remove`) values (?, ?, ?, ?) returning `ID`", - "params": [ - { - "name": ":P1", - "type": "expression", - "value": "{{$_POST.Owner}}", - "test": "" - }, - { - "name": ":P2", - "type": "expression", - "value": "{{$_POST.numSection}}", - "test": "" - }, - { - "name": ":P3", - "type": "expression", - "value": "{{$_POST.numSectionValue}}", - "test": "" - }, - { - "name": ":P4", - "type": "expression", - "value": "{{$_POST.remove}}", - "test": "" - } - ] - } - }, - "meta": [ - { - "name": "identity", - "type": "text" - }, - { - "name": "affected", - "type": "number" - } - ] - } - } + "exec": {} } \ No newline at end of file diff --git a/app/modules/connections/dbCouch.json b/app/modules/connections/dbCouch.json new file mode 100644 index 0000000..42d47b0 --- /dev/null +++ b/app/modules/connections/dbCouch.json @@ -0,0 +1,19 @@ +{ + "name": "dbCouch", + "module": "dbconnector", + "action": "connect", + "options": { + "client": "couchdb", + "connection": { + "host": "host.docker.internal", + "port": 9913, + "user": "trainer", + "password": "sGynUdlM9cuLtUdc", + "database": "db_training" + }, + "databaseResource": "Local / dbCouch", + "cloudDatabaseName": "db_training", + "tz": "utc" + }, + "fileName": "dbCouch.json" +} \ No newline at end of file diff --git a/package.json b/package.json index ebf2b03..1b7f1af 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "sqlite3": "^5.1.6", "unzipper": "^0.12.1", "uuid": "^10.0.0", - "sharp": "^0.32.6" + "sharp": "^0.32.6", + "nano": "^10.1.0" }, "nodemonConfig": { "watch": [ diff --git a/public/ERTSQlite.db b/public/ERTSQlite.db index fed801a5b48bd388a37bfe89e3e206343707bba7..b96fc415e120e2a5b146d4f7185f7b13a6eb9af9 100644 GIT binary patch delta 814 zcmZo@U~5>wHbGkO5(5K+BoOlhF(VMmPt-BizQmwcw1}5|Edw9xLRNle-rKywJgHm{ zID5HlxGOkWIV#zu*s56<^64^P**MXQnX55XfL+|!n6asFawChVxT(2me0E-HMSMwW zZb5uvPDyGJP)Ks}S{Au_AR|FRBf--pLBZ26#MRw3NWsrPM8PlA$45sY!M{8&wJ1R$ z#5E!W$jd9u4Ngri$;{8gA{3UGQ<@4FFG|hLF9ULu^7C_26Z3$Yi&B&Gi&8-LlqD7= zXCxMB7@3-CD(ff&1bO;821P1(yGBABqNxe=>C?tIs2`F+egL@>n;)EmTpdGP6+#@H zd|VZjQj1Cg@-y>FToOwXm8j|~XGjPT>n*Il+PsjJhlz#z0mGTe8`%$VunDjMI&os<=2)H!j9iTYK)aA^ zPqr`QVc}O};J?W~pFfOWZL^?&7{7rY3oAn)Bdd{tk%^&^fti7kv8kzLJUGr2K#`_U qoLW*^pqEw5!Z>;6r7tp@!~9oG0BZfrKQVxJQGvoT0mgzw0s;UVcl4kD delta 309 zcmZozz}C>fHbGkOA_D`11Q5f3^h6zF?TZY0MT>a3A29H-E@a|o=Dp1;%#+IXfU}p& zhP#53m7|hPlU53_)6Dv2z@?2n40s7{exS$|ovmn^4l*E)oX6GPR#}HSA5Jx8;R|Tb% z#L0pDGLyqO6($$+7jNR9WWdNgd9r;W7c+kt1OH9_`TSu(uX*rq4)b3%VNrs?G6BW{ E0M>C>1^@s6 diff --git a/public/PDF/dummyFunctions.js b/public/PDF/dummyFunctions.js index b7e275e..d304f33 100644 --- a/public/PDF/dummyFunctions.js +++ b/public/PDF/dummyFunctions.js @@ -1,4 +1,8 @@ // JavaScript Document + + + + console.log("LIBRARY: dummyFunctions.js") function myFunction() { let myVar = 'Hello, Wappler!'; diff --git a/public/js/bundle.js b/public/js/bundle.js new file mode 100644 index 0000000..f6e5203 --- /dev/null +++ b/public/js/bundle.js @@ -0,0 +1,1069 @@ +(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i> 5] >>> i % 32 & 0xff; + const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16); + output.push(hex); + } + return output; +} + +/** + * Calculate output length with padding and bit length + */ +function getOutputLength(inputLength8) { + return (inputLength8 + 64 >>> 9 << 4) + 14 + 1; +} + +/* + * Calculate the MD5 of an array of little-endian words, and a bit length. + */ +function wordsToMd5(x, len) { + /* append padding */ + x[len >> 5] |= 0x80 << len % 32; + x[getOutputLength(len) - 1] = len; + let a = 1732584193; + let b = -271733879; + let c = -1732584194; + let d = 271733878; + for (let i = 0; i < x.length; i += 16) { + const olda = a; + const oldb = b; + const oldc = c; + const oldd = d; + a = md5ff(a, b, c, d, x[i], 7, -680876936); + d = md5ff(d, a, b, c, x[i + 1], 12, -389564586); + c = md5ff(c, d, a, b, x[i + 2], 17, 606105819); + b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330); + a = md5ff(a, b, c, d, x[i + 4], 7, -176418897); + d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426); + c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341); + b = md5ff(b, c, d, a, x[i + 7], 22, -45705983); + a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416); + d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417); + c = md5ff(c, d, a, b, x[i + 10], 17, -42063); + b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162); + a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682); + d = md5ff(d, a, b, c, x[i + 13], 12, -40341101); + c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290); + b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329); + a = md5gg(a, b, c, d, x[i + 1], 5, -165796510); + d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632); + c = md5gg(c, d, a, b, x[i + 11], 14, 643717713); + b = md5gg(b, c, d, a, x[i], 20, -373897302); + a = md5gg(a, b, c, d, x[i + 5], 5, -701558691); + d = md5gg(d, a, b, c, x[i + 10], 9, 38016083); + c = md5gg(c, d, a, b, x[i + 15], 14, -660478335); + b = md5gg(b, c, d, a, x[i + 4], 20, -405537848); + a = md5gg(a, b, c, d, x[i + 9], 5, 568446438); + d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690); + c = md5gg(c, d, a, b, x[i + 3], 14, -187363961); + b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501); + a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467); + d = md5gg(d, a, b, c, x[i + 2], 9, -51403784); + c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473); + b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734); + a = md5hh(a, b, c, d, x[i + 5], 4, -378558); + d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463); + c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562); + b = md5hh(b, c, d, a, x[i + 14], 23, -35309556); + a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060); + d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353); + c = md5hh(c, d, a, b, x[i + 7], 16, -155497632); + b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640); + a = md5hh(a, b, c, d, x[i + 13], 4, 681279174); + d = md5hh(d, a, b, c, x[i], 11, -358537222); + c = md5hh(c, d, a, b, x[i + 3], 16, -722521979); + b = md5hh(b, c, d, a, x[i + 6], 23, 76029189); + a = md5hh(a, b, c, d, x[i + 9], 4, -640364487); + d = md5hh(d, a, b, c, x[i + 12], 11, -421815835); + c = md5hh(c, d, a, b, x[i + 15], 16, 530742520); + b = md5hh(b, c, d, a, x[i + 2], 23, -995338651); + a = md5ii(a, b, c, d, x[i], 6, -198630844); + d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415); + c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905); + b = md5ii(b, c, d, a, x[i + 5], 21, -57434055); + a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571); + d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606); + c = md5ii(c, d, a, b, x[i + 10], 15, -1051523); + b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799); + a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359); + d = md5ii(d, a, b, c, x[i + 15], 10, -30611744); + c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380); + b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649); + a = md5ii(a, b, c, d, x[i + 4], 6, -145523070); + d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379); + c = md5ii(c, d, a, b, x[i + 2], 15, 718787259); + b = md5ii(b, c, d, a, x[i + 9], 21, -343485551); + a = safeAdd(a, olda); + b = safeAdd(b, oldb); + c = safeAdd(c, oldc); + d = safeAdd(d, oldd); + } + return [a, b, c, d]; +} + +/* + * Convert an array bytes to an array of little-endian words + * Characters >255 have their high-byte silently ignored. + */ +function bytesToWords(input) { + if (input.length === 0) { + return []; + } + const length8 = input.length * 8; + const output = new Uint32Array(getOutputLength(length8)); + for (let i = 0; i < length8; i += 8) { + output[i >> 5] |= (input[i / 8] & 0xff) << i % 32; + } + return output; +} + +/* + * Add integers, wrapping at 2^32. This uses 16-bit operations internally + * to work around bugs in some JS interpreters. + */ +function safeAdd(x, y) { + const lsw = (x & 0xffff) + (y & 0xffff); + const msw = (x >> 16) + (y >> 16) + (lsw >> 16); + return msw << 16 | lsw & 0xffff; +} + +/* + * Bitwise rotate a 32-bit number to the left. + */ +function bitRotateLeft(num, cnt) { + return num << cnt | num >>> 32 - cnt; +} + +/* + * These functions implement the four basic operations the algorithm uses. + */ +function md5cmn(q, a, b, x, s, t) { + return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b); +} +function md5ff(a, b, c, d, x, s, t) { + return md5cmn(b & c | ~b & d, a, b, x, s, t); +} +function md5gg(a, b, c, d, x, s, t) { + return md5cmn(b & d | c & ~d, a, b, x, s, t); +} +function md5hh(a, b, c, d, x, s, t) { + return md5cmn(b ^ c ^ d, a, b, x, s, t); +} +function md5ii(a, b, c, d, x, s, t) { + return md5cmn(c ^ (b | ~d), a, b, x, s, t); +} +var _default = exports.default = md5; +},{}],4:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto); +var _default = exports.default = { + randomUUID +}; +},{}],5:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _default = exports.default = '00000000-0000-0000-0000-000000000000'; +},{}],6:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _validate = _interopRequireDefault(require("./validate.js")); +function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +function parse(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); + } + let v; + const arr = new Uint8Array(16); + + // Parse ########-....-....-....-............ + arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; + arr[1] = v >>> 16 & 0xff; + arr[2] = v >>> 8 & 0xff; + arr[3] = v & 0xff; + + // Parse ........-####-....-....-............ + arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; + arr[5] = v & 0xff; + + // Parse ........-....-####-....-............ + arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; + arr[7] = v & 0xff; + + // Parse ........-....-....-####-............ + arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; + arr[9] = v & 0xff; + + // Parse ........-....-....-....-############ + // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) + arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; + arr[11] = v / 0x100000000 & 0xff; + arr[12] = v >>> 24 & 0xff; + arr[13] = v >>> 16 & 0xff; + arr[14] = v >>> 8 & 0xff; + arr[15] = v & 0xff; + return arr; +} +var _default = exports.default = parse; +},{"./validate.js":20}],7:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _default = exports.default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i; +},{}],8:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = rng; +// Unique ID creation requires a high quality random # generator. In the browser we therefore +// require the crypto API and do not support built-in fallback to lower quality random number +// generators (like Math.random()). + +let getRandomValues; +const rnds8 = new Uint8Array(16); +function rng() { + // lazy load so that environments that need to polyfill have a chance to do so + if (!getRandomValues) { + // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. + getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto); + if (!getRandomValues) { + throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); + } + } + return getRandomValues(rnds8); +} +},{}],9:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +// Adapted from Chris Veness' SHA1 code at +// http://www.movable-type.co.uk/scripts/sha1.html +function f(s, x, y, z) { + switch (s) { + case 0: + return x & y ^ ~x & z; + case 1: + return x ^ y ^ z; + case 2: + return x & y ^ x & z ^ y & z; + case 3: + return x ^ y ^ z; + } +} +function ROTL(x, n) { + return x << n | x >>> 32 - n; +} +function sha1(bytes) { + const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6]; + const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0]; + if (typeof bytes === 'string') { + const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape + + bytes = []; + for (let i = 0; i < msg.length; ++i) { + bytes.push(msg.charCodeAt(i)); + } + } else if (!Array.isArray(bytes)) { + // Convert Array-like to Array + bytes = Array.prototype.slice.call(bytes); + } + bytes.push(0x80); + const l = bytes.length / 4 + 2; + const N = Math.ceil(l / 16); + const M = new Array(N); + for (let i = 0; i < N; ++i) { + const arr = new Uint32Array(16); + for (let j = 0; j < 16; ++j) { + arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3]; + } + M[i] = arr; + } + M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32); + M[N - 1][14] = Math.floor(M[N - 1][14]); + M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff; + for (let i = 0; i < N; ++i) { + const W = new Uint32Array(80); + for (let t = 0; t < 16; ++t) { + W[t] = M[i][t]; + } + for (let t = 16; t < 80; ++t) { + W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1); + } + let a = H[0]; + let b = H[1]; + let c = H[2]; + let d = H[3]; + let e = H[4]; + for (let t = 0; t < 80; ++t) { + const s = Math.floor(t / 20); + const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0; + e = d; + d = c; + c = ROTL(b, 30) >>> 0; + b = a; + a = T; + } + H[0] = H[0] + a >>> 0; + H[1] = H[1] + b >>> 0; + H[2] = H[2] + c >>> 0; + H[3] = H[3] + d >>> 0; + H[4] = H[4] + e >>> 0; + } + return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff]; +} +var _default = exports.default = sha1; +},{}],10:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +exports.unsafeStringify = unsafeStringify; +var _validate = _interopRequireDefault(require("./validate.js")); +function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +/** + * Convert array of 16 byte values to UUID string format of the form: + * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + */ +const byteToHex = []; +for (let i = 0; i < 256; ++i) { + byteToHex.push((i + 0x100).toString(16).slice(1)); +} +function unsafeStringify(arr, offset = 0) { + // Note: Be careful editing this code! It's been tuned for performance + // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 + // + // Note to future-self: No, you can't remove the `toLowerCase()` call. + // REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351 + return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); +} +function stringify(arr, offset = 0) { + const uuid = unsafeStringify(arr, offset); + // Consistency check for valid UUID. If this throws, it's likely due to one + // of the following: + // - One or more input array values don't map to a hex octet (leading to + // "undefined" in the uuid) + // - Invalid input values for the RFC `version` or `variant` fields + if (!(0, _validate.default)(uuid)) { + throw TypeError('Stringified UUID is invalid'); + } + return uuid; +} +var _default = exports.default = stringify; +},{"./validate.js":20}],11:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _rng = _interopRequireDefault(require("./rng.js")); +var _stringify = require("./stringify.js"); +function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +// **`v1()` - Generate time-based UUID** +// +// Inspired by https://github.com/LiosK/UUID.js +// and http://docs.python.org/library/uuid.html + +let _nodeId; +let _clockseq; + +// Previous uuid creation time +let _lastMSecs = 0; +let _lastNSecs = 0; + +// See https://github.com/uuidjs/uuid for API details +function v1(options, buf, offset) { + let i = buf && offset || 0; + const b = buf || new Array(16); + options = options || {}; + let node = options.node; + let clockseq = options.clockseq; + + // v1 only: Use cached `node` and `clockseq` values + if (!options._v6) { + if (!node) { + node = _nodeId; + } + if (clockseq == null) { + clockseq = _clockseq; + } + } + + // Handle cases where we need entropy. We do this lazily to minimize issues + // related to insufficient system entropy. See #189 + if (node == null || clockseq == null) { + const seedBytes = options.random || (options.rng || _rng.default)(); + + // Randomize node + if (node == null) { + node = [seedBytes[0], seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; + + // v1 only: cache node value for reuse + if (!_nodeId && !options._v6) { + // per RFC4122 4.5: Set MAC multicast bit (v1 only) + node[0] |= 0x01; // Set multicast bit + + _nodeId = node; + } + } + + // Randomize clockseq + if (clockseq == null) { + // Per 4.2.2, randomize (14 bit) clockseq + clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; + if (_clockseq === undefined && !options._v6) { + _clockseq = clockseq; + } + } + } + + // v1 & v6 timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so time is + // handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. + let msecs = options.msecs !== undefined ? options.msecs : Date.now(); + + // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock + let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; + + // Time since last uuid creation (in msecs) + const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; + + // Per 4.2.1.2, Bump clockseq on clock regression + if (dt < 0 && options.clockseq === undefined) { + clockseq = clockseq + 1 & 0x3fff; + } + + // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { + nsecs = 0; + } + + // Per 4.2.1.2 Throw error if too many uuids are requested + if (nsecs >= 10000) { + throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); + } + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; + + // Per 4.1.4 - Convert from unix epoch to Gregorian epoch + msecs += 12219292800000; + + // `time_low` + const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; + + // `time_mid` + const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; + + // `time_high_and_version` + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version + b[i++] = tmh >>> 16 & 0xff; + + // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) + b[i++] = clockseq >>> 8 | 0x80; + + // `clock_seq_low` + b[i++] = clockseq & 0xff; + + // `node` + for (let n = 0; n < 6; ++n) { + b[i + n] = node[n]; + } + return buf || (0, _stringify.unsafeStringify)(b); +} +var _default = exports.default = v1; +},{"./rng.js":8,"./stringify.js":10}],12:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = v1ToV6; +var _parse = _interopRequireDefault(require("./parse.js")); +var _stringify = require("./stringify.js"); +function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +/** + * Convert a v1 UUID to a v6 UUID + * + * @param {string|Uint8Array} uuid - The v1 UUID to convert to v6 + * @returns {string|Uint8Array} The v6 UUID as the same type as the `uuid` arg + * (string or Uint8Array) + */ +function v1ToV6(uuid) { + const v1Bytes = typeof uuid === 'string' ? (0, _parse.default)(uuid) : uuid; + const v6Bytes = _v1ToV6(v1Bytes); + return typeof uuid === 'string' ? (0, _stringify.unsafeStringify)(v6Bytes) : v6Bytes; +} + +// Do the field transformation needed for v1 -> v6 +function _v1ToV6(v1Bytes, randomize = false) { + return Uint8Array.of((v1Bytes[6] & 0x0f) << 4 | v1Bytes[7] >> 4 & 0x0f, (v1Bytes[7] & 0x0f) << 4 | (v1Bytes[4] & 0xf0) >> 4, (v1Bytes[4] & 0x0f) << 4 | (v1Bytes[5] & 0xf0) >> 4, (v1Bytes[5] & 0x0f) << 4 | (v1Bytes[0] & 0xf0) >> 4, (v1Bytes[0] & 0x0f) << 4 | (v1Bytes[1] & 0xf0) >> 4, (v1Bytes[1] & 0x0f) << 4 | (v1Bytes[2] & 0xf0) >> 4, 0x60 | v1Bytes[2] & 0x0f, v1Bytes[3], v1Bytes[8], v1Bytes[9], v1Bytes[10], v1Bytes[11], v1Bytes[12], v1Bytes[13], v1Bytes[14], v1Bytes[15]); +} +},{"./parse.js":6,"./stringify.js":10}],13:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _v = _interopRequireDefault(require("./v35.js")); +var _md = _interopRequireDefault(require("./md5.js")); +function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +const v3 = (0, _v.default)('v3', 0x30, _md.default); +var _default = exports.default = v3; +},{"./md5.js":3,"./v35.js":14}],14:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.URL = exports.DNS = void 0; +exports.default = v35; +var _stringify = require("./stringify.js"); +var _parse = _interopRequireDefault(require("./parse.js")); +function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +function stringToBytes(str) { + str = unescape(encodeURIComponent(str)); // UTF8 escape + + const bytes = []; + for (let i = 0; i < str.length; ++i) { + bytes.push(str.charCodeAt(i)); + } + return bytes; +} +const DNS = exports.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +const URL = exports.URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; +function v35(name, version, hashfunc) { + function generateUUID(value, namespace, buf, offset) { + var _namespace; + if (typeof value === 'string') { + value = stringToBytes(value); + } + if (typeof namespace === 'string') { + namespace = (0, _parse.default)(namespace); + } + if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) { + throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); + } + + // Compute hash of namespace and value, Per 4.3 + // Future: Use spread syntax when supported on all platforms, e.g. `bytes = + // hashfunc([...namespace, ... value])` + let bytes = new Uint8Array(16 + value.length); + bytes.set(namespace); + bytes.set(value, namespace.length); + bytes = hashfunc(bytes); + bytes[6] = bytes[6] & 0x0f | version; + bytes[8] = bytes[8] & 0x3f | 0x80; + if (buf) { + offset = offset || 0; + for (let i = 0; i < 16; ++i) { + buf[offset + i] = bytes[i]; + } + return buf; + } + return (0, _stringify.unsafeStringify)(bytes); + } + + // Function#name is not settable on some platforms (#270) + try { + generateUUID.name = name; + } catch (err) {} + + // For CommonJS default export support + generateUUID.DNS = DNS; + generateUUID.URL = URL; + return generateUUID; +} +},{"./parse.js":6,"./stringify.js":10}],15:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _native = _interopRequireDefault(require("./native.js")); +var _rng = _interopRequireDefault(require("./rng.js")); +var _stringify = require("./stringify.js"); +function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +function v4(options, buf, offset) { + if (_native.default.randomUUID && !buf && !options) { + return _native.default.randomUUID(); + } + options = options || {}; + const rnds = options.random || (options.rng || _rng.default)(); + + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + rnds[6] = rnds[6] & 0x0f | 0x40; + rnds[8] = rnds[8] & 0x3f | 0x80; + + // Copy bytes to buffer, if provided + if (buf) { + offset = offset || 0; + for (let i = 0; i < 16; ++i) { + buf[offset + i] = rnds[i]; + } + return buf; + } + return (0, _stringify.unsafeStringify)(rnds); +} +var _default = exports.default = v4; +},{"./native.js":4,"./rng.js":8,"./stringify.js":10}],16:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _v = _interopRequireDefault(require("./v35.js")); +var _sha = _interopRequireDefault(require("./sha1.js")); +function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +const v5 = (0, _v.default)('v5', 0x50, _sha.default); +var _default = exports.default = v5; +},{"./sha1.js":9,"./v35.js":14}],17:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = v6; +var _stringify = require("./stringify.js"); +var _v = _interopRequireDefault(require("./v1.js")); +var _v1ToV = _interopRequireDefault(require("./v1ToV6.js")); +function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +/** + * + * @param {object} options + * @param {Uint8Array=} buf + * @param {number=} offset + * @returns + */ +function v6(options = {}, buf, offset = 0) { + // v6 is v1 with different field layout, so we start with a v1 UUID, albeit + // with slightly different behavior around how the clock_seq and node fields + // are randomized, which is why we call v1 with _v6: true. + let bytes = (0, _v.default)({ + ...options, + _v6: true + }, new Uint8Array(16)); + + // Reorder the fields to v6 layout. + bytes = (0, _v1ToV.default)(bytes); + + // Return as a byte array if requested + if (buf) { + for (let i = 0; i < 16; i++) { + buf[offset + i] = bytes[i]; + } + return buf; + } + return (0, _stringify.unsafeStringify)(bytes); +} +},{"./stringify.js":10,"./v1.js":11,"./v1ToV6.js":12}],18:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = v6ToV1; +var _parse = _interopRequireDefault(require("./parse.js")); +var _stringify = require("./stringify.js"); +function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +/** + * Convert a v6 UUID to a v1 UUID + * + * @param {string|Uint8Array} uuid - The v6 UUID to convert to v6 + * @returns {string|Uint8Array} The v1 UUID as the same type as the `uuid` arg + * (string or Uint8Array) + */ +function v6ToV1(uuid) { + const v6Bytes = typeof uuid === 'string' ? (0, _parse.default)(uuid) : uuid; + const v1Bytes = _v6ToV1(v6Bytes); + return typeof uuid === 'string' ? (0, _stringify.unsafeStringify)(v1Bytes) : v1Bytes; +} + +// Do the field transformation needed for v6 -> v1 +function _v6ToV1(v6Bytes) { + return Uint8Array.of((v6Bytes[3] & 0x0f) << 4 | v6Bytes[4] >> 4 & 0x0f, (v6Bytes[4] & 0x0f) << 4 | (v6Bytes[5] & 0xf0) >> 4, (v6Bytes[5] & 0x0f) << 4 | v6Bytes[6] & 0x0f, v6Bytes[7], (v6Bytes[1] & 0x0f) << 4 | (v6Bytes[2] & 0xf0) >> 4, (v6Bytes[2] & 0x0f) << 4 | (v6Bytes[3] & 0xf0) >> 4, 0x10 | (v6Bytes[0] & 0xf0) >> 4, (v6Bytes[0] & 0x0f) << 4 | (v6Bytes[1] & 0xf0) >> 4, v6Bytes[8], v6Bytes[9], v6Bytes[10], v6Bytes[11], v6Bytes[12], v6Bytes[13], v6Bytes[14], v6Bytes[15]); +} +},{"./parse.js":6,"./stringify.js":10}],19:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _rng = _interopRequireDefault(require("./rng.js")); +var _stringify = require("./stringify.js"); +function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +/** + * UUID V7 - Unix Epoch time-based UUID + * + * The IETF has published RFC9562, introducing 3 new UUID versions (6,7,8). This + * implementation of V7 is based on the accepted, though not yet approved, + * revisions. + * + * RFC 9562:https://www.rfc-editor.org/rfc/rfc9562.html Universally Unique + * IDentifiers (UUIDs) + + * + * Sample V7 value: + * https://www.rfc-editor.org/rfc/rfc9562.html#name-example-of-a-uuidv7-value + * + * Monotonic Bit Layout: RFC rfc9562.6.2 Method 1, Dedicated Counter Bits ref: + * https://www.rfc-editor.org/rfc/rfc9562.html#section-6.2-5.1 + * + * 0 1 2 3 0 1 2 3 4 5 6 + * 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | unix_ts_ms | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | unix_ts_ms | ver | seq_hi | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |var| seq_low | rand | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | rand | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + * seq is a 31 bit serialized counter; comprised of 12 bit seq_hi and 19 bit + * seq_low, and randomly initialized upon timestamp change. 31 bit counter size + * was selected as any bitwise operations in node are done as _signed_ 32 bit + * ints. we exclude the sign bit. + */ + +let _seqLow = null; +let _seqHigh = null; +let _msecs = 0; +function v7(options, buf, offset) { + options = options || {}; + + // initialize buffer and pointer + let i = buf && offset || 0; + const b = buf || new Uint8Array(16); + + // rnds is Uint8Array(16) filled with random bytes + const rnds = options.random || (options.rng || _rng.default)(); + + // milliseconds since unix epoch, 1970-01-01 00:00 + const msecs = options.msecs !== undefined ? options.msecs : Date.now(); + + // seq is user provided 31 bit counter + let seq = options.seq !== undefined ? options.seq : null; + + // initialize local seq high/low parts + let seqHigh = _seqHigh; + let seqLow = _seqLow; + + // check if clock has advanced and user has not provided msecs + if (msecs > _msecs && options.msecs === undefined) { + _msecs = msecs; + + // unless user provided seq, reset seq parts + if (seq !== null) { + seqHigh = null; + seqLow = null; + } + } + + // if we have a user provided seq + if (seq !== null) { + // trim provided seq to 31 bits of value, avoiding overflow + if (seq > 0x7fffffff) { + seq = 0x7fffffff; + } + + // split provided seq into high/low parts + seqHigh = seq >>> 19 & 0xfff; + seqLow = seq & 0x7ffff; + } + + // randomly initialize seq + if (seqHigh === null || seqLow === null) { + seqHigh = rnds[6] & 0x7f; + seqHigh = seqHigh << 8 | rnds[7]; + seqLow = rnds[8] & 0x3f; // pad for var + seqLow = seqLow << 8 | rnds[9]; + seqLow = seqLow << 5 | rnds[10] >>> 3; + } + + // increment seq if within msecs window + if (msecs + 10000 > _msecs && seq === null) { + if (++seqLow > 0x7ffff) { + seqLow = 0; + if (++seqHigh > 0xfff) { + seqHigh = 0; + + // increment internal _msecs. this allows us to continue incrementing + // while staying monotonic. Note, once we hit 10k milliseconds beyond system + // clock, we will reset breaking monotonicity (after (2^31)*10000 generations) + _msecs++; + } + } + } else { + // resetting; we have advanced more than + // 10k milliseconds beyond system clock + _msecs = msecs; + } + _seqHigh = seqHigh; + _seqLow = seqLow; + + // [bytes 0-5] 48 bits of local timestamp + b[i++] = _msecs / 0x10000000000 & 0xff; + b[i++] = _msecs / 0x100000000 & 0xff; + b[i++] = _msecs / 0x1000000 & 0xff; + b[i++] = _msecs / 0x10000 & 0xff; + b[i++] = _msecs / 0x100 & 0xff; + b[i++] = _msecs & 0xff; + + // [byte 6] - set 4 bits of version (7) with first 4 bits seq_hi + b[i++] = seqHigh >>> 4 & 0x0f | 0x70; + + // [byte 7] remaining 8 bits of seq_hi + b[i++] = seqHigh & 0xff; + + // [byte 8] - variant (2 bits), first 6 bits seq_low + b[i++] = seqLow >>> 13 & 0x3f | 0x80; + + // [byte 9] 8 bits seq_low + b[i++] = seqLow >>> 5 & 0xff; + + // [byte 10] remaining 5 bits seq_low, 3 bits random + b[i++] = seqLow << 3 & 0xff | rnds[10] & 0x07; + + // [bytes 11-15] always random + b[i++] = rnds[11]; + b[i++] = rnds[12]; + b[i++] = rnds[13]; + b[i++] = rnds[14]; + b[i++] = rnds[15]; + return buf || (0, _stringify.unsafeStringify)(b); +} +var _default = exports.default = v7; +},{"./rng.js":8,"./stringify.js":10}],20:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _regex = _interopRequireDefault(require("./regex.js")); +function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +function validate(uuid) { + return typeof uuid === 'string' && _regex.default.test(uuid); +} +var _default = exports.default = validate; +},{"./regex.js":7}],21:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _validate = _interopRequireDefault(require("./validate.js")); +function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } +function version(uuid) { + if (!(0, _validate.default)(uuid)) { + throw TypeError('Invalid UUID'); + } + return parseInt(uuid.slice(14, 15), 16); +} +var _default = exports.default = version; +},{"./validate.js":20}],22:[function(require,module,exports){ +// JavaScript Document + +const { v4: uuidv4 } = require('uuid'); + +// Example usage +const uuid = uuidv4(); +console.log(uuid); +},{"uuid":1}]},{},[22]); diff --git a/public/js/connections/dbCouch.js b/public/js/connections/dbCouch.js new file mode 100644 index 0000000..49e0325 --- /dev/null +++ b/public/js/connections/dbCouch.js @@ -0,0 +1,2 @@ +dmx.databases = dmx.databases || {}; +dmx.databases['dbCouch'] = {type: "pouchdb", remote: "http://host.docker.internal:9913/db_training"} \ No newline at end of file diff --git a/public/js/extraFunctions.js b/public/js/extraFunctions.js new file mode 100644 index 0000000..b553110 --- /dev/null +++ b/public/js/extraFunctions.js @@ -0,0 +1,9 @@ +// JavaScript Document +// Functions in this file will be run thru +// the 'browserify' script to make browser friendly. + +const { v4: uuidv4 } = require('uuid'); + +// Example usage +const uuid = uuidv4(); +console.log(uuid); \ No newline at end of file diff --git a/public/js/libProcessScript.js b/public/js/libProcessScript.js index aa574ca..e765240 100644 --- a/public/js/libProcessScript.js +++ b/public/js/libProcessScript.js @@ -4,7 +4,7 @@ // // ** OFFICIAL SCRIPT TO USE WHEN IN PRODUCTION // - +// Function to add Authenticator validation https://www.npmjs.com/package/speakeasy // Utility to fetch PDF bytes diff --git a/views/success.ejs b/views/success.ejs index 9572e42..e7801d7 100644 --- a/views/success.ejs +++ b/views/success.ejs @@ -15,4 +15,5 @@ Return home - \ No newline at end of file + + \ No newline at end of file