Skip to content

bug: yivi-dialog sends pg4outlook (was pg4ol) and stale ADDIN_VERSION="0.1.0" in client-version header #103

@dobby-coder

Description

@dobby-coder

Summary

Two related defects in the X-PostGuard-Client-Version header that the launchevent's Yivi dialog sends to PKG and Cryptify. Both silently break per-client metrics — sends still succeed but the dashboards mis-attribute them.

1. Wrong client-id token (regression of PR #11)

src/yivi-dialog/yivi-dialog.ts:135 hardcodes:

"X-PostGuard-Client-Version": `Outlook,1.0,pg4outlook,${ADDIN_VERSION}`,

The PKG (postguard/pg-pkg/src/middleware/metrics.rs) keys its Prometheus counter on the third comma-separated field. Org convention is:

  • pg4ol for Outlook (this addon)
  • pg4tb for Thunderbird

pg4outlook was the v0.2.0 rewrite bug that PR #11 fixed in the taskpane, and the dialog runtime has reintroduced it. The taskpane code (src/lib/pkg-client.ts:13) already exposes CLIENT_ID = "pg4ol" and a clientHeaders() helper — the dialog should use the same.

The dialog header is also missing the X-Cryptify-Source: outlook header that clientHeaders() adds; without it, cryptify's detect_channel mis-classifies dialog-flow uploads (its origin check on addin.*.postguard.eu falls back to the website channel).

2. Stale ADDIN_VERSION = "0.1.0"

Hardcoded in three files, never matched the real package version:

  • src/yivi-dialog/yivi-dialog.ts:22
  • src/taskpane/compose-view.ts:39
  • src/taskpane/read-view.ts:34

package.json is at 0.4.0 and the open release-please PR (#95) bumps to 0.5.0. The fourth field of the client-version header is meant to track the deployed extension version; right now every release reports as 0.1.0, so the PKG metric cannot distinguish current vs. historical clients.

Suggested fix

  1. In src/yivi-dialog/yivi-dialog.ts, replace the hardcoded headers object on line 134-136 with a call to clientHeaders(ADDIN_VERSION) from ../lib/pkg-client. (The import already brings in PKG_URL/CRYPTIFY_URL/POSTGUARD_WEBSITE_URL from that module.)
  2. Replace the three const ADDIN_VERSION = "0.1.0" declarations with a single source of truth. Two options:
    • Import the version from package.json via webpack's DefinePlugin / EnvironmentPlugin (same mechanism used for PKG_URL etc.). Add process.env.ADDIN_VERSION set from require('./package.json').version.
    • Or declare export const ADDIN_VERSION = "<version>" in src/lib/pkg-client.ts and update it on release. Less reliable; release-please can probably bump it via extra-files config though.
  3. Optionally: extract recipientsKey, guessContentType, and the Office.js promise wrappers into shared lib modules. Separate issue — see follow-up.

Verification

  • grep -rn "pg4outlook\|pg4ol" src — should only return pg4ol (in pkg-client.ts).
  • grep -rn "ADDIN_VERSION" src — all references should resolve to a single constant matching package.json.
  • Build + lint + typecheck + manifest validate all pass.
  • Manual smoke test: trigger the one-click flow (Encrypt-on-send via the dialog), confirm the network tab shows pg4ol,<current-version> in the header on both PKG and Cryptify requests, and that X-Cryptify-Source: outlook is present on the Cryptify upload.

/dobby

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions