@owlmeans/oidc 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts ADDED
@@ -0,0 +1,116 @@
1
+ import type { AuthToken } from '@owlmeans/auth'
2
+ import type { AuthorizationService } from '@owlmeans/auth-common'
3
+ import type { BasicConfig, BasicContext } from '@owlmeans/context'
4
+ import type { GuardService } from '@owlmeans/module'
5
+
6
+ export interface Config extends BasicConfig { }
7
+ export interface Context<C extends Config = Config> extends BasicContext<C> { }
8
+
9
+ export interface OidcSharedConfig {
10
+ clientCookie?: {
11
+ interaction?: {
12
+ name?: string
13
+ ttl?: number
14
+ }
15
+ },
16
+ providers?: OidcProviderConfig[]
17
+ /**
18
+ * false - in case the service user can't use identity provider for authentication (restricted for internal use only)
19
+ * true - in case only default identity provider can be used
20
+ * string[] - list of allowed identity providers
21
+ */
22
+ restrictedProviders?: boolean | string[]
23
+ }
24
+
25
+ export interface OidcProviderConfig extends OidcProviderDescriptor {
26
+ // Use this flag to allow only internal use
27
+ internal?: boolean
28
+ // The client id that is used to administrate the underlying IAM service
29
+ apiClientId?: string
30
+ }
31
+
32
+ export interface OidcProviderDescriptor {
33
+ // Bound this client to sepcific organization entity
34
+ entityId?: string
35
+ service?: string
36
+ discoveryUrl?: string
37
+ basePath?: string
38
+ clientId: string
39
+ secret?: string
40
+ extraScopes?: string
41
+ idOverride?: string
42
+ // This flag works only on client side. It specifies a default relying party
43
+ def?: boolean
44
+ }
45
+
46
+
47
+ export interface WithSharedConfig {
48
+ oidc: OidcSharedConfig
49
+ }
50
+
51
+ export interface OidcGuard extends GuardService {
52
+ }
53
+
54
+ export interface OidcGuardOptions {
55
+ cache?: string
56
+ coguards: string | string[]
57
+ tokenService?: string
58
+ }
59
+
60
+ export interface OIDCAuthInitParams {
61
+ entity?: string
62
+ profile?: string
63
+ }
64
+
65
+ // @TODO replace arbitarary Record params with specific possible params for OIDC
66
+ export interface OIDCClientAuthPayload extends Record<string, string> {
67
+ code: string
68
+ authUrl: string
69
+ }
70
+
71
+ export interface WrappedOIDCService extends AuthorizationService {
72
+ }
73
+
74
+ export interface OIDCTokenUpdate extends AuthToken {
75
+ tokenSet: CommonTokenSetParams
76
+ }
77
+
78
+ export interface CommonTokenSetParams extends Record<string, string | number | undefined> {
79
+ access_token?: string
80
+ token_type?: string
81
+ id_token?: string
82
+ refresh_token?: string
83
+ scope?: string
84
+
85
+ expires_at?: number
86
+ session_state?: string
87
+ }
88
+
89
+
90
+ export interface ProviderProfileDetails extends Partial<OidcUserDetails> {
91
+ type: string
92
+ service: string
93
+ clientId: string
94
+ userId: string
95
+ profileId?: string
96
+ }
97
+
98
+ export interface OidcUserDetails {
99
+ userId: string
100
+ username: string
101
+ entityId?: string
102
+ did?: string
103
+ // This flag is used to identify OwlMeans ID and OwlMeans IAM user
104
+ // The presence of OlwMeans ID exactly is defined by presence of the did field
105
+ // alongisde this flag set to true
106
+ // In general sence this flag is used to denounce that the authenticated
107
+ // profile belongs to the governining organization.
108
+ // So if the flag is ended up being true - it may also mean that the user
109
+ // is governed by an organization that uses OwlMeans IAM solutions on premises basis.
110
+ // Actually it makes this property untrasferable between different app services.
111
+ isOwlMeansId?: boolean
112
+ }
113
+
114
+ export interface OidcProviderSettings {
115
+ registrationEnabled: boolean
116
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": [
3
+ "../tsconfig.default.json",
4
+ ],
5
+ "compilerOptions": {
6
+ "rootDir": "./src/", /* Specify the root folder within your source files. */
7
+ "outDir": "./build/", /* Specify an output folder for all emitted files. */
8
+ "moduleResolution": "Bundler",
9
+ },
10
+ "exclude": [
11
+ "./dist/**/*",
12
+ "./build/**/*",
13
+ "./*.ts"
14
+ ]
15
+ }