addPassword(params: AddPasswordParams)

Requires:
@ray-js/lock-sdk≥1.0.0

Description

Add a password-type unlock method.

Parameters

ParameterTypeRequiredDescription
YesParameters for adding a password (password content, name, and validity settings, etc.)

Return Value

Type: Promise<CreateUnlockMethodResult>
None (resolves after added successfully)
CreateUnlockMethodResult
PropertyTypeDescription
opModeIdnumberUnlock method ID
unlockNamestringUnlock method name

Error Code

Error CodeError Message
1054Password is empty
1057Special password not supported and App notifications are disabled
1058SMS is supported, but both App notifications and SMS are disabled
1066SMS phone number is empty
1056Country code is empty
1055Verification code is empty
1014This unlock method type is not supported
1001Device is offline
1002Operation timed out
1015~1025 Device-reported add failure (status 0~10)
1026Device-reported add failure (status 0xfe)
1037Cloud: password already exists (USER_PWD_ALREADY_EXIST)
1038Cloud: password name is duplicate (LOCK_PWD_NAME_REPEAT)
1040Cloud: record does not exist (RECORD_NOT_EXIST)

Examples

import { addPassword } from '@ray-js/lock-sdk';
await addPassword({ password: '123456', userId: 'user_001', name: 'Daily password' });