export type { CustomConnectorOptions } from "./connector.js"; export { DacLibrary } from "./dac.js"; import { Connection } from "post-me"; import { Permission } from "skynet-mysky-utils"; import { Connector, CustomConnectorOptions } from "./connector.js"; import { SkynetClient } from "../client.js"; import { DacLibrary } from "./dac.js"; import { RegistryEntry } from "../registry.js"; import { Signature } from "../crypto.js"; import { deleteEntryData, deleteJSON, getEntryData, getEntryLink, getJSON, getJSONEncrypted, setDataLink, setEntryData, setJSON, setJSONEncrypted } from "./skydb.js"; /** * The domain for MySky. */ export declare const MYSKY_DOMAIN = "skynet-mysky.hns"; /** * @deprecated please use MYSKY_DOMAIN. */ export declare const mySkyDomain = "skynet-mysky.hns"; /** * The domain for MySky dev. */ export declare const MYSKY_DEV_DOMAIN = "skynet-mysky-dev.hns"; /** * @deprecated please use MYSKY_DEV_DOMAIN. */ export declare const mySkyDevDomain = "skynet-mysky-dev.hns"; /** * The domain for MySky alpha. Intentionally not exported in index file. */ export declare const MYSKY_ALPHA_DOMAIN = "sandbridge.hns"; /** * The maximum length for entry data when setting entry data. */ export declare const MAX_ENTRY_LENGTH = 70; export declare type EntryData = { data: Uint8Array | null; }; /** * Loads MySky. Note that this does not log in the user. * * @param this - The Skynet client. * @param skappDomain - The domain of the host skapp. For this domain permissions will be requested and, by default, automatically granted. * @param [customOptions] - Additional settings that can optionally be set. * @returns - Loaded (but not logged-in) MySky instance. */ export declare function loadMySky(this: SkynetClient, skappDomain?: string, customOptions?: CustomConnectorOptions): Promise; /** * The singleton object that allows skapp developers to initialize and * communicate with MySky. */ export declare class MySky { protected connector: Connector; protected hostDomain: string; protected currentPortalUrl: string; static instance: MySky | null; dacs: DacLibrary[]; grantedPermissions: Permission[]; pendingPermissions: Permission[]; /** * Creates a `MySky` instance. * * @param connector - The `Connector` object. * @param permissions - The initial requested permissions. * @param hostDomain - The domain of the host skapp. * @param currentPortalUrl - The URL of the current portal. This is the portal that the skapp is running on, not the portal that may have been requested by the developer when creating a `SkynetClient`. */ constructor(connector: Connector, permissions: Permission[], hostDomain: string, currentPortalUrl: string); /** * Initializes MySky and returns a `MySky` instance. * * @param client - The Skynet Client. * @param [skappDomain] - The domain of the host skapp. * @param [customOptions] - Additional settings that can optionally be set. * @returns - A `MySky` instance. */ static New(client: SkynetClient, skappDomain?: string, customOptions?: CustomConnectorOptions): Promise; /** * Checks if the current browser is supported by MySky. * * @returns - A promise with a boolean indicating whether the browser is supported and, if not, a string containing the user-friendly error message. */ static isBrowserSupported(): Promise<[boolean, string]>; /** * Loads the given DACs. * * @param dacs - The DAC library instances to call `init` on. */ loadDacs(...dacs: DacLibrary[]): Promise; /** * Adds the given permissions to the list of pending permissions. * * @param permissions - The list of permissions to add. */ addPermissions(...permissions: Permission[]): Promise; /** * Checks whether main MySky, living in an invisible iframe, is already logged * in and all requested permissions are granted. * * @returns - A boolean indicating whether the user is logged in and all * permissions are granted. */ checkLogin(): Promise; /** * Destroys the mysky connection by: * * 1. Destroying the connected DACs. * * 2. Closing the connection. * * 3. Closing the child iframe. * * @throws - Will throw if there is an unexpected DOM error. */ destroy(): Promise; /** * Log out the user. * * @returns - An empty promise. */ logout(): Promise; /** * Requests login access by opening the MySky UI window. * * @returns - A boolean indicating whether we successfully logged in and all * requested permissions were granted. */ requestLoginAccess(): Promise; /** * Returns the user ID (i.e. same as the user's public key). * * @returns - The hex-encoded user ID. */ userID(): Promise; getJSON: typeof getJSON; getEntryLink: typeof getEntryLink; setJSON: typeof setJSON; deleteJSON: typeof deleteJSON; setDataLink: typeof setDataLink; getEntryData: typeof getEntryData; setEntryData: typeof setEntryData; deleteEntryData: typeof deleteEntryData; getJSONEncrypted: typeof getJSONEncrypted; setJSONEncrypted: typeof setJSONEncrypted; dbV2: { getJSON: (path: string, customOptions?: import("../skydb_v2.js").CustomGetJSONOptions | undefined) => Promise; getEntryLink: (path: string) => Promise; setJSON: (path: string, json: import("../index.js").JsonData, customOptions?: import("../skydb_v2.js").CustomSetJSONOptions | undefined) => Promise; deleteJSON: (path: string, customOptions?: import("../skydb_v2.js").CustomSetEntryDataOptions | undefined) => Promise; setDataLink: (path: string, dataLink: string, customOptions?: import("../skydb_v2.js").CustomSetEntryDataOptions | undefined) => Promise; getEntryData: (path: string, customOptions?: import("../registry.js").CustomGetEntryOptions | undefined) => Promise; setEntryData: (path: string, data: Uint8Array, customOptions?: import("../skydb_v2.js").CustomSetEntryDataOptions | undefined) => Promise; deleteEntryData: (path: string, customOptions?: import("../skydb_v2.js").CustomSetEntryDataOptions | undefined) => Promise; getJSONEncrypted: (path: string, customOptions?: import("../skydb_v2.js").CustomGetJSONOptions | undefined) => Promise; setJSONEncrypted: (path: string, json: import("../index.js").JsonData, customOptions?: import("../skydb_v2.js").CustomSetJSONOptions | undefined) => Promise; }; /** * Lets you get the share-able path seed, which can be passed to * `file.getJSONEncrypted` (in file.ts). Requires Hidden Read permission on * the path. * * @param path - The given path. * @param isDirectory - Whether the path is a directory. * @returns - The seed for the path. * @throws - Will throw if the user does not have Hidden Read permission on the path. * @deprecated - This function has been deprecated in favor of `getEncryptedPathSeed`. */ getEncryptedFileSeed(path: string, isDirectory: boolean): Promise; /** * Lets you get the share-able path seed, which can be passed to * `file.getJSONEncrypted` (in file.ts). Requires Hidden Read permission on * the path. * * @param path - The given path. * @param isDirectory - Whether the path is a directory. * @returns - The seed for the path. * @throws - Will throw if the user does not have Hidden Read permission on the path. */ getEncryptedPathSeed(path: string, isDirectory: boolean): Promise; /** * signMessage will sign the given data using the MySky user's private key, * this method can be used for MySky user verification as the signature may be * verified against the user's public key, which is the MySky user id. * * @param message - message to sign * @returns signature */ signMessage(message: Uint8Array): Promise; /** * verifyMessageSignature verifies the signature for the message and given * public key and returns a boolean that indicates whether the verification * succeeded. * * @param message - the original message that was signed * @param signature - the signature * @param publicKey - the public key * @returns boolean that indicates whether the verification succeeded */ verifyMessageSignature(message: Uint8Array, signature: Uint8Array, publicKey: string): Promise; /** * Catches any errors returned from the UI and dispatches them in the current * window. This is how we bubble up errors from the MySky UI window to the * skapp. * * @param errorMsg - The error message. */ protected catchError(errorMsg: string): Promise; /** * Checks if the MySky user can be logged into a portal account. * * @returns - Whether the user can be logged into a portal account. */ protected checkPortalLogin(): Promise; /** * Launches the MySky UI popup window. * * @returns - The window handle. * @throws - Will throw if the window could not be opened. */ protected launchUI(): Window; /** * Connects to the MySky UI window by establishing a postmessage handshake. * * @param childWindow - The MySky UI window. * @returns - The `Connection` with the other window. */ protected connectUi(childWindow: Window): Promise; /** * Gets the preferred portal from MySky, or `null` if not set. * * @returns - The preferred portal if set. */ protected getPreferredPortal(): Promise; /** * Loads the given DAC. * * @param dac - The dac to load. */ protected loadDac(dac: DacLibrary): Promise; /** * Handles the after-login logic. */ protected handleLogin(): Promise; /** * Logs in to the user's portal account. * * @returns - An empty promise. */ protected portalLogin(): Promise; /** * Get the preferred portal and redirect the page if it is different than * the current portal. * * Load MySky redirect flow: * * 1. SDK opens MySky on the same portal as the skapp. * 2. If the preferred portal is found in localstorage, MySky connects to it * and we go to step 5. * 3. Else, MySky connects to siasky.net. * 4. MySky tries to get the saved portal preference. * 1. If the portal is set, MySky switches to using the preferred portal. * 2. If it is not set or we don't have the seed, MySky switches to using * the current portal as opposed to siasky.net. * 5. After MySky finishes loading, SDK queries `mySky.getPortalPreference`. * 6. If the preferred portal is set and different than the current portal, * SDK triggers refresh. * 7. We go back to step 1 and repeat, but since we're on the right portal * now we won't refresh in step 6. * * Login redirect flow: * * 1. SDK logs in through the UI. * 2. MySky UI switches to siasky.net and tries to get the saved portal * preference. * 1. If the portal is set, MySky switches to using the preferred portal. * 2. If it is not set or we don't have the seed, MySky switches to using * the current portal as opposed to siasky.net. * 3. SDK queries `mySky.getPortalPreference`. * 4. If the preferred portal is set and different than the current portal, * SDK triggers refresh. * 5. We go to "Load MySky" step 1 and go through that flow, but we don't * refresh in step 6. */ protected redirectIfNotOnPreferredPortal(): Promise; /** * Asks MySky to sign the non-encrypted registry entry. * * @param entry - The non-encrypted registry entry. * @param path - The MySky path. * @returns - The signature. */ protected signRegistryEntry(entry: RegistryEntry, path: string): Promise; /** * Asks MySky to sign the encrypted registry entry. * * @param entry - The encrypted registry entry. * @param path - The MySky path. * @returns - The signature. */ protected signEncryptedRegistryEntry(entry: RegistryEntry, path: string): Promise; } //# sourceMappingURL=index.d.ts.map