@ampsec/platform-client 12.1.0 → 12.2.0

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.
@@ -0,0 +1,16 @@
1
+ export declare enum AgentRole {
2
+ /** Agent can only read data. */
3
+ VIEWER = "VIEWER",
4
+ /** Agent can read and write data. */
5
+ AGENT = "AGENT",
6
+ /** Agent can read and write data and manage other agents. */
7
+ ADMIN = "ADMIN",
8
+ /** Agent owns organization. */
9
+ OWNER = "OWNER",
10
+ /** Token belongs to a service account. */
11
+ SERVICE_ACCOUNT = "SERVICE_ACCOUNT",
12
+ /** Unknown role. Used for validation */
13
+ UNKNOWN = "UNKNOWN"
14
+ }
15
+ export declare function lookupAgentRole(role: string): AgentRole;
16
+ export declare function lookupAgentRoleOrdinal(role: string): number;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lookupAgentRoleOrdinal = exports.lookupAgentRole = exports.AgentRole = void 0;
4
+ /* eslint-disable no-unused-vars */
5
+ var AgentRole;
6
+ (function (AgentRole) {
7
+ /** Agent can only read data. */
8
+ AgentRole["VIEWER"] = "VIEWER";
9
+ /** Agent can read and write data. */
10
+ AgentRole["AGENT"] = "AGENT";
11
+ /** Agent can read and write data and manage other agents. */
12
+ AgentRole["ADMIN"] = "ADMIN";
13
+ /** Agent owns organization. */
14
+ AgentRole["OWNER"] = "OWNER";
15
+ /** Token belongs to a service account. */
16
+ AgentRole["SERVICE_ACCOUNT"] = "SERVICE_ACCOUNT";
17
+ /** Unknown role. Used for validation */
18
+ AgentRole["UNKNOWN"] = "UNKNOWN";
19
+ })(AgentRole = exports.AgentRole || (exports.AgentRole = {}));
20
+ const agentRoleLookupMap = {
21
+ VIEWER: AgentRole.VIEWER,
22
+ AGENT: AgentRole.AGENT,
23
+ ADMIN: AgentRole.ADMIN,
24
+ OWNER: AgentRole.OWNER,
25
+ SERVICE_ACCOUNT: AgentRole.SERVICE_ACCOUNT,
26
+ };
27
+ function lookupAgentRole(role) {
28
+ return agentRoleLookupMap[role] || AgentRole.UNKNOWN;
29
+ }
30
+ exports.lookupAgentRole = lookupAgentRole;
31
+ const UNKNOWN_ORDINAL = -99;
32
+ const agentRoleOrdinalMap = new Map([
33
+ [AgentRole.VIEWER, 0],
34
+ [AgentRole.AGENT, 1],
35
+ [AgentRole.ADMIN, 2],
36
+ [AgentRole.OWNER, 3],
37
+ [AgentRole.SERVICE_ACCOUNT, -1],
38
+ [AgentRole.UNKNOWN, UNKNOWN_ORDINAL],
39
+ ]);
40
+ function lookupAgentRoleOrdinal(role) {
41
+ return agentRoleOrdinalMap.get(lookupAgentRole(role)) || UNKNOWN_ORDINAL;
42
+ }
43
+ exports.lookupAgentRoleOrdinal = lookupAgentRoleOrdinal;
44
+ //# sourceMappingURL=agent.role.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.role.js","sourceRoot":"","sources":["../../../../src/dto/enums/agent.role.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,IAAY,SAaX;AAbD,WAAY,SAAS;IACnB,gCAAgC;IAChC,8BAAiB,CAAA;IACjB,qCAAqC;IACrC,4BAAe,CAAA;IACf,6DAA6D;IAC7D,4BAAe,CAAA;IACf,+BAA+B;IAC/B,4BAAe,CAAA;IACf,0CAA0C;IAC1C,gDAAmC,CAAA;IACnC,wCAAwC;IACxC,gCAAmB,CAAA;AACrB,CAAC,EAbW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAapB;AAED,MAAM,kBAAkB,GAA+B;IACrD,MAAM,EAAE,SAAS,CAAC,MAAM;IACxB,KAAK,EAAE,SAAS,CAAC,KAAK;IACtB,KAAK,EAAE,SAAS,CAAC,KAAK;IACtB,KAAK,EAAE,SAAS,CAAC,KAAK;IACtB,eAAe,EAAE,SAAS,CAAC,eAAe;CAC3C,CAAC;AAEF,SAAgB,eAAe,CAAC,IAAY;IAC1C,OAAO,kBAAkB,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC;AACvD,CAAC;AAFD,0CAEC;AAED,MAAM,eAAe,GAAG,CAAC,EAAE,CAAC;AAC5B,MAAM,mBAAmB,GAA2B,IAAI,GAAG,CAAC;IAC1D,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACrB,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC;IACpB,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC;IACpB,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC;IACpB,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;IAC/B,CAAC,SAAS,CAAC,OAAO,EAAE,eAAe,CAAC;CACrC,CAAC,CAAC;AAEH,SAAgB,sBAAsB,CAAC,IAAY;IACjD,OAAO,mBAAmB,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,eAAe,CAAC;AAC3E,CAAC;AAFD,wDAEC"}
@@ -1,3 +1,4 @@
1
+ export * from './agent.role';
1
2
  export * from './agent.status';
2
3
  export * from './connector.status';
3
4
  export * from './finding.severity';
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./agent.role"), exports);
17
18
  __exportStar(require("./agent.status"), exports);
18
19
  __exportStar(require("./connector.status"), exports);
19
20
  __exportStar(require("./finding.severity"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/dto/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,qDAAmC;AACnC,qDAAmC;AACnC,mDAAiC;AACjC,wDAAsC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/dto/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,iDAA+B;AAC/B,qDAAmC;AACnC,qDAAmC;AACnC,mDAAiC;AACjC,wDAAsC"}
@@ -6,6 +6,7 @@ export * from './enum.dto';
6
6
  export * from './enums';
7
7
  export * from './extKeyMap.dto';
8
8
  export * from './findings.dto';
9
+ export * from './jwt';
9
10
  export * from './message.dto';
10
11
  export * from './page.dto';
11
12
  export * from './platform';
@@ -22,6 +22,7 @@ __exportStar(require("./enum.dto"), exports);
22
22
  __exportStar(require("./enums"), exports);
23
23
  __exportStar(require("./extKeyMap.dto"), exports);
24
24
  __exportStar(require("./findings.dto"), exports);
25
+ __exportStar(require("./jwt"), exports);
25
26
  __exportStar(require("./message.dto"), exports);
26
27
  __exportStar(require("./page.dto"), exports);
27
28
  __exportStar(require("./platform"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,+CAA6B;AAC7B,6CAA2B;AAC3B,mDAAiC;AACjC,6CAA2B;AAC3B,0CAAwB;AACxB,kDAAgC;AAChC,iDAA+B;AAC/B,gDAA8B;AAC9B,6CAA2B;AAC3B,6CAA2B;AAC3B,kDAAgC;AAChC,sDAAoC;AACpC,yDAAuC;AACvC,mDAAiC;AACjC,uDAAqC;AACrC,kDAAgC;AAChC,gDAA8B;AAC9B,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,+CAA6B;AAC7B,6CAA2B;AAC3B,mDAAiC;AACjC,6CAA2B;AAC3B,0CAAwB;AACxB,kDAAgC;AAChC,iDAA+B;AAC/B,wCAAsB;AACtB,gDAA8B;AAC9B,6CAA2B;AAC3B,6CAA2B;AAC3B,kDAAgC;AAChC,sDAAoC;AACpC,yDAAuC;AACvC,mDAAiC;AACjC,uDAAqC;AACrC,kDAAgC;AAChC,gDAA8B;AAC9B,8CAA4B"}
@@ -0,0 +1,20 @@
1
+ export type AmpJwtToken = {
2
+ /** Constant for now but might change in the future. */
3
+ iss: 'amp-platform-api';
4
+ /** UNIX timestamp, i.e. seconds since January 1, 1970 */
5
+ exp: number;
6
+ /** Single tenant ID for scoping requests */
7
+ tid: string;
8
+ /** DB PK for authenticated Agent/End User */
9
+ sub: string;
10
+ /** Display value for subject. Falls back to email. */
11
+ name: string;
12
+ /** Single role defining Amplifier User Personas */
13
+ role: string;
14
+ /** Enables fine grain access controls to actions/data. Defined by ORG admin or SCIM. */
15
+ group: string[];
16
+ /** Feature flags and other permissions. Defined by Amplifier Platform. */
17
+ entitlement: string[];
18
+ /** OAuth scopes to limit ability of token, e.g. READ_ONLY service accounts. Might overlap too much with `group` field. */
19
+ scope: string[];
20
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=jwt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt.js","sourceRoot":"","sources":["../../../src/dto/jwt.ts"],"names":[],"mappings":""}
@@ -9,14 +9,14 @@
9
9
  "version": "1.0.0",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
- "@ampsec/platform-client": "^10.0.0",
12
+ "@ampsec/platform-client": "^10.4.0",
13
13
  "axios": "^1.4.0"
14
14
  }
15
15
  },
16
16
  "node_modules/@ampsec/platform-client": {
17
- "version": "10.0.0",
18
- "resolved": "https://registry.npmjs.org/@ampsec/platform-client/-/platform-client-10.0.0.tgz",
19
- "integrity": "sha512-RT6yDe83+smIGWrBmTdFj0j5kUOzGmBGyZyPGBjdcqBjfjGpyc41pAoo8kjSsjPKANIX2BxWjNvs5/1NwUeYZA==",
17
+ "version": "10.4.0",
18
+ "resolved": "https://registry.npmjs.org/@ampsec/platform-client/-/platform-client-10.4.0.tgz",
19
+ "integrity": "sha512-KNmFLtDCvsQEQZFdjAlNclII0bcAVPS3VI4sS5ZyDvcimngucgGvlm6jUsndkDXGdv2CRR+wC/3P+riemNWTsQ==",
20
20
  "dependencies": {
21
21
  "axios": "^1.4.0",
22
22
  "blueimp-md5": "^2.19.0",
@@ -132,9 +132,9 @@
132
132
  },
133
133
  "dependencies": {
134
134
  "@ampsec/platform-client": {
135
- "version": "10.0.0",
136
- "resolved": "https://registry.npmjs.org/@ampsec/platform-client/-/platform-client-10.0.0.tgz",
137
- "integrity": "sha512-RT6yDe83+smIGWrBmTdFj0j5kUOzGmBGyZyPGBjdcqBjfjGpyc41pAoo8kjSsjPKANIX2BxWjNvs5/1NwUeYZA==",
135
+ "version": "10.4.0",
136
+ "resolved": "https://registry.npmjs.org/@ampsec/platform-client/-/platform-client-10.4.0.tgz",
137
+ "integrity": "sha512-KNmFLtDCvsQEQZFdjAlNclII0bcAVPS3VI4sS5ZyDvcimngucgGvlm6jUsndkDXGdv2CRR+wC/3P+riemNWTsQ==",
138
138
  "requires": {
139
139
  "axios": "^1.4.0",
140
140
  "blueimp-md5": "^2.19.0",
@@ -10,7 +10,7 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@ampsec/platform-client": "^10.3.0",
13
+ "@ampsec/platform-client": "^12.2.0",
14
14
  "axios": "^1.4.0"
15
15
  }
16
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampsec/platform-client",
3
- "version": "12.1.0",
3
+ "version": "12.2.0",
4
4
  "description": "",
5
5
  "main": "build/src/index.js",
6
6
  "runkitExampleFilename": "example/main.js",
@@ -1,5 +1,6 @@
1
1
  import {AgentStatus} from './enums/agent.status';
2
2
  import {BaseDto, BaseUpsertDto} from './base.dto';
3
+ // import {AgentRole} from './enums';
3
4
 
4
5
  export type AgentUpsertDto = BaseUpsertDto & {
5
6
  /** Agent first name */
@@ -10,6 +11,8 @@ export type AgentUpsertDto = BaseUpsertDto & {
10
11
  status: AgentStatus;
11
12
  /** External Id */
12
13
  email: string;
14
+ /** Agent role */
15
+ // TODO: role: AgentRole; // for now all agents are `OWNER`. Need to map role to tenant
13
16
  };
14
17
 
15
18
  export type AgentDto = BaseDto & AgentUpsertDto;
@@ -0,0 +1,41 @@
1
+ /* eslint-disable no-unused-vars */
2
+ export enum AgentRole {
3
+ /** Agent can only read data. */
4
+ VIEWER = 'VIEWER',
5
+ /** Agent can read and write data. */
6
+ AGENT = 'AGENT',
7
+ /** Agent can read and write data and manage other agents. */
8
+ ADMIN = 'ADMIN',
9
+ /** Agent owns organization. */
10
+ OWNER = 'OWNER',
11
+ /** Token belongs to a service account. */
12
+ SERVICE_ACCOUNT = 'SERVICE_ACCOUNT',
13
+ /** Unknown role. Used for validation */
14
+ UNKNOWN = 'UNKNOWN',
15
+ }
16
+
17
+ const agentRoleLookupMap: {[key: string]: AgentRole} = {
18
+ VIEWER: AgentRole.VIEWER,
19
+ AGENT: AgentRole.AGENT,
20
+ ADMIN: AgentRole.ADMIN,
21
+ OWNER: AgentRole.OWNER,
22
+ SERVICE_ACCOUNT: AgentRole.SERVICE_ACCOUNT,
23
+ };
24
+
25
+ export function lookupAgentRole(role: string): AgentRole {
26
+ return agentRoleLookupMap[role] || AgentRole.UNKNOWN;
27
+ }
28
+
29
+ const UNKNOWN_ORDINAL = -99;
30
+ const agentRoleOrdinalMap: Map<AgentRole, number> = new Map([
31
+ [AgentRole.VIEWER, 0],
32
+ [AgentRole.AGENT, 1],
33
+ [AgentRole.ADMIN, 2],
34
+ [AgentRole.OWNER, 3],
35
+ [AgentRole.SERVICE_ACCOUNT, -1],
36
+ [AgentRole.UNKNOWN, UNKNOWN_ORDINAL],
37
+ ]);
38
+
39
+ export function lookupAgentRoleOrdinal(role: string): number {
40
+ return agentRoleOrdinalMap.get(lookupAgentRole(role)) || UNKNOWN_ORDINAL;
41
+ }
@@ -1,3 +1,4 @@
1
+ export * from './agent.role';
1
2
  export * from './agent.status';
2
3
  export * from './connector.status';
3
4
  export * from './finding.severity';
package/src/dto/index.ts CHANGED
@@ -6,6 +6,7 @@ export * from './enum.dto';
6
6
  export * from './enums';
7
7
  export * from './extKeyMap.dto';
8
8
  export * from './findings.dto';
9
+ export * from './jwt';
9
10
  export * from './message.dto';
10
11
  export * from './page.dto';
11
12
  export * from './platform';
package/src/dto/jwt.ts ADDED
@@ -0,0 +1,20 @@
1
+ export type AmpJwtToken = {
2
+ /** Constant for now but might change in the future. */
3
+ iss: 'amp-platform-api';
4
+ /** UNIX timestamp, i.e. seconds since January 1, 1970 */
5
+ exp: number;
6
+ /** Single tenant ID for scoping requests */
7
+ tid: string;
8
+ /** DB PK for authenticated Agent/End User */
9
+ sub: string;
10
+ /** Display value for subject. Falls back to email. */
11
+ name: string;
12
+ /** Single role defining Amplifier User Personas */
13
+ role: string;
14
+ /** Enables fine grain access controls to actions/data. Defined by ORG admin or SCIM. */
15
+ group: string[];
16
+ /** Feature flags and other permissions. Defined by Amplifier Platform. */
17
+ entitlement: string[];
18
+ /** OAuth scopes to limit ability of token, e.g. READ_ONLY service accounts. Might overlap too much with `group` field. */
19
+ scope: string[];
20
+ };