@dscvr-one/canvas-interface
Advanced tools
Comparing version 1.0.7 to 1.1.0
import * as zod from 'zod'; | ||
declare const UserSchema: zod.ZodObject<{ | ||
type CanvasMessageType = `${string}:${string}`; | ||
type BaseClientMessageSchema<T extends CanvasMessageType = CanvasMessageType, D extends zod.ZodTypeAny | undefined = undefined> = D extends zod.ZodTypeAny ? zod.ZodObject<{ | ||
type: zod.ZodLiteral<T>; | ||
payload: D; | ||
}> : zod.ZodObject<{ | ||
type: zod.ZodLiteral<T>; | ||
}>; | ||
type BaseHostMessageSchema<T extends CanvasMessageType = CanvasMessageType, D extends zod.ZodTypeAny | undefined = undefined> = D extends zod.ZodTypeAny ? zod.ZodObject<{ | ||
type: zod.ZodLiteral<T>; | ||
untrusted: D; | ||
trustedBytes: zod.ZodString; | ||
}> : zod.ZodObject<{ | ||
type: zod.ZodLiteral<T>; | ||
trustedBytes: zod.ZodString; | ||
}>; | ||
type BaseClientMessage<T extends BaseClientMessageSchema = BaseClientMessageSchema<CanvasMessageType, zod.ZodTypeAny | undefined>> = zod.infer<T>; | ||
type BaseHostMessage<T extends BaseHostMessageSchema = BaseHostMessageSchema<CanvasMessageType, zod.ZodTypeAny | undefined>> = zod.infer<T>; | ||
declare function createClientMessageSchema<T extends CanvasMessageType>(type: T): BaseClientMessageSchema<T>; | ||
declare function createClientMessageSchema<T extends CanvasMessageType, D extends zod.ZodTypeAny>(type: T, payloadSchema: D): BaseClientMessageSchema<T, D>; | ||
declare function createHostMessageSchema<T extends CanvasMessageType>(type: T): BaseHostMessageSchema<T>; | ||
declare function createHostMessageSchema<T extends CanvasMessageType, D extends zod.ZodTypeAny>(type: T, payloadSchema: D): BaseHostMessageSchema<T, D>; | ||
declare const createFailedResponsePayload: <U extends string, T extends readonly [U, ...U[]]>(reasons: T) => zod.ZodObject<{ | ||
success: zod.ZodLiteral<false>; | ||
errorReason: zod.ZodEnum<zod.Writeable<T>>; | ||
error: zod.ZodOptional<zod.ZodString>; | ||
}, "strip", zod.ZodTypeAny, { [k in keyof zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<{ | ||
success: zod.ZodLiteral<false>; | ||
errorReason: zod.ZodEnum<zod.Writeable<T>>; | ||
error: zod.ZodOptional<zod.ZodString>; | ||
}>, any>]: zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<{ | ||
success: zod.ZodLiteral<false>; | ||
errorReason: zod.ZodEnum<zod.Writeable<T>>; | ||
error: zod.ZodOptional<zod.ZodString>; | ||
}>, any>[k]; }, { [k_1 in keyof zod.baseObjectInputType<{ | ||
success: zod.ZodLiteral<false>; | ||
errorReason: zod.ZodEnum<zod.Writeable<T>>; | ||
error: zod.ZodOptional<zod.ZodString>; | ||
}>]: zod.baseObjectInputType<{ | ||
success: zod.ZodLiteral<false>; | ||
errorReason: zod.ZodEnum<zod.Writeable<T>>; | ||
error: zod.ZodOptional<zod.ZodString>; | ||
}>[k_1]; }>; | ||
declare const parseBaseClientMessage: (message: unknown) => BaseClientMessage | undefined; | ||
declare const parseBaseHostMessage: (message: unknown) => BaseHostMessage | undefined; | ||
declare const userSchema: zod.ZodObject<{ | ||
id: zod.ZodString; | ||
@@ -16,3 +62,3 @@ username: zod.ZodString; | ||
}>; | ||
declare const ContentSchema: zod.ZodObject<{ | ||
declare const contentSchema: zod.ZodObject<{ | ||
id: zod.ZodString; | ||
@@ -30,3 +76,3 @@ portalId: zod.ZodString; | ||
}>; | ||
declare const InitRequestMessageSchema: zod.ZodObject<{ | ||
declare const initRequestSchema: zod.ZodObject<{ | ||
type: zod.ZodLiteral<"lifecycle:init-request">; | ||
@@ -51,3 +97,3 @@ payload: zod.ZodObject<{ | ||
}>; | ||
declare const InitResponseMessageSchema: zod.ZodObject<{ | ||
declare const initResponseSchema: zod.ZodObject<{ | ||
type: zod.ZodLiteral<"lifecycle:init-response">; | ||
@@ -107,3 +153,2 @@ untrusted: zod.ZodObject<{ | ||
type: "lifecycle:init-response"; | ||
trustedBytes: string; | ||
untrusted: { | ||
@@ -121,5 +166,5 @@ user?: { | ||
}; | ||
trustedBytes: string; | ||
}, { | ||
type: "lifecycle:init-response"; | ||
trustedBytes: string; | ||
untrusted: { | ||
@@ -137,36 +182,40 @@ user?: { | ||
}; | ||
trustedBytes: string; | ||
}>; | ||
declare const CloseMessageSchema: zod.ZodObject<{ | ||
declare const closeMessageSchema: zod.ZodObject<{ | ||
type: zod.ZodLiteral<"lifecycle:close">; | ||
trustedBytes: zod.ZodString; | ||
}, zod.UnknownKeysParam, zod.ZodTypeAny, { | ||
type: "lifecycle:close"; | ||
trustedBytes: string; | ||
}, { | ||
type: "lifecycle:close"; | ||
trustedBytes: string; | ||
}>; | ||
interface User extends zod.infer<typeof UserSchema> { | ||
interface User extends zod.infer<typeof userSchema> { | ||
} | ||
interface Content extends zod.infer<typeof ContentSchema> { | ||
interface Content extends zod.infer<typeof contentSchema> { | ||
} | ||
interface InitRequestMessage extends zod.infer<typeof InitRequestMessageSchema> { | ||
interface InitRequest extends BaseClientMessage<typeof initRequestSchema> { | ||
} | ||
interface InitResponseMessage extends zod.infer<typeof InitResponseMessageSchema> { | ||
interface InitResponse extends BaseHostMessage<typeof initResponseSchema> { | ||
} | ||
interface CloseMessage extends zod.infer<typeof CloseMessageSchema> { | ||
interface CloseMessage extends BaseClientMessage<typeof closeMessageSchema> { | ||
} | ||
type lifecycle_CloseMessage = CloseMessage; | ||
declare const lifecycle_CloseMessageSchema: typeof CloseMessageSchema; | ||
type lifecycle_Content = Content; | ||
declare const lifecycle_ContentSchema: typeof ContentSchema; | ||
type lifecycle_InitRequestMessage = InitRequestMessage; | ||
declare const lifecycle_InitRequestMessageSchema: typeof InitRequestMessageSchema; | ||
type lifecycle_InitResponseMessage = InitResponseMessage; | ||
declare const lifecycle_InitResponseMessageSchema: typeof InitResponseMessageSchema; | ||
type lifecycle_InitRequest = InitRequest; | ||
type lifecycle_InitResponse = InitResponse; | ||
type lifecycle_User = User; | ||
declare const lifecycle_UserSchema: typeof UserSchema; | ||
declare const lifecycle_closeMessageSchema: typeof closeMessageSchema; | ||
declare const lifecycle_contentSchema: typeof contentSchema; | ||
declare const lifecycle_initRequestSchema: typeof initRequestSchema; | ||
declare const lifecycle_initResponseSchema: typeof initResponseSchema; | ||
declare const lifecycle_userSchema: typeof userSchema; | ||
declare namespace lifecycle { | ||
export { type lifecycle_CloseMessage as CloseMessage, lifecycle_CloseMessageSchema as CloseMessageSchema, type lifecycle_Content as Content, lifecycle_ContentSchema as ContentSchema, type lifecycle_InitRequestMessage as InitRequestMessage, lifecycle_InitRequestMessageSchema as InitRequestMessageSchema, type lifecycle_InitResponseMessage as InitResponseMessage, lifecycle_InitResponseMessageSchema as InitResponseMessageSchema, type lifecycle_User as User, lifecycle_UserSchema as UserSchema }; | ||
export { type lifecycle_CloseMessage as CloseMessage, type lifecycle_Content as Content, type lifecycle_InitRequest as InitRequest, type lifecycle_InitResponse as InitResponse, type lifecycle_User as User, lifecycle_closeMessageSchema as closeMessageSchema, lifecycle_contentSchema as contentSchema, lifecycle_initRequestSchema as initRequestSchema, lifecycle_initResponseSchema as initResponseSchema, lifecycle_userSchema as userSchema }; | ||
} | ||
declare const ConnectWalletRequestMessageSchema: zod.ZodObject<{ | ||
declare const connectWalletRequestSchema: zod.ZodObject<{ | ||
type: zod.ZodLiteral<"user:connect-wallet-request">; | ||
@@ -191,3 +240,3 @@ payload: zod.ZodObject<{ | ||
}>; | ||
declare const InitialInteractionRequestMessageSchema: zod.ZodObject<{ | ||
declare const initialInteractionRequestSchema: zod.ZodObject<{ | ||
type: zod.ZodLiteral<"user:initial-interaction-request">; | ||
@@ -199,3 +248,3 @@ }, zod.UnknownKeysParam, zod.ZodTypeAny, { | ||
}>; | ||
declare const ResizeRequestMessageSchema: zod.ZodObject<{ | ||
declare const resizeRequestSchema: zod.ZodObject<{ | ||
type: zod.ZodLiteral<"user:resize-request">; | ||
@@ -225,3 +274,3 @@ payload: zod.ZodObject<{ | ||
}>; | ||
declare const ConnectWalletResponseMessageSchema: zod.ZodObject<{ | ||
declare const connectWalletResponseSchema: zod.ZodObject<{ | ||
type: zod.ZodLiteral<"user:connect-wallet-response">; | ||
@@ -233,2 +282,4 @@ untrusted: zod.ZodUnion<[zod.ZodObject<{ | ||
walletIcon: zod.ZodString; | ||
walletUrl: zod.ZodString; | ||
walletSupportedTransactionVersions: zod.ZodOptional<zod.ZodType<ReadonlySet<0 | "legacy">, zod.ZodTypeDef, ReadonlySet<0 | "legacy">>>; | ||
}, "strip", zod.ZodTypeAny, { | ||
@@ -239,2 +290,4 @@ success: true; | ||
walletIcon: string; | ||
walletUrl: string; | ||
walletSupportedTransactionVersions?: ReadonlySet<0 | "legacy"> | undefined; | ||
}, { | ||
@@ -245,2 +298,4 @@ success: true; | ||
walletIcon: string; | ||
walletUrl: string; | ||
walletSupportedTransactionVersions?: ReadonlySet<0 | "legacy"> | undefined; | ||
}>, zod.ZodObject<{ | ||
@@ -252,7 +307,7 @@ success: zod.ZodLiteral<false>; | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
}, { | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
@@ -263,3 +318,2 @@ }>]>; | ||
type: "user:connect-wallet-response"; | ||
trustedBytes: string; | ||
untrusted: { | ||
@@ -270,10 +324,12 @@ success: true; | ||
walletIcon: string; | ||
walletUrl: string; | ||
walletSupportedTransactionVersions?: ReadonlySet<0 | "legacy"> | undefined; | ||
} | { | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
}; | ||
trustedBytes: string; | ||
}, { | ||
type: "user:connect-wallet-response"; | ||
trustedBytes: string; | ||
untrusted: { | ||
@@ -284,7 +340,10 @@ success: true; | ||
walletIcon: string; | ||
walletUrl: string; | ||
walletSupportedTransactionVersions?: ReadonlySet<0 | "legacy"> | undefined; | ||
} | { | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
}; | ||
trustedBytes: string; | ||
}>; | ||
@@ -297,3 +356,3 @@ /** | ||
*/ | ||
declare const UnsignedTransactionSchema: zod.ZodObject<{ | ||
declare const unsignedTransactionSchema: zod.ZodObject<{ | ||
unsignedTx: zod.ZodString; | ||
@@ -308,3 +367,3 @@ awaitCommitment: zod.ZodOptional<zod.ZodEnum<["confirmed", "finalized", "none"]>>; | ||
}>; | ||
declare const SignAndSendTransactionRequestMessageSchema: zod.ZodObject<{ | ||
declare const signAndSendTransactionRequestSchema: zod.ZodObject<{ | ||
type: zod.ZodLiteral<"user:sign-send-transaction-request">; | ||
@@ -340,3 +399,3 @@ payload: zod.ZodObject<zod.objectUtil.extendShape<{ | ||
}>; | ||
declare const SignAndSendTransactionResponseMessageSchema: zod.ZodObject<{ | ||
declare const signAndSendTransactionResponseSchema: zod.ZodObject<{ | ||
type: zod.ZodLiteral<"user:sign-send-transaction-response">; | ||
@@ -358,7 +417,7 @@ untrusted: zod.ZodUnion<[zod.ZodObject<{ | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
}, { | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
@@ -369,24 +428,24 @@ }>]>; | ||
type: "user:sign-send-transaction-response"; | ||
trustedBytes: string; | ||
untrusted: { | ||
success: false; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
} | { | ||
success: true; | ||
signedTx: string; | ||
} | { | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
error?: string | undefined; | ||
}; | ||
trustedBytes: string; | ||
}, { | ||
type: "user:sign-send-transaction-response"; | ||
trustedBytes: string; | ||
untrusted: { | ||
success: false; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
} | { | ||
success: true; | ||
signedTx: string; | ||
} | { | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
error?: string | undefined; | ||
}; | ||
trustedBytes: string; | ||
}>; | ||
declare const OpenLnkRequestMessageSchema: zod.ZodObject<{ | ||
declare const openLnkRequestSchema: zod.ZodObject<{ | ||
type: zod.ZodLiteral<"user:open-link-request">; | ||
@@ -411,39 +470,39 @@ payload: zod.ZodObject<{ | ||
}>; | ||
interface InitialInteractionRequestMessage extends zod.infer<typeof InitialInteractionRequestMessageSchema> { | ||
interface InitialInteractionRequest extends BaseClientMessage<typeof initialInteractionRequestSchema> { | ||
} | ||
interface ResizeRequestMessage extends zod.infer<typeof ResizeRequestMessageSchema> { | ||
interface ResizeRequest extends BaseClientMessage<typeof resizeRequestSchema> { | ||
} | ||
interface ConnectWalletRequestMessage extends zod.infer<typeof ConnectWalletRequestMessageSchema> { | ||
interface ConnectWalletRequest extends BaseClientMessage<typeof connectWalletRequestSchema> { | ||
} | ||
interface ConnectWalletResponseMessage extends zod.infer<typeof ConnectWalletResponseMessageSchema> { | ||
interface ConnectWalletResponse extends BaseHostMessage<typeof connectWalletResponseSchema> { | ||
} | ||
type UnsignedTransaction = zod.infer<typeof UnsignedTransactionSchema>; | ||
interface SignAndSendTransactionRequestMessage extends zod.infer<typeof SignAndSendTransactionRequestMessageSchema> { | ||
type UnsignedTransaction = zod.infer<typeof unsignedTransactionSchema>; | ||
interface SignAndSendTransactionRequest extends BaseClientMessage<typeof signAndSendTransactionRequestSchema> { | ||
} | ||
interface SignAndSendTransactionResponseMessage extends zod.infer<typeof SignAndSendTransactionResponseMessageSchema> { | ||
interface SignAndSendTransactionResponse extends BaseHostMessage<typeof signAndSendTransactionResponseSchema> { | ||
} | ||
interface OpenLnkRequestMessage extends zod.infer<typeof OpenLnkRequestMessageSchema> { | ||
interface OpenLnkRequest extends BaseClientMessage<typeof openLnkRequestSchema> { | ||
} | ||
type user_ConnectWalletRequestMessage = ConnectWalletRequestMessage; | ||
declare const user_ConnectWalletRequestMessageSchema: typeof ConnectWalletRequestMessageSchema; | ||
type user_ConnectWalletResponseMessage = ConnectWalletResponseMessage; | ||
declare const user_ConnectWalletResponseMessageSchema: typeof ConnectWalletResponseMessageSchema; | ||
type user_InitialInteractionRequestMessage = InitialInteractionRequestMessage; | ||
declare const user_InitialInteractionRequestMessageSchema: typeof InitialInteractionRequestMessageSchema; | ||
type user_OpenLnkRequestMessage = OpenLnkRequestMessage; | ||
declare const user_OpenLnkRequestMessageSchema: typeof OpenLnkRequestMessageSchema; | ||
type user_ResizeRequestMessage = ResizeRequestMessage; | ||
declare const user_ResizeRequestMessageSchema: typeof ResizeRequestMessageSchema; | ||
type user_SignAndSendTransactionRequestMessage = SignAndSendTransactionRequestMessage; | ||
declare const user_SignAndSendTransactionRequestMessageSchema: typeof SignAndSendTransactionRequestMessageSchema; | ||
type user_SignAndSendTransactionResponseMessage = SignAndSendTransactionResponseMessage; | ||
declare const user_SignAndSendTransactionResponseMessageSchema: typeof SignAndSendTransactionResponseMessageSchema; | ||
type user_ConnectWalletRequest = ConnectWalletRequest; | ||
type user_ConnectWalletResponse = ConnectWalletResponse; | ||
type user_InitialInteractionRequest = InitialInteractionRequest; | ||
type user_OpenLnkRequest = OpenLnkRequest; | ||
type user_ResizeRequest = ResizeRequest; | ||
type user_SignAndSendTransactionRequest = SignAndSendTransactionRequest; | ||
type user_SignAndSendTransactionResponse = SignAndSendTransactionResponse; | ||
type user_UnsignedTransaction = UnsignedTransaction; | ||
declare const user_UnsignedTransactionSchema: typeof UnsignedTransactionSchema; | ||
declare const user_connectWalletRequestSchema: typeof connectWalletRequestSchema; | ||
declare const user_connectWalletResponseSchema: typeof connectWalletResponseSchema; | ||
declare const user_initialInteractionRequestSchema: typeof initialInteractionRequestSchema; | ||
declare const user_openLnkRequestSchema: typeof openLnkRequestSchema; | ||
declare const user_resizeRequestSchema: typeof resizeRequestSchema; | ||
declare const user_signAndSendTransactionRequestSchema: typeof signAndSendTransactionRequestSchema; | ||
declare const user_signAndSendTransactionResponseSchema: typeof signAndSendTransactionResponseSchema; | ||
declare const user_unsignedTransactionSchema: typeof unsignedTransactionSchema; | ||
declare namespace user { | ||
export { type user_ConnectWalletRequestMessage as ConnectWalletRequestMessage, user_ConnectWalletRequestMessageSchema as ConnectWalletRequestMessageSchema, type user_ConnectWalletResponseMessage as ConnectWalletResponseMessage, user_ConnectWalletResponseMessageSchema as ConnectWalletResponseMessageSchema, type user_InitialInteractionRequestMessage as InitialInteractionRequestMessage, user_InitialInteractionRequestMessageSchema as InitialInteractionRequestMessageSchema, type user_OpenLnkRequestMessage as OpenLnkRequestMessage, user_OpenLnkRequestMessageSchema as OpenLnkRequestMessageSchema, type user_ResizeRequestMessage as ResizeRequestMessage, user_ResizeRequestMessageSchema as ResizeRequestMessageSchema, type user_SignAndSendTransactionRequestMessage as SignAndSendTransactionRequestMessage, user_SignAndSendTransactionRequestMessageSchema as SignAndSendTransactionRequestMessageSchema, type user_SignAndSendTransactionResponseMessage as SignAndSendTransactionResponseMessage, user_SignAndSendTransactionResponseMessageSchema as SignAndSendTransactionResponseMessageSchema, type user_UnsignedTransaction as UnsignedTransaction, user_UnsignedTransactionSchema as UnsignedTransactionSchema }; | ||
export { type user_ConnectWalletRequest as ConnectWalletRequest, type user_ConnectWalletResponse as ConnectWalletResponse, type user_InitialInteractionRequest as InitialInteractionRequest, type user_OpenLnkRequest as OpenLnkRequest, type user_ResizeRequest as ResizeRequest, type user_SignAndSendTransactionRequest as SignAndSendTransactionRequest, type user_SignAndSendTransactionResponse as SignAndSendTransactionResponse, type user_UnsignedTransaction as UnsignedTransaction, user_connectWalletRequestSchema as connectWalletRequestSchema, user_connectWalletResponseSchema as connectWalletResponseSchema, user_initialInteractionRequestSchema as initialInteractionRequestSchema, user_openLnkRequestSchema as openLnkRequestSchema, user_resizeRequestSchema as resizeRequestSchema, user_signAndSendTransactionRequestSchema as signAndSendTransactionRequestSchema, user_signAndSendTransactionResponseSchema as signAndSendTransactionResponseSchema, user_unsignedTransactionSchema as unsignedTransactionSchema }; | ||
} | ||
declare const ClientMessageSchema: zod.ZodUnion<[zod.ZodObject<{ | ||
declare const coreClientSchemas: readonly [zod.ZodObject<{ | ||
type: zod.ZodLiteral<"lifecycle:init-request">; | ||
@@ -565,4 +624,4 @@ payload: zod.ZodObject<{ | ||
}; | ||
}>]>; | ||
declare const HostMessageSchema: zod.ZodUnion<[zod.ZodObject<{ | ||
}>]; | ||
declare const coreHostSchemas: readonly [zod.ZodObject<{ | ||
type: zod.ZodLiteral<"lifecycle:init-response">; | ||
@@ -622,3 +681,2 @@ untrusted: zod.ZodObject<{ | ||
type: "lifecycle:init-response"; | ||
trustedBytes: string; | ||
untrusted: { | ||
@@ -636,5 +694,5 @@ user?: { | ||
}; | ||
trustedBytes: string; | ||
}, { | ||
type: "lifecycle:init-response"; | ||
trustedBytes: string; | ||
untrusted: { | ||
@@ -652,8 +710,12 @@ user?: { | ||
}; | ||
trustedBytes: string; | ||
}>, zod.ZodObject<{ | ||
type: zod.ZodLiteral<"lifecycle:close">; | ||
trustedBytes: zod.ZodString; | ||
}, zod.UnknownKeysParam, zod.ZodTypeAny, { | ||
type: "lifecycle:close"; | ||
trustedBytes: string; | ||
}, { | ||
type: "lifecycle:close"; | ||
trustedBytes: string; | ||
}>, zod.ZodObject<{ | ||
@@ -666,2 +728,4 @@ type: zod.ZodLiteral<"user:connect-wallet-response">; | ||
walletIcon: zod.ZodString; | ||
walletUrl: zod.ZodString; | ||
walletSupportedTransactionVersions: zod.ZodOptional<zod.ZodType<ReadonlySet<0 | "legacy">, zod.ZodTypeDef, ReadonlySet<0 | "legacy">>>; | ||
}, "strip", zod.ZodTypeAny, { | ||
@@ -672,2 +736,4 @@ success: true; | ||
walletIcon: string; | ||
walletUrl: string; | ||
walletSupportedTransactionVersions?: ReadonlySet<0 | "legacy"> | undefined; | ||
}, { | ||
@@ -678,2 +744,4 @@ success: true; | ||
walletIcon: string; | ||
walletUrl: string; | ||
walletSupportedTransactionVersions?: ReadonlySet<0 | "legacy"> | undefined; | ||
}>, zod.ZodObject<{ | ||
@@ -685,7 +753,7 @@ success: zod.ZodLiteral<false>; | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
}, { | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
@@ -696,3 +764,2 @@ }>]>; | ||
type: "user:connect-wallet-response"; | ||
trustedBytes: string; | ||
untrusted: { | ||
@@ -703,10 +770,12 @@ success: true; | ||
walletIcon: string; | ||
walletUrl: string; | ||
walletSupportedTransactionVersions?: ReadonlySet<0 | "legacy"> | undefined; | ||
} | { | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
}; | ||
trustedBytes: string; | ||
}, { | ||
type: "user:connect-wallet-response"; | ||
trustedBytes: string; | ||
untrusted: { | ||
@@ -717,7 +786,10 @@ success: true; | ||
walletIcon: string; | ||
walletUrl: string; | ||
walletSupportedTransactionVersions?: ReadonlySet<0 | "legacy"> | undefined; | ||
} | { | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
}; | ||
trustedBytes: string; | ||
}>, zod.ZodObject<{ | ||
@@ -740,7 +812,7 @@ type: zod.ZodLiteral<"user:sign-send-transaction-response">; | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
}, { | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
@@ -751,29 +823,31 @@ }>]>; | ||
type: "user:sign-send-transaction-response"; | ||
trustedBytes: string; | ||
untrusted: { | ||
success: false; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
} | { | ||
success: true; | ||
signedTx: string; | ||
} | { | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
error?: string | undefined; | ||
}; | ||
trustedBytes: string; | ||
}, { | ||
type: "user:sign-send-transaction-response"; | ||
trustedBytes: string; | ||
untrusted: { | ||
success: false; | ||
errorReason: "error" | "user-cancelled"; | ||
error?: string | undefined; | ||
} | { | ||
success: true; | ||
signedTx: string; | ||
} | { | ||
success: false; | ||
errorReason: "user-cancelled" | "error"; | ||
error?: string | undefined; | ||
}; | ||
}>]>; | ||
declare const ClientMessageTypeSchema: zod.ZodEnum<["lifecycle:init-request" | "user:connect-wallet-request" | "user:initial-interaction-request" | "user:resize-request" | "user:sign-send-transaction-request" | "user:open-link-request", ...("lifecycle:init-request" | "user:connect-wallet-request" | "user:initial-interaction-request" | "user:resize-request" | "user:sign-send-transaction-request" | "user:open-link-request")[]]>; | ||
declare const HostMessageTypeSchema: zod.ZodEnum<["lifecycle:init-response" | "lifecycle:close" | "user:connect-wallet-response" | "user:sign-send-transaction-response", ...("lifecycle:init-response" | "lifecycle:close" | "user:connect-wallet-response" | "user:sign-send-transaction-response")[]]>; | ||
type ClientMessage = zod.infer<typeof ClientMessageSchema>; | ||
type ClientMessageType = zod.infer<typeof ClientMessageTypeSchema>; | ||
type HostMessage = zod.infer<typeof HostMessageSchema>; | ||
type HostMessageType = zod.infer<typeof HostMessageTypeSchema>; | ||
trustedBytes: string; | ||
}>]; | ||
type CoreClientMessageSchema = (typeof coreClientSchemas)[number]; | ||
type CoreHostMessageSchema = (typeof coreHostSchemas)[number]; | ||
type CoreClientMessage = BaseClientMessage<CoreClientMessageSchema>; | ||
type CoreHostMessage = BaseHostMessage<CoreHostMessageSchema>; | ||
type CoreClientMessageType = CoreClientMessage['type']; | ||
type CoreHostMessageType = CoreHostMessage['type']; | ||
declare const parseCoreClientMessage: (message: unknown) => CoreClientMessage | undefined; | ||
declare const parseCoreHostMessage: (message: unknown) => CoreHostMessage | undefined; | ||
@@ -799,2 +873,2 @@ declare class ClientAlreadyInitializedError extends Error { | ||
export { ClientAlreadyInitializedError, type ClientMessage, ClientMessageSchema, type ClientMessageType, ClientNotInitializedError, type HostMessage, HostMessageSchema, type HostMessageType, lifecycle as Lifecycle, ReferrerNotDefinedError, user as User, VERSION, WindowNotDefinedError }; | ||
export { type BaseClientMessage, type BaseClientMessageSchema, type BaseHostMessage, type BaseHostMessageSchema, ClientAlreadyInitializedError, ClientNotInitializedError, type CoreClientMessage, type CoreClientMessageSchema, type CoreClientMessageType, type CoreHostMessage, type CoreHostMessageSchema, type CoreHostMessageType, lifecycle as Lifecycle, ReferrerNotDefinedError, user as User, VERSION, WindowNotDefinedError, createClientMessageSchema, createFailedResponsePayload, createHostMessageSchema, parseBaseClientMessage, parseBaseHostMessage, parseCoreClientMessage, parseCoreHostMessage }; |
@@ -10,11 +10,11 @@ var __defProp = Object.defineProperty; | ||
__export(lifecycle_exports, { | ||
CloseMessageSchema: () => CloseMessageSchema, | ||
ContentSchema: () => ContentSchema, | ||
InitRequestMessageSchema: () => InitRequestMessageSchema, | ||
InitResponseMessageSchema: () => InitResponseMessageSchema, | ||
UserSchema: () => UserSchema | ||
closeMessageSchema: () => closeMessageSchema, | ||
contentSchema: () => contentSchema, | ||
initRequestSchema: () => initRequestSchema, | ||
initResponseSchema: () => initResponseSchema, | ||
userSchema: () => userSchema | ||
}); | ||
import * as zod2 from "zod"; | ||
// src/schema/base.ts | ||
// src/schema/base/lib.ts | ||
import * as zod from "zod"; | ||
@@ -45,5 +45,36 @@ function createClientMessageSchema(type, payloadSchema) { | ||
} | ||
var createFailedResponsePayload = (reasons) => { | ||
return zod.object({ | ||
success: zod.literal(false), | ||
errorReason: zod.enum(reasons), | ||
error: zod.string().optional() | ||
}); | ||
}; | ||
var parseBaseClientMessage = (message) => { | ||
const clientMessageSchema = zod.object({ | ||
type: zod.custom(), | ||
payload: zod.any().optional() | ||
}); | ||
const parsedMessage = clientMessageSchema.safeParse(message); | ||
if (!parsedMessage.success) { | ||
return void 0; | ||
} | ||
return parsedMessage.data; | ||
}; | ||
var parseBaseHostMessage = (message) => { | ||
const hostMessageSchema = zod.object({ | ||
type: zod.custom(), | ||
untrusted: zod.any().optional(), | ||
trustedBytes: zod.string(), | ||
zod: zod.custom() | ||
}); | ||
const parsedMessage = hostMessageSchema.safeParse(message); | ||
if (!parsedMessage.success) { | ||
return void 0; | ||
} | ||
return parsedMessage.data; | ||
}; | ||
// src/schema/lifecycle.ts | ||
var UserSchema = zod2.object({ | ||
var userSchema = zod2.object({ | ||
id: zod2.string(), | ||
@@ -53,3 +84,3 @@ username: zod2.string(), | ||
}); | ||
var ContentSchema = zod2.object({ | ||
var contentSchema = zod2.object({ | ||
id: zod2.string(), | ||
@@ -59,3 +90,3 @@ portalId: zod2.string(), | ||
}); | ||
var InitRequestMessageSchema = createClientMessageSchema( | ||
var initRequestSchema = createClientMessageSchema( | ||
"lifecycle:init-request", | ||
@@ -66,10 +97,10 @@ zod2.object({ | ||
); | ||
var InitResponseMessageSchema = createHostMessageSchema( | ||
var initResponseSchema = createHostMessageSchema( | ||
"lifecycle:init-response", | ||
zod2.object({ | ||
user: UserSchema.optional(), | ||
content: ContentSchema.optional() | ||
user: userSchema.optional(), | ||
content: contentSchema.optional() | ||
}) | ||
); | ||
var CloseMessageSchema = createHostMessageSchema("lifecycle:close"); | ||
var closeMessageSchema = createHostMessageSchema("lifecycle:close"); | ||
@@ -79,13 +110,13 @@ // src/schema/user.ts | ||
__export(user_exports, { | ||
ConnectWalletRequestMessageSchema: () => ConnectWalletRequestMessageSchema, | ||
ConnectWalletResponseMessageSchema: () => ConnectWalletResponseMessageSchema, | ||
InitialInteractionRequestMessageSchema: () => InitialInteractionRequestMessageSchema, | ||
OpenLnkRequestMessageSchema: () => OpenLnkRequestMessageSchema, | ||
ResizeRequestMessageSchema: () => ResizeRequestMessageSchema, | ||
SignAndSendTransactionRequestMessageSchema: () => SignAndSendTransactionRequestMessageSchema, | ||
SignAndSendTransactionResponseMessageSchema: () => SignAndSendTransactionResponseMessageSchema, | ||
UnsignedTransactionSchema: () => UnsignedTransactionSchema | ||
connectWalletRequestSchema: () => connectWalletRequestSchema, | ||
connectWalletResponseSchema: () => connectWalletResponseSchema, | ||
initialInteractionRequestSchema: () => initialInteractionRequestSchema, | ||
openLnkRequestSchema: () => openLnkRequestSchema, | ||
resizeRequestSchema: () => resizeRequestSchema, | ||
signAndSendTransactionRequestSchema: () => signAndSendTransactionRequestSchema, | ||
signAndSendTransactionResponseSchema: () => signAndSendTransactionResponseSchema, | ||
unsignedTransactionSchema: () => unsignedTransactionSchema | ||
}); | ||
import * as zod3 from "zod"; | ||
var ConnectWalletRequestMessageSchema = createClientMessageSchema( | ||
var connectWalletRequestSchema = createClientMessageSchema( | ||
"user:connect-wallet-request", | ||
@@ -96,6 +127,6 @@ zod3.object({ | ||
); | ||
var InitialInteractionRequestMessageSchema = createClientMessageSchema( | ||
var initialInteractionRequestSchema = createClientMessageSchema( | ||
"user:initial-interaction-request" | ||
); | ||
var ResizeRequestMessageSchema = createClientMessageSchema( | ||
var resizeRequestSchema = createClientMessageSchema( | ||
"user:resize-request", | ||
@@ -107,3 +138,3 @@ zod3.object({ | ||
); | ||
var ConnectWalletResponseMessageSchema = createHostMessageSchema( | ||
var connectWalletResponseSchema = createHostMessageSchema( | ||
"user:connect-wallet-response", | ||
@@ -115,22 +146,20 @@ zod3.union([ | ||
walletName: zod3.string(), | ||
walletIcon: zod3.string() | ||
walletIcon: zod3.string(), | ||
walletUrl: zod3.string(), | ||
walletSupportedTransactionVersions: zod3.custom().optional() | ||
}), | ||
zod3.object({ | ||
success: zod3.literal(false), | ||
errorReason: zod3.enum(["user-cancelled", "error"]), | ||
error: zod3.string().optional() | ||
}) | ||
createFailedResponsePayload(["user-cancelled", "error"]) | ||
]) | ||
); | ||
var UnsignedTransactionSchema = zod3.object({ | ||
var unsignedTransactionSchema = zod3.object({ | ||
unsignedTx: zod3.string(), | ||
awaitCommitment: zod3.enum(["confirmed", "finalized", "none"]).optional() | ||
}); | ||
var SignAndSendTransactionRequestMessageSchema = createClientMessageSchema( | ||
var signAndSendTransactionRequestSchema = createClientMessageSchema( | ||
"user:sign-send-transaction-request", | ||
UnsignedTransactionSchema.extend({ | ||
unsignedTransactionSchema.extend({ | ||
chainId: zod3.string() | ||
}) | ||
); | ||
var SignAndSendTransactionResponseMessageSchema = createHostMessageSchema( | ||
var signAndSendTransactionResponseSchema = createHostMessageSchema( | ||
"user:sign-send-transaction-response", | ||
@@ -142,10 +171,6 @@ zod3.union([ | ||
}), | ||
zod3.object({ | ||
success: zod3.literal(false), | ||
errorReason: zod3.enum(["user-cancelled", "error"]), | ||
error: zod3.string().optional() | ||
}) | ||
createFailedResponsePayload(["user-cancelled", "error"]) | ||
]) | ||
); | ||
var OpenLnkRequestMessageSchema = createClientMessageSchema( | ||
var openLnkRequestSchema = createClientMessageSchema( | ||
"user:open-link-request", | ||
@@ -157,32 +182,34 @@ zod3.object({ | ||
// src/schema/index.ts | ||
// src/schema/core.ts | ||
import * as zod4 from "zod"; | ||
var ClientMessageSchema = zod4.union([ | ||
InitRequestMessageSchema, | ||
InitialInteractionRequestMessageSchema, | ||
ResizeRequestMessageSchema, | ||
ConnectWalletRequestMessageSchema, | ||
SignAndSendTransactionRequestMessageSchema, | ||
OpenLnkRequestMessageSchema | ||
]); | ||
var HostMessageSchema = zod4.union([ | ||
InitResponseMessageSchema, | ||
CloseMessageSchema, | ||
ConnectWalletResponseMessageSchema, | ||
SignAndSendTransactionResponseMessageSchema | ||
]); | ||
var clientMessageTypes = ClientMessageSchema.options.map( | ||
(m) => m.shape.type.value | ||
); | ||
var ClientMessageTypeSchema = zod4.enum([ | ||
clientMessageTypes[0], | ||
...clientMessageTypes.slice(1) | ||
]); | ||
var hostMessageTypes = HostMessageSchema.options.map( | ||
(m) => m.shape.type.value | ||
); | ||
var HostMessageTypeSchema = zod4.enum([ | ||
hostMessageTypes[0], | ||
...hostMessageTypes.slice(1) | ||
]); | ||
var coreClientSchemas = [ | ||
initRequestSchema, | ||
initialInteractionRequestSchema, | ||
resizeRequestSchema, | ||
connectWalletRequestSchema, | ||
signAndSendTransactionRequestSchema, | ||
openLnkRequestSchema | ||
]; | ||
var coreHostSchemas = [ | ||
initResponseSchema, | ||
closeMessageSchema, | ||
connectWalletResponseSchema, | ||
signAndSendTransactionResponseSchema | ||
]; | ||
var parseCoreClientMessage = (message) => { | ||
const schema = zod4.union(coreClientSchemas); | ||
const parsedMessage = schema.safeParse(message); | ||
if (!parsedMessage.success) { | ||
return void 0; | ||
} | ||
return parsedMessage.data; | ||
}; | ||
var parseCoreHostMessage = (message) => { | ||
const schema = zod4.union(coreHostSchemas); | ||
const parsedMessage = schema.safeParse(message); | ||
if (!parsedMessage.success) { | ||
return void 0; | ||
} | ||
return parsedMessage.data; | ||
}; | ||
@@ -211,5 +238,3 @@ // src/errors.ts | ||
ClientAlreadyInitializedError, | ||
ClientMessageSchema, | ||
ClientNotInitializedError, | ||
HostMessageSchema, | ||
lifecycle_exports as Lifecycle, | ||
@@ -219,4 +244,11 @@ ReferrerNotDefinedError, | ||
VERSION, | ||
WindowNotDefinedError | ||
WindowNotDefinedError, | ||
createClientMessageSchema, | ||
createFailedResponsePayload, | ||
createHostMessageSchema, | ||
parseBaseClientMessage, | ||
parseBaseHostMessage, | ||
parseCoreClientMessage, | ||
parseCoreHostMessage | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@dscvr-one/canvas-interface", | ||
"version": "1.0.7", | ||
"version": "1.1.0", | ||
"description": "Types for iframes to interact with dscvr", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103840
1343