Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 1, 2025

Deno v2's bundler renames internal ASN.1 class constructors (e.g., LocalSimpleStringValueBlockLocalSimpleStringValueBlock2), breaking certificate parsing that relied on constructor.name string matching.

Changes

Refactored decodeValue() in lib/certUtils.js to use property-based type detection instead of constructor name strings:

Before:

function decodeValue(valueBlock) {
  const blockType = Object.getPrototypeOf(valueBlock).constructor.name;
  switch (blockType) {
    case "LocalSimpleStringValueBlock":
      return valueBlock.value;
    case "LocalIntegerValueBlock":
      return valueBlock.valueDec;
    // ... fails when bundler renames these classes
  }
}

After:

function decodeValue(valueBlock) {
  // Wrapper objects (OctetString, BmpString, Utf8String, Constructed)
  if ("valueBlock" in valueBlock && valueBlock.valueBlock) {
    const innerBlock = valueBlock.valueBlock;
    if ("value" in innerBlock && typeof innerBlock.value === "string") {
      return innerBlock.value;  // String types
    }
    // ... other wrapper types
  }
  
  // Value blocks
  if ("valueDec" in valueBlock) return valueBlock.valueDec;  // Integer
  if ("unusedBits" in valueBlock) return new Uint8Array(valueBlock.valueHex)[0];  // BitString
  // ... other value block types
}

Type detection now relies on structural properties that bundlers preserve:

  • Integer blocks: presence of valueDec getter
  • Bit strings: unusedBits + valueHex properties
  • String types: value string property (checked before valueHex since both exist)
  • Constructed blocks: value array property with explicit wrapper exclusion

CI Workflow Update:
Re-enabled deno task build in .github/workflows/test.yml to run the complete Deno build process including bundling and testing against bundled code, validating the fix in CI.

Fixes #178

Original prompt

Create a fork and have a look at the recent issue describing problems with new deno bundler.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Nov 1, 2025
Copilot AI changed the title [WIP] Investigate recent issues with Deno bundler Fix Deno v2 bundler incompatibility in ASN.1 certificate decoding Nov 1, 2025
Copilot AI requested a review from Hexagon November 1, 2025 09:31
Copilot finished work on behalf of Hexagon November 1, 2025 09:31
@Hexagon
Copy link
Member

Hexagon commented Nov 1, 2025

@copilot Re-enable deno task build in test ci

Copy link
Contributor Author

Copilot AI commented Nov 1, 2025

@copilot Re-enable deno task build in test ci

Done. Re-enabled deno task build in both the test_deno job and the release job. The CI will now run the full build process including bundling and testing against bundled code. (commit 9bfeb53)

Copilot finished work on behalf of Hexagon November 1, 2025 09:38
@Hexagon Hexagon marked this pull request as ready for review November 1, 2025 09:44
@JamesCullum JamesCullum merged commit 34a36f6 into master Nov 8, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deno test passes, but Deno bundle fails

3 participants