(
webBundle: Uint8Array,
signingStrategies: Array<ISigningStrategy>,
options?: { webBundleId?: string }
)
| 43 | |
| 44 | // Web bundle ID is derived from the first key if not provided |
| 45 | static async fromWebBundle( |
| 46 | webBundle: Uint8Array, |
| 47 | signingStrategies: Array<ISigningStrategy>, |
| 48 | options?: { webBundleId?: string } |
| 49 | ): Promise<SignedWebBundle> { |
| 50 | assert(signingStrategies.length > 0, 'No signing strategies provided'); |
| 51 | |
| 52 | const publicKey = await signingStrategies[0].getPublicKey(); |
| 53 | const webBundleId = |
| 54 | options?.webBundleId ?? new WebBundleId(publicKey).serialize(); |
| 55 | |
| 56 | const { signedWebBundle } = await new IntegrityBlockSigner( |
| 57 | webBundle, |
| 58 | webBundleId, |
| 59 | signingStrategies |
| 60 | ).sign(); |
| 61 | |
| 62 | return SignedWebBundle.fromBytes(signedWebBundle); |
| 63 | } |
| 64 | |
| 65 | async addSignature(signingStrategy: ISigningStrategy): Promise<this> { |
| 66 | this.integrityBlock = await new IntegrityBlockSigner( |
no test coverage detected