@springmicro/auth 0.5.15 → 0.5.17

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.
@@ -1,155 +1,157 @@
1
- // https://github.com/casdoor/casdoor/blob/master/web/src/backend/ApplicationBackend.js
2
-
3
- // Copyright 2021 The Casdoor Authors. All Rights Reserved.
4
- //
5
- // Licensed under the Apache License, Version 2.0 (the "License");
6
- // you may not use this file except in compliance with the License.
7
- // You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing, software
12
- // distributed under the License is distributed on an "AS IS" BASIS,
13
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- // See the License for the specific language governing permissions and
15
- // limitations under the License.
16
-
17
- import * as Setting from "./core";
18
-
19
- export function getApplications(
20
- owner: string,
21
- page = "",
22
- pageSize = "",
23
- field = "",
24
- value = "",
25
- sortField = "",
26
- sortOrder = ""
27
- ) {
28
- return fetch(
29
- `${Setting.ROOT_URLS.casdoor}/api/get-applications?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`,
30
- {
31
- method: "GET",
32
- credentials: "include",
33
- headers: {
34
- "Accept-Language": Setting.getAcceptLanguage(),
35
- },
36
- }
37
- ).then((res) => res.json());
38
- }
39
-
40
- export function getApplicationsByOrganization(
41
- owner: string,
42
- organization: string,
43
- page = "",
44
- pageSize = "",
45
- field = "",
46
- value = "",
47
- sortField = "",
48
- sortOrder = ""
49
- ) {
50
- return fetch(
51
- `${Setting.ROOT_URLS.casdoor}/api/get-organization-applications?owner=${owner}&organization=${organization}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`,
52
- {
53
- method: "GET",
54
- credentials: "include",
55
- headers: {
56
- "Accept-Language": Setting.getAcceptLanguage(),
57
- },
58
- }
59
- ).then((res) => res.json());
60
- }
61
-
62
- export function getApplication(owner: string, name: string) {
63
- return fetch(
64
- `${
65
- Setting.ROOT_URLS.casdoor
66
- }/api/get-application?id=${owner}/${encodeURIComponent(name)}`,
67
- {
68
- method: "GET",
69
- credentials: "include",
70
- headers: {
71
- "Content-Type": "application/json",
72
- },
73
- }
74
- ).then((res) => res.json());
75
- }
76
-
77
- export function getUserApplication(owner: string, name: string) {
78
- return fetch(
79
- `${
80
- Setting.ROOT_URLS.casdoor
81
- }/api/get-user-application?id=${owner}/${encodeURIComponent(name)}`,
82
- {
83
- method: "GET",
84
- credentials: "include",
85
- headers: {
86
- "Accept-Language": Setting.getAcceptLanguage(),
87
- },
88
- }
89
- ).then((res) => res.json());
90
- }
91
-
92
- export function updateApplication(
93
- owner: string,
94
- name: string,
95
- application: string
96
- ) {
97
- return fetch(
98
- `${
99
- Setting.ROOT_URLS.casdoor
100
- }/api/update-application?id=${owner}/${encodeURIComponent(name)}`,
101
- {
102
- method: "POST",
103
- credentials: "include",
104
- body: JSON.stringify(application),
105
- headers: {
106
- "Accept-Language": Setting.getAcceptLanguage(),
107
- },
108
- }
109
- ).then((res) => res.json());
110
- }
111
-
112
- export function addApplication(application: string) {
113
- const newApplication = Setting.deepCopy(application);
114
- return fetch(`${Setting.ROOT_URLS.casdoor}/api/add-application`, {
115
- method: "POST",
116
- credentials: "include",
117
- body: JSON.stringify(newApplication),
118
- headers: {
119
- "Accept-Language": Setting.getAcceptLanguage(),
120
- },
121
- }).then((res) => res.json());
122
- }
123
-
124
- export function deleteApplication(application: string) {
125
- const newApplication = Setting.deepCopy(application);
126
- return fetch(`${Setting.ROOT_URLS.casdoor}/api/delete-application`, {
127
- method: "POST",
128
- credentials: "include",
129
- body: JSON.stringify(newApplication),
130
- headers: {
131
- "Accept-Language": Setting.getAcceptLanguage(),
132
- },
133
- }).then((res) => res.json());
134
- }
135
-
136
- export function getSamlMetadata(
137
- owner: string,
138
- name: string,
139
- enablePostBinding: boolean
140
- ) {
141
- return fetch(
142
- `${
143
- Setting.ROOT_URLS.casdoor
144
- }/api/saml/metadata?application=${owner}/${encodeURIComponent(
145
- name
146
- )}&enablePostBinding=${enablePostBinding}`,
147
- {
148
- method: "GET",
149
- credentials: "include",
150
- headers: {
151
- "Accept-Language": Setting.getAcceptLanguage(),
152
- },
153
- }
154
- ).then((res) => res.text());
155
- }
1
+ // https://github.com/casdoor/casdoor/blob/master/web/src/backend/ApplicationBackend.js
2
+
3
+ // Copyright 2021 The Casdoor Authors. All Rights Reserved.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 (the "License");
6
+ // you may not use this file except in compliance with the License.
7
+ // You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing, software
12
+ // distributed under the License is distributed on an "AS IS" BASIS,
13
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ // See the License for the specific language governing permissions and
15
+ // limitations under the License.
16
+
17
+ import * as Setting from "./core";
18
+
19
+ export function getApplications(
20
+ owner: string,
21
+ page = "",
22
+ pageSize = "",
23
+ field = "",
24
+ value = "",
25
+ sortField = "",
26
+ sortOrder = ""
27
+ ) {
28
+ return fetch(
29
+ `${Setting.ROOT_URLS.casdoor}/api/get-applications?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`,
30
+ {
31
+ method: "GET",
32
+ credentials: "include",
33
+ headers: {
34
+ "Accept-Language": Setting.getAcceptLanguage(),
35
+ },
36
+ }
37
+ ).then((res) => res.json());
38
+ }
39
+
40
+ export function getApplicationsByOrganization(
41
+ owner: string,
42
+ organization: string,
43
+ page = "",
44
+ pageSize = "",
45
+ field = "",
46
+ value = "",
47
+ sortField = "",
48
+ sortOrder = ""
49
+ ) {
50
+ return fetch(
51
+ `${Setting.ROOT_URLS.casdoor}/api/get-organization-applications?owner=${owner}&organization=${organization}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`,
52
+ {
53
+ method: "GET",
54
+ credentials: "include",
55
+ headers: {
56
+ "Accept-Language": Setting.getAcceptLanguage(),
57
+ },
58
+ }
59
+ ).then((res) => res.json());
60
+ }
61
+
62
+ export function getApplication(owner: string, name: string) {
63
+ return fetch(
64
+ `${
65
+ Setting.ROOT_URLS.casdoor
66
+ }/api/get-application?id=${owner}/${encodeURIComponent(name)}`,
67
+ {
68
+ method: "GET",
69
+ credentials: Setting.ROOT_URLS.casdoor.startsWith("https")
70
+ ? "include"
71
+ : undefined,
72
+ headers: {
73
+ "Content-Type": "application/json",
74
+ },
75
+ }
76
+ ).then((res) => res.json());
77
+ }
78
+
79
+ export function getUserApplication(owner: string, name: string) {
80
+ return fetch(
81
+ `${
82
+ Setting.ROOT_URLS.casdoor
83
+ }/api/get-user-application?id=${owner}/${encodeURIComponent(name)}`,
84
+ {
85
+ method: "GET",
86
+ credentials: "include",
87
+ headers: {
88
+ "Accept-Language": Setting.getAcceptLanguage(),
89
+ },
90
+ }
91
+ ).then((res) => res.json());
92
+ }
93
+
94
+ export function updateApplication(
95
+ owner: string,
96
+ name: string,
97
+ application: string
98
+ ) {
99
+ return fetch(
100
+ `${
101
+ Setting.ROOT_URLS.casdoor
102
+ }/api/update-application?id=${owner}/${encodeURIComponent(name)}`,
103
+ {
104
+ method: "POST",
105
+ credentials: "include",
106
+ body: JSON.stringify(application),
107
+ headers: {
108
+ "Accept-Language": Setting.getAcceptLanguage(),
109
+ },
110
+ }
111
+ ).then((res) => res.json());
112
+ }
113
+
114
+ export function addApplication(application: string) {
115
+ const newApplication = Setting.deepCopy(application);
116
+ return fetch(`${Setting.ROOT_URLS.casdoor}/api/add-application`, {
117
+ method: "POST",
118
+ credentials: "include",
119
+ body: JSON.stringify(newApplication),
120
+ headers: {
121
+ "Accept-Language": Setting.getAcceptLanguage(),
122
+ },
123
+ }).then((res) => res.json());
124
+ }
125
+
126
+ export function deleteApplication(application: string) {
127
+ const newApplication = Setting.deepCopy(application);
128
+ return fetch(`${Setting.ROOT_URLS.casdoor}/api/delete-application`, {
129
+ method: "POST",
130
+ credentials: "include",
131
+ body: JSON.stringify(newApplication),
132
+ headers: {
133
+ "Accept-Language": Setting.getAcceptLanguage(),
134
+ },
135
+ }).then((res) => res.json());
136
+ }
137
+
138
+ export function getSamlMetadata(
139
+ owner: string,
140
+ name: string,
141
+ enablePostBinding: boolean
142
+ ) {
143
+ return fetch(
144
+ `${
145
+ Setting.ROOT_URLS.casdoor
146
+ }/api/saml/metadata?application=${owner}/${encodeURIComponent(
147
+ name
148
+ )}&enablePostBinding=${enablePostBinding}`,
149
+ {
150
+ method: "GET",
151
+ credentials: "include",
152
+ headers: {
153
+ "Accept-Language": Setting.getAcceptLanguage(),
154
+ },
155
+ }
156
+ ).then((res) => res.text());
157
+ }