@@ -24,11 +24,11 @@ import { ProtocolAuthorization } from '../../../core/protocol-authorization.js';
2424import { Records } from '../../../utils/records.js' ;
2525import { removeUndefinedProperties } from '../../../utils/object.js' ;
2626import { Secp256k1 } from '../../../utils/secp256k1.js' ;
27-
2827import { authorize , validateAuthorizationIntegrity } from '../../../core/auth.js' ;
2928import { Cid , computeCid } from '../../../utils/cid.js' ;
3029import { DwnError , DwnErrorCode } from '../../../core/dwn-error.js' ;
3130import { DwnInterfaceName , DwnMethodName } from '../../../core/message.js' ;
31+ import { normalizeProtocolUri , validateProtocolUriNormalized } from '../../../utils/url.js' ;
3232
3333export type RecordsWriteOptions = {
3434 recipient ?: string ;
@@ -161,7 +161,7 @@ export class RecordsWrite extends Message<RecordsWriteMessage> {
161161 const descriptor : RecordsWriteDescriptor = {
162162 interface : DwnInterfaceName . Records ,
163163 method : DwnMethodName . Write ,
164- protocol : options . protocol ,
164+ protocol : options . protocol !== undefined ? normalizeProtocolUri ( options . protocol ) : undefined ,
165165 protocolPath : options . protocolPath ,
166166 recipient : options . recipient ! ,
167167 schema : options . schema ,
@@ -368,6 +368,10 @@ export class RecordsWrite extends Message<RecordsWriteMessage> {
368368 ) ;
369369 }
370370 }
371+
372+ if ( this . message . descriptor . protocol !== undefined ) {
373+ validateProtocolUriNormalized ( this . message . descriptor . protocol ) ;
374+ }
371375 }
372376
373377 /**
@@ -500,7 +504,7 @@ export class RecordsWrite extends Message<RecordsWriteMessage> {
500504 /**
501505 * Creates the `attestation` property of a RecordsWrite message if given signature inputs; returns `undefined` otherwise.
502506 */
503- private static async createAttestation ( descriptorCid : string , signatureInputs ?: SignatureInput [ ] ) : Promise < GeneralJws | undefined > {
507+ public static async createAttestation ( descriptorCid : string , signatureInputs ?: SignatureInput [ ] ) : Promise < GeneralJws | undefined > {
504508 if ( signatureInputs === undefined || signatureInputs . length === 0 ) {
505509 return undefined ;
506510 }
@@ -515,7 +519,7 @@ export class RecordsWrite extends Message<RecordsWriteMessage> {
515519 /**
516520 * Creates the `authorization` property of a RecordsWrite message.
517521 */
518- private static async createAuthorization (
522+ public static async createAuthorization (
519523 recordId : string ,
520524 contextId : string | undefined ,
521525 descriptorCid : string ,
0 commit comments