Skip to content

Commit

Permalink
Merge pull request #84 from decentralized-identity/peacekeeper-impl-r…
Browse files Browse the repository at this point in the history
…esources

Implement support for DID URLs
  • Loading branch information
peacekeeper authored Nov 24, 2024
2 parents 65e3bd2 + 651280d commit b5da097
Show file tree
Hide file tree
Showing 22 changed files with 1,811 additions and 93 deletions.
366 changes: 362 additions & 4 deletions driver-http/src/main/java/uniregistrar/driver/http/HttpDriver.java

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions driver/src/main/java/uniregistrar/driver/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public interface Driver {
public UpdateState update(UpdateRequest updateRequest) throws RegistrationException;
public DeactivateState deactivate(DeactivateRequest deactivateRequest) throws RegistrationException;
public ExecuteState execute(ExecuteRequest executeRequest) throws RegistrationException;
public CreateResourceState createResource(CreateResourceRequest createResourceRequest) throws RegistrationException;
public UpdateResourceState updateResource(UpdateResourceRequest updateResourceRequest) throws RegistrationException;
public DeactivateResourceState deactivateResource(DeactivateResourceRequest deactivateResourceRequest) throws RegistrationException;

default public Map<String, Object> properties() throws RegistrationException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uniregistrar.RegistrationException;
import uniregistrar.openapi.model.CreateState;
import uniregistrar.openapi.model.DidStateFailed;
import uniregistrar.openapi.model.DidStateFinished;
import uniregistrar.openapi.model.RegistrarState;
import uniregistrar.openapi.model.*;
import uniregistrar.util.HttpBindingUtil;

import java.io.IOException;
Expand Down Expand Up @@ -41,4 +38,23 @@ else if (RegistrationException.ERROR_BADREQUEST.equals(didStateFailed.getError()
return HttpStatus.SC_OK;
}
}

public static int httpStatusCodeForState(RegistrarResourceState state) {
if (state.getDidUrlState() instanceof DidUrlStateFailed didUrlStateFailed) {
if (RegistrationException.ERROR_NOTFOUND.equals(didUrlStateFailed.getError()))
return HttpStatus.SC_NOT_FOUND;
else if (RegistrationException.ERROR_BADREQUEST.equals(didUrlStateFailed.getError()))
return HttpStatus.SC_BAD_REQUEST;
else
return HttpStatus.SC_INTERNAL_SERVER_ERROR;
} else if (state.getDidUrlState() instanceof DidUrlStateFinished) {
if (state instanceof CreateResourceState) {
return HttpStatus.SC_CREATED;
} else {
return HttpStatus.SC_OK;
}
} else {
return HttpStatus.SC_OK;
}
}
}
98 changes: 76 additions & 22 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ components:
DID URL create operation.
type: string
example: /resources/123
data:
content:
description: This input field contains Base64-encoded data that is the content of the
resource associated with the DID URL.
type: string
Expand Down Expand Up @@ -522,7 +522,7 @@ components:
type: string
example:
- setResource
data:
content:
description: This input field contains Base64-encoded data that is the content of the
resource associated with the DID URL.
type: array
Expand Down Expand Up @@ -596,17 +596,17 @@ components:
description: The state after a DID URL operation.
type: object
required:
- didState
- didUrlState
properties:
jobId:
type: string
example: 6d85bcd0-2ea3-4288-ab00-15afadd8a156
didState:
$ref: "#/components/schemas/DidState"
didUrlState:
$ref: "#/components/schemas/DidUrlState"
didRegistrationMetadata:
type: object
additionalProperties: { }
resourceMetadata:
contentMetadata:
type: object
additionalProperties: { }
CreateState:
Expand Down Expand Up @@ -676,36 +676,87 @@ components:
didDocument:
$ref: "#/components/schemas/DidDocument"
additionalProperties: { }
DidUrlState:
description: The current state of a DID URL and associated resource.
type: object
required:
- state
discriminator:
propertyName: state
mapping:
finished: "#/components/schemas/DidUrlStateFinished"
failed: "#/components/schemas/DidUrlStateFailed"
action: "#/components/schemas/DidUrlStateAction"
wait: "#/components/schemas/DidUrlStateWait"
properties:
state:
$ref: "#/components/schemas/String"
example: finished
didUrl:
$ref: "#/components/schemas/String"
example: did:indy:sovrin:WRfXPg8dantKVubE3HX8pw
secret:
$ref: "#/components/schemas/DidStateSecret"
content:
$ref: "#/components/schemas/String"
additionalProperties: { }
DidStateFinished:
allOf:
- $ref: "#/components/schemas/DidState"
- $ref: "#/components/schemas/StateFinished"
DidStateFailed:
allOf:
- $ref: "#/components/schemas/DidState"
- $ref: "#/components/schemas/StateFailed"
DidStateAction:
allOf:
- $ref: "#/components/schemas/DidState"
- $ref: "#/components/schemas/StateAction"
DidStateWait:
allOf:
- $ref: "#/components/schemas/DidState"
- $ref: "#/components/schemas/StateWait"
DidUrlStateFinished:
allOf:
- $ref: "#/components/schemas/DidUrlState"
- $ref: "#/components/schemas/StateFinished"
DidUrlStateFailed:
allOf:
- $ref: "#/components/schemas/DidUrlState"
- $ref: "#/components/schemas/StateFailed"
DidUrlStateAction:
allOf:
- $ref: "#/components/schemas/DidUrlState"
- $ref: "#/components/schemas/StateAction"
DidUrlStateWait:
allOf:
- $ref: "#/components/schemas/DidUrlState"
- $ref: "#/components/schemas/StateWait"
StateFinished:
description: This state indicates that the DID operation has been completed. See
https://identity.foundation/did-registration/#didstatestatefinished.
allOf:
- $ref: "#/components/schemas/DidState"
- type: object
DidStateFailed:
StateFailed:
description: This state indicates that the DID operation has failed. See
https://identity.foundation/did-registration/#didstatestatefailed.
allOf:
- $ref: "#/components/schemas/DidState"
- type: object
properties:
error:
type: string
$ref: "#/components/schemas/String"
reason:
type: string
DidStateAction:
$ref: "#/components/schemas/String"
StateAction:
description: This state indicates that the client needs to perform an action, before the DID operation can be continued. See
https://identity.foundation/did-registration/#didstatestateaction.
allOf:
- $ref: "#/components/schemas/DidState"
- type: object
properties:
action:
type: string
$ref: "#/components/schemas/String"
verificationMethodTemplate:
type: array
items:
$ref: "#/components/schemas/VerificationMethodTemplate"
$ref: "#/components/schemas/StateActionVerificationMethodTemplate"
signingRequest:
type: [object, null]
additionalProperties:
Expand All @@ -714,17 +765,20 @@ components:
type: [object, null]
additionalProperties:
$ref: "#/components/schemas/DecryptionRequest"
DidStateWait:
StateActionVerificationMethodTemplate:
type: array
items:
$ref: "#/components/schemas/VerificationMethodTemplate"
StateWait:
description: This state indicates that the client needs to wait, before the DID operation can be continued.
See https://identity.foundation/did-registration/#didstatestatewait.
allOf:
- $ref: "#/components/schemas/DidState"
- type: object
properties:
wait:
type: string
$ref: "#/components/schemas/String"
waittime:
type: string
$ref: "#/components/schemas/String"
Secret:
description: Secrets in requests and states.
type: object
Expand All @@ -751,7 +805,7 @@ components:
SecretVerificationMethodVerificationMethodTemplate:
type: array
items:
$ref: "#/components/schemas/VerificationMethodTemplate"
$ref: "#/components/schemas/VerificationMethodTemplate"
RequestSecret:
description: This input field contains an object with DID controller keys
and other secrets needed for performing the DID operation. See
Expand Down
Loading

0 comments on commit b5da097

Please sign in to comment.