Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@wharfkit/session",
"description": "Create account-based sessions, perform transactions, and allow users to login using Antelope-based blockchains.",
"version": "1.6.1",
"version": "1.7.1-beta1",
"homepage": "https://github.com/wharfkit/session",
"license": "BSD-3-Clause",
"main": "lib/session.js",
Expand Down
35 changes: 35 additions & 0 deletions src/encoded.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {Checksum256, Name, Struct} from '@wharfkit/antelope'
import {SerializedSession, Session} from './index-module'

/**
* The metadata of an [[AccountCreationPlugin]].
*/
@Struct.type('url_encoded_session')
export class URLEncodedSession extends Struct {
@Struct.field(Checksum256) declare chain: Checksum256
@Struct.field(Name) declare actor: Name
@Struct.field(Name) declare permission: Name
@Struct.field('string') declare walletPlugin: string
@Struct.field('string', {optional: true}) declare data?: string

static fromSession(data: Session | SerializedSession): URLEncodedSession {
Copy link
Contributor

@dafuga dafuga Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need some better error handling for situations when bad data is passed to this method?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The serializer should catch any bad data and report on it.

const session = data instanceof Session ? data.serialize() : data
return new URLEncodedSession({
chain: session.chain,
actor: session.actor,
permission: session.permission,
walletPlugin: JSON.stringify(session.walletPlugin),
data: JSON.stringify(session.data),
})
}

get serialized(): SerializedSession {
return {
chain: this.chain,
actor: this.actor,
permission: this.permission,
walletPlugin: JSON.parse(this.walletPlugin),
data: this.data ? JSON.parse(this.data) : undefined,
}
}
}
1 change: 1 addition & 0 deletions src/index-module.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './encoded'
export * from './kit'
export * from './login'
export * from './session'
Expand Down
Loading