All files / src/schemas ClientSchema.js

100% Statements 3/3
100% Branches 0/0
100% Functions 0/0
100% Lines 3/3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284          1x         1x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1x  
'use strict'
 
/**
 * Dependencies
 */
const {JSONSchema} = require('@trust/json-document')
 
/**
 * OpenID Client Metadata (Relying Party) Schema
 */
const schema = new JSONSchema({
  type: 'object',
  properties: {
    client_id: {
      type: 'string'
    },
 
    client_secret: {
      type: 'string'
    },
 
    redirect_uris: {
      type: 'array',
      items: {
        format: 'uri'
      }
    },
 
    response_types: {
      type: 'array',
      default: ['code'],
      items: {
        type: 'string',
        enum: [
          'code',
          'code token',
          'code id_token',
          'id_token',
          'id_token token',
          'code id_token token',
          'none'
        ]
      }
    },
 
    /**
     * TODO
     *
     * The following table lists the correspondence between response_type values
     * that the Client will use and grant_type values that MUST be included in
     * the registered grant_types list:
     *
     * code: authorization_code
     * id_token: implicit
     * token id_token: implicit
     * code id_token: authorization_code, implicit
     * code token: authorization_code, implicit
     * code token id_token: authorization_code, implicit
     */
    grant_types: {
      type: 'array',
      default: ['authorization_code'],
      items: {
        type: 'string',
        enum: [
          'authorization_code',
          'implicit',
          'refresh_token',
          'client_credentials'
        ]
      }
    },
 
    /**
     * application_type
     * OPTIONAL. Kind of the application. The default, if omitted, is web. The
     * defined values are native or web. Web Clients using the OAuth Implicit
     * Grant Type MUST only register URLs using the https scheme as
     * redirect_uris; they MUST NOT use localhost as the hostname. Native
     * Clients MUST only register redirect_uris using custom URI schemes or URLs
     * using the http: scheme with localhost as the hostname. Authorization
     * Servers MAY place additional constraints on Native Clients. Authorization
     * Servers MAY reject Redirection URI values using the http scheme, other
     * than the localhost case for Native Clients. The Authorization Server MUST
     * verify that all the registered redirect_uris conform to these
     * constraints. This prevents sharing a Client ID across different types of
     * Clients.
     */
    application_type: {
      type: 'string',
      default: 'web',
      enum: [
        'native',
        'web'
      ]
    },
 
    contacts: {
      type: 'array',
      items: {
        format: 'email'
      }
    },
 
    /**
     * TODO
     *
     * Internationalization. See JSON Schema Validation (Section 3.3)
     */
    client_name: {
      type: 'string'
    },
 
    logo_uri: {
      type: 'string',
      format: 'uri'
    },
 
    client_uri: {
      type: 'string',
      format: 'uri'
    },
 
    policy_uri: {
      type: 'string',
      format: 'uri'
    },
 
    tos_uri: {
      type: 'string',
      format: 'uri'
    },
 
    jwks_uri: {
      type: 'string',
      format: 'uri'
    },
 
    /**
     * TODO
     *
     * Reference JWK Set Schema
     */
    jwks: {
      type: 'object'
    },
 
    sector_identifier_uri: {
      type: 'string',
      format: 'uri'
    },
 
    subject_type: {
      type: 'string',
      enum: [
        'pairwise',
        'public'
      ]
    },
 
    id_token_signed_response_alg: {
      type: 'string',
      default: 'RS256',
      enum: [
        'RS256',
        'RS384',
        'RS512'
      ]
    },
 
    id_token_encrypted_response_alg: {
      type: 'string'
    },
 
    id_token_encrypted_response_enc: {
      type: 'string'
    },
 
    userinfo_signed_response_alg: {
      type: 'string'
    },
 
    userinfo_encrypted_response_alg: {
      type: 'string'
    },
 
    userinfo_encrypted_response_enc: {
      type: 'string'
    },
 
    request_object_signing_alg: {
      type: 'string'
    },
 
    request_object_encryption_alg: {
      type: 'string'
    },
 
    request_object_encryption_enc: {
      type: 'string'
    },
 
    token_endpoint_auth_method: {
      type: 'string',
      enum: [
        'client_secret_basic',
        'client_secret_post',
        'client_secret_jwt',
        'private_key_jwt',
        'none'
      ],
      default: 'client_secret_basic'
    },
 
    token_endpoint_auth_signing_alg: {
      type: 'string'
    },
 
    default_max_age: {
      type: 'number'
    },
 
    require_auth_time: {
      type: 'boolean'
    },
 
    default_acr_values: {
      type: 'array'
    },
 
    initiate_login_uri: {
      type: 'string',
      format: 'uri'
    },
 
    request_uris: {
      type: 'array',
      items: {
        format: 'uri'
      }
    },
 
    post_logout_redirect_uris: {
      type: 'array',
      items: {
        format: 'uri'
      }
    },
 
    /**
     * frontchannel_logout_uri
     *
     * OPTIONAL. RP URL that will cause the RP to log itself out when rendered
     * in an iframe by the OP.
     *
     * @see https://openid.net/specs/openid-connect-frontchannel-1_0.html#RPLogout
     */
    frontchannel_logout_uri: {
      type: 'string',
      format: 'uri'
    },
 
    /**
     * frontchannel_logout_session_required
     *
     * OPTIONAL. Boolean value specifying whether the RP requires that `iss`
     * (issuer) and `sid` (session ID) query parameters be included to identify
     * the RP session with the OP when the `frontchannel_logout_uri` is used.
     *
     * @see https://openid.net/specs/openid-connect-frontchannel-1_0.html#RPLogout
     */
    frontchannel_logout_session_required: {
      type: 'boolean',
      default: false
    }
  },
  required: ['redirect_uris']
})
 
/**
 * Export
 */
module.exports = schema