I tried to migrate my ASP CORE project to NET6
My project uses next packages
IdentityServer4.AccessTokenValidation - 3.0.1
IdentityModel.AspNetCore.OAuth2Introspection - 4.0.1
IdentityModel - 5.2.0
The build of project is success.
But when I run application I get error
MissingMethodException: Method not found: 'IdentityModel.Client.DiscoveryEndpoint IdentityModel.Client.DiscoveryEndpoint.ParseUrl(System.String)'.
IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationOptions.ConfigureJwtBearer(JwtBearerOptions jwtOptions)
IdentityServer4.AccessTokenValidation.ConfigureInternalOptions.Configure(string name, JwtBearerOptions options)
Microsoft.Extensions.Options.OptionsFactory<TOptions>.Create(string name)
Microsoft.Extensions.Options.OptionsMonitor<TOptions>+<>c__DisplayClass10_0.<Get>b__0()
Anybody had this issue ?
Roman's answer is correct, we can fix it by doing the IdentityModel downgrade, but another way to fix that issue is by replacing the IdentityServer4.AccessTokenValidation by Microsoft.AspNetCore.Authentication.JwtBearer, and we can change a little bit the token validation, using IdentityServer4.AccessTokenValidation we were doing the validation like this:
services
.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(
options =>
{
options.Authority = configuration["Authentication:Authority"];
options.ApiName = configuration["Authentication:ApiName"];
});
Now we can do the token validation using the Microsoft.AspNetCore.Authentication.JwtBearer like that:
services
.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.Authority = configuration["Authentication:Authority"];
options.RequireHttpsMetadata = false;
options.TokenValidationParameters.ValidAudiences = new List<string>() { configuration["Authentication:ApiName"] };
});
I investigated this problem and found cause.
I used IdentityModel V 4,2,2 before update.
When I update my project to NET 6, IdentityModel was upgrated to version 5.2.0.
The difference between IdentityModel V 4,2,2 and IdentityModel version 5.2.0 was in signature method.
public static DiscoveryEndpoint ParseUrl(string input, string path = null) version 5,2,0
public static DiscoveryEndpoint ParseUrl(string input) version 4,2,2
So we see that in new version default parameter was added.
But this method is called by method from IdentityServer4.AccessTokenValidation package. And this package was not compiled to call updated ParseUrl function.
See this topic about this problem c# method with default parameter value does not generate overload without parameter?
IdentityServer4.AccessTokenValidation library is deprecated, and hence does not have a version, which is compiled against IdentityModel version 5.2.0.
You should use the new approach described in https://leastprivilege.com/2020/07/06/flexible-access-token-validation-in-asp-net-core/
Related
When I make a change to my react-app, and it tries to reload, I get the following error:
/path/to/app/node_modules/webpack/lib/node/NodeWatchFileSystem.js:50
changes = changes.concat(removals);
^
TypeError: changes.concat is not a function
I then have to restart my react app in order for the changes to be reflected.
This started when we did a bunch of fiddling with versions of different packages, so I suspect that there's some combination of packages that webpack is not happy with, but I don't know which ones, or how to figure that out.
Just in case it's relevant, though I don't think it is, here's the webpack section of my craco.config.js:
webpack: {
plugins: [
new DefinePlugin({
BRAND_NAME: '"My app"'
})
],
configure: webpackConfig => {
const instanceOfMiniCssExtractPlugin = webpackConfig.plugins.find(
plugin => plugin instanceof MiniCssExtractPlugin
);
if (instanceOfMiniCssExtractPlugin)
instanceOfMiniCssExtractPlugin.options.ignoreOrder = true;
return webpackConfig;
}
}
Package.json link
Webpack and Watchpack Versions
The error seems to be in reference to v4 of webpack (or earlier). This function was reworked in v5 of webpack, where it now no longer assumes changes is an array (it's now an iterable that is only iterated if inputFileSystem.purge is defined).
From the resolution section of package.json, it looks like you're resolving watchpack to version 2.2.0. From the v2 release notes, it looks like it changed its API to now pass sets instead of arrays to watcher.once("aggregated", (changes, removals) => {...}), breaking v4 of webpack.
Updating to version 5 of webpack may solve this particular issue (though you may need to upgrade other packages that depend on webpack v4, like webpack-cli). Alternatively, downgrading watchpack to before version 2 (like version 1.7.5) might also work, though this may also introduce new issues.
Please check your array before performing the concat operation. You can also use the Array.from() method before using concat. For example,
const arr1 = ['a', 'b'];
const arr2=['d', 'c'];
const arr3 = Array.isArray(arr1) ? arr1.concat(arr2) : []; //check if arr1 is a array
const arr4=Array.from(arr1).concat(arr2); //use type conversion.
Try the above methods in the node modules folder of where the error is from.
I want the best method to implement these two lines.
Goal: Obtain the object of a smart contract named dev-token.
async function ... {
...
const web3 = new Web3(Web3.givenProvider);
const devtoken = await new web3.Contract(abi,address);
...
}
Warning during execution:
MetaMask: The event 'close' is deprecated and may be removed in the
future. Please use 'disconnect' instead. For more information, see:
https://eips.ethereum.org/EIPS/eip-1193#disconnect
Cordially
I had the same problem due to an out-of-date version of the web3.js library. I was using version 1.2 imported from the jsdelivr CDN like this:
<script src="https://cdn.jsdelivr.net/npm/web3#1.2/dist/web3.min.js"></script>
The warnings went away when I updated to the current version of web3.js (1.7.3 at the time of this writting). However, the version distributed in the jsdelivr CDN has other problems, so I had to deliver from my own server the one downloaded by npm:
<script src="./web3.min.js"></script>
I have installed react-native-version-check by yarn into my project when I use some functions the app crash sending me this message:
WARN [TypeError: Network request failed]
this only happens when I'm using these functions only:
VersionCheck.getLatestVersion()
VersionCheck.needUpdate()
The same thing happens using react-native-check-version package function
There has been some unresolved issues regarding this package and especially those functions that you mentioned. I had faced the same issue previously, my suggestion would be to go with a backend driven version check. You can maintain a table to store the latest version, force update flag, etc. Also since these 2 functions are promise, you can check what they are returning.
VersionCheck.getLatestVersion({
forceUpdate: true,
provider: () => fetch('http://your.own/api')
.then(r => r.json())
.then(({version}) => version), // You can get latest version from your own api.
}).then(latestVersion =>{
console.log(latestVersion);
});
VersionCheck.needUpdate()
.then(async res => {
console.log(res.isNeeded); // true
if (res.isNeeded) {
Linking.openURL(res.storeUrl); // open store if update is needed.
}
});
After some search in the library to know what was making this error
it was actually the fetch API
I had to put these lines of code in my build.gradle
dependencies {
api(platform("com.squareup.okhttp3:okhttp-bom:4.7.2"))
api("com.squareup.okhttp3:okhttp")
api("com.squareup.okhttp3:logging-interceptor")
}
after adding those lines everything worked just fine
version "react-native-version-check": "^3.4.3", is up to date
documentation link:
https://www.npmjs.com/package/react-native-version-check?activeTab=versions
I'm working through the NativeScript getting started tutorial in TypeScript:
http://developer.telerik.com/featured/getting-started-nativescript/
In one snippet of code, I see:
exports.loadSignUpView = function(args) {
page = args.object;
page.bindingContext = journeyInfo;
}
After some research I was able to type args as
import app = require("application");
exports.loadSignUpView = function(args: app.ApplicationEventData) {
//...
}
But that still does not help me type the page object above, which has the bindingContext property. What is the TypeScript type that corresponds to the page?
Page type is defined in the "ui/page" module and the type of the args of the loaded event is EventData (from the "data/observable" module).
So you can do something like this:
import observable = require("data/observable");
import pages = require("ui/page");
// Event handler for Page "loaded" event attached in main-page.xml
export function loadSignUpView (args: observable.EventData) {
// Get the event sender
var page = <pages.Page>args.object;
}
Few more useful tips to get you started:
NativeScript has TypeScript support build in since the 1.5 release. You can now use the NativeScript CLI to setup typescript project. You can check the documentation for more.
In the documentation there is more up to date getting-started guide
All of the code snippets in the docs have also a TypeScript version so that you can see the typings there - we love typescript ;)
I get the following error "ReferenceError: printStackTrace is not defined",
when I tried to use StackTrace in my angular aplication.
stacktrace.js changed the API for v1.0.
You'll want to use
var callback = function(frames) { console.log(frames); };
var errback = function(err) { console.log(err.message); };
StackTrace.get().then(callback).catch(errback);
as suggested by the docs.
If all you want to do is parse an Error you can just use error-stack-parser
Please refer to the v0.x -> v1.x migration guide if you were using the old version.
By the way, if you need to use version 0.x you can find it in the stable branch on GitHub