@boxyhq/saml-jackson 0.2.3-beta.220 → 0.2.3-beta.222
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/package.json
CHANGED
package/src/controller/api.ts
CHANGED
@@ -4,8 +4,7 @@ import * as dbutils from '../db/utils';
|
|
4
4
|
import saml from '../saml/saml';
|
5
5
|
import { JacksonError } from './error';
|
6
6
|
import { IndexNames } from './utils';
|
7
|
-
|
8
|
-
const x509 = require('../saml/x509.js');
|
7
|
+
import x509 from '../saml/x509';
|
9
8
|
|
10
9
|
export class SAMLConfig implements ISAMLConfig {
|
11
10
|
private configStore: Storable;
|
@@ -17,9 +17,12 @@ const mapping = [
|
|
17
17
|
attribute: 'lastName',
|
18
18
|
schema: 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname',
|
19
19
|
},
|
20
|
-
];
|
20
|
+
] as const;
|
21
21
|
|
22
|
-
|
22
|
+
type attributes = typeof mapping[number]['attribute'];
|
23
|
+
type schemas = typeof mapping[number]['schema'];
|
24
|
+
|
25
|
+
const map = (claims: Record<attributes | schemas, unknown>) => {
|
23
26
|
const profile = {
|
24
27
|
raw: claims,
|
25
28
|
};
|
@@ -35,6 +38,4 @@ const map = (claims) => {
|
|
35
38
|
return profile;
|
36
39
|
};
|
37
40
|
|
38
|
-
|
39
|
-
map,
|
40
|
-
};
|
41
|
+
export default { map };
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import * as x509 from '@peculiar/x509';
|
2
|
+
import { Crypto } from '@peculiar/webcrypto';
|
3
3
|
|
4
4
|
const crypto = new Crypto();
|
5
5
|
x509.cryptoProvider.set(crypto);
|
@@ -14,16 +14,18 @@ const alg = {
|
|
14
14
|
const generate = async () => {
|
15
15
|
const keys = await crypto.subtle.generateKey(alg, true, ['sign', 'verify']);
|
16
16
|
|
17
|
-
const extensions = [
|
17
|
+
const extensions: x509.Extension[] = [
|
18
18
|
new x509.BasicConstraintsExtension(false, undefined, true),
|
19
19
|
];
|
20
20
|
|
21
21
|
extensions.push(
|
22
22
|
new x509.KeyUsagesExtension(x509.KeyUsageFlags.digitalSignature, true)
|
23
23
|
);
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
if (keys.publicKey) {
|
25
|
+
extensions.push(
|
26
|
+
await x509.SubjectKeyIdentifierExtension.create(keys.publicKey)
|
27
|
+
);
|
28
|
+
}
|
27
29
|
|
28
30
|
const cert = await x509.X509CertificateGenerator.createSelfSigned({
|
29
31
|
serialNumber: '01',
|
@@ -34,15 +36,16 @@ const generate = async () => {
|
|
34
36
|
keys: keys,
|
35
37
|
extensions,
|
36
38
|
});
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
if (keys.privateKey) {
|
40
|
+
const pkcs8 = await crypto.subtle.exportKey('pkcs8', keys.privateKey);
|
41
|
+
|
42
|
+
return {
|
43
|
+
publicKey: cert.toString('pem'),
|
44
|
+
privateKey: x509.PemConverter.encode(pkcs8, 'private key'),
|
45
|
+
};
|
46
|
+
}
|
44
47
|
};
|
45
48
|
|
46
|
-
|
49
|
+
export default {
|
47
50
|
generate,
|
48
51
|
};
|