Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@cloudbase/oauth
Advanced tools
提供 oauth2 的登录相关功能。
OAuth2Client oauth2 基础模块
Auth 登录相关模块
const authOptions = {
apiOrigin: "服务域名",
clientId: "客户端ID"
}
const auth = new Auth(authOptions)
import { initializeClient } from "@xbasesdk/xbase"
const config = {
env: "xbase-4gh5dh6nf62145a9"
}
const client = initializeClient(config)
// 调用API
const loginState = await client.auth.hasLoginState()
// 获取 accessToken
const accessToken = await client.oAuth2Client.getAccessToken()
// 用 OIDC Token 用自己的API
export interface ExampleData {
result?: string
}
const data = await client.oAuth2Client.request<ExampleData>(
"https://example.com",
{ withCredentials: true }
)
console.log(data.result)
import {initializeApp} from '@clodbasesdk/oauth/app';
import {getAuth} from '@clodbasesdk/oauth/auth';
export const config = {
env: 'env-4gh5dh6nf62145a9'
};
const app = initializeApp(config)
const auth = getAuth(app)
// 调用API
const loginState = await auth.hasLoginState()
auth.signIn({
username: "test",
password: "test"
})
const phoneNumber = "10012341234"
// 短信验证码
const verificationCode = "******"
const verification = await auth.getVerification({
phone_number: "+86 " + phoneNumber,
target: "ANY"
})
let verifyResult = await auth.verify({
verification_code: verificationCode,
verification_id: verification ? verification.verification_id : ""
})
let isUser = verification ? verification.is_user : false
let result
if (isUser) {
result = await auth.signIn({
username: "+86 " + phoneNumber,
verification_code: verificationCode,
verification_token: verifyResult.verification_token
})
} else {
result = await auth.signUp({
phone_number: "+86 " + phoneNumber,
password: "*******",
verification_code: verificationCode,
verification_token: verifyResult.verification_token,
local: "zh-cn",
name: "100****1234"
})
}
try {
await auth.verify({
verification_code: verificationCode,
verification_id: verification ? verification.verification_id : ""
})
} catch (error) {
if (error && error.error_uri === "/v1/auth/verification/verify") {
switch (error.error) {
case "not_found": {
result = i18n.translate("error", "User Not Found")
break
}
case "invalid_password": {
if (error.details !== undefined && error.details.length > 0) {
result =
i18n.translate("error", "Certification failed, you still have") +
error.details[0].limit_remaining +
i18n.translate("error", "chances. You can also") +
"" +
i18n.translate("error", "Reset Login Password") +
"</a>"
} else {
result = i18n.translate("error", "Password does not match")
}
break
}
case "user_pending": {
result = i18n.translate("error", "The account is not activated")
break
}
case "user_blocked": {
result = i18n.translate("error", "Account has been disabled")
break
}
case "invalid_status": {
if (error.details !== undefined && error.details.length > 0) {
let s = error.details[0].retry_delay
s = s.substring(0, s.length - 1)
s = parseInt(s)
result =
i18n.translate(
"error",
"The password input error has reached the upper limit and the account will be locked "
) +
(s < 3600
? s / 60 + i18n.translate("error", "minute")
: s / 3600 + i18n.translate("error", "hour"))
} else {
result = i18n.translate(
"error",
"Account has been temporarily locked"
)
}
break
}
case "invalid_two_factor": {
result = i18n.translate(
"error",
"Secondary authentication code does not match or has expired"
)
break
}
case "invalid_two_factor_recovery": {
result = i18n.translate(
"error",
"Recovery code does not match or has expired"
)
break
}
default: {
result = i18n.translate("error", "unknown")
break
}
}
}
}
FAQs
auth apis for cloudbase
The npm package @cloudbase/oauth receives a total of 573 weekly downloads. As such, @cloudbase/oauth popularity was classified as not popular.
We found that @cloudbase/oauth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.