Skip to content

Commit 03952db

Browse files
committed
update jsrsasign
1 parent c494f5d commit 03952db

File tree

8 files changed

+48
-19
lines changed

8 files changed

+48
-19
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"webpack-stream": "^3.2.0"
4646
},
4747
"dependencies": {
48-
"jsrsasign": "^5.0.7"
48+
"jsrsasign": "^8.0.12"
4949
},
5050
"peerDependencies": {
5151
"babel-polyfill": ">=6.9.1"

src/JoseUtil.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4-
import { jws, KEYUTIL as KeyUtil, X509, crypto, hextob64u } from 'jsrsasign';
4+
import { jws, KEYUTIL as KeyUtil, X509, crypto, hextob64u, b64tohex } from 'jsrsasign';
55
import Log from './Log';
66

77
const AllowedSigningAlgs = ['RS256', 'RS384', 'RS512', 'PS256', 'PS384', 'PS512', 'ES256', 'ES384', 'ES512'];
@@ -31,7 +31,8 @@ export default class JoseUtil {
3131
key = KeyUtil.getKey(key);
3232
}
3333
else if (key.x5c && key.x5c.length) {
34-
key = KeyUtil.getKey(X509.getPublicKeyFromCertPEM(key.x5c[0]));
34+
var hex = b64tohex(key.x5c[0]);
35+
key = X509.getPublicKeyFromCertHex(hex);
3536
}
3637
else {
3738
Log.error("RSA key missing key material", key);

test/unit/JoseUtil.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ describe("JoseUtil", function () {
104104

105105
describe("validateJwt", function () {
106106

107-
it("should validate from RSA X509 key", function (done) {
108-
107+
it.only("should validate from RSA X509 key", function (done, fail) {
108+
Log.level = Log.DEBUG;
109109
delete rsaKey.n;
110110
delete rsaKey.e;
111111

112112
JoseUtil.validateJwt(jwtFromRsa, rsaKey, expectedIssuer, expectedAudience, 0, expectedNow).then(()=>{
113113
done();
114-
})
114+
});
115115

116116
});
117117

test/unit/JsonService.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ describe("JsonService", function() {
3333
it("should return a promise", function() {
3434
let p = subject.getJson("http://test");
3535
p.should.be.instanceof(Promise);
36+
p.catch(e=>{});
3637
});
3738

3839
it("should make GET request to url", function() {

test/unit/MetadataService.spec.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import MetadataService from '../../src/MetadataService';
77
import StubJsonService from './StubJsonService';
88

99
import chai from 'chai';
10+
import { Z_NO_COMPRESSION } from 'zlib';
1011
chai.should();
1112
let assert = chai.assert;
1213

@@ -43,7 +44,9 @@ describe("MetadataService", function() {
4344
describe("getMetadata", function() {
4445

4546
it("should return a promise", function() {
46-
subject.getMetadata().should.be.instanceof(Promise);
47+
var p = subject.getMetadata();
48+
p.should.be.instanceof(Promise);
49+
p.catch(e=>{});
4750
});
4851

4952
it("should use metadata on settings", function(done) {
@@ -130,7 +133,9 @@ describe("MetadataService", function() {
130133
describe("_getMetadataProperty", function() {
131134

132135
it("should return a promise", function() {
133-
subject._getMetadataProperty().should.be.instanceof(Promise);
136+
var p = subject._getMetadataProperty();
137+
p.should.be.instanceof(Promise);
138+
p.catch(e=>{});
134139
});
135140

136141
it("should use metadata on settings", function(done) {
@@ -285,7 +290,9 @@ describe("MetadataService", function() {
285290
describe("getSigningKeys", function() {
286291

287292
it("should return a promise", function() {
288-
subject.getSigningKeys().should.be.instanceof(Promise);
293+
var p = subject.getSigningKeys();
294+
p.should.be.instanceof(Promise);
295+
p.catch(e=>{});
289296
});
290297

291298
it("should use signingKeys on settings", function(done) {

test/unit/OidcClient.spec.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import StubStateStore from './StubStateStore';
2020
import StubResponseValidator from './StubResponseValidator';
2121

2222
import chai from 'chai';
23+
import { Z_NO_COMPRESSION } from 'zlib';
2324
chai.should();
2425
let assert = chai.assert;
2526

@@ -98,7 +99,9 @@ describe("OidcClient", function () {
9899

99100
it("should return a promise", function () {
100101
stubMetadataService.getAuthorizationEndpointResult = Promise.resolve("http://sts/authorize");
101-
subject.createSigninRequest().should.be.instanceof(Promise);
102+
var p = subject.createSigninRequest();
103+
p.should.be.instanceof(Promise);
104+
p.catch(e=>{});
102105
});
103106

104107
it("should return SigninRequest", function (done) {
@@ -234,7 +237,9 @@ describe("OidcClient", function () {
234237
describe("processSigninResponse", function () {
235238

236239
it("should return a promise", function () {
237-
subject.processSigninResponse("state=state").should.be.instanceof(Promise);
240+
var p = subject.processSigninResponse("state=state");
241+
p.should.be.instanceof(Promise);
242+
p.catch(e=>{});
238243
});
239244

240245
it("should fail if no state on response", function (done) {
@@ -273,7 +278,9 @@ describe("OidcClient", function () {
273278

274279
it("should return a promise", function () {
275280
stubMetadataService.getEndSessionEndpointResult = Promise.resolve("http://sts/signout");
276-
subject.createSignoutRequest().should.be.instanceof(Promise);
281+
var p = subject.createSignoutRequest();
282+
p.should.be.instanceof(Promise);
283+
p.catch(e=>{});
277284
});
278285

279286
it("should return SignoutRequest", function (done) {
@@ -375,7 +382,9 @@ describe("OidcClient", function () {
375382
describe("processSignoutResponse", function () {
376383

377384
it("should return a promise", function () {
378-
subject.processSignoutResponse("state=state").should.be.instanceof(Promise);
385+
var p = subject.processSignoutResponse("state=state");
386+
p.should.be.instanceof(Promise);
387+
p.catch(e=>{});
379388
});
380389

381390
it("should return result if no state on response", function (done) {
@@ -427,7 +436,9 @@ describe("OidcClient", function () {
427436
describe("clearStaleState", function () {
428437

429438
it("should return a promise", function () {
430-
subject.clearStaleState().should.be.instanceof(Promise);
439+
var p = subject.clearStaleState();
440+
p.should.be.instanceof(Promise);
441+
p.catch(e=>{});
431442
});
432443

433444
it("should call State.clearStaleState", function () {

test/unit/UserInfoService.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ describe("UserInfoService", function() {
4242
describe("getClaims", function() {
4343

4444
it("should return a promise", function() {
45-
subject.getClaims().should.be.instanceof(Promise);
45+
var p = subject.getClaims();
46+
p.should.be.instanceof(Promise);
47+
p.catch(e=>{});
4648
});
4749

4850
it("should require a token", function(done) {

test/unit/WebStorageStateStore.spec.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ describe("WebStorageStateStore", function() {
2424
describe("set", function() {
2525

2626
it("should return a promise", function() {
27-
subject.set("key", "value").should.be.instanceof(Promise);
27+
var p = subject.set("key", "value");
28+
p.should.be.instanceof(Promise);
29+
p.catch(e=>{});
2830
});
2931

3032
it("should store item", function(done) {
@@ -49,7 +51,9 @@ describe("WebStorageStateStore", function() {
4951
describe("remove", function() {
5052

5153
it("should return a promise", function() {
52-
subject.remove("key").should.be.instanceof(Promise);
54+
var p = subject.remove("key");
55+
p.should.be.instanceof(Promise);
56+
p.catch(e=>{});
5357
});
5458

5559
it("should remove item", function(done) {
@@ -94,7 +98,8 @@ describe("WebStorageStateStore", function() {
9498
describe("get", function() {
9599

96100
it("should return a promise", function() {
97-
subject.get("key").should.be.instanceof(Promise);
101+
var p = subject.get("key");
102+
p.should.be.instanceof(Promise);
98103
});
99104

100105
it("should return value if exists", function(done) {
@@ -130,7 +135,9 @@ describe("WebStorageStateStore", function() {
130135
describe("getAllKeys", function() {
131136

132137
it("should return a promise", function() {
133-
subject.getAllKeys().should.be.instanceof(Promise);
138+
var p = subject.getAllKeys();
139+
p.should.be.instanceof(Promise);
140+
p.catch(e=>{});
134141
});
135142

136143
it("should return keys", function(done) {

0 commit comments

Comments
 (0)