Skip to content

Commit

Permalink
chore: Rename authorize to authorise
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran committed Oct 16, 2024
1 parent 52701eb commit a5100dc
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 48 deletions.
30 changes: 15 additions & 15 deletions src/controllers/api/accreditation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class AccreditationController {
query('accreditationType')
.exists()
.isIn([
AccreditationRequestType.authorize,
AccreditationRequestType.authorise,
AccreditationRequestType.accredit,
AccreditationRequestType.attest,
])
Expand All @@ -49,32 +49,32 @@ export class AccreditationController {
.custom((value) => typeof value === 'string' || (Array.isArray(value) && typeof value[0] === 'string'))
.withMessage('schema type must be a string'),
body('parentAccreditation').optional().isString().withMessage('parentAccreditation must be a string').bail(),
body('rootAuthorization').optional().isString().withMessage('rootAuthorization must be a string').bail(),
body('rootAuthorisation').optional().isString().withMessage('rootAuthorisation must be a string').bail(),
body('trustFramework').optional().isString().withMessage('trustFramework must be a string').bail(),
body('trustFrameworkId').optional().isString().withMessage('trustFrameworkId must be a string').bail(),
query('accreditationType')
.custom((value, { req }) => {
const { parentAccreditation, rootAuthorization, trustFramework, trustFrameworkId } = req.body;
const { parentAccreditation, rootAuthorisation, trustFramework, trustFrameworkId } = req.body;

const hasParentOrRoot = parentAccreditation || rootAuthorization;
const hasParentOrRoot = parentAccreditation || rootAuthorisation;

if (
!hasParentOrRoot &&
(value === AccreditationRequestType.accredit || value === AccreditationRequestType.attest)
) {
throw new Error('parentAccreditation or rootAuthorization is required');
throw new Error('parentAccreditation or rootAuthorisation is required');
}

if (hasParentOrRoot && value === AccreditationRequestType.authorize) {
if (hasParentOrRoot && value === AccreditationRequestType.authorise) {
throw new Error(
'parentAccreditation or rootAuthorization is not required for an authorize operation'
'parentAccreditation or rootAuthorisation is not required for an authorise operation'
);
}

const hasTrustFramework = trustFramework && trustFrameworkId;

if (!hasTrustFramework && value === AccreditationRequestType.authorize) {
throw new Error('trustFramework and trustFrameworkId are required for an authorize operation');
if (!hasTrustFramework && value === AccreditationRequestType.authorise) {
throw new Error('trustFramework and trustFrameworkId are required for an authorise operation');
}

return true;
Expand Down Expand Up @@ -149,7 +149,7 @@ export class AccreditationController {
* schema:
* type: string
* enum:
* - authorize
* - authorise
* - accredit
* - attest
* required: true
Expand Down Expand Up @@ -196,7 +196,7 @@ export class AccreditationController {
schemas,
type,
parentAccreditation,
rootAuthorization,
rootAuthorisation,
trustFramework,
trustFrameworkId,
attributes,
Expand Down Expand Up @@ -259,7 +259,7 @@ export class AccreditationController {

let resourceType: string;
switch (accreditationType) {
case AccreditationRequestType.authorize:
case AccreditationRequestType.authorise:
resourceType = DIDAccreditationTypes.VerifiableAuthorisationForTrustChain;
credentialRequest.type = [...(type || []), resourceType];
credentialRequest.termsOfUse = {
Expand All @@ -274,7 +274,7 @@ export class AccreditationController {
credentialRequest.termsOfUse = {
type: resourceType,
parentAccreditation,
rootAuthorization,
rootAuthorisation,
};
break;
case AccreditationRequestType.attest:
Expand All @@ -283,7 +283,7 @@ export class AccreditationController {
credentialRequest.termsOfUse = {
type: resourceType,
parentAccreditation,
rootAuthorization,
rootAuthorisation,
};
break;
}
Expand All @@ -300,7 +300,7 @@ export class AccreditationController {
true,
false,
response.locals.customer,
rootAuthorization
rootAuthorisation
);

if (result.success === false) {
Expand Down
14 changes: 7 additions & 7 deletions src/services/api/accreditation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class AccreditationService {
verifyStatus: boolean,
allowDeactivatedDid: boolean,
customer: CustomerEntity,
rootAuthorization?: string,
rootAuthorisation?: string,
policies?: VerificationPolicies
): Promise<SafeAPIResponse<{ verified: boolean }>> {
// Get strategy e.g. postgres or local
Expand Down Expand Up @@ -96,7 +96,7 @@ export class AccreditationService {
);

if (!initialVerifyResult) {
initialVerifyResult = { ...verifyResult, rootAuthorization };
initialVerifyResult = { ...verifyResult, rootAuthorisation };
}

if (verifyResult.error) {
Expand Down Expand Up @@ -134,12 +134,12 @@ export class AccreditationService {
isTypeAccreditation === DIDAccreditationTypes.VerifiableAccreditationToAttest
) {
const termsOfUse = accreditation.termsOfUse;
if (!termsOfUse || !termsOfUse.parentAccreditation || !termsOfUse.rootAuthorization) {
if (!termsOfUse || !termsOfUse.parentAccreditation || !termsOfUse.rootAuthorisation) {
return {
success: false,
status: StatusCodes.BAD_REQUEST,
data: initialVerifyResult,
error: `Error on verifying accreditation ${accreditationUrl}: Missing parentAccreditaiton and rootAuthorization in termsOfUse for accreditation: ${accreditationUrl}`,
error: `Error on verifying accreditation ${accreditationUrl}: Missing parentAccreditaiton and rootAuthorisation in termsOfUse for accreditation: ${accreditationUrl}`,
};
}

Expand All @@ -150,16 +150,16 @@ export class AccreditationService {
accreditedSubject = accreditorDid;
accreditedFor = accreditation.credentialSubject.accreditedFor;

if (rootAuthorization && rootAuthorization !== termsOfUse.rootAuthorization) {
if (rootAuthorisation && rootAuthorisation !== termsOfUse.rootAuthorisation) {
return {
status: StatusCodes.OK,
success: false,
data: initialVerifyResult,
error: `Error on verifying accreditation ${accreditationUrl}: Expected accreditation to be linked to root accreditation ${rootAuthorization}, but found it linked to DID ${termsOfUse.rootAuthorization} instead`,
error: `Error on verifying accreditation ${accreditationUrl}: Expected accreditation to be linked to root accreditation ${rootAuthorisation}, but found it linked to DID ${termsOfUse.rootAuthorisation} instead`,
};
}

rootAuthorization = termsOfUse.rootAuthorization;
rootAuthorisation = termsOfUse.rootAuthorisation;
} else {
return {
status: StatusCodes.OK,
Expand Down
12 changes: 6 additions & 6 deletions src/static/swagger-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -557,16 +557,16 @@
"description": "DID URL of the parent Verifiable Accreditation, required for accredit/attest operation.",
"type": "string"
},
"rootAuthorization": {
"rootAuthorisation": {
"description": "DID URL of the root Verifiable Accreditation, required for accredit/attest operation.",
"type": "string"
},
"trustFramework": {
"description": "Name or Type of the Trust Framework, required for authorize operation.",
"description": "Name or Type of the Trust Framework, required for authorise operation.",
"type": "string"
},
"trustFrameworkId": {
"description": "Url of the Trust Framework, required for authorize operation.",
"description": "Url of the Trust Framework, required for authorise operation.",
"type": "string"
},
"type": {
Expand Down Expand Up @@ -702,11 +702,11 @@
}
],
"format": "jwt",
"accreditationName": "authorizeAccreditation",
"accreditationName": "authoriseAccreditation",
"trustFramework": "https://learn.cheqd.io/governance/start",
"trustFrameworkId": "cheqd Governance Framework",
"parentAccreditation": "did:cheqd:testnet:15b74787-6e48-4fd5-8020-eab24e990578?resourceName=accreditAccreditation&resourceType=VerifiableAccreditationToAccredit",
"rootAuthorization": "did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain",
"rootAuthorisation": "did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authoriseAccreditation&resourceType=VerifiableAuthorisationForTrustChain",
"credentialStatus": {
"statusPurpose": "revocation",
"statusListName": "employee-credentials",
Expand Down Expand Up @@ -2517,7 +2517,7 @@
"schema": {
"type": "string",
"enum": [
"authorize",
"authorise",
"accredit",
"attest"
]
Expand Down
6 changes: 3 additions & 3 deletions src/types/accreditation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export enum DIDAccreditationTypes {
}

export enum AccreditationRequestType {
authorize = 'authorize',
authorise = 'authorise',
accredit = 'accredit',
attest = 'attest',
}
Expand All @@ -40,14 +40,14 @@ export type DIDAccreditationRequestBody = Omit<
accreditationName: string;
attributes?: Record<string, unknown>;
type: string[] | undefined;
rootAuthorization?: string;
rootAuthorisation?: string;
parentAccreditation?: string;
trustFramework?: string;
trustFrameworkId?: string;
};

export type DIDAccreditationRequestParams = {
accreditationType: 'authorize' | 'accredit' | 'attest';
accreditationType: 'authorise' | 'accredit' | 'attest';
};

export interface DIDUrlParams {
Expand Down
10 changes: 5 additions & 5 deletions src/types/swagger-api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,14 @@
* parentAccreditation:
* description: DID URL of the parent Verifiable Accreditation, required for accredit/attest operation.
* type: string
* rootAuthorization:
* rootAuthorisation:
* description: DID URL of the root Verifiable Accreditation, required for accredit/attest operation.
* type: string
* trustFramework:
* description: Name or Type of the Trust Framework, required for authorize operation.
* description: Name or Type of the Trust Framework, required for authorise operation.
* type: string
* trustFrameworkId:
* description: Url of the Trust Framework, required for authorize operation.
* description: Url of the Trust Framework, required for authorise operation.
* type: string
* type:
* description: Optional properties to be included in the `type` property of the Accreditation.
Expand Down Expand Up @@ -466,11 +466,11 @@
* - type: MuseumPassCredential
* url: https://resolver.cheqd.net/1.0/identifiers/did:cheqd:testnet:0a5b94d0-a417-48ed-a6f5-4abc9e95888d?resourceName=MuseumPassCredentialSchema&resourceType=JsonSchemaValidator2018
* format: jwt
* accreditationName: authorizeAccreditation
* accreditationName: authoriseAccreditation
* trustFramework: https://learn.cheqd.io/governance/start
* trustFrameworkId: cheqd Governance Framework
* parentAccreditation: did:cheqd:testnet:15b74787-6e48-4fd5-8020-eab24e990578?resourceName=accreditAccreditation&resourceType=VerifiableAccreditationToAccredit
* rootAuthorization: did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain
* rootAuthorisation: did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authoriseAccreditation&resourceType=VerifiableAuthorisationForTrustChain
* credentialStatus:
* statusPurpose: revocation
* statusListName: employee-credentials
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/parallel/accreditation/negative-flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CONTENT_TYPE, PAYLOADS_PATH } from '../../constants';
test.use({ storageState: 'playwright/.auth/user.json' });

test(' Issue accreditation [Negative]: Missing query parameters', async ({ request }) => {
const credentialData = JSON.parse(fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/authorize-jwt.json`, 'utf-8'));
const credentialData = JSON.parse(fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/authorise-jwt.json`, 'utf-8'));
const issueResponse = await request.post(`/trust-registry/accreditation/issue`, {
data: JSON.stringify(credentialData),
headers: {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/payloads/accreditation/accredit-jwt.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"format": "jwt",
"accreditationName": "accreditAccreditation",
"parentAccreditation": "did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain",
"rootAuthorization": "did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain"
"rootAuthorisation": "did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain"
}
2 changes: 1 addition & 1 deletion tests/e2e/payloads/accreditation/attest-jwt.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"format": "jwt",
"accreditationName": "attestAccreditation",
"parentAccreditation": "did:cheqd:testnet:15b74787-6e48-4fd5-8020-eab24e990578?resourceName=accreditAccreditation&resourceType=VerifiableAccreditationToAccredit",
"rootAuthorization": "did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain"
"rootAuthorisation": "did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain"
}
2 changes: 1 addition & 1 deletion tests/e2e/payloads/accreditation/child-accredit-jwt.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"format": "jwt",
"accreditationName": "accreditAccreditation",
"parentAccreditation": "did:cheqd:testnet:15b74787-6e48-4fd5-8020-eab24e990578?resourceName=accreditAccreditation&resourceType=VerifiableAccreditationToAccredit",
"rootAuthorization": "did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain"
"rootAuthorisation": "did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"format": "jwt",
"accreditationName": "childAccreditAccreditation",
"parentAccreditation": "did:cheqd:testnet:15b74787-6e48-4fd5-8020-eab24e990578?resourceName=accreditAccreditation&resourceType=VerifiableAccreditationToAccredit",
"rootAuthorization": "did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain"
"rootAuthorisation": "did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=authorizeAccreditation&resourceType=VerifiableAuthorisationForTrustChain"
}
6 changes: 3 additions & 3 deletions tests/e2e/sequential/accreditation/issue-verify-flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { CONTENT_TYPE, PAYLOADS_PATH } from '../../constants';

test.use({ storageState: 'playwright/.auth/user.json' });

test(' Issue and verify a authorize accreditation', async ({ request }) => {
const credentialData = JSON.parse(fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/authorize-jwt.json`, 'utf-8'));
const issueResponse = await request.post(`/trust-registry/accreditation/issue?accreditationType=authorize`, {
test(' Issue and verify a authorise accreditation', async ({ request }) => {
const credentialData = JSON.parse(fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/authorise-jwt.json`, 'utf-8'));
const issueResponse = await request.post(`/trust-registry/accreditation/issue?accreditationType=authorise`, {
data: JSON.stringify(credentialData),
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/sequential/accreditation/revocation-flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const didUrl: string = `did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=re
const subjectDid: string = 'did:cheqd:testnet:15b74787-6e48-4fd5-8020-eab24e990578';
test(' Issue an Accreditation with revocation statuslist', async ({ request }) => {
const payload = JSON.parse(
fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/authorize-jwt-revocation.json`, 'utf-8')
fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/authorise-jwt-revocation.json`, 'utf-8')
);
const issueResponse = await request.post(`/trust-registry/accreditation/issue?accreditationType=authorize`, {
const issueResponse = await request.post(`/trust-registry/accreditation/issue?accreditationType=authorise`, {
data: JSON.stringify(payload),
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/sequential/accreditation/suspension-flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const subjectDid: string = 'did:cheqd:testnet:15b74787-6e48-4fd5-8020-eab24e9905

test(' Issue a jwt accreditation with suspension statuslist', async ({ request }) => {
const payload = JSON.parse(
fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/authorize-jwt-revocation.json`, 'utf-8')
fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/authorise-jwt-revocation.json`, 'utf-8')
);
payload.credentialStatus.statusPurpose = 'suspension';
payload.accreditationName = 'suspensionAccreditation';
const issueResponse = await request.post(`/trust-registry/accreditation/issue?accreditationType=authorize`, {
const issueResponse = await request.post(`/trust-registry/accreditation/issue?accreditationType=authorise`, {
data: JSON.stringify(payload),
headers: {
'Content-Type': CONTENT_TYPE.APPLICATION_JSON,
Expand Down

0 comments on commit a5100dc

Please sign in to comment.