antifraud-data-utils-ts 0.1.0 → 0.1.1

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
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 0.1.1 - 2026-10-17
8
+
9
+ - Add the canonical credential-issuance request, lifecycle, receipt wire
10
+ conversion and synthetic fixture shared by SDK Core, SDK Node and ICA.
7
11
  - Add a validated, product-neutral flat-claim projection for subject identity,
8
12
  subject relationships and age-over evidence targets.
9
13
  - Publish the canonical flat-claim name that binds an evidence target to its
@@ -0,0 +1,41 @@
1
+ import { type IdentityAttestationCapabilityValue } from './vocabulary.js';
2
+ export declare const CredentialIssuanceStatus: Readonly<{
3
+ readonly Pending: "pending";
4
+ readonly Issued: "issued";
5
+ readonly Denied: "denied";
6
+ readonly Failed: "failed";
7
+ }>;
8
+ export type CredentialIssuanceStatusValue = typeof CredentialIssuanceStatus[keyof typeof CredentialIssuanceStatus];
9
+ export type CredentialIssuanceRequest = Readonly<{
10
+ subjectReference: string;
11
+ capability: IdentityAttestationCapabilityValue;
12
+ verificationTransactionId: string;
13
+ }>;
14
+ export type CredentialIssuanceRequestWire = Readonly<{
15
+ subject_reference: string;
16
+ capability: IdentityAttestationCapabilityValue;
17
+ verification_transaction_id: string;
18
+ }>;
19
+ export type CredentialIssuanceReceipt = Readonly<{
20
+ issuanceId: string;
21
+ status: CredentialIssuanceStatusValue;
22
+ credential?: unknown;
23
+ credentialReference?: string;
24
+ reason?: string;
25
+ }>;
26
+ export type CredentialIssuanceReceiptWire = Readonly<{
27
+ issuance_id: string;
28
+ status: CredentialIssuanceStatusValue;
29
+ credential?: unknown;
30
+ credential_reference?: string;
31
+ reason?: string;
32
+ }>;
33
+ export declare function defineCredentialIssuanceRequest(input: CredentialIssuanceRequest & Record<string, unknown>): CredentialIssuanceRequest;
34
+ export declare function toCredentialIssuanceRequestWire(input: CredentialIssuanceRequest & Record<string, unknown>): CredentialIssuanceRequestWire;
35
+ export declare function parseCredentialIssuanceReceiptWire(value: unknown): CredentialIssuanceReceipt;
36
+ export declare const credentialIssuanceRequestFixture: Readonly<{
37
+ subjectReference: "urn:subject:synthetic";
38
+ capability: "identity.relationship.attest";
39
+ verificationTransactionId: "verification-synthetic-001";
40
+ }>;
41
+ //# sourceMappingURL=credential-issuance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-issuance.d.ts","sourceRoot":"","sources":["../../src/identity-assurance/credential-issuance.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kCAAkC,EACxC,MAAM,iBAAiB,CAAA;AAExB,eAAO,MAAM,wBAAwB;;;;;EAK1B,CAAA;AAEX,MAAM,MAAM,6BAA6B,GACvC,OAAO,wBAAwB,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAA;AAExE,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC;IAC/C,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,kCAAkC,CAAA;IAC9C,yBAAyB,EAAE,MAAM,CAAA;CAClC,CAAC,CAAA;AAEF,MAAM,MAAM,6BAA6B,GAAG,QAAQ,CAAC;IACnD,iBAAiB,EAAE,MAAM,CAAA;IACzB,UAAU,EAAE,kCAAkC,CAAA;IAC9C,2BAA2B,EAAE,MAAM,CAAA;CACpC,CAAC,CAAA;AAEF,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC;IAC/C,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,6BAA6B,CAAA;IACrC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAC,CAAA;AAEF,MAAM,MAAM,6BAA6B,GAAG,QAAQ,CAAC;IACnD,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,6BAA6B,CAAA;IACrC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAC,CAAA;AAkBF,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACzD,yBAAyB,CAmB3B;AAED,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACzD,6BAA6B,CAO/B;AAED,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,GACb,yBAAyB,CAgD3B;AAED,eAAO,MAAM,gCAAgC;;;;EAIP,CAAA"}
@@ -0,0 +1,93 @@
1
+ import { IdentityAttestationCapability, } from './vocabulary.js';
2
+ export const CredentialIssuanceStatus = Object.freeze({
3
+ Pending: 'pending',
4
+ Issued: 'issued',
5
+ Denied: 'denied',
6
+ Failed: 'failed',
7
+ });
8
+ function requireText(value, name) {
9
+ if (typeof value !== 'string' || value.trim().length === 0) {
10
+ throw new TypeError(`${name} must be a non-empty string`);
11
+ }
12
+ return value.trim();
13
+ }
14
+ function isCapability(value) {
15
+ return Object.values(IdentityAttestationCapability).includes(value);
16
+ }
17
+ function isStatus(value) {
18
+ return typeof value === 'string'
19
+ && Object.values(CredentialIssuanceStatus).includes(value);
20
+ }
21
+ export function defineCredentialIssuanceRequest(input) {
22
+ if ('claims' in input) {
23
+ throw new TypeError('Caller-supplied claims are not accepted; the provider must perform authoritative readback');
24
+ }
25
+ const subjectReference = requireText(input.subjectReference, 'subjectReference');
26
+ const capability = requireText(input.capability, 'capability');
27
+ if (!isCapability(capability)) {
28
+ throw new TypeError('capability must be a governed identity-attestation capability');
29
+ }
30
+ return Object.freeze({
31
+ subjectReference,
32
+ capability,
33
+ verificationTransactionId: requireText(input.verificationTransactionId, 'verificationTransactionId'),
34
+ });
35
+ }
36
+ export function toCredentialIssuanceRequestWire(input) {
37
+ const request = defineCredentialIssuanceRequest(input);
38
+ return Object.freeze({
39
+ subject_reference: request.subjectReference,
40
+ capability: request.capability,
41
+ verification_transaction_id: request.verificationTransactionId,
42
+ });
43
+ }
44
+ export function parseCredentialIssuanceReceiptWire(value) {
45
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
46
+ throw new TypeError('Invalid credential-provider response');
47
+ }
48
+ const input = value;
49
+ let issuanceId;
50
+ try {
51
+ issuanceId = requireText(input.issuance_id, 'issuance_id');
52
+ }
53
+ catch {
54
+ throw new TypeError('Invalid credential-provider response');
55
+ }
56
+ if (!isStatus(input.status)) {
57
+ throw new TypeError('Invalid credential-provider response');
58
+ }
59
+ const credentialReference = typeof input.credential_reference === 'string'
60
+ && input.credential_reference.trim().length > 0
61
+ ? input.credential_reference.trim()
62
+ : undefined;
63
+ const reason = typeof input.reason === 'string' && input.reason.trim().length > 0
64
+ ? input.reason.trim()
65
+ : undefined;
66
+ const hasCredential = Object.prototype.hasOwnProperty.call(input, 'credential');
67
+ if (input.status === CredentialIssuanceStatus.Issued && !hasCredential && !credentialReference) {
68
+ throw new TypeError('An issued credential receipt requires a credential or credential reference');
69
+ }
70
+ if ((input.status === CredentialIssuanceStatus.Denied
71
+ || input.status === CredentialIssuanceStatus.Failed)
72
+ && hasCredential) {
73
+ throw new TypeError(`${input.status} credential receipt must not include a credential`);
74
+ }
75
+ if ((input.status === CredentialIssuanceStatus.Denied
76
+ || input.status === CredentialIssuanceStatus.Failed)
77
+ && !reason) {
78
+ throw new TypeError(`${input.status} credential receipt requires a reason`);
79
+ }
80
+ return Object.freeze({
81
+ issuanceId,
82
+ status: input.status,
83
+ ...(hasCredential ? { credential: input.credential } : {}),
84
+ ...(credentialReference ? { credentialReference } : {}),
85
+ ...(reason ? { reason } : {}),
86
+ });
87
+ }
88
+ export const credentialIssuanceRequestFixture = Object.freeze({
89
+ subjectReference: 'urn:subject:synthetic',
90
+ capability: IdentityAttestationCapability.AttestRelationship,
91
+ verificationTransactionId: 'verification-synthetic-001',
92
+ });
93
+ //# sourceMappingURL=credential-issuance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-issuance.js","sourceRoot":"","sources":["../../src/identity-assurance/credential-issuance.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,GAE9B,MAAM,iBAAiB,CAAA;AAExB,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,CAAC;IACpD,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CACR,CAAC,CAAA;AAiCX,SAAS,WAAW,CAAC,KAAc,EAAE,IAAY;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,6BAA6B,CAAC,CAAA;IAC3D,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAA;AACrB,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,OAAQ,MAAM,CAAC,MAAM,CAAC,6BAA6B,CAAuB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC5F,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ;WAC1B,MAAM,CAAC,MAAM,CAAC,wBAAwB,CAAuB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AACrF,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,KAA0D;IAE1D,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,IAAI,SAAS,CACjB,2FAA2F,CAC5F,CAAA;IACH,CAAC;IACD,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAA;IAChF,MA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AAC,MAAM;QACpB,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAC,UAAU,EAAE,KAAK,CAAC,UAAU,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAC,mBAAmB,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5B,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5D,gBAAgB,EAAE,uBAAuB;IACzC,UAAU,EAAE,6BAA6B,CAAC,kBAAkB;IAC5D,yBAAyB,EAAE,4BAA4B;CACxD,CAAqC,CAAA"}
@@ -1,5 +1,6 @@
1
1
  export * from './claim-proofs.js';
2
2
  export * from './converters.js';
3
+ export * from './credential-issuance.js';
3
4
  export * from './identity-evidence.js';
4
5
  export * from './professional-qualification.js';
5
6
  export * from './schema-org-evidence.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,iBAAiB,CAAA;AAC/B,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,iBAAiB,CAAA;AAC/B,cAAc,0BAA0B,CAAA;AACxC,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,5 +1,6 @@
1
1
  export * from './claim-proofs.js';
2
2
  export * from './converters.js';
3
+ export * from './credential-issuance.js';
3
4
  export * from './identity-evidence.js';
4
5
  export * from './professional-qualification.js';
5
6
  export * from './schema-org-evidence.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity-assurance/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,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,iBAAiB,CAAA;AAC/B,cAAc,0BAA0B,CAAA;AACxC,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antifraud-data-utils-ts",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Product-neutral identity verification, evidence and attestation data contracts",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",