@@ -20,6 +20,7 @@ import {
2020 ComputeJobMetadata
2121} from '../@types'
2222import { decodeJwt } from '../utils/Jwt.js'
23+ import { PolicyServer } from '../@types/PolicyServer.js'
2324
2425export class Provider {
2526 private async getConsumerAddress ( signerOrAuthToken : Signer | string ) : Promise < string > {
@@ -512,6 +513,7 @@ export class Provider {
512513 * @param {SignerOrAuthToken } signerOrAuthToken Signer or auth token
513514 * @param {ComputeResourceRequest[] } resources The resources to start compute job with.
514515 * @param {number } chainId The chain used to do payments
516+ * @param {PolicyServer } policyServer The policy server object.
515517 * @param {AbortSignal } signal abort signal
516518 * @return {Promise<ProviderComputeInitialize> } ProviderComputeInitialize data
517519 */
@@ -525,6 +527,7 @@ export class Provider {
525527 signerOrAuthToken : Signer | string ,
526528 resources : ComputeResourceRequest [ ] ,
527529 chainId : number ,
530+ policyServer ?: PolicyServer ,
528531 signal ?: AbortSignal
529532 ) : Promise < ProviderComputeInitializeResults > {
530533 const providerEndpoints = await this . getEndpoints ( providerUri )
@@ -556,7 +559,7 @@ export class Provider {
556559 signatureMessage += nonce
557560 const signature = await this . getSignature ( signerOrAuthToken , signatureMessage )
558561
559- const providerData : Object = {
562+ const providerData : Record < string , any > = {
560563 datasets : assets ,
561564 algorithm,
562565 environment : computeEnv ,
@@ -570,6 +573,8 @@ export class Provider {
570573 signature
571574 }
572575
576+ if ( policyServer ) providerData . policyServer = policyServer
577+
573578 let response
574579 try {
575580 console . log ( 'Initialize compute url:' , initializeUrl )
@@ -615,7 +620,7 @@ export class Provider {
615620 * @param {string } transferTxId - The transfer transaction ID.
616621 * @param {string } providerUri - The provider URI.
617622 * @param {SignerOrAuthToken } signerOrAuthToken - The signer or auth token.
618- * @param {any } policyServer - The policy server (if any is to be used).
623+ * @param {PolicyServer } policyServer - The policy server (if any is to be used).
619624 * @param {UserCustomParameters } userCustomParameters - The user custom parameters.
620625 * @returns {Promise<any> } The download URL.
621626 */
@@ -626,7 +631,7 @@ export class Provider {
626631 transferTxId : string ,
627632 providerUri : string ,
628633 signerOrAuthToken : Signer | string ,
629- policyServer ?: any ,
634+ policyServer ?: PolicyServer ,
630635 userCustomParameters ?: UserCustomParameters
631636 ) : Promise < any > {
632637 const providerEndpoints = await this . getEndpoints ( providerUri )
@@ -763,6 +768,7 @@ export class Provider {
763768 * @param {chainId } chainId The chain used to do payments
764769 * @param {ComputeJobMetadata } metadata The compute job metadata. Additional metadata to be stored in the database.
765770 * @param {ComputeOutput } output The compute job output settings.
771+ * @param {PolicyServer } policyServer The policy server object.
766772 * @param {AbortSignal } signal abort signal
767773 * @return {Promise<ComputeJob | ComputeJob[]> } The compute job or jobs.
768774 */
@@ -778,6 +784,7 @@ export class Provider {
778784 chainId : number , // network used by payment (only for payed compute jobs)
779785 metadata ?: ComputeJobMetadata ,
780786 output ?: ComputeOutput ,
787+ policyServer ?: PolicyServer ,
781788 signal ?: AbortSignal
782789 ) : Promise < ComputeJob | ComputeJob [ ] > {
783790 console . log ( 'called new compute start method...' )
@@ -837,6 +844,7 @@ export class Provider {
837844 if ( metadata ) payload . metadata = metadata
838845 // if (additionalDatasets) payload.additionalDatasets = additionalDatasets
839846 if ( output ) payload . output = output
847+ if ( policyServer ) payload . policyServer = policyServer
840848 let response
841849 try {
842850 response = await fetch ( computeStartUrl , {
@@ -877,6 +885,7 @@ export class Provider {
877885 * @param {ComputeResourceRequest } resources The resources to start compute job with.
878886 * @param {ComputeJobMetadata } metadata The compute job metadata. Additional metadata to be stored in the database.
879887 * @param {ComputeOutput } output The compute job output settings.
888+ * @param {PolicyServer } policyServer The policy server object.
880889 * @param {AbortSignal } signal abort signal
881890 * @return {Promise<ComputeJob | ComputeJob[]> } The compute job or jobs.
882891 */
@@ -889,6 +898,7 @@ export class Provider {
889898 resources ?: ComputeResourceRequest [ ] ,
890899 metadata ?: ComputeJobMetadata ,
891900 output ?: ComputeOutput ,
901+ policyServer ?: PolicyServer ,
892902 signal ?: AbortSignal
893903 ) : Promise < ComputeJob | ComputeJob [ ] > {
894904 console . log ( 'called new free compute start method...' )
@@ -939,6 +949,7 @@ export class Provider {
939949 if ( metadata ) payload . metadata = metadata
940950 // if (additionalDatasets) payload.additionalDatasets = additionalDatasets
941951 payload . output = output
952+ if ( policyServer ) payload . policyServer = policyServer
942953 let response
943954 try {
944955 response = await fetch ( computeStartUrl , {
0 commit comments