@aep-foundation/next 0.1.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/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/index.cjs +99 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +70 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @aep-foundation/next
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1](https://github.com/aep-foundation/aep-node/pull/1) [`3d4713e`](https://github.com/aep-foundation/aep-node/commit/3d4713e2a9cf85478a415192c7c0abc90c374073) Thanks [@nkavian](https://github.com/nkavian)! - Add the initial AEP Node SDK packages, framework adapters, and conformance helpers.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`3d4713e`](https://github.com/aep-foundation/aep-node/commit/3d4713e2a9cf85478a415192c7c0abc90c374073)]:
|
|
12
|
+
- @aep-foundation/core@0.1.0
|
|
13
|
+
- @aep-foundation/service@0.1.0
|
|
14
|
+
|
|
15
|
+
## 0.0.0
|
|
16
|
+
|
|
17
|
+
Initial development version.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AEP Foundation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
AEP_NEXT_MEDIA_TYPE: () => AEP_NEXT_MEDIA_TYPE,
|
|
24
|
+
createNextAepCommandRouteHandler: () => createNextAepCommandRouteHandler,
|
|
25
|
+
createNextAepRoute: () => createNextAepRoute,
|
|
26
|
+
createNextAepRouteHandler: () => createNextAepRouteHandler,
|
|
27
|
+
packageName: () => packageName
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(index_exports);
|
|
30
|
+
var import_service = require("@aep-foundation/service");
|
|
31
|
+
var packageName = "@aep-foundation/next";
|
|
32
|
+
var AEP_NEXT_MEDIA_TYPE = "application/aep+json";
|
|
33
|
+
function createNextAepRouteHandler(input) {
|
|
34
|
+
const service = resolveService(input);
|
|
35
|
+
return () => new Response(JSON.stringify(service.inspectDocument()), {
|
|
36
|
+
headers: {
|
|
37
|
+
"Content-Type": AEP_NEXT_MEDIA_TYPE
|
|
38
|
+
},
|
|
39
|
+
status: 200
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function createNextAepCommandRouteHandler(input, command) {
|
|
43
|
+
const service = resolveService(input);
|
|
44
|
+
return async (request) => {
|
|
45
|
+
const clientAssertion = parseAepAuthorization(
|
|
46
|
+
request?.headers.get("Authorization") ?? void 0
|
|
47
|
+
);
|
|
48
|
+
const idempotencyKey = request?.headers.get("Idempotency-Key") ?? void 0;
|
|
49
|
+
const body = command === "status" ? void 0 : await request?.json();
|
|
50
|
+
const commandOptions = authenticatedOptions(clientAssertion, idempotencyKey);
|
|
51
|
+
const result = command === "enroll" ? await service.enroll(body, commandOptions) : command === "status" ? await service.status({ clientAssertion }) : command === "grant" ? await service.grant(body, commandOptions) : await service.revoke(body, commandOptions);
|
|
52
|
+
return new Response(JSON.stringify(result.body), {
|
|
53
|
+
headers: {
|
|
54
|
+
"Content-Type": result.contentType
|
|
55
|
+
},
|
|
56
|
+
status: result.status
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function authenticatedOptions(clientAssertion, idempotencyKey) {
|
|
61
|
+
return {
|
|
62
|
+
clientAssertion,
|
|
63
|
+
...idempotencyKey === void 0 ? {} : { idempotencyKey }
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function createNextAepRoute(input, command = "inspect") {
|
|
67
|
+
if (command === "inspect") {
|
|
68
|
+
return {
|
|
69
|
+
GET: createNextAepRouteHandler(input)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (command === "status") {
|
|
73
|
+
return {
|
|
74
|
+
GET: createNextAepCommandRouteHandler(input, command)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
POST: createNextAepCommandRouteHandler(input, command)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function parseAepAuthorization(authorization) {
|
|
82
|
+
const prefix = "AEP ";
|
|
83
|
+
if (authorization?.startsWith(prefix)) {
|
|
84
|
+
return authorization.slice(prefix.length);
|
|
85
|
+
}
|
|
86
|
+
return "";
|
|
87
|
+
}
|
|
88
|
+
function resolveService(input) {
|
|
89
|
+
return "inspectDocument" in input ? input : (0, import_service.createAepService)(input);
|
|
90
|
+
}
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
AEP_NEXT_MEDIA_TYPE,
|
|
94
|
+
createNextAepCommandRouteHandler,
|
|
95
|
+
createNextAepRoute,
|
|
96
|
+
createNextAepRouteHandler,
|
|
97
|
+
packageName
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createAepService } from \"@aep-foundation/service\";\nimport type {\n AepAuthenticatedServiceOptions,\n AepService,\n AepServiceOptions\n} from \"@aep-foundation/service\";\n\nexport const packageName = \"@aep-foundation/next\";\nexport const AEP_NEXT_MEDIA_TYPE = \"application/aep+json\";\n\nexport type NextAepServiceInput = AepService | AepServiceOptions;\nexport type NextAepCommand = \"enroll\" | \"grant\" | \"inspect\" | \"revoke\" | \"status\";\nexport type NextAepRouteHandler = (request?: Request) => Promise<Response> | Response;\n\nexport function createNextAepRouteHandler(input: NextAepServiceInput): NextAepRouteHandler {\n const service = resolveService(input);\n\n return () =>\n new Response(JSON.stringify(service.inspectDocument()), {\n headers: {\n \"Content-Type\": AEP_NEXT_MEDIA_TYPE\n },\n status: 200\n });\n}\n\nexport function createNextAepCommandRouteHandler(\n input: NextAepServiceInput,\n command: Exclude<NextAepCommand, \"inspect\">\n): NextAepRouteHandler {\n const service = resolveService(input);\n\n return async (request) => {\n const clientAssertion = parseAepAuthorization(\n request?.headers.get(\"Authorization\") ?? undefined\n );\n const idempotencyKey = request?.headers.get(\"Idempotency-Key\") ?? undefined;\n const body = command === \"status\" ? undefined : await request?.json();\n const commandOptions = authenticatedOptions(clientAssertion, idempotencyKey);\n const result =\n command === \"enroll\"\n ? await service.enroll(body, commandOptions)\n : command === \"status\"\n ? await service.status({ clientAssertion })\n : command === \"grant\"\n ? await service.grant(body, commandOptions)\n : await service.revoke(body, commandOptions);\n\n return new Response(JSON.stringify(result.body), {\n headers: {\n \"Content-Type\": result.contentType\n },\n status: result.status\n });\n };\n}\n\nfunction authenticatedOptions(\n clientAssertion: string,\n idempotencyKey: string | undefined\n): AepAuthenticatedServiceOptions {\n return {\n clientAssertion,\n ...(idempotencyKey === undefined ? {} : { idempotencyKey })\n };\n}\n\nexport function createNextAepRoute(\n input: NextAepServiceInput,\n command: NextAepCommand = \"inspect\"\n): {\n GET?: NextAepRouteHandler;\n POST?: NextAepRouteHandler;\n} {\n if (command === \"inspect\") {\n return {\n GET: createNextAepRouteHandler(input)\n };\n }\n\n if (command === \"status\") {\n return {\n GET: createNextAepCommandRouteHandler(input, command)\n };\n }\n\n return {\n POST: createNextAepCommandRouteHandler(input, command)\n };\n}\n\nfunction parseAepAuthorization(authorization: string | undefined): string {\n const prefix = \"AEP \";\n\n if (authorization?.startsWith(prefix)) {\n return authorization.slice(prefix.length);\n }\n\n return \"\";\n}\n\nfunction resolveService(input: NextAepServiceInput): AepService {\n return \"inspectDocument\" in input ? input : createAepService(input);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAiC;AAO1B,IAAM,cAAc;AACpB,IAAM,sBAAsB;AAM5B,SAAS,0BAA0B,OAAiD;AACzF,QAAM,UAAU,eAAe,KAAK;AAEpC,SAAO,MACL,IAAI,SAAS,KAAK,UAAU,QAAQ,gBAAgB,CAAC,GAAG;AAAA,IACtD,SAAS;AAAA,MACP,gBAAgB;AAAA,IAClB;AAAA,IACA,QAAQ;AAAA,EACV,CAAC;AACL;AAEO,SAAS,iCACd,OACA,SACqB;AACrB,QAAM,UAAU,eAAe,KAAK;AAEpC,SAAO,OAAO,YAAY;AACxB,UAAM,kBAAkB;AAAA,MACtB,SAAS,QAAQ,IAAI,eAAe,KAAK;AAAA,IAC3C;AACA,UAAM,iBAAiB,SAAS,QAAQ,IAAI,iBAAiB,KAAK;AAClE,UAAM,OAAO,YAAY,WAAW,SAAY,MAAM,SAAS,KAAK;AACpE,UAAM,iBAAiB,qBAAqB,iBAAiB,cAAc;AAC3E,UAAM,SACJ,YAAY,WACR,MAAM,QAAQ,OAAO,MAAM,cAAc,IACzC,YAAY,WACV,MAAM,QAAQ,OAAO,EAAE,gBAAgB,CAAC,IACxC,YAAY,UACV,MAAM,QAAQ,MAAM,MAAM,cAAc,IACxC,MAAM,QAAQ,OAAO,MAAM,cAAc;AAEnD,WAAO,IAAI,SAAS,KAAK,UAAU,OAAO,IAAI,GAAG;AAAA,MAC/C,SAAS;AAAA,QACP,gBAAgB,OAAO;AAAA,MACzB;AAAA,MACA,QAAQ,OAAO;AAAA,IACjB,CAAC;AAAA,EACH;AACF;AAEA,SAAS,qBACP,iBACA,gBACgC;AAChC,SAAO;AAAA,IACL;AAAA,IACA,GAAI,mBAAmB,SAAY,CAAC,IAAI,EAAE,eAAe;AAAA,EAC3D;AACF;AAEO,SAAS,mBACd,OACA,UAA0B,WAI1B;AACA,MAAI,YAAY,WAAW;AACzB,WAAO;AAAA,MACL,KAAK,0BAA0B,KAAK;AAAA,IACtC;AAAA,EACF;AAEA,MAAI,YAAY,UAAU;AACxB,WAAO;AAAA,MACL,KAAK,iCAAiC,OAAO,OAAO;AAAA,IACtD;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM,iCAAiC,OAAO,OAAO;AAAA,EACvD;AACF;AAEA,SAAS,sBAAsB,eAA2C;AACxE,QAAM,SAAS;AAEf,MAAI,eAAe,WAAW,MAAM,GAAG;AACrC,WAAO,cAAc,MAAM,OAAO,MAAM;AAAA,EAC1C;AAEA,SAAO;AACT;AAEA,SAAS,eAAe,OAAwC;AAC9D,SAAO,qBAAqB,QAAQ,YAAQ,iCAAiB,KAAK;AACpE;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AepService, AepServiceOptions } from '@aep-foundation/service';
|
|
2
|
+
|
|
3
|
+
declare const packageName = "@aep-foundation/next";
|
|
4
|
+
declare const AEP_NEXT_MEDIA_TYPE = "application/aep+json";
|
|
5
|
+
type NextAepServiceInput = AepService | AepServiceOptions;
|
|
6
|
+
type NextAepCommand = "enroll" | "grant" | "inspect" | "revoke" | "status";
|
|
7
|
+
type NextAepRouteHandler = (request?: Request) => Promise<Response> | Response;
|
|
8
|
+
declare function createNextAepRouteHandler(input: NextAepServiceInput): NextAepRouteHandler;
|
|
9
|
+
declare function createNextAepCommandRouteHandler(input: NextAepServiceInput, command: Exclude<NextAepCommand, "inspect">): NextAepRouteHandler;
|
|
10
|
+
declare function createNextAepRoute(input: NextAepServiceInput, command?: NextAepCommand): {
|
|
11
|
+
GET?: NextAepRouteHandler;
|
|
12
|
+
POST?: NextAepRouteHandler;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { AEP_NEXT_MEDIA_TYPE, type NextAepCommand, type NextAepRouteHandler, type NextAepServiceInput, createNextAepCommandRouteHandler, createNextAepRoute, createNextAepRouteHandler, packageName };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AepService, AepServiceOptions } from '@aep-foundation/service';
|
|
2
|
+
|
|
3
|
+
declare const packageName = "@aep-foundation/next";
|
|
4
|
+
declare const AEP_NEXT_MEDIA_TYPE = "application/aep+json";
|
|
5
|
+
type NextAepServiceInput = AepService | AepServiceOptions;
|
|
6
|
+
type NextAepCommand = "enroll" | "grant" | "inspect" | "revoke" | "status";
|
|
7
|
+
type NextAepRouteHandler = (request?: Request) => Promise<Response> | Response;
|
|
8
|
+
declare function createNextAepRouteHandler(input: NextAepServiceInput): NextAepRouteHandler;
|
|
9
|
+
declare function createNextAepCommandRouteHandler(input: NextAepServiceInput, command: Exclude<NextAepCommand, "inspect">): NextAepRouteHandler;
|
|
10
|
+
declare function createNextAepRoute(input: NextAepServiceInput, command?: NextAepCommand): {
|
|
11
|
+
GET?: NextAepRouteHandler;
|
|
12
|
+
POST?: NextAepRouteHandler;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { AEP_NEXT_MEDIA_TYPE, type NextAepCommand, type NextAepRouteHandler, type NextAepServiceInput, createNextAepCommandRouteHandler, createNextAepRoute, createNextAepRouteHandler, packageName };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { createAepService } from "@aep-foundation/service";
|
|
3
|
+
var packageName = "@aep-foundation/next";
|
|
4
|
+
var AEP_NEXT_MEDIA_TYPE = "application/aep+json";
|
|
5
|
+
function createNextAepRouteHandler(input) {
|
|
6
|
+
const service = resolveService(input);
|
|
7
|
+
return () => new Response(JSON.stringify(service.inspectDocument()), {
|
|
8
|
+
headers: {
|
|
9
|
+
"Content-Type": AEP_NEXT_MEDIA_TYPE
|
|
10
|
+
},
|
|
11
|
+
status: 200
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function createNextAepCommandRouteHandler(input, command) {
|
|
15
|
+
const service = resolveService(input);
|
|
16
|
+
return async (request) => {
|
|
17
|
+
const clientAssertion = parseAepAuthorization(
|
|
18
|
+
request?.headers.get("Authorization") ?? void 0
|
|
19
|
+
);
|
|
20
|
+
const idempotencyKey = request?.headers.get("Idempotency-Key") ?? void 0;
|
|
21
|
+
const body = command === "status" ? void 0 : await request?.json();
|
|
22
|
+
const commandOptions = authenticatedOptions(clientAssertion, idempotencyKey);
|
|
23
|
+
const result = command === "enroll" ? await service.enroll(body, commandOptions) : command === "status" ? await service.status({ clientAssertion }) : command === "grant" ? await service.grant(body, commandOptions) : await service.revoke(body, commandOptions);
|
|
24
|
+
return new Response(JSON.stringify(result.body), {
|
|
25
|
+
headers: {
|
|
26
|
+
"Content-Type": result.contentType
|
|
27
|
+
},
|
|
28
|
+
status: result.status
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function authenticatedOptions(clientAssertion, idempotencyKey) {
|
|
33
|
+
return {
|
|
34
|
+
clientAssertion,
|
|
35
|
+
...idempotencyKey === void 0 ? {} : { idempotencyKey }
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function createNextAepRoute(input, command = "inspect") {
|
|
39
|
+
if (command === "inspect") {
|
|
40
|
+
return {
|
|
41
|
+
GET: createNextAepRouteHandler(input)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (command === "status") {
|
|
45
|
+
return {
|
|
46
|
+
GET: createNextAepCommandRouteHandler(input, command)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
POST: createNextAepCommandRouteHandler(input, command)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function parseAepAuthorization(authorization) {
|
|
54
|
+
const prefix = "AEP ";
|
|
55
|
+
if (authorization?.startsWith(prefix)) {
|
|
56
|
+
return authorization.slice(prefix.length);
|
|
57
|
+
}
|
|
58
|
+
return "";
|
|
59
|
+
}
|
|
60
|
+
function resolveService(input) {
|
|
61
|
+
return "inspectDocument" in input ? input : createAepService(input);
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
AEP_NEXT_MEDIA_TYPE,
|
|
65
|
+
createNextAepCommandRouteHandler,
|
|
66
|
+
createNextAepRoute,
|
|
67
|
+
createNextAepRouteHandler,
|
|
68
|
+
packageName
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createAepService } from \"@aep-foundation/service\";\nimport type {\n AepAuthenticatedServiceOptions,\n AepService,\n AepServiceOptions\n} from \"@aep-foundation/service\";\n\nexport const packageName = \"@aep-foundation/next\";\nexport const AEP_NEXT_MEDIA_TYPE = \"application/aep+json\";\n\nexport type NextAepServiceInput = AepService | AepServiceOptions;\nexport type NextAepCommand = \"enroll\" | \"grant\" | \"inspect\" | \"revoke\" | \"status\";\nexport type NextAepRouteHandler = (request?: Request) => Promise<Response> | Response;\n\nexport function createNextAepRouteHandler(input: NextAepServiceInput): NextAepRouteHandler {\n const service = resolveService(input);\n\n return () =>\n new Response(JSON.stringify(service.inspectDocument()), {\n headers: {\n \"Content-Type\": AEP_NEXT_MEDIA_TYPE\n },\n status: 200\n });\n}\n\nexport function createNextAepCommandRouteHandler(\n input: NextAepServiceInput,\n command: Exclude<NextAepCommand, \"inspect\">\n): NextAepRouteHandler {\n const service = resolveService(input);\n\n return async (request) => {\n const clientAssertion = parseAepAuthorization(\n request?.headers.get(\"Authorization\") ?? undefined\n );\n const idempotencyKey = request?.headers.get(\"Idempotency-Key\") ?? undefined;\n const body = command === \"status\" ? undefined : await request?.json();\n const commandOptions = authenticatedOptions(clientAssertion, idempotencyKey);\n const result =\n command === \"enroll\"\n ? await service.enroll(body, commandOptions)\n : command === \"status\"\n ? await service.status({ clientAssertion })\n : command === \"grant\"\n ? await service.grant(body, commandOptions)\n : await service.revoke(body, commandOptions);\n\n return new Response(JSON.stringify(result.body), {\n headers: {\n \"Content-Type\": result.contentType\n },\n status: result.status\n });\n };\n}\n\nfunction authenticatedOptions(\n clientAssertion: string,\n idempotencyKey: string | undefined\n): AepAuthenticatedServiceOptions {\n return {\n clientAssertion,\n ...(idempotencyKey === undefined ? {} : { idempotencyKey })\n };\n}\n\nexport function createNextAepRoute(\n input: NextAepServiceInput,\n command: NextAepCommand = \"inspect\"\n): {\n GET?: NextAepRouteHandler;\n POST?: NextAepRouteHandler;\n} {\n if (command === \"inspect\") {\n return {\n GET: createNextAepRouteHandler(input)\n };\n }\n\n if (command === \"status\") {\n return {\n GET: createNextAepCommandRouteHandler(input, command)\n };\n }\n\n return {\n POST: createNextAepCommandRouteHandler(input, command)\n };\n}\n\nfunction parseAepAuthorization(authorization: string | undefined): string {\n const prefix = \"AEP \";\n\n if (authorization?.startsWith(prefix)) {\n return authorization.slice(prefix.length);\n }\n\n return \"\";\n}\n\nfunction resolveService(input: NextAepServiceInput): AepService {\n return \"inspectDocument\" in input ? input : createAepService(input);\n}\n"],"mappings":";AAAA,SAAS,wBAAwB;AAO1B,IAAM,cAAc;AACpB,IAAM,sBAAsB;AAM5B,SAAS,0BAA0B,OAAiD;AACzF,QAAM,UAAU,eAAe,KAAK;AAEpC,SAAO,MACL,IAAI,SAAS,KAAK,UAAU,QAAQ,gBAAgB,CAAC,GAAG;AAAA,IACtD,SAAS;AAAA,MACP,gBAAgB;AAAA,IAClB;AAAA,IACA,QAAQ;AAAA,EACV,CAAC;AACL;AAEO,SAAS,iCACd,OACA,SACqB;AACrB,QAAM,UAAU,eAAe,KAAK;AAEpC,SAAO,OAAO,YAAY;AACxB,UAAM,kBAAkB;AAAA,MACtB,SAAS,QAAQ,IAAI,eAAe,KAAK;AAAA,IAC3C;AACA,UAAM,iBAAiB,SAAS,QAAQ,IAAI,iBAAiB,KAAK;AAClE,UAAM,OAAO,YAAY,WAAW,SAAY,MAAM,SAAS,KAAK;AACpE,UAAM,iBAAiB,qBAAqB,iBAAiB,cAAc;AAC3E,UAAM,SACJ,YAAY,WACR,MAAM,QAAQ,OAAO,MAAM,cAAc,IACzC,YAAY,WACV,MAAM,QAAQ,OAAO,EAAE,gBAAgB,CAAC,IACxC,YAAY,UACV,MAAM,QAAQ,MAAM,MAAM,cAAc,IACxC,MAAM,QAAQ,OAAO,MAAM,cAAc;AAEnD,WAAO,IAAI,SAAS,KAAK,UAAU,OAAO,IAAI,GAAG;AAAA,MAC/C,SAAS;AAAA,QACP,gBAAgB,OAAO;AAAA,MACzB;AAAA,MACA,QAAQ,OAAO;AAAA,IACjB,CAAC;AAAA,EACH;AACF;AAEA,SAAS,qBACP,iBACA,gBACgC;AAChC,SAAO;AAAA,IACL;AAAA,IACA,GAAI,mBAAmB,SAAY,CAAC,IAAI,EAAE,eAAe;AAAA,EAC3D;AACF;AAEO,SAAS,mBACd,OACA,UAA0B,WAI1B;AACA,MAAI,YAAY,WAAW;AACzB,WAAO;AAAA,MACL,KAAK,0BAA0B,KAAK;AAAA,IACtC;AAAA,EACF;AAEA,MAAI,YAAY,UAAU;AACxB,WAAO;AAAA,MACL,KAAK,iCAAiC,OAAO,OAAO;AAAA,IACtD;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM,iCAAiC,OAAO,OAAO;AAAA,EACvD;AACF;AAEA,SAAS,sBAAsB,eAA2C;AACxE,QAAM,SAAS;AAEf,MAAI,eAAe,WAAW,MAAM,GAAG;AACrC,WAAO,cAAc,MAAM,OAAO,MAAM;AAAA,EAC1C;AAEA,SAAO;AACT;AAEA,SAAS,eAAe,OAAwC;AAC9D,SAAO,qBAAqB,QAAQ,QAAQ,iBAAiB,KAAK;AACpE;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aep-foundation/next",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Next.js adapter for AEP Service handlers.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"node": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
},
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"CHANGELOG.md",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=22.0.0"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@aep-foundation/core": "^0.1.0",
|
|
33
|
+
"@aep-foundation/service": "^0.1.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"next": ">=15"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public",
|
|
40
|
+
"provenance": true
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"next": "^15.5.19",
|
|
44
|
+
"react": "^19.2.7",
|
|
45
|
+
"react-dom": "^19.2.7"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsup",
|
|
49
|
+
"dev": "tsup --watch",
|
|
50
|
+
"test": "vitest run --coverage",
|
|
51
|
+
"test:watch": "vitest",
|
|
52
|
+
"lint": "eslint src test --max-warnings 0",
|
|
53
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
|
|
54
|
+
"clean": "rm -rf dist .turbo coverage"
|
|
55
|
+
}
|
|
56
|
+
}
|