@tdacorp/identity-client 0.2.2 → 0.2.3
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/dist/{chunk-TTFIPEZ3.js → chunk-MB66JUMG.js} +12 -2
- package/dist/index.cjs +12 -2
- package/dist/index.js +1 -1
- package/dist/next.cjs +11 -1
- package/dist/next.js +1 -1
- package/package.json +2 -2
|
@@ -129,6 +129,16 @@ var TokenRequestError = class extends Error {
|
|
|
129
129
|
this.errorDescription = details.errorDescription;
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
|
+
async function fetchDiscoveryForTokenRequest(issuer) {
|
|
133
|
+
try {
|
|
134
|
+
return await fetchDiscovery(issuer);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
throw new TokenRequestError({
|
|
137
|
+
error: "discovery_failed",
|
|
138
|
+
errorDescription: error instanceof Error ? error.message : "Failed to fetch the issuer's discovery document"
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
132
142
|
function toTokenSet(body) {
|
|
133
143
|
return {
|
|
134
144
|
accessToken: body.access_token,
|
|
@@ -159,7 +169,7 @@ async function readTokenResponseBody(response) {
|
|
|
159
169
|
return await response.json().catch(() => null);
|
|
160
170
|
}
|
|
161
171
|
async function exchangeAuthorizationCode(options) {
|
|
162
|
-
const discovery = await
|
|
172
|
+
const discovery = await fetchDiscoveryForTokenRequest(options.issuer);
|
|
163
173
|
const response = await postTokenRequest(
|
|
164
174
|
discovery.token_endpoint,
|
|
165
175
|
options.clientId,
|
|
@@ -179,7 +189,7 @@ async function exchangeAuthorizationCode(options) {
|
|
|
179
189
|
return toTokenSet(body);
|
|
180
190
|
}
|
|
181
191
|
async function clientCredentialsGrant(options) {
|
|
182
|
-
const discovery = await
|
|
192
|
+
const discovery = await fetchDiscoveryForTokenRequest(options.issuer);
|
|
183
193
|
const response = await postTokenRequest(
|
|
184
194
|
discovery.token_endpoint,
|
|
185
195
|
options.clientId,
|
package/dist/index.cjs
CHANGED
|
@@ -166,6 +166,16 @@ var TokenRequestError = class extends Error {
|
|
|
166
166
|
this.errorDescription = details.errorDescription;
|
|
167
167
|
}
|
|
168
168
|
};
|
|
169
|
+
async function fetchDiscoveryForTokenRequest(issuer) {
|
|
170
|
+
try {
|
|
171
|
+
return await fetchDiscovery(issuer);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
throw new TokenRequestError({
|
|
174
|
+
error: "discovery_failed",
|
|
175
|
+
errorDescription: error instanceof Error ? error.message : "Failed to fetch the issuer's discovery document"
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
169
179
|
function toTokenSet(body) {
|
|
170
180
|
return {
|
|
171
181
|
accessToken: body.access_token,
|
|
@@ -196,7 +206,7 @@ async function readTokenResponseBody(response) {
|
|
|
196
206
|
return await response.json().catch(() => null);
|
|
197
207
|
}
|
|
198
208
|
async function exchangeAuthorizationCode(options) {
|
|
199
|
-
const discovery = await
|
|
209
|
+
const discovery = await fetchDiscoveryForTokenRequest(options.issuer);
|
|
200
210
|
const response = await postTokenRequest(
|
|
201
211
|
discovery.token_endpoint,
|
|
202
212
|
options.clientId,
|
|
@@ -216,7 +226,7 @@ async function exchangeAuthorizationCode(options) {
|
|
|
216
226
|
return toTokenSet(body);
|
|
217
227
|
}
|
|
218
228
|
async function clientCredentialsGrant(options) {
|
|
219
|
-
const discovery = await
|
|
229
|
+
const discovery = await fetchDiscoveryForTokenRequest(options.issuer);
|
|
220
230
|
const response = await postTokenRequest(
|
|
221
231
|
discovery.token_endpoint,
|
|
222
232
|
options.clientId,
|
package/dist/index.js
CHANGED
package/dist/next.cjs
CHANGED
|
@@ -157,6 +157,16 @@ var TokenRequestError = class extends Error {
|
|
|
157
157
|
this.errorDescription = details.errorDescription;
|
|
158
158
|
}
|
|
159
159
|
};
|
|
160
|
+
async function fetchDiscoveryForTokenRequest(issuer) {
|
|
161
|
+
try {
|
|
162
|
+
return await fetchDiscovery(issuer);
|
|
163
|
+
} catch (error) {
|
|
164
|
+
throw new TokenRequestError({
|
|
165
|
+
error: "discovery_failed",
|
|
166
|
+
errorDescription: error instanceof Error ? error.message : "Failed to fetch the issuer's discovery document"
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
160
170
|
function toTokenSet(body) {
|
|
161
171
|
return {
|
|
162
172
|
accessToken: body.access_token,
|
|
@@ -187,7 +197,7 @@ async function readTokenResponseBody(response) {
|
|
|
187
197
|
return await response.json().catch(() => null);
|
|
188
198
|
}
|
|
189
199
|
async function exchangeAuthorizationCode(options) {
|
|
190
|
-
const discovery = await
|
|
200
|
+
const discovery = await fetchDiscoveryForTokenRequest(options.issuer);
|
|
191
201
|
const response = await postTokenRequest(
|
|
192
202
|
discovery.token_endpoint,
|
|
193
203
|
options.clientId,
|
package/dist/next.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tdacorp/identity-client",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "OIDC relying-party client for TDACorp Identity: discovery, PKCE, token exchange, token verification and Next.js route helpers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bugs": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"jose": "^6.2.9",
|
|
58
|
-
"@tdacorp/identity-authz": "^0.2.
|
|
58
|
+
"@tdacorp/identity-authz": "^0.2.1"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"next": ">=14"
|