antifraud-data-utils-ts 0.1.5 → 0.1.7
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/CHANGELOG.md +19 -0
- package/README.md +7 -0
- package/dist/identity-assurance/index.d.ts +1 -0
- package/dist/identity-assurance/index.d.ts.map +1 -1
- package/dist/identity-assurance/index.js +1 -0
- package/dist/identity-assurance/index.js.map +1 -1
- package/dist/identity-assurance/managed-signing.d.ts +111 -0
- package/dist/identity-assurance/managed-signing.d.ts.map +1 -0
- package/dist/identity-assurance/managed-signing.js +181 -0
- package/dist/identity-assurance/managed-signing.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## 0.1.7 - 2026-10-18
|
|
8
|
+
|
|
9
|
+
- Add the canonical verified managed-signature proof projection. Manifest,
|
|
10
|
+
operation, signer, relying party, purpose, algorithm and verification method
|
|
11
|
+
are copied from the immutable request rather than accepted from wallet output.
|
|
12
|
+
- Reject unverified, malformed, out-of-lifetime or authority-overriding proof
|
|
13
|
+
material and harden the ciphertext-tampering test so it always changes a
|
|
14
|
+
decoded byte rather than optional base64 padding bits.
|
|
15
|
+
|
|
16
|
+
## 0.1.6 - 2026-10-18
|
|
17
|
+
|
|
18
|
+
- Add the canonical managed-signature request state, local user-presence method,
|
|
19
|
+
ML-DSA-65 actor-signing key and immutable manifest-binding contracts.
|
|
20
|
+
- Build pending requests from a browser-controlled manifest draft and separate
|
|
21
|
+
trusted backend context for user, registered device, relying party, purpose,
|
|
22
|
+
signer and verification method; reject browser-authored authority.
|
|
23
|
+
- Export one reusable synthetic signing-request fixture for SDK, gateway and
|
|
24
|
+
portal journey tests.
|
|
25
|
+
|
|
7
26
|
## 0.1.5 - 2026-10-18
|
|
8
27
|
|
|
9
28
|
- Migrate the reviewed stateless `gdc-common-utils-ts` cryptography profile so
|
package/README.md
CHANGED
|
@@ -33,6 +33,13 @@ import {
|
|
|
33
33
|
const cryptography = new CryptographyService(runtimeCryptoHelper)
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
`defineManagedSignatureRequest` creates only a pending request. It binds the
|
|
37
|
+
immutable manifest digest to the trusted authenticated user, registered device,
|
|
38
|
+
operation, signer, relying party, purpose and ML-DSA-65 actor-signing key.
|
|
39
|
+
Login, review, delivery, read state and a successful local user-presence
|
|
40
|
+
ceremony are deliberately not represented as signatures. SDK orchestration
|
|
41
|
+
owns authorization, one-use session consumption and proof creation.
|
|
42
|
+
|
|
36
43
|
## Current API
|
|
37
44
|
|
|
38
45
|
```ts
|
|
@@ -4,6 +4,7 @@ export * from './converters.js';
|
|
|
4
4
|
export * from './credential-issuance.js';
|
|
5
5
|
export * from './didcomm-binary-attachment.js';
|
|
6
6
|
export * from './identity-evidence.js';
|
|
7
|
+
export * from './managed-signing.js';
|
|
7
8
|
export * from './professional-qualification.js';
|
|
8
9
|
export * from './schema-org-evidence.js';
|
|
9
10
|
export * from './schemas.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity-assurance/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,0BAA0B,CAAA;AACxC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,0BAA0B,CAAA;AACxC,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,2BAA2B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity-assurance/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,0BAA0B,CAAA;AACxC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,0BAA0B,CAAA;AACxC,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,2BAA2B,CAAA"}
|
|
@@ -4,6 +4,7 @@ export * from './converters.js';
|
|
|
4
4
|
export * from './credential-issuance.js';
|
|
5
5
|
export * from './didcomm-binary-attachment.js';
|
|
6
6
|
export * from './identity-evidence.js';
|
|
7
|
+
export * from './managed-signing.js';
|
|
7
8
|
export * from './professional-qualification.js';
|
|
8
9
|
export * from './schema-org-evidence.js';
|
|
9
10
|
export * from './schemas.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity-assurance/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,0BAA0B,CAAA;AACxC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,0BAA0B,CAAA;AACxC,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,2BAA2B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity-assurance/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,0BAA0B,CAAA;AACxC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,0BAA0B,CAAA;AACxC,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,2BAA2B,CAAA"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export declare const ManagedSignatureRequestState: Readonly<{
|
|
2
|
+
readonly Pending: "pending";
|
|
3
|
+
readonly Authorized: "authorized";
|
|
4
|
+
readonly Rejected: "rejected";
|
|
5
|
+
readonly Cancelled: "cancelled";
|
|
6
|
+
readonly Expired: "expired";
|
|
7
|
+
readonly Signed: "signed";
|
|
8
|
+
readonly Failed: "failed";
|
|
9
|
+
}>;
|
|
10
|
+
export type ManagedSignatureRequestStateValue = typeof ManagedSignatureRequestState[keyof typeof ManagedSignatureRequestState];
|
|
11
|
+
export declare const UserPresenceMethod: Readonly<{
|
|
12
|
+
readonly Biometric: "biometric";
|
|
13
|
+
readonly Pin: "pin";
|
|
14
|
+
readonly Password: "password";
|
|
15
|
+
}>;
|
|
16
|
+
export type UserPresenceMethodValue = typeof UserPresenceMethod[keyof typeof UserPresenceMethod];
|
|
17
|
+
export declare const ManagedSigningAlgorithm: Readonly<{
|
|
18
|
+
readonly MlDsa65: "ML-DSA-65";
|
|
19
|
+
}>;
|
|
20
|
+
export declare const ManagedSigningKeyPurpose: Readonly<{
|
|
21
|
+
readonly ActorSigning: "actor-signing";
|
|
22
|
+
}>;
|
|
23
|
+
export type ManagedSignatureManifestBinding = Readonly<{
|
|
24
|
+
id: string;
|
|
25
|
+
version: string;
|
|
26
|
+
digestAlgorithm: 'sha3-384';
|
|
27
|
+
digest: string;
|
|
28
|
+
}>;
|
|
29
|
+
export type ManagedSignatureRequestDraft = Readonly<{
|
|
30
|
+
requestId: string;
|
|
31
|
+
operationId: string;
|
|
32
|
+
manifest: ManagedSignatureManifestBinding;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
expiresAt: string;
|
|
35
|
+
}>;
|
|
36
|
+
export type ManagedSignatureTrustedContext = Readonly<{
|
|
37
|
+
authenticatedUserId: string;
|
|
38
|
+
registeredDeviceId: string;
|
|
39
|
+
relyingParty: string;
|
|
40
|
+
purpose: string;
|
|
41
|
+
signerReference: string;
|
|
42
|
+
signingKey: Readonly<{
|
|
43
|
+
purpose: typeof ManagedSigningKeyPurpose.ActorSigning;
|
|
44
|
+
algorithm: typeof ManagedSigningAlgorithm.MlDsa65;
|
|
45
|
+
verificationMethod: string;
|
|
46
|
+
}>;
|
|
47
|
+
}>;
|
|
48
|
+
export type ManagedSignatureRequest = ManagedSignatureRequestDraft & ManagedSignatureTrustedContext & Readonly<{
|
|
49
|
+
state: typeof ManagedSignatureRequestState.Pending;
|
|
50
|
+
}>;
|
|
51
|
+
export declare const ManagedSignatureProofStatus: Readonly<{
|
|
52
|
+
readonly Verified: "verified";
|
|
53
|
+
}>;
|
|
54
|
+
export type ManagedSignatureProof = Readonly<{
|
|
55
|
+
proofId: string;
|
|
56
|
+
requestId: string;
|
|
57
|
+
operationId: string;
|
|
58
|
+
manifest: ManagedSignatureManifestBinding;
|
|
59
|
+
relyingParty: string;
|
|
60
|
+
purpose: string;
|
|
61
|
+
signerReference: string;
|
|
62
|
+
algorithm: typeof ManagedSigningAlgorithm.MlDsa65;
|
|
63
|
+
verificationMethod: string;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
signature: string;
|
|
66
|
+
status: typeof ManagedSignatureProofStatus.Verified;
|
|
67
|
+
}>;
|
|
68
|
+
export type ManagedSignatureProofResult = Readonly<{
|
|
69
|
+
proofId: string;
|
|
70
|
+
signature: string;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
verified: boolean;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Builds one pending request from browser-controlled manifest continuity and
|
|
76
|
+
* trusted backend identity, device, purpose, relying-party and key context.
|
|
77
|
+
*/
|
|
78
|
+
export declare function defineManagedSignatureRequest(draft: ManagedSignatureRequestDraft & Readonly<Record<string, unknown>>, trustedContext: ManagedSignatureTrustedContext): ManagedSignatureRequest;
|
|
79
|
+
/**
|
|
80
|
+
* Projects verified wallet output into public proof metadata while copying all
|
|
81
|
+
* authority and manifest bindings from the immutable request.
|
|
82
|
+
*/
|
|
83
|
+
export declare function defineManagedSignatureProof(request: ManagedSignatureRequest, result: ManagedSignatureProofResult & Readonly<Record<string, unknown>>): ManagedSignatureProof;
|
|
84
|
+
/** Synthetic, non-sensitive fixture shared by SDK, gateway and portal tests. */
|
|
85
|
+
export declare const SyntheticManagedSignatureRequestFixture: Readonly<{
|
|
86
|
+
draft: Readonly<{
|
|
87
|
+
requestId: "urn:signature-request:synthetic-publication-v1";
|
|
88
|
+
operationId: "urn:operation:synthetic-publication-signing-v1";
|
|
89
|
+
manifest: Readonly<{
|
|
90
|
+
id: "urn:document-set:synthetic-agreement";
|
|
91
|
+
version: "1";
|
|
92
|
+
digestAlgorithm: "sha3-384";
|
|
93
|
+
digest: string;
|
|
94
|
+
}>;
|
|
95
|
+
createdAt: "2026-10-18T20:00:00.000Z";
|
|
96
|
+
expiresAt: "2026-10-18T20:05:00.000Z";
|
|
97
|
+
}>;
|
|
98
|
+
trustedContext: Readonly<{
|
|
99
|
+
authenticatedUserId: "urn:user:synthetic-signer";
|
|
100
|
+
registeredDeviceId: "urn:device:synthetic-signer-primary";
|
|
101
|
+
relyingParty: "https://social-demo.antifraud.services";
|
|
102
|
+
purpose: "synthetic-publication-manifest-signing";
|
|
103
|
+
signerReference: "did:example:synthetic-signer";
|
|
104
|
+
signingKey: Readonly<{
|
|
105
|
+
purpose: "actor-signing";
|
|
106
|
+
algorithm: "ML-DSA-65";
|
|
107
|
+
verificationMethod: "did:example:synthetic-signer#actor-signing-ml-dsa-65";
|
|
108
|
+
}>;
|
|
109
|
+
}>;
|
|
110
|
+
}>;
|
|
111
|
+
//# sourceMappingURL=managed-signing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managed-signing.d.ts","sourceRoot":"","sources":["../../src/identity-assurance/managed-signing.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,4BAA4B;;;;;;;;EAQ9B,CAAA;AAEX,MAAM,MAAM,iCAAiC,GAC3C,OAAO,4BAA4B,CAAC,MAAM,OAAO,4BAA4B,CAAC,CAAA;AAEhF,eAAO,MAAM,kBAAkB;;;;EAIpB,CAAA;AAEX,MAAM,MAAM,uBAAuB,GACjC,OAAO,kBAAkB,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAA;AAE5D,eAAO,MAAM,uBAAuB;;EAEzB,CAAA;AAEX,eAAO,MAAM,wBAAwB;;EAE1B,CAAA;AAEX,MAAM,MAAM,+BAA+B,GAAG,QAAQ,CAAC;IACrD,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,UAAU,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;CACf,CAAC,CAAA;AAEF,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CAAC;IAClD,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,+BAA+B,CAAA;IACzC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAC,CAAA;AAEF,MAAM,MAAM,8BAA8B,GAAG,QAAQ,CAAC;IACpD,mBAAmB,EAAE,MAAM,CAAA;IAC3B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,QAAQ,CAAC;QACnB,OAAO,EAAE,OAAO,wBAAwB,CAAC,YAAY,CAAA;QACrD,SAAS,EAA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MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACtE,qBAAqB,CAkCvB;AAED,gFAAgF;AAChF,eAAO,MAAM,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;EAyBlD,CAAA"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { SyntheticConfidentialDocumentFixture } from './confidential-document.js';
|
|
2
|
+
export const ManagedSignatureRequestState = Object.freeze({
|
|
3
|
+
Pending: 'pending',
|
|
4
|
+
Authorized: 'authorized',
|
|
5
|
+
Rejected: 'rejected',
|
|
6
|
+
Cancelled: 'cancelled',
|
|
7
|
+
Expired: 'expired',
|
|
8
|
+
Signed: 'signed',
|
|
9
|
+
Failed: 'failed',
|
|
10
|
+
});
|
|
11
|
+
export const UserPresenceMethod = Object.freeze({
|
|
12
|
+
Biometric: 'biometric',
|
|
13
|
+
Pin: 'pin',
|
|
14
|
+
Password: 'password',
|
|
15
|
+
});
|
|
16
|
+
export const ManagedSigningAlgorithm = Object.freeze({
|
|
17
|
+
MlDsa65: 'ML-DSA-65',
|
|
18
|
+
});
|
|
19
|
+
export const ManagedSigningKeyPurpose = Object.freeze({
|
|
20
|
+
ActorSigning: 'actor-signing',
|
|
21
|
+
});
|
|
22
|
+
export const ManagedSignatureProofStatus = Object.freeze({
|
|
23
|
+
Verified: 'verified',
|
|
24
|
+
});
|
|
25
|
+
const CLIENT_FORBIDDEN_AUTHORITY = Object.freeze([
|
|
26
|
+
'authenticatedUserId',
|
|
27
|
+
'registeredDeviceId',
|
|
28
|
+
'relyingParty',
|
|
29
|
+
'purpose',
|
|
30
|
+
'signerReference',
|
|
31
|
+
'signingKey',
|
|
32
|
+
'verificationMethod',
|
|
33
|
+
]);
|
|
34
|
+
const REQUEST_BOUND_PROOF_FIELDS = Object.freeze([
|
|
35
|
+
'requestId',
|
|
36
|
+
'operationId',
|
|
37
|
+
'manifest',
|
|
38
|
+
'manifestDigest',
|
|
39
|
+
'relyingParty',
|
|
40
|
+
'purpose',
|
|
41
|
+
'signerReference',
|
|
42
|
+
'algorithm',
|
|
43
|
+
'verificationMethod',
|
|
44
|
+
'status',
|
|
45
|
+
]);
|
|
46
|
+
function requireNonEmpty(value, path) {
|
|
47
|
+
const normalized = String(value).trim();
|
|
48
|
+
if (!normalized)
|
|
49
|
+
throw new TypeError(`${path} must not be empty`);
|
|
50
|
+
return normalized;
|
|
51
|
+
}
|
|
52
|
+
function requireIsoInstant(value, path) {
|
|
53
|
+
const normalized = requireNonEmpty(value, path);
|
|
54
|
+
const epoch = Date.parse(normalized);
|
|
55
|
+
if (!Number.isFinite(epoch) || new Date(epoch).toISOString() !== normalized) {
|
|
56
|
+
throw new TypeError(`${path} must be an ISO 8601 UTC instant`);
|
|
57
|
+
}
|
|
58
|
+
return normalized;
|
|
59
|
+
}
|
|
60
|
+
function assertSha3_384Base64(value) {
|
|
61
|
+
const normalized = requireNonEmpty(value, 'manifest.digest');
|
|
62
|
+
if (!/^(?:[A-Za-z0-9+/]{4}){16}$/u.test(normalized)) {
|
|
63
|
+
throw new TypeError('manifest.digest must be a base64-encoded 48-byte SHA3-384 digest');
|
|
64
|
+
}
|
|
65
|
+
return normalized;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Builds one pending request from browser-controlled manifest continuity and
|
|
69
|
+
* trusted backend identity, device, purpose, relying-party and key context.
|
|
70
|
+
*/
|
|
71
|
+
export function defineManagedSignatureRequest(draft, trustedContext) {
|
|
72
|
+
for (const property of CLIENT_FORBIDDEN_AUTHORITY) {
|
|
73
|
+
if (Object.hasOwn(draft, property)) {
|
|
74
|
+
throw new TypeError(`Browser draft contains server-owned signing authority (${property})`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (trustedContext.signingKey.algorithm !== ManagedSigningAlgorithm.MlDsa65) {
|
|
78
|
+
throw new TypeError('Managed manifest signing requires ML-DSA-65');
|
|
79
|
+
}
|
|
80
|
+
if (trustedContext.signingKey.purpose !== ManagedSigningKeyPurpose.ActorSigning) {
|
|
81
|
+
throw new TypeError('Managed manifest signing requires the actor-signing key purpose');
|
|
82
|
+
}
|
|
83
|
+
const createdAt = requireIsoInstant(draft.createdAt, 'createdAt');
|
|
84
|
+
const expiresAt = requireIsoInstant(draft.expiresAt, 'expiresAt');
|
|
85
|
+
if (Date.parse(expiresAt) <= Date.parse(createdAt)) {
|
|
86
|
+
throw new TypeError('expiresAt must be after createdAt');
|
|
87
|
+
}
|
|
88
|
+
if (draft.manifest.digestAlgorithm !== 'sha3-384') {
|
|
89
|
+
throw new TypeError('manifest.digestAlgorithm must be sha3-384');
|
|
90
|
+
}
|
|
91
|
+
const manifest = Object.freeze({
|
|
92
|
+
id: requireNonEmpty(draft.manifest.id, 'manifest.id'),
|
|
93
|
+
version: requireNonEmpty(draft.manifest.version, 'manifest.version'),
|
|
94
|
+
digestAlgorithm: 'sha3-384',
|
|
95
|
+
digest: assertSha3_384Base64(draft.manifest.digest),
|
|
96
|
+
});
|
|
97
|
+
const signingKey = Object.freeze({
|
|
98
|
+
purpose: ManagedSigningKeyPurpose.ActorSigning,
|
|
99
|
+
algorithm: ManagedSigningAlgorithm.MlDsa65,
|
|
100
|
+
verificationMethod: requireNonEmpty(trustedContext.signingKey.verificationMethod, 'signingKey.verificationMethod'),
|
|
101
|
+
});
|
|
102
|
+
return Object.freeze({
|
|
103
|
+
requestId: requireNonEmpty(draft.requestId, 'requestId'),
|
|
104
|
+
operationId: requireNonEmpty(draft.operationId, 'operationId'),
|
|
105
|
+
manifest,
|
|
106
|
+
createdAt,
|
|
107
|
+
expiresAt,
|
|
108
|
+
authenticatedUserId: requireNonEmpty(trustedContext.authenticatedUserId, 'authenticatedUserId'),
|
|
109
|
+
registeredDeviceId: requireNonEmpty(trustedContext.registeredDeviceId, 'registeredDeviceId'),
|
|
110
|
+
relyingParty: requireNonEmpty(trustedContext.relyingParty, 'relyingParty'),
|
|
111
|
+
purpose: requireNonEmpty(trustedContext.purpose, 'purpose'),
|
|
112
|
+
signerReference: requireNonEmpty(trustedContext.signerReference, 'signerReference'),
|
|
113
|
+
signingKey,
|
|
114
|
+
state: ManagedSignatureRequestState.Pending,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Projects verified wallet output into public proof metadata while copying all
|
|
119
|
+
* authority and manifest bindings from the immutable request.
|
|
120
|
+
*/
|
|
121
|
+
export function defineManagedSignatureProof(request, result) {
|
|
122
|
+
for (const property of REQUEST_BOUND_PROOF_FIELDS) {
|
|
123
|
+
if (Object.hasOwn(result, property)) {
|
|
124
|
+
throw new TypeError(`Wallet result contains request-bound proof field (${property})`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (result.verified !== true) {
|
|
128
|
+
throw new TypeError('Managed signature proof must be verified before projection');
|
|
129
|
+
}
|
|
130
|
+
const signature = requireNonEmpty(result.signature, 'signature');
|
|
131
|
+
if (!/^[A-Za-z0-9_-]+$/u.test(signature)) {
|
|
132
|
+
throw new TypeError('signature must be unpadded base64url');
|
|
133
|
+
}
|
|
134
|
+
const createdAt = requireIsoInstant(result.createdAt, 'proof.createdAt');
|
|
135
|
+
if (Date.parse(createdAt) < Date.parse(request.createdAt)
|
|
136
|
+
|| Date.parse(createdAt) > Date.parse(request.expiresAt)) {
|
|
137
|
+
throw new TypeError('proof.createdAt must fall within the signature request lifetime');
|
|
138
|
+
}
|
|
139
|
+
return Object.freeze({
|
|
140
|
+
proofId: requireNonEmpty(result.proofId, 'proofId'),
|
|
141
|
+
requestId: request.requestId,
|
|
142
|
+
operationId: request.operationId,
|
|
143
|
+
manifest: request.manifest,
|
|
144
|
+
relyingParty: request.relyingParty,
|
|
145
|
+
purpose: request.purpose,
|
|
146
|
+
signerReference: request.signerReference,
|
|
147
|
+
algorithm: ManagedSigningAlgorithm.MlDsa65,
|
|
148
|
+
verificationMethod: request.signingKey.verificationMethod,
|
|
149
|
+
createdAt,
|
|
150
|
+
signature,
|
|
151
|
+
status: ManagedSignatureProofStatus.Verified,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/** Synthetic, non-sensitive fixture shared by SDK, gateway and portal tests. */
|
|
155
|
+
export const SyntheticManagedSignatureRequestFixture = Object.freeze({
|
|
156
|
+
draft: Object.freeze({
|
|
157
|
+
requestId: 'urn:signature-request:synthetic-publication-v1',
|
|
158
|
+
operationId: 'urn:operation:synthetic-publication-signing-v1',
|
|
159
|
+
manifest: Object.freeze({
|
|
160
|
+
id: SyntheticConfidentialDocumentFixture.manifest.id,
|
|
161
|
+
version: SyntheticConfidentialDocumentFixture.manifest.version,
|
|
162
|
+
digestAlgorithm: 'sha3-384',
|
|
163
|
+
digest: SyntheticConfidentialDocumentFixture.attachment.digest,
|
|
164
|
+
}),
|
|
165
|
+
createdAt: '2026-10-18T20:00:00.000Z',
|
|
166
|
+
expiresAt: '2026-10-18T20:05:00.000Z',
|
|
167
|
+
}),
|
|
168
|
+
trustedContext: Object.freeze({
|
|
169
|
+
authenticatedUserId: 'urn:user:synthetic-signer',
|
|
170
|
+
registeredDeviceId: 'urn:device:synthetic-signer-primary',
|
|
171
|
+
relyingParty: 'https://social-demo.antifraud.services',
|
|
172
|
+
purpose: 'synthetic-publication-manifest-signing',
|
|
173
|
+
signerReference: 'did:example:synthetic-signer',
|
|
174
|
+
signingKey: Object.freeze({
|
|
175
|
+
purpose: ManagedSigningKeyPurpose.ActorSigning,
|
|
176
|
+
algorithm: ManagedSigningAlgorithm.MlDsa65,
|
|
177
|
+
verificationMethod: 'did:example:synthetic-signer#actor-signing-ml-dsa-65',
|
|
178
|
+
}),
|
|
179
|
+
}),
|
|
180
|
+
});
|
|
181
|
+
//# sourceMappingURL=managed-signing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managed-signing.js","sourceRoot":"","sources":["../../src/identity-assurance/managed-signing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,4BAA4B,CAAA;AAEjF,MAAM,CAAC,MAAM,4BA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