New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

edge-core-js

Package Overview
Dependencies
Maintainers
6
Versions
292
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

edge-core-js - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

5

CHANGELOG.md
# edge-core-js
## v1.3.0 (2023-06-16)
- added: Add an `EdgeAccount.getPin` method.
- fixed: Allow the `EdgeAccount.username` property to update after calling `changeUsername`.
## v1.2.0 (2023-06-15)

@@ -4,0 +9,0 @@

26

lib/core/account/account-api.js

@@ -70,6 +70,13 @@ function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }

export function makeAccountApi(ai, accountId) {
const accountState = () => ai.props.state.accounts[accountId]
const { accountWalletInfo, loginType, loginTree } = accountState()
const { username } = loginTree
// We don't want accountState to be undefined when we log out,
// so preserve a snapshot of our last state:
let lastState = ai.props.state.accounts[accountId]
const accountState = () => {
const nextState = ai.props.state.accounts[accountId]
if (nextState != null) lastState = nextState
return lastState
}
const { accountWalletInfo, loginType } = accountState()
// Plugin config API's:

@@ -150,3 +157,3 @@ const currencyConfigs = {}

get loggedIn() {
return accountState() != null
return ai.props.state.accounts[accountId] != null
},

@@ -164,2 +171,3 @@

lockdown()
const { loginTree } = accountState()
return base58.stringify(loginTree.loginId)

@@ -169,3 +177,4 @@ },

get username() {
return username
const { loginTree } = accountState()
return loginTree.username
},

@@ -263,2 +272,7 @@

async getPin() {
const { login, loginTree } = accountState()
return _nullishCoalesce(login.pin, () => ( loginTree.pin))
},
// ----------------------------------------------------------------

@@ -331,2 +345,3 @@ // Remove credentials:

async approveVoucher(voucherId) {
const { loginTree } = accountState()
return await changeVoucherStatus(ai, loginTree, {

@@ -338,2 +353,3 @@ approvedVouchers: [voucherId]

async rejectVoucher(voucherId) {
const { loginTree } = accountState()
return await changeVoucherStatus(ai, loginTree, {

@@ -340,0 +356,0 @@ rejectedVouchers: [voucherId]

@@ -15,3 +15,5 @@ import { asMaybe, asObject, uncleaner } from 'cleaners'

asChangePasswordPayload,
asChangePin2IdPayload,
asChangePin2Payload,
asChangeRecovery2IdPayload,
asChangeRecovery2Payload,

@@ -483,4 +485,96 @@ asChangeSecretPayload,

export const vouchersRoute = withLogin2(async request => {
const usernameRoute = withLogin2(async request => {
const { db, login, payload } = request
const cleanPassword = asMaybe(asChangePasswordPayload)(payload)
const cleanPin2 = asMaybe(asChangePin2IdPayload)(payload)
const cleanRecovery2 = asMaybe(asChangeRecovery2IdPayload)(payload)
const cleanUsername = asMaybe(asChangeUsernamePayload)(payload)
// Validate the payload selection:
if (login.passwordAuth != null && cleanPassword == null) {
return await statusResponse(
statusCodes.invalidRequest,
'Missing password payload'
)
}
if (login.pin2Auth != null && cleanPin2 == null) {
return await statusResponse(
statusCodes.invalidRequest,
'Missing pin2Id payload'
)
}
if (login.recovery2Auth != null && cleanRecovery2 == null) {
return await statusResponse(
statusCodes.invalidRequest,
'Missing recovery2Id payload'
)
}
if (login.parentBox == null && cleanUsername == null) {
return await statusResponse(
statusCodes.invalidRequest,
'Missing username payload'
)
}
// Do we have a password?
if (cleanPassword != null) {
login.passwordAuth = cleanPassword.passwordAuth
login.passwordAuthBox = cleanPassword.passwordAuthBox
login.passwordAuthSnrp = cleanPassword.passwordAuthSnrp
login.passwordBox = cleanPassword.passwordBox
login.passwordKeySnrp = cleanPassword.passwordKeySnrp
}
// Do we have a PIN?
if (cleanPin2 != null) {
if (login.pin2Auth == null) {
return await statusResponse(
statusCodes.invalidRequest,
'Login lacks pin2'
)
}
const existing = await db.getLoginByPin2Id(cleanPin2.pin2Id)
if (existing != null) {
return await statusResponse(statusCodes.conflict)
}
login.pin2Id = cleanPin2.pin2Id
}
// Do we have recovery?
if (cleanRecovery2 != null) {
if (login.recovery2Auth == null) {
return await statusResponse(
statusCodes.invalidRequest,
'Login lacks recovery2'
)
}
const existing = await db.getLoginByRecovery2Id(cleanRecovery2.recovery2Id)
if (existing != null) {
return await statusResponse(statusCodes.conflict)
}
login.recovery2Id = cleanRecovery2.recovery2Id
}
// Are we the root login?
if (cleanUsername != null) {
if (login.parentBox != null) {
return await statusResponse(
statusCodes.invalidRequest,
'Only top-level logins can have usernames'
)
}
const existing = await db.getLoginByUserId(cleanUsername.userId)
if (existing != null) {
return await statusResponse(statusCodes.conflict)
}
login.userId = cleanUsername.userId
login.userTextBox = cleanUsername.userTextBox
}
return await payloadResponse(wasLoginPayload(makeLoginPayload(db, login)))
})
const vouchersRoute = withLogin2(async request => {
const { db, login, payload } = request
const clean = asMaybe(asChangeVouchersPayload)(payload)

@@ -685,2 +779,5 @@ if (clean == null) return await statusResponse(statusCodes.invalidRequest)

}),
'/api/v2/login/username/?': pickMethod({
POST: withApiKey(usernameRoute)
}),
'/api/v2/login/vouchers/?': pickMethod({

@@ -687,0 +784,0 @@ POST: withApiKey(vouchersRoute)

@@ -1370,2 +1370,3 @@ // @flow

+checkPin: (pin: string) => Promise<boolean>;
+getPin: () => Promise<string | void>;

@@ -1372,0 +1373,0 @@ // Remove credentials:

@@ -1705,1 +1705,2 @@

2

package.json
{
"name": "edge-core-js",
"version": "1.2.0",
"version": "1.3.0",
"description": "Edge account & wallet management library",

@@ -5,0 +5,0 @@ "keywords": [

@@ -1364,2 +1364,3 @@ import type { Disklet } from 'disklet'

readonly checkPin: (pin: string) => Promise<boolean>
readonly getPin: () => Promise<string | undefined>

@@ -1366,0 +1367,0 @@ // Remove credentials:

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc