anvilresearch / json-document Goto Github PK
View Code? Open in Web Editor NEWFast, declarative, standards-based JavaScript (ES6) data modeling & manipulation
License: MIT License
Fast, declarative, standards-based JavaScript (ES6) data modeling & manipulation
License: MIT License
Please update @trust/json-document to migrate to webpack5 as maintaining it in the Debian OS environment caused a bug as we try to build the package with webpack 5.65.0, as you still support of webpack1.13.1
here is a link to the bug report https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1002865
The failing build major output looks like this while building with webpack 5.65.0
debian/rules binary
dh binary
dh_update_autotools_config
dh_autoreconf
debian/rules override_dh_auto_build
make[1]: Entering directory '/home/ayoyimika/debian-js-packaging/trust-json-document/node-trust-json-document'
babeljs --no-babelrc src -d lib --presets=@babel/preset-env
Successfully compiled 10 files with Babel (4537ms).
webpack --output-filename json-document.js --mode development
asset json-document.js 99 bytes [emitted] (name: main)
ERROR in main
Module not found: Error: Recursion in resolving
Stack:
undefined: (/home/ayoyimika/debian-js-packaging/trust-json-document/node-trust-json-document) ./lib/index.js
webpack 5.65.0 compiled with 1 error in 191 ms
make[1]: *** [debian/rules:32: debian/js/json-document.min.js] Error 1
make[1]: Leaving directory '/home/ayoyimika/debian-js-packaging/trust-json-document/node-trust-json-document'
make: *** [debian/rules:48: binary] Error 2
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
A simple solution i proffer is migrating to webpack5 to have access to its updated features, benefits and options https://webpack.js.org/migrate/5/
Thanks and Cheers
A typical usage for json-document
validation is something like in jose/JWKSet.importKeys()
:
if (!validation.valid) {
return Promise.reject(validation)
}
However, Promise.reject()
, just like a regular throw
, is supposed to accept Error objects. For various historical reasons, throw
also accepts non-error objects (so you can throw a string, ie throw 'Something'
). Same with Promise.reject(). However, this is considered an anti-pattern, and Standard linters flag this as an error.
Now, a validation result is currently not an Error instance, it's its own object.
So the question before us is this: What's the best way to turn a validation result into an Error instance? I'm currently doing something like:
return Promise.reject(new Error(JSON.stringify(validation)))
but that feels hack-y. We should actually consider a .error
getter method on our validation result instances. (That would return a nice error instance, populated with a stringified validation error message.) So that the use can do:
return Promise.reject(validation.error)
There's a stray require('js-beautify')
in Initializer.js (though its actual usage is commented out). Let's remove it or add that lib to package.json
, cause it causes a 'cannot find module' error.
Example:
... properties: { id: { type: 'string'}, type: {type: 'string' },
Trace:
`
undefined:47
if (value !== undefined && ) {
^
SyntaxError: Unexpected token )
`
I suspect this one has something to do with the recent changes in schema validation (I'm on json-document v0.1.1
In jose/JWKSet.js#L30 in importKeys()
, I'm getting the following validation error:
{ valid: false,
errors:
[ { keyword: 'enum',
message: '["verify"] is not an enumerated value' },
{ keyword: 'enum',
message: '["verify"] is not an enumerated value' },
{ keyword: 'enum',
message: '["verify"] is not an enumerated value' },
{ keyword: 'enum',
message: '["verify"] is not an enumerated value' },
{ keyword: 'enum',
message: '["verify"] is not an enumerated value' },
{ keyword: 'enum',
message: '["verify"] is not an enumerated value' },
{ keyword: 'enum',
message: '["verify"] is not an enumerated value' } ] }
This is what the jwks
object that's being validated looks like:
{ keys:
[ { kid: 'E0lJdnSTmYg',
kty: 'RSA',
alg: 'RS256',
n: 'zXwQOoY8ITG5rpF3Sew1cKEHzmgRAA12JNS4OlFQosHO3e7NiNsHjRL8XKrsjkvaWMjmkfPEUagfMjbxgr6fNz0k2zO3F6S8loyWeO4ySc-GIVOas8SSdmTRIuHdeLyhZQicfbLZUSJOsFj7jLsf1QxDQ0ih8qqzM0L6Zud8REnh6W6i_60xxNnSm2mqgt9h9wS37kl38tGRme5xkBSKkvF-ADqBkJ7W9XcPuIVf3gkt5taVUhdgLEgG0PaJ_EffhjrgJB4YsSud0_fMqzlvMRhPSncuPTdRKd-WZEgzAycWGt5OAF3s75nBiyAdOMsTstQvM4rDFap6DdCiJPc-HQ',
e: 'AQAB',
key_ops: [Object],
ext: true },
{ kid: '9fo7nRnakQ0',
kty: 'RSA',
alg: 'RS384',
n: '2S-EiCzGE1tLQNUm1aKOAgCtcB_eoWHYql0AG6z7vapc2ZG8Ghw7d2QHzPbpr_Nz6eC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OfFubalmXZ-tiCl3Hw3VAju9S3Jvh9BCfNgw',
e: 'AQAB',
key_ops: [Object],
ext: true },
{ kid: 'fjKBx8JXLqk',
kty: 'RSA',
alg: 'RS384',
n: 'sobaYwYeoNl34J0TWpssfAa_TH1cznkmQnNek9R9IRRYXyNl9uK_yuCI6-4LKMvHrbbKOa1cpj_KsZL0-FZp8A8dLhA8P3eiaPVXctpscMWUNdlNDEeqRCl8G1hXu5HC4ugY5qHIMZBCZ-pmB6MRnrQj3NZLZ-QaESVIKxoF0NuzCe_brf-FQskUBFlA8r5T5k3gkicqHD16Ab0w5gyJCWT63ELkBV6u9WmbcDVyhll-Bl4y-v1ielCgi80UonVC-ujHtRj83tJusgKEeHZSjXUnIol5taQ5Fes8E4YdFKiMjuKxKNACO4hAI-KAGjRA0DKoSkOmGzJgisIvskL4Qw',
e: 'AQAB',
key_ops: [Object],
ext: true },
{ kid: 'dGQG5TrhK2w',
kty: 'RSA',
alg: 'RS512',
n: 'xOCBpS4HnLJVYl_ivBp6HldBECfgWBzmGKfsZNrt7k2jj2NXoo7wB3j_-7YxjTks3Mzsoi8epGq1m8FSN8U-ovpnFPtl9tpKxYk0sZJLmZY0ftBq-dAsGF5Ksq3IIK5a3pryiOeLiDR1BVCX-pMOJMgntfQUiePlk156c6xlRkoOOWlBgNfGT_pTDMi987wkkSjRR6Mw2sRAQzen10mpfDo0kxLHkaRj0YOzYFD-2xrD0SLzgNNnyxKCudTb_49aVzDJoo1uYMpuNZB5SPDGfMgL3-7sdJ3FvBoyhEiy1va5h-7PLpzd15tC6BKwUkupfwevPMg5-81G3s3aUeAJ5Q',
e: 'AQAB',
key_ops: [Object],
ext: true },
{ kid: 'T75lzOnV_Lk',
kty: 'RSA',
alg: 'RS256',
n: '6j3FJiqoZWcLcEBaAF7YG7JJmueoIcZdie7R3o7wlnd-0Hk8SYrBbyEKa5fUHRZfeNnaJ-ZGgeixsBxaoASypdB89Jz1iFD_A5I9MFo3mJ7XQTCndcvE9VtrTnnqwDdV1oN1KTnIiMGZ863-D3OditNbymR3N9080D5KCtACGgeKERWGgHZ89lceAoIccHxhyxtVo6T9kZ3JWpke92nPwiGwqUYAsNtJgUauqa6BjNaoNaiJBvMCUCdwQmq6KzNPCdz_OHaLxm8M90iYEfpfZlXPMP5jDXQW4rs2-BIIArqDssrpZ-lkonjM3lXvpHJxQlZuRKarwhjLdUL-cfbxrQ',
e: 'AQAB',
key_ops: [Object],
ext: true } ] }
The files test/JSONPatchSpec.js
and test/JSONPointerSpec.js
contains contents from RFC documents which are covered by licensing certainly not MIT and (by some definitions) not free.
Please consider removing that content, to ease (re)distribution e.g. by Debian-based distributions.
Several schemas downstream in @trust/jose
are intending to use format: 'case-sensitive'
property, when it becomes available.
This is a placeholder/reminder to implement support for this.
If we move JSONPatch.js
, JSONPointer.js
and JSONMapping.js
to an external lib, we will save about 15.5 kb of lib size (this is before minifying, but still).
They're being packaged up in every RP bundle, but aren't used.
Example output of a webpack
command for oidc-rp
:
...
[14] ../_auth/json-document/lib/JSONPatch.js 5.21 kB {0} [built]
[15] ../_auth/json-document/lib/JSONPointer.js 7.08 kB {0} [built]
[16] ../_auth/json-document/lib/JSONMapping.js 3.21 kB {0} [built]
...
Given a schema:
{
properties: {
signatures: {
type: 'array',
items: { type: 'object' }
}
}
}
and input: { signatures: [ { foo: 'bar' }, { baz: 'qux' } ] }
results in: { signatures: [ { foo: 'bar' } ] }
See the oidc-op
/IDTokenSchema
, the cnf
claim, for an example. (Seems to be failing).
It's making it hard to set up Travis CI / test incoming PRs.
To maintain a standard style across our repositories and to aid new contributors, I propose that we add EditorConfig files to our repositories and make a note of it in our READMEs.
Most editors (vim, Sublime, Atom, VSCode, etc.) have plugins for EditorConfig making it relatively easy to automate tab indentation size, UNIX line-endings and ensure that files end with a new line.
Please see the @trust/model README and .editorconfig file for the proposed configuration.
Properties that are not defined on the schema are being allowed on the output object without explicitly stating additionalProperties: true,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.