diff --git a/dist/jwtauth/AuthorizationBadge.d.ts b/dist/jwtauth/AuthorizationBadge.d.ts index 4ff8684..5f6af84 100644 --- a/dist/jwtauth/AuthorizationBadge.d.ts +++ b/dist/jwtauth/AuthorizationBadge.d.ts @@ -5,14 +5,11 @@ import { RolesConfig } from "../secureConfig"; */ export declare class AuthorizationBadge { private readonly rolesConfig?; - giftbitUserId: string; + userId: string; teamMemberId: string; merchantId: string; - cardId: string; - templateId: string; + valueId: string; programId: string; - contactUserSuppliedId: string; - shopperId: string; contactId: string; serviceId: string; metadata: { @@ -34,10 +31,21 @@ export declare class AuthorizationBadge { assumeJwtIdentity(jwtPayload: JwtPayload): AuthorizationBadge; /** * Require that the given IDs are set on the badge. - * eg: requireIds("giftbitUserId", "merchantId"); + * eg: requireIds("userId", "merchantId"); + */ + requireIds(...ids: ("userId" | "teamMemberId" | "merchantId" | "valueId" | "programId" | "contactId" | "serviceId")[]): void; + /** + * @deprecated use hasScope, because the name is clearer */ - requireIds(...ids: ("giftbitUserId" | "teamMemberId" | "merchantId" | "cardId" | "templateId" | "programId" | "contactUserSuppliedId" | "shopperId" | "contactId" | "serviceId")[]): void; isBadgeAuthorized(scope: string): boolean; + /** + * Returns true if this badge contains the given scope or any parent of the scope. + */ + hasScope(scope: string): boolean; + /** + * Returns true if the badge has all the given scopes. + */ + hasScopes(...scopes: string[]): boolean; /** * Require that the given scopes are authorized on the badge. * Throws a RestError if they are not. diff --git a/dist/jwtauth/AuthorizationBadge.js b/dist/jwtauth/AuthorizationBadge.js index 751f8f8..ef545e0 100644 --- a/dist/jwtauth/AuthorizationBadge.js +++ b/dist/jwtauth/AuthorizationBadge.js @@ -13,14 +13,11 @@ class AuthorizationBadge { this.effectiveScopes = []; if (jwtPayload) { if (jwtPayload.g) { - this.giftbitUserId = jwtPayload.g.gui; + this.userId = jwtPayload.g.gui; this.teamMemberId = jwtPayload.g.tmi; this.merchantId = jwtPayload.g.gmi; - this.cardId = jwtPayload.g.gci; - this.templateId = jwtPayload.g.gti; + this.valueId = jwtPayload.g.gvi; this.programId = jwtPayload.g.pid; - this.contactUserSuppliedId = jwtPayload.g.cui; - this.shopperId = jwtPayload.g.shi; this.contactId = jwtPayload.g.coi; this.serviceId = jwtPayload.g.si; } @@ -51,8 +48,8 @@ class AuthorizationBadge { const payload = { g: {} }; - if (this.giftbitUserId) { - payload.g.gui = this.giftbitUserId; + if (this.userId) { + payload.g.gui = this.userId; } if (this.teamMemberId) { payload.g.tmi = this.teamMemberId; @@ -60,21 +57,12 @@ class AuthorizationBadge { if (this.merchantId) { payload.g.gmi = this.merchantId; } - if (this.cardId) { - payload.g.gci = this.cardId; - } - if (this.templateId) { - payload.g.gti = this.templateId; + if (this.valueId) { + payload.g.gvi = this.valueId; } if (this.programId) { payload.g.pid = this.programId; } - if (this.contactUserSuppliedId) { - payload.g.cui = this.contactUserSuppliedId; - } - if (this.shopperId) { - payload.g.shi = this.shopperId; - } if (this.contactId) { payload.g.coi = this.contactId; } @@ -123,7 +111,7 @@ class AuthorizationBadge { assumeJwtIdentity(jwtPayload) { this.requireScopes("ASSUME"); const j = this.getJwtPayload(); - j.g = Object.assign({}, jwtPayload.g, { si: this.giftbitUserId }); + j.g = Object.assign({}, jwtPayload.g, { si: this.userId }); j.parentJti = jwtPayload.jti; const badge = new AuthorizationBadge(j, this.rolesConfig); badge.scopes = badge.scopes.filter(scope => scope !== "ASSUME"); @@ -132,7 +120,7 @@ class AuthorizationBadge { } /** * Require that the given IDs are set on the badge. - * eg: requireIds("giftbitUserId", "merchantId"); + * eg: requireIds("userId", "merchantId"); */ requireIds(...ids) { for (let id of ids) { @@ -141,7 +129,16 @@ class AuthorizationBadge { } } } + /** + * @deprecated use hasScope, because the name is clearer + */ isBadgeAuthorized(scope) { + return this.hasScope(scope); + } + /** + * Returns true if this badge contains the given scope or any parent of the scope. + */ + hasScope(scope) { for (; scope; scope = getParentScope(scope)) { if (this.effectiveScopes.indexOf(scope) !== -1) { return true; @@ -149,24 +146,32 @@ class AuthorizationBadge { } return false; } + /** + * Returns true if the badge has all the given scopes. + */ + hasScopes(...scopes) { + for (let scope of scopes) { + if (!this.hasScope(scope)) { + return false; + } + } + return true; + } /** * Require that the given scopes are authorized on the badge. * Throws a RestError if they are not. */ requireScopes(...scopes) { - for (let scope of scopes) { - if (!this.isBadgeAuthorized(scope)) { - throw new cassava.RestError(cassava.httpStatusCode.clientError.FORBIDDEN); - } + if (!this.hasScopes(...scopes)) { + throw new cassava.RestError(cassava.httpStatusCode.clientError.FORBIDDEN); } } /** * Save the merchant from themselves. */ sanitizeMerchantSigned() { - this.merchantId = this.giftbitUserId; - if (!this.contactUserSuppliedId && !this.shopperId && !this.contactId) { - this.shopperId = "defaultShopper"; + this.merchantId = this.userId; + if (!this.contactId) { this.contactId = "defaultShopper"; } this.roles = ["shopper"]; // This might be a whitelist in the future. @@ -208,7 +213,7 @@ class AuthorizationBadge { return effectiveScopes; } isTestUser() { - return this.giftbitUserId && this.giftbitUserId.endsWith("-TEST"); + return this.userId && this.userId.endsWith("-TEST"); } } exports.AuthorizationBadge = AuthorizationBadge; diff --git a/dist/jwtauth/AuthorizationBadge.js.map b/dist/jwtauth/AuthorizationBadge.js.map index a68e7a7..a6b5341 100644 --- a/dist/jwtauth/AuthorizationBadge.js.map +++ b/dist/jwtauth/AuthorizationBadge.js.map @@ -1 +1 @@ -{"version":3,"file":"AuthorizationBadge.js","sourceRoot":"","sources":["../../src/jwtauth/AuthorizationBadge.ts"],"names":[],"mappings":";;AAAA,mCAAmC;AACnC,oCAAoC;AAIpC;;GAEG;AACH;IAyBI,YAAY,UAAuB,EAAmB,WAAyB;QAAzB,gBAAW,GAAX,WAAW,CAAc;QAJ/E,UAAK,GAAa,EAAE,CAAC;QACrB,WAAM,GAAa,EAAE,CAAC;QACtB,oBAAe,GAAa,EAAE,CAAC;QAG3B,IAAI,UAAU,EAAE;YACZ,IAAI,UAAU,CAAC,CAAC,EAAE;gBACd,IAAI,CAAC,aAAa,GAAG,UAAU,C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eAAe,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC,cAAc,KAAK,KAAK,IAAI,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE;gBACjK,eAAe,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;aAC/C;QACL,CAAC,CAAC,CAAC;QAEP,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED,UAAU;QACN,OAAO,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACtE,CAAC;CACJ;AA1PD,gDA0PC;AAED,wBAAwB,KAAa;IACjC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACrC,OAAO,IAAI,CAAC;KACf;IAED,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,eAAe,KAAK,CAAC,CAAC,EAAE;QACxB,OAAO,IAAI,CAAC;KACf;IAED,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;AAC/C,CAAC"} \ No newline at end of file +{"version":3,"file":"AuthorizationBadge.js","sourceRoot":"","sources":["../../src/jwtauth/AuthorizationBadge.ts"],"names":[],"mappings":";;AAAA,mCAAmC;AACnC,oCAAoC;AAIpC;;GAEG;AACH;IAuBI,YAAY,UAAuB,EAAmB,WAAyB;QAAzB,gBAAW,GAAX,WAAW,CAAc;QAJ/E,UAAK,GAAa,EAAE,CAAC;QACrB,WAAM,GAAa,EAAE,CAAC;QACtB,oBAAe,GAAa,EAAE,CAAC;QAG3B,IAAI,UAAU,EAAE;YACZ,IAAI,UAAU,CAAC,CAAC,EAAE;gBACd,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;gBAC/B,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,CA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wBAAwB,KAAa;IACjC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACrC,OAAO,IAAI,CAAC;KACf;IAED,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,eAAe,KAAK,CAAC,CAAC,EAAE;QACxB,OAAO,IAAI,CAAC;KACf;IAED,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;AAC/C,CAAC"} \ No newline at end of file diff --git a/dist/jwtauth/JwtPayload.d.ts b/dist/jwtauth/JwtPayload.d.ts index a6021d7..3b3c1e5 100644 --- a/dist/jwtauth/JwtPayload.d.ts +++ b/dist/jwtauth/JwtPayload.d.ts @@ -7,11 +7,8 @@ export interface JwtPayload { gui?: string; tmi?: string; gmi?: string; - gci?: string; - gti?: string; + gvi?: string; pid?: string; - cui?: string; - shi?: string; coi?: string; si?: string; }; diff --git a/dist/jwtauth/JwtPayload.js.map b/dist/jwtauth/JwtPayload.js.map index 14fbc1c..827272d 100644 --- a/dist/jwtauth/JwtPayload.js.map +++ b/dist/jwtauth/JwtPayload.js.map @@ -1 +1 @@ -{"version":3,"file":"JwtPayload.js","sourceRoot":"","sources":["../../src/jwtauth/JwtPayload.ts"],"names":[],"mappings":";;AA4BA,IAAiB,UAAU,CAI1B;AAJD,WAAiB,UAAU;IACvB,oBAA2B,OAAmB;QAC1C,OAAO,OAAO,IAAI,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpF,CAAC;IAFe,qBAAU,aAEzB,CAAA;AACL,CAAC,EAJgB,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAI1B"} \ No newline at end of file +{"version":3,"file":"JwtPayload.js","sourceRoot":"","sources":["../../src/jwtauth/JwtPayload.ts"],"names":[],"mappings":";;AAyBA,IAAiB,UAAU,CAI1B;AAJD,WAAiB,UAAU;IACvB,oBAA2B,OAAmB;QAC1C,OAAO,OAAO,IAAI,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpF,CAAC;IAFe,qBAAU,aAEzB,CAAA;AACL,CAAC,EAJgB,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAI1B"} \ No newline at end of file diff --git a/dist/jwtauth/merchantSharedKey/RestMerchantKeyProvider.d.ts b/dist/jwtauth/merchantSharedKey/RestMerchantKeyProvider.d.ts index 4ab0df1..acc75c6 100644 --- a/dist/jwtauth/merchantSharedKey/RestMerchantKeyProvider.d.ts +++ b/dist/jwtauth/merchantSharedKey/RestMerchantKeyProvider.d.ts @@ -1,4 +1,4 @@ -import { AssumeScopeToken } from "../../secureConfig/AssumeScopeToken"; +import { AssumeScopeToken } from "../../secureConfig"; import { MerchantKeyProvider } from "./MerchantKeyProvider"; export declare class RestMerchantKeyProvider implements MerchantKeyProvider { private readonly merchantKeyUri; diff --git a/dist/sentry/index.js.map b/dist/sentry/index.js.map index 7efd98c..aaf43b9 100644 --- a/dist/sentry/index.js.map +++ b/dist/sentry/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sentry/index.ts"],"names":[],"mappings":";;;;;;;;;;AAEA,+BAA+B;AAI/B,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB,IAAI,MAAM,GAAoC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAE1E,IAAI,YAAY,GAAiB;IAC7B,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,EAAE;CACZ,CAAC;AAUF;;;;GAIG;AACH,2BAAkC,OAAiC;IAC/D,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;QACrC,MA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AC,CAAC;QACzD,OAAO;KACV;IAED,KAAK,CAAC,gBAAgB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;AAC9C,CAAC;AATD,sDASC"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4f7c90d..fc2d645 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "giftbit-cassava-routes", - "version": "7.0.0", + "version": "7.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -13,10 +13,16 @@ "samsam": "1.3.0" } }, + "@sinonjs/samsam": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-2.0.0.tgz", + "integrity": "sha512-D7VxhADdZbDJ0HjUTMnSQ5xIGb4H2yWpg8k9Sf1T08zfFiQYlaxM8LZydpR4FQ2E6LZJX8IlabNZ5io4vdChwg==", + "dev": true + }, "@types/aws-lambda": { - "version": "8.10.7", - "resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.7.tgz", - "integrity": "sha512-oBt6+WHA9ViJwbUXiU7oIKrshD7bnco21vrqMlti3pWwhkAS90OaXSuZbgYiVLBQ5kvYDkKoU+uKTXoy6tzJpw==", + "version": "8.10.8", + "resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.8.tgz", + "integrity": "sha512-k7JhthzujQ98BAdIDU60H9i4v+9yq4zUJQDMpWuLVdXhd9s59XaChmF+wv/Hz78Pk53jxxVQGKUrx8Ft0faLbw==", "dev": true }, "@types/chai": { @@ -31,6 +37,12 @@ "integrity": "sha512-64Uv+8bTRVZHlbB8eXQgMP9HguxPgnOOIYrQpwHWrtLDrtcG/lILKhUl7bV65NSOIJ9dXGYD7skQFXzhL8tk1A==", "dev": true }, + "@types/cookiejar": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.0.tgz", + "integrity": "sha512-EIjmpvnHj+T4nMcKwHwxZKUfDmphIKJc2qnEMhSoOvr1lYEQpuRKRz8orWr//krYIIArS/KGGLfL2YGVUYXmIA==", + "dev": true + }, "@types/events": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@types/events/-/events-1.2.0.tgz", @@ -38,33 +50,24 @@ "dev": true }, "@types/jsonwebtoken": { - "version": "7.2.7", - "resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-7.2.7.tgz", - "integrity": "sha512-lq9X76APpxGJDUe1VptL1P5GrogqhPCH+SDy94+gaBJw7Hhj6hwrVC6zuxAx2GrgktkBuwydESZBvPfrdBoOEg==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, - "@types/mitm": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@types/mitm/-/mitm-1.3.2.tgz", - "integrity": "sha1-omkQqgznRrYKWK18on3OsYEZ5uw=", + "version": "7.2.8", + "resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-7.2.8.tgz", + "integrity": "sha512-XENN3YzEB8D6TiUww0O8SRznzy1v+77lH7UmuN54xq/IHIsyWjWOzZuFFTtoiRuaE782uAoRwBe/wwow+vQXZw==", "dev": true, "requires": { "@types/node": "*" } }, "@types/mocha": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.3.tgz", - "integrity": "sha512-C1wVVr7xhKu6c3Mb27dFzNYR05qvHwgtpN+JOYTGc1pKA7dCEDDYpscn7kul+bCUwa3NoGDbzI1pdznSOa397w==", + "version": "5.2.5", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.5.tgz", + "integrity": "sha512-lAVp+Kj54ui/vLUFxsJTMtWvZraZxum3w3Nwkble2dNuV5VnPA+Mi2oGX9XYJAaIvZi3tn3cbjS/qcJXRb6Bww==", "dev": true }, "@types/node": { - "version": "10.3.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.3.5.tgz", - "integrity": "sha512-6lRwZN0Y3TuglwaaZN2XPocobmzLlhxcqDjKFjNYSsXG/TFAGYkCqkzZh4+ms8iTHHQE6gJXLHPV7TziVGeWhg==", + "version": "10.5.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.3.tgz", + "integrity": "sha512-jQ1p+SyF/z8ygPxfSPKZKMWazlCgTBSyIaC1UCUvkLHDdxdmPQtQFk02X4WFM31Z1BKMAS3MSAK0cRP2c92n6Q==", "dev": true }, "@types/raven": { @@ -78,17 +81,18 @@ } }, "@types/sinon": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-4.3.1.tgz", - "integrity": "sha512-DK4YtH30I67k4klURIBS4VAe1aBISfS9lgNlHFkibSmKem2tLQc5VkKoJreT3dCJAd+xRyCS8bx1o97iq3yUVg==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-5.0.1.tgz", + "integrity": "sha512-yxzBCIjE3lp9lYjfBbIK/LRCoXgCLLbIIBIje7eNCcUIIR2CZZtyX5uto2hVoMSMqLrsRrT6mwwUEd0yFgOwpA==", "dev": true }, "@types/superagent": { - "version": "3.5.8", - "resolved": "https://registry.npmjs.org/@types/superagent/-/superagent-3.5.8.tgz", - "integrity": "sha512-+u55ca5A0YO0d9ZjaoDKvM/N3NINH4eYiE42jgqYfkqfVt76BHcf00itQ9CyoPNu7IewEovIESI2Gt1W+NVfZg==", + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/@types/superagent/-/superagent-3.8.3.tgz", + "integrity": "sha512-Mge1Msz48U09kJYYNZWmCsTCI8tmTAkZhsKx2Neapd9PqzEm7caM4wQ3uiGpAvT6vTIzaq1apOoa/TipMeZkow==", "dev": true, "requires": { + "@types/cookiejar": "*", "@types/node": "*" } }, @@ -99,13 +103,10 @@ "dev": true }, "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true }, "argparse": { "version": "1.0.10", @@ -134,9 +135,9 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "aws-sdk": { - "version": "2.263.1", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.263.1.tgz", - "integrity": "sha512-/iMyp7UIvQ5fYqfxjsyFIT051qC/Qu+xu618t+bidKJpwqTqTBoksDoYFnq827c48MZUrzIS9C6WMY5Z7bK8jA==", + "version": "2.280.1", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.280.1.tgz", + "integrity": "sha512-NdATmKYTWKvRsUo7F0hhMbSVbk4kHdQb8aWSJpXRccXsOTviNSxTIOvaube8RXT7nCz+S5CckJ/fPTUTVv/vQw==", "dev": true, "requires": { "buffer": "4.9.1", @@ -147,7 +148,7 @@ "sax": "1.2.1", "url": "0.10.3", "uuid": "3.1.0", - "xml2js": "0.4.17" + "xml2js": "0.4.19" }, "dependencies": { "uuid": { @@ -169,12 +170,6 @@ "js-tokens": "^3.0.2" }, "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", @@ -241,9 +236,9 @@ "integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=" }, "buffer-from": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.0.0.tgz", - "integrity": "sha512-83apNb8KK0Se60UE1+4Ukbe3HbfELJ6UlI4ldtOGs7So4KD26orJM8hIY9lxdzP+UpItH1Yh/Y8GUvNFWFFRxA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.0.tgz", + "integrity": "sha512-c5mRlguI/Pe2dSZmpER62rSCu0ryKmWddzRYsuXc50U2/g8jMOulc31VZMa4mYx31U5xsmSOpDCgH88Vl9cDGQ==", "dev": true }, "builtin-modules": { @@ -253,21 +248,21 @@ "dev": true }, "cassava": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cassava/-/cassava-2.2.0.tgz", - "integrity": "sha512-JjqRW2nQUbS83QvNdZ2x1Ipg2HhGhlobzu1vFOiHRCdgNQBZ/RGgZiDZvHHVLPJEZn810hNv/8KL9X2NLTmoWg==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/cassava/-/cassava-2.2.2.tgz", + "integrity": "sha512-u9eHKlVekX9gZ9tVh0SrvEfpEnL+24ptEVRq3LSQNn1q9EaP/VFkxNwqJUtZU4GBLKo87mnsjXpPoY67w/ureg==", "dev": true, "requires": { "cookie": "^0.3.1", "jsonschema": "^1.2.4", "negotiator": "^0.6.1", - "uuid": "3.2.1" + "uuid": "^3.3.2" }, "dependencies": { "uuid": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", "dev": true } } @@ -297,19 +292,13 @@ "supports-color": "^5.3.0" }, "dependencies": { - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "color-convert": "^1.9.0" } } } @@ -326,18 +315,18 @@ "dev": true }, "color-convert": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.2.tgz", + "integrity": "sha512-3NUJZdhMhcdPn8vJ9v2UQJoH0qqoGUkYTgFEPZaPjEtwmmKUfNV46zZmgB2M5M4DCEQHMaCfWHCxiBflLm04Tg==", "dev": true, "requires": { - "color-name": "^1.1.1" + "color-name": "1.1.1" } }, "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha1-SxQVMEz1ACjqgWQ2Q72C6gWANok=", "dev": true }, "combined-stream": { @@ -435,9 +424,9 @@ "dev": true }, "esprima": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, "esutils": { @@ -569,9 +558,9 @@ "dev": true }, "js-yaml": { - "version": "3.11.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", + "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", "dev": true, "requires": { "argparse": "^1.0.7", @@ -625,12 +614,6 @@ "safe-buffer": "^5.0.1" } }, - "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", - "dev": true - }, "lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", @@ -673,9 +656,9 @@ "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=" }, "lolex": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.7.1.tgz", + "integrity": "sha512-Oo2Si3RMKV3+lV5MsSWplDQFoTClz/24S0MMHYcgGWWmFXr6TMlqcqk/l1GtH+d5wLBwNRiqGnwDRMirtFalJw==", "dev": true }, "make-error": { @@ -732,15 +715,6 @@ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, - "mitm": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/mitm/-/mitm-1.3.3.tgz", - "integrity": "sha512-b2+h4QIvW0gS8xluuXhgG6JXQYjuoxXVpACudXewK4c+7giwigN4UJ2hhWKQUwaT+jh9mQA5HYNfJ6t89Tq/uA==", - "dev": true, - "requires": { - "underscore": ">= 1.1.6 < 1.6" - } - }, "mkdirp": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", @@ -797,9 +771,9 @@ "dev": true }, "nise": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/nise/-/nise-1.3.3.tgz", - "integrity": "sha512-v1J/FLUB9PfGqZLGDBhQqODkbLotP0WtLo9R4EJY2PPu5f5Xg4o0rA8FDlmrjFSv9vBBKcfnOSpfYYuu5RTHqg==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/nise/-/nise-1.4.2.tgz", + "integrity": "sha512-BxH/DxoQYYdhKgVAfqVy4pzXRZELHOIewzoesxpjYvpU+7YOalQhGNPf7wAx8pLrTNPrHRDlLOkAl8UI0ZpXjw==", "dev": true, "requires": { "@sinonjs/formatio": "^2.0.0", @@ -902,9 +876,9 @@ } }, "resolve": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", - "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", + "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", "dev": true, "requires": { "path-parse": "^1.0.5" @@ -943,35 +917,21 @@ "dev": true }, "sinon": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-5.0.3.tgz", - "integrity": "sha512-kzBkET1Hf0r0J4uVnlicuAEiq9nnhPrEHZWS0mds+5EaB9rA0XoliIkLaqkBNU9lwPuJACo/velUQQOmTRJtUw==", + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-6.1.4.tgz", + "integrity": "sha512-NFEts+4D4jp2sBjL94fQpZk5o73kzn/g58+I9Dp15i9vsnT4Lk1UEyUf2jACODWLG6Pz/llF0sArYUw47Aarmg==", "dev": true, "requires": { "@sinonjs/formatio": "^2.0.0", - "diff": "^3.1.0", + "@sinonjs/samsam": "^2.0.0", + "diff": "^3.5.0", "lodash.get": "^4.4.2", - "lolex": "^2.2.0", - "nise": "^1.2.0", - "supports-color": "^5.1.0", - "type-detect": "^4.0.5" + "lolex": "^2.7.1", + "nise": "^1.4.2", + "supports-color": "^5.4.0", + "type-detect": "^4.0.8" }, "dependencies": { - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -987,9 +947,9 @@ "dev": true }, "source-map-support": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.5.tgz", - "integrity": "sha512-mR7/Nd5l1z6g99010shcXJiNEaf3fEtmLhRB/sBcQVJGodcHCULPp2y4Sfa43Kv2zq7T+Izmfp/WHCR6dYkQCA==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.6.tgz", + "integrity": "sha512-N4KXEz7jcKqPf2b2vZF11lQIz9W5ZMuUcIOGj243lduidkf2fjkVKJS9vNxVWn3u/uxX38AcE8U9nnH9FPcq+g==", "dev": true, "requires": { "buffer-from": "^1.0.0", @@ -1062,18 +1022,18 @@ "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=" }, "ts-node": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-6.0.2.tgz", - "integrity": "sha512-H/KWK27B3JJAc5WFOBBUxN638DukbV8PptdQgiHWPO2SGDVJzuVOl8Ye0XJ5+FiZIdFtgUuGOJRV4c/XBQ5dBg==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.0.tgz", + "integrity": "sha512-klJsfswHP0FuOLsvBZ/zzCfUvakOSSxds78mVeK7I+qP76YWtxf16hEZsp3U+b0kIo82R5UatGFeblYMqabb2Q==", "dev": true, "requires": { "arrify": "^1.0.0", - "chalk": "^2.3.0", + "buffer-from": "^1.1.0", "diff": "^3.1.0", "make-error": "^1.1.1", "minimist": "^1.2.0", "mkdirp": "^0.5.1", - "source-map-support": "^0.5.3", + "source-map-support": "^0.5.6", "yn": "^2.0.0" }, "dependencies": { @@ -1086,15 +1046,15 @@ } }, "tslib": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz", - "integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==", + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", "dev": true }, "tslint": { - "version": "5.10.0", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.10.0.tgz", - "integrity": "sha1-EeJrzLiK+gLdDZlWyuPUVAtfVMM=", + "version": "5.11.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.11.0.tgz", + "integrity": "sha1-mPMMAurjzecAYgHkwzywi0hYHu0=", "dev": true, "requires": { "babel-code-frame": "^6.22.0", @@ -1108,21 +1068,13 @@ "resolve": "^1.3.2", "semver": "^5.3.0", "tslib": "^1.8.0", - "tsutils": "^2.12.1" - }, - "dependencies": { - "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", - "dev": true - } + "tsutils": "^2.27.2" } }, "tsutils": { - "version": "2.26.2", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.26.2.tgz", - "integrity": "sha512-uzwnhmrSbyinPCiwfzGsOY3IulBTwoky7r83HmZdz9QNCjhSCzavkh47KLWuU0zF2F2WbpmmzoJUIEiYyd+jEQ==", + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", "dev": true, "requires": { "tslib": "^1.8.1" @@ -1140,12 +1092,6 @@ "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", "dev": true }, - "underscore": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.5.2.tgz", - "integrity": "sha1-EzXF5PXm0zu7SwBrqMhqAPVW3gg=", - "dev": true - }, "url": { "version": "0.10.3", "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", @@ -1173,23 +1119,20 @@ "dev": true }, "xml2js": { - "version": "0.4.17", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz", - "integrity": "sha1-F76T6q4/O3eTWceVtBlwWogX6Gg=", + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", + "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", "dev": true, "requires": { "sax": ">=0.6.0", - "xmlbuilder": "^4.1.0" + "xmlbuilder": "~9.0.1" } }, "xmlbuilder": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.2.1.tgz", - "integrity": "sha1-qlijBBoGb5DqoWwvU4n/GfP0YaU=", - "dev": true, - "requires": { - "lodash": "^4.0.0" - } + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=", + "dev": true }, "yn": { "version": "2.0.0", diff --git a/package.json b/package.json index 804ed9e..4787c74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "giftbit-cassava-routes", - "version": "7.0.1", + "version": "8.0.0", "description": "Private Giftbit routes for use with Cassava.", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -24,29 +24,27 @@ }, "homepage": "https://github.com/Giftbit/giftbit-cassava#readme", "peerDependencies": { - "aws-sdk": "^2.263.1", - "cassava": "^2.2.0" + "aws-sdk": "^2.280.1", + "cassava": "^2.2.2" }, "devDependencies": { - "@types/aws-lambda": "^8.10.7", + "@types/aws-lambda": "^8.10.8", "@types/chai": "^4.1.4", "@types/cookie": "^0.3.1", - "@types/jsonwebtoken": "^7.2.7", - "@types/mitm": "^1.3.2", - "@types/mocha": "^5.2.3", - "@types/node": "^10.3.5", + "@types/jsonwebtoken": "^7.2.8", + "@types/mocha": "^5.2.5", + "@types/node": "^10.5.3", "@types/raven": "^2.5.1", - "@types/sinon": "^4.3.1", - "@types/superagent": "^3.5.8", - "aws-sdk": "^2.263.1", - "cassava": "^2.2.0", + "@types/sinon": "^5.0.1", + "@types/superagent": "^3.8.3", + "aws-sdk": "^2.280.1", + "cassava": "^2.2.2", "chai": "^4.1.2", - "mitm": "^1.3.3", "mocha": "^5.2.0", "rimraf": "^2.6.2", - "sinon": "^5.0.3", - "ts-node": "^6.0.2", - "tslint": "^5.10.0", + "sinon": "^6.1.4", + "ts-node": "^7.0.0", + "tslint": "^5.11.0", "typescript": "^2.9.2" }, "dependencies": { diff --git a/src/jwtauth/AuthorizationBadge.test.ts b/src/jwtauth/AuthorizationBadge.test.ts index c5df8e0..79d54de 100644 --- a/src/jwtauth/AuthorizationBadge.test.ts +++ b/src/jwtauth/AuthorizationBadge.test.ts @@ -175,7 +175,7 @@ describe("AuthorizationBadge", () => { }); }); - describe("isBadgeAuthorized()", () => { + describe("hasScope()", () => { it("verifies an exact match", () => { const badge: AuthorizationBadge = new AuthorizationBadge({ scopes: [ @@ -184,8 +184,8 @@ describe("AuthorizationBadge", () => { ] }); - chai.assert.isTrue(badge.isBadgeAuthorized("lightrailV1:transaction:create:drawdown")); - chai.assert.isTrue(badge.isBadgeAuthorized("lightrailV1:foo:bar:baz")); + chai.assert.isTrue(badge.hasScope("lightrailV1:transaction:create:drawdown")); + chai.assert.isTrue(badge.hasScope("lightrailV1:foo:bar:baz")); }); it("verifies more powerful scopes", () => { @@ -196,8 +196,8 @@ describe("AuthorizationBadge", () => { ] }); - chai.assert.isTrue(badge.isBadgeAuthorized("lightrailV1:transaction:create:drawdown")); - chai.assert.isTrue(badge.isBadgeAuthorized("lightrailV1:foo:bar:baz")); + chai.assert.isTrue(badge.hasScope("lightrailV1:transaction:create:drawdown")); + chai.assert.isTrue(badge.hasScope("lightrailV1:foo:bar:baz")); }); it("does not verify anything else", () => { @@ -208,19 +208,19 @@ describe("AuthorizationBadge", () => { ] }); - chai.assert.isFalse(badge.isBadgeAuthorized(undefined)); - chai.assert.isFalse(badge.isBadgeAuthorized(null)); - chai.assert.isFalse(badge.isBadgeAuthorized("")); - chai.assert.isFalse(badge.isBadgeAuthorized(14901 as any)); - chai.assert.isFalse(badge.isBadgeAuthorized("lightrailV1")); - chai.assert.isFalse(badge.isBadgeAuthorized("lightrailV1:transaction")); - chai.assert.isFalse(badge.isBadgeAuthorized("lightrailV1:transaction:create")); - chai.assert.isFalse(badge.isBadgeAuthorized("lightrailV1:Transaction:create:drawdown")); - chai.assert.isFalse(badge.isBadgeAuthorized("transaction:create:drawdown")); - chai.assert.isFalse(badge.isBadgeAuthorized("create:drawdown")); - chai.assert.isFalse(badge.isBadgeAuthorized("drawdown")); - chai.assert.isFalse(badge.isBadgeAuthorized("lightrailV1:foo:create:drawdown")); - chai.assert.isFalse(badge.isBadgeAuthorized("lightrailV1:foo:create:baz")); + chai.assert.isFalse(badge.hasScope(undefined)); + chai.assert.isFalse(badge.hasScope(null)); + chai.assert.isFalse(badge.hasScope("")); + chai.assert.isFalse(badge.hasScope(14901 as any)); + chai.assert.isFalse(badge.hasScope("lightrailV1")); + chai.assert.isFalse(badge.hasScope("lightrailV1:transaction")); + chai.assert.isFalse(badge.hasScope("lightrailV1:transaction:create")); + chai.assert.isFalse(badge.hasScope("lightrailV1:Transaction:create:drawdown")); + chai.assert.isFalse(badge.hasScope("transaction:create:drawdown")); + chai.assert.isFalse(badge.hasScope("create:drawdown")); + chai.assert.isFalse(badge.hasScope("drawdown")); + chai.assert.isFalse(badge.hasScope("lightrailV1:foo:create:drawdown")); + chai.assert.isFalse(badge.hasScope("lightrailV1:foo:create:baz")); }); }); @@ -384,8 +384,6 @@ describe("AuthorizationBadge", () => { "gui": "user-f7ddcbbfe0e741c688993da35669a47b", "gmi": "user-f7ddcbbfe0e741c688993da35669a47b", "tmi": "user-f7ddcbbfe0e741c688993da35669a47b", - "cui": "customer", - "shi": "sssssh", "coi": "don't play coi with me" }, "aud": "API_KEY", @@ -468,8 +466,8 @@ describe("AuthorizationBadge", () => { ] }); - chai.assert.isFalse(auth2.isBadgeAuthorized("ASSUME"), `not in ${JSON.stringify(auth2.scopes)} or ${JSON.stringify(auth2.effectiveScopes)}`); - chai.assert.equal(auth2.giftbitUserId, "user-123-TEST"); + chai.assert.isFalse(auth2.hasScope("ASSUME"), `not in ${JSON.stringify(auth2.scopes)} or ${JSON.stringify(auth2.effectiveScopes)}`); + chai.assert.equal(auth2.userId, "user-123-TEST"); chai.assert.equal(auth2.merchantId, "user-123-TEST"); chai.assert.equal(auth2.uniqueIdentifier, "badge-cca79a9a42134e609aafdc8e9482854e"); chai.assert.equal(auth2.parentUniqueIdentifier, "badge-2"); diff --git a/src/jwtauth/AuthorizationBadge.ts b/src/jwtauth/AuthorizationBadge.ts index 1091640..c177156 100644 --- a/src/jwtauth/AuthorizationBadge.ts +++ b/src/jwtauth/AuthorizationBadge.ts @@ -8,16 +8,14 @@ import {RolesConfig} from "../secureConfig"; */ export class AuthorizationBadge { - giftbitUserId: string; + userId: string; teamMemberId: string; merchantId: string; - cardId: string; - templateId: string; + valueId: string; programId: string; - contactUserSuppliedId: string; - shopperId: string; contactId: string; serviceId: string; + metadata: {[name: string]: any}; audience: string; @@ -34,14 +32,11 @@ export class AuthorizationBadge { constructor(jwtPayload?: JwtPayload, private readonly rolesConfig?: RolesConfig) { if (jwtPayload) { if (jwtPayload.g) { - this.giftbitUserId = jwtPayload.g.gui; + this.userId = jwtPayload.g.gui; this.teamMemberId = jwtPayload.g.tmi; this.merchantId = jwtPayload.g.gmi; - this.cardId = jwtPayload.g.gci; - this.templateId = jwtPayload.g.gti; + this.valueId = jwtPayload.g.gvi; this.programId = jwtPayload.g.pid; - this.contactUserSuppliedId = jwtPayload.g.cui; - this.shopperId = jwtPayload.g.shi; this.contactId = jwtPayload.g.coi; this.serviceId = jwtPayload.g.si; } @@ -76,8 +71,8 @@ export class AuthorizationBadge { const payload: JwtPayload = { g: {} }; - if (this.giftbitUserId) { - payload.g.gui = this.giftbitUserId; + if (this.userId) { + payload.g.gui = this.userId; } if (this.teamMemberId) { payload.g.tmi = this.teamMemberId; @@ -85,21 +80,12 @@ export class AuthorizationBadge { if (this.merchantId) { payload.g.gmi = this.merchantId; } - if (this.cardId) { - payload.g.gci = this.cardId; - } - if (this.templateId) { - payload.g.gti = this.templateId; + if (this.valueId) { + payload.g.gvi = this.valueId; } if (this.programId) { payload.g.pid = this.programId; } - if (this.contactUserSuppliedId) { - payload.g.cui = this.contactUserSuppliedId; - } - if (this.shopperId) { - payload.g.shi = this.shopperId; - } if (this.contactId) { payload.g.coi = this.contactId; } @@ -154,7 +140,7 @@ export class AuthorizationBadge { const j = this.getJwtPayload(); j.g = { ... jwtPayload.g, - si: this.giftbitUserId + si: this.userId }; j.parentJti = jwtPayload.jti; @@ -167,9 +153,9 @@ export class AuthorizationBadge { /** * Require that the given IDs are set on the badge. - * eg: requireIds("giftbitUserId", "merchantId"); + * eg: requireIds("userId", "merchantId"); */ - requireIds(...ids: ("giftbitUserId" | "teamMemberId" | "merchantId" | "cardId" | "templateId" | "programId" | "contactUserSuppliedId" | "shopperId" | "contactId" | "serviceId")[]): void { + requireIds(...ids: ("userId" | "teamMemberId" | "merchantId" | "valueId" | "programId" | "contactId" | "serviceId")[]): void { for (let id of ids) { if (!this[id]) { throw new cassava.RestError(cassava.httpStatusCode.clientError.FORBIDDEN); @@ -177,7 +163,17 @@ export class AuthorizationBadge { } } + /** + * @deprecated use hasScope, because the name is clearer + */ isBadgeAuthorized(scope: string): boolean { + return this.hasScope(scope); + } + + /** + * Returns true if this badge contains the given scope or any parent of the scope. + */ + hasScope(scope: string): boolean { for (; scope; scope = getParentScope(scope)) { if (this.effectiveScopes.indexOf(scope) !== -1) { return true; @@ -186,15 +182,25 @@ export class AuthorizationBadge { return false; } + /** + * Returns true if the badge has all the given scopes. + */ + hasScopes(...scopes: string[]): boolean { + for (let scope of scopes) { + if (!this.hasScope(scope)) { + return false; + } + } + return true; + } + /** * Require that the given scopes are authorized on the badge. * Throws a RestError if they are not. */ requireScopes(...scopes: string[]): void { - for (let scope of scopes) { - if (!this.isBadgeAuthorized(scope)) { - throw new cassava.RestError(cassava.httpStatusCode.clientError.FORBIDDEN); - } + if (!this.hasScopes(...scopes)) { + throw new cassava.RestError(cassava.httpStatusCode.clientError.FORBIDDEN); } } @@ -202,9 +208,8 @@ export class AuthorizationBadge { * Save the merchant from themselves. */ private sanitizeMerchantSigned(): void { - this.merchantId = this.giftbitUserId; - if (!this.contactUserSuppliedId && !this.shopperId && !this.contactId) { - this.shopperId = "defaultShopper"; + this.merchantId = this.userId; + if (!this.contactId) { this.contactId = "defaultShopper"; } this.roles = ["shopper"]; // This might be a whitelist in the future. @@ -254,7 +259,7 @@ export class AuthorizationBadge { } isTestUser(): boolean { - return this.giftbitUserId && this.giftbitUserId.endsWith("-TEST"); + return this.userId && this.userId.endsWith("-TEST"); } } diff --git a/src/jwtauth/JwtAuthorizationRoute.test.ts b/src/jwtauth/JwtAuthorizationRoute.test.ts index 8a197fb..c5e4401 100644 --- a/src/jwtauth/JwtAuthorizationRoute.test.ts +++ b/src/jwtauth/JwtAuthorizationRoute.test.ts @@ -25,7 +25,7 @@ describe("JwtAuthorizationRoute", () => { handle: async evt => { const auth = evt.meta["auth"] as AuthorizationBadge; chai.assert.isObject(auth); - chai.assert.equal(auth.giftbitUserId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); + chai.assert.equal(auth.userId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); chai.assert.equal(auth.merchantId, "user-7052210bcb94448b825ffa68508d29ad"); chai.assert.instanceOf(auth.issuedAtTime, Date); chai.assert.equal(auth.issuedAtTime.getTime(), 1481573500000); @@ -61,7 +61,7 @@ describe("JwtAuthorizationRoute", () => { handle: async evt => { const auth = evt.meta["auth"] as AuthorizationBadge; chai.assert.isObject(auth); - chai.assert.equal(auth.giftbitUserId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); + chai.assert.equal(auth.userId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); chai.assert.equal(auth.merchantId, "user-7052210bcb94448b825ffa68508d29ad"); chai.assert.instanceOf(auth.issuedAtTime, Date); chai.assert.equal(auth.issuedAtTime.getTime(), 1481573500000); @@ -93,7 +93,7 @@ describe("JwtAuthorizationRoute", () => { handle: async evt => { const auth = evt.meta["auth"] as AuthorizationBadge; chai.assert.isObject(auth); - chai.assert.equal(auth.giftbitUserId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); + chai.assert.equal(auth.userId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); chai.assert.equal(auth.merchantId, "user-7052210bcb94448b825ffa68508d29ad"); chai.assert.instanceOf(auth.issuedAtTime, Date); chai.assert.equal(auth.issuedAtTime.getTime(), 1481573500000); @@ -351,7 +351,7 @@ describe("JwtAuthorizationRoute", () => { handle: async evt => { const auth = evt.meta["auth"] as AuthorizationBadge; chai.assert.isObject(auth); - chai.assert.equal(auth.giftbitUserId, "user-123"); + chai.assert.equal(auth.userId, "user-123"); chai.assert.equal(auth.merchantId, "user-123"); chai.assert.equal(auth.uniqueIdentifier, "badge-1234"); chai.assert.equal(auth.serviceId, "service-1"); @@ -385,7 +385,7 @@ describe("JwtAuthorizationRoute", () => { handle: async evt => { const auth = evt.meta["auth"] as AuthorizationBadge; chai.assert.isObject(auth); - chai.assert.equal(auth.giftbitUserId, "user-9485b8758ca542b098a30ca4f7745d2a-TEST"); + chai.assert.equal(auth.userId, "user-9485b8758ca542b098a30ca4f7745d2a-TEST"); chai.assert.sameMembers(auth.scopes, [ "lightrailV1:token:read", "lightrailV1:sharedSecret:read" @@ -471,7 +471,7 @@ describe("JwtAuthorizationRoute", () => { handle: async evt => { const auth = evt.meta["auth"] as AuthorizationBadge; chai.assert.isObject(auth); - chai.assert.equal(auth.giftbitUserId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); + chai.assert.equal(auth.userId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); chai.assert.equal(auth.merchantId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); chai.assert.sameMembers(auth.roles, ["shopper"]); chai.assert.sameMembers(auth.scopes, []); @@ -501,7 +501,7 @@ describe("JwtAuthorizationRoute", () => { handle: async evt => { const auth = evt.meta["auth"] as AuthorizationBadge; chai.assert.isObject(auth); - chai.assert.equal(auth.giftbitUserId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); + chai.assert.equal(auth.userId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); chai.assert.equal(auth.merchantId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); chai.assert.sameMembers(auth.roles, ["shopper"]); chai.assert.sameMembers(auth.scopes, []); @@ -531,7 +531,7 @@ describe("JwtAuthorizationRoute", () => { handle: async evt => { const auth = evt.meta["auth"] as AuthorizationBadge; chai.assert.isObject(auth); - chai.assert.equal(auth.giftbitUserId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); + chai.assert.equal(auth.userId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); chai.assert.equal(auth.merchantId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); chai.assert.sameMembers(auth.roles, ["shopper"]); chai.assert.sameMembers(auth.scopes, []); @@ -604,7 +604,7 @@ describe("JwtAuthorizationRoute", () => { handle: async evt => { const auth = evt.meta["auth"] as AuthorizationBadge; chai.assert.isObject(auth); - chai.assert.equal(auth.giftbitUserId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); + chai.assert.equal(auth.userId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); chai.assert.equal(auth.merchantId, "user-7052210bcb94448b825ffa68508d29ad-TEST"); chai.assert.sameMembers(auth.roles, ["shopper"]); chai.assert.sameMembers(auth.scopes, []); diff --git a/src/jwtauth/JwtPayload.ts b/src/jwtauth/JwtPayload.ts index 9479ab8..4b33962 100644 --- a/src/jwtauth/JwtPayload.ts +++ b/src/jwtauth/JwtPayload.ts @@ -7,11 +7,8 @@ export interface JwtPayload { gui?: string; tmi?: string; gmi?: string; - gci?: string; - gti?: string; + gvi?: string; pid?: string; - cui?: string; - shi?: string; coi?: string; si?: string; }; diff --git a/src/jwtauth/merchantSharedKey/RestMerchantKeyProvider.test.ts b/src/jwtauth/merchantSharedKey/RestMerchantKeyProvider.test.ts deleted file mode 100644 index a3df98a..0000000 --- a/src/jwtauth/merchantSharedKey/RestMerchantKeyProvider.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -import * as chai from "chai"; -import * as http from "http"; -import mitm = require("mitm"); -import {RestMerchantKeyProvider} from "./RestMerchantKeyProvider"; -import {AssumeScopeToken} from "../../secureConfig"; -import {TLSSocket} from "tls"; - -describe("RestMerchantKeyProvider", () => { - - let mitmInstance: any; - - beforeEach(() => { - // mitm shims node's internal request/response constructs so they can be intercepted. - // A similar project called nock works at a higher level but can't do assertions on - // the header based on the whole request. - mitmInstance = mitm(); - }); - - afterEach(() => { - if (mitmInstance) { - mitmInstance.disable(); - mitmInstance = null; - } - }); - - it.skip("defaults to the https protocol -- mitm testing dependency is broken", async () => { - mitmInstance.on("request", (req: http.IncomingMessage, res: http.ServerResponse) => { - // The socket type proves this went over HTTPS. - chai.assert.instanceOf(req.socket, TLSSocket); - chai.assert.equal(req.method, "GET"); - chai.assert.equal(req.url, "/"); - chai.assert.equal(req.headers.authorization, "Bearer secret"); - chai.assert.equal(req.headers.authorizeas, "bbb"); - - res.statusCode = 200; - res.setHeader("Content-Type", "application/json"); - res.end(JSON.stringify("hello")); - }); - - const prov = new RestMerchantKeyProvider("www.example.com", Promise.resolve({assumeToken: "secret"})); - const key = await prov.getMerchantKey("aaa.bbb.ccc"); - chai.assert.equal(key, "hello"); - }); -}); diff --git a/src/jwtauth/merchantSharedKey/RestMerchantKeyProvider.ts b/src/jwtauth/merchantSharedKey/RestMerchantKeyProvider.ts index 4d912e9..cb3432b 100644 --- a/src/jwtauth/merchantSharedKey/RestMerchantKeyProvider.ts +++ b/src/jwtauth/merchantSharedKey/RestMerchantKeyProvider.ts @@ -1,5 +1,5 @@ import * as superagent from "superagent"; -import {AssumeScopeToken} from "../../secureConfig/AssumeScopeToken"; +import {AssumeScopeToken} from "../../secureConfig"; import {MerchantKeyProvider} from "./MerchantKeyProvider"; export class RestMerchantKeyProvider implements MerchantKeyProvider { diff --git a/src/sentry/index.ts b/src/sentry/index.ts index 557d998..d074ed4 100644 --- a/src/sentry/index.ts +++ b/src/sentry/index.ts @@ -28,7 +28,7 @@ export interface WrapLambdaHandlerOptions { */ export function wrapLambdaHandler(options: WrapLambdaHandlerOptions): (evt: any, ctx: awslambda.Context) => Promise { if (!options.router && !options.handler) { - throw new Error("Must specify one of router or handler.") + throw new Error("Must specify one of router or handler."); } const handler: (evt: any, ctx: awslambda.Context) => Promise = options.handler || options.router.getLambdaHandler() as any;