Skip to main content

Class: Tokenizer

Constructors

constructor

โ€ข new Tokenizer(config)

Parameters

NameType
configPartial<TokenizerClientConfig>

Defined in

tokenizer.ts:50

Properties

config

โ€ข Readonly config: TokenizerClientConfig

Defined in

tokenizer.ts:46


openApi

โ€ข Readonly openApi: DefaultApi

Defined in

tokenizer.ts:47

Methods

createGrant

โ–ธ createGrant(sessionId, tokenId, customDuration?): Promise<TokenizerFailApiResponse | { success: boolean }>

Parameters

NameType
sessionIdstring
tokenIdstring
customDuration?string

Returns

Promise<TokenizerFailApiResponse | { success: boolean }>

Defined in

tokenizer.ts:101


verifyGrant

โ–ธ verifyGrant(sessionId, tokenId): SuccessOrFailOutput<TokenizerVerifyGrantResponse>

Parameters

NameType
sessionIdstring
tokenIdstring

Returns

SuccessOrFailOutput<TokenizerVerifyGrantResponse>

Defined in

tokenizer.ts:119


getMetadata

โ–ธ getMetadata(tokenId): SuccessOrFailOutput<TokenizerGetMetadataResponse>

Parameters

NameType
tokenIdstring

Returns

SuccessOrFailOutput<TokenizerGetMetadataResponse>

Defined in

tokenizer.ts:137


tokenize

โ–ธ tokenize(input, metadata): SuccessOrFailOutput<TokenizerTokenizeResponse>

Parameters

NameType
inputstring | Buffer
metadataMetaData

Returns

SuccessOrFailOutput<TokenizerTokenizeResponse>

Defined in

tokenizer.ts:155


detokenize

โ–ธ detokenize(tokenId): SuccessOrFailOutput<TokenizerDetokenizeResponse>

Parameters

NameType
tokenIdstring

Returns

SuccessOrFailOutput<TokenizerDetokenizeResponse>

Defined in

tokenizer.ts:175


detokenizeToUrl

โ–ธ detokenizeToUrl(tokenId): SuccessOrFailOutput<TokenizerDetokenizeToUrlResponse>

Parameters

NameType
tokenIdstring

Returns

SuccessOrFailOutput<TokenizerDetokenizeToUrlResponse>

Defined in

tokenizer.ts:217


detokenizeToFileInfo

โ–ธ detokenizeToFileInfo(token): SuccessOrFailOutput<TokenizerDetokenizeFileInfo>

// Fetches file info and pre-signed URL needed to start a file download. Useful when we want to prepare the option to start a download but not yet start one. Grabs the file URL and metadata in parallel. Similar to detokenizeToUrl but for files

Parameters

NameType
tokenstring

Returns

SuccessOrFailOutput<TokenizerDetokenizeFileInfo>

Defined in

tokenizer.ts:261


detokenizeFileFromFileInfo

โ–ธ detokenizeFileFromFileInfo(fileInfo): SuccessOrFailOutput<TokenizerDetokenizeFileResponse>

BROWSER ONLY Triggers a download of a file that we already got the file info for using getFileInfo

Parameters

NameTypeDescription
fileInfoFileInfoLunaSec's custom FileInfo object which tells us about the tokenized file

Returns

SuccessOrFailOutput<TokenizerDetokenizeFileResponse>

Defined in

tokenizer.ts:307


detokenizeFile

โ–ธ detokenizeFile(token): SuccessOrFailOutput<TokenizerDetokenizeFileResponse>

BROWSER ONLY Takes a token and downloads and returns a File object, complete with proper name, mime type, and lastModified fields

Parameters

NameType
tokenstring

Returns

SuccessOrFailOutput<TokenizerDetokenizeFileResponse>

Defined in

tokenizer.ts:328


tokenizeFile

โ–ธ tokenizeFile(file, customMetadata?): SuccessOrFailOutput<TokenizerTokenizeResponse>

BROWSER ONLY uploads a file into LunaSec and returns a tokenId, just like tokenize

Parameters

NameType
fileFile | FileWithPath
customMetadata?Record<string, unknown>

Returns

SuccessOrFailOutput<TokenizerTokenizeResponse>

Defined in

tokenizer.ts:342