antifraud-sdk-core-ts 0.1.1 → 0.1.3

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 CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.1.3 - 2026-10-18
6
+
7
+ - Consume `antifraud-data-utils-ts@0.1.4` and orchestrate Schema.org
8
+ confidential-document delivery through canonical inline or protected-link
9
+ DIDComm attachments.
10
+ - Preserve trusted sender and recipient bindings, idempotent operation replay,
11
+ exact byte-count agreement and separate delivery, read and signature states.
12
+
13
+ ## 0.1.2 - 2026-10-18
14
+
15
+ - Replace binary qualification-issuer lookup with explicit
16
+ `participant-resolved`, `identity-resolved` and `not-resolved` outcomes.
17
+ - Record employer evidence for a known non-participating issuer as
18
+ `awaiting-issuer-onboarding` without fabricating a tenant or queueing a
19
+ confirmation request.
20
+ - Reuse the canonical CIDv1(raw, SHA3-384) validator and synthetic attachment
21
+ fixture from `antifraud-data-utils-ts@0.1.3` instead of duplicating the
22
+ multibase and multihash implementation.
23
+
5
24
  ## 0.1.1 - 2026-10-17
6
25
 
7
26
  - Add runtime-neutral authoritative credential issuance orchestration using
package/README.md CHANGED
@@ -4,7 +4,8 @@ Runtime-neutral orchestration contracts for identity verification, subject and r
4
4
 
5
5
  ## Status
6
6
 
7
- Public implementation foundation. No package has been published and no production readiness is claimed yet.
7
+ Published public implementation foundation. Registry publication proves the
8
+ package artifact only; no deployment or production readiness is claimed.
8
9
 
9
10
  ## Responsibility
10
11
 
@@ -65,12 +66,26 @@ jurisdiction. If no source credential exists, the employer may sign its own
65
66
  attestation but must not be represented as the awarding organization's issuer.
66
67
 
67
68
  The implemented qualification-evidence controller records the employer's proof
68
- through a trusted port, resolves the claimed issuer by legal identifier and
69
- jurisdiction, anchors only opaque continuity, and queues a tenant-to-tenant
70
- confirmation request. See [Qualification evidence confirmation prototype](docs/QUALIFICATION_EVIDENCE_CONFIRMATION.md)
69
+ through a trusted port and resolves the claimed issuer by legal identifier and
70
+ jurisdiction with three explicit outcomes. A participating issuer has a known
71
+ tenant and confirmation service, so the controller anchors opaque continuity
72
+ and queues a tenant-to-tenant confirmation request. A known legal identity
73
+ without a participating tenant is recorded as `awaiting-issuer-onboarding`
74
+ without sending a message or inventing tenant authority. An unresolved identity
75
+ fails before evidence recording. See [Qualification evidence confirmation prototype](docs/QUALIFICATION_EVIDENCE_CONFIRMATION.md)
71
76
  for attachment, issuer notification, ledger recovery and credential-rendering
72
77
  boundaries.
73
78
 
79
+ ## Schema.org document delivery
80
+
81
+ Antifraud documents are Schema.org `DigitalDocument` resources with concrete
82
+ `MediaObject` encodings. They are never FHIR `DocumentReference` resources.
83
+ `createDocumentDeliveryController` consumes the canonical data-utils contract
84
+ and carries governed bytes through DIDComm `attachments[]`, inline or by
85
+ protected reference. Trusted sender, recipient and service bindings remain
86
+ server-owned; replay is operation-idempotent; receipt storage contains no raw
87
+ bytes. Delivery, read and signature remain distinct states.
88
+
74
89
  ## Dependency direction
75
90
 
76
91
  ```text
@@ -0,0 +1,62 @@
1
+ import { buildSchemaOrgConfidentialDocumentGraph, type DidCommBinaryAttachment, type SchemaOrgDigitalDocumentDescriptor, type SchemaOrgEvidenceMediaAttachment } from 'antifraud-data-utils-ts';
2
+ export type TrustedDocumentDeliveryContext = Readonly<{
3
+ senderReference: string;
4
+ recipientReference: string;
5
+ serviceReference: string;
6
+ }>;
7
+ export type DocumentDeliveryAttachmentInput = Readonly<{
8
+ kind: 'inline';
9
+ mediaObject: SchemaOrgEvidenceMediaAttachment;
10
+ bytes: Uint8Array;
11
+ }> | Readonly<{
12
+ kind: 'linked';
13
+ mediaObject: SchemaOrgEvidenceMediaAttachment;
14
+ }>;
15
+ export type DocumentDeliveryRequest = Readonly<{
16
+ operationId: string;
17
+ messageId: string;
18
+ trustedContext: TrustedDocumentDeliveryContext;
19
+ manifest: SchemaOrgDigitalDocumentDescriptor;
20
+ document: SchemaOrgDigitalDocumentDescriptor;
21
+ attachment: DocumentDeliveryAttachmentInput;
22
+ }>;
23
+ export type PreparedDocumentDelivery = Readonly<{
24
+ operationId: string;
25
+ messageId: string;
26
+ trustedContext: TrustedDocumentDeliveryContext;
27
+ documentGraph: ReturnType<typeof buildSchemaOrgConfidentialDocumentGraph>;
28
+ attachments: readonly [DidCommBinaryAttachment];
29
+ }>;
30
+ export type DocumentDeliveryReceipt = Readonly<{
31
+ operationId: string;
32
+ messageId: string;
33
+ deliveryReference: string;
34
+ deliveredAt: string;
35
+ deliveryStatus: 'delivered';
36
+ readStatus: 'unread';
37
+ signatureStatus: 'unsigned';
38
+ }>;
39
+ type DocumentDeliveryContinuity = Readonly<{
40
+ messageId: string;
41
+ senderReference: string;
42
+ recipientReference: string;
43
+ contentId: string;
44
+ receipt: DocumentDeliveryReceipt;
45
+ }>;
46
+ export type DocumentDeliveryControllerPorts = Readonly<{
47
+ transport: Readonly<{
48
+ send(delivery: PreparedDocumentDelivery): Promise<Readonly<{
49
+ deliveryReference: string;
50
+ deliveredAt: string;
51
+ }>>;
52
+ }>;
53
+ receipts: Readonly<{
54
+ get(operationId: string): Promise<DocumentDeliveryContinuity | undefined>;
55
+ put(operationId: string, record: DocumentDeliveryContinuity): Promise<void>;
56
+ }>;
57
+ }>;
58
+ export declare function createDocumentDeliveryController(ports: DocumentDeliveryControllerPorts): Readonly<{
59
+ deliver(request: DocumentDeliveryRequest): Promise<DocumentDeliveryReceipt>;
60
+ }>;
61
+ export {};
62
+ //# sourceMappingURL=document-delivery-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-delivery-controller.d.ts","sourceRoot":"","sources":["../src/document-delivery-controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,uCAAuC,EACvC,KAAK,uBAAuB,EAC5B,KAAK,kCAAkC,EACvC,KAAK,gCAAgC,EACtC,MAAM,yBAAyB,CAAA;AAEhC,MAAM,MAAM,8BAA8B,GAAG,QAAQ,CAAC;IAC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M,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,uBAAuB,CAAA;CACjC,CAAC,CAAA;AAEF,MAAM,MAAM,+BAA+B,GAAG,QAAQ,CAAC;IACrD,SAAS,EAAE,QAAQ,CAAC;QAClB,IAAI,CAAC,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,QAAQ,CAAC;YACzD,iBAAiB,EAAE,MAAM,CAAA;YACzB,WAAW,EAAE,MAAM,CAAA;SACpB,CAAC,CAAC,CAAA;KACJ,CAAC,CAAA;IACF,QAAQ,EAAE,QAAQ,CAAC;QACjB,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC,CAAA;QACzE,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;KAC5E,CAAC,CAAA;CACH,CAAC,CAAA;AAqDF,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,+BAA+B;qBAE5D,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC;GA+BpF"}
@@ -0,0 +1,77 @@
1
+ // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ import { buildDidCommInlineBinaryAttachment, buildDidCommLinkedBinaryAttachment, buildSchemaOrgConfidentialDocumentGraph, } from 'antifraud-data-utils-ts';
3
+ function requireNonEmpty(value, path) {
4
+ const normalized = value.trim();
5
+ if (!normalized)
6
+ throw new TypeError(`${path} must not be empty`);
7
+ return normalized;
8
+ }
9
+ function prepareDocumentDelivery(request) {
10
+ const operationId = requireNonEmpty(request.operationId, 'operationId');
11
+ const messageId = requireNonEmpty(request.messageId, 'messageId');
12
+ const trustedContext = Object.freeze({
13
+ senderReference: requireNonEmpty(request.trustedContext.senderReference, 'senderReference'),
14
+ recipientReference: requireNonEmpty(request.trustedContext.recipientReference, 'recipientReference'),
15
+ serviceReference: requireNonEmpty(request.trustedContext.serviceReference, 'serviceReference'),
16
+ });
17
+ const documentGraph = buildSchemaOrgConfidentialDocumentGraph({
18
+ manifest: request.manifest,
19
+ documents: [{ ...request.document, attachment: request.attachment.mediaObject }],
20
+ });
21
+ const attachment = request.attachment.kind === 'inline'
22
+ ? buildDidCommInlineBinaryAttachment({
23
+ id: request.attachment.mediaObject.id,
24
+ mediaType: request.attachment.mediaObject.mediaType,
25
+ bytes: request.attachment.bytes,
26
+ })
27
+ : buildDidCommLinkedBinaryAttachment(request.attachment.mediaObject);
28
+ if (attachment.byte_count !== request.attachment.mediaObject.contentSize) {
29
+ throw new TypeError('DIDComm attachment byte count does not match the Schema.org MediaObject');
30
+ }
31
+ return Object.freeze({
32
+ operationId,
33
+ messageId,
34
+ trustedContext,
35
+ documentGraph,
36
+ attachments: Object.freeze([attachment]),
37
+ });
38
+ }
39
+ function isSameOperation(current, prepared, contentId) {
40
+ return current.messageId === prepared.messageId
41
+ && current.senderReference === prepared.trustedContext.senderReference
42
+ && current.recipientReference === prepared.trustedContext.recipientReference
43
+ && current.contentId === contentId;
44
+ }
45
+ export function createDocumentDeliveryController(ports) {
46
+ return Object.freeze({
47
+ async deliver(request) {
48
+ const prepared = prepareDocumentDelivery(request);
49
+ const contentId = request.attachment.mediaObject.contentId;
50
+ const current = await ports.receipts.get(prepared.operationId);
51
+ if (current) {
52
+ if (!isSameOperation(current, prepared, contentId)) {
53
+ throw new Error('Document delivery operation replay does not match the original request');
54
+ }
55
+ return current.receipt;
56
+ }
57
+ const delivered = await ports.transport.send(prepared);
58
+ const receipt = Object.freeze({
59
+ operationId: prepared.operationId,
60
+ messageId: prepared.messageId,
61
+ deliveryReference: requireNonEmpty(delivered.deliveryReference, 'deliveryReference'),
62
+ deliveredAt: requireNonEmpty(delivered.deliveredAt, 'deliveredAt'),
63
+ deliveryStatus: 'delivered',
64
+ readStatus: 'unread',
65
+ signatureStatus: 'unsigned',
66
+ });
67
+ await ports.receipts.put(prepared.operationId, Object.freeze({
68
+ messageId: prepared.messageId,
69
+ senderReference: prepared.trustedContext.senderReference,
70
+ recipientReference: prepared.trustedContext.recipientReference,
71
+ contentId,
72
+ receipt,
73
+ }));
74
+ return receipt;
75
+ },
76
+ });
77
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './openid4vp.js';
2
2
  export * from './credential-issuance-controller.js';
3
+ export * from './document-delivery-controller.js';
3
4
  export * from './presentation-controller.js';
4
5
  export * from './presentation-session.js';
5
6
  export * from './qualification-evidence-controller.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qCAAqC,CAAA;AACnD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,wCAAwC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qCAAqC,CAAA;AACnD,cAAc,mCAAmC,CAAA;AACjD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,wCAAwC,CAAA"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './openid4vp.js';
2
2
  export * from './credential-issuance-controller.js';
3
+ export * from './document-delivery-controller.js';
3
4
  export * from './presentation-controller.js';
4
5
  export * from './presentation-session.js';
5
6
  export * from './qualification-evidence-controller.js';
@@ -7,6 +7,15 @@ export type ResolvedQualificationIssuer = QualificationIssuerQuery & Readonly<{
7
7
  issuerOrganizationReference: string;
8
8
  confirmationServiceReference: string;
9
9
  }>;
10
+ export type QualificationIssuerResolution = Readonly<{
11
+ kind: 'participant-resolved';
12
+ issuer: ResolvedQualificationIssuer;
13
+ }> | Readonly<{
14
+ kind: 'identity-resolved';
15
+ issuerOrganizationReference: string;
16
+ }> | Readonly<{
17
+ kind: 'not-resolved';
18
+ }>;
10
19
  export type QualificationEvidenceRequest = Readonly<{
11
20
  trustedContext: Readonly<{
12
21
  controllerAuthorizationReference: string;
@@ -40,7 +49,7 @@ export type QualificationConfirmationRequestMessage = Readonly<{
40
49
  }>;
41
50
  export type QualificationEvidenceControllerPorts = Readonly<{
42
51
  issuerDirectory: Readonly<{
43
- resolve(query: QualificationIssuerQuery): Promise<ResolvedQualificationIssuer | null>;
52
+ resolve(query: QualificationIssuerQuery): Promise<QualificationIssuerResolution>;
44
53
  }>;
45
54
  evidenceRecorder: Readonly<{
46
55
  recordEmployerAttestation(request: QualificationEvidenceRequest): Promise<Readonly<{
@@ -57,9 +66,13 @@ export type QualificationEvidenceControllerPorts = Readonly<{
57
66
  anchorReference: string;
58
67
  evidenceReference: string;
59
68
  contentHash: string;
69
+ issuerOrganizationReference: string;
70
+ }> & (Readonly<{
60
71
  issuerTenantReference: string;
61
72
  lifecycleStatus: 'awaiting-issuer-confirmation';
62
- }>): Promise<void>;
73
+ }> | Readonly<{
74
+ lifecycleStatus: 'awaiting-issuer-onboarding';
75
+ }>)): Promise<void>;
63
76
  }>;
64
77
  outbox: Readonly<{
65
78
  queue(message: QualificationConfirmationRequestMessage): Promise<Readonly<{
@@ -71,6 +84,12 @@ export type QualificationEvidenceControllerPorts = Readonly<{
71
84
  export declare function createQualificationEvidenceController(ports: QualificationEvidenceControllerPorts): {
72
85
  submit(request: QualificationEvidenceRequest): Promise<Readonly<{
73
86
  phase: "issuer-not-resolved";
87
+ }> | Readonly<{
88
+ phase: "awaiting-issuer-onboarding";
89
+ evidenceReference: string;
90
+ employerProofReference: string;
91
+ ledgerAnchorReference: string;
92
+ issuerOrganizationReference: string;
74
93
  }> | Readonly<{
75
94
  phase: "issuer-confirmation-queued";
76
95
  evidenceReference: string;
@@ -1 +1 @@
1
- {"version":3,"file":"qualification-evidence-controller.d.ts","sourceRoot":"","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MAAM,CAAA;IAC/B,qBAAqB,EAAE,MAAM,CAAA;IAC7B,oCAAoC,EAAE,MAAM,CAAA;IAC5C,SAAS,EAAE,MAAM,CAAA;CAClB,CAAC,GAAG,iCAAiC,CAarC"}
1
+ {"version":3,"file":"qualification-evidence-controller.d.ts","sourceRoot":"","sources":["../src/qualification-evidence-controller.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC;IAC9C,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAC,CAAA;AAEF,MAAM,MAAM,2BAA2B,GAAG,wBAAwB,GAAG,QAAQ,CAAC;IAC5E,qBAAqB,EAAE,MAAM,CAAA;IAC7B,2BAA2B,EAAE,MAAM,CAAA;IACnC,4BAA4B,EAAE,MAAM,CAAA;CACrC,CAAC,CAAA;AAEF,MAAM,MAAM,6BAA6B,GACrC,QAAQ,CAAC;IACP,IAAI,EAAE,sBAAsB,CAAA;IAC5B,MAAM,EAAE,2BAA2B,CAAA;CACpC,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,mBAAmB,CAAA;IACzB,2BAA2B,EAAE,MAAM,CAAA;CACpC,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,cAAc,CAAA;CACrB,CAAC,CAAA;AAEN,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CAAC;IAClD,cAAc,EAAE,QAAQ,CAAC;QACvB,gCAAgC,EAAE,MAAM,CAAA;QACxC,uBAAuB,EAAE,MAAM,CAAA;QAC/B,6BAA6B,EAAE,MAAM,CAAA;QACrC,iBAAiB,EAAE,MAAM,CAAA;QACzB,2BAA2B,EAAE,MAAM,CAAA;KACpC,CAAC,CAAA;IACF,2BAA2B,EAAE,MAAM,CAAA;IACnC,aAAa,EAAE,wBAAwB,CAAA;IACvC,QAAQ,EAAE,QAAQ,CAAC;QACjB,SAAS,EAAE,MAAM,CAAA;QACjB,SAAS,EAAE,MAAM,CAAA;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B,6BAA6B,EAAE,MAAM,CAAA;IACrC,mCAAmC,EAAE,MAAM,CAAA;CAC5C,CAAC,EACF,QAAQ,EAAE,2BAA2B,GACpC,0BAA0B,CAkB5B;AAED,MAAM,MAAM,iCAAiC,GAAG,QAAQ,CAAC;IACvD,WAAW,EAAE,wCAAwC,CAAA;IACrD,SAAS,EAAE,MAAM,CAAA;IACjB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,iBAAiB,EAAE,MAAM,CAAA;IACzB,gBAAgB,EAAE,MAAM,CAAA;IACxB,iBAAiB,EAAE,MAAM,CAAA;IACzB,MAAM,EAAE,0BAA0B,CAAC,QAAQ,CAAC,CAAA;IAC5C,oBAAoB,EAAE,MAAM,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAC,CAAA;AAEF,wBAAgB,sCAAsC,CAAC,KAAK,EAAE,QAAQ,CAAC;IACrE,OAAO,EAAE,0BAA0B,CAAA;IACnC,uBAAuB,EAAE,MAAM,CAAA;IAC/B,qBAAqB,EAAE,MAAM,CAAA;IAC7B,oCAAoC,EAAE,MAAM,CAAA;IAC5C,SAAS,EAAE,MAAM,CAAA;CAClB,CAAC,GAAG,iCAAiC,CAarC"}
@@ -1,42 +1,9 @@
1
1
  // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ import { assertSha3_384EvidenceContentId } from 'antifraud-data-utils-ts';
2
3
  function requireReference(value, path) {
3
4
  if (value.trim().length === 0)
4
5
  throw new TypeError(`${path} must not be empty`);
5
6
  }
6
- const BASE58BTC_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
7
- function decodeBase58btc(value) {
8
- let decoded = 0n;
9
- for (const character of value) {
10
- const index = BASE58BTC_ALPHABET.indexOf(character);
11
- if (index < 0)
12
- throw new TypeError('Invalid base58btc character');
13
- decoded = decoded * 58n + BigInt(index);
14
- }
15
- const bytes = [];
16
- while (decoded > 0n) {
17
- bytes.unshift(Number(decoded & 0xffn));
18
- decoded >>= 8n;
19
- }
20
- for (const character of value) {
21
- if (character !== '1')
22
- break;
23
- bytes.unshift(0);
24
- }
25
- return Uint8Array.from(bytes);
26
- }
27
- function assertRawSha3_384CidV1(contentId) {
28
- if (!/^z[1-9A-HJ-NP-Za-km-z]+$/u.test(contentId)) {
29
- throw new TypeError('evidence.contentId must be a base58btc multibase CID');
30
- }
31
- const bytes = decodeBase58btc(contentId.slice(1));
32
- if (bytes.length !== 52
33
- || bytes[0] !== 0x01
34
- || bytes[1] !== 0x55
35
- || bytes[2] !== 0x15
36
- || bytes[3] !== 0x30) {
37
- throw new TypeError('evidence.contentId must be CIDv1 raw with a SHA3-384 multihash');
38
- }
39
- }
40
7
  function validateRequest(request) {
41
8
  requireReference(request.trustedContext.controllerAuthorizationReference, 'controllerAuthorizationReference');
42
9
  requireReference(request.trustedContext.employerTenantReference, 'employerTenantReference');
@@ -47,22 +14,40 @@ function validateRequest(request) {
47
14
  requireReference(request.claimedIssuer.legalIdentifier, 'claimedIssuer.legalIdentifier');
48
15
  requireReference(request.claimedIssuer.jurisdiction, 'claimedIssuer.jurisdiction');
49
16
  requireReference(request.evidence.reference, 'evidence.reference');
50
- assertRawSha3_384CidV1(request.evidence.contentId);
17
+ assertSha3_384EvidenceContentId(request.evidence.contentId);
51
18
  }
52
19
  export function createQualificationEvidenceController(ports) {
53
20
  return {
54
21
  async submit(request) {
55
22
  validateRequest(request);
56
- const issuer = await ports.issuerDirectory.resolve(request.claimedIssuer);
57
- if (!issuer) {
23
+ const resolution = await ports.issuerDirectory.resolve(request.claimedIssuer);
24
+ if (resolution.kind === 'not-resolved') {
58
25
  return Object.freeze({ phase: 'issuer-not-resolved' });
59
26
  }
60
27
  const recorded = await ports.evidenceRecorder.recordEmployerAttestation(request);
28
+ if (resolution.kind === 'identity-resolved') {
29
+ await ports.ledger.recordAnchor({
30
+ anchorReference: recorded.anchor.anchorReference,
31
+ evidenceReference: recorded.evidenceReference,
32
+ contentHash: recorded.anchor.contentHash,
33
+ issuerOrganizationReference: resolution.issuerOrganizationReference,
34
+ lifecycleStatus: 'awaiting-issuer-onboarding',
35
+ });
36
+ return Object.freeze({
37
+ phase: 'awaiting-issuer-onboarding',
38
+ evidenceReference: recorded.evidenceReference,
39
+ employerProofReference: recorded.employerProofReference,
40
+ ledgerAnchorReference: recorded.anchor.anchorReference,
41
+ issuerOrganizationReference: resolution.issuerOrganizationReference,
42
+ });
43
+ }
44
+ const issuer = resolution.issuer;
61
45
  await ports.ledger.recordAnchor({
62
46
  anchorReference: recorded.anchor.anchorReference,
63
47
  evidenceReference: recorded.evidenceReference,
64
48
  contentHash: recorded.anchor.contentHash,
65
49
  issuerTenantReference: issuer.issuerTenantReference,
50
+ issuerOrganizationReference: issuer.issuerOrganizationReference,
66
51
  lifecycleStatus: 'awaiting-issuer-confirmation',
67
52
  });
68
53
  const message = Object.freeze({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antifraud-sdk-core-ts",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Runtime-neutral orchestration for identity verification and provider-issued credentials",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -34,6 +34,6 @@
34
34
  "typescript": "^5.9.3"
35
35
  },
36
36
  "dependencies": {
37
- "antifraud-data-utils-ts": "0.1.1"
37
+ "antifraud-data-utils-ts": "0.1.4"
38
38
  }
39
39
  }