@tesouro/embedded-components-widget-token 0.2.222 → 0.2.238
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/index.js +2 -6
- package/dist/index2.js +51 -80
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { DEFAULT_EXPIRATION_IN_SECONDS as
|
|
2
|
-
export {
|
|
3
|
-
r as DEFAULT_EXPIRATION_IN_SECONDS,
|
|
4
|
-
t as configureCreateWidgetToken,
|
|
5
|
-
T as createWidgetToken
|
|
6
|
-
};
|
|
1
|
+
import { DEFAULT_EXPIRATION_IN_SECONDS as e, configureCreateWidgetToken as t, createWidgetToken as n } from "./index2.js";
|
|
2
|
+
export { e as DEFAULT_EXPIRATION_IN_SECONDS, t as configureCreateWidgetToken, n as createWidgetToken };
|
package/dist/index2.js
CHANGED
|
@@ -1,82 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { EncryptJWT as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
jti: d.randomUUID(),
|
|
41
|
-
...a ? { organization_reference: a } : {},
|
|
42
|
-
subject_token: g,
|
|
43
|
-
subject_token_type: "urn:ietf:params:oauth:token-type:access_token"
|
|
44
|
-
};
|
|
45
|
-
return { widgetToken: await new y(p).setProtectedHeader({
|
|
46
|
-
alg: "A256KW",
|
|
47
|
-
enc: "A256GCM",
|
|
48
|
-
kid: e,
|
|
49
|
-
typ: "JWT",
|
|
50
|
-
cty: "JWT"
|
|
51
|
-
}).encrypt(u), exp: n };
|
|
1
|
+
import e from "crypto";
|
|
2
|
+
import { EncryptJWT as t } from "jose";
|
|
3
|
+
//#region src/lib/createWidgetToken.ts
|
|
4
|
+
var n = 480;
|
|
5
|
+
async function r({ clientId: n, clientSecret: r, widgetSecret: i, userId: a, userEmail: o, organizationReference: s, expirationInSeconds: c = 480 }) {
|
|
6
|
+
if (!i || !n || !r) throw Error("Missing required parameters for widget token generation: clientId, clientSecret, and widgetSecret are required");
|
|
7
|
+
let l = Math.floor(Date.now() / 1e3), u = l + c, d = new TextEncoder().encode(i), f = {
|
|
8
|
+
sub: a,
|
|
9
|
+
email: o,
|
|
10
|
+
aud: "tesouro",
|
|
11
|
+
iss: n,
|
|
12
|
+
exp: u,
|
|
13
|
+
iat: l
|
|
14
|
+
}, p = Buffer.from(JSON.stringify({
|
|
15
|
+
alg: "none",
|
|
16
|
+
typ: "JWT"
|
|
17
|
+
})).toString("base64url") + "." + Buffer.from(JSON.stringify(f)).toString("base64url") + ".", m = {
|
|
18
|
+
aud: "tesouro",
|
|
19
|
+
client_id: n,
|
|
20
|
+
client_secret: r,
|
|
21
|
+
exp: u,
|
|
22
|
+
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
|
|
23
|
+
iat: l,
|
|
24
|
+
iss: n,
|
|
25
|
+
jti: e.randomUUID(),
|
|
26
|
+
...s ? { organization_reference: s } : {},
|
|
27
|
+
subject_token: p,
|
|
28
|
+
subject_token_type: "urn:ietf:params:oauth:token-type:access_token"
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
widgetToken: await new t(m).setProtectedHeader({
|
|
32
|
+
alg: "A256KW",
|
|
33
|
+
enc: "A256GCM",
|
|
34
|
+
kid: n,
|
|
35
|
+
typ: "JWT",
|
|
36
|
+
cty: "JWT"
|
|
37
|
+
}).encrypt(d),
|
|
38
|
+
exp: u
|
|
39
|
+
};
|
|
52
40
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// Defaults to the partner-config value bound at configure time. A per-call
|
|
64
|
-
// override supports partners whose single client serves multiple
|
|
65
|
-
// organizations; it must still be resolved server-side, never from the browser.
|
|
66
|
-
organizationReference: t = i,
|
|
67
|
-
expirationInSeconds: n = s
|
|
68
|
-
}) => T({
|
|
69
|
-
clientId: e,
|
|
70
|
-
clientSecret: o,
|
|
71
|
-
widgetSecret: r,
|
|
72
|
-
userId: a,
|
|
73
|
-
userEmail: c,
|
|
74
|
-
organizationReference: t,
|
|
75
|
-
expirationInSeconds: n
|
|
76
|
-
});
|
|
41
|
+
function i({ clientId: e, clientSecret: t, widgetSecret: n, organizationReference: i, expirationInSeconds: a }) {
|
|
42
|
+
return ({ userId: o, userEmail: s, organizationReference: c = i, expirationInSeconds: l = a }) => r({
|
|
43
|
+
clientId: e,
|
|
44
|
+
clientSecret: t,
|
|
45
|
+
widgetSecret: n,
|
|
46
|
+
userId: o,
|
|
47
|
+
userEmail: s,
|
|
48
|
+
organizationReference: c,
|
|
49
|
+
expirationInSeconds: l
|
|
50
|
+
});
|
|
77
51
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
b as configureCreateWidgetToken,
|
|
81
|
-
T as createWidgetToken
|
|
82
|
-
};
|
|
52
|
+
//#endregion
|
|
53
|
+
export { n as DEFAULT_EXPIRATION_IN_SECONDS, i as configureCreateWidgetToken, r as createWidgetToken };
|