@open-dpp/dto 6.0.0 → 6.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/dist/index.d.ts CHANGED
@@ -81,6 +81,7 @@ export * from "./shared/table.dto";
81
81
  export * from "./status/status.dto";
82
82
  export * from "./templates/template.dto";
83
83
  export * from "./api-keys/api-key.dto";
84
+ export * from "./oauth-provider/continue-authorization.dto";
84
85
  export * from "./users/create-user.dto";
85
86
  export * from "./users/me.dto";
86
87
  export * from "./users/pending-email-change.dto";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8CAA8C,CAAC;AAC7D,cAAc,oCAAoC,CAAC;AACnD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wCAAwC,CAAC;AAEvD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yDAAyD,CAAC;AAExE,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAE/C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC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E,cAAc,mDAAmD,CAAC;AAClE,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,wCAAwC,CAAC;AACvD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8DAA8D,CAAC;AAC7E,cAAc,6DAA6D,CAAC;AAC5E,cAAc,yBAAyB,CAAC;AACxC,cAAc,oCAAoC,CAAC;AACnD,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AAEjC,cAAc,yCAAyC,CAAC;AACxD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,uCAAuC,CAAC;AACtD,cAAc,sEAAsE,CAAC;AACrF,cAAc,mEAAmE,CAAC;AAClF,cAAc,4EAA4E,CAAC;AAC3F,cAAc,mEAAmE,CAAC;AAClF,cAAc,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -97,6 +97,7 @@ __exportStar(require("./shared/table.dto"), exports);
97
97
  __exportStar(require("./status/status.dto"), exports);
98
98
  __exportStar(require("./templates/template.dto"), exports);
99
99
  __exportStar(require("./api-keys/api-key.dto"), exports);
100
+ __exportStar(require("./oauth-provider/continue-authorization.dto"), exports);
100
101
  __exportStar(require("./users/create-user.dto"), exports);
101
102
  __exportStar(require("./users/me.dto"), exports);
102
103
  __exportStar(require("./users/pending-email-change.dto"), exports);
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Resumes a pending OAuth Provider authorization after the User signed up (the Trusted
4
+ * Client asked for `prompt=create`). `oauthQuery` is the signed query, up to and including
5
+ * `sig`, that the provider put on the sign-up page's URL.
6
+ */
7
+ export declare const ContinueAuthorizationDtoSchema: z.ZodObject<{
8
+ oauthQuery: z.ZodString;
9
+ }, z.core.$strip>;
10
+ export type ContinueAuthorizationDto = z.infer<typeof ContinueAuthorizationDtoSchema>;
11
+ /** Where the browser continues: the Trusted Client's redirect URI with the authorization code. */
12
+ export declare const ContinueAuthorizationResponseDtoSchema: z.ZodObject<{
13
+ url: z.ZodString;
14
+ }, z.core.$strip>;
15
+ export type ContinueAuthorizationResponseDto = z.infer<typeof ContinueAuthorizationResponseDtoSchema>;
16
+ //# sourceMappingURL=continue-authorization.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"continue-authorization.dto.d.ts","sourceRoot":"","sources":["../../src/oauth-provider/continue-authorization.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;;;GAIG;AACH,eAAO,MAAM,8BAA8B;;iBAEzC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF,kGAAkG;AAClG,eAAO,MAAM,sCAAsC;;iBAEjD,CAAC;AAEH,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CACpD,OAAO,sCAAsC,CAC9C,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContinueAuthorizationResponseDtoSchema = exports.ContinueAuthorizationDtoSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /** Upper bound for the signed authorize query the OAuth Provider appended to /signup. */
6
+ const MAX_OAUTH_QUERY_LENGTH = 8192;
7
+ /**
8
+ * Resumes a pending OAuth Provider authorization after the User signed up (the Trusted
9
+ * Client asked for `prompt=create`). `oauthQuery` is the signed query, up to and including
10
+ * `sig`, that the provider put on the sign-up page's URL.
11
+ */
12
+ exports.ContinueAuthorizationDtoSchema = zod_1.z.object({
13
+ oauthQuery: zod_1.z.string().min(1).max(MAX_OAUTH_QUERY_LENGTH),
14
+ });
15
+ /** Where the browser continues: the Trusted Client's redirect URI with the authorization code. */
16
+ exports.ContinueAuthorizationResponseDtoSchema = zod_1.z.object({
17
+ url: zod_1.z.string().min(1),
18
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-dpp/dto",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/open-dpp/open-dpp#readme",
package/src/index.ts CHANGED
@@ -87,6 +87,7 @@ export * from "./shared/table.dto";
87
87
  export * from "./status/status.dto";
88
88
  export * from "./templates/template.dto";
89
89
  export * from "./api-keys/api-key.dto";
90
+ export * from "./oauth-provider/continue-authorization.dto";
90
91
  export * from "./users/create-user.dto";
91
92
  export * from "./users/me.dto";
92
93
  export * from "./users/pending-email-change.dto";
@@ -0,0 +1,35 @@
1
+ import { expect } from "@jest/globals";
2
+ import {
3
+ ContinueAuthorizationDtoSchema,
4
+ ContinueAuthorizationResponseDtoSchema,
5
+ } from "./continue-authorization.dto";
6
+
7
+ describe("ContinueAuthorizationDtoSchema", () => {
8
+ it("parses the signed authorize query", () => {
9
+ const parsed = ContinueAuthorizationDtoSchema.parse({
10
+ oauthQuery: "client_id=landing-page&prompt=create&exp=1&sig=abc",
11
+ });
12
+ expect(parsed.oauthQuery).toBe("client_id=landing-page&prompt=create&exp=1&sig=abc");
13
+ });
14
+
15
+ it.each([
16
+ ["a missing query", {}],
17
+ ["an empty query", { oauthQuery: "" }],
18
+ ["an oversized query", { oauthQuery: "a".repeat(8193) }],
19
+ ])("rejects %s", (_label: string, body: object) => {
20
+ expect(() => ContinueAuthorizationDtoSchema.parse(body)).toThrow();
21
+ });
22
+ });
23
+
24
+ describe("ContinueAuthorizationResponseDtoSchema", () => {
25
+ it("parses the Trusted Client redirect", () => {
26
+ const parsed = ContinueAuthorizationResponseDtoSchema.parse({
27
+ url: "https://landing.example.com/auth/callback?code=c&state=s",
28
+ });
29
+ expect(parsed.url).toBe("https://landing.example.com/auth/callback?code=c&state=s");
30
+ });
31
+
32
+ it("rejects a response without a URL", () => {
33
+ expect(() => ContinueAuthorizationResponseDtoSchema.parse({})).toThrow();
34
+ });
35
+ });
@@ -0,0 +1,24 @@
1
+ import { z } from "zod";
2
+
3
+ /** Upper bound for the signed authorize query the OAuth Provider appended to /signup. */
4
+ const MAX_OAUTH_QUERY_LENGTH = 8192;
5
+
6
+ /**
7
+ * Resumes a pending OAuth Provider authorization after the User signed up (the Trusted
8
+ * Client asked for `prompt=create`). `oauthQuery` is the signed query, up to and including
9
+ * `sig`, that the provider put on the sign-up page's URL.
10
+ */
11
+ export const ContinueAuthorizationDtoSchema = z.object({
12
+ oauthQuery: z.string().min(1).max(MAX_OAUTH_QUERY_LENGTH),
13
+ });
14
+
15
+ export type ContinueAuthorizationDto = z.infer<typeof ContinueAuthorizationDtoSchema>;
16
+
17
+ /** Where the browser continues: the Trusted Client's redirect URI with the authorization code. */
18
+ export const ContinueAuthorizationResponseDtoSchema = z.object({
19
+ url: z.string().min(1),
20
+ });
21
+
22
+ export type ContinueAuthorizationResponseDto = z.infer<
23
+ typeof ContinueAuthorizationResponseDtoSchema
24
+ >;