Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nmattia committed Nov 30, 2023
1 parent 1500f03 commit 92112d5
Show file tree
Hide file tree
Showing 8 changed files with 389 additions and 223 deletions.
File renamed without changes.
9 changes: 6 additions & 3 deletions demos/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
"buffer": "^6.0.3"
},
"scripts": {
"build": "vite build",
"dev": "vite"
"dev": "vite --config ./vite.config.ts",
"check": "tsc --noEmit",
"watch": "npm run check -- --watch",
"build": "npm run check && vite --config ./vite.config.ts build"
},
"devDependencies": {
"vite": "^4.3.9"
"vite": "^4.3.9",
"typescript": "5.2.2"
}
}
213 changes: 111 additions & 102 deletions demos/test-app/src/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<html>
<head>
<script type="module" src="./index.ts"></script>
</head>
<body>
<style>
.postMessage {
Expand All @@ -17,108 +20,114 @@
background-color: lightgreen;
}
</style>
<div>
<h1>Identity</h1>
<h2>Sign In</h2>
<div>
<label for="iiUrl" style="display: inline-block; width: 200px"
>Identity Provider:
</label>
<input type="text" id="iiUrl" value="https://identity.ic0.app/" />
</div>
<div>
<label for="maxTimeToLive" style="display: inline-block; width: 200px"
>Max Time to live (ms):</label
>
<input type="number" id="maxTimeToLive" placeholder="(use default)" />
</div>
<div>
<label
for="derivationOrigin"
style="display: inline-block; width: 200px"
>Derivation Origin:</label
>
<input type="text" id="derivationOrigin" placeholder="(use default)" />
</div>
<button id="signinBtn">Sign In</button>
<button id="signoutBtn">Sign Out</button>
<h3>/.well-known/ii-alternative-origins</h3>
<div id="alternativeOrigins"></div>
<h3>Principal:</h3>
<div id="principal"></div>
<h3>Delegation:</h3>
<pre id="delegation"></pre>
<h3>Expiry (ns from now):</h3>
<div id="expiration"></div>
</div>

<div>
<h1>Contact the IC</h1>
<label for="hostUrl" style="display: inline-block; width: 120px"
>Replica URL:
</label>
<input type="text" id="hostUrl" value="https://ic0.app/" />
</div>
<div>
<button id="whoamiBtn">Who Am I?</button>
<div id="whoamiResponse"></div>
</div>
<div>
<label for="newAlternativeOrigins" style="display: inline-block">
Set new value for /.well-known/ii-alternative-origins:
</label>
<div>
<input
type="radio"
id="certified"
name="alternativeOriginsMode"
value="certified"
checked
/>
<label for="certified">Certified</label>
</div>
<div>
<input
type="radio"
id="uncertified"
name="alternativeOriginsMode"
value="uncertified"
/>
<label for="uncertified">Uncertified</label>
</div>
<div>
<input
type="radio"
id="redirect"
name="alternativeOriginsMode"
value="redirect"
/>
<label for="redirect">Redirect</label>
<input
type="text"
id="redirectLocation"
value="/.well-known/evil-alternative-origins"
/>
</div>
<input type="text" id="newAlternativeOrigins" />
<button id="updateNewAlternativeOrigins">Update Value</button>
</div>
<h1>Protocol Tests</h1>
<button id="openIiWindowBtn">Open II tab</button>
<button id="invalidDataBtn">Send Invalid Data</button>
<button id="incompleteMessageBtn">Send incomplete message</button>
<button id="validMessageBtn">Send valid message</button>
<button id="closeIIWindowBtn">Close II tab</button>
<div>
<label for="customMessage" style="display: inline-block">
Send custom message:
</label>
<input type="text" id="customMessage" />
<button id="customMessageBtn">Send Message</button>
</div>
<h3>WindowPostMessages:</h3>
<div id="messages"></div>
<main>
<section>
<h1>Identity</h1>
<h2>Sign In</h2>
<div>
<label for="iiUrl" style="display: inline-block; width: 200px"
>Identity Provider:
</label>
<input type="text" id="iiUrl" value="https://identity.ic0.app/" />
</div>
<div>
<label for="maxTimeToLive" style="display: inline-block; width: 200px"
>Max Time to live (ms):</label
>
<input type="number" id="maxTimeToLive" placeholder="(use default)" />
</div>
<div>
<label
for="derivationOrigin"
style="display: inline-block; width: 200px"
>Derivation Origin:</label
>
<input
type="text"
id="derivationOrigin"
placeholder="(use default)"
/>
</div>
<button id="signinBtn">Sign In</button>
<button id="signoutBtn">Sign Out</button>
<h3>/.well-known/ii-alternative-origins</h3>
<div id="alternativeOrigins"></div>
<h3>Principal:</h3>
<div id="principal"></div>
<h3>Delegation:</h3>
<pre id="delegation"></pre>
<h3>Expiry (ns from now):</h3>
<div id="expiration"></div>
</section>

<script type="module" src="/main.js"></script>
<section>
<h1>Contact the IC</h1>
<label for="hostUrl" style="display: inline-block; width: 120px"
>Replica URL:
</label>
<input type="text" id="hostUrl" value="https://ic0.app/" />
<div>
<button id="whoamiBtn">Who Am I?</button>
<div id="whoamiResponse"></div>
</div>
<div>
<label for="newAlternativeOrigins" style="display: inline-block">
Set new value for /.well-known/ii-alternative-origins:
</label>
<div>
<input
type="radio"
id="certified"
name="alternativeOriginsMode"
value="certified"
checked
/>
<label for="certified">Certified</label>
</div>
<div>
<input
type="radio"
id="uncertified"
name="alternativeOriginsMode"
value="uncertified"
/>
<label for="uncertified">Uncertified</label>
</div>
<div>
<input
type="radio"
id="redirect"
name="alternativeOriginsMode"
value="redirect"
/>
<label for="redirect">Redirect</label>
<input
type="text"
id="redirectLocation"
value="/.well-known/evil-alternative-origins"
/>
</div>
<input type="text" id="newAlternativeOrigins" />
<button id="updateNewAlternativeOrigins">Update Value</button>
</div>
</section>
<section>
<h1>Protocol Tests</h1>
<button id="openIiWindowBtn">Open II tab</button>
<button id="invalidDataBtn">Send Invalid Data</button>
<button id="incompleteMessageBtn">Send incomplete message</button>
<button id="validMessageBtn">Send valid message</button>
<button id="closeIIWindowBtn">Close II tab</button>
<div>
<label for="customMessage" style="display: inline-block">
Send custom message:
</label>
<input type="text" id="customMessage" />
<button id="customMessageBtn">Send Message</button>
</div>
<h3>WindowPostMessages:</h3>
<div id="messages"></div>
</section>
</main>
</body>
</html>
Loading

0 comments on commit 92112d5

Please sign in to comment.