Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
19 lines
627 B
Plaintext
19 lines
627 B
Plaintext
import { FlattenedSign } from '../flattened/sign.js';
|
|
export class CompactSign {
|
|
_flattened;
|
|
constructor(payload) {
|
|
this._flattened = new FlattenedSign(payload);
|
|
}
|
|
setProtectedHeader(protectedHeader) {
|
|
this._flattened.setProtectedHeader(protectedHeader);
|
|
return this;
|
|
}
|
|
async sign(key, options) {
|
|
const jws = await this._flattened.sign(key, options);
|
|
if (jws.payload === undefined) {
|
|
throw new TypeError('use the flattened module for creating JWS with b64: false');
|
|
}
|
|
return `${jws.protected}.${jws.payload}.${jws.signature}`;
|
|
}
|
|
}
|