enigmatic 0.21.7 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +181 -44
- package/__tests__/enigmatic.test.js +328 -0
- package/components.js +166 -13
- package/enigmatic.js +134 -150
- package/index.html +30 -30
- package/jest.config.js +6 -0
- package/jest.setup.js +5 -0
- package/package.json +5 -4
- package/authn.mjs +0 -123
- package/tests/test-error.html +0 -5
- package/tests/test-fetch.html +0 -26
- package/tests/test-flatten.html +0 -38
- package/tests/test-layout.html +0 -32
- package/tests/test-schema.html +0 -10
- package/tests/test.html +0 -44
package/authn.mjs
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
ArrayBuffer.from = (string) => Uint8Array.from(string.split('').map(e => e.charCodeAt(0))).buffer
|
|
2
|
-
|
|
3
|
-
const webauthn = async () => {
|
|
4
|
-
const op = {}
|
|
5
|
-
op.attestation = 'direct'
|
|
6
|
-
op.authenticatorSelection = {
|
|
7
|
-
authenticatorAttachment: 'platform',
|
|
8
|
-
requireResidentKey: false,
|
|
9
|
-
userVerification: 'discouraged'
|
|
10
|
-
}
|
|
11
|
-
op.challenge = ArrayBuffer.from('challenge')
|
|
12
|
-
op.pubKeyCredParams = []
|
|
13
|
-
op.rp = { id: location.hostname, name: location.hostname }
|
|
14
|
-
op.timeout = 60000,
|
|
15
|
-
op.user = { name: 'cb', displayName: 'cb', id: ArrayBuffer.from('cb') }
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
async makeCredential() {
|
|
19
|
-
return await navigator.credentials.create({ publicKey: op })
|
|
20
|
-
},
|
|
21
|
-
async getAssertion() {
|
|
22
|
-
return await navigator.credentials.get({ publicKey: op })
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const w = await webauthn()
|
|
28
|
-
const credential = await w.makeCredential()
|
|
29
|
-
const decodedClientData = JSON.parse(new TextDecoder('utf-8').decode(credential.response.clientDataJSON))
|
|
30
|
-
console.log(decodedClientData)
|
|
31
|
-
// decode credential.response.attestationObject
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
// w.getAssertion()
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
/*
|
|
38
|
-
const credential = await navigator.credentials.create({
|
|
39
|
-
publicKey: {
|
|
40
|
-
challenge: Uint8Array.from(
|
|
41
|
-
'xxxxxx', c => c.charCodeAt(0)),
|
|
42
|
-
rp: {
|
|
43
|
-
name: "Test",
|
|
44
|
-
id: "localhost",
|
|
45
|
-
},
|
|
46
|
-
user: {
|
|
47
|
-
id: Uint8Array.from(
|
|
48
|
-
"UZSL85T9AFC", c => c.charCodeAt(0)),
|
|
49
|
-
name: "lee@webauthn.guide",
|
|
50
|
-
displayName: "Lee",
|
|
51
|
-
},
|
|
52
|
-
pubKeyCredParams: [{ alg: -7, type: "public-key" }],
|
|
53
|
-
authenticatorSelection: {
|
|
54
|
-
authenticatorAttachment: "cross-platform",
|
|
55
|
-
},
|
|
56
|
-
timeout: 60000,
|
|
57
|
-
attestation: "direct"
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
console.log(credential)
|
|
62
|
-
|
|
63
|
-
// Auth
|
|
64
|
-
const publicKeyCredentialRequestOptions = {
|
|
65
|
-
challenge: Uint8Array.from(
|
|
66
|
-
randomStringFromServer, c => c.charCodeAt(0)),
|
|
67
|
-
allowCredentials: [{
|
|
68
|
-
id: Uint8Array.from(
|
|
69
|
-
credentialId, c => c.charCodeAt(0)),
|
|
70
|
-
type: 'public-key',
|
|
71
|
-
transports: ['usb', 'ble', 'nfc'],
|
|
72
|
-
}],
|
|
73
|
-
timeout: 60000,
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const assertion = await navigator.credentials.get({
|
|
77
|
-
publicKey: publicKeyCredentialRequestOptions
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
ArrayBuffer.from = (string) => Uint8Array.from(string.split('').map(e => e.charCodeAt(0))).buffer
|
|
82
|
-
|
|
83
|
-
const webauthn = async () => {
|
|
84
|
-
//if(!await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable())
|
|
85
|
-
// return false
|
|
86
|
-
const op = {}
|
|
87
|
-
op.attestation = 'direct'
|
|
88
|
-
op.authenticatorSelection = {
|
|
89
|
-
authenticatorAttachment: 'platform',
|
|
90
|
-
requireResidentKey: false,
|
|
91
|
-
userVerification: 'discouraged'
|
|
92
|
-
}
|
|
93
|
-
op.challenge = ArrayBuffer.from('challenge')
|
|
94
|
-
op.pubKeyCredParams = [{ alg: -7, type: 'public-key' }]
|
|
95
|
-
op.rp = { id: 'localhost', name: 'localhost' }
|
|
96
|
-
op.timeout = 60000,
|
|
97
|
-
op.user = { name: 'cb', displayName: 'cb', id: ArrayBuffer.from('cb') }
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
async makeCredential() {
|
|
101
|
-
const cred = await navigator.credentials.create({ publicKey: op })
|
|
102
|
-
return cred
|
|
103
|
-
},
|
|
104
|
-
async getAssertion() {
|
|
105
|
-
const cred = await navigator.credentials.get({ publicKey: op })
|
|
106
|
-
return cred
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const w = await webauthn()
|
|
112
|
-
w.makeCredential().then(e => console.log(e))
|
|
113
|
-
//w.getAssertion().then(e => console.log(e))
|
|
114
|
-
|
|
115
|
-
/*
|
|
116
|
-
send to server
|
|
117
|
-
{
|
|
118
|
-
credential: {type: 'FIDO', id: attestation.id},
|
|
119
|
-
clientData: attestation.signature.clientData,
|
|
120
|
-
authnrData: attestation.signature.authnrData,
|
|
121
|
-
signature: attestation.signature.signature
|
|
122
|
-
}
|
|
123
|
-
*/
|
package/tests/test-error.html
DELETED
package/tests/test-fetch.html
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<script src='../enigmatic.js'></script>
|
|
2
|
-
|
|
3
|
-
<!-- HTML declarative -->
|
|
4
|
-
<div data='users_declare' fetch='toydb-687z3zxxqk0r.runkit.sh/'>{test_message}</div>
|
|
5
|
-
|
|
6
|
-
<!-- Not immediate -->
|
|
7
|
-
<div id='f' data='users_declare2' fetch='toydb-687z3zxxqk0r.runkit.sh/' defer>Delayed: {test_message}</div>
|
|
8
|
-
<button onclick='f.fetch()'>Fetch</button>
|
|
9
|
-
|
|
10
|
-
<!-- Transform results -->
|
|
11
|
-
<script>
|
|
12
|
-
get('randomuser.me/api', null, x=>x.results, 'users')
|
|
13
|
-
</script>
|
|
14
|
-
<div data="users">
|
|
15
|
-
<div>{gender} {picture}</div>
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<!-- Component -->
|
|
19
|
-
<script>
|
|
20
|
-
element('my-c', {
|
|
21
|
-
onmount: e=>e.style.border='1px solid black',
|
|
22
|
-
template: 'is: {gender}',
|
|
23
|
-
style: 'color:red'})
|
|
24
|
-
</script>
|
|
25
|
-
|
|
26
|
-
<my-c data='users_component'></my-c>
|
package/tests/test-flatten.html
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<script src='../enigmatic.js'></script>
|
|
2
|
-
<link rel=stylesheet href='../enigmatic.css'>
|
|
3
|
-
|
|
4
|
-
<body style='--rows: 1fr 1fr 1fr 1fr 10fr; --cols: 1fr 10fr 1fr'>
|
|
5
|
-
<h1 style='--span: 3'>Text templating (Flatten)</h1>
|
|
6
|
-
|
|
7
|
-
<div data="testobj" style='--span: 4' preserve='true'>
|
|
8
|
-
{k1} {k2}
|
|
9
|
-
</div>
|
|
10
|
-
|
|
11
|
-
<div data="testobjkv" style='--span: 4' preserve='true'>
|
|
12
|
-
{$key} {$val}
|
|
13
|
-
</div>
|
|
14
|
-
|
|
15
|
-
<div data="testarray" style='--span: 4' preserve='true'>
|
|
16
|
-
{$key}: {name}={value}
|
|
17
|
-
</div>
|
|
18
|
-
|
|
19
|
-
<div data="testobjobj" style='--span: 4' preserve='true'>
|
|
20
|
-
{$key}: {name}={value}
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
<div></div>
|
|
24
|
-
|
|
25
|
-
<section style='--cols: 1fr 1fr 1fr 1fr'>
|
|
26
|
-
<button onclick='state.testobj={"k1": "val1", "k2": "val2"}'>{k1: 'val1', k2: 'val2'}</button>
|
|
27
|
-
<button onclick='state.testobjkv={"k1": "val1", "k2": "val2"}'>{k1: 'val1', k2: 'val2'}</button>
|
|
28
|
-
<button onclick='state.testarray=[{ name: "myname", value: "myvalue" },{ name: "myname2", value: "myvalue2" }]'>[
|
|
29
|
-
{ name: 'myname', value: 'myvalue' },
|
|
30
|
-
{ name: 'myname2', value: 'myvalue2' },
|
|
31
|
-
]</button>
|
|
32
|
-
<button onclick='state.testobjobj={ "k1": {name: "myname3", value: "myvalue3"}, "k2": {name: "myname4", value: "myvalue4"} }'>{
|
|
33
|
-
"k1": { name: 'myname3', value: 'myvalue3' },
|
|
34
|
-
"k2": { name: 'myname4', value: 'myvalue4' },
|
|
35
|
-
}</button>
|
|
36
|
-
</section>
|
|
37
|
-
|
|
38
|
-
</body>
|
package/tests/test-layout.html
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<script src=components.js></script>
|
|
2
|
-
<script src=enigmatic.js></script>
|
|
3
|
-
<link rel=stylesheet href=enigmatic.css>
|
|
4
|
-
|
|
5
|
-
<body style="--cols:3fr 10fr 3fr; --rows:3fr 11fr 2fr">
|
|
6
|
-
|
|
7
|
-
<div class="bg-white"></div>
|
|
8
|
-
<div class="bg-white">
|
|
9
|
-
<img height='62' style='filter:invert(50%)' src='https://unpkg.com/simple-icons@v7/icons/apple.svg'>
|
|
10
|
-
|
|
11
|
-
</div>
|
|
12
|
-
<div class="bg-white"></div>
|
|
13
|
-
|
|
14
|
-
<div class="bg-white"></div>
|
|
15
|
-
<section class="bg-white" style="--cols: 1fr 1fr 1fr; --rows: 1fr 1fr 1fr">
|
|
16
|
-
<div class="bg-green"></div>
|
|
17
|
-
<div class="bg-white"><hello-world></hello-world></div>
|
|
18
|
-
<div class="bg-white"></div>
|
|
19
|
-
<div class="bg-white"></div>
|
|
20
|
-
<div class="bg-white"></div>
|
|
21
|
-
<div class="bg-white"></div>
|
|
22
|
-
<div class="bg-white"></div>
|
|
23
|
-
<div class="bg-white"></div>
|
|
24
|
-
<div class="bg-green"></div>
|
|
25
|
-
</section>
|
|
26
|
-
<div class="bg-white"></div>
|
|
27
|
-
|
|
28
|
-
<div class="bg-yellow"></div>
|
|
29
|
-
<div class="bg-yellow"></div>
|
|
30
|
-
<div class="bg-yellow"></div>
|
|
31
|
-
|
|
32
|
-
</body>
|
package/tests/test-schema.html
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<script src=../enigmatic.js></script>
|
|
2
|
-
<script type=module src=https://unpkg.com/e-schema@0.0.2/module.mjs></script>
|
|
3
|
-
|
|
4
|
-
<script type="module">
|
|
5
|
-
const es = new eSchema({MyType: {message: 'string'}})
|
|
6
|
-
es.validate({message: 'you are'}, 'MyType')
|
|
7
|
-
save(es.schema, 'myschema')
|
|
8
|
-
console.log(load('myschema'))
|
|
9
|
-
console.log(load('nothing'))
|
|
10
|
-
</script>
|
package/tests/test.html
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
<script src='../enigmatic.js'></script>
|
|
2
|
-
<script src='../components.js'></script>
|
|
3
|
-
<link rel='stylesheet' href='../enigmatic.css'>
|
|
4
|
-
|
|
5
|
-
<body style="--cols:1fr 10fr 1fr; --rows:1fr">
|
|
6
|
-
<div class="bg-black">a</div>
|
|
7
|
-
<section class="bg-white">
|
|
8
|
-
<div id='par' fetch='[{"id": 1, "control": "input"},{"id": 2, "control": "select"}]'>
|
|
9
|
-
<div>{control}</div>
|
|
10
|
-
<test-element id="a{id}"></test-element>
|
|
11
|
-
<br>
|
|
12
|
-
<!--IGNORE-->
|
|
13
|
-
<test-link></test-link>
|
|
14
|
-
<!--ENDIGNORE-->
|
|
15
|
-
</div>
|
|
16
|
-
</section>
|
|
17
|
-
<div class="bg-yellow"></div>
|
|
18
|
-
</body>
|
|
19
|
-
|
|
20
|
-
<script>
|
|
21
|
-
e('test-element', {
|
|
22
|
-
set: o=>console.log(o),
|
|
23
|
-
click: ev=>alert()
|
|
24
|
-
}, { border: '4px green solid' })
|
|
25
|
-
|
|
26
|
-
e('test-link', {
|
|
27
|
-
init: e => e.innerHTML = '<a>Click me</a>',
|
|
28
|
-
click: ev => alert()
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
/*
|
|
32
|
-
More verbose:
|
|
33
|
-
customElements.define('test-element', class extends HTMLElement {
|
|
34
|
-
connectedCallback() {
|
|
35
|
-
this.style.border = '3px black solid'
|
|
36
|
-
}
|
|
37
|
-
set(o) {
|
|
38
|
-
this.innerHTML = `<${o.control}></${o.control}>`
|
|
39
|
-
}
|
|
40
|
-
myfunc() {
|
|
41
|
-
alert('custom func')
|
|
42
|
-
}
|
|
43
|
-
})*/
|
|
44
|
-
</script>
|