-
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
14 changed files
with
158 additions
and
60 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
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 |
---|---|---|
@@ -1,29 +1,28 @@ | ||
import * as jose from 'jose' | ||
import path from 'node:path' | ||
|
||
const alg = 'ES256' | ||
// const options = { | ||
// issuer: "urn:example:issuer", | ||
// audience: "urn:example:audience", | ||
// }; | ||
const keys = await jose.generateKeyPair(alg, { extractable: true }) | ||
const keys2 = await jose.generateKeyPair(alg, { extractable: true }) | ||
// const keys3 = await jose.generateKeyPair(alg, { extractable: true }); | ||
export const alg = 'ES256' | ||
const keysDir = path.join(__dirname, './keys') | ||
|
||
const jwk1 = await jose.exportJWK(keys.publicKey).then((jwk) => { | ||
jwk.kid = 'key1' | ||
export const publicKeyPath = path.join(keysDir, 'public') | ||
export const privateKeyPath = path.join(keysDir, 'private') | ||
export function loadKeys() { | ||
|
||
return jwk | ||
}) | ||
} | ||
|
||
const jwk2 = await jose.exportJWK(keys2.publicKey).then((jwk) => { | ||
jwk.kid = 'key2' | ||
// export async function writeKeys(obj: { | ||
// name: string | ||
// privateKey: jose.KeyLike | ||
// publicKey: jose.KeyLike | ||
// }) { | ||
|
||
return jwk | ||
}) | ||
// } | ||
|
||
// const jwk3 = await jose.exportJWK(keys3.publicKey).then((jwk) => { | ||
// jwk.kid = "key3"; | ||
// return jwk; | ||
// }); | ||
// export async function generateKeyPair(name: string) { | ||
// const { privateKey, publicKey } = await jose.generateKeyPair(alg, { extractable: true }) | ||
|
||
export const jwks = jose.createLocalJWKSet({ keys: [jwk1, jwk2] }) | ||
// // writeKeys({ | ||
// // name, | ||
// // privateKey, | ||
// // publicKey, | ||
// // }) | ||
// } |
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,22 @@ | ||
function generateCombinations(test: { [key: string]: string[] }): string[][] { | ||
let combinations: string[][] = [[]] | ||
Object.keys(test).forEach((key) => { | ||
const newCombinations: string[][] = [] | ||
test[key].forEach((value) => { | ||
combinations.forEach((combination) => { | ||
newCombinations.push([...combination, `${key}-${value}`]) | ||
}) | ||
}) | ||
combinations = newCombinations | ||
}) | ||
|
||
return combinations | ||
} | ||
|
||
const test = { | ||
size: ['xs', 's', 'm', 'l', 'xl'], | ||
color: ['red', 'green', 'blue'], | ||
material: ['wood', 'plastic', 'metal'], | ||
} | ||
|
||
console.log(generateCombinations(test)) |
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 consola from 'consola' | ||
import { MongoClient } from 'mongodb' | ||
|
||
const logger = consola.withTag('mongodb') | ||
export async function createMongoDBStore() { | ||
const client = new MongoClient('mongodb://root:example@mongodb:27017') | ||
|
||
await client.connect() | ||
|
||
const db = client.db('testSozdev') | ||
logger.debug('Connected to MongoDB', db.databaseName) | ||
|
||
return { | ||
data: db.collection('data'), | ||
} | ||
} |
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
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
Oops, something went wrong.