constants.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * @copyright
  3. * Copyright © Microsoft Open Technologies, Inc.
  4. *
  5. * All Rights Reserved
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http: *www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
  14. * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
  15. * ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A
  16. * PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT.
  17. *
  18. * See the Apache License, Version 2.0 for the specific language
  19. * governing permissions and limitations under the License.
  20. */
  21. 'use strict';
  22. var Constants = {
  23. OAuth2 : {
  24. Parameters : {
  25. GRANT_TYPE : 'grant_type',
  26. CLIENT_ASSERTION : 'client_assertion',
  27. CLIENT_ASSERTION_TYPE : 'client_assertion_type',
  28. CLIENT_ID : 'client_id',
  29. CLIENT_SECRET : 'client_secret',
  30. REDIRECT_URI : 'redirect_uri',
  31. RESOURCE : 'resource',
  32. CODE : 'code',
  33. SCOPE : 'scope',
  34. ASSERTION : 'assertion',
  35. AAD_API_VERSION : 'api-version',
  36. USERNAME : 'username',
  37. PASSWORD : 'password',
  38. REFRESH_TOKEN : 'refresh_token',
  39. LANGUAGE : 'mkt',
  40. DEVICE_CODE : 'device_code',
  41. },
  42. GrantType : {
  43. AUTHORIZATION_CODE : 'authorization_code',
  44. REFRESH_TOKEN : 'refresh_token',
  45. CLIENT_CREDENTIALS : 'client_credentials',
  46. JWT_BEARER : 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
  47. PASSWORD : 'password',
  48. SAML1 : 'urn:ietf:params:oauth:grant-type:saml1_1-bearer',
  49. SAML2 : 'urn:ietf:params:oauth:grant-type:saml2-bearer',
  50. DEVICE_CODE: 'device_code'
  51. },
  52. ResponseParameters : {
  53. CODE : 'code',
  54. TOKEN_TYPE : 'token_type',
  55. ACCESS_TOKEN : 'access_token',
  56. ID_TOKEN : 'id_token',
  57. REFRESH_TOKEN : 'refresh_token',
  58. CREATED_ON : 'created_on',
  59. EXPIRES_ON : 'expires_on',
  60. EXPIRES_IN : 'expires_in',
  61. RESOURCE : 'resource',
  62. ERROR : 'error',
  63. ERROR_DESCRIPTION : 'error_description'
  64. },
  65. DeviceCodeResponseParameters : {
  66. USER_CODE : 'user_code',
  67. DEVICE_CODE : 'device_code',
  68. VERIFICATION_URL : 'verification_url',
  69. EXPIRES_IN : 'expires_in',
  70. INTERVAL: 'interval',
  71. MESSAGE: 'message',
  72. ERROR: 'error',
  73. ERROR_DESCRIPTION: 'error_description'
  74. },
  75. Scope : {
  76. OPENID : 'openid'
  77. },
  78. IdTokenMap : {
  79. 'tid' : 'tenantId',
  80. 'given_name' : 'givenName',
  81. 'family_name' : 'familyName',
  82. 'idp' : 'identityProvider',
  83. 'oid': 'oid'
  84. }
  85. },
  86. TokenResponseFields : {
  87. TOKEN_TYPE : 'tokenType',
  88. ACCESS_TOKEN : 'accessToken',
  89. REFRESH_TOKEN : 'refreshToken',
  90. CREATED_ON : 'createdOn',
  91. EXPIRES_ON : 'expiresOn',
  92. EXPIRES_IN : 'expiresIn',
  93. RESOURCE : 'resource',
  94. USER_ID : 'userId',
  95. ERROR : 'error',
  96. ERROR_DESCRIPTION : 'errorDescription'
  97. },
  98. UserCodeResponseFields : {
  99. USER_CODE : 'userCode',
  100. DEVICE_CODE: 'deviceCode',
  101. VERIFICATION_URL: 'verificationUrl',
  102. EXPIRES_IN: 'expiresIn',
  103. INTERVAL: 'interval',
  104. MESSAGE: 'message',
  105. ERROR: 'error',
  106. ERROR_DESCRIPTION: 'errorDescription'
  107. },
  108. IdTokenFields : {
  109. USER_ID : 'userId',
  110. IS_USER_ID_DISPLAYABLE : 'isUserIdDisplayable',
  111. TENANT_ID : 'tenantId',
  112. GIVE_NAME : 'givenName',
  113. FAMILY_NAME : 'familyName',
  114. IDENTITY_PROVIDER : 'identityProvider'
  115. },
  116. Misc : {
  117. MAX_DATE : 0xffffffff,
  118. CLOCK_BUFFER : 5 // In minutes.
  119. },
  120. Jwt : {
  121. SELF_SIGNED_JWT_LIFETIME : 10, // 10 mins in mins
  122. AUDIENCE : 'aud',
  123. ISSUER : 'iss',
  124. SUBJECT : 'sub',
  125. NOT_BEFORE : 'nbf',
  126. EXPIRES_ON : 'exp',
  127. JWT_ID : 'jti'
  128. },
  129. AADConstants : {
  130. WORLD_WIDE_AUTHORITY : 'login.windows.net',
  131. WELL_KNOWN_AUTHORITY_HOSTS : ['login.windows.net', 'login.microsoftonline.com', 'login.chinacloudapi.cn', 'login-us.microsoftonline.com', 'login.microsoftonline.de', 'login.microsoftonline.us'],
  132. INSTANCE_DISCOVERY_ENDPOINT_TEMPLATE : 'https://{authorize_host}/common/discovery/instance?authorization_endpoint={authorize_endpoint}&api-version=1.0',
  133. AUTHORIZE_ENDPOINT_PATH : '/oauth2/authorize',
  134. TOKEN_ENDPOINT_PATH : '/oauth2/token',
  135. DEVICE_ENDPOINT_PATH : '/oauth2/devicecode'
  136. },
  137. UserRealm : {
  138. FederationProtocolType : {
  139. WSFederation : 'wstrust',
  140. SAML2 : 'saml20',
  141. Unknown : 'unknown'
  142. },
  143. AccountType : {
  144. Federated : 'federated',
  145. Managed : 'managed',
  146. Unknown : 'unknown'
  147. }
  148. },
  149. Saml : {
  150. TokenTypeV1 : 'urn:oasis:names:tc:SAML:1.0:assertion',
  151. TokenTypeV2 : 'urn:oasis:names:tc:SAML:2.0:assertion'
  152. },
  153. XmlNamespaces : {
  154. wsdl : 'http://schemas.xmlsoap.org/wsdl/',
  155. sp : 'http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702',
  156. sp2005 : 'http://schemas.xmlsoap.org/ws/2005/07/securitypolicy',
  157. wsu : 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd',
  158. wsa10 : 'http://www.w3.org/2005/08/addressing',
  159. http : 'http://schemas.microsoft.com/ws/06/2004/policy/http',
  160. soap12 : 'http://schemas.xmlsoap.org/wsdl/soap12/',
  161. wsp : 'http://schemas.xmlsoap.org/ws/2004/09/policy',
  162. s : 'http://www.w3.org/2003/05/soap-envelope',
  163. wsa : 'http://www.w3.org/2005/08/addressing',
  164. wst : 'http://docs.oasis-open.org/ws-sx/ws-trust/200512',
  165. t : 'http://schemas.xmlsoap.org/ws/2005/02/trust'
  166. },
  167. Cache : {
  168. HASH_ALGORITHM : 'sha256'
  169. },
  170. HttpError : {
  171. UNAUTHORIZED : 401
  172. },
  173. AdalIdParameters : {
  174. SKU : 'x-client-SKU',
  175. VERSION : 'x-client-Ver',
  176. OS : 'x-client-OS',
  177. CPU : 'x-client-CPU',
  178. NODE_SKU : 'Node'
  179. },
  180. WSTrustVersion : {
  181. UNDEFINED : 'undefined',
  182. WSTRUST13 : 'wstrust13',
  183. WSTRUST2005 : 'wstrust2005'
  184. }
  185. };
  186. module.exports = Constants;