@sphereon/ssi-express-support 0.18.2-next.3 → 0.18.2-unstable.10
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/auth-utils.d.ts +20 -20
- package/dist/auth-utils.js +143 -143
- package/dist/entra-id-auth.d.ts +9 -9
- package/dist/entra-id-auth.js +60 -60
- package/dist/express-builders.d.ts +99 -99
- package/dist/express-builders.js +279 -279
- package/dist/express-utils.d.ts +3 -3
- package/dist/express-utils.js +52 -52
- package/dist/functions.d.ts +1 -1
- package/dist/functions.js +10 -10
- package/dist/index.d.ts +8 -8
- package/dist/index.js +41 -41
- package/dist/openid-connect-rp.d.ts +53 -53
- package/dist/openid-connect-rp.js +213 -213
- package/dist/static-bearer-auth.d.ts +33 -33
- package/dist/static-bearer-auth.js +145 -145
- package/dist/types.d.ts +193 -193
- package/dist/types.js +7 -7
- package/package.json +2 -2
- package/src/express-utils.ts +47 -47
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.MapBasedStaticBearerUserProvider = exports.StaticBearerAuth = void 0;
|
|
30
|
-
const passport_1 = __importDefault(require("passport"));
|
|
31
|
-
const u8a = __importStar(require("uint8arrays"));
|
|
32
|
-
class StaticBearerAuth {
|
|
33
|
-
static init(strategy, provider) {
|
|
34
|
-
return new StaticBearerAuth(strategy !== null && strategy !== void 0 ? strategy : 'bearer', provider !== null && provider !== void 0 ? provider : new MapBasedStaticBearerUserProvider(strategy));
|
|
35
|
-
}
|
|
36
|
-
constructor(strategy, provider) {
|
|
37
|
-
this.hashTokens = false;
|
|
38
|
-
this.strategy = strategy;
|
|
39
|
-
if (StaticBearerAuth.providers.has(strategy)) {
|
|
40
|
-
if (StaticBearerAuth.providers.get(strategy) !== provider) {
|
|
41
|
-
throw Error('Cannot register another user provider for strategy: ' + strategy);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
StaticBearerAuth.providers.set(strategy, provider);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
get provider() {
|
|
49
|
-
const provider = StaticBearerAuth.providers.get(this.strategy);
|
|
50
|
-
if (!provider) {
|
|
51
|
-
throw Error('Could not get user provider for ' + this.strategy);
|
|
52
|
-
}
|
|
53
|
-
return provider;
|
|
54
|
-
}
|
|
55
|
-
withHashTokens(hashTokens) {
|
|
56
|
-
this.hashTokens = hashTokens;
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
withUsers(users) {
|
|
60
|
-
this.addUser(users);
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
addUser(user) {
|
|
64
|
-
this.provider.addUser(user);
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
withVerifyOptions(options) {
|
|
68
|
-
StaticBearerAuth.verifyOptions.set(this.strategy, options);
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
connectPassport() {
|
|
72
|
-
const _provider = this.provider;
|
|
73
|
-
function findUser(token, cb) {
|
|
74
|
-
const user = _provider.getUser(token);
|
|
75
|
-
if (user) {
|
|
76
|
-
return cb(null, user);
|
|
77
|
-
}
|
|
78
|
-
return cb('bearer token not found or incorrect', false);
|
|
79
|
-
}
|
|
80
|
-
Promise.resolve().then(() => __importStar(require('passport-http-bearer'))).then((httpBearer) => {
|
|
81
|
-
var _a;
|
|
82
|
-
const hashTokens = (_a = this.hashTokens) !== null && _a !== void 0 ? _a : false;
|
|
83
|
-
passport_1.default.use(this.strategy, new httpBearer.Strategy({ passReqToCallback: false }, function (token, cb) {
|
|
84
|
-
if (hashTokens) {
|
|
85
|
-
Promise.resolve().then(() => __importStar(require('@noble/hashes/sha256'))).then((hash) => {
|
|
86
|
-
findUser(u8a.toString(hash.sha256(token)), cb);
|
|
87
|
-
})
|
|
88
|
-
.catch((error) => {
|
|
89
|
-
console.log(`hash problem: ${error}`);
|
|
90
|
-
throw Error('Did you include @noble/hashes in package.json?');
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
findUser(token, cb);
|
|
95
|
-
}
|
|
96
|
-
}));
|
|
97
|
-
})
|
|
98
|
-
.catch((error) => {
|
|
99
|
-
console.log(`passport-http-bearer package problem: ${error}`);
|
|
100
|
-
throw Error('Did you include passport-http-bearer in package.json?');
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exports.StaticBearerAuth = StaticBearerAuth;
|
|
105
|
-
StaticBearerAuth.providers = new Map();
|
|
106
|
-
StaticBearerAuth.verifyOptions = new Map();
|
|
107
|
-
class MapBasedStaticBearerUserProvider {
|
|
108
|
-
constructor(strategy, hashedTokens) {
|
|
109
|
-
this._users = [];
|
|
110
|
-
this._strategy = strategy;
|
|
111
|
-
this._hashedTokens = hashedTokens !== null && hashedTokens !== void 0 ? hashedTokens : false;
|
|
112
|
-
}
|
|
113
|
-
get users() {
|
|
114
|
-
return this._users;
|
|
115
|
-
}
|
|
116
|
-
get hashedTokens() {
|
|
117
|
-
return this._hashedTokens;
|
|
118
|
-
}
|
|
119
|
-
get strategy() {
|
|
120
|
-
return this._strategy;
|
|
121
|
-
}
|
|
122
|
-
getUser(token) {
|
|
123
|
-
return this.users.find((user) => user.token === token);
|
|
124
|
-
}
|
|
125
|
-
addUser(user, hashToken) {
|
|
126
|
-
const users = Array.isArray(user) ? user : [user];
|
|
127
|
-
if (hashToken) {
|
|
128
|
-
if (!this.hashedTokens) {
|
|
129
|
-
throw Error('Cannot hash token, when hashed tokens is not enabled on the user provider for strategy ' + this.strategy);
|
|
130
|
-
}
|
|
131
|
-
Promise.resolve().then(() => __importStar(require('@noble/hashes/sha256'))).then((hash) => {
|
|
132
|
-
users.forEach((user) => (user.token = u8a.toString(hash.sha256(user.token))));
|
|
133
|
-
})
|
|
134
|
-
.catch((error) => {
|
|
135
|
-
console.log(`hash problem: ${error}`);
|
|
136
|
-
throw Error('Did you include @noble/hashes in package.json?');
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
this._users.push(...users);
|
|
140
|
-
}
|
|
141
|
-
getUsers() {
|
|
142
|
-
return this._users;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
exports.MapBasedStaticBearerUserProvider = MapBasedStaticBearerUserProvider;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.MapBasedStaticBearerUserProvider = exports.StaticBearerAuth = void 0;
|
|
30
|
+
const passport_1 = __importDefault(require("passport"));
|
|
31
|
+
const u8a = __importStar(require("uint8arrays"));
|
|
32
|
+
class StaticBearerAuth {
|
|
33
|
+
static init(strategy, provider) {
|
|
34
|
+
return new StaticBearerAuth(strategy !== null && strategy !== void 0 ? strategy : 'bearer', provider !== null && provider !== void 0 ? provider : new MapBasedStaticBearerUserProvider(strategy));
|
|
35
|
+
}
|
|
36
|
+
constructor(strategy, provider) {
|
|
37
|
+
this.hashTokens = false;
|
|
38
|
+
this.strategy = strategy;
|
|
39
|
+
if (StaticBearerAuth.providers.has(strategy)) {
|
|
40
|
+
if (StaticBearerAuth.providers.get(strategy) !== provider) {
|
|
41
|
+
throw Error('Cannot register another user provider for strategy: ' + strategy);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
StaticBearerAuth.providers.set(strategy, provider);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
get provider() {
|
|
49
|
+
const provider = StaticBearerAuth.providers.get(this.strategy);
|
|
50
|
+
if (!provider) {
|
|
51
|
+
throw Error('Could not get user provider for ' + this.strategy);
|
|
52
|
+
}
|
|
53
|
+
return provider;
|
|
54
|
+
}
|
|
55
|
+
withHashTokens(hashTokens) {
|
|
56
|
+
this.hashTokens = hashTokens;
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
withUsers(users) {
|
|
60
|
+
this.addUser(users);
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
addUser(user) {
|
|
64
|
+
this.provider.addUser(user);
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
withVerifyOptions(options) {
|
|
68
|
+
StaticBearerAuth.verifyOptions.set(this.strategy, options);
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
connectPassport() {
|
|
72
|
+
const _provider = this.provider;
|
|
73
|
+
function findUser(token, cb) {
|
|
74
|
+
const user = _provider.getUser(token);
|
|
75
|
+
if (user) {
|
|
76
|
+
return cb(null, user);
|
|
77
|
+
}
|
|
78
|
+
return cb('bearer token not found or incorrect', false);
|
|
79
|
+
}
|
|
80
|
+
Promise.resolve().then(() => __importStar(require('passport-http-bearer'))).then((httpBearer) => {
|
|
81
|
+
var _a;
|
|
82
|
+
const hashTokens = (_a = this.hashTokens) !== null && _a !== void 0 ? _a : false;
|
|
83
|
+
passport_1.default.use(this.strategy, new httpBearer.Strategy({ passReqToCallback: false }, function (token, cb) {
|
|
84
|
+
if (hashTokens) {
|
|
85
|
+
Promise.resolve().then(() => __importStar(require('@noble/hashes/sha256'))).then((hash) => {
|
|
86
|
+
findUser(u8a.toString(hash.sha256(token)), cb);
|
|
87
|
+
})
|
|
88
|
+
.catch((error) => {
|
|
89
|
+
console.log(`hash problem: ${error}`);
|
|
90
|
+
throw Error('Did you include @noble/hashes in package.json?');
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
findUser(token, cb);
|
|
95
|
+
}
|
|
96
|
+
}));
|
|
97
|
+
})
|
|
98
|
+
.catch((error) => {
|
|
99
|
+
console.log(`passport-http-bearer package problem: ${error}`);
|
|
100
|
+
throw Error('Did you include passport-http-bearer in package.json?');
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.StaticBearerAuth = StaticBearerAuth;
|
|
105
|
+
StaticBearerAuth.providers = new Map();
|
|
106
|
+
StaticBearerAuth.verifyOptions = new Map();
|
|
107
|
+
class MapBasedStaticBearerUserProvider {
|
|
108
|
+
constructor(strategy, hashedTokens) {
|
|
109
|
+
this._users = [];
|
|
110
|
+
this._strategy = strategy;
|
|
111
|
+
this._hashedTokens = hashedTokens !== null && hashedTokens !== void 0 ? hashedTokens : false;
|
|
112
|
+
}
|
|
113
|
+
get users() {
|
|
114
|
+
return this._users;
|
|
115
|
+
}
|
|
116
|
+
get hashedTokens() {
|
|
117
|
+
return this._hashedTokens;
|
|
118
|
+
}
|
|
119
|
+
get strategy() {
|
|
120
|
+
return this._strategy;
|
|
121
|
+
}
|
|
122
|
+
getUser(token) {
|
|
123
|
+
return this.users.find((user) => user.token === token);
|
|
124
|
+
}
|
|
125
|
+
addUser(user, hashToken) {
|
|
126
|
+
const users = Array.isArray(user) ? user : [user];
|
|
127
|
+
if (hashToken) {
|
|
128
|
+
if (!this.hashedTokens) {
|
|
129
|
+
throw Error('Cannot hash token, when hashed tokens is not enabled on the user provider for strategy ' + this.strategy);
|
|
130
|
+
}
|
|
131
|
+
Promise.resolve().then(() => __importStar(require('@noble/hashes/sha256'))).then((hash) => {
|
|
132
|
+
users.forEach((user) => (user.token = u8a.toString(hash.sha256(user.token))));
|
|
133
|
+
})
|
|
134
|
+
.catch((error) => {
|
|
135
|
+
console.log(`hash problem: ${error}`);
|
|
136
|
+
throw Error('Did you include @noble/hashes in package.json?');
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
this._users.push(...users);
|
|
140
|
+
}
|
|
141
|
+
getUsers() {
|
|
142
|
+
return this._users;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.MapBasedStaticBearerUserProvider = MapBasedStaticBearerUserProvider;
|
|
146
146
|
//# sourceMappingURL=static-bearer-auth.js.map
|