MCPcopy Create free account
hub / github.com/WICG/webpackage / fromBytes

Method fromBytes

js/sign/src/core/signed-web-bundle.ts:29–42  ·  view source on GitHub ↗
(signedWebBundle: Uint8Array)

Source from the content-addressed store, hash-verified

27
28 // Use with raw Singed Web Bundle data, for example read from file with fs.readFile('bundle.swbn')
29 static fromBytes(signedWebBundle: Uint8Array): SignedWebBundle {
30 if (!isSignedWebBundle(signedWebBundle)) {
31 throw new Error('Not a signed web bundle.');
32 }
33
34 const offset = this.obtainIntegrityOffset(signedWebBundle);
35
36 const integrityBlockBytes = signedWebBundle.slice(0, offset);
37 const integrityBlock = IntegrityBlock.fromCbor(integrityBlockBytes);
38
39 const bundle = signedWebBundle.slice(offset);
40
41 return new SignedWebBundle(integrityBlock, bundle);
42 }
43
44 // Web bundle ID is derived from the first key if not provided
45 static async fromWebBundle(

Callers 2

parseArgumentsFunction · 0.80
fromWebBundleMethod · 0.80

Calls 3

obtainIntegrityOffsetMethod · 0.95
isSignedWebBundleFunction · 0.90
fromCborMethod · 0.80

Tested by

no test coverage detected