@entros/verify 0.1.1 → 0.3.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.
@@ -0,0 +1,414 @@
1
+ // src/policy.ts
2
+ var POLICY_NETWORK = Object.freeze({
3
+ genesisHash: "EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG",
4
+ programIds: Object.freeze({
5
+ anchor: "GZYwTp2ozeuRA5Gof9vs4ya961aANcJBdUzB7LN6q4b2",
6
+ verifier: "4F97jNoxQzT2qRbkWpW3ztC3Nz2TtKj3rnKG8ExgnrfV",
7
+ registry: "6VBs3zr9KrfFPGd6j7aGBPQWwZa5tajVfA7HN6MMV9VW",
8
+ sas: "22zoJMtdu4tQc2PzL74ZUT7FrwgB1Udec8DdW4yw4BdG",
9
+ credential: "AMBtabCgRFwGLjoZ21Z2LhSKJ6c47NckxUkMogJ3Lpuw",
10
+ schema: "5LNc7syFW7USPLveVLcNcjjY1xqS7QTXVjHZ7CQCbAMQ"
11
+ })
12
+ });
13
+ var PolicyValidationError = class extends Error {
14
+ constructor(reason) {
15
+ super(`Invalid verification policy: ${reason}`);
16
+ this.reason = reason;
17
+ this.name = "PolicyValidationError";
18
+ }
19
+ };
20
+ function record(value) {
21
+ return typeof value === "object" && value !== null && !Array.isArray(value);
22
+ }
23
+ function exactKeys(value, keys) {
24
+ return Object.keys(value).length === keys.length && keys.every((key) => Object.prototype.hasOwnProperty.call(value, key));
25
+ }
26
+ function integer(value, minimum = 0, maximum = Number.MAX_SAFE_INTEGER) {
27
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= minimum && value <= maximum;
28
+ }
29
+ var REQUEST_KEYS = [
30
+ "id",
31
+ "version",
32
+ "minTrustScore",
33
+ "maxVerificationAgeSeconds",
34
+ "maxEvaluationAgeSeconds",
35
+ "requiredAssurance",
36
+ "uniquenessRequirement",
37
+ "requireAttestation",
38
+ "cluster"
39
+ ];
40
+ function normalizePolicyRequest(input, legacyMinTrustScore) {
41
+ if (legacyMinTrustScore !== void 0 && !integer(legacyMinTrustScore, 0, 1e4)) {
42
+ throw new PolicyValidationError("unsupported_policy");
43
+ }
44
+ const value = input === void 0 ? {
45
+ id: "entros-verify-default",
46
+ version: 1,
47
+ minTrustScore: legacyMinTrustScore ?? 0,
48
+ maxVerificationAgeSeconds: 86400,
49
+ requiredAssurance: "browser_unattested",
50
+ uniquenessRequirement: "allow_unmeasured",
51
+ cluster: "devnet"
52
+ } : input;
53
+ if (!record(value) || Object.keys(value).some(
54
+ (key) => !REQUEST_KEYS.includes(key)
55
+ )) {
56
+ throw new PolicyValidationError("unsupported_policy");
57
+ }
58
+ if (value.requiredAssurance !== "browser_unattested")
59
+ throw new PolicyValidationError("unsupported_assurance");
60
+ if (value.uniquenessRequirement !== "allow_unmeasured")
61
+ throw new PolicyValidationError("unsupported_uniqueness");
62
+ if (typeof value.id !== "string" || !/^[A-Za-z0-9_-]{1,64}$/.test(value.id) || value.version !== 1 || !integer(value.minTrustScore, 0, 1e4) || !integer(value.maxVerificationAgeSeconds, 1, 31536e3) || !integer(
63
+ value.maxEvaluationAgeSeconds === void 0 ? 90 : value.maxEvaluationAgeSeconds,
64
+ 1,
65
+ 90
66
+ ) || value.requireAttestation !== void 0 && typeof value.requireAttestation !== "boolean" || value.cluster !== "devnet" || legacyMinTrustScore !== void 0 && value.minTrustScore !== legacyMinTrustScore) {
67
+ throw new PolicyValidationError("unsupported_policy");
68
+ }
69
+ return {
70
+ id: value.id,
71
+ version: 1,
72
+ minTrustScore: value.minTrustScore,
73
+ maxVerificationAgeSeconds: value.maxVerificationAgeSeconds,
74
+ maxEvaluationAgeSeconds: value.maxEvaluationAgeSeconds ?? 90,
75
+ requiredAssurance: "browser_unattested",
76
+ uniquenessRequirement: "allow_unmeasured",
77
+ requireAttestation: value.requireAttestation === true,
78
+ cluster: "devnet"
79
+ };
80
+ }
81
+ function encodePolicyRequest(request) {
82
+ return JSON.stringify(normalizePolicyRequest(request));
83
+ }
84
+ function parsePolicyParameters(params, legacyMinTrustScore) {
85
+ for (const key of ["policy", "policy_version", "min_trust_score"]) {
86
+ if (params.getAll(key).length > 1)
87
+ throw new PolicyValidationError("unsupported_policy");
88
+ }
89
+ const floorText = params.get("min_trust_score");
90
+ if (floorText !== null) {
91
+ if (!/^(0|[1-9][0-9]{0,4})$/.test(floorText) || !integer(Number(floorText), 0, 1e4) || legacyMinTrustScore !== void 0 && legacyMinTrustScore !== Number(floorText))
92
+ throw new PolicyValidationError("unsupported_policy");
93
+ legacyMinTrustScore = Number(floorText);
94
+ }
95
+ const encoded = params.get("policy");
96
+ const marker = params.get("policy_version");
97
+ if (encoded === null && marker === null) {
98
+ return {
99
+ negotiated: false,
100
+ policy: {
101
+ ...normalizePolicyRequest(void 0, legacyMinTrustScore),
102
+ requireAttestation: true
103
+ }
104
+ };
105
+ }
106
+ if (marker !== "1" || encoded === null || encoded.length > 2048)
107
+ throw new PolicyValidationError("unsupported_policy");
108
+ let raw;
109
+ try {
110
+ raw = JSON.parse(encoded);
111
+ } catch {
112
+ throw new PolicyValidationError("unsupported_policy");
113
+ }
114
+ const policy = normalizePolicyRequest(raw, legacyMinTrustScore);
115
+ if (encodePolicyRequest(policy) !== encoded)
116
+ throw new PolicyValidationError("unsupported_policy");
117
+ return { negotiated: true, policy };
118
+ }
119
+ var BASE58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
120
+ function base58Bytes(value, expected) {
121
+ if (typeof value !== "string" || value.length < 1 || value.length > expected * 2)
122
+ return false;
123
+ let number = 0n;
124
+ for (const character of value) {
125
+ const digit = BASE58.indexOf(character);
126
+ if (digit < 0) return false;
127
+ number = number * 58n + BigInt(digit);
128
+ }
129
+ let bytes = 0;
130
+ while (number > 0n) {
131
+ bytes++;
132
+ number >>= 8n;
133
+ }
134
+ let zeros = 0;
135
+ while (value[zeros] === "1") zeros++;
136
+ return bytes + zeros === expected;
137
+ }
138
+ function commitment(value) {
139
+ return typeof value === "string" && /^[0-9a-f]{64}$/.test(value) && !/^0+$/.test(value);
140
+ }
141
+ function isPolicyAttestation(value) {
142
+ if (!record(value)) return false;
143
+ if (value.status === "present") {
144
+ return exactKeys(value, ["status", "address", "readContextSlot", "expiresAt"]) && base58Bytes(value.address, 32) && integer(value.readContextSlot) && (value.expiresAt === null || integer(value.expiresAt, 1));
145
+ }
146
+ return exactKeys(value, ["status"]) && ["missing", "invalid", "unavailable"].includes(String(value.status));
147
+ }
148
+ function isPolicyEvidence(value) {
149
+ if (!record(value) || !exactKeys(value, [
150
+ "cluster",
151
+ "genesisHash",
152
+ "programIds",
153
+ "assuranceTier",
154
+ "uniquenessStatus",
155
+ "readContextSlot",
156
+ "identity",
157
+ "transaction",
158
+ "attestation"
159
+ ]))
160
+ return false;
161
+ if (value.cluster !== "devnet" || value.genesisHash !== POLICY_NETWORK.genesisHash || value.assuranceTier !== "browser_unattested" || value.uniquenessStatus !== "unmeasured" || !integer(value.readContextSlot))
162
+ return false;
163
+ const programs = value.programIds;
164
+ if (!record(programs) || !exactKeys(programs, Object.keys(POLICY_NETWORK.programIds)) || Object.entries(POLICY_NETWORK.programIds).some(
165
+ ([key, id]) => programs[key] !== id
166
+ ))
167
+ return false;
168
+ const identity = value.identity;
169
+ const transaction = value.transaction;
170
+ if (!record(identity) || !exactKeys(identity, [
171
+ "walletPubkey",
172
+ "identityPda",
173
+ "creationTimestamp",
174
+ "lastVerificationTimestamp",
175
+ "verificationCount",
176
+ "trustScore",
177
+ "currentCommitment",
178
+ "projectionVersion",
179
+ "lastResetTimestamp",
180
+ "lastRebaselineTimestamp",
181
+ "mint"
182
+ ]) || !base58Bytes(identity.walletPubkey, 32) || !base58Bytes(identity.identityPda, 32) || !base58Bytes(identity.mint, 32) || !integer(identity.creationTimestamp, 1) || !integer(identity.lastVerificationTimestamp, identity.creationTimestamp) || !integer(identity.verificationCount, 0, 4294967295) || !integer(identity.trustScore, 0, 1e4) || !commitment(identity.currentCommitment) || !integer(identity.projectionVersion, 0, 2) || !integer(identity.lastResetTimestamp) || !integer(identity.lastRebaselineTimestamp))
183
+ return false;
184
+ if (!record(transaction) || !exactKeys(transaction, [
185
+ "signature",
186
+ "slot",
187
+ "blockTime",
188
+ "commitment",
189
+ "kind"
190
+ ]) || !base58Bytes(transaction.signature, 64) || !integer(transaction.slot) || !integer(transaction.blockTime, identity.creationTimestamp) || !commitment(transaction.commitment) || !["mint", "update", "rebaseline"].includes(String(transaction.kind)))
191
+ return false;
192
+ return isPolicyAttestation(value.attestation);
193
+ }
194
+ function evaluatePolicy(request, observation, nowSeconds) {
195
+ const requirements = normalizePolicyRequest(request);
196
+ if (!integer(nowSeconds, 1) || nowSeconds > Number.MAX_SAFE_INTEGER - 31536e3)
197
+ throw new PolicyValidationError("invalid_evidence");
198
+ const base = {
199
+ policyId: requirements.id,
200
+ policyVersion: 1,
201
+ requirements,
202
+ evaluatedAt: nowSeconds,
203
+ expiresAt: nowSeconds,
204
+ evidenceTimestamp: null,
205
+ evaluatedAgeSeconds: null
206
+ };
207
+ if (record(observation) && observation.status === "unavailable")
208
+ return {
209
+ ...base,
210
+ decision: "unavailable",
211
+ reason: "state_unavailable",
212
+ evidence: null
213
+ };
214
+ if (!record(observation) || observation.status !== "available" || !isPolicyEvidence(observation.evidence)) {
215
+ return {
216
+ ...base,
217
+ decision: "deny",
218
+ reason: "invalid_evidence",
219
+ evidence: null
220
+ };
221
+ }
222
+ const evidence = observation.evidence;
223
+ const { identity, transaction, attestation } = evidence;
224
+ const deny = (reason) => ({ ...base, decision: "deny", reason, evidence });
225
+ const freshMint = transaction.kind === "mint" && identity.verificationCount === 0 && identity.trustScore === 0 && identity.creationTimestamp === transaction.blockTime && identity.lastVerificationTimestamp === transaction.blockTime && identity.lastResetTimestamp === 0 && identity.lastRebaselineTimestamp === 0;
226
+ if (identity.verificationCount === 0 && !freshMint || identity.currentCommitment !== transaction.commitment || identity.lastResetTimestamp >= transaction.blockTime || identity.lastResetTimestamp > identity.lastVerificationTimestamp || identity.lastRebaselineTimestamp > identity.lastVerificationTimestamp || identity.lastRebaselineTimestamp > transaction.blockTime || identity.lastVerificationTimestamp > nowSeconds || transaction.blockTime > nowSeconds || evidence.readContextSlot < transaction.slot || attestation.status === "invalid" || attestation.status === "present" && (attestation.readContextSlot < transaction.slot || attestation.expiresAt !== null && attestation.expiresAt <= nowSeconds)) {
227
+ return deny("invalid_evidence");
228
+ }
229
+ base.evidenceTimestamp = Math.min(
230
+ identity.lastVerificationTimestamp,
231
+ transaction.blockTime
232
+ );
233
+ base.evaluatedAgeSeconds = nowSeconds - base.evidenceTimestamp;
234
+ base.expiresAt = Math.min(
235
+ base.evidenceTimestamp + requirements.maxVerificationAgeSeconds,
236
+ nowSeconds + requirements.maxEvaluationAgeSeconds
237
+ );
238
+ if (requirements.requireAttestation && attestation.status === "present" && attestation.expiresAt !== null)
239
+ base.expiresAt = Math.min(base.expiresAt, attestation.expiresAt);
240
+ if (identity.trustScore < requirements.minTrustScore)
241
+ return deny("score_below_minimum");
242
+ if (nowSeconds >= base.expiresAt) return deny("verification_stale");
243
+ if (requirements.requireAttestation && attestation.status === "missing")
244
+ return deny("attestation_required");
245
+ if (requirements.requireAttestation && attestation.status === "unavailable")
246
+ return {
247
+ ...base,
248
+ decision: "unavailable",
249
+ reason: "state_unavailable",
250
+ evidence
251
+ };
252
+ return { ...base, decision: "allow", reason: "accepted", evidence };
253
+ }
254
+ function policyResultToWire(result) {
255
+ const e = result.evidence;
256
+ return {
257
+ policy_id: result.policyId,
258
+ policy_version: 1,
259
+ decision: result.decision,
260
+ reason: result.reason,
261
+ requirements: result.requirements,
262
+ evaluated_at: result.evaluatedAt,
263
+ expires_at: result.expiresAt,
264
+ evidence_timestamp: result.evidenceTimestamp,
265
+ evaluated_age_seconds: result.evaluatedAgeSeconds,
266
+ wallet_pubkey: e?.identity.walletPubkey ?? null,
267
+ identity_pda: e?.identity.identityPda ?? null,
268
+ verified_transaction: e ? {
269
+ signature: e.transaction.signature,
270
+ slot: e.transaction.slot,
271
+ block_time: e.transaction.blockTime,
272
+ commitment: e.transaction.commitment,
273
+ kind: e.transaction.kind
274
+ } : null,
275
+ verification_timestamp: e?.identity.lastVerificationTimestamp ?? null,
276
+ trust_score: e?.identity.trustScore ?? null,
277
+ anchor_created_at: e?.identity.creationTimestamp ?? null,
278
+ verification_count: e?.identity.verificationCount ?? null,
279
+ current_commitment: e?.identity.currentCommitment ?? null,
280
+ projection_version: e?.identity.projectionVersion ?? null,
281
+ last_reset_timestamp: e?.identity.lastResetTimestamp ?? null,
282
+ last_rebaseline_timestamp: e?.identity.lastRebaselineTimestamp ?? null,
283
+ mint: e?.identity.mint ?? null,
284
+ uniqueness_status: e?.uniquenessStatus ?? null,
285
+ assurance_tier: e?.assuranceTier ?? null,
286
+ cluster: e?.cluster ?? null,
287
+ genesis_hash: e?.genesisHash ?? null,
288
+ program_ids: e?.programIds ?? null,
289
+ read_context_slot: e?.readContextSlot ?? null,
290
+ attestation: e ? e.attestation.status === "present" ? {
291
+ status: "present",
292
+ address: e.attestation.address,
293
+ read_context_slot: e.attestation.readContextSlot,
294
+ expires_at: e.attestation.expiresAt
295
+ } : e.attestation : null
296
+ };
297
+ }
298
+ function parsePolicyWireResult(input) {
299
+ if (!record(input) || !integer(input.evaluated_at, 1)) return null;
300
+ try {
301
+ const requirements = normalizePolicyRequest(input.requirements);
302
+ let observation;
303
+ if (input.wallet_pubkey === null) {
304
+ observation = input.decision === "unavailable" ? { status: "unavailable", reason: "state_unavailable" } : { status: "invalid", reason: "invalid_evidence" };
305
+ } else {
306
+ const tx = input.verified_transaction;
307
+ const sas = input.attestation;
308
+ if (!record(tx) || !record(sas)) return null;
309
+ const evidence = {
310
+ cluster: input.cluster,
311
+ genesisHash: input.genesis_hash,
312
+ programIds: input.program_ids,
313
+ assuranceTier: input.assurance_tier,
314
+ uniquenessStatus: input.uniqueness_status,
315
+ readContextSlot: input.read_context_slot,
316
+ identity: {
317
+ walletPubkey: input.wallet_pubkey,
318
+ identityPda: input.identity_pda,
319
+ creationTimestamp: input.anchor_created_at,
320
+ lastVerificationTimestamp: input.verification_timestamp,
321
+ verificationCount: input.verification_count,
322
+ trustScore: input.trust_score,
323
+ currentCommitment: input.current_commitment,
324
+ projectionVersion: input.projection_version,
325
+ lastResetTimestamp: input.last_reset_timestamp,
326
+ lastRebaselineTimestamp: input.last_rebaseline_timestamp,
327
+ mint: input.mint
328
+ },
329
+ transaction: {
330
+ signature: tx.signature,
331
+ slot: tx.slot,
332
+ blockTime: tx.block_time,
333
+ commitment: tx.commitment,
334
+ kind: tx.kind
335
+ },
336
+ attestation: sas.status === "present" ? {
337
+ status: "present",
338
+ address: sas.address,
339
+ readContextSlot: sas.read_context_slot,
340
+ expiresAt: sas.expires_at
341
+ } : { status: sas.status }
342
+ };
343
+ if (!isPolicyEvidence(evidence)) return null;
344
+ observation = { status: "available", evidence };
345
+ }
346
+ const result = evaluatePolicy(
347
+ requirements,
348
+ observation,
349
+ input.evaluated_at
350
+ );
351
+ return canonicalEqual(input, policyResultToWire(result)) ? result : null;
352
+ } catch {
353
+ return null;
354
+ }
355
+ }
356
+ function canonicalEqual(left, right) {
357
+ if (left === right) return true;
358
+ if (!record(left) || !record(right)) return false;
359
+ return exactKeys(left, Object.keys(right)) && Object.keys(right).every((key) => canonicalEqual(left[key], right[key]));
360
+ }
361
+ function isPolicyReason(value) {
362
+ return typeof value === "string" && [
363
+ "accepted",
364
+ "score_below_minimum",
365
+ "verification_stale",
366
+ "attestation_required",
367
+ "unsupported_policy",
368
+ "unsupported_assurance",
369
+ "unsupported_uniqueness",
370
+ "invalid_evidence",
371
+ "state_unavailable"
372
+ ].includes(value);
373
+ }
374
+ function validatePolicyVerifiedPayload(payload, requestedPolicy, nowSeconds) {
375
+ if (!record(payload)) return { ok: false, reason: "invalid_evidence" };
376
+ if (!Object.prototype.hasOwnProperty.call(payload, "policy"))
377
+ return { ok: false, reason: "unsupported_policy" };
378
+ const result = parsePolicyWireResult(payload.policy);
379
+ if (!result || !canonicalEqual(
380
+ result.requirements,
381
+ normalizePolicyRequest(requestedPolicy)
382
+ ))
383
+ return { ok: false, reason: "invalid_evidence" };
384
+ if (result.decision !== "allow") return { ok: false, reason: result.reason };
385
+ if (!integer(nowSeconds, 1) || result.evaluatedAt > nowSeconds || nowSeconds >= result.expiresAt)
386
+ return { ok: false, reason: "verification_stale" };
387
+ const current = evaluatePolicy(
388
+ requestedPolicy,
389
+ { status: "available", evidence: result.evidence },
390
+ nowSeconds
391
+ );
392
+ if (current.decision !== "allow")
393
+ return { ok: false, reason: current.reason };
394
+ const e = result.evidence;
395
+ const address = e.attestation.status === "present" ? e.attestation.address : null;
396
+ if (payload.wallet_pubkey !== e.identity.walletPubkey || payload.trust_score !== e.identity.trustScore || payload.cluster !== e.cluster || payload.tx_sig !== e.transaction.signature || payload.attestation_pda !== address)
397
+ return { ok: false, reason: "invalid_evidence" };
398
+ return { ok: true, result };
399
+ }
400
+ export {
401
+ POLICY_NETWORK,
402
+ PolicyValidationError,
403
+ encodePolicyRequest,
404
+ evaluatePolicy,
405
+ isPolicyAttestation,
406
+ isPolicyEvidence,
407
+ isPolicyReason,
408
+ normalizePolicyRequest,
409
+ parsePolicyParameters,
410
+ parsePolicyWireResult,
411
+ policyResultToWire,
412
+ validatePolicyVerifiedPayload
413
+ };
414
+ //# sourceMappingURL=policy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/policy.ts"],"sourcesContent":["/** Pure policy evaluation. RPC evidence must come from a trusted account reader. */\nexport interface PolicyRequest {\n id: string;\n version: 1;\n minTrustScore: number;\n maxVerificationAgeSeconds: number;\n maxEvaluationAgeSeconds: number;\n requiredAssurance: \"browser_unattested\";\n uniquenessRequirement: \"allow_unmeasured\";\n requireAttestation: boolean;\n cluster: \"devnet\";\n}\n\nexport type PolicyRequestInput = Omit<\n PolicyRequest,\n \"maxEvaluationAgeSeconds\" | \"requireAttestation\"\n> &\n Partial<\n Pick<PolicyRequest, \"maxEvaluationAgeSeconds\" | \"requireAttestation\">\n >;\n\nexport interface PolicyProgramIds {\n anchor: string;\n verifier: string;\n registry: string;\n sas: string;\n credential: string;\n schema: string;\n}\n\nexport const POLICY_NETWORK = Object.freeze({\n genesisHash: \"EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG\",\n programIds: Object.freeze({\n anchor: \"GZYwTp2ozeuRA5Gof9vs4ya961aANcJBdUzB7LN6q4b2\",\n verifier: \"4F97jNoxQzT2qRbkWpW3ztC3Nz2TtKj3rnKG8ExgnrfV\",\n registry: \"6VBs3zr9KrfFPGd6j7aGBPQWwZa5tajVfA7HN6MMV9VW\",\n sas: \"22zoJMtdu4tQc2PzL74ZUT7FrwgB1Udec8DdW4yw4BdG\",\n credential: \"AMBtabCgRFwGLjoZ21Z2LhSKJ6c47NckxUkMogJ3Lpuw\",\n schema: \"5LNc7syFW7USPLveVLcNcjjY1xqS7QTXVjHZ7CQCbAMQ\",\n } satisfies PolicyProgramIds),\n});\n\nexport type PolicyAttestation =\n | {\n status: \"present\";\n address: string;\n readContextSlot: number;\n expiresAt: number | null;\n }\n | { status: \"missing\" | \"invalid\" | \"unavailable\" };\n\nexport interface PolicyEvidence {\n cluster: \"devnet\";\n genesisHash: string;\n programIds: PolicyProgramIds;\n assuranceTier: \"browser_unattested\";\n uniquenessStatus: \"unmeasured\";\n readContextSlot: number;\n identity: {\n walletPubkey: string;\n identityPda: string;\n creationTimestamp: number;\n lastVerificationTimestamp: number;\n verificationCount: number;\n trustScore: number;\n currentCommitment: string;\n projectionVersion: number;\n lastResetTimestamp: number;\n lastRebaselineTimestamp: number;\n mint: string;\n };\n transaction: {\n signature: string;\n slot: number;\n blockTime: number;\n commitment: string;\n kind: \"mint\" | \"update\" | \"rebaseline\";\n };\n attestation: PolicyAttestation;\n}\n\nexport type PolicyEvidenceReadResult =\n | { status: \"available\"; evidence: PolicyEvidence }\n | { status: \"invalid\" | \"unavailable\"; reason: string };\n\nexport type PolicyReason =\n | \"accepted\"\n | \"score_below_minimum\"\n | \"verification_stale\"\n | \"attestation_required\"\n | \"unsupported_policy\"\n | \"unsupported_assurance\"\n | \"unsupported_uniqueness\"\n | \"invalid_evidence\"\n | \"state_unavailable\";\n\ninterface PolicyResultBase {\n policyId: string;\n policyVersion: 1;\n requirements: PolicyRequest;\n evaluatedAt: number;\n expiresAt: number;\n evidenceTimestamp: number | null;\n evaluatedAgeSeconds: number | null;\n}\n\nexport type PolicyResult = PolicyResultBase &\n (\n | { decision: \"allow\"; reason: \"accepted\"; evidence: PolicyEvidence }\n | {\n decision: \"deny\";\n reason: Exclude<PolicyReason, \"accepted\" | \"state_unavailable\">;\n evidence: PolicyEvidence | null;\n }\n | {\n decision: \"unavailable\";\n reason: \"state_unavailable\";\n evidence: PolicyEvidence | null;\n }\n );\n\nexport class PolicyValidationError extends Error {\n constructor(public readonly reason: PolicyReason) {\n super(`Invalid verification policy: ${reason}`);\n this.name = \"PolicyValidationError\";\n }\n}\n\nfunction record(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction exactKeys(\n value: Record<string, unknown>,\n keys: readonly string[],\n): boolean {\n return (\n Object.keys(value).length === keys.length &&\n keys.every((key) => Object.prototype.hasOwnProperty.call(value, key))\n );\n}\n\nfunction integer(\n value: unknown,\n minimum = 0,\n maximum = Number.MAX_SAFE_INTEGER,\n): value is number {\n return (\n typeof value === \"number\" &&\n Number.isSafeInteger(value) &&\n value >= minimum &&\n value <= maximum\n );\n}\n\nconst REQUEST_KEYS = [\n \"id\",\n \"version\",\n \"minTrustScore\",\n \"maxVerificationAgeSeconds\",\n \"maxEvaluationAgeSeconds\",\n \"requiredAssurance\",\n \"uniquenessRequirement\",\n \"requireAttestation\",\n \"cluster\",\n] as const;\n\n/** Canonical defaults are applied before a request leaves the consumer. */\nexport function normalizePolicyRequest(\n input?: unknown,\n legacyMinTrustScore?: number,\n): PolicyRequest {\n if (\n legacyMinTrustScore !== undefined &&\n !integer(legacyMinTrustScore, 0, 10000)\n ) {\n throw new PolicyValidationError(\"unsupported_policy\");\n }\n const value: unknown =\n input === undefined\n ? {\n id: \"entros-verify-default\",\n version: 1,\n minTrustScore: legacyMinTrustScore ?? 0,\n maxVerificationAgeSeconds: 86400,\n requiredAssurance: \"browser_unattested\",\n uniquenessRequirement: \"allow_unmeasured\",\n cluster: \"devnet\",\n }\n : input;\n if (\n !record(value) ||\n Object.keys(value).some(\n (key) => !REQUEST_KEYS.includes(key as (typeof REQUEST_KEYS)[number]),\n )\n ) {\n throw new PolicyValidationError(\"unsupported_policy\");\n }\n if (value.requiredAssurance !== \"browser_unattested\")\n throw new PolicyValidationError(\"unsupported_assurance\");\n if (value.uniquenessRequirement !== \"allow_unmeasured\")\n throw new PolicyValidationError(\"unsupported_uniqueness\");\n if (\n typeof value.id !== \"string\" ||\n !/^[A-Za-z0-9_-]{1,64}$/.test(value.id) ||\n value.version !== 1 ||\n !integer(value.minTrustScore, 0, 10000) ||\n !integer(value.maxVerificationAgeSeconds, 1, 31536000) ||\n !integer(\n value.maxEvaluationAgeSeconds === undefined\n ? 90\n : value.maxEvaluationAgeSeconds,\n 1,\n 90,\n ) ||\n (value.requireAttestation !== undefined &&\n typeof value.requireAttestation !== \"boolean\") ||\n value.cluster !== \"devnet\" ||\n (legacyMinTrustScore !== undefined &&\n value.minTrustScore !== legacyMinTrustScore)\n ) {\n throw new PolicyValidationError(\"unsupported_policy\");\n }\n return {\n id: value.id,\n version: 1,\n minTrustScore: value.minTrustScore,\n maxVerificationAgeSeconds: value.maxVerificationAgeSeconds,\n maxEvaluationAgeSeconds: (value.maxEvaluationAgeSeconds ?? 90) as number,\n requiredAssurance: \"browser_unattested\",\n uniquenessRequirement: \"allow_unmeasured\",\n requireAttestation: value.requireAttestation === true,\n cluster: \"devnet\",\n };\n}\n\nexport function encodePolicyRequest(request: PolicyRequest): string {\n return JSON.stringify(normalizePolicyRequest(request));\n}\n\n/** Legacy callers require a real attestation because their result type cannot represent absence. */\nexport function parsePolicyParameters(\n params: URLSearchParams,\n legacyMinTrustScore?: number,\n): { policy: PolicyRequest; negotiated: boolean } {\n for (const key of [\"policy\", \"policy_version\", \"min_trust_score\"]) {\n if (params.getAll(key).length > 1)\n throw new PolicyValidationError(\"unsupported_policy\");\n }\n const floorText = params.get(\"min_trust_score\");\n if (floorText !== null) {\n if (\n !/^(0|[1-9][0-9]{0,4})$/.test(floorText) ||\n !integer(Number(floorText), 0, 10000) ||\n (legacyMinTrustScore !== undefined &&\n legacyMinTrustScore !== Number(floorText))\n )\n throw new PolicyValidationError(\"unsupported_policy\");\n legacyMinTrustScore = Number(floorText);\n }\n const encoded = params.get(\"policy\");\n const marker = params.get(\"policy_version\");\n if (encoded === null && marker === null) {\n return {\n negotiated: false,\n policy: {\n ...normalizePolicyRequest(undefined, legacyMinTrustScore),\n requireAttestation: true,\n },\n };\n }\n if (marker !== \"1\" || encoded === null || encoded.length > 2048)\n throw new PolicyValidationError(\"unsupported_policy\");\n let raw: unknown;\n try {\n raw = JSON.parse(encoded);\n } catch {\n throw new PolicyValidationError(\"unsupported_policy\");\n }\n const policy = normalizePolicyRequest(raw, legacyMinTrustScore);\n if (encodePolicyRequest(policy) !== encoded)\n throw new PolicyValidationError(\"unsupported_policy\");\n return { negotiated: true, policy };\n}\n\nconst BASE58 = \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\nfunction base58Bytes(value: unknown, expected: number): value is string {\n if (\n typeof value !== \"string\" ||\n value.length < 1 ||\n value.length > expected * 2\n )\n return false;\n let number = 0n;\n for (const character of value) {\n const digit = BASE58.indexOf(character);\n if (digit < 0) return false;\n number = number * 58n + BigInt(digit);\n }\n let bytes = 0;\n while (number > 0n) {\n bytes++;\n number >>= 8n;\n }\n let zeros = 0;\n while (value[zeros] === \"1\") zeros++;\n return bytes + zeros === expected;\n}\n\nfunction commitment(value: unknown): value is string {\n return (\n typeof value === \"string\" &&\n /^[0-9a-f]{64}$/.test(value) &&\n !/^0+$/.test(value)\n );\n}\n\nexport function isPolicyAttestation(\n value: unknown,\n): value is PolicyAttestation {\n if (!record(value)) return false;\n if (value.status === \"present\") {\n return (\n exactKeys(value, [\"status\", \"address\", \"readContextSlot\", \"expiresAt\"]) &&\n base58Bytes(value.address, 32) &&\n integer(value.readContextSlot) &&\n (value.expiresAt === null || integer(value.expiresAt, 1))\n );\n }\n return (\n exactKeys(value, [\"status\"]) &&\n [\"missing\", \"invalid\", \"unavailable\"].includes(String(value.status))\n );\n}\n\nexport function isPolicyEvidence(value: unknown): value is PolicyEvidence {\n if (\n !record(value) ||\n !exactKeys(value, [\n \"cluster\",\n \"genesisHash\",\n \"programIds\",\n \"assuranceTier\",\n \"uniquenessStatus\",\n \"readContextSlot\",\n \"identity\",\n \"transaction\",\n \"attestation\",\n ])\n )\n return false;\n if (\n value.cluster !== \"devnet\" ||\n value.genesisHash !== POLICY_NETWORK.genesisHash ||\n value.assuranceTier !== \"browser_unattested\" ||\n value.uniquenessStatus !== \"unmeasured\" ||\n !integer(value.readContextSlot)\n )\n return false;\n const programs = value.programIds;\n if (\n !record(programs) ||\n !exactKeys(programs, Object.keys(POLICY_NETWORK.programIds)) ||\n Object.entries(POLICY_NETWORK.programIds).some(\n ([key, id]) => programs[key] !== id,\n )\n )\n return false;\n const identity = value.identity;\n const transaction = value.transaction;\n if (\n !record(identity) ||\n !exactKeys(identity, [\n \"walletPubkey\",\n \"identityPda\",\n \"creationTimestamp\",\n \"lastVerificationTimestamp\",\n \"verificationCount\",\n \"trustScore\",\n \"currentCommitment\",\n \"projectionVersion\",\n \"lastResetTimestamp\",\n \"lastRebaselineTimestamp\",\n \"mint\",\n ]) ||\n !base58Bytes(identity.walletPubkey, 32) ||\n !base58Bytes(identity.identityPda, 32) ||\n !base58Bytes(identity.mint, 32) ||\n !integer(identity.creationTimestamp, 1) ||\n !integer(identity.lastVerificationTimestamp, identity.creationTimestamp) ||\n !integer(identity.verificationCount, 0, 0xffffffff) ||\n !integer(identity.trustScore, 0, 10000) ||\n !commitment(identity.currentCommitment) ||\n !integer(identity.projectionVersion, 0, 2) ||\n !integer(identity.lastResetTimestamp) ||\n !integer(identity.lastRebaselineTimestamp)\n )\n return false;\n if (\n !record(transaction) ||\n !exactKeys(transaction, [\n \"signature\",\n \"slot\",\n \"blockTime\",\n \"commitment\",\n \"kind\",\n ]) ||\n !base58Bytes(transaction.signature, 64) ||\n !integer(transaction.slot) ||\n !integer(transaction.blockTime, identity.creationTimestamp) ||\n !commitment(transaction.commitment) ||\n ![\"mint\", \"update\", \"rebaseline\"].includes(String(transaction.kind))\n )\n return false;\n return isPolicyAttestation(value.attestation);\n}\n\n/** Evaluates application requirements. It does not authenticate browser-supplied evidence. */\nexport function evaluatePolicy(\n request: PolicyRequest,\n observation: PolicyEvidenceReadResult,\n nowSeconds: number,\n): PolicyResult {\n const requirements = normalizePolicyRequest(request);\n if (\n !integer(nowSeconds, 1) ||\n nowSeconds > Number.MAX_SAFE_INTEGER - 31536000\n )\n throw new PolicyValidationError(\"invalid_evidence\");\n const base: PolicyResultBase = {\n policyId: requirements.id,\n policyVersion: 1,\n requirements,\n evaluatedAt: nowSeconds,\n expiresAt: nowSeconds,\n evidenceTimestamp: null,\n evaluatedAgeSeconds: null,\n };\n if (record(observation) && observation.status === \"unavailable\")\n return {\n ...base,\n decision: \"unavailable\",\n reason: \"state_unavailable\",\n evidence: null,\n };\n if (\n !record(observation) ||\n observation.status !== \"available\" ||\n !isPolicyEvidence(observation.evidence)\n ) {\n return {\n ...base,\n decision: \"deny\",\n reason: \"invalid_evidence\",\n evidence: null,\n };\n }\n const evidence = observation.evidence;\n const { identity, transaction, attestation } = evidence;\n const deny = (\n reason: Exclude<PolicyReason, \"accepted\" | \"state_unavailable\">,\n ): PolicyResult => ({ ...base, decision: \"deny\", reason, evidence });\n const freshMint =\n transaction.kind === \"mint\" &&\n identity.verificationCount === 0 &&\n identity.trustScore === 0 &&\n identity.creationTimestamp === transaction.blockTime &&\n identity.lastVerificationTimestamp === transaction.blockTime &&\n identity.lastResetTimestamp === 0 &&\n identity.lastRebaselineTimestamp === 0;\n if (\n (identity.verificationCount === 0 && !freshMint) ||\n identity.currentCommitment !== transaction.commitment ||\n identity.lastResetTimestamp >= transaction.blockTime ||\n identity.lastResetTimestamp > identity.lastVerificationTimestamp ||\n identity.lastRebaselineTimestamp > identity.lastVerificationTimestamp ||\n identity.lastRebaselineTimestamp > transaction.blockTime ||\n identity.lastVerificationTimestamp > nowSeconds ||\n transaction.blockTime > nowSeconds ||\n evidence.readContextSlot < transaction.slot ||\n attestation.status === \"invalid\" ||\n (attestation.status === \"present\" &&\n (attestation.readContextSlot < transaction.slot ||\n (attestation.expiresAt !== null &&\n attestation.expiresAt <= nowSeconds)))\n ) {\n return deny(\"invalid_evidence\");\n }\n base.evidenceTimestamp = Math.min(\n identity.lastVerificationTimestamp,\n transaction.blockTime,\n );\n base.evaluatedAgeSeconds = nowSeconds - base.evidenceTimestamp;\n base.expiresAt = Math.min(\n base.evidenceTimestamp + requirements.maxVerificationAgeSeconds,\n nowSeconds + requirements.maxEvaluationAgeSeconds,\n );\n if (\n requirements.requireAttestation &&\n attestation.status === \"present\" &&\n attestation.expiresAt !== null\n )\n base.expiresAt = Math.min(base.expiresAt, attestation.expiresAt);\n if (identity.trustScore < requirements.minTrustScore)\n return deny(\"score_below_minimum\");\n if (nowSeconds >= base.expiresAt) return deny(\"verification_stale\");\n if (requirements.requireAttestation && attestation.status === \"missing\")\n return deny(\"attestation_required\");\n if (requirements.requireAttestation && attestation.status === \"unavailable\")\n return {\n ...base,\n decision: \"unavailable\",\n reason: \"state_unavailable\",\n evidence,\n };\n return { ...base, decision: \"allow\", reason: \"accepted\", evidence };\n}\n\nexport interface PolicyWireResult {\n policy_id: string;\n policy_version: 1;\n decision: PolicyResult[\"decision\"];\n reason: PolicyReason;\n requirements: PolicyRequest;\n evaluated_at: number;\n expires_at: number;\n evidence_timestamp: number | null;\n evaluated_age_seconds: number | null;\n wallet_pubkey: string | null;\n identity_pda: string | null;\n verified_transaction: {\n signature: string;\n slot: number;\n block_time: number;\n commitment: string;\n kind: \"mint\" | \"update\" | \"rebaseline\";\n } | null;\n verification_timestamp: number | null;\n trust_score: number | null;\n anchor_created_at: number | null;\n verification_count: number | null;\n current_commitment: string | null;\n projection_version: number | null;\n last_reset_timestamp: number | null;\n last_rebaseline_timestamp: number | null;\n mint: string | null;\n uniqueness_status: \"unmeasured\" | null;\n assurance_tier: \"browser_unattested\" | null;\n cluster: \"devnet\" | null;\n genesis_hash: string | null;\n program_ids: PolicyProgramIds | null;\n read_context_slot: number | null;\n attestation:\n | {\n status: \"present\";\n address: string;\n read_context_slot: number;\n expires_at: number | null;\n }\n | { status: \"missing\" | \"invalid\" | \"unavailable\" }\n | null;\n}\n\nexport function policyResultToWire(result: PolicyResult): PolicyWireResult {\n const e = result.evidence;\n return {\n policy_id: result.policyId,\n policy_version: 1,\n decision: result.decision,\n reason: result.reason,\n requirements: result.requirements,\n evaluated_at: result.evaluatedAt,\n expires_at: result.expiresAt,\n evidence_timestamp: result.evidenceTimestamp,\n evaluated_age_seconds: result.evaluatedAgeSeconds,\n wallet_pubkey: e?.identity.walletPubkey ?? null,\n identity_pda: e?.identity.identityPda ?? null,\n verified_transaction: e\n ? {\n signature: e.transaction.signature,\n slot: e.transaction.slot,\n block_time: e.transaction.blockTime,\n commitment: e.transaction.commitment,\n kind: e.transaction.kind,\n }\n : null,\n verification_timestamp: e?.identity.lastVerificationTimestamp ?? null,\n trust_score: e?.identity.trustScore ?? null,\n anchor_created_at: e?.identity.creationTimestamp ?? null,\n verification_count: e?.identity.verificationCount ?? null,\n current_commitment: e?.identity.currentCommitment ?? null,\n projection_version: e?.identity.projectionVersion ?? null,\n last_reset_timestamp: e?.identity.lastResetTimestamp ?? null,\n last_rebaseline_timestamp: e?.identity.lastRebaselineTimestamp ?? null,\n mint: e?.identity.mint ?? null,\n uniqueness_status: e?.uniquenessStatus ?? null,\n assurance_tier: e?.assuranceTier ?? null,\n cluster: e?.cluster ?? null,\n genesis_hash: e?.genesisHash ?? null,\n program_ids: e?.programIds ?? null,\n read_context_slot: e?.readContextSlot ?? null,\n attestation: e\n ? e.attestation.status === \"present\"\n ? {\n status: \"present\",\n address: e.attestation.address,\n read_context_slot: e.attestation.readContextSlot,\n expires_at: e.attestation.expiresAt,\n }\n : e.attestation\n : null,\n };\n}\n\n/** Recompute every derived field before accepting a remote decision. */\nexport function parsePolicyWireResult(input: unknown): PolicyResult | null {\n if (!record(input) || !integer(input.evaluated_at, 1)) return null;\n try {\n const requirements = normalizePolicyRequest(input.requirements);\n let observation: PolicyEvidenceReadResult;\n if (input.wallet_pubkey === null) {\n observation =\n input.decision === \"unavailable\"\n ? { status: \"unavailable\", reason: \"state_unavailable\" }\n : { status: \"invalid\", reason: \"invalid_evidence\" };\n } else {\n const tx = input.verified_transaction;\n const sas = input.attestation;\n if (!record(tx) || !record(sas)) return null;\n const evidence: unknown = {\n cluster: input.cluster,\n genesisHash: input.genesis_hash,\n programIds: input.program_ids,\n assuranceTier: input.assurance_tier,\n uniquenessStatus: input.uniqueness_status,\n readContextSlot: input.read_context_slot,\n identity: {\n walletPubkey: input.wallet_pubkey,\n identityPda: input.identity_pda,\n creationTimestamp: input.anchor_created_at,\n lastVerificationTimestamp: input.verification_timestamp,\n verificationCount: input.verification_count,\n trustScore: input.trust_score,\n currentCommitment: input.current_commitment,\n projectionVersion: input.projection_version,\n lastResetTimestamp: input.last_reset_timestamp,\n lastRebaselineTimestamp: input.last_rebaseline_timestamp,\n mint: input.mint,\n },\n transaction: {\n signature: tx.signature,\n slot: tx.slot,\n blockTime: tx.block_time,\n commitment: tx.commitment,\n kind: tx.kind,\n },\n attestation:\n sas.status === \"present\"\n ? {\n status: \"present\",\n address: sas.address,\n readContextSlot: sas.read_context_slot,\n expiresAt: sas.expires_at,\n }\n : { status: sas.status },\n };\n if (!isPolicyEvidence(evidence)) return null;\n observation = { status: \"available\", evidence };\n }\n const result = evaluatePolicy(\n requirements,\n observation,\n input.evaluated_at,\n );\n return canonicalEqual(input, policyResultToWire(result)) ? result : null;\n } catch {\n return null;\n }\n}\n\nfunction canonicalEqual(left: unknown, right: unknown): boolean {\n if (left === right) return true;\n if (!record(left) || !record(right)) return false;\n return (\n exactKeys(left, Object.keys(right)) &&\n Object.keys(right).every((key) => canonicalEqual(left[key], right[key]))\n );\n}\n\nexport function isPolicyReason(value: unknown): value is PolicyReason {\n return (\n typeof value === \"string\" &&\n [\n \"accepted\",\n \"score_below_minimum\",\n \"verification_stale\",\n \"attestation_required\",\n \"unsupported_policy\",\n \"unsupported_assurance\",\n \"unsupported_uniqueness\",\n \"invalid_evidence\",\n \"state_unavailable\",\n ].includes(value)\n );\n}\n\nexport function validatePolicyVerifiedPayload(\n payload: unknown,\n requestedPolicy: PolicyRequest,\n nowSeconds: number,\n):\n | { ok: true; result: PolicyResult & { decision: \"allow\" } }\n | { ok: false; reason: PolicyReason } {\n if (!record(payload)) return { ok: false, reason: \"invalid_evidence\" };\n if (!Object.prototype.hasOwnProperty.call(payload, \"policy\"))\n return { ok: false, reason: \"unsupported_policy\" };\n const result = parsePolicyWireResult(payload.policy);\n if (\n !result ||\n !canonicalEqual(\n result.requirements,\n normalizePolicyRequest(requestedPolicy),\n )\n )\n return { ok: false, reason: \"invalid_evidence\" };\n if (result.decision !== \"allow\") return { ok: false, reason: result.reason };\n if (\n !integer(nowSeconds, 1) ||\n result.evaluatedAt > nowSeconds ||\n nowSeconds >= result.expiresAt\n )\n return { ok: false, reason: \"verification_stale\" };\n const current = evaluatePolicy(\n requestedPolicy,\n { status: \"available\", evidence: result.evidence },\n nowSeconds,\n );\n if (current.decision !== \"allow\")\n return { ok: false, reason: current.reason };\n const e = result.evidence;\n const address =\n e.attestation.status === \"present\" ? e.attestation.address : null;\n if (\n payload.wallet_pubkey !== e.identity.walletPubkey ||\n payload.trust_score !== e.identity.trustScore ||\n payload.cluster !== e.cluster ||\n payload.tx_sig !== e.transaction.signature ||\n payload.attestation_pda !== address\n )\n return { ok: false, reason: \"invalid_evidence\" };\n return { ok: true, result };\n}\n"],"mappings":";AA8BO,IAAM,iBAAiB,OAAO,OAAO;AAAA,EAC1C,aAAa;AAAA,EACb,YAAY,OAAO,OAAO;AAAA,IACxB,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,UAAU;AAAA,IACV,KAAK;AAAA,IACL,YAAY;AAAA,IACZ,QAAQ;AAAA,EACV,CAA4B;AAC9B,CAAC;AAiFM,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAC/C,YAA4B,QAAsB;AAChD,UAAM,gCAAgC,MAAM,EAAE;AADpB;AAE1B,SAAK,OAAO;AAAA,EACd;AACF;AAEA,SAAS,OAAO,OAAkD;AAChE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,UACP,OACA,MACS;AACT,SACE,OAAO,KAAK,KAAK,EAAE,WAAW,KAAK,UACnC,KAAK,MAAM,CAAC,QAAQ,OAAO,UAAU,eAAe,KAAK,OAAO,GAAG,CAAC;AAExE;AAEA,SAAS,QACP,OACA,UAAU,GACV,UAAU,OAAO,kBACA;AACjB,SACE,OAAO,UAAU,YACjB,OAAO,cAAc,KAAK,KAC1B,SAAS,WACT,SAAS;AAEb;AAEA,IAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,SAAS,uBACd,OACA,qBACe;AACf,MACE,wBAAwB,UACxB,CAAC,QAAQ,qBAAqB,GAAG,GAAK,GACtC;AACA,UAAM,IAAI,sBAAsB,oBAAoB;AAAA,EACtD;AACA,QAAM,QACJ,UAAU,SACN;AAAA,IACE,IAAI;AAAA,IACJ,SAAS;AAAA,IACT,eAAe,uBAAuB;AAAA,IACtC,2BAA2B;AAAA,IAC3B,mBAAmB;AAAA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AO;AAC5B;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entros/verify",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "description": "React popup component for wallet-connected Entros verification on Solana devnet",
5
5
  "license": "MIT",
6
6
  "homepage": "https://entros.io",
@@ -27,6 +27,16 @@
27
27
  "types": "./dist/index.d.ts",
28
28
  "import": "./dist/index.mjs",
29
29
  "require": "./dist/index.js"
30
+ },
31
+ "./policy": {
32
+ "types": "./dist/policy.d.ts",
33
+ "import": "./dist/policy.mjs",
34
+ "require": "./dist/policy.js"
35
+ },
36
+ "./agent-permit": {
37
+ "types": "./dist/agent-permit.d.ts",
38
+ "import": "./dist/agent-permit.mjs",
39
+ "require": "./dist/agent-permit.js"
30
40
  }
31
41
  },
32
42
  "files": [
@@ -43,6 +53,10 @@
43
53
  "verify-publish-contents": "node scripts/verify-publish-contents.mjs",
44
54
  "prepublishOnly": "npm run typecheck && npm test && npm run verify-publish-contents && npm run build"
45
55
  },
56
+ "dependencies": {
57
+ "@noble/curves": "^1.9.7",
58
+ "@noble/hashes": "^1.8.0"
59
+ },
46
60
  "peerDependencies": {
47
61
  "react": "^19.0.0",
48
62
  "react-dom": "^19.0.0"
@@ -59,5 +73,8 @@
59
73
  "tsup": "^8.0.0",
60
74
  "typescript": "^6.0.2",
61
75
  "vitest": "^3.0.0"
76
+ },
77
+ "overrides": {
78
+ "esbuild": "^0.28.1"
62
79
  }
63
80
  }