浏览代码

Branch with Beta packages included.

Meant to be a "It Just works" branch for internal use.
/main
当前提交
ebccd32c
共有 865 个文件被更改,包括 3797 次插入90 次删除
  1. 22
      Packages/manifest.json
  2. 55
      Packages/packages-lock.json
  3. 24
      ProjectSettings/PackageManagerSettings.asset
  4. 6
      ProjectSettings/ProjectSettings.asset
  5. 41
      README.md
  6. 242
      Packages/com.unity.services.authentication/.README - External.md
  7. 53
      Packages/com.unity.services.authentication/CHANGELOG.md
  8. 7
      Packages/com.unity.services.authentication/CHANGELOG.md.meta
  9. 5
      Packages/com.unity.services.authentication/Documentation~/com.unity.services.authentication.md
  10. 8
      Packages/com.unity.services.authentication/Editor.meta
  11. 5
      Packages/com.unity.services.authentication/Editor/AssemblyInfo.cs
  12. 3
      Packages/com.unity.services.authentication/Editor/AssemblyInfo.cs.meta
  13. 298
      Packages/com.unity.services.authentication/Editor/AuthenticationAdminClient.cs
  14. 3
      Packages/com.unity.services.authentication/Editor/AuthenticationAdminClient.cs.meta
  15. 148
      Packages/com.unity.services.authentication/Editor/AuthenticationAdminNetworkClient.cs
  16. 11
      Packages/com.unity.services.authentication/Editor/AuthenticationAdminNetworkClient.cs.meta
  17. 17
      Packages/com.unity.services.authentication/Editor/AuthenticationIdentifier.cs
  18. 11
      Packages/com.unity.services.authentication/Editor/AuthenticationIdentifier.cs.meta
  19. 47
      Packages/com.unity.services.authentication/Editor/AuthenticationService.cs
  20. 11
      Packages/com.unity.services.authentication/Editor/AuthenticationService.cs.meta
  21. 292
      Packages/com.unity.services.authentication/Editor/AuthenticationSettingsElement.cs
  22. 3
      Packages/com.unity.services.authentication/Editor/AuthenticationSettingsElement.cs.meta
  23. 47
      Packages/com.unity.services.authentication/Editor/AuthenticationSettingsHelper.cs
  24. 3
      Packages/com.unity.services.authentication/Editor/AuthenticationSettingsHelper.cs.meta
  25. 58
      Packages/com.unity.services.authentication/Editor/AuthenticationSettingsProvider.cs
  26. 11
      Packages/com.unity.services.authentication/Editor/AuthenticationSettingsProvider.cs.meta
  27. 20
      Packages/com.unity.services.authentication/Editor/AuthenticationTopMenu.cs
  28. 11
      Packages/com.unity.services.authentication/Editor/AuthenticationTopMenu.cs.meta
  29. 79
      Packages/com.unity.services.authentication/Editor/IAuthenticationAdminClient.cs
  30. 3
      Packages/com.unity.services.authentication/Editor/IAuthenticationAdminClient.cs.meta
  31. 399
      Packages/com.unity.services.authentication/Editor/IdProviderElement.cs
  32. 3
      Packages/com.unity.services.authentication/Editor/IdProviderElement.cs.meta
  33. 8
      Packages/com.unity.services.authentication/Editor/Models.meta
  34. 49
      Packages/com.unity.services.authentication/Editor/Models/CreateIdProviderRequest.cs
  35. 11
      Packages/com.unity.services.authentication/Editor/Models/CreateIdProviderRequest.cs.meta
  36. 20
      Packages/com.unity.services.authentication/Editor/Models/DeleteIdProviderRequest.cs
  37. 11
      Packages/com.unity.services.authentication/Editor/Models/DeleteIdProviderRequest.cs.meta
  38. 19
      Packages/com.unity.services.authentication/Editor/Models/GetIdDomainResponse.cs
  39. 11
      Packages/com.unity.services.authentication/Editor/Models/GetIdDomainResponse.cs.meta
  40. 56
      Packages/com.unity.services.authentication/Editor/Models/IdProviderResponse.cs
  41. 11
      Packages/com.unity.services.authentication/Editor/Models/IdProviderResponse.cs.meta
  42. 19
      Packages/com.unity.services.authentication/Editor/Models/ListIdProviderResponse.cs
  43. 11
      Packages/com.unity.services.authentication/Editor/Models/ListIdProviderResponse.cs.meta
  44. 29
      Packages/com.unity.services.authentication/Editor/Models/TokenExchangeErrorResponse.cs
  45. 11
      Packages/com.unity.services.authentication/Editor/Models/TokenExchangeErrorResponse.cs.meta
  46. 16
      Packages/com.unity.services.authentication/Editor/Models/TokenExchangeRequest.cs
  47. 11
      Packages/com.unity.services.authentication/Editor/Models/TokenExchangeRequest.cs.meta
  48. 16
      Packages/com.unity.services.authentication/Editor/Models/TokenExchangeResponse.cs
  49. 11
      Packages/com.unity.services.authentication/Editor/Models/TokenExchangeResponse.cs.meta
  50. 44
      Packages/com.unity.services.authentication/Editor/Models/UpdateIdProviderRequest.cs
  51. 11
      Packages/com.unity.services.authentication/Editor/Models/UpdateIdProviderRequest.cs.meta
  52. 3
      Packages/com.unity.services.authentication/Editor/USS.meta
  53. 41
      Packages/com.unity.services.authentication/Editor/USS/AuthenticationStyleSheet.uss
  54. 3
      Packages/com.unity.services.authentication/Editor/USS/AuthenticationStyleSheet.uss.meta
  55. 3
      Packages/com.unity.services.authentication/Editor/UXML.meta
  56. 15
      Packages/com.unity.services.authentication/Editor/UXML/AuthenticationProjectSettings.uxml
  57. 3
      Packages/com.unity.services.authentication/Editor/UXML/AuthenticationProjectSettings.uxml.meta
  58. 12
      Packages/com.unity.services.authentication/Editor/UXML/IdProviderElement.uxml
  59. 3
      Packages/com.unity.services.authentication/Editor/UXML/IdProviderElement.uxml.meta
  60. 10
      Packages/com.unity.services.authentication/Editor/Unity.Services.Authentication.Editor.api
  61. 7
      Packages/com.unity.services.authentication/Editor/Unity.Services.Authentication.Editor.api.meta
  62. 23
      Packages/com.unity.services.authentication/Editor/Unity.Services.Authentication.Editor.asmdef
  63. 7
      Packages/com.unity.services.authentication/Editor/Unity.Services.Authentication.Editor.asmdef.meta
  64. 5
      Packages/com.unity.services.authentication/LICENSE.md
  65. 7
      Packages/com.unity.services.authentication/LICENSE.md.meta
  66. 79
      Packages/com.unity.services.authentication/README.md
  67. 7
      Packages/com.unity.services.authentication/README.md.meta
  68. 8
      Packages/com.unity.services.authentication/Runtime.meta
  69. 127
      Packages/com.unity.services.authentication/Runtime/AuthenticationAsyncOperation.cs
  70. 3
      Packages/com.unity.services.authentication/Runtime/AuthenticationAsyncOperation.cs.meta
  71. 58
      Packages/com.unity.services.authentication/Runtime/AuthenticationError.cs
  72. 3
      Packages/com.unity.services.authentication/Runtime/AuthenticationError.cs.meta
  73. 49
      Packages/com.unity.services.authentication/Runtime/AuthenticationException.cs
  74. 3
      Packages/com.unity.services.authentication/Runtime/AuthenticationException.cs.meta
  75. 209
      Packages/com.unity.services.authentication/Runtime/AuthenticationNetworkClient.cs
  76. 11
      Packages/com.unity.services.authentication/Runtime/AuthenticationNetworkClient.cs.meta
  77. 12
      Packages/com.unity.services.authentication/Runtime/AuthenticationService.cs
  78. 11
      Packages/com.unity.services.authentication/Runtime/AuthenticationService.cs.meta
  79. 645
      Packages/com.unity.services.authentication/Runtime/AuthenticationServiceInternal.cs
  80. 11
      Packages/com.unity.services.authentication/Runtime/AuthenticationServiceInternal.cs.meta
  81. 48
      Packages/com.unity.services.authentication/Runtime/CodeChallengeGenerator.cs
  82. 11
      Packages/com.unity.services.authentication/Runtime/CodeChallengeGenerator.cs.meta
  83. 8
      Packages/com.unity.services.authentication/Runtime/Core.meta
  84. 16
      Packages/com.unity.services.authentication/Runtime/Core/AccessTokenComponent.cs
  85. 3
      Packages/com.unity.services.authentication/Runtime/Core/AccessTokenComponent.cs.meta
  86. 51
      Packages/com.unity.services.authentication/Runtime/Core/AuthenticationPackageInitializer.cs
  87. 11
      Packages/com.unity.services.authentication/Runtime/Core/AuthenticationPackageInitializer.cs.meta
  88. 40
      Packages/com.unity.services.authentication/Runtime/Core/PlayerIdComponent.cs

22
Packages/manifest.json


"com.unity.ide.visualstudio": "2.0.9",
"com.unity.ide.vscode": "1.2.3",
"com.unity.nuget.newtonsoft-json": "2.0.0",
"com.unity.services.authentication": "0.5.0-preview",
"com.unity.services.core": "0.3.0-preview",
"com.unity.services.lobby": "file:../LocalPackage/com.unity.services.lobby",
"com.unity.services.relay": "0.0.1-preview.7",
"com.unity.sysroot.linux-x86_64": "0.1.15-preview",
"com.unity.test-framework": "1.1.26",
"com.unity.textmeshpro": "3.0.6",

"com.unity.modules.vr": "1.0.0",
"com.unity.modules.wind": "1.0.0",
"com.unity.modules.xr": "1.0.0"
},
"scopedRegistries": [
{
"name": "Internal Candidates Registry",
"url": "https://artifactory.prd.it.unity3d.com/artifactory/api/npm/upm-candidates",
"scopes": [
"com.unity.services.relay",
"com.unity.services.core",
"com.unity.toolchain.win-x86_64-linux-x86_64",
"com.unity.sysroot",
"com.unity.services.rooms",
"com.unity.services.utility",
"com.unity.sysroot.linux-x86_64",
"com.unity.services.authentication"
]
}
]
}
}

55
Packages/packages-lock.json


},
"com.unity.burst": {
"version": "1.6.0-pre.2",
"depth": 2,
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.mathematics": "1.2.1"

"source": "registry",
"dependencies": {
"com.unity.nuget.newtonsoft-json": "2.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.collections": {
"version": "1.0.0-pre.3",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.burst": "1.5.3",
"com.unity.test-framework": "1.1.22"
},
"url": "https://packages.unity.com"
},

"url": "https://packages.unity.com"
},
"com.unity.services.authentication": {
"version": "0.5.0-preview",
"version": "file:com.unity.services.authentication",
"source": "registry",
"source": "embedded",
},
"url": "https://artifactory.prd.it.unity3d.com/artifactory/api/npm/upm-candidates"
}
"version": "1.1.0-pre.2",
"depth": 1,
"source": "registry",
"version": "file:com.unity.services.core",
"depth": 0,
"source": "embedded",
},
"url": "https://artifactory.prd.it.unity3d.com/artifactory/api/npm/upm-candidates"
}
"version": "file:../LocalPackage/com.unity.services.lobby",
"version": "file:com.unity.services.lobby",
"source": "local",
"source": "embedded",
"dependencies": {
"com.unity.services.core": "1.1.0-pre.2",
"com.unity.modules.unitywebrequest": "1.0.0",

}
},
"com.unity.services.relay": {
"version": "0.0.1-preview.7",
"version": "file:com.unity.services.relay",
"source": "registry",
"source": "embedded",
"dependencies": {
"com.unity.services.core": "1.1.0-pre.2",
"com.unity.modules.unitywebrequest": "1.0.0",

"com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.nuget.newtonsoft-json": "2.0.0"
},
"url": "https://artifactory.prd.it.unity3d.com/artifactory/api/npm/upm-candidates"
}
},
"com.unity.sysroot": {
"version": "0.1.19-preview",

"url": "https://artifactory.prd.it.unity3d.com/artifactory/api/npm/upm-candidates"
"url": "https://packages.unity.com"
},
"com.unity.sysroot.linux-x86_64": {
"version": "0.1.15-preview",

"com.unity.sysroot": "0.1.19-preview"
},
"url": "https://artifactory.prd.it.unity3d.com/artifactory/api/npm/upm-candidates"
"url": "https://packages.unity.com"
},
"com.unity.test-framework": {
"version": "1.1.26",

"com.unity.sysroot": "0.1.19-preview",
"com.unity.sysroot.linux-x86_64": "0.1.14-preview"
},
"url": "https://artifactory.prd.it.unity3d.com/artifactory/api/npm/upm-candidates"
"url": "https://packages.unity.com"
},
"com.unity.transport": {
"version": "file:com.unity.transport",
"depth": 0,
"source": "embedded",
"dependencies": {
"com.unity.collections": "1.0.0-pre.3",
"com.unity.burst": "1.5.1",
"com.unity.mathematics": "1.2.1"
}
},
"com.unity.ugui": {
"version": "1.0.0",

24
ProjectSettings/PackageManagerSettings.asset


m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0}
m_Name:
m_EditorClassIdentifier:
m_EnablePreReleasePackages: 1
m_EnablePackageDependencies: 1
m_EnablePreReleasePackages: 0
m_EnablePackageDependencies: 0
m_AdvancedSettingsExpanded: 1
m_ScopedRegistriesSettingsExpanded: 1
m_SeeAllPackageVersions: 0

m_Scopes: []
m_IsDefault: 1
m_Capabilities: 7
- m_Id: scoped:Internal Candidates Registry
m_Name: Internal Candidates Registry
m_Url: https://artifactory.prd.it.unity3d.com/artifactory/api/npm/upm-candidates
m_Scopes:
- com.unity.services.relay
- com.unity.services.core
- com.unity.toolchain.win-x86_64-linux-x86_64
- com.unity.sysroot
- com.unity.services.rooms
- com.unity.services.utility
- com.unity.sysroot.linux-x86_64
- com.unity.services.authentication
m_IsDefault: 0
m_Capabilities: 0
m_UserSelectedRegistryName: Internal Candidates Registry
m_UserSelectedRegistryName:
m_UserModificationsInstanceId: -812
m_OriginalInstanceId: -816
m_UserModificationsInstanceId: -822
m_OriginalInstanceId: -824
m_LoadAssets: 0

6
ProjectSettings/ProjectSettings.asset


m_VersionName:
apiCompatibilityLevel: 6
activeInputHandler: 0
cloudProjectId:
cloudProjectId: 35a50d42-c591-451d-968c-b59d5f3c317b
projectName:
organizationId:
projectName: Game-Lobby-Sample
organizationId: operate-samples
cloudEnabled: 0
legacyClampBlendShapeWeights: 0
playerDataPath:

41
README.md


Lobby and Relay are **only** available in closed beta at the moment, to use these services you will need to have signed up here for the services to show in your Organization: https://create.unity3d.com/relay-lobby-beta-signup
# Game Lobby Sample
## *Unity 2021.0b1*
## *Unity 2021.2 0b1*
This is a Unity Project Sample showing how to integrate Lobby and Relay into a typical Game Lobby experience.

- Relay Server Join
## Service Organization Setup
** Create an organization.**
** Create an organization**
## Lobby
## Lobby & Relay
Navigate to https://dashboard.unity3d.com/lobby
Lobby Dashboard: https://dashboard.unity3d.com/lobby
*(This will only be visibile if you are in the closed beta)*
In the bottom left, select "Get Started"
Follow the steps until you hit "Lobby On"
We use the Relay service to obfuscate the Hosts' IP, while still allowing them to locally host strangers.
## Relay
We use the Relay service to obfuscate the Hosts' IP, while still allowing them to locally host strangers.
Navigate to https://dashboard.unity3d.com/relay
Relay Dashboard: https://dashboard.unity3d.com/relay
*(This will only be visibile if you are in the closed beta)*
In the bottom left, select "Get Started"
Follow the steps until you hit "Relay On"
*(Current version of the sample does not use transport, so you may skip it.)*
### Setup
For either one, select "Get Started"
** Closed Beta Only **
## Unity Editor Setup
In the project, navigate to **Edit => Project Settings => Services**
![Services Editor](~Documentation/Images/services1.PNG?raw=true)
Select your organization from the drop-down, and push **Create Project ID**.
Follow the steps, downloading your packaged folders to the Sample Project Pac.
In the end your Service window should look like this!
![Services Editor Complete](~Documentation/Images/services2.PNG?raw=true)
Follow the steps until you hit "Lobby/Relay On"
## Solo Testing

242
Packages/com.unity.services.authentication/.README - External.md


# UPM Package Starter Kit
The purpose of this starter kit is to provide the data structure and development guidelines for new packages meant for the **Unity Package Manager (UPM)**.
## Are you ready to become a package?
The Package Manager is a work-in-progress for Unity and, in that sense, there are a few criteria that must be met for your package to be considered on the package list at this time:
- **Your code accesses public Unity C# APIs only.** If you have a native code component, it will need to ship with an official editor release. Internal API access might eventually be possible for Unity made packages, but not at this time.
- **Your code doesn't require security, obfuscation, or conditional access control.** Anyone should be able to download your package and access the source code.
## Package structure
```none
<root>
├── package.json
├── README.md
├── CHANGELOG.md
├── LICENSE.md
├── Third Party Notices.md
├── QAReport.md
├── Editor
│ ├── Unity.[YourPackageName].Editor.asmdef
│ └── EditorExample.cs
├── Runtime
│ ├── Unity.[YourPackageName].asmdef
│ └── RuntimeExample.cs
├── Tests
│ ├── .tests.json
│ ├── Editor
│ │ ├── Unity.[YourPackageName].Editor.Tests.asmdef
│ │ └── EditorExampleTest.cs
│ └── Runtime
│ ├── Unity.[YourPackageName].Tests.asmdef
│ └── RuntimeExampleTest.cs
├── Samples
│ └── Example
│ ├── .sample.json
│ └── SampleExample.cs
└── Documentation~
├── your-package-name.md
└── Images
```
## Develop your package
Package development works best within the Unity Editor. Here's how to set that up:
1. Start **Unity**, create a local empty project.
1. In a console (or terminal) application, go to the newly created project folder, then copy the contents of this starter kit into the packages directory.
__Note:__ Your directory name must be the name of your package (Example: `"com.unity.terrain-builder"`)
1. ##### Fill in your package information
Update the following required fields in file **package.json**:
- `"name"`: Package name, it should follow this naming convention: `"com.[YourCompanyName].[sub-group].[your-package-name]"`
(Example: `"com.unity.2d.animation"`, where `sub-group` should match the sub-group you selected in Gitlab)
- `"displayName"`: Package user friendly display name. (Example: `"Terrain Builder SDK"`). <br>__Note:__ Use a display name that will help users understand what your package is intended for.
- `"version"`: Package version `"X.Y.Z"`, your project **must** adhere to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
Follow this guideline:
- To introduce a new feature or bug fix, increment the minor version (X.**Y**.Z)
- To introduce a breaking API change, increment the major version (**X**.Y.Z)
- The patch version (X.Y.**Z**), is reserved for sustainable engineering use only.
- `"unity"`: Unity Version your package is compatible with. (Example: `"2018.1"`)
- `"description"`: This description appears in the Package Manager window when the user selects this package from the list. For best results, use this text to summarize what the package does and how it can benefit the user.<br>__Note:__ Special formatting characters are supported, including line breaks (`\n`) and unicode characters such as bullets (`\u25AA`).<br>
Update the following recommended fields in file **package.json**:
- `"dependencies"`: List of packages this package depends on. All dependencies will also be downloaded and loaded in a project with your package. Here's an example:
```
dependencies: {
"com.unity.ads": "1.0.0"
"com.unity.analytics": "2.0.0"
}
```
- `"keywords"`: List of words that will be indexed by the package manager search engine to facilitate discovery.
Update the following field in file **Tests/.tests.json**:
- `"createSeparatePackage"`: If this is set to true, the CI will create a separate package for these tests. If you leave it set to false, the tests will remain part of the published package. If you set it to true, the tests in your package will automatically be moved to a separate package, and metadata will be added at publish time to link the packages together. This allows you to have a large number of tests, or assets, etc. that you don't want to include in your main package, while making it easy to test your package with those tests & fixtures.
1. You should now see your package in the Project Window, along with all other available packages for your project.
1. ##### Rename and update assembly definition files.
Assembly definition files are used to generate C# assemblies during compilation. Package code must include asmdef files to ensure package code isolation. You can read up on assembly definition files [here](https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html).
If your package contains Editor code, rename and modify [Editor/Unity.YourPackageName.Editor.asmdef](Editor/Unity.YourPackageName.Editor.asmdef). Otherwise, delete the Editor directory.
* Name **must** match your package name, suffixed by `.Editor` (i.e `Unity.[YourPackageName].Editor`)
* Assembly **must** reference `Unity.[YourPackageName]` (if you have any Runtime)
* Platforms **must** include `"Editor"`
If your package contains code that needs to be included in Unity runtime builds, rename and modify [Runtime/Unity.YourPackageName.asmdef](Runtime/Unity.YourPackageName.asmdef). Otherwise, delete the Runtime directory.
* Name **must** match your package name (i.e `Unity.[YourPackageName]`)
If your package has Editor code, you **must** include Editor Tests in your package. In that case, rename and modify [Tests/Editor/Unity.YourPackageName.Editor.Tests.asmdef](Tests/Editor/Unity.YourPackageName.Editor.Tests.asmdef).
* Name **must** match your package name, suffixed by `.Editor.Tests` (i.e `Unity.[YourPackageName].Editor.Tests`)
* Assembly **must** reference `Unity.[YourPackageName].Editor` and `Unity.[YourPackageName]` (if you have any Runtime)
* Platforms **must** include `"Editor"`
* Optional Unity references **must** include `"TestAssemblies"` to allow your Editor Tests to show up in the Test Runner/run on Katana when your package is listed in project manifest `testables`
If your package has Runtime code, you **must** include Playmode Tests in your package. In that case, rename and modify [Tests/Runtime/Unity.YourPackageName.Tests.asmdef](Tests/Runtime/Unity.YourPackageName.Tests.asmdef).
* Name **must** match your package name, suffixed by `.Tests` (i.e `Unity.[YourPackageName].Tests`)
* Assembly **must** reference `Unity.[YourPackageName]`
* Optional Unity references **must** include `"TestAssemblies"` to allow your Playmode Tests to show up in the Test Runner/run on Katana when your package is listed in project manifest `testables`
>
> The reason for choosing such name schema is to ensure that the name of the assembly built based on *assembly definition file* (_a.k.a .asmdef_) will follow the .Net [Framework Design Guidelines](https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/index)
1. ##### Document your package.
Rename and update **your-package-name.md** documentation file. Use this documentation template file to create preliminary, high-level documentation. This document is meant to introduce users to the features and sample files included in your package. Your package documentation files will be used to generate online and local docs, available from the package manager UI.
**Document your public APIs**
* All public APIs need to be documented with XmlDoc. If you don't need an API to be accessed by clients, mark it as internal instead.
* API documentation is generated from [XmlDoc tags](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/xml-documentation-comments) included with all public APIs found in the package. See [Editor/EditorExample.cs](Editor/EditorExample.cs) for an example.
**Documentation flow**
* Documentation needs to be ready when a publish request is sent to Release Management, as they will ask the documentation team to review it.
* The package will remain in `preview` mode until the final documentation is completed. Users will have access to the developer-generated documentation only in preview packages.
* When the documentation is completed, the documentation team will update the package git repo with the updates and they will publish it on the web.
* The package's development team will then need to submit a new package version with updated docs.
* The starting page in the user manual that links to package documentation is [Here](https://docs.unity3d.com/Manual/PackagesList.html).
* The `Documentation~` folder is suffixed with `~` so that its content does not get loaded in the editor, which is the recommended behavior. If this is problematic, you can still name it `Documentation` and all tools will still work correctly. `.Documentation` is also supported.
**Test your documentation locally**
As you are developing your documentation, you can see what your documentation will look like by using the DocTools extension (optional).
Once the DocTools package is installed, it will add a `Generate Documentation` button in the Package Manager UI's details of your installed packages. To install the extension, follow these steps:
1. Make sure you have `Package Manager UI v1.9.6` or above.
1. Your project manifest will need to point to a staging registry for this, which you can do by adding this line to it: `"registry": "https://staging-packages.unity.com"`
1. Install `Package Manager DocTools v1.0.0-preview.6` or above from the `Package Manager UI` (in the `All Packages` section).
1. After installation, you will see a `Generate Documentation` button which will generate the documentation locally, and open a web browser to a locally served version of your documentation so you can preview it.
1. (optional) If your package documentation contains multiple `.md` files for the user manual, see [this page](https://docs.unity3d.com/Packages/com.unity.package-manager-doctools@1.0/manual/index.html#table-of-content) to add a table of content to your documentation.
The DocTools extension is still in preview, if you come across arguable results, please discuss them on #docs-packman.
1. ##### Add samples to your package (code & assets).
If your package contains a sample, rename the `Samples/Example` folder, and update the `.sample.json` file in it.
In the case where your package contains multiple samples, you can make a copy of the `Samples/Example` folder for each sample, and update the `.sample.json` file accordingly.
Similar to `.tests.json` file, there is a `"createSeparatePackage"` field in `.sample.json`.If set to true, the CI will create an separate package for the sample..
Delete the `Samples` folder altogether if your package does not need samples.
As of Unity release 2019.1, the /Samples directory of a package will be recognized by the package manager. Samples will not be imported to Unity when the package is added to a project, but will instead be offered to users of the package as an optional import, which can be added to their "/Assets" directory through a UI option.
1. ##### Validate your package.
Before you publish your package, you need to make sure that it passes all the necessary validation checks by using the Package Validation Suite extension (optional).
Once the Validation Suite package is installed, it will add a `Validate` button in the Package Manager UI's details of your installed packages. To install the extension, follow these steps:
1. Make sure you have `Package Manager UI v1.9.6` or above.
1. Your project manifest will need to point to a staging registry for this, which you can do by adding this line to it: `"registry": "https://staging-packages.unity.com"`
1. Install `Package Validation Suite v0.3.0-preview.13` or above from the `Package Manager UI` in the `All Packages` section. If you can't find it there, try turning on `Show preview packages` in the `Advanced` menu.
1. After installation, you will see a `Validate` button show up in the Package Manager UI, which, when pressed, will run a series of tests and expose a `See Results` button for additional explanation.
1. If it succeeds, you will see a green bar with a `Success` message.
1. If it fails, you will see a red bar with a `Failed` message.
The validation suite is still in preview, if you come across arguable results, please discuss them on #release-management.
1. ##### Add tests to your package.
All packages must contain tests. Tests are essential for Unity to ensure that the package works as expected in different scenarios.
**Editor tests**
* Write all your Editor Tests in `Tests/Editor`
**Playmode Tests**
* Write all your Playmode Tests in `Tests/Runtime`.
1. ##### Update **CHANGELOG.md**.
Every new feature or bug fix should have a trace in this file. For more details on the chosen changelog format, see [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## Create a Pre-Release Package
Pre-Release Packages are a great way of getting your features in front of Unity Developers in order to get early feedback on functionality and UI designs. Pre-Release packages need to go through the publishing to production flow, as would any other package, but with diminished requirements. Here are the supported Pre-Release tags (to be used in package.json,`version` field), along with the requirements for each one:
**Preview** - ex: `"version" : "1.2.0-preview"`
* Expected Package structure respected
* Package loads in Unity Editor without errors
* License file present - With third party notices file if necessary
* Test coverage is good - Optional but preferred
* Public APIs documented, minimal feature docs exists- Optional but preferred
## Make sure your package meets all legal requirements
##### Update **Third Party Notices.md** & **License.md**
1. If your package has third-party elements and its licenses are approved, then all the licenses must be added to the `Third Party Notices.md` file. Simply duplicate the `Component Name/License Type/Provide License Details` section if you have more then one licenes.
a. Concerning `[Provide License Details]` in the `Third Party Notices.md`, a URL can work as long as it actually points to the reproduced license and the copyright information _(if applicable)_.
1. If your package does not have third party elements, you can remove the `Third Party Notices.md` file from your package.
## Preparing your package for Staging
Before publishing your package to production, you must send your package on the Package Manager's **staging** repository. The staging repository is monitored by QA and release management, and is where package validation will take place before it is accepted in production.
## *** IMPORTANT: The staging repository is publicly accessible, do not publish any packages with sensitive material you aren't ready to share with the public ***
1. Publishing your changes to the package manager's **staging** repository happens from Gitlab. To do so, simply setup your project's Continuous integration, which will be triggered by "Tags" on your branches.
* Join the **#devs-packman** channel on Slack, and request a staging **USERNAME** and **API_KEY**.
* In Gitlab, under the **Settings-> CI/CD -> Secret Variables** section, setup the following 2 project variables:
* API_KEY = [your API KEY]
* USER_NAME = [your USER NAME@unity]
* You're almost done! To publish a version of your package, make sure all your changes are checked into Gitlab, then create a new tag to reflect the version you are publishing (ex. "v1.2.2"), **the tag will trigger a publish to Staging**. You can view progress you the publish request by switch over to the "CI / CD" part of your project.
1. Do it yourself CI
If you are using your own CI, it is still recommended that you use the `build.sh` wrapper script that comes with the starter kit, as it handle the installation of the actual CI build scripts for you.
Instead of calling `npm pack` and `npm publish` in the package root folder in your CI, use
```
./build.sh package-ci pack --git-head $CI_COMMIT_SHA --git-url $CI_REPOSITORY_URL
```
and
```
./build.sh package-ci publish --git-head $CI_COMMIT_SHA --git-url $CI_REPOSITORY_URL
```
respectively.
1. Test your package locally
Now that your package is published on the package manager's **staging** repository, you can test your package in the editor by creating a new project, and editing the project's `manifest.json` file to point to your staging package, as such:
```
dependencies: {
"com.[YourCompanyName].[sub-group].[your-package-name]": "0.1.0"
},
"registry": "https://staging-packages.unity.com"
```
## Get your package published to Production
Packages are promoted to the **production** repository from **staging**, described above.
Once you feel comfortable that your package is ready for prime time, and passes validation (Validation Suite), reach out to Unity so your package can be passed along to Release Management, for evaluation.
**Release management will validate your package content, and check that the editor/playmode tests are passed before promoting the package to production. You will receive a confirmation email once the package is in production.**
**You're almost done!**
At this point, your package is available on the cloud, but not discoverable through the editor:
1. Contact the Package Manager team to ask them to add your package to the list of discoverable package for the Unity Editor. All you need to provide is the package name (com.[YourCompanyName].[sub-group].[your-package-name])

53
Packages/com.unity.services.authentication/CHANGELOG.md


# Changelog
All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [0.4.0-preview] - 2021-06-16
### Changed
- Remove `SetOAuthClient()` as the authentication flow is simplified.
- Updated the initialization code to initialize with `UnityServices.Initialize()`
## [0.4.0-preview] - 2021-06-07
### Added
- Added Project Settings UI to configure ID providers.
- Added `SignInWithSteam`, `LinkWithSteam` functions.
- Changed the public interface of the Authentication service from a static instance and static methods to a singleton instance hidden behind an interface.
### Changed
- Change the public signature of `Authentication` to return a Task, as opposed to a IAsyncOperation
- Change the public API names of `Authentication` to `Async`
## [0.3.1-preview] - 2021-04-23
### Changed
- Change the `SignInFailed` event to take `AuthenticationException` instead of a string as parameter. It can provide more information for debugging purposes.
- Fixed the `com.unity.services.core` package dependency version.
## [0.3.0-preview] - 2021-04-21
### Added
- Added `SignInWithApple`, `LinkWithApple`, `SignInWithGoogle`, `LinkWithGoogle`, `SignInWithFacebook`, `LinkWithFacebook` functions.
- Added `SignInWithSessionToken`
- Added error codes used by the social scenarios to `AuthenticationError`.
## [0.2.3-preview] - 2021-03-23
### Changed
- Rename the package from `com.unity.services.identity` to `com.unity.services.authentication`. Renamed the internal types/methods, too.
## [0.2.2-preview] - 2021-03-15
### Added
- Core package integration
## [0.2.1-preview] - 2021-03-05
- Fixed dependency on Utilities package
## [0.2.0-preview] - 2021-03-05
- Removed requirement for OAuth client ID to be specified (automatically uses project default OAuth client)
## [0.1.0-preview] - 2021-01-18
### This is the first release of *com.unity.services.identity*.

7
Packages/com.unity.services.authentication/CHANGELOG.md.meta


fileFormatVersion: 2
guid: 06e5cc5b0f38f824b835fc371283773e
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

5
Packages/com.unity.services.authentication/Documentation~/com.unity.services.authentication.md


# About Authentication SDK
This is the Authentication SDK, a way to manage player accounts through the Unity User Authentication Service (UAS).
This package is currently in pre-release state and is not guaranteed to be fully functional.

8
Packages/com.unity.services.authentication/Editor.meta


fileFormatVersion: 2
guid: 9ab04733f4c8a4d7181b07dfa234aa46
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

5
Packages/com.unity.services.authentication/Editor/AssemblyInfo.cs


using System;
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Unity.Services.Authentication.EditorTests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] // For Moq

3
Packages/com.unity.services.authentication/Editor/AssemblyInfo.cs.meta


fileFormatVersion: 2
guid: 80f9842e95c141e59bcc9d49c93cc2e1
timeCreated: 1620833560

298
Packages/com.unity.services.authentication/Editor/AuthenticationAdminClient.cs


using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using Newtonsoft.Json;
using Unity.Services.Authentication.Editor.Models;
using Unity.Services.Authentication.Models;
using Unity.Services.Authentication.Utilities;
using Unity.Services.Core;
using UnityEditor;
using UnityEngine;
using ILogger = Unity.Services.Authentication.Utilities.ILogger;
using Logger = Unity.Services.Authentication.Utilities.Logger;
[assembly: InternalsVisibleTo("Unity.Services.Authentication.Editor.Tests")]
[assembly: InternalsVisibleTo("Unity.Services.Authentication.EditorTests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] // For Moq
namespace Unity.Services.Authentication.Editor
{
static class AuthenticationAdminClientManager
{
internal static IAuthenticationAdminClient Instance { get; set; } = AuthenticationAdminClient();
static IAuthenticationAdminClient AuthenticationAdminClient()
{
var logger = new Logger("[Authentication]");
IDateTimeWrapper dateTime = new DateTimeWrapper();
INetworkingUtilities networkUtilities = new NetworkingUtilities(null, logger);
string orgId = GetOrganizationId();
var networkClient = new AuthenticationAdminNetworkClient("https://services.unity.com",
orgId,
CloudProjectSettings.projectId,
networkUtilities,
logger);
return new AuthenticationAdminClient(logger, networkClient);
}
// GetOrganizationId will gets the organization id associated with this Unity project.
static string GetOrganizationId()
{
// This is a temporary workaround to get the Genesis organization foreign key for non-DevX enhanced Unity versions.
// When the eventual changes are backported into previous versions of Unity, this will no longer be necessary.
Assembly assembly = Assembly.GetAssembly(typeof(EditorWindow));
var unityConnectInstance = assembly.CreateInstance("UnityEditor.Connect.UnityConnect", false, BindingFlags.NonPublic | BindingFlags.Instance, null, null, null, null); Type t = unityConnectInstance.GetType();
var projectInfo = t.GetProperty("projectInfo").GetValue(unityConnectInstance, null);
Type projectInfoType = projectInfo.GetType();
return projectInfoType.GetProperty("organizationForeignKey").GetValue(projectInfo, null) as string;
}
}
class AuthenticationAdminClient : IAuthenticationAdminClient
{
string m_IdDomain;
IAuthenticationAdminNetworkClient m_AuthenticationAdminNetworkClient;
ILogger m_Logger;
string m_orgForeignKey;
string m_servicesGatewayToken;
string m_genesisToken;
internal enum ServiceCalled
{
TokenExchange,
AuthenticationAdmin
}
public AuthenticationAdminClient(ILogger logger, IAuthenticationAdminNetworkClient networkClient, string genesisToken = "")
{
m_Logger = logger;
m_AuthenticationAdminNetworkClient = networkClient;
m_genesisToken = genesisToken;
}
public IAsyncOperation<string> GetIDDomain()
{
var asyncOp = new AsyncOperation<string>();
Action<string> getIdDomainFunc = token =>
{
var getDefaultIdDomainRequest = m_AuthenticationAdminNetworkClient.GetDefaultIdDomain(token);
getDefaultIdDomainRequest.Completed += request => HandleGetIdDomainAPICall(asyncOp, request);
};
getGenesisToken();
var tokenAsyncOp = ExchangeToken(m_genesisToken);
tokenAsyncOp.Completed += tokenAsyncOpResult => getIdDomainFunc(tokenAsyncOpResult?.Result);
return asyncOp;
}
public IAsyncOperation<IdProviderResponse> CreateIdProvider(string iddomain, CreateIdProviderRequest body)
{
var asyncOp = new AsyncOperation<IdProviderResponse>();
Action<string> createIdProviderFunc = token =>
{
var request = m_AuthenticationAdminNetworkClient.CreateIdProvider(body, iddomain, token);
request.Completed += req => HandleIdProviderResponseApiCall(asyncOp, req);
};
getGenesisToken();
var tokenAsyncOp = ExchangeToken(m_genesisToken);
tokenAsyncOp.Completed += tokenAsyncOpResult => createIdProviderFunc(tokenAsyncOpResult?.Result);
return asyncOp;
}
public IAsyncOperation<ListIdProviderResponse> ListIdProviders(string iddomain)
{
var asyncOp = new AsyncOperation<ListIdProviderResponse>();
Action<string> listIdProviderFunc = token =>
{
var request = m_AuthenticationAdminNetworkClient.ListIdProvider(iddomain, token);
request.Completed += req => HandleListIdProviderResponseApiCall(asyncOp, req);
};
getGenesisToken();
var tokenAsyncOp = ExchangeToken(m_genesisToken);
tokenAsyncOp.Completed += tokenAsyncOpResult => listIdProviderFunc(tokenAsyncOpResult?.Result);
return asyncOp;
}
public IAsyncOperation<IdProviderResponse> UpdateIdProvider(string iddomain, string type, UpdateIdProviderRequest body)
{
var asyncOp = new AsyncOperation<IdProviderResponse>();
Action<string> enableIdProviderFunc = token =>
{
var request = m_AuthenticationAdminNetworkClient.UpdateIdProvider(body, iddomain, type, token);
request.Completed += req => HandleIdProviderResponseApiCall(asyncOp, req);
};
getGenesisToken();
var tokenAsyncOp = ExchangeToken(m_genesisToken);
tokenAsyncOp.Completed += tokenAsyncOpResult => enableIdProviderFunc(tokenAsyncOpResult?.Result);
return asyncOp;
}
public IAsyncOperation<IdProviderResponse> EnableIdProvider(string iddomain, string type)
{
var asyncOp = new AsyncOperation<IdProviderResponse>();
Action<string> enableIdProviderFunc = token =>
{
var request = m_AuthenticationAdminNetworkClient.EnableIdProvider(iddomain, type, token);
request.Completed += req => HandleIdProviderResponseApiCall(asyncOp, req);
};
getGenesisToken();
var tokenAsyncOp = ExchangeToken(m_genesisToken);
tokenAsyncOp.Completed += tokenAsyncOpResult => enableIdProviderFunc(tokenAsyncOpResult?.Result);
return asyncOp;
}
public IAsyncOperation<IdProviderResponse> DisableIdProvider(string iddomain, string type)
{
var asyncOp = new AsyncOperation<IdProviderResponse>();
Action<string> disableIdProviderFunc = token =>
{
var request = m_AuthenticationAdminNetworkClient.DisableIdProvider(iddomain, type, token);
request.Completed += req => HandleIdProviderResponseApiCall(asyncOp, req);
};
getGenesisToken();
var tokenAsyncOp = ExchangeToken(m_genesisToken);
tokenAsyncOp.Completed += tokenAsyncOpResult => disableIdProviderFunc(tokenAsyncOpResult?.Result);
return asyncOp;
}
public IAsyncOperation<IdProviderResponse> DeleteIdProvider(string iddomain, string type)
{
var asyncOp = new AsyncOperation<IdProviderResponse>();
Action<string> deleteIdProviderFunc = token =>
{
var request = m_AuthenticationAdminNetworkClient.DeleteIdProvider(iddomain, type, token);
request.Completed += req => HandleIdProviderResponseApiCall(asyncOp, req);
};
getGenesisToken();
var tokenAsyncOp = ExchangeToken(m_genesisToken);
tokenAsyncOp.Completed += tokenAsyncOpResult => deleteIdProviderFunc(tokenAsyncOpResult?.Result);
return asyncOp;
}
public IdProviderResponse CloneIdProvider(IdProviderResponse x)
{
return x.Clone();
}
internal IAsyncOperation<string> ExchangeToken(string token)
{
var asyncOp = new AsyncOperation<string>();
var request = m_AuthenticationAdminNetworkClient.TokenExchange(token);
request.Completed += req => HandleTokenExchange(asyncOp, req);
return asyncOp;
}
void HandleGetIdDomainAPICall(AsyncOperation<string> asyncOp, IWebRequest<GetIdDomainResponse> request)
{
if (HandleError(asyncOp, request, ServiceCalled.AuthenticationAdmin))
{
return;
}
m_IdDomain = request?.ResponseBody?.Id;
asyncOp.Succeed(request?.ResponseBody?.Id);
}
void HandleTokenExchange(AsyncOperation<string> asyncOp, IWebRequest<TokenExchangeResponse> request)
{
if (HandleError(asyncOp, request, ServiceCalled.TokenExchange))
{
return;
}
var token = request?.ResponseBody?.Token;
m_servicesGatewayToken = token;
asyncOp.Succeed(token);
}
void HandleIdProviderResponseApiCall(AsyncOperation<IdProviderResponse> asyncOp, IWebRequest<IdProviderResponse> request)
{
if (HandleError(asyncOp, request, ServiceCalled.AuthenticationAdmin))
{
return;
}
asyncOp.Succeed(request?.ResponseBody);
}
void HandleListIdProviderResponseApiCall(AsyncOperation<ListIdProviderResponse> asyncOp, IWebRequest<ListIdProviderResponse> request)
{
if (HandleError(asyncOp, request, ServiceCalled.AuthenticationAdmin))
{
return;
}
asyncOp.Succeed(request?.ResponseBody);
}
void HandleEmptyResponseApiCall(AsyncOperation<IdProviderResponse> asyncOp, IWebRequest<IdProviderResponse> request)
{
if (HandleError(asyncOp, request, ServiceCalled.AuthenticationAdmin))
{
return;
}
asyncOp.Succeed(request?.ResponseBody);
}
internal bool HandleError<Q, T>(AsyncOperation<Q> asyncOp, IWebRequest<T> request, ServiceCalled sc)
{
if (!request.RequestFailed)
{
return false;
}
if (request.NetworkError)
{
asyncOp.Fail(new AuthenticationException(AuthenticationError.NetworkError));
return true;
}
m_Logger?.Error("Error message: " + request.ErrorMessage);
try
{
switch (sc)
{
case ServiceCalled.TokenExchange:
var tokenExchangeErrorResponse = JsonConvert.DeserializeObject<TokenExchangeErrorResponse>(request.ErrorMessage);
asyncOp.Fail(new AuthenticationException(tokenExchangeErrorResponse.Name, tokenExchangeErrorResponse.Message));
break;
case ServiceCalled.AuthenticationAdmin:
var authenticationAdminErrorResponse = JsonConvert.DeserializeObject<AuthenticationErrorResponse>(request.ErrorMessage);
asyncOp.Fail(new AuthenticationException(authenticationAdminErrorResponse.Title, authenticationAdminErrorResponse.Detail));
break;
default:
asyncOp.Fail(new AuthenticationException(AuthenticationError.UnknownError, "Unknown error"));
break;
}
}
catch (JsonException ex)
{
asyncOp.Fail(new AuthenticationException(AuthenticationError.UnknownError, "Failed to deserialize server response: " + request.ErrorMessage));
}
catch (Exception ex)
{
asyncOp.Fail(new AuthenticationException(AuthenticationError.UnknownError, "Unknown error deserializing server response: " + request.ErrorMessage));
}
return true;
}
void getGenesisToken()
{
if (m_genesisToken == "")
{
m_genesisToken = CloudProjectSettings.accessToken;
}
}
}
}

3
Packages/com.unity.services.authentication/Editor/AuthenticationAdminClient.cs.meta


fileFormatVersion: 2
guid: ca4a5cace103447794de02de329b8eeb
timeCreated: 1620234241

148
Packages/com.unity.services.authentication/Editor/AuthenticationAdminNetworkClient.cs


using System;
using System.Collections.Generic;
using Unity.Services.Authentication.Editor.Models;
using Unity.Services.Authentication.Utilities;
using UnityEngine;
using ILogger = Unity.Services.Authentication.Utilities.ILogger;
namespace Unity.Services.Authentication.Editor
{
interface IAuthenticationAdminNetworkClient
{
IWebRequest<TokenExchangeResponse> TokenExchange(string token);
IWebRequest<GetIdDomainResponse> GetDefaultIdDomain(string token);
IWebRequest<IdProviderResponse> CreateIdProvider(CreateIdProviderRequest body, string idDomain, string token);
IWebRequest<ListIdProviderResponse> ListIdProvider(string idDomain, string token);
IWebRequest<IdProviderResponse> UpdateIdProvider(UpdateIdProviderRequest body, string idDomain, string type, string token);
IWebRequest<IdProviderResponse> EnableIdProvider(string idDomain, string type, string token);
IWebRequest<IdProviderResponse> DisableIdProvider(string idDomain, string type, string token);
IWebRequest<IdProviderResponse> DeleteIdProvider(string idDomain, string type, string token);
}
class AuthenticationAdminNetworkClient : IAuthenticationAdminNetworkClient
{
const string k_ServicesGatewayStem = "/api/player-identity/v1/organizations/";
const string k_GetDefaultIdDomainStem = "/iddomains/default";
const string k_TokenExchangeStem = "/api/auth/v1/genesis-token-exchange/unity";
readonly string m_ServicesGatewayHost;
readonly string m_GetDefaultIdDomainUrl;
readonly string m_TokenExchangeUrl;
readonly string m_OrganizationId;
readonly string m_ProjectId;
readonly INetworkingUtilities m_NetworkClient;
readonly Dictionary<string, string> m_CommonPlayerIdentityHeaders;
internal AuthenticationAdminNetworkClient(string servicesGatewayHost,
string organizationId,
string projectId,
INetworkingUtilities networkClient,
ILogger logger)
{
m_ServicesGatewayHost = servicesGatewayHost;
m_OrganizationId = organizationId;
m_ProjectId = projectId;
m_GetDefaultIdDomainUrl = servicesGatewayHost + k_ServicesGatewayStem + organizationId + k_GetDefaultIdDomainStem;
m_TokenExchangeUrl = servicesGatewayHost + k_TokenExchangeStem;
m_NetworkClient = networkClient;
m_CommonPlayerIdentityHeaders = new Dictionary<string, string>
{
["ProjectId"] = projectId,
// The Error-Version header enables RFC7807HttpError error responses
["Error-Version"] = "v1"
};
}
public IWebRequest<GetIdDomainResponse> GetDefaultIdDomain(string token)
{
return m_NetworkClient.Get<GetIdDomainResponse>(m_GetDefaultIdDomainUrl, addTokenHeader(m_CommonPlayerIdentityHeaders, token));
}
public IWebRequest<TokenExchangeResponse> TokenExchange(string token)
{
var body = new TokenExchangeRequest();
body.Token = token;
return m_NetworkClient.PostJson<TokenExchangeResponse>(m_TokenExchangeUrl, body);
}
public IWebRequest<IdProviderResponse> CreateIdProvider(CreateIdProviderRequest body, string idDomain, string token)
{
return m_NetworkClient.PostJson<IdProviderResponse>(CreateIdProviderUrl(idDomain), body, addTokenHeader(m_CommonPlayerIdentityHeaders, token));
}
public IWebRequest<ListIdProviderResponse> ListIdProvider(string idDomain, string token)
{
return m_NetworkClient.Get<ListIdProviderResponse>(ListIdProviderUrl(idDomain), addTokenHeader(m_CommonPlayerIdentityHeaders, token));
}
public IWebRequest<IdProviderResponse> UpdateIdProvider(UpdateIdProviderRequest body, string idDomain, string type, string token)
{
return m_NetworkClient.Put<IdProviderResponse>(UpdateIdProviderUrl(idDomain, type), body, addTokenHeader(m_CommonPlayerIdentityHeaders, token));
}
public IWebRequest<IdProviderResponse> EnableIdProvider(string idDomain, string type, string token)
{
return m_NetworkClient.Post<IdProviderResponse>(EnableIdProviderUrl(idDomain, type), addJsonHeader(addTokenHeader(m_CommonPlayerIdentityHeaders, token)));
}
public IWebRequest<IdProviderResponse> DisableIdProvider(string idDomain, string type, string token)
{
return m_NetworkClient.Post<IdProviderResponse>(DisableIdProviderUrl(idDomain, type), addJsonHeader(addTokenHeader(m_CommonPlayerIdentityHeaders, token)));
}
public IWebRequest<IdProviderResponse> DeleteIdProvider(string idDomain, string type, string token)
{
return m_NetworkClient.Delete<IdProviderResponse>(DeleteIdProviderUrl(idDomain, type), addTokenHeader(m_CommonPlayerIdentityHeaders, token));
}
Dictionary<string, string> addTokenHeader(Dictionary<string, string> d, string token)
{
var headers = new Dictionary<string, string>(d);
headers.Add("Authorization", "Bearer " + token);
return headers;
}
Dictionary<string, string> addJsonHeader(Dictionary<string, string> d)
{
var headers = new Dictionary<string, string>(d);
headers.Add("Content-Type", "application/json");
return headers;
}
string CreateIdProviderUrl(string idDomain)
{
return m_ServicesGatewayHost + k_ServicesGatewayStem + m_OrganizationId + "/iddomains/" + idDomain + "/idps";
}
string ListIdProviderUrl(string idDomain)
{
return m_ServicesGatewayHost + k_ServicesGatewayStem + m_OrganizationId + "/iddomains/" + idDomain + "/idps";
}
string UpdateIdProviderUrl(string idDomain, string type)
{
return m_ServicesGatewayHost + k_ServicesGatewayStem + m_OrganizationId + "/iddomains/" + idDomain + "/idps/" + type;
}
string DeleteIdProviderUrl(string idDomain, string type)
{
return m_ServicesGatewayHost + k_ServicesGatewayStem + m_OrganizationId + "/iddomains/" + idDomain + "/idps/" + type;
}
string EnableIdProviderUrl(string idDomain, string type)
{
return m_ServicesGatewayHost + k_ServicesGatewayStem + m_OrganizationId + "/iddomains/" + idDomain + "/idps/" + type + "/enable";
}
string DisableIdProviderUrl(string idDomain, string type)
{
return m_ServicesGatewayHost + k_ServicesGatewayStem + m_OrganizationId + "/iddomains/" + idDomain + "/idps/" + type + "/disable";
}
}
}

11
Packages/com.unity.services.authentication/Editor/AuthenticationAdminNetworkClient.cs.meta


fileFormatVersion: 2
guid: 45791e692f25c4a61adf3f50dc1397ac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

17
Packages/com.unity.services.authentication/Editor/AuthenticationIdentifier.cs


using System;
using Unity.Services.Core.Editor;
namespace Unity.Services.Authentication.Editor
{
/// <summary>
/// Implementation of the <see cref="IEditorGameServiceIdentifier"/> for the Authentication package
/// </summary>
/// <remarks>This identifier MUST be public struct.</remarks>
public struct AuthenticationIdentifier : IEditorGameServiceIdentifier
{
/// <summary>
/// Key for the Authentication package
/// </summary>
public string GetKey() => "Authentication";
}
}

11
Packages/com.unity.services.authentication/Editor/AuthenticationIdentifier.cs.meta


fileFormatVersion: 2
guid: 6ac6e0d63f116404caeed7d030ba58cb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

47
Packages/com.unity.services.authentication/Editor/AuthenticationService.cs


using System;
using Unity.Services.Core.Editor;
namespace Unity.Services.Authentication.Editor
{
class AuthenticationService : IEditorGameService
{
/// <summary>
/// Name of the service
/// Used for error handling and service fetching
/// </summary>
public string Name => "Authentication Service";
/// <summary>
/// Identifier for the service
/// Used when registering and fetching the service
/// </summary>
public IEditorGameServiceIdentifier Identifier { get; } = new AuthenticationIdentifier();
/// <summary>
/// Flag used to determine whether COPPA Compliance should be adhered to
/// for this service
/// </summary>
public bool RequiresCoppaCompliance => false;
/// <summary>
/// Flag used to determine whether this service has a dashboard
/// </summary>
public bool HasDashboard => false;
/// <summary>
/// Getter for the formatted dashboard url
/// If <see cref="HasDashboard"/> is false, this field only need return null or empty string
/// </summary>
/// <returns>The formatted URL</returns>
public string GetFormattedDashboardUrl()
{
return null;
}
/// <summary>
/// The enabler which allows the service to toggle on/off
/// Can be set to null, in which case there would be no toggle
/// </summary>
public IEditorGameServiceEnabler Enabler { get; } = null;
}
}

11
Packages/com.unity.services.authentication/Editor/AuthenticationService.cs.meta


fileFormatVersion: 2
guid: 8907e4a6f69d84349b9fdf60013bdd52
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

292
Packages/com.unity.services.authentication/Editor/AuthenticationSettingsElement.cs


using System;
using System.Collections.Generic;
using Unity.Services.Authentication.Editor.Models;
using Unity.Services.Core;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;
namespace Unity.Services.Authentication.Editor
{
class AuthenticationSettingsElement : VisualElement
{
const string k_Uxml = "Packages/com.unity.services.authentication/Editor/UXML/AuthenticationProjectSettings.uxml";
const string k_Uss = "Packages/com.unity.services.authentication/Editor/USS/AuthenticationStyleSheet.uss";
IAuthenticationAdminClient m_AdminClient;
string m_ProjectId;
string m_IdDomainId;
// Whether skip the confirmation window for tests/automation.
bool m_SkipConfirmation;
TextElement m_WaitingTextElement;
TextElement m_ErrorTextElement;
VisualElement m_AddIdProviderContainer;
List<string> m_AddIdProviderTypeChoices;
PopupField<string> m_AddIdProviderType;
Button m_RefreshButton;
Button m_AddButton;
VisualElement m_IdProviderListContainer;
/// <summary>
/// The text to show when the settings is waitng for an async operation to finish.
/// </summary>
public TextElement WaitingTextElement => m_WaitingTextElement;
/// <summary>
/// The text to show when there is an error.
/// </summary>
public TextElement ErrorTextElement => m_ErrorTextElement;
/// <summary>
/// The add ID provider choices in the dropdown list.
/// </summary>
public IEnumerable<string> AddIdProviderTypeChoices => m_AddIdProviderTypeChoices;
/// <summary>
/// The add ID provider dropdown list.
/// </summary>
public PopupField<string> AddIdProviderType => m_AddIdProviderType;
/// <summary>
/// The button to refresh the ID provider list.
/// </summary>
public Button RefreshButton => m_RefreshButton;
/// <summary>
/// The button to add a new ID provider.
/// </summary>
public Button AddButton => m_AddButton;
/// <summary>
/// The container to add ID providers.
/// </summary>
public VisualElement IdProviderListContainer => m_IdProviderListContainer;
/// <summary>
/// Event triggered when the <cref="AuthenticationSettingsElement"/> starts or finishes waiting for an async operation.
/// The first parameter of the callback is the sender.
/// The second parameter is true if it starts waiting, and false if it finishes waiting.
/// </summary>
public event Action<AuthenticationSettingsElement, bool> Waiting;
public AuthenticationSettingsElement(IAuthenticationAdminClient adminClient, string projectId, bool skipConfirmation = false)
{
m_AdminClient = adminClient;
m_ProjectId = projectId;
m_SkipConfirmation = skipConfirmation;
var containerAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(k_Uxml);
if (containerAsset != null)
{
var containerUI = containerAsset.CloneTree().contentContainer;
var styleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>(k_Uss);
if (styleSheet != null)
{
containerUI.styleSheets.Add(styleSheet);
}
else
{
throw new Exception("Asset not found: " + k_Uss);
}
m_WaitingTextElement = containerUI.Q<TextElement>(className: "auth-progress");
m_ErrorTextElement = containerUI.Q<TextElement>(className: "auth-error");
m_RefreshButton = containerUI.Q<Button>("id-provider-refresh");
m_RefreshButton.clicked += RefreshIdProviders;
m_AddButton = containerUI.Q<Button>("id-provider-add");
m_AddButton.SetEnabled(false);
m_AddButton.clicked += AddIdProvider;
m_IdProviderListContainer = containerUI.Q<VisualElement>(className: "auth-id-provider-list");
m_AddIdProviderContainer = containerUI.Q<VisualElement>("id-provider-type");
Add(containerUI);
}
else
{
throw new Exception("Asset not found: " + k_Uxml);
}
}
public void RefreshIdProviders()
{
ShowWaiting();
if (m_IdDomainId == null)
{
GetIdDomain();
}
else
{
ListIdProviders();
}
}
void GetIdDomain()
{
var asyncOp = m_AdminClient.GetIDDomain();
asyncOp.Completed += OnGetIdDomainCompleted;
}
void OnGetIdDomainCompleted(IAsyncOperation<string> asyncOp)
{
if (asyncOp.Exception != null)
{
OnError(asyncOp.Exception);
return;
}
m_IdDomainId = asyncOp.Result;
ListIdProviders();
}
void ListIdProviders()
{
var asyncOp = m_AdminClient.ListIdProviders(m_IdDomainId);
asyncOp.Completed += OnListIdProvidersCompleted;
}
void OnListIdProvidersCompleted(IAsyncOperation<ListIdProviderResponse> asyncOp)
{
if (asyncOp.Exception != null)
{
OnError(asyncOp.Exception);
return;
}
m_IdProviderListContainer.Clear();
if (asyncOp.Result?.Results != null)
{
foreach (var provider in asyncOp.Result.Results)
{
CreateIdProviderElement(provider);
}
}
UpdateAddIdproviderList();
HideWaiting();
}
void UpdateAddIdproviderList()
{
var unusedIdProviders = new List<string>(IdProviderType.All);
foreach (var child in m_IdProviderListContainer.Children())
{
if (!(child is IdProviderElement))
{
continue;
}
var idProviderElement = (IdProviderElement)child;
unusedIdProviders.Remove(idProviderElement.SavedValue.Type);
}
unusedIdProviders.Sort();
m_AddIdProviderContainer.Clear();
m_AddIdProviderTypeChoices = unusedIdProviders;
if (unusedIdProviders.Count == 0)
{
m_AddButton.SetEnabled(false);
}
else
{
if (unusedIdProviders.Count > 0)
{
m_AddIdProviderType = new PopupField<string>(null, unusedIdProviders, 0);
m_AddIdProviderContainer.Add(m_AddIdProviderType);
}
m_AddButton.SetEnabled(true);
}
}
void AddIdProvider()
{
var idProvider = new IdProviderResponse
{
New = true,
Type = m_AddIdProviderType.value
};
CreateIdProviderElement(idProvider);
}
void OnError(Exception error)
{
error = AuthenticationSettingsHelper.ExtractException(error);
m_ErrorTextElement.style.display = DisplayStyle.Flex;
m_ErrorTextElement.text = AuthenticationSettingsHelper.ExceptionToString(error);
Debug.LogError(error);
HideWaiting();
}
void CreateIdProviderElement(IdProviderResponse idProvider)
{
var options = IdProviderOptions.GetOptions(idProvider.Type);
if (options == null)
{
// the SDK doesn't support the ID provider type yet. Skip.
return;
}
var idProviderElement = new IdProviderElement(m_IdDomainId, m_AdminClient, idProvider, options, m_SkipConfirmation);
m_IdProviderListContainer.Add(idProviderElement);
idProviderElement.Waiting += OnIdProviderWaiting;
idProviderElement.Deleted += OnIdProviderDeleted;
idProviderElement.Error += OnIdProviderError;
m_IdProviderListContainer.Add(idProviderElement);
UpdateAddIdproviderList();
}
void OnIdProviderWaiting(IdProviderElement sender, bool waiting)
{
if (waiting)
{
ShowWaiting();
}
else
{
HideWaiting();
}
}
void OnIdProviderDeleted(IdProviderElement sender)
{
m_IdProviderListContainer.Remove(sender);
UpdateAddIdproviderList();
}
void OnIdProviderError(IdProviderElement sender, Exception error)
{
OnError(error);
}
void ShowWaiting()
{
// clear previous error when a new async action is triggered.
m_ErrorTextElement.style.display = DisplayStyle.None;
m_ErrorTextElement.text = string.Empty;
m_WaitingTextElement.style.display = DisplayStyle.Flex;
SetEnabled(false);
Waiting?.Invoke(this, true);
}
void HideWaiting()
{
m_WaitingTextElement.style.display = DisplayStyle.None;
SetEnabled(true);
Waiting?.Invoke(this, false);
}
}
}

3
Packages/com.unity.services.authentication/Editor/AuthenticationSettingsElement.cs.meta


fileFormatVersion: 2
guid: 1f130c428a4b4feb9d46ecee3206cc34
timeCreated: 1620752364

47
Packages/com.unity.services.authentication/Editor/AuthenticationSettingsHelper.cs


using System;
namespace Unity.Services.Authentication.Editor
{
static class AuthenticationSettingsHelper
{
internal static Exception ExtractException(Exception exception)
{
var aggregatedException = exception as AggregateException;
if (aggregatedException == null)
{
return exception;
}
if (aggregatedException.InnerExceptions.Count > 1)
{
// There are multiple exceptions aggregated, don't try to extract exception.
return exception;
}
// It returns the first exception.
return aggregatedException.InnerException;
}
internal static string ExceptionToString(Exception exception)
{
var errorMessage = "[ERROR] ";
var currentError = exception;
var firstError = true;
while (currentError != null)
{
if (!firstError)
{
errorMessage += "\n---> ";
}
else
{
firstError = false;
}
errorMessage += currentError.Message;
currentError = currentError.InnerException;
}
return errorMessage;
}
}
}

3
Packages/com.unity.services.authentication/Editor/AuthenticationSettingsHelper.cs.meta


fileFormatVersion: 2
guid: 7caccdcd0f744a8d911a745661de6c5c
timeCreated: 1621631992

58
Packages/com.unity.services.authentication/Editor/AuthenticationSettingsProvider.cs


using System;
using System.Collections.Generic;
using Unity.Services.Core.Editor;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
namespace Unity.Services.Authentication.Editor
{
class AuthenticationSettingsProvider : EditorGameServiceSettingsProvider
{
const string k_Title = "Authentication";
AuthenticationSettingsProvider(SettingsScope scopes, IEnumerable<string> keywords = null)
: base(GenerateProjectSettingsPath(k_Title), scopes, keywords) {}
/// <summary>
/// Accessor for the operate service
/// Used to toggle and get dashboard access
/// </summary>
protected override IEditorGameService EditorGameService => EditorGameServiceRegistry.Instance.GetEditorGameService<AuthenticationIdentifier>();
/// <summary>
/// Title shown in the header for the project settings
/// </summary>
protected override string Title => k_Title;
/// <summary>
/// Description show in the header for the project settings
/// </summary>
protected override string Description => "This package provides a system for working with the Unity User Authentication Service (UAS), including log-in, player ID and access token retrieval, and session persistence.";
/// <inheritdoc/>
protected override VisualElement GenerateServiceDetailUI()
{
var settingsElement = new AuthenticationSettingsElement(AuthenticationAdminClientManager.Instance, CloudProjectSettings.projectId);
settingsElement.RefreshIdProviders();
return settingsElement;
}
/// <inheritdoc/>
protected override VisualElement GenerateUnsupportedDetailUI()
{
return GenerateServiceDetailUI();
}
/// <summary>
/// Method which adds your settings provider to ProjectSettings
/// </summary>
/// <returns>A <see cref="AuthenticationSettingsProvider"/>.</returns>
[SettingsProvider]
public static SettingsProvider CreateSettingsProvider()
{
return new AuthenticationSettingsProvider(SettingsScope.Project);
}
}
}

11
Packages/com.unity.services.authentication/Editor/AuthenticationSettingsProvider.cs.meta


fileFormatVersion: 2
guid: 78b5efd28d743406b8682bcb71c787a3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

20
Packages/com.unity.services.authentication/Editor/AuthenticationTopMenu.cs