-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
13,516 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
node_moduals | ||
.vscode | ||
.nyc_output | ||
coverage | ||
coverage | ||
|
||
tests/browser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Sha256 } from '@aws-crypto/sha256-js'; | ||
|
||
/** | ||
* Calculates the SHA256 hash of a string | ||
* | ||
* @param {string} input the string to hash | ||
* @returns {string} the hash of the string | ||
* @example | ||
* const hash = sha256('hello'); | ||
* console.log(hash); // 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969 | ||
*/ | ||
export default function sha256(input: string): string { | ||
const hash = new Sha256(); | ||
hash.update(input); | ||
return Buffer.from(hash.digestSync()).toString('hex'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.parcel-cache | ||
.cache | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const { defineConfig } = require('cypress'); | ||
|
||
const path = require('path'); | ||
const dotenvPath = path.resolve(__dirname, '..', '..', '.env'); | ||
require('dotenv').config({ path: dotenvPath }); | ||
|
||
module.exports = defineConfig({ | ||
env: { | ||
...process.env, | ||
}, | ||
e2e: { | ||
setupNodeEvents(on, config) {}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
describe('template spec', () => { | ||
it('passes', () => { | ||
cy.visit('http://localhost:1234/buildAndLoad.html'); | ||
cy.get('body').should('contain', 'Douglas Adams'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<html> | ||
<head> | ||
<title>Build and Load</title> | ||
</head> | ||
<body> | ||
<h1>test</h1> | ||
<script type="module"> | ||
import { requestItem } from '../../../../'; | ||
const item = requestItem('Q42'); | ||
item.then((item) => { | ||
document.body.innerHTML = item.findLabel('en').value; | ||
}); | ||
</script> | ||
<h1>result</h1> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
describe('template spec', () => { | ||
it('passes', () => { | ||
cy.visit('http://localhost:1234/login.html'); | ||
|
||
// the following code is injected into the page | ||
// and executed in the browser | ||
// the username and passwords are replaced by the .parcel-plugin-replace.js | ||
// with the values from the .env file | ||
const functionCall = `login('${Cypress.env('WIKIDATA_USERNAME')}', '${Cypress.env('WIKIDATA_PASSWORD')}')`; | ||
|
||
cy.window().then((win) => { | ||
try { | ||
win.eval(functionCall); | ||
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.error(e); | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html> | ||
<head> | ||
<title>login</title> | ||
<script type="module" src="./login.ts"></script> | ||
</head> | ||
<body> | ||
<h1>test</h1> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* eslint-disable import/no-relative-packages */ | ||
/* eslint-disable import/no-useless-path-segments */ | ||
import { | ||
getToken | ||
} from '../../../../'; | ||
|
||
declare global { | ||
interface Window { | ||
login: (username: string, password: string) => Promise<void>; | ||
} | ||
} | ||
|
||
async function login(username: string, password: string): Promise<void> { | ||
const token = await getToken(username, password); | ||
|
||
if (token) { | ||
document.body.innerHTML = `success: ${token}`; | ||
} | ||
} | ||
|
||
window.login = login; |
Empty file.
Oops, something went wrong.