@etohq/api-key 1.0.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.
- package/README.md +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/joiner-config.d.ts +2 -0
- package/dist/joiner-config.d.ts.map +1 -0
- package/dist/joiner-config.js +11 -0
- package/dist/joiner-config.js.map +1 -0
- package/dist/migrations/InitialSetup20240221144943.d.ts +5 -0
- package/dist/migrations/InitialSetup20240221144943.d.ts.map +1 -0
- package/dist/migrations/InitialSetup20240221144943.js +13 -0
- package/dist/migrations/InitialSetup20240221144943.js.map +1 -0
- package/dist/migrations/Migration20240604080145.d.ts +6 -0
- package/dist/migrations/Migration20240604080145.d.ts.map +1 -0
- package/dist/migrations/Migration20240604080145.js +14 -0
- package/dist/migrations/Migration20240604080145.js.map +1 -0
- package/dist/migrations/Migration20241205122700.d.ts +6 -0
- package/dist/migrations/Migration20241205122700.d.ts.map +1 -0
- package/dist/migrations/Migration20241205122700.js +20 -0
- package/dist/migrations/Migration20241205122700.js.map +1 -0
- package/dist/models/api-key.d.ts +14 -0
- package/dist/models/api-key.d.ts.map +1 -0
- package/dist/models/api-key.js +27 -0
- package/dist/models/api-key.js.map +1 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +9 -0
- package/dist/models/index.js.map +1 -0
- package/dist/services/api-key-module-service.d.ts +44 -0
- package/dist/services/api-key-module-service.d.ts.map +1 -0
- package/dist/services/api-key-module-service.js +407 -0
- package/dist/services/api-key-module-service.js.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +6 -0
- package/dist/services/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +26 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# API Key Module
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;;;;AAE/C,wBAEE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
4
|
+
const _services_1 = require("./services");
|
|
5
|
+
exports.default = (0, utils_1.Module)(utils_1.Modules.API_KEY, {
|
|
6
|
+
service: _services_1.ApiKeyModuleService,
|
|
7
|
+
});
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,kDAAwD;AACxD,yCAA+C;AAE/C,kBAAe,IAAA,cAAM,EAAC,eAAO,CAAC,OAAO,EAAE;IACrC,OAAO,EAAE,+BAAmB;CAC7B,CAAC,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const joinerConfig: Omit<import("@etohq/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys"> & Required<Pick<import("@etohq/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys">>;
|
|
2
|
+
//# sourceMappingURL=joiner-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joiner-config.d.ts","sourceRoot":"","sources":["../src/joiner-config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,iOAKvB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.joinerConfig = void 0;
|
|
4
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
5
|
+
exports.joinerConfig = (0, utils_1.defineJoinerConfig)(utils_1.Modules.API_KEY, {
|
|
6
|
+
linkableKeys: {
|
|
7
|
+
// Merged with the autogenerated ones to maintain backward compatibility
|
|
8
|
+
publishable_key_id: "ApiKey",
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=joiner-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joiner-config.js","sourceRoot":"","sources":["../src/joiner-config.ts"],"names":[],"mappings":";;;AAAA,kDAAoE;AAEvD,QAAA,YAAY,GAAG,IAAA,0BAAkB,EAAC,eAAO,CAAC,OAAO,EAAE;IAC9D,YAAY,EAAE;QACZ,wEAAwE;QACxE,kBAAkB,EAAE,QAAQ;KAC7B;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InitialSetup20240221144943.d.ts","sourceRoot":"","sources":["../../src/migrations/InitialSetup20240221144943.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,0BAA2B,SAAQ,SAAS;IACjD,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;CAW1B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InitialSetup20240221144943 = void 0;
|
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
|
5
|
+
class InitialSetup20240221144943 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
this.addSql('create table if not exists "api_key" ("id" text not null, "token" text not null, "salt" text not null, "redacted" text not null, "title" text not null, "type" text not null, "last_used_at" timestamptz null, "created_by" text not null, "created_at" timestamptz not null default now(), "revoked_by" text null, "revoked_at" timestamptz null, constraint "api_key_pkey" primary key ("id"));');
|
|
8
|
+
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_api_key_token_unique" ON "api_key" (token);');
|
|
9
|
+
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_api_key_type" ON "api_key" (type);');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.InitialSetup20240221144943 = InitialSetup20240221144943;
|
|
13
|
+
//# sourceMappingURL=InitialSetup20240221144943.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InitialSetup20240221144943.js","sourceRoot":"","sources":["../../src/migrations/InitialSetup20240221144943.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,MAAa,0BAA2B,SAAQ,sBAAS;IACvD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CACT,mYAAmY,CACpY,CAAA;QACD,IAAI,CAAC,MAAM,CACT,oFAAoF,CACrF,CAAA;QACD,IAAI,CAAC,MAAM,CACT,oEAAoE,CACrE,CAAA;IACH,CAAC;CACF;AAZD,gEAYC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20240604080145.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240604080145.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK5B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20240604080145 = void 0;
|
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
|
5
|
+
class Migration20240604080145 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
this.addSql('alter table if exists "api_key" add column if not exists "updated_at" timestamptz not null default now();');
|
|
8
|
+
}
|
|
9
|
+
async down() {
|
|
10
|
+
this.addSql('alter table if exists "api_key" drop column if exists "updated_at";');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.Migration20240604080145 = Migration20240604080145;
|
|
14
|
+
//# sourceMappingURL=Migration20240604080145.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20240604080145.js","sourceRoot":"","sources":["../../src/migrations/Migration20240604080145.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,MAAa,uBAAwB,SAAQ,sBAAS;IACpD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CACT,2GAA2G,CAC5G,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,MAAM,CACT,qEAAqE,CACtE,CAAA;IACH,CAAC;CACF;AAZD,0DAYC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20241205122700.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20241205122700.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAenB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAa5B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20241205122700 = void 0;
|
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
|
5
|
+
class Migration20241205122700 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
this.addSql('alter table if exists "api_key" add column if not exists "deleted_at" timestamptz null;');
|
|
8
|
+
this.addSql('alter table if exists "api_key" alter column "type" type text using ("type"::text);');
|
|
9
|
+
this.addSql('alter table if exists "api_key" add constraint "api_key_type_check" check ("type" in (\'publishable\', \'secret\'));');
|
|
10
|
+
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_api_key_deleted_at" ON "api_key" (deleted_at) WHERE deleted_at IS NULL;');
|
|
11
|
+
}
|
|
12
|
+
async down() {
|
|
13
|
+
this.addSql('alter table if exists "api_key" drop constraint if exists "api_key_type_check";');
|
|
14
|
+
this.addSql('alter table if exists "api_key" alter column "type" type text using ("type"::text);');
|
|
15
|
+
this.addSql('drop index if exists "IDX_api_key_deleted_at";');
|
|
16
|
+
this.addSql('alter table if exists "api_key" drop column if exists "deleted_at";');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.Migration20241205122700 = Migration20241205122700;
|
|
20
|
+
//# sourceMappingURL=Migration20241205122700.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20241205122700.js","sourceRoot":"","sources":["../../src/migrations/Migration20241205122700.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,MAAa,uBAAwB,SAAQ,sBAAS;IACpD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CACT,yFAAyF,CAC1F,CAAA;QACD,IAAI,CAAC,MAAM,CACT,qFAAqF,CACtF,CAAA;QACD,IAAI,CAAC,MAAM,CACT,sHAAsH,CACvH,CAAA;QACD,IAAI,CAAC,MAAM,CACT,yGAAyG,CAC1G,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,MAAM,CACT,iFAAiF,CAClF,CAAA;QAED,IAAI,CAAC,MAAM,CACT,qFAAqF,CACtF,CAAA;QACD,IAAI,CAAC,MAAM,CAAC,gDAAgD,CAAC,CAAA;QAC7D,IAAI,CAAC,MAAM,CACT,qEAAqE,CACtE,CAAA;IACH,CAAC;CACF;AA7BD,0DA6BC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const ApiKey: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
|
|
2
|
+
id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
|
|
3
|
+
token: import("@etohq/framework/utils").TextProperty;
|
|
4
|
+
salt: import("@etohq/framework/utils").TextProperty;
|
|
5
|
+
redacted: import("@etohq/framework/utils").TextProperty;
|
|
6
|
+
title: import("@etohq/framework/utils").TextProperty;
|
|
7
|
+
type: import("@etohq/framework/utils").EnumProperty<["publishable", "secret"]>;
|
|
8
|
+
last_used_at: import("@etohq/framework/utils").NullableModifier<Date, import("@etohq/framework/utils").DateTimeProperty>;
|
|
9
|
+
created_by: import("@etohq/framework/utils").TextProperty;
|
|
10
|
+
revoked_by: import("@etohq/framework/utils").NullableModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
11
|
+
revoked_at: import("@etohq/framework/utils").NullableModifier<Date, import("@etohq/framework/utils").DateTimeProperty>;
|
|
12
|
+
}>, "ApiKey">;
|
|
13
|
+
export default ApiKey;
|
|
14
|
+
//# sourceMappingURL=api-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/models/api-key.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,MAAM;;;;;;;;;;;aAqBR,CAAA;AAEJ,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
4
|
+
const ApiKey = utils_1.model
|
|
5
|
+
.define("ApiKey", {
|
|
6
|
+
id: utils_1.model.id({ prefix: "apk" }).primaryKey(),
|
|
7
|
+
token: utils_1.model.text(),
|
|
8
|
+
salt: utils_1.model.text(),
|
|
9
|
+
redacted: utils_1.model.text().searchable(),
|
|
10
|
+
title: utils_1.model.text().searchable(),
|
|
11
|
+
type: utils_1.model.enum(["publishable", "secret"]),
|
|
12
|
+
last_used_at: utils_1.model.dateTime().nullable(),
|
|
13
|
+
created_by: utils_1.model.text(),
|
|
14
|
+
revoked_by: utils_1.model.text().nullable(),
|
|
15
|
+
revoked_at: utils_1.model.dateTime().nullable(),
|
|
16
|
+
})
|
|
17
|
+
.indexes([
|
|
18
|
+
{
|
|
19
|
+
on: ["token"],
|
|
20
|
+
unique: true,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
on: ["type"],
|
|
24
|
+
},
|
|
25
|
+
]);
|
|
26
|
+
exports.default = ApiKey;
|
|
27
|
+
//# sourceMappingURL=api-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.js","sourceRoot":"","sources":["../../src/models/api-key.ts"],"names":[],"mappings":";;AAAA,kDAA8C;AAE9C,MAAM,MAAM,GAAG,aAAK;KACjB,MAAM,CAAC,QAAQ,EAAE;IAChB,EAAE,EAAE,aAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,UAAU,EAAE;IAC5C,KAAK,EAAE,aAAK,CAAC,IAAI,EAAE;IACnB,IAAI,EAAE,aAAK,CAAC,IAAI,EAAE;IAClB,QAAQ,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IACnC,KAAK,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IAChC,IAAI,EAAE,aAAK,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAC3C,YAAY,EAAE,aAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACzC,UAAU,EAAE,aAAK,CAAC,IAAI,EAAE;IACxB,UAAU,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACnC,UAAU,EAAE,aAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACxC,CAAC;KACD,OAAO,CAAC;IACP;QACE,EAAE,EAAE,CAAC,OAAO,CAAC;QACb,MAAM,EAAE,IAAI;KACb;IACD;QACE,EAAE,EAAE,CAAC,MAAM,CAAC;KACb;CACF,CAAC,CAAA;AAEJ,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ApiKey = void 0;
|
|
7
|
+
var api_key_1 = require("./api-key");
|
|
8
|
+
Object.defineProperty(exports, "ApiKey", { enumerable: true, get: function () { return __importDefault(api_key_1).default; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;;;;AAAA,qCAA6C;AAApC,kHAAA,OAAO,OAAU"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ApiKeyTypes, Context, DAL, FilterableApiKeyProps, FindConfig, IApiKeyModuleService, InferEntityType, InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes } from "@etohq/framework/types";
|
|
2
|
+
import { ApiKey } from "../models";
|
|
3
|
+
import { RevokeApiKeyInput, TokenDTO, UpdateApiKeyInput } from "../types";
|
|
4
|
+
type InjectedDependencies = {
|
|
5
|
+
baseRepository: DAL.RepositoryService;
|
|
6
|
+
apiKeyService: ModulesSdkTypes.IEtoInternalService<any>;
|
|
7
|
+
};
|
|
8
|
+
declare const ApiKeyModuleService_base: import("@etohq/framework/utils").EtoServiceReturnType<{
|
|
9
|
+
ApiKey: {
|
|
10
|
+
dto: ApiKeyTypes.ApiKeyDTO;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
export declare class ApiKeyModuleService extends ApiKeyModuleService_base implements IApiKeyModuleService {
|
|
14
|
+
protected readonly moduleDeclaration: InternalModuleDeclaration;
|
|
15
|
+
protected baseRepository_: DAL.RepositoryService;
|
|
16
|
+
protected readonly apiKeyService_: ModulesSdkTypes.IEtoInternalService<InferEntityType<typeof ApiKey>>;
|
|
17
|
+
constructor({ baseRepository, apiKeyService }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
|
|
18
|
+
__joinerConfig(): ModuleJoinerConfig;
|
|
19
|
+
deleteApiKeys(ids: string | string[], sharedContext?: Context): Promise<void>;
|
|
20
|
+
createApiKeys(data: ApiKeyTypes.CreateApiKeyDTO[], sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
|
|
21
|
+
createApiKeys(data: ApiKeyTypes.CreateApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
|
|
22
|
+
protected createApiKeys_(data: ApiKeyTypes.CreateApiKeyDTO[], sharedContext?: Context): Promise<[InferEntityType<typeof ApiKey>[], TokenDTO[]]>;
|
|
23
|
+
upsertApiKeys(data: ApiKeyTypes.UpsertApiKeyDTO[], sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
|
|
24
|
+
upsertApiKeys(data: ApiKeyTypes.UpsertApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
|
|
25
|
+
updateApiKeys(id: string, data: ApiKeyTypes.UpdateApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
|
|
26
|
+
updateApiKeys(selector: FilterableApiKeyProps, data: ApiKeyTypes.UpdateApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
|
|
27
|
+
protected updateApiKeys_(normalizedInput: UpdateApiKeyInput[], sharedContext?: Context): Promise<InferEntityType<typeof ApiKey>[]>;
|
|
28
|
+
retrieveApiKey(id: string, config?: FindConfig<ApiKeyTypes.ApiKeyDTO>, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
|
|
29
|
+
listApiKeys(filters?: ApiKeyTypes.FilterableApiKeyProps, config?: FindConfig<ApiKeyTypes.ApiKeyDTO>, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
|
|
30
|
+
listAndCountApiKeys(filters?: ApiKeyTypes.FilterableApiKeyProps, config?: FindConfig<ApiKeyTypes.ApiKeyDTO>, sharedContext?: Context): Promise<[ApiKeyTypes.ApiKeyDTO[], number]>;
|
|
31
|
+
revoke(id: string, data: ApiKeyTypes.RevokeApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO>;
|
|
32
|
+
revoke(selector: FilterableApiKeyProps, data: ApiKeyTypes.RevokeApiKeyDTO, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO[]>;
|
|
33
|
+
revoke_(normalizedInput: RevokeApiKeyInput[], sharedContext?: Context): Promise<InferEntityType<typeof ApiKey>[]>;
|
|
34
|
+
authenticate(token: string, sharedContext?: Context): Promise<ApiKeyTypes.ApiKeyDTO | false>;
|
|
35
|
+
protected authenticate_(token: string, sharedContext?: Context): Promise<InferEntityType<typeof ApiKey> | false>;
|
|
36
|
+
protected validateCreateApiKeys_(data: ApiKeyTypes.CreateApiKeyDTO[], sharedContext?: Context): Promise<void>;
|
|
37
|
+
protected normalizeUpdateInput_<T>(idOrSelector: string | FilterableApiKeyProps, data: Omit<T, "id">, sharedContext?: Context): Promise<T[]>;
|
|
38
|
+
protected validateRevokeApiKeys_(data: RevokeApiKeyInput[], sharedContext?: Context): Promise<void>;
|
|
39
|
+
protected static generatePublishableKey(): TokenDTO;
|
|
40
|
+
protected static generateSecretKey(): Promise<TokenDTO>;
|
|
41
|
+
protected static calculateHash(token: string, salt: string): Promise<string>;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=api-key-module-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key-module-service.d.ts","sourceRoot":"","sources":["../../src/services/api-key-module-service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,OAAO,EACP,GAAG,EACH,qBAAqB,EACrB,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EAChB,MAAM,wBAAwB,CAAA;AAa/B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAEL,iBAAiB,EACjB,QAAQ,EACR,iBAAiB,EAClB,MAAM,QAAQ,CAAA;AAOf,KAAK,oBAAoB,GAAG;IAC1B,cAAc,EAAE,GAAG,CAAC,iBAAiB,CAAA;IACrC,aAAa,EAAE,eAAe,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAA;CACxD,CAAA;;YAIW;QAAE,GAAG,EAAE,WAAW,CAAC,SAAS,CAAA;KAAE;;AAF1C,qBAAa,mBACX,SAAQ,wBAGR,YAAW,oBAAoB;IAS7B,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,yBAAyB;IAPjE,SAAS,CAAC,eAAe,EAAE,GAAG,CAAC,iBAAiB,CAAA;IAChD,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,eAAe,CAAC,mBAAmB,CACpE,eAAe,CAAC,OAAO,MAAM,CAAC,CAC/B,CAAA;gBAGC,EAAE,cAAc,EAAE,aAAa,EAAE,EAAE,oBAAoB,EACpC,iBAAiB,EAAE,yBAAyB;IAQjE,cAAc,IAAI,kBAAkB;IAM9B,aAAa,CACjB,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EACR,aAAa,GAAE,OAAY;IA+B3C,aAAa,CACX,IAAI,EAAE,WAAW,CAAC,eAAe,EAAE,EACnC,aAA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AY,EAAE,MAAM,GAAG,qBAAqB,EAC5C,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,EACnB,aAAa,GAAE,OAAY,GAC1B,OAAO,CAAC,CAAC,EAAE,CAAC;cAyBC,sBAAsB,CACpC,IAAI,EAAE,iBAAiB,EAAE,EACzB,aAAa,GAAE,OAAY,GAC1B,OAAO,CAAC,IAAI,CAAC;IAsChB,SAAS,CAAC,MAAM,CAAC,sBAAsB,IAAI,QAAQ;qBAW5B,iBAAiB,IAAI,OAAO,CAAC,QAAQ,CAAC;qBAatC,aAAa,CAClC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC;CAGnB"}
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ApiKeyModuleService = void 0;
|
|
19
|
+
const types_1 = require("@etohq/framework/types");
|
|
20
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
21
|
+
const _models_1 = require("../models");
|
|
22
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
23
|
+
const util_1 = __importDefault(require("util"));
|
|
24
|
+
const joiner_config_1 = require("../joiner-config");
|
|
25
|
+
const scrypt = util_1.default.promisify(crypto_1.default.scrypt);
|
|
26
|
+
class ApiKeyModuleService extends (0, utils_1.EtoService)({ ApiKey: _models_1.ApiKey }) {
|
|
27
|
+
constructor({ baseRepository, apiKeyService }, moduleDeclaration) {
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.moduleDeclaration = moduleDeclaration;
|
|
31
|
+
this.baseRepository_ = baseRepository;
|
|
32
|
+
this.apiKeyService_ = apiKeyService;
|
|
33
|
+
}
|
|
34
|
+
__joinerConfig() {
|
|
35
|
+
return joiner_config_1.joinerConfig;
|
|
36
|
+
}
|
|
37
|
+
// @ts-expect-error
|
|
38
|
+
async deleteApiKeys(ids, sharedContext = {}) {
|
|
39
|
+
const apiKeyIds = Array.isArray(ids) ? ids : [ids];
|
|
40
|
+
const unrevokedApiKeys = (await this.apiKeyService_.list({
|
|
41
|
+
id: ids,
|
|
42
|
+
$or: [
|
|
43
|
+
{ revoked_at: { $eq: null } },
|
|
44
|
+
{ revoked_at: { $gt: new Date() } },
|
|
45
|
+
],
|
|
46
|
+
}, { select: ["id"] }, sharedContext)).map((apiKey) => apiKey.id);
|
|
47
|
+
if ((0, utils_1.isPresent)(unrevokedApiKeys)) {
|
|
48
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.NOT_ALLOWED, `Cannot delete api keys that are not revoked - ${unrevokedApiKeys.join(", ")}`);
|
|
49
|
+
}
|
|
50
|
+
return await super.deleteApiKeys(apiKeyIds, sharedContext);
|
|
51
|
+
}
|
|
52
|
+
async createApiKeys(data, sharedContext = {}) {
|
|
53
|
+
const [createdApiKeys, generatedTokens] = await this.createApiKeys_(Array.isArray(data) ? data : [data], sharedContext);
|
|
54
|
+
const serializedResponse = await this.baseRepository_.serialize(createdApiKeys, {
|
|
55
|
+
populate: true,
|
|
56
|
+
});
|
|
57
|
+
// When creating we want to return the raw token, as this will be the only time the user will be able to take note of it for future use.
|
|
58
|
+
const responseWithRawToken = serializedResponse.map((key) => ({
|
|
59
|
+
...key,
|
|
60
|
+
token: generatedTokens.find((t) => t.hashedToken === key.token)?.rawToken ??
|
|
61
|
+
key.token,
|
|
62
|
+
salt: undefined,
|
|
63
|
+
}));
|
|
64
|
+
return Array.isArray(data) ? responseWithRawToken : responseWithRawToken[0];
|
|
65
|
+
}
|
|
66
|
+
async createApiKeys_(data, sharedContext = {}) {
|
|
67
|
+
await this.validateCreateApiKeys_(data, sharedContext);
|
|
68
|
+
const normalizedInput = [];
|
|
69
|
+
const generatedTokens = [];
|
|
70
|
+
for (const key of data) {
|
|
71
|
+
let tokenData;
|
|
72
|
+
if (key.type === utils_1.ApiKeyType.PUBLISHABLE) {
|
|
73
|
+
tokenData = ApiKeyModuleService.generatePublishableKey();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
tokenData = await ApiKeyModuleService.generateSecretKey();
|
|
77
|
+
}
|
|
78
|
+
generatedTokens.push(tokenData);
|
|
79
|
+
normalizedInput.push({
|
|
80
|
+
...key,
|
|
81
|
+
token: tokenData.hashedToken,
|
|
82
|
+
salt: tokenData.salt,
|
|
83
|
+
redacted: tokenData.redacted,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const createdApiKeys = await this.apiKeyService_.create(normalizedInput, sharedContext);
|
|
87
|
+
return [createdApiKeys, generatedTokens];
|
|
88
|
+
}
|
|
89
|
+
async upsertApiKeys(data, sharedContext = {}) {
|
|
90
|
+
const input = Array.isArray(data) ? data : [data];
|
|
91
|
+
const forUpdate = input.filter((apiKey) => !!apiKey.id);
|
|
92
|
+
const forCreate = input.filter((apiKey) => !apiKey.id);
|
|
93
|
+
const operations = [];
|
|
94
|
+
if (forCreate.length) {
|
|
95
|
+
const op = async () => {
|
|
96
|
+
const [createdApiKeys, generatedTokens] = await this.createApiKeys_(forCreate, sharedContext);
|
|
97
|
+
const serializedResponse = await this.baseRepository_.serialize(createdApiKeys, {
|
|
98
|
+
populate: true,
|
|
99
|
+
});
|
|
100
|
+
return serializedResponse.map((key) => ({
|
|
101
|
+
...key,
|
|
102
|
+
token: generatedTokens.find((t) => t.hashedToken === key.token)
|
|
103
|
+
?.rawToken ?? key.token,
|
|
104
|
+
salt: undefined,
|
|
105
|
+
}));
|
|
106
|
+
};
|
|
107
|
+
operations.push(op());
|
|
108
|
+
}
|
|
109
|
+
if (forUpdate.length) {
|
|
110
|
+
const op = async () => {
|
|
111
|
+
const updateResp = await this.updateApiKeys_(forUpdate, sharedContext);
|
|
112
|
+
return await this.baseRepository_.serialize(updateResp);
|
|
113
|
+
};
|
|
114
|
+
operations.push(op());
|
|
115
|
+
}
|
|
116
|
+
const result = (await (0, utils_1.promiseAll)(operations)).flat();
|
|
117
|
+
return Array.isArray(data) ? result : result[0];
|
|
118
|
+
}
|
|
119
|
+
async updateApiKeys(idOrSelector, data, sharedContext = {}) {
|
|
120
|
+
let normalizedInput = await this.normalizeUpdateInput_(idOrSelector, data, sharedContext);
|
|
121
|
+
const updatedApiKeys = await this.updateApiKeys_(normalizedInput, sharedContext);
|
|
122
|
+
const serializedResponse = await this.baseRepository_.serialize(updatedApiKeys.map(omitToken), {
|
|
123
|
+
populate: true,
|
|
124
|
+
});
|
|
125
|
+
return (0, utils_1.isString)(idOrSelector) ? serializedResponse[0] : serializedResponse;
|
|
126
|
+
}
|
|
127
|
+
async updateApiKeys_(normalizedInput, sharedContext = {}) {
|
|
128
|
+
const updateRequest = normalizedInput.map((k) => ({
|
|
129
|
+
id: k.id,
|
|
130
|
+
title: k.title,
|
|
131
|
+
}));
|
|
132
|
+
const updatedApiKeys = await this.apiKeyService_.update(updateRequest, sharedContext);
|
|
133
|
+
return updatedApiKeys;
|
|
134
|
+
}
|
|
135
|
+
// @ts-expect-error
|
|
136
|
+
async retrieveApiKey(id, config, sharedContext) {
|
|
137
|
+
const apiKey = await this.apiKeyService_.retrieve(id, config, sharedContext);
|
|
138
|
+
return await this.baseRepository_.serialize(omitToken(apiKey), {
|
|
139
|
+
populate: true,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
//@ts-expect-error
|
|
143
|
+
async listApiKeys(filters, config, sharedContext) {
|
|
144
|
+
const apiKeys = await this.apiKeyService_.list(filters, config, sharedContext);
|
|
145
|
+
return await this.baseRepository_.serialize(apiKeys.map(omitToken), {
|
|
146
|
+
populate: true,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
//@ts-expect-error
|
|
150
|
+
async listAndCountApiKeys(filters, config, sharedContext) {
|
|
151
|
+
const [apiKeys, count] = await this.apiKeyService_.listAndCount(filters, config, sharedContext);
|
|
152
|
+
return [
|
|
153
|
+
await this.baseRepository_.serialize(apiKeys.map(omitToken), {
|
|
154
|
+
populate: true,
|
|
155
|
+
}),
|
|
156
|
+
count,
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
async revoke(idOrSelector, data, sharedContext = {}) {
|
|
160
|
+
const normalizedInput = await this.normalizeUpdateInput_(idOrSelector, data, sharedContext);
|
|
161
|
+
const revokedApiKeys = await this.revoke_(normalizedInput, sharedContext);
|
|
162
|
+
const serializedResponse = await this.baseRepository_.serialize(revokedApiKeys.map(omitToken), {
|
|
163
|
+
populate: true,
|
|
164
|
+
});
|
|
165
|
+
return (0, utils_1.isString)(idOrSelector) ? serializedResponse[0] : serializedResponse;
|
|
166
|
+
}
|
|
167
|
+
async revoke_(normalizedInput, sharedContext = {}) {
|
|
168
|
+
await this.validateRevokeApiKeys_(normalizedInput);
|
|
169
|
+
const updateRequest = normalizedInput.map((k) => {
|
|
170
|
+
const revokedAt = new Date();
|
|
171
|
+
if (k.revoke_in && k.revoke_in > 0) {
|
|
172
|
+
revokedAt.setSeconds(revokedAt.getSeconds() + k.revoke_in);
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
id: k.id,
|
|
176
|
+
revoked_at: revokedAt,
|
|
177
|
+
revoked_by: k.revoked_by,
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
const revokedApiKeys = await this.apiKeyService_.update(updateRequest, sharedContext);
|
|
181
|
+
return revokedApiKeys;
|
|
182
|
+
}
|
|
183
|
+
async authenticate(token, sharedContext = {}) {
|
|
184
|
+
const result = await this.authenticate_(token, sharedContext);
|
|
185
|
+
if (!result) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
const serialized = await this.baseRepository_.serialize(result, {
|
|
189
|
+
populate: true,
|
|
190
|
+
});
|
|
191
|
+
return serialized;
|
|
192
|
+
}
|
|
193
|
+
async authenticate_(token, sharedContext = {}) {
|
|
194
|
+
// Since we only allow up to 2 active tokens, getitng the list and checking each token isn't an issue.
|
|
195
|
+
// We can always filter on the redacted key if we add support for an arbitrary number of tokens.
|
|
196
|
+
const secretKeys = await this.apiKeyService_.list({
|
|
197
|
+
type: utils_1.ApiKeyType.SECRET,
|
|
198
|
+
// If the revoke date is set in the future, it means the key is still valid.
|
|
199
|
+
$or: [
|
|
200
|
+
{ revoked_at: { $eq: null } },
|
|
201
|
+
{ revoked_at: { $gt: new Date() } },
|
|
202
|
+
],
|
|
203
|
+
}, {}, sharedContext);
|
|
204
|
+
const matches = await (0, utils_1.promiseAll)(secretKeys.map(async (dbKey) => {
|
|
205
|
+
const hashedInput = await ApiKeyModuleService.calculateHash(token, dbKey.salt);
|
|
206
|
+
if (hashedInput === dbKey.token) {
|
|
207
|
+
return dbKey;
|
|
208
|
+
}
|
|
209
|
+
return undefined;
|
|
210
|
+
}));
|
|
211
|
+
const matchedKeys = matches.filter((match) => !!match);
|
|
212
|
+
if (!matchedKeys.length) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
return matchedKeys[0];
|
|
216
|
+
}
|
|
217
|
+
async validateCreateApiKeys_(data, sharedContext = {}) {
|
|
218
|
+
if (!data.length) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
// There can only be 2 secret keys at most, and one has to be with a revoked_at date set, so only 1 can be newly created.
|
|
222
|
+
const secretKeysToCreate = data.filter((k) => k.type === utils_1.ApiKeyType.SECRET);
|
|
223
|
+
if (!secretKeysToCreate.length) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (secretKeysToCreate.length > 1) {
|
|
227
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, `You can only create one secret key at a time. You tried to create ${secretKeysToCreate.length} secret keys.`);
|
|
228
|
+
}
|
|
229
|
+
// There already is a key that is not set to expire/or it hasn't expired
|
|
230
|
+
const dbSecretKeys = await this.apiKeyService_.list({
|
|
231
|
+
type: utils_1.ApiKeyType.SECRET,
|
|
232
|
+
$or: [
|
|
233
|
+
{ revoked_at: { $eq: null } },
|
|
234
|
+
{ revoked_at: { $gt: new Date() } },
|
|
235
|
+
],
|
|
236
|
+
}, {}, sharedContext);
|
|
237
|
+
if (dbSecretKeys.length) {
|
|
238
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, `You can only have one active secret key a time. Revoke or delete your existing key before creating a new one.`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async normalizeUpdateInput_(idOrSelector, data, sharedContext = {}) {
|
|
242
|
+
let normalizedInput = [];
|
|
243
|
+
if ((0, utils_1.isString)(idOrSelector)) {
|
|
244
|
+
normalizedInput = [{ id: idOrSelector, ...data }];
|
|
245
|
+
}
|
|
246
|
+
if ((0, utils_1.isObject)(idOrSelector)) {
|
|
247
|
+
const apiKeys = await this.apiKeyService_.list(idOrSelector, {}, sharedContext);
|
|
248
|
+
normalizedInput = apiKeys.map((apiKey) => ({
|
|
249
|
+
id: apiKey.id,
|
|
250
|
+
...data,
|
|
251
|
+
}));
|
|
252
|
+
}
|
|
253
|
+
return normalizedInput;
|
|
254
|
+
}
|
|
255
|
+
async validateRevokeApiKeys_(data, sharedContext = {}) {
|
|
256
|
+
if (!data.length) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (data.some((k) => !k.id)) {
|
|
260
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, `You must provide an api key id field when revoking a key.`);
|
|
261
|
+
}
|
|
262
|
+
if (data.some((k) => !k.revoked_by)) {
|
|
263
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, `You must provide a revoked_by field when revoking a key.`);
|
|
264
|
+
}
|
|
265
|
+
const revokedApiKeys = await this.apiKeyService_.list({
|
|
266
|
+
id: data.map((k) => k.id),
|
|
267
|
+
type: utils_1.ApiKeyType.SECRET,
|
|
268
|
+
revoked_at: { $ne: null },
|
|
269
|
+
}, {}, sharedContext);
|
|
270
|
+
if (revokedApiKeys.length) {
|
|
271
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, `There are ${revokedApiKeys.length} secret keys that are already revoked.`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
// These are public keys, so there is no point hashing them.
|
|
275
|
+
static generatePublishableKey() {
|
|
276
|
+
const token = "pk_" + crypto_1.default.randomBytes(32).toString("hex");
|
|
277
|
+
return {
|
|
278
|
+
rawToken: token,
|
|
279
|
+
hashedToken: token,
|
|
280
|
+
salt: "",
|
|
281
|
+
redacted: redactKey(token),
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
static async generateSecretKey() {
|
|
285
|
+
const token = "sk_" + crypto_1.default.randomBytes(32).toString("hex");
|
|
286
|
+
const salt = crypto_1.default.randomBytes(16).toString("hex");
|
|
287
|
+
const hashed = await this.calculateHash(token, salt);
|
|
288
|
+
return {
|
|
289
|
+
rawToken: token,
|
|
290
|
+
hashedToken: hashed,
|
|
291
|
+
salt,
|
|
292
|
+
redacted: redactKey(token),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
static async calculateHash(token, salt) {
|
|
296
|
+
return (await scrypt(token, salt, 64)).toString("hex");
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
exports.ApiKeyModuleService = ApiKeyModuleService;
|
|
300
|
+
__decorate([
|
|
301
|
+
(0, utils_1.InjectTransactionManager)()
|
|
302
|
+
// @ts-expect-error
|
|
303
|
+
,
|
|
304
|
+
__param(1, (0, utils_1.EtoContext)()),
|
|
305
|
+
__metadata("design:type", Function),
|
|
306
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
307
|
+
__metadata("design:returntype", Promise)
|
|
308
|
+
], ApiKeyModuleService.prototype, "deleteApiKeys", null);
|
|
309
|
+
__decorate([
|
|
310
|
+
(0, utils_1.InjectManager)(),
|
|
311
|
+
__param(1, (0, utils_1.EtoContext)()),
|
|
312
|
+
__metadata("design:type", Function),
|
|
313
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
314
|
+
__metadata("design:returntype", Promise)
|
|
315
|
+
], ApiKeyModuleService.prototype, "createApiKeys", null);
|
|
316
|
+
__decorate([
|
|
317
|
+
(0, utils_1.InjectTransactionManager)(),
|
|
318
|
+
__param(1, (0, utils_1.EtoContext)()),
|
|
319
|
+
__metadata("design:type", Function),
|
|
320
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
321
|
+
__metadata("design:returntype", Promise)
|
|
322
|
+
], ApiKeyModuleService.prototype, "createApiKeys_", null);
|
|
323
|
+
__decorate([
|
|
324
|
+
(0, utils_1.InjectManager)(),
|
|
325
|
+
__param(1, (0, utils_1.EtoContext)()),
|
|
326
|
+
__metadata("design:type", Function),
|
|
327
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
328
|
+
__metadata("design:returntype", Promise)
|
|
329
|
+
], ApiKeyModuleService.prototype, "upsertApiKeys", null);
|
|
330
|
+
__decorate([
|
|
331
|
+
(0, utils_1.InjectManager)(),
|
|
332
|
+
__param(2, (0, utils_1.EtoContext)()),
|
|
333
|
+
__metadata("design:type", Function),
|
|
334
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
335
|
+
__metadata("design:returntype", Promise)
|
|
336
|
+
], ApiKeyModuleService.prototype, "updateApiKeys", null);
|
|
337
|
+
__decorate([
|
|
338
|
+
(0, utils_1.InjectTransactionManager)(),
|
|
339
|
+
__param(1, (0, utils_1.EtoContext)()),
|
|
340
|
+
__metadata("design:type", Function),
|
|
341
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
342
|
+
__metadata("design:returntype", Promise)
|
|
343
|
+
], ApiKeyModuleService.prototype, "updateApiKeys_", null);
|
|
344
|
+
__decorate([
|
|
345
|
+
(0, utils_1.InjectManager)()
|
|
346
|
+
// @ts-expect-error
|
|
347
|
+
,
|
|
348
|
+
__metadata("design:type", Function),
|
|
349
|
+
__metadata("design:paramtypes", [String, Object, Object]),
|
|
350
|
+
__metadata("design:returntype", Promise)
|
|
351
|
+
], ApiKeyModuleService.prototype, "retrieveApiKey", null);
|
|
352
|
+
__decorate([
|
|
353
|
+
(0, utils_1.InjectManager)()
|
|
354
|
+
//@ts-expect-error
|
|
355
|
+
,
|
|
356
|
+
__metadata("design:type", Function),
|
|
357
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
358
|
+
__metadata("design:returntype", Promise)
|
|
359
|
+
], ApiKeyModuleService.prototype, "listApiKeys", null);
|
|
360
|
+
__decorate([
|
|
361
|
+
(0, utils_1.InjectManager)()
|
|
362
|
+
//@ts-expect-error
|
|
363
|
+
,
|
|
364
|
+
__metadata("design:type", Function),
|
|
365
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
366
|
+
__metadata("design:returntype", Promise)
|
|
367
|
+
], ApiKeyModuleService.prototype, "listAndCountApiKeys", null);
|
|
368
|
+
__decorate([
|
|
369
|
+
(0, utils_1.InjectManager)(),
|
|
370
|
+
__param(2, (0, utils_1.EtoContext)()),
|
|
371
|
+
__metadata("design:type", Function),
|
|
372
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
373
|
+
__metadata("design:returntype", Promise)
|
|
374
|
+
], ApiKeyModuleService.prototype, "revoke", null);
|
|
375
|
+
__decorate([
|
|
376
|
+
(0, utils_1.InjectTransactionManager)(),
|
|
377
|
+
__param(1, (0, utils_1.EtoContext)()),
|
|
378
|
+
__metadata("design:type", Function),
|
|
379
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
380
|
+
__metadata("design:returntype", Promise)
|
|
381
|
+
], ApiKeyModuleService.prototype, "revoke_", null);
|
|
382
|
+
__decorate([
|
|
383
|
+
(0, utils_1.InjectManager)(),
|
|
384
|
+
__param(1, (0, utils_1.EtoContext)()),
|
|
385
|
+
__metadata("design:type", Function),
|
|
386
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
387
|
+
__metadata("design:returntype", Promise)
|
|
388
|
+
], ApiKeyModuleService.prototype, "authenticate", null);
|
|
389
|
+
__decorate([
|
|
390
|
+
(0, utils_1.InjectTransactionManager)(),
|
|
391
|
+
__param(1, (0, utils_1.EtoContext)()),
|
|
392
|
+
__metadata("design:type", Function),
|
|
393
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
394
|
+
__metadata("design:returntype", Promise)
|
|
395
|
+
], ApiKeyModuleService.prototype, "authenticate_", null);
|
|
396
|
+
// We are mutating the object here as what microORM relies on non-enumerable fields for serialization, among other things.
|
|
397
|
+
const omitToken = (
|
|
398
|
+
// We have to make salt optional before deleting it (and we do want it required in the DB)
|
|
399
|
+
key) => {
|
|
400
|
+
key.token = key.type === utils_1.ApiKeyType.SECRET ? "" : key.token;
|
|
401
|
+
delete key.salt;
|
|
402
|
+
return key;
|
|
403
|
+
};
|
|
404
|
+
const redactKey = (key) => {
|
|
405
|
+
return [key.slice(0, 6), key.slice(-3)].join("***");
|
|
406
|
+
};
|
|
407
|
+
//# sourceMappingURL=api-key-module-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key-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|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiKeyModuleService = void 0;
|
|
4
|
+
var api_key_module_service_1 = require("./api-key-module-service");
|
|
5
|
+
Object.defineProperty(exports, "ApiKeyModuleService", { enumerable: true, get: function () { return api_key_module_service_1.ApiKeyModuleService; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,mEAA8D;AAArD,6HAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/index.ts","../src/joiner-config.ts","../src/migrations/InitialSetup20240221144943.ts","../src/migrations/Migration20240604080145.ts","../src/migrations/Migration20241205122700.ts","../src/models/api-key.ts","../src/models/index.ts","../src/services/api-key-module-service.ts","../src/services/index.ts","../src/services/__tests__/noop.ts","../src/types/index.ts"],"version":"5.6.2"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ApiKeyType, IEventBusModuleService, Logger, RevokeApiKeyDTO, UpdateApiKeyDTO } from "@etohq/framework/types";
|
|
2
|
+
export type InitializeModuleInjectableDependencies = {
|
|
3
|
+
logger?: Logger;
|
|
4
|
+
EventBus?: IEventBusModuleService;
|
|
5
|
+
};
|
|
6
|
+
export type CreateApiKeyDTO = {
|
|
7
|
+
token: string;
|
|
8
|
+
salt: string;
|
|
9
|
+
redacted: string;
|
|
10
|
+
title: string;
|
|
11
|
+
type: ApiKeyType;
|
|
12
|
+
created_by: string;
|
|
13
|
+
};
|
|
14
|
+
export type TokenDTO = {
|
|
15
|
+
rawToken: string;
|
|
16
|
+
hashedToken: string;
|
|
17
|
+
salt: string;
|
|
18
|
+
redacted: string;
|
|
19
|
+
};
|
|
20
|
+
export type UpdateApiKeyInput = UpdateApiKeyDTO & {
|
|
21
|
+
id: string;
|
|
22
|
+
};
|
|
23
|
+
export type RevokeApiKeyInput = RevokeApiKeyDTO & {
|
|
24
|
+
id: string;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,MAAM,EACN,eAAe,EACf,eAAe,EAChB,MAAM,wBAAwB,CAAA;AAE/B,MAAM,MAAM,sCAAsC,GAAG;IACnD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,sBAAsB,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,UAAU,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,eAAe,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAChE,MAAM,MAAM,iBAAiB,GAAG,eAAe,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@etohq/api-key",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Eto API Key module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"!dist/**/__tests__",
|
|
10
|
+
"!dist/**/__mocks__",
|
|
11
|
+
"!dist/**/__fixtures__"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/etohq/eto",
|
|
19
|
+
"directory": "packages/api-key"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"author": "Eto",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"watch": "tsc --build --watch",
|
|
28
|
+
"watch:test": "tsc --build tsconfig.spec.json --watch",
|
|
29
|
+
"resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", "build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
|
30
|
+
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
|
|
31
|
+
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
|
32
|
+
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:create --initial",
|
|
33
|
+
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:create",
|
|
34
|
+
"migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:up",
|
|
35
|
+
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm cache:clear"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@etohq/test-utils": "^1.0.0",
|
|
39
|
+
"@mikro-orm/cli": "5.9.7",
|
|
40
|
+
"@swc/core": "^1.7.28",
|
|
41
|
+
"@swc/jest": "^0.2.36",
|
|
42
|
+
"@types/jest": "^29.5.14",
|
|
43
|
+
"jest": "^29.7.0",
|
|
44
|
+
"rimraf": "^5.0.2",
|
|
45
|
+
"tsc-alias": "^1.8.6",
|
|
46
|
+
"typescript": "^5.6.2"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@etohq/framework": "^1.0.0",
|
|
50
|
+
"@mikro-orm/core": "5.9.7",
|
|
51
|
+
"@mikro-orm/migrations": "5.9.7",
|
|
52
|
+
"@mikro-orm/postgresql": "5.9.7",
|
|
53
|
+
"awilix": "^8.0.1"
|
|
54
|
+
}
|
|
55
|
+
}
|