Skip to content
This repository was archived by the owner on Aug 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/lib/pkg-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export const POSTGUARD_WEBSITE_URL: string = process.env.POSTGUARD_WEBSITE_URL a
// OnMessageSend launchevent runtime to construct the Yivi dialog URL —
// window.location is unreliable there on New Outlook for Mac.
export const ADDIN_PUBLIC_URL: string = process.env.ADDIN_PUBLIC_URL as string;
// Sourced from package.json at build time via webpack DefinePlugin so the
// X-PostGuard-Client-Version header always matches the deployed release.
export const ADDIN_VERSION: string = process.env.ADDIN_VERSION as string;

export const CLIENT_NAME = "Outlook";
export const CLIENT_ID = "pg4ol";
Expand Down
10 changes: 7 additions & 3 deletions src/taskpane/compose-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ import {
import { toBase64 } from "../lib/encoding";
import { EMAIL_ATTRIBUTE_TYPE } from "../lib/attributes";
import { Policy, MimeAttachment } from "../lib/types";
import { PKG_URL, CRYPTIFY_URL, POSTGUARD_WEBSITE_URL, clientHeaders } from "../lib/pkg-client";
import {
PKG_URL,
CRYPTIFY_URL,
POSTGUARD_WEBSITE_URL,
ADDIN_VERSION,
clientHeaders,
} from "../lib/pkg-client";
import { byId } from "../lib/dom";
import { guessContentType, POSTGUARD_ENCRYPTED_FILENAME } from "../lib/mime";
import {
Expand All @@ -45,8 +51,6 @@ import {
import { mountPolicyPanel } from "./policy-editor";
import { showView, setStatus, showError } from "./taskpane";

const ADDIN_VERSION = "0.1.0";

async function persistEncryptOnSend(value: boolean): Promise<void> {
try {
// saveItem() before and after the header write: the first ensures
Expand Down
4 changes: 1 addition & 3 deletions src/taskpane/read-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ import {
readMimeHeader,
} from "../lib/mime";
import { Badge, FriendlySender } from "../lib/types";
import { PKG_URL, CRYPTIFY_URL, clientHeaders } from "../lib/pkg-client";
import { PKG_URL, CRYPTIFY_URL, ADDIN_VERSION, clientHeaders } from "../lib/pkg-client";
import { byId } from "../lib/dom";
import { t } from "../lib/i18n";
import { stringifyError } from "../lib/stringify-error";
import { showView, setStatus, showError } from "./taskpane";

const ADDIN_VERSION = "0.1.0";

interface ReadState {
ciphertext: Uint8Array | null;
recipientEmail: string;
Expand Down
14 changes: 8 additions & 6 deletions src/yivi-dialog/yivi-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@

import { PostGuard, buildMime, UploadSessionExpiredError } from "@e4a/pg-js";
import { toBase64, fromBase64 } from "../lib/encoding";
import { PKG_URL, CRYPTIFY_URL, POSTGUARD_WEBSITE_URL } from "../lib/pkg-client";
import {
PKG_URL,
CRYPTIFY_URL,
POSTGUARD_WEBSITE_URL,
ADDIN_VERSION,
clientHeaders,
} from "../lib/pkg-client";
import { ChunkAssembler, chunkPayload, isChunkMessage, ChunkMessage } from "../lib/dialog-chunk";
import { stringifyError } from "../lib/stringify-error";
import {
Expand All @@ -19,8 +25,6 @@ import {
probeAndClearPendingUpload,
} from "../lib/pending-upload";

const ADDIN_VERSION = "0.1.0";

interface AttachmentPayload {
name: string;
type: string;
Expand Down Expand Up @@ -131,9 +135,7 @@ async function runEncryption(req: EncryptRequest): Promise<EncryptResult> {
const pg = new PostGuard({
pkgUrl: PKG_URL,
cryptifyUrl: CRYPTIFY_URL,
headers: {
"X-PostGuard-Client-Version": `Outlook,1.0,pg4outlook,${ADDIN_VERSION}`,
},
headers: clientHeaders(ADDIN_VERSION),
} as never);

const recipients = [...req.to, ...req.cc].map((email) =>
Expand Down
5 changes: 5 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const devCerts = require("office-addin-dev-certs");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
const pkg = require("./package.json");
require("dotenv").config();

const urlDev = "https://localhost:3000/";
Expand Down Expand Up @@ -92,6 +93,10 @@ module.exports = async (env, options) => {
// override (JSRuntime.Url) where window.location is an Office-
// internal URL, not the add-in origin.
"process.env.ADDIN_PUBLIC_URL": JSON.stringify(dev ? urlDev : urlProd),
// Stamped into the X-PostGuard-Client-Version header so PKG /
// Cryptify dashboards can attribute metrics per release. Sourced
// from package.json, which release-please bumps on every release.
"process.env.ADDIN_VERSION": JSON.stringify(pkg.version),
}),
new HtmlWebpackPlugin({
filename: "taskpane.html",
Expand Down