{
  "lexicon": 1,
  "id": "org.tangled.temp.account.completeSignup",
  "defs": {
    "main": {
      "type": "procedure",
      "description": "Complete signup with the link token, choosing a username and password. Deliberi provisions the PDS account internally using a pre-minted invite code.",
      "input": {
        "encoding": "application/json",
        "schema": {
          "type": "object",
          "required": ["token", "username", "password"],
          "properties": {
            "token": {
              "type": "string",
              "description": "Verification token from the emailed link."
            },
            "username": {
              "type": "string",
              "description": "Desired username; the handle is <username>.<pds domain>."
            },
            "password": {
              "type": "string",
              "description": "Password for the new account."
            },
            "requestUri": {
              "type": "string",
              "description": "request_uri of the browser's pushed OAuth authorization request at the PDS. When the PDS supports it, the new account authorizes that request without the PDS sign-in and consent screens."
            }
          }
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "type": "object",
          "required": ["did", "handle"],
          "properties": {
            "did": {
              "type": "string",
              "format": "did",
              "description": "DID of the newly provisioned account."
            },
            "handle": {
              "type": "string",
              "description": "The assigned handle, <username>.<pds domain>."
            },
            "authorization": {
              "type": "ref",
              "ref": "#authorization",
              "description": "Present when the PDS authorized requestUri for the new account. Without it the browser signs in through the PDS."
            }
          }
        }
      },
      "errors": [
        { "name": "SignupDisabled", "description": "Signup is not currently enabled on this service." },
        { "name": "InvalidCode", "description": "The verification link is invalid or expired." },
        { "name": "InvalidUsername", "description": "The username is invalid or not allowed." },
        { "name": "UsernameNotAvailable", "description": "The username is already taken." },
        { "name": "InvalidPassword", "description": "The password is not allowed." },
        { "name": "EmailAlreadyRegistered", "description": "An account already exists for this email." }
      ]
    },
    "authorization": {
      "type": "object",
      "description": "The OAuth authorization response for requestUri, as the PDS would have put it in the redirect.",
      "required": ["code", "state", "iss"],
      "properties": {
        "code": { "type": "string" },
        "state": { "type": "string" },
        "iss": { "type": "string" }
      }
    }
  }
}
