I have looked at many examples of Promises
and Continuations
but have not found a consistently working pattern.
Here is an attempt to use a pair of encryption related methods:
async function makeAesGcmKeys() {
let key = await crypto.subtle.generateKey(
{
name: "AES-GCM",
length: 256
},
true,
["encrypt", "decrypt"]
);
let exported = key.then( k => { crypto.subtle.exportKey('raw',k)})
return [key,exported]
}
makeAesGcmKeys().then((k,e) => {
console.log(`in continuation: exported=${e}`);
return [k,e]
}).then( (key,exported) => {
console.log(`main: ${exported}`)
});
This results in a Promise
being returned. I need the resolved result not the Promise
. I have tried various permutations on the above but they also return a Promise
. Pointers appreciated.