-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathtypes.go
More file actions
99 lines (75 loc) · 3.01 KB
/
types.go
File metadata and controls
99 lines (75 loc) · 3.01 KB
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
/*
* Copyright (C) 2023 Nuts community
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
package iam
import (
"github.com/nuts-foundation/go-did/did"
"github.com/nuts-foundation/go-did/vc"
"github.com/nuts-foundation/nuts-node/auth/oauth"
"github.com/nuts-foundation/nuts-node/vcr/pe"
"github.com/nuts-foundation/nuts-node/vdr/resolver"
"slices"
"strings"
)
// DIDDocument is an alias
type DIDDocument = did.Document
// DIDDocumentMetadata is an alias
type DIDDocumentMetadata = resolver.DocumentMetadata
// VerifiablePresentation is an alias
type VerifiablePresentation = vc.VerifiablePresentation
// VerifiableCredential is an alias
type VerifiableCredential = vc.VerifiableCredential
// ErrorResponse is an alias
type ErrorResponse = oauth.OAuth2Error
// PresentationDefinition is an alias
type PresentationDefinition = pe.PresentationDefinition
// PresentationSubmission is an alias
type PresentationSubmission = pe.PresentationSubmission
type RedirectResponse = oauth.Redirect
// TokenResponse is an alias
type TokenResponse = oauth.TokenResponse
// OAuthAuthorizationServerMetadata is an alias
type OAuthAuthorizationServerMetadata = oauth.AuthorizationServerMetadata
// OAuthClientMetadata is an alias
type OAuthClientMetadata = oauth.OAuthClientMetadata
// WalletOwnerType is an alias
type WalletOwnerType = pe.WalletOwnerType
// RequiredPresentationDefinitions is an alias
type RequiredPresentationDefinitions = pe.WalletOwnerMapping
const (
// responseModeQuery returns the answer to the authorization request append as query parameters to the provided redirect_uri
responseModeQuery = "query" // default if no response_mode is specified
// responseModeDirectPost signals the Authorization Server to POST the requested presentation definition to the provided response_uri
responseModeDirectPost = "direct_post"
)
var responseModesSupported = []string{responseModeQuery, responseModeDirectPost}
var responseTypesSupported = []string{oauth.CodeResponseType, oauth.VPTokenResponseType}
var grantTypesSupported = []string{oauth.AuthorizationCodeGrantType, oauth.VpTokenGrantType}
var clientIdSchemesSupported = []string{entityClientIDScheme}
const entityClientIDScheme = "entity_id"
const (
AccessTokenTypeBearer = "Bearer"
AccessTokenTypeDPoP = "DPoP"
)
type Scope string
func (s Scope) Contains(scope string) bool {
if s == "" {
return false
}
scopes := strings.Split(scope, " ")
return slices.Contains(scopes, string(s))
}