UNPKG

@docusign/iam-sdk

Version:

Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@docusign/iam-sdk* API.

316 lines (288 loc) 9.72 kB
/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const GetTokenFromRefreshTokenServerList = [ /** * 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; export type GetTokenFromRefreshTokenSecurity = { clientId?: string | undefined; secretKey?: string | undefined; }; /** * The grant type. This value must be set to "refresh_token". */ export const GetTokenFromRefreshTokenGrantType = { RefreshToken: "refresh_token", } as const; /** * The grant type. This value must be set to "refresh_token". */ export type GetTokenFromRefreshTokenGrantType = ClosedEnum< typeof GetTokenFromRefreshTokenGrantType >; /** * This grant optionally uses Proof Key for Code Exchange (PKCE) to authenticate securely without requiring a client secret. */ export type AuthorizationCodeGrant = { /** * The grant type. This value must be set to "refresh_token". */ grantType?: GetTokenFromRefreshTokenGrantType | undefined; /** * The refresh token supplied to the callback. */ refreshToken: string; /** * The client ID. */ clientId?: string | undefined; }; /** * Successful response. */ export type GetTokenFromRefreshTokenResponse = { /** * The value of the access token. This value will be added to the Authorization header of all Docusign API calls. */ accessToken: string; /** * The type of token. For access tokens, the value of this will be Bearer. */ tokenType: string; /** * The refresh token. */ refreshToken: string; /** * The number of seconds until the access token expires. */ expiresIn: number; }; /** @internal */ export const GetTokenFromRefreshTokenSecurity$inboundSchema: z.ZodType< GetTokenFromRefreshTokenSecurity, z.ZodTypeDef, unknown > = z.object({ clientId: z.string().optional(), secretKey: z.string().optional(), }); /** @internal */ export type GetTokenFromRefreshTokenSecurity$Outbound = { clientId?: string | undefined; secretKey?: string | undefined; }; /** @internal */ export const GetTokenFromRefreshTokenSecurity$outboundSchema: z.ZodType< GetTokenFromRefreshTokenSecurity$Outbound, z.ZodTypeDef, GetTokenFromRefreshTokenSecurity > = z.object({ clientId: z.string().optional(), secretKey: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetTokenFromRefreshTokenSecurity$ { /** @deprecated use `GetTokenFromRefreshTokenSecurity$inboundSchema` instead. */ export const inboundSchema = GetTokenFromRefreshTokenSecurity$inboundSchema; /** @deprecated use `GetTokenFromRefreshTokenSecurity$outboundSchema` instead. */ export const outboundSchema = GetTokenFromRefreshTokenSecurity$outboundSchema; /** @deprecated use `GetTokenFromRefreshTokenSecurity$Outbound` instead. */ export type Outbound = GetTokenFromRefreshTokenSecurity$Outbound; } export function getTokenFromRefreshTokenSecurityToJSON( getTokenFromRefreshTokenSecurity: GetTokenFromRefreshTokenSecurity, ): string { return JSON.stringify( GetTokenFromRefreshTokenSecurity$outboundSchema.parse( getTokenFromRefreshTokenSecurity, ), ); } export function getTokenFromRefreshTokenSecurityFromJSON( jsonString: string, ): SafeParseResult<GetTokenFromRefreshTokenSecurity, SDKValidationError> { return safeParse( jsonString, (x) => GetTokenFromRefreshTokenSecurity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetTokenFromRefreshTokenSecurity' from JSON`, ); } /** @internal */ export const GetTokenFromRefreshTokenGrantType$inboundSchema: z.ZodNativeEnum< typeof GetTokenFromRefreshTokenGrantType > = z.nativeEnum(GetTokenFromRefreshTokenGrantType); /** @internal */ export const GetTokenFromRefreshTokenGrantType$outboundSchema: z.ZodNativeEnum< typeof GetTokenFromRefreshTokenGrantType > = GetTokenFromRefreshTokenGrantType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetTokenFromRefreshTokenGrantType$ { /** @deprecated use `GetTokenFromRefreshTokenGrantType$inboundSchema` instead. */ export const inboundSchema = GetTokenFromRefreshTokenGrantType$inboundSchema; /** @deprecated use `GetTokenFromRefreshTokenGrantType$outboundSchema` instead. */ export const outboundSchema = GetTokenFromRefreshTokenGrantType$outboundSchema; } /** @internal */ export const AuthorizationCodeGrant$inboundSchema: z.ZodType< AuthorizationCodeGrant, z.ZodTypeDef, unknown > = z.object({ grant_type: GetTokenFromRefreshTokenGrantType$inboundSchema.default( "refresh_token", ), refresh_token: z.string(), client_id: z.string().optional(), }).transform((v) => { return remap$(v, { "grant_type": "grantType", "refresh_token": "refreshToken", "client_id": "clientId", }); }); /** @internal */ export type AuthorizationCodeGrant$Outbound = { grant_type: string; refresh_token: string; client_id?: string | undefined; }; /** @internal */ export const AuthorizationCodeGrant$outboundSchema: z.ZodType< AuthorizationCodeGrant$Outbound, z.ZodTypeDef, AuthorizationCodeGrant > = z.object({ grantType: GetTokenFromRefreshTokenGrantType$outboundSchema.default( "refresh_token", ), refreshToken: z.string(), clientId: z.string().optional(), }).transform((v) => { return remap$(v, { grantType: "grant_type", refreshToken: "refresh_token", clientId: "client_id", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AuthorizationCodeGrant$ { /** @deprecated use `AuthorizationCodeGrant$inboundSchema` instead. */ export const inboundSchema = AuthorizationCodeGrant$inboundSchema; /** @deprecated use `AuthorizationCodeGrant$outboundSchema` instead. */ export const outboundSchema = AuthorizationCodeGrant$outboundSchema; /** @deprecated use `AuthorizationCodeGrant$Outbound` instead. */ export type Outbound = AuthorizationCodeGrant$Outbound; } export function authorizationCodeGrantToJSON( authorizationCodeGrant: AuthorizationCodeGrant, ): string { return JSON.stringify( AuthorizationCodeGrant$outboundSchema.parse(authorizationCodeGrant), ); } export function authorizationCodeGrantFromJSON( jsonString: string, ): SafeParseResult<AuthorizationCodeGrant, SDKValidationError> { return safeParse( jsonString, (x) => AuthorizationCodeGrant$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AuthorizationCodeGrant' from JSON`, ); } /** @internal */ export const GetTokenFromRefreshTokenResponse$inboundSchema: z.ZodType< GetTokenFromRefreshTokenResponse, z.ZodTypeDef, unknown > = z.object({ access_token: z.string(), token_type: z.string(), refresh_token: z.string(), expires_in: z.number().int(), }).transform((v) => { return remap$(v, { "access_token": "accessToken", "token_type": "tokenType", "refresh_token": "refreshToken", "expires_in": "expiresIn", }); }); /** @internal */ export type GetTokenFromRefreshTokenResponse$Outbound = { access_token: string; token_type: string; refresh_token: string; expires_in: number; }; /** @internal */ export const GetTokenFromRefreshTokenResponse$outboundSchema: z.ZodType< GetTokenFromRefreshTokenResponse$Outbound, z.ZodTypeDef, GetTokenFromRefreshTokenResponse > = z.object({ accessToken: z.string(), tokenType: z.string(), refreshToken: z.string(), expiresIn: z.number().int(), }).transform((v) => { return remap$(v, { accessToken: "access_token", tokenType: "token_type", refreshToken: "refresh_token", expiresIn: "expires_in", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetTokenFromRefreshTokenResponse$ { /** @deprecated use `GetTokenFromRefreshTokenResponse$inboundSchema` instead. */ export const inboundSchema = GetTokenFromRefreshTokenResponse$inboundSchema; /** @deprecated use `GetTokenFromRefreshTokenResponse$outboundSchema` instead. */ export const outboundSchema = GetTokenFromRefreshTokenResponse$outboundSchema; /** @deprecated use `GetTokenFromRefreshTokenResponse$Outbound` instead. */ export type Outbound = GetTokenFromRefreshTokenResponse$Outbound; } export function getTokenFromRefreshTokenResponseToJSON( getTokenFromRefreshTokenResponse: GetTokenFromRefreshTokenResponse, ): string { return JSON.stringify( GetTokenFromRefreshTokenResponse$outboundSchema.parse( getTokenFromRefreshTokenResponse, ), ); } export function getTokenFromRefreshTokenResponseFromJSON( jsonString: string, ): SafeParseResult<GetTokenFromRefreshTokenResponse, SDKValidationError> { return safeParse( jsonString, (x) => GetTokenFromRefreshTokenResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetTokenFromRefreshTokenResponse' from JSON`, ); }