@omni-co/embed 0.1.4 → 0.1.5
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/lib/cjs/signature.d.ts +4 -1
- package/lib/cjs/signature.js +11 -8
- package/lib/esm/signature.d.ts +4 -1
- package/lib/esm/signature.js +10 -7
- package/package.json +3 -2
package/lib/cjs/signature.d.ts
CHANGED
|
@@ -35,5 +35,8 @@ type SignatureProps = {
|
|
|
35
35
|
*/
|
|
36
36
|
userAttributes?: string;
|
|
37
37
|
};
|
|
38
|
-
export declare const getSignature: ({
|
|
38
|
+
export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
|
|
39
|
+
export declare const TEST_ONLY: {
|
|
40
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, }: Omit<SignatureProps, "secret">) => string;
|
|
41
|
+
};
|
|
39
42
|
export {};
|
package/lib/cjs/signature.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getSignature = exports.hmacSign = void 0;
|
|
6
|
+
exports.TEST_ONLY = exports.getSignature = exports.hmacSign = void 0;
|
|
7
7
|
const crypto_1 = __importDefault(require("crypto"));
|
|
8
8
|
const hmacSign = (data, secret) => {
|
|
9
9
|
const hmac = crypto_1.default.createHmac("sha256", secret);
|
|
@@ -11,17 +11,20 @@ const hmacSign = (data, secret) => {
|
|
|
11
11
|
return hmac.digest("base64url");
|
|
12
12
|
};
|
|
13
13
|
exports.hmacSign = hmacSign;
|
|
14
|
-
const
|
|
15
|
-
const validationStr = `
|
|
14
|
+
const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, }) => `
|
|
16
15
|
${loginUrl}
|
|
17
16
|
${contentPath}
|
|
18
17
|
${externalId}
|
|
19
18
|
${name}
|
|
20
19
|
${nonce}
|
|
21
|
-
${userAttributes}
|
|
22
|
-
`
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
${userAttributes || ""}
|
|
21
|
+
`
|
|
22
|
+
.trim()
|
|
23
|
+
.replace(/\n\s+/g, "\n");
|
|
24
|
+
const getSignature = ({ secret, ...props }) => {
|
|
25
|
+
return (0, exports.hmacSign)(generateStringForSignature(props), secret);
|
|
26
26
|
};
|
|
27
27
|
exports.getSignature = getSignature;
|
|
28
|
+
exports.TEST_ONLY = {
|
|
29
|
+
generateStringForSignature,
|
|
30
|
+
};
|
package/lib/esm/signature.d.ts
CHANGED
|
@@ -35,5 +35,8 @@ type SignatureProps = {
|
|
|
35
35
|
*/
|
|
36
36
|
userAttributes?: string;
|
|
37
37
|
};
|
|
38
|
-
export declare const getSignature: ({
|
|
38
|
+
export declare const getSignature: ({ secret, ...props }: SignatureProps) => string;
|
|
39
|
+
export declare const TEST_ONLY: {
|
|
40
|
+
generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, }: Omit<SignatureProps, "secret">) => string;
|
|
41
|
+
};
|
|
39
42
|
export {};
|
package/lib/esm/signature.js
CHANGED
|
@@ -4,16 +4,19 @@ export const hmacSign = (data, secret) => {
|
|
|
4
4
|
hmac.update(data);
|
|
5
5
|
return hmac.digest("base64url");
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
const validationStr = `
|
|
7
|
+
const generateStringForSignature = ({ loginUrl, contentPath, externalId, name, nonce, userAttributes, }) => `
|
|
9
8
|
${loginUrl}
|
|
10
9
|
${contentPath}
|
|
11
10
|
${externalId}
|
|
12
11
|
${name}
|
|
13
12
|
${nonce}
|
|
14
|
-
${userAttributes}
|
|
15
|
-
`
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
${userAttributes || ""}
|
|
14
|
+
`
|
|
15
|
+
.trim()
|
|
16
|
+
.replace(/\n\s+/g, "\n");
|
|
17
|
+
export const getSignature = ({ secret, ...props }) => {
|
|
18
|
+
return hmacSign(generateStringForSignature(props), secret);
|
|
19
|
+
};
|
|
20
|
+
export const TEST_ONLY = {
|
|
21
|
+
generateStringForSignature,
|
|
19
22
|
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.
|
|
2
|
+
"version": "0.1.5",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "@omni-co/embed",
|
|
5
5
|
"author": "Nate Agrin <nate@exploreomni.com>",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"build": "npm run clean && tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
|
|
18
18
|
"clean": "rm -rf lib",
|
|
19
19
|
"prepublishOnly": "npm run build",
|
|
20
|
-
"test": "vitest"
|
|
20
|
+
"test": "vitest",
|
|
21
|
+
"test:watch": "vitest --watch"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
24
|
"nanoid": "^5.0.2"
|