@docusign/iam-sdk
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@docusign/iam-sdk* API.
78 lines (69 loc) • 1.91 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";
import { ClosedEnum } from "../../types/enums.js";
export const GetTokenFromJWTGrantServerList = [
/**
* For the developer environment, the URI is https://account-d.docusign.com/oauth/token
*/
"https://account-d.docusign.com",
/**
* For the production environment, the URI is https://account.docusign.com/oauth/token
*/
"https://account.docusign.com",
] as const;
/**
* The grant type.
*/
export const GetTokenFromJWTGrantGrantType = {
UrnIetfParamsOauthGrantTypeJwtBearer:
"urn:ietf:params:oauth:grant-type:jwt-bearer",
} as const;
/**
* The grant type.
*/
export type GetTokenFromJWTGrantGrantType = ClosedEnum<
typeof GetTokenFromJWTGrantGrantType
>;
/**
* JSON Web Token (JWT) Grant is an OAuth 2.0 flow that is used to grant an access token to service integrations
*/
export type JWTGrant = {
/**
* The grant type.
*/
grantType?: GetTokenFromJWTGrantGrantType | undefined;
/**
* Your JWT
*/
assertion: string;
};
/** @internal */
export const GetTokenFromJWTGrantGrantType$outboundSchema: z.ZodNativeEnum<
typeof GetTokenFromJWTGrantGrantType
> = z.nativeEnum(GetTokenFromJWTGrantGrantType);
/** @internal */
export type JWTGrant$Outbound = {
grant_type: string;
assertion: string;
};
/** @internal */
export const JWTGrant$outboundSchema: z.ZodType<
JWTGrant$Outbound,
z.ZodTypeDef,
JWTGrant
> = z.object({
grantType: GetTokenFromJWTGrantGrantType$outboundSchema.default(
"urn:ietf:params:oauth:grant-type:jwt-bearer",
),
assertion: z.string(),
}).transform((v) => {
return remap$(v, {
grantType: "grant_type",
});
});
export function jwtGrantToJSON(jwtGrant: JWTGrant): string {
return JSON.stringify(JWTGrant$outboundSchema.parse(jwtGrant));
}