|
| 1 | +# Copyright 2018 New Vector Ltd |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +swagger: '2.0' |
| 15 | +info: |
| 16 | + title: "Matrix Identity Service Phone Number Associations API" |
| 17 | + version: "1.0.0" |
| 18 | +host: localhost:8090 |
| 19 | +schemes: |
| 20 | + - https |
| 21 | + - http |
| 22 | +basePath: /_matrix/identity/api/v1 |
| 23 | +produces: |
| 24 | + - application/json |
| 25 | +paths: |
| 26 | + "/validate/msisdn/requestToken": |
| 27 | + post: |
| 28 | + summary: Request a token for validating a phone number. |
| 29 | + description: |- |
| 30 | + Create a session for validating a phone number. |
| 31 | +
|
| 32 | + The identity service will send an SMS message containing a token. If |
| 33 | + that token is presented to the identity service in the future, it |
| 34 | + indicates that that user was able to read the SMS for that phone |
| 35 | + number, and so we validate ownership of the phone number. |
| 36 | +
|
| 37 | + Note that Home Servers offer APIs that proxy this API, adding |
| 38 | + additional behaviour on top, for example, |
| 39 | + ``/register/msisdn/requestToken`` is designed specifically for use when |
| 40 | + registering an account and therefore will inform the user if the phone |
| 41 | + number given is already registered on the server. |
| 42 | +
|
| 43 | + Note: for backwards compatibility with older versions of this |
| 44 | + specification, the parameters may also be specified as |
| 45 | + ``application/x-form-www-urlencoded`` data. However, this usage is |
| 46 | + deprecated. |
| 47 | + operationId: msisdnRequestToken |
| 48 | + parameters: |
| 49 | + - in: body |
| 50 | + name: body |
| 51 | + schema: |
| 52 | + type: object |
| 53 | + example: { |
| 54 | + "client_secret": "monkeys_are_GREAT", |
| 55 | + "country": "GB", |
| 56 | + "phone_number": "07700900001", |
| 57 | + "send_attempt": 1 |
| 58 | + } |
| 59 | + properties: |
| 60 | + client_secret: |
| 61 | + type: string |
| 62 | + description: A unique string used to identify the validation attempt. |
| 63 | + country: |
| 64 | + type: string |
| 65 | + description: |- |
| 66 | + The two-letter uppercase ISO country code that the number in |
| 67 | + ``phone_number`` should be parsed as if it were dialled from. |
| 68 | + phone_number: |
| 69 | + type: string |
| 70 | + description: The phone number to validate. |
| 71 | + send_attempt: |
| 72 | + type: integer |
| 73 | + description: |- |
| 74 | + Optional. If specified, the server will only send an SMS if |
| 75 | + the ``send_attempt`` is a number greater than the most recent |
| 76 | + one which it has seen (or if it has never seen one), scoped |
| 77 | + to that ``country`` + ``phone_number`` + ``client_secret`` |
| 78 | + triple. This is to avoid repeatedly sending the same SMS in |
| 79 | + the case of request retries between the POSTing user and the |
| 80 | + identity service. The client should increment this value if |
| 81 | + they desire a new SMS (e.g. a reminder) to be sent. |
| 82 | + next_link: |
| 83 | + type: string |
| 84 | + description: |- |
| 85 | + Optional. When the validation is completed, the identity |
| 86 | + service will redirect the user to this URL. |
| 87 | + required: ["client_secret", "country", "phone_number"] |
| 88 | + responses: |
| 89 | + 200: |
| 90 | + description: |
| 91 | + Session created. |
| 92 | + examples: |
| 93 | + application/json: { |
| 94 | + "sid": "1234" |
| 95 | + } |
| 96 | + schema: |
| 97 | + type: object |
| 98 | + properties: |
| 99 | + sid: |
| 100 | + type: string |
| 101 | + description: The session ID. |
| 102 | + 400: |
| 103 | + description: | |
| 104 | + An error ocurred. Some possible errors are: |
| 105 | +
|
| 106 | + - ``M_INVALID_ADDRESS``: The phone number provided was invalid. |
| 107 | + - ``M_SEND_ERROR``: The validation SMS could not be sent. |
| 108 | + "/validate/msisdn/submitToken": |
| 109 | + post: |
| 110 | + summary: Validate ownership of a phone number. |
| 111 | + description: |- |
| 112 | + Validate ownership of a phone number. |
| 113 | +
|
| 114 | + If the three parameters are consistent with a set generated by a |
| 115 | + ``requestToken`` call, ownership of the phone number is considered to |
| 116 | + have been validated. This does not publish any information publicly, or |
| 117 | + associate the phone number address with any Matrix user |
| 118 | + ID. Specifically, calls to ``/lookup`` will not show a binding. |
| 119 | +
|
| 120 | + Note: for backwards compatibility with older versions of this |
| 121 | + specification, the parameters may also be specified as |
| 122 | + ``application/x-form-www-urlencoded`` data. However, this usage is |
| 123 | + deprecated. |
| 124 | + operationId: msisdnSubmitTokenPost |
| 125 | + parameters: |
| 126 | + - in: body |
| 127 | + name: body |
| 128 | + schema: |
| 129 | + type: object |
| 130 | + example: { |
| 131 | + "sid": "1234", |
| 132 | + "client_secret": "monkeys_are_GREAT", |
| 133 | + "token": "atoken" |
| 134 | + } |
| 135 | + properties: |
| 136 | + sid: |
| 137 | + type: string |
| 138 | + description: The session ID, generated by the ``requestToken`` call. |
| 139 | + client_secret: |
| 140 | + type: string |
| 141 | + description: The client secret that was supplied to the ``requestToken`` call. |
| 142 | + token: |
| 143 | + type: string |
| 144 | + description: The token generated by the ``requestToken`` call and sent to the user. |
| 145 | + required: ["sid", "client_secret", "token"] |
| 146 | + responses: |
| 147 | + 200: |
| 148 | + description: |
| 149 | + The success of the validation. |
| 150 | + examples: |
| 151 | + application/json: { |
| 152 | + "success": true |
| 153 | + } |
| 154 | + schema: |
| 155 | + type: object |
| 156 | + properties: |
| 157 | + success: |
| 158 | + type: boolean |
| 159 | + description: Whether the validation was successful or not. |
| 160 | + get: |
| 161 | + summary: Validate ownership of a phone number. |
| 162 | + description: |- |
| 163 | + Validate ownership of a phone number. |
| 164 | +
|
| 165 | + If the three parameters are consistent with a set generated by a |
| 166 | + ``requestToken`` call, ownership of the phone number address is |
| 167 | + considered to have been validated. This does not publish any |
| 168 | + information publicly, or associate the phone number with any Matrix |
| 169 | + user ID. Specifically, calls to ``/lookup`` will not show a binding. |
| 170 | +
|
| 171 | + Note that, in contrast with the POST version, this endpoint will be |
| 172 | + used by end-users, and so the response should be human-readable. |
| 173 | + operationId: msisdnSubmitTokenGet |
| 174 | + parameters: |
| 175 | + - in: query |
| 176 | + type: string |
| 177 | + name: sid |
| 178 | + required: true |
| 179 | + description: The session ID, generated by the ``requestToken`` call. |
| 180 | + x-example: 1234 |
| 181 | + - in: query |
| 182 | + type: string |
| 183 | + name: client_secret |
| 184 | + required: true |
| 185 | + description: The client secret that was supplied to the ``requestToken`` call. |
| 186 | + x-example: monkeys_are_GREAT |
| 187 | + - in: query |
| 188 | + type: string |
| 189 | + name: token |
| 190 | + required: true |
| 191 | + description: The token generated by the ``requestToken`` call and sent to the user. |
| 192 | + x-example: atoken |
| 193 | + responses: |
| 194 | + "200": |
| 195 | + description: Phone number is validated. |
| 196 | + "3xx": |
| 197 | + description: |- |
| 198 | + Phone number address is validated, and the ``next_link`` parameter |
| 199 | + was provided to the ``requestToken`` call. The user must be |
| 200 | + redirected to the URL provided by the ``next_link`` parameter. |
| 201 | + "4xx": |
| 202 | + description: |
| 203 | + Validation failed. |
0 commit comments