@deliverd/sdk 0.28.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context.d.ts +7 -3
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +11 -3
- package/dist/data-screen.d.ts.map +1 -1
- package/dist/data-screen.js +33 -2
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +4 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/purview-rules.d.ts +63 -0
- package/dist/purview-rules.d.ts.map +1 -0
- package/dist/purview-rules.js +98 -0
- package/dist/purview.d.ts +114 -0
- package/dist/purview.d.ts.map +1 -0
- package/dist/purview.js +124 -0
- package/dist/released.d.ts +1 -1
- package/dist/released.d.ts.map +1 -1
- package/dist/released.js +2917 -0
- package/dist/screen.d.ts +8 -0
- package/dist/screen.d.ts.map +1 -1
- package/dist/screen.js +2 -0
- package/dist/types.d.ts +74 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/context.ts +15 -3
- package/src/data-screen.ts +33 -2
- package/src/dev.ts +4 -2
- package/src/index.ts +1 -0
- package/src/purview-rules.ts +117 -0
- package/src/purview.ts +182 -0
- package/src/released.ts +2919 -0
- package/src/screen.ts +10 -0
- package/src/types.ts +74 -2
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from "./http.js";
|
|
2
|
-
import type { ContextGiven, DraftPlaybookInput, EditKnowledgeInput, ExportKnowledgeInput, ImportedKnowledge, ImportKnowledgeInput, KnowledgeDetail, KnowledgeEntryData, KnowledgeExport, KnowledgeSearchResult, PlaybookData, PlaybookDetail, PlaybookSummary, PromoteFindingInput, ProposedKnowledge, ProposeKnowledgeInput, RequestPlaybookApprovalInput, SearchKnowledgeInput, StartedPlaybook, StartPlaybookInput } from "./types.js";
|
|
2
|
+
import type { ContextGiven, DraftPlaybookInput, EditKnowledgeInput, ExportKnowledgeInput, ImportedKnowledge, ImportKnowledgeInput, KnowledgeDetail, KnowledgeEntryData, KnowledgeExport, KnowledgeSearchResult, PlaybookData, PlaybookDetail, PlaybookSummary, PromoteFindingInput, ProposedKnowledge, ProposeKnowledgeInput, RequestPlaybookApprovalInput, SearchKnowledgeInput, StartedPlaybook, StartPlaybookInput, PlaybookKind, UsedPrompt, UsePromptInput } from "./types.js";
|
|
3
3
|
export declare class Knowledge {
|
|
4
4
|
private readonly http;
|
|
5
5
|
constructor(http: HttpClient);
|
|
@@ -29,8 +29,10 @@ export declare class Knowledge {
|
|
|
29
29
|
export declare class Playbooks {
|
|
30
30
|
private readonly http;
|
|
31
31
|
constructor(http: HttpClient);
|
|
32
|
-
/** One row per playbook: its newest version, and the version in force. */
|
|
33
|
-
list(
|
|
32
|
+
/** One row per playbook: its newest version, and the version in force. `kind: "prompt"` for approved prompts only. */
|
|
33
|
+
list(options?: {
|
|
34
|
+
kind?: PlaybookKind;
|
|
35
|
+
}, signal?: AbortSignal): Promise<PlaybookSummary[]>;
|
|
34
36
|
get(id: string, signal?: AbortSignal): Promise<PlaybookDetail>;
|
|
35
37
|
/** Draft a new playbook. Nobody runs a draft until a person puts it in force. */
|
|
36
38
|
draft(input: DraftPlaybookInput, signal?: AbortSignal): Promise<PlaybookData>;
|
|
@@ -40,6 +42,8 @@ export declare class Playbooks {
|
|
|
40
42
|
updateDraft(id: string, input: DraftPlaybookInput, signal?: AbortSignal): Promise<PlaybookData>;
|
|
41
43
|
/** Put a draft to people as a Deliverd approval. Approved, it goes in force. Needs `approvals:write` and `tasks:write`. */
|
|
42
44
|
requestApproval(id: string, input?: RequestPlaybookApprovalInput, signal?: AbortSignal): Promise<PlaybookData>;
|
|
45
|
+
/** Take an approved prompt: the version in force, filled in with `inputs`. The use is recorded against the version. */
|
|
46
|
+
use(id: string, input?: UsePromptInput, signal?: AbortSignal): Promise<UsedPrompt>;
|
|
43
47
|
/** Run the version in force: an objective, and a side task per step. */
|
|
44
48
|
start(id: string, input?: StartPlaybookInput, signal?: AbortSignal): Promise<StartedPlaybook>;
|
|
45
49
|
}
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,4BAA4B,EAC5B,oBAAoB,EACpB,eAAe,EACf,kBAAkB,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,4BAA4B,EAC5B,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,cAAc,EACf,MAAM,YAAY,CAAC;AAuBpB,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,oFAAoF;IACpF,MAAM,CAAC,KAAK,GAAE,oBAAyB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAS9F,w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C,sHAAsH;IAChH,IAAI,CAAC,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,YAAY,CAAA;KAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAKnG,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC;IAI9D,iFAAiF;IACjF,KAAK,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAI7E,2GAA2G;IAC3G,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAIhG,uDAAuD;IACvD,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAI/F,2HAA2H;IAC3H,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,GAAE,4BAAiC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAIlH,uHAAuH;IACvH,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,GAAE,cAAmB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAItF,wEAAwE;IACxE,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,GAAE,kBAAuB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC;CAGlG"}
|
package/dist/context.js
CHANGED
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
* objective with a side task per step. A person puts a playbook in force; an
|
|
12
12
|
* agent's key can draft one and run one, never publish it, and never confirm
|
|
13
13
|
* knowledge.
|
|
14
|
+
*
|
|
15
|
+
* An approved prompt is a playbook of kind `prompt`: the organisation's agreed
|
|
16
|
+
* words for a piece of work, approved and versioned the same way. `use()`
|
|
17
|
+
* hands out the version in force, filled in, and records the use.
|
|
14
18
|
*/
|
|
15
19
|
const enc = encodeURIComponent;
|
|
16
20
|
export class Knowledge {
|
|
@@ -92,9 +96,9 @@ export class Playbooks {
|
|
|
92
96
|
constructor(http) {
|
|
93
97
|
this.http = http;
|
|
94
98
|
}
|
|
95
|
-
/** One row per playbook: its newest version, and the version in force. */
|
|
96
|
-
async list(signal) {
|
|
97
|
-
const out = await this.http.request({ method: "GET", path: "/playbooks", signal });
|
|
99
|
+
/** One row per playbook: its newest version, and the version in force. `kind: "prompt"` for approved prompts only. */
|
|
100
|
+
async list(options = {}, signal) {
|
|
101
|
+
const out = await this.http.request({ method: "GET", path: "/playbooks", query: { kind: options.kind }, signal });
|
|
98
102
|
return out.playbooks;
|
|
99
103
|
}
|
|
100
104
|
get(id, signal) {
|
|
@@ -116,6 +120,10 @@ export class Playbooks {
|
|
|
116
120
|
requestApproval(id, input = {}, signal) {
|
|
117
121
|
return this.http.request({ method: "POST", path: `/playbooks/${enc(id)}/approval`, body: input, signal });
|
|
118
122
|
}
|
|
123
|
+
/** Take an approved prompt: the version in force, filled in with `inputs`. The use is recorded against the version. */
|
|
124
|
+
use(id, input = {}, signal) {
|
|
125
|
+
return this.http.request({ method: "POST", path: `/playbooks/${enc(id)}/use`, body: input, signal });
|
|
126
|
+
}
|
|
119
127
|
/** Run the version in force: an objective, and a side task per step. */
|
|
120
128
|
start(id, input = {}, signal) {
|
|
121
129
|
return this.http.request({ method: "POST", path: `/playbooks/${enc(id)}/start`, body: input, signal });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-screen.d.ts","sourceRoot":"","sources":["../src/data-screen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,+DAAgE,CAA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AAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,oBAAoB,CAE7F"}
|
package/dist/data-screen.js
CHANGED
|
@@ -97,19 +97,35 @@ function ppsValid(raw) {
|
|
|
97
97
|
return m[2] === (r === 0 ? "W" : String.fromCharCode(64 + r));
|
|
98
98
|
}
|
|
99
99
|
function ipv4Valid(raw) {
|
|
100
|
+
// "v1.2.3.4" and "version 1.2.3.4" are versions, and so is "1.2.3.4.5".
|
|
101
|
+
if (/[a-z]/i.test(raw))
|
|
102
|
+
return false;
|
|
100
103
|
const parts = raw.split(".").map(Number);
|
|
101
104
|
if (parts.length !== 4 || parts.some((p) => p > 255))
|
|
102
105
|
return false;
|
|
103
106
|
// Loopback and the unspecified address identify nobody.
|
|
104
107
|
return parts[0] !== 127 && parts[0] !== 0;
|
|
105
108
|
}
|
|
109
|
+
/** Eight groups, or a "::" and at least three, so "10:30:00" and a MAC address are not addresses. */
|
|
110
|
+
function ipv6Valid(raw) {
|
|
111
|
+
if (raw.includes(":::"))
|
|
112
|
+
return false;
|
|
113
|
+
const compressed = raw.split("::").length - 1;
|
|
114
|
+
const groups = raw.split(":").filter(Boolean).length;
|
|
115
|
+
return compressed === 0 ? groups === 8 : compressed === 1 && groups >= 3 && groups <= 7;
|
|
116
|
+
}
|
|
117
|
+
/** A value in a .env line that is a placeholder, not a credential. */
|
|
118
|
+
function envSecretValid(value) {
|
|
119
|
+
return !/^[<{%(]/.test(value) && !/your|example|placeholder|changeme|xxxx/i.test(value);
|
|
120
|
+
}
|
|
106
121
|
/**
|
|
107
122
|
* Credential patterns. The same set the publish scanner blocks a report for,
|
|
108
123
|
* because a key that must not be published must not be sent to a model either.
|
|
109
124
|
*/
|
|
110
125
|
const SECRET_PATTERNS = [
|
|
111
126
|
/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
|
|
112
|
-
|
|
127
|
+
// The whole block, or the header and the lines of key under it when the end was cut off.
|
|
128
|
+
/-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP |ENCRYPTED )?PRIVATE KEY(?: BLOCK)?-----(?:[\s\S]*?-----END (?:RSA |EC |DSA |OPENSSH |PGP |ENCRYPTED )?PRIVATE KEY(?: BLOCK)?-----|(?:\r?\n[A-Za-z0-9+\/=]{16,})*)/g,
|
|
113
129
|
/\bgh[pousr]_[A-Za-z0-9]{36,255}\b/g,
|
|
114
130
|
/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g,
|
|
115
131
|
/\b[sr]k_(?:live|test)_[A-Za-z0-9]{20,}\b/g,
|
|
@@ -129,6 +145,15 @@ const SECRET_PATTERNS = [
|
|
|
129
145
|
const SPECIAL_PATTERN = /\b(?:diagnos(?:is|ed|es)|medical (?:record|history|condition)s?|mental health|prescri(?:bed|ption)s?|HIV|pregnan(?:t|cy)|disabilit(?:y|ies)|sexual orientation|religious belief|ethnic origin|racial origin|trade union member(?:ship)?|biometric|genetic data|criminal (?:record|conviction|offence)s?)\b/gi;
|
|
130
146
|
const DETECTORS = [
|
|
131
147
|
...SECRET_PATTERNS.map((pattern) => ({ kind: "secret", pattern })),
|
|
148
|
+
// The user and password in a connection string: postgres://user:password@host.
|
|
149
|
+
{ kind: "secret", pattern: /\b[A-Za-z][A-Za-z0-9+.-]{1,15}:\/\/([A-Za-z0-9._~%!$&'()*+,;=-]+:[A-Za-z0-9._~%!$&'()*+,;=:-]+)@/g, group: 1 },
|
|
150
|
+
// A credential in a .env line, quoted or not: DB_PASSWORD=..., OPENAI_API_KEY="...".
|
|
151
|
+
{
|
|
152
|
+
kind: "secret",
|
|
153
|
+
pattern: /\b(?:[A-Z0-9]+_)*(?:PASSWORD|PASSWD|SECRET|TOKEN|API_KEY|APIKEY|SECRET_KEY|ACCESS_KEY|PRIVATE_KEY|CLIENT_SECRET|AUTH_TOKEN)[ \t]*=[ \t]*["']?([!%&(-~]{6,})/g,
|
|
154
|
+
valid: envSecretValid,
|
|
155
|
+
group: 1,
|
|
156
|
+
},
|
|
132
157
|
{ kind: "iban", pattern: /\b[A-Z]{2}\d{2}(?: ?[A-Z0-9]{4}){2,7}(?: ?[A-Z0-9]{1,4})?\b/g, valid: ibanValid },
|
|
133
158
|
{
|
|
134
159
|
kind: "payment_card",
|
|
@@ -160,7 +185,13 @@ const DETECTORS = [
|
|
|
160
185
|
return d.length >= 9 && d.length <= 15;
|
|
161
186
|
},
|
|
162
187
|
},
|
|
163
|
-
{
|
|
188
|
+
{
|
|
189
|
+
kind: "phone",
|
|
190
|
+
// A North American number written the North American way: (415) 555-0132, 415-555-0132.
|
|
191
|
+
pattern: /(?:\+1[ .-]?)?\([2-9]\d{2}\)[ .-]?[2-9]\d{2}[ .-]\d{4}\b|\b[2-9]\d{2}[.-][2-9]\d{2}[.-]\d{4}\b/g,
|
|
192
|
+
},
|
|
193
|
+
{ kind: "ip_address", pattern: /\b(?:(?:version|release|build|ver|v)[ \t:]*)?(?:\d{1,3}\.){3}\d{1,3}(?:\.\d+)*\b/gi, valid: ipv4Valid },
|
|
194
|
+
{ kind: "ip_address", pattern: /\b[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{0,4}){2,7}\b/g, valid: ipv6Valid },
|
|
164
195
|
{ kind: "special_category", pattern: SPECIAL_PATTERN },
|
|
165
196
|
];
|
|
166
197
|
/** Earlier wins an overlap: a card number is not also a phone number. */
|
package/dist/dev.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAYb,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAYb,MAAM,YAAY,CAAC;AAIpB;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAE7F,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,kBAAkB,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,KAAK,kBAAkB,CAAC,CAAC;IAC/E,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAcD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,UAAU,CAAC,KAAK,CAynB1F"}
|
package/dist/dev.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assessCounts, DEFAULT_SCREEN_POLICY, describeCounts } from "./data-screen.js";
|
|
2
|
+
import { applyPurview } from "./purview-rules.js";
|
|
2
3
|
const DEFAULT_QUESTION = "Has this been through staging?";
|
|
3
4
|
let counter = 0;
|
|
4
5
|
/**
|
|
@@ -553,13 +554,13 @@ export function developmentFetch(options = {}) {
|
|
|
553
554
|
if (method === "POST" && path === "/screen") {
|
|
554
555
|
const counts = (body.counts ?? {});
|
|
555
556
|
const termClassification = body.termClassification === "restricted" ? "restricted" : "confidential";
|
|
556
|
-
const assessment = assessCounts(counts, null, DEFAULT_SCREEN_POLICY, termClassification);
|
|
557
|
+
const assessment = applyPurview(assessCounts(counts, null, DEFAULT_SCREEN_POLICY, termClassification), (body.purview ?? null));
|
|
557
558
|
let approval = null;
|
|
558
559
|
if (assessment.verdict === "ask" && body.ask !== false) {
|
|
559
560
|
const created = (await (await handle(`${url.origin}/api/v1/approvals`, {
|
|
560
561
|
method: "POST",
|
|
561
562
|
body: JSON.stringify({
|
|
562
|
-
title: `Send ${describeCounts(counts)} to an AI model
|
|
563
|
+
title: assessment.offending.length ? `Send ${describeCounts(counts)} to an AI model?` : "Send text Microsoft Purview flagged to an AI model?",
|
|
563
564
|
description: assessment.reasons.join("\n"),
|
|
564
565
|
risk: assessment.classification === "restricted" ? "high" : "medium",
|
|
565
566
|
externalId: body.externalId,
|
|
@@ -580,6 +581,7 @@ export function developmentFetch(options = {}) {
|
|
|
580
581
|
findings: null,
|
|
581
582
|
redactedText: null,
|
|
582
583
|
approval,
|
|
584
|
+
purview: body.purview ?? null,
|
|
583
585
|
});
|
|
584
586
|
}
|
|
585
587
|
const taskMatch = /^\/tasks\/([^/]+)(?:\/(context|graph|side-tasks|findings|complete|apply|reopen|cancel|links))?$/.exec(path);
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export { AiGovernance, AiSystems, Incidents } from "./governance.js";
|
|
|
27
27
|
export { WebhookEndpoints } from "./webhook-endpoints.js";
|
|
28
28
|
export { canonicalJson, DECISION_TOKEN_CONTEXT, DECISION_TOKEN_PREFIX, decisionInputHash, DecisionTokens, EVIDENCE_KEY_PATH, verifyDecisionToken, type DecisionTokenClaims, type DecisionTokenExpectation, type DecisionTokenFailure, type DecisionTokenResult, } from "./decision-token.js";
|
|
29
29
|
export { Screened, type ScreenOptions } from "./screen.js";
|
|
30
|
+
export { entraAppToken, purviewCheck, type EntraAppTokenOptions, type PurviewCheck, type PurviewCheckOptions, type PurviewOutcome, type PurviewOnUnavailable, type PurviewRestriction } from "./purview.js";
|
|
30
31
|
export { DATA_KINDS, redact, restore, screenText, summarise, type DataKind, type DetectedSpan, type Redaction, type ScreenFinding, type ScreenTerm, type SpanDetector, } from "./data-screen.js";
|
|
31
32
|
export { constructCallback, constructEvent, DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, TOLERANCE_SECONDS, verifySignature, Webhooks, } from "./webhooks.js";
|
|
32
33
|
export { DeliverdError, DeliverdTimeout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E;IACtE;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIpE,OAAO,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAGjF;AAoBD,eAAO,MAAM,QAAQ,EAAE,QAMrB,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export { AiGovernance, AiSystems, Incidents } from "./governance.js";
|
|
|
26
26
|
export { WebhookEndpoints } from "./webhook-endpoints.js";
|
|
27
27
|
export { canonicalJson, DECISION_TOKEN_CONTEXT, DECISION_TOKEN_PREFIX, decisionInputHash, DecisionTokens, EVIDENCE_KEY_PATH, verifyDecisionToken, } from "./decision-token.js";
|
|
28
28
|
export { Screened } from "./screen.js";
|
|
29
|
+
export { entraAppToken, purviewCheck } from "./purview.js";
|
|
29
30
|
export { DATA_KINDS, redact, restore, screenText, summarise, } from "./data-screen.js";
|
|
30
31
|
export { constructCallback, constructEvent, DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, TOLERANCE_SECONDS, verifySignature, Webhooks, } from "./webhooks.js";
|
|
31
32
|
export { DeliverdError, DeliverdTimeoutError } from "./errors.js";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Microsoft Purview's answer on a text, held beside Deliverd's own.
|
|
3
|
+
*
|
|
4
|
+
* An organisation that runs Microsoft Purview has already written its data
|
|
5
|
+
* loss prevention (DLP) policies there. An app can ask Purview about a text
|
|
6
|
+
* before it is sent to a model, through Microsoft Graph's `processContent`,
|
|
7
|
+
* and Purview answers with what the app must do: nothing, or a restricted
|
|
8
|
+
* access action whose `restrictionAction` is `audit`, `warn` or `block`.
|
|
9
|
+
*
|
|
10
|
+
* The SDKs make that call where the agent runs, with the organisation's own
|
|
11
|
+
* Entra app, so the text goes to Microsoft and never to Deliverd. Deliverd is
|
|
12
|
+
* sent only the outcome below, and holds it beside its own screening:
|
|
13
|
+
*
|
|
14
|
+
* - `block`: nothing is sent. The organisation's own policy said so, and it
|
|
15
|
+
* is honoured on every plan, report-only included.
|
|
16
|
+
* - `warn`: a person decides, through an ordinary approval. Purview's "warn"
|
|
17
|
+
* is an override a user may make; here the override is recorded, with who
|
|
18
|
+
* made it.
|
|
19
|
+
* - `audit`: no hold. Purview has recorded the activity itself.
|
|
20
|
+
*
|
|
21
|
+
* When Purview cannot be reached, the caller has already decided what that
|
|
22
|
+
* means (allow, ask or deny) and says so in `restriction`, with `unavailable`
|
|
23
|
+
* set, so the reason given is honest about it.
|
|
24
|
+
*
|
|
25
|
+
* Pure, with no imports. This file is copied verbatim into
|
|
26
|
+
* `packages/sdk/src/purview-rules.ts` and `packages/screen/src/purview-rules.ts`,
|
|
27
|
+
* and a test fails when they differ.
|
|
28
|
+
*/
|
|
29
|
+
export declare const PURVIEW_RESTRICTIONS: readonly ["audit", "warn", "block"];
|
|
30
|
+
export type PurviewRestriction = (typeof PURVIEW_RESTRICTIONS)[number];
|
|
31
|
+
export interface PurviewOutcome {
|
|
32
|
+
/** The strictest restriction among Purview's policy actions; null when there were none. */
|
|
33
|
+
restriction: PurviewRestriction | null;
|
|
34
|
+
/** How many policy actions Purview returned. */
|
|
35
|
+
actions: number;
|
|
36
|
+
/** Purview said the organisation's policies changed since the caller last looked. */
|
|
37
|
+
scopeModified: boolean;
|
|
38
|
+
/** Purview could not be reached; `restriction` is what the caller chose for that case. */
|
|
39
|
+
unavailable: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** What a caller does when Purview cannot be reached. */
|
|
42
|
+
export type PurviewOnUnavailable = "allow" | "ask" | "deny";
|
|
43
|
+
/**
|
|
44
|
+
* The outcome of a `processContent` response body. Anything unrecognised in
|
|
45
|
+
* a policy action counts as a block: a DLP rule the code does not understand
|
|
46
|
+
* is not a reason to send the text.
|
|
47
|
+
*/
|
|
48
|
+
export declare function purviewOutcomeFromResponse(body: unknown): PurviewOutcome;
|
|
49
|
+
/** The outcome when Purview could not be reached, by the caller's choice. */
|
|
50
|
+
export declare function purviewUnavailable(onUnavailable: PurviewOnUnavailable): PurviewOutcome;
|
|
51
|
+
type Verdict = "allow" | "redact" | "ask" | "deny";
|
|
52
|
+
/**
|
|
53
|
+
* Deliverd's verdict with Purview's held beside it: the stricter wins, and
|
|
54
|
+
* the reason says it was Purview. `enforce` false is the report-only mode,
|
|
55
|
+
* where Deliverd holds nothing back of its own but a Purview block still
|
|
56
|
+
* stands, because it is the organisation's own policy, not Deliverd's.
|
|
57
|
+
*/
|
|
58
|
+
export declare function applyPurview<T extends {
|
|
59
|
+
verdict: Verdict;
|
|
60
|
+
reasons: string[];
|
|
61
|
+
}>(assessment: T, outcome: PurviewOutcome | null | undefined, enforce?: boolean): T;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=purview-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purview-rules.d.ts","sourceRoot":"","sources":["../src/purview-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,eAAO,MAAM,oBAAoB,qCAAsC,CAAC;AACxE,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvE,MAAM,WAAW,cAAc;IAC7B,2FAA2F;IAC3F,WAAW,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACvC,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,aAAa,EAAE,OAAO,CAAC;IACvB,0FAA0F;IAC1F,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,yDAAyD;AACzD,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAI5D;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,OAAO,GAAG,cAAc,CAWxE;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,oBAAoB,GAAG,cAAc,CAGtF;AAED,KAAK,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAGnD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,EAC5E,UAAU,EAAE,CAAC,EACb,OAAO,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,EAC1C,OAAO,UAAO,GACb,CAAC,CA+BH"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Microsoft Purview's answer on a text, held beside Deliverd's own.
|
|
3
|
+
*
|
|
4
|
+
* An organisation that runs Microsoft Purview has already written its data
|
|
5
|
+
* loss prevention (DLP) policies there. An app can ask Purview about a text
|
|
6
|
+
* before it is sent to a model, through Microsoft Graph's `processContent`,
|
|
7
|
+
* and Purview answers with what the app must do: nothing, or a restricted
|
|
8
|
+
* access action whose `restrictionAction` is `audit`, `warn` or `block`.
|
|
9
|
+
*
|
|
10
|
+
* The SDKs make that call where the agent runs, with the organisation's own
|
|
11
|
+
* Entra app, so the text goes to Microsoft and never to Deliverd. Deliverd is
|
|
12
|
+
* sent only the outcome below, and holds it beside its own screening:
|
|
13
|
+
*
|
|
14
|
+
* - `block`: nothing is sent. The organisation's own policy said so, and it
|
|
15
|
+
* is honoured on every plan, report-only included.
|
|
16
|
+
* - `warn`: a person decides, through an ordinary approval. Purview's "warn"
|
|
17
|
+
* is an override a user may make; here the override is recorded, with who
|
|
18
|
+
* made it.
|
|
19
|
+
* - `audit`: no hold. Purview has recorded the activity itself.
|
|
20
|
+
*
|
|
21
|
+
* When Purview cannot be reached, the caller has already decided what that
|
|
22
|
+
* means (allow, ask or deny) and says so in `restriction`, with `unavailable`
|
|
23
|
+
* set, so the reason given is honest about it.
|
|
24
|
+
*
|
|
25
|
+
* Pure, with no imports. This file is copied verbatim into
|
|
26
|
+
* `packages/sdk/src/purview-rules.ts` and `packages/screen/src/purview-rules.ts`,
|
|
27
|
+
* and a test fails when they differ.
|
|
28
|
+
*/
|
|
29
|
+
export const PURVIEW_RESTRICTIONS = ["audit", "warn", "block"];
|
|
30
|
+
const RESTRICTION_RANK = { audit: 0, warn: 1, block: 2 };
|
|
31
|
+
/**
|
|
32
|
+
* The outcome of a `processContent` response body. Anything unrecognised in
|
|
33
|
+
* a policy action counts as a block: a DLP rule the code does not understand
|
|
34
|
+
* is not a reason to send the text.
|
|
35
|
+
*/
|
|
36
|
+
export function purviewOutcomeFromResponse(body) {
|
|
37
|
+
const b = (body ?? {});
|
|
38
|
+
const actions = Array.isArray(b.policyActions) ? b.policyActions : [];
|
|
39
|
+
let restriction = null;
|
|
40
|
+
for (const raw of actions) {
|
|
41
|
+
const a = (raw ?? {});
|
|
42
|
+
const given = typeof a.restrictionAction === "string" ? a.restrictionAction : null;
|
|
43
|
+
const r = given === "audit" || given === "warn" || given === "block" ? given : "block";
|
|
44
|
+
if (restriction === null || RESTRICTION_RANK[r] > RESTRICTION_RANK[restriction])
|
|
45
|
+
restriction = r;
|
|
46
|
+
}
|
|
47
|
+
return { restriction, actions: actions.length, scopeModified: b.protectionScopeState === "modified", unavailable: false };
|
|
48
|
+
}
|
|
49
|
+
/** The outcome when Purview could not be reached, by the caller's choice. */
|
|
50
|
+
export function purviewUnavailable(onUnavailable) {
|
|
51
|
+
const restriction = onUnavailable === "deny" ? "block" : onUnavailable === "ask" ? "warn" : null;
|
|
52
|
+
return { restriction, actions: 0, scopeModified: false, unavailable: true };
|
|
53
|
+
}
|
|
54
|
+
const VERDICT_RANK = { allow: 0, redact: 1, ask: 2, deny: 3 };
|
|
55
|
+
/**
|
|
56
|
+
* Deliverd's verdict with Purview's held beside it: the stricter wins, and
|
|
57
|
+
* the reason says it was Purview. `enforce` false is the report-only mode,
|
|
58
|
+
* where Deliverd holds nothing back of its own but a Purview block still
|
|
59
|
+
* stands, because it is the organisation's own policy, not Deliverd's.
|
|
60
|
+
*/
|
|
61
|
+
export function applyPurview(assessment, outcome, enforce = true) {
|
|
62
|
+
if (!outcome)
|
|
63
|
+
return assessment;
|
|
64
|
+
const reasons = [...assessment.reasons];
|
|
65
|
+
let verdict = assessment.verdict;
|
|
66
|
+
const raise = (to) => {
|
|
67
|
+
if (VERDICT_RANK[to] > VERDICT_RANK[verdict])
|
|
68
|
+
verdict = to;
|
|
69
|
+
};
|
|
70
|
+
if (outcome.unavailable) {
|
|
71
|
+
if (outcome.restriction === "block") {
|
|
72
|
+
raise("deny");
|
|
73
|
+
reasons.push("Microsoft Purview could not be reached, and this agent is set not to send text Purview has not checked.");
|
|
74
|
+
}
|
|
75
|
+
else if (outcome.restriction === "warn" && enforce) {
|
|
76
|
+
raise("ask");
|
|
77
|
+
reasons.push("Microsoft Purview could not be reached, so a person decides whether to send it unchecked.");
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
reasons.push("Microsoft Purview could not be reached, so this was not checked against your Purview policies.");
|
|
81
|
+
}
|
|
82
|
+
return { ...assessment, verdict, reasons };
|
|
83
|
+
}
|
|
84
|
+
if (outcome.restriction === "block") {
|
|
85
|
+
raise("deny");
|
|
86
|
+
reasons.push("Your organisation's Microsoft Purview policy blocks sending this text.");
|
|
87
|
+
}
|
|
88
|
+
else if (outcome.restriction === "warn") {
|
|
89
|
+
if (enforce) {
|
|
90
|
+
raise("ask");
|
|
91
|
+
reasons.push("Your organisation's Microsoft Purview policy warns about this text, so a person decides.");
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
reasons.push("Your organisation's Microsoft Purview policy warns about this text.");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return { ...assessment, verdict, reasons };
|
|
98
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { type PurviewOnUnavailable, type PurviewOutcome } from "./purview-rules.js";
|
|
2
|
+
export { type PurviewOutcome, type PurviewOnUnavailable, type PurviewRestriction } from "./purview-rules.js";
|
|
3
|
+
/**
|
|
4
|
+
* Ask your organisation's Microsoft Purview about a text before it goes to a
|
|
5
|
+
* model, and hold its answer beside Deliverd's.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const purview = purviewCheck({
|
|
9
|
+
* token: () => credential.getToken("https://graph.microsoft.com/.default").then((t) => t.token),
|
|
10
|
+
* userId: entraObjectIdOfTheUser,
|
|
11
|
+
* app: { name: "Claims assistant", entraAppId: "11111111-…" },
|
|
12
|
+
* });
|
|
13
|
+
* const screened = await deliverd.screen(prompt, { aiSystemId: CLAIMS_MODEL, purview });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* The call goes from where your agent runs straight to Microsoft Graph
|
|
17
|
+
* (`processContent`), with your own Entra app's token, so the text goes to
|
|
18
|
+
* Microsoft and never to Deliverd. Deliverd is sent only the outcome: block,
|
|
19
|
+
* warn, audit or nothing. A block stops the text; a warn puts it to a person.
|
|
20
|
+
*
|
|
21
|
+
* The Entra app needs `Content.Process.User` or `Content.Process.All`
|
|
22
|
+
* (application permission with `userId`, or delegated with the signed-in
|
|
23
|
+
* user's token and no `userId`). Purview applies DLP policies to an
|
|
24
|
+
* Entra-registered app only when they were created with
|
|
25
|
+
* `New-DlpComplianceRule`; one made in the portal alone does not apply.
|
|
26
|
+
*/
|
|
27
|
+
export interface PurviewCheckOptions {
|
|
28
|
+
/** A Microsoft Graph access token, or a function that returns one. Called on every check, so a credential can refresh it. */
|
|
29
|
+
token: string | (() => string | Promise<string>);
|
|
30
|
+
/** The Entra object id of the user the text is for. Omit to use `/me` with a delegated token. */
|
|
31
|
+
userId?: string;
|
|
32
|
+
/** Your app as Purview knows it: its name and its Entra application (client) id. */
|
|
33
|
+
app: {
|
|
34
|
+
name: string;
|
|
35
|
+
entraAppId: string;
|
|
36
|
+
version?: string;
|
|
37
|
+
};
|
|
38
|
+
/** The agent sending the text, when it is one, as Purview's AI agent info. */
|
|
39
|
+
agent?: {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
version?: string;
|
|
43
|
+
blueprintId?: string;
|
|
44
|
+
};
|
|
45
|
+
/** One id per conversation, so Purview can group the texts in it. */
|
|
46
|
+
correlationId?: string;
|
|
47
|
+
/** What to do when Purview cannot be reached. Default `ask`: a person decides. */
|
|
48
|
+
onUnavailable?: PurviewOnUnavailable;
|
|
49
|
+
/** Milliseconds to wait for Purview. Default 10,000. */
|
|
50
|
+
timeoutMs?: number;
|
|
51
|
+
fetch?: typeof fetch;
|
|
52
|
+
}
|
|
53
|
+
/** A check `screen()` runs on the text before asking Deliverd. */
|
|
54
|
+
export type PurviewCheck = (text: string) => Promise<PurviewOutcome>;
|
|
55
|
+
/** The body `processContent` takes for a prompt about to be sent to a model. */
|
|
56
|
+
export declare function processContentBody(text: string, options: Pick<PurviewCheckOptions, "app" | "agent" | "correlationId">, sequenceNumber?: number): {
|
|
57
|
+
contentToProcess: {
|
|
58
|
+
contentEntries: {
|
|
59
|
+
agents?: {
|
|
60
|
+
blueprintId?: string | undefined;
|
|
61
|
+
version?: string | undefined;
|
|
62
|
+
"@odata.type": string;
|
|
63
|
+
identifier: string;
|
|
64
|
+
name: string;
|
|
65
|
+
}[] | undefined;
|
|
66
|
+
"@odata.type": string;
|
|
67
|
+
identifier: string;
|
|
68
|
+
content: {
|
|
69
|
+
"@odata.type": string;
|
|
70
|
+
data: string;
|
|
71
|
+
};
|
|
72
|
+
name: string;
|
|
73
|
+
correlationId: string;
|
|
74
|
+
sequenceNumber: number;
|
|
75
|
+
isTruncated: boolean;
|
|
76
|
+
createdDateTime: string;
|
|
77
|
+
modifiedDateTime: string;
|
|
78
|
+
}[];
|
|
79
|
+
activityMetadata: {
|
|
80
|
+
activity: string;
|
|
81
|
+
};
|
|
82
|
+
deviceMetadata: {};
|
|
83
|
+
protectedAppMetadata: {
|
|
84
|
+
name: string;
|
|
85
|
+
version: string;
|
|
86
|
+
applicationLocation: {
|
|
87
|
+
"@odata.type": string;
|
|
88
|
+
value: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
integratedAppMetadata: {
|
|
92
|
+
name: string;
|
|
93
|
+
version: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
export interface EntraAppTokenOptions {
|
|
98
|
+
/** The customer's Entra tenant id: where the DLP policies are. */
|
|
99
|
+
tenantId: string;
|
|
100
|
+
/** The app's application (client) id. */
|
|
101
|
+
clientId: string;
|
|
102
|
+
/** A client secret for it. Keep it in a secret store, never in code. */
|
|
103
|
+
clientSecret: string;
|
|
104
|
+
fetch?: typeof fetch;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A Microsoft Graph token for an app acting as itself (client credentials),
|
|
108
|
+
* for `purviewCheck`'s `token` where there is no signed-in user: a pipeline,
|
|
109
|
+
* a local MCP server, a back-end agent. Cached until five minutes before it
|
|
110
|
+
* expires. Use it with `userId`, the person the text is about or on behalf of.
|
|
111
|
+
*/
|
|
112
|
+
export declare function entraAppToken(options: EntraAppTokenOptions): () => Promise<string>;
|
|
113
|
+
export declare function purviewCheck(options: PurviewCheckOptions): PurviewCheck;
|
|
114
|
+
//# sourceMappingURL=purview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purview.d.ts","sourceRoot":"","sources":["../src/purview.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,oBAAoB,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7G;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,WAAW,mBAAmB;IAClC,6HAA6H;IAC7H,KAA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