@@ -2,12 +2,17 @@ import type { Claim, SignedClaim } from '#claims/types.js';
22import type {
33 ClaimLinkNode ,
44 ClaimLinkIdentity ,
5+ ClaimNetworkAccess ,
56} from '#claims/payloads/index.js' ;
7+ import type { SignedTokenEncoded } from '#tokens/types.js' ;
8+ import type { ClaimNetworkAuthority } from '#claims/payloads/claimNetworkAuthority.js' ;
9+ import type { NodeIdEncoded } from '#ids/index.js' ;
610import fc from 'fast-check' ;
711import * as testsClaimsUtils from '../utils.js' ;
812import * as testsTokensUtils from '../../tokens/utils.js' ;
913import * as testsIdsUtils from '../../ids/utils.js' ;
1014import * as claimsUtils from '#claims/utils.js' ;
15+ import { NodeId } from '#ids/index.js' ;
1116
1217const claimLinkIdentityArb = testsClaimsUtils . claimArb . chain ( ( claim ) => {
1318 return fc
@@ -66,11 +71,83 @@ const signedClaimArb = <P extends Claim>(
6671const signedClaimEncodedArb = ( payloadArb : fc . Arbitrary < Claim > ) =>
6772 signedClaimArb ( payloadArb ) . map ( claimsUtils . generateSignedClaim ) ;
6873
74+ const claimNetworkAuthorityArb = (
75+ iss : fc . Arbitrary < NodeIdEncoded > = testsIdsUtils . nodeIdEncodedArb ,
76+ sub : fc . Arbitrary < NodeIdEncoded > = testsIdsUtils . nodeIdEncodedArb ,
77+ ) =>
78+ fc . noShrink (
79+ testsClaimsUtils . claimArb . chain ( ( claim ) => {
80+ return fc
81+ . record (
82+ {
83+ iss : testsIdsUtils . nodeIdEncodedArb ,
84+ sub : testsIdsUtils . nodeIdEncodedArb ,
85+ } ,
86+ { noNullPrototype : true } ,
87+ )
88+ . chain ( ( value ) => {
89+ return fc . constant ( {
90+ typ : 'ClaimNetworkAuthority' ,
91+ ...claim ,
92+ ...value ,
93+ } ) ;
94+ } ) ;
95+ } ) as fc . Arbitrary < ClaimNetworkAuthority > ,
96+ ) ;
97+
98+ const claimNetworkAuthorityEncodedArb = (
99+ iss : fc . Arbitrary < NodeIdEncoded > = testsIdsUtils . nodeIdEncodedArb ,
100+ sub : fc . Arbitrary < NodeIdEncoded > = testsIdsUtils . nodeIdEncodedArb ,
101+ ) => claimNetworkAuthorityArb ( iss , sub ) . map ( claimsUtils . generateClaim ) ;
102+
103+ const claimNetworkAccessArb = (
104+ iss : fc . Arbitrary < NodeIdEncoded > = testsIdsUtils . nodeIdEncodedArb ,
105+ sub : fc . Arbitrary < NodeIdEncoded > = testsIdsUtils . nodeIdEncodedArb ,
106+ network : fc . Arbitrary < string > = fc . string ( ) ,
107+ signedClaimNetworkAuthorityEncoded : fc . Arbitrary < SignedTokenEncoded > = signedClaimEncodedArb (
108+ claimNetworkAuthorityArb (
109+ testsIdsUtils . nodeIdEncodedArb ,
110+ testsIdsUtils . nodeIdEncodedArb ,
111+ ) ,
112+ ) ,
113+ ) =>
114+ fc . noShrink (
115+ testsClaimsUtils . claimArb . chain ( ( claim ) => {
116+ return fc
117+ . record (
118+ {
119+ iss,
120+ sub,
121+ network,
122+ signedClaimNetworkAuthorityEncoded,
123+ } ,
124+ { noNullPrototype : true } ,
125+ )
126+ . chain ( ( value ) => {
127+ return fc . constant ( {
128+ typ : 'ClaimNetworkAccess' ,
129+ ...claim ,
130+ ...value ,
131+ } ) ;
132+ } ) ;
133+ } ) as fc . Arbitrary < ClaimNetworkAccess > ,
134+ ) ;
135+
136+ const claimNetworkAccessEncodedArb = (
137+ iss : fc . Arbitrary < NodeIdEncoded > = testsIdsUtils . nodeIdEncodedArb ,
138+ sub : fc . Arbitrary < NodeIdEncoded > = testsIdsUtils . nodeIdEncodedArb ,
139+ network : fc . Arbitrary < string > = fc . string ( ) ,
140+ ) => claimNetworkAccessArb ( iss , sub , network ) . map ( claimsUtils . generateClaim ) ;
141+
69142export {
70143 claimLinkIdentityArb ,
71144 claimLinkIdentityEncodedArb ,
72145 claimLinkNodeArb ,
73146 claimLinkNodeEncodedArb ,
74147 signedClaimArb ,
75148 signedClaimEncodedArb ,
149+ claimNetworkAccessArb ,
150+ claimNetworkAccessEncodedArb ,
151+ claimNetworkAuthorityArb ,
152+ claimNetworkAuthorityEncodedArb ,
76153} ;
0 commit comments