---
name: "updateTempCustom"
mode: "api"
versionRequirements:
  - { name: "@ray-js/lock-sdk", version: "1.0.0" }
title: "updateTempCustom - 更新自定义临时密码的名称和时效配置。"
summary: "更新自定义临时密码的名称和时效配置。注意，当前只支持更新名称和时效配置，且只支持走云端更新。"
---

## updateTempCustom

> [VERSION] @ray-js/lock-sdk >= 1.0.0

### 描述

更新自定义临时密码。

### 参数

`Params`

| 参数 | 类型 | 必填 | 描述 |
| --- | --- | --- | --- |
| `params` | `UpdateTempPasswordParams` | 是 | 更新参数 |

### 返回值

类型: `Promise<boolean>`

无（更新成功后 resolve）

### 错误码

| 错误码 | 错误信息 |
| --- | --- |
| `1031` | 密码名称过长（超过 20 字符） |
| `1032` | 缺少生效时间配置 |
| `1033` | 缺少生效日期 |
| `1034` | 缺少过期日期 |
| `1010` | 生效时间大于过期时间 |
| `1035` | 周重复模式下未传入 weeks |
| `1039` | 云端：时间参数不正确（START_END_DATE_NOT_RIGHT） |

### 引用对象

##### `interface` UpdateTempPasswordParams

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `unlockBindingId` | `string` | 密码 id |
| `name` | `string` | 密码名称，长度不能超过 20 |
| `effective` | `EffectiveConfig` | 密码时效配置 |

##### `interface` EffectiveConfig

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `effectiveDate` | `number` | 生效日（秒级时间戳） |
| `expiredDate` | `number` | 失效日（秒级时间戳） |
| `repeat` | `"none" \| "week"` | 重复策略：无或按周 |
| `weeks` | `Week` | 周重复位图 |
| `effectiveTime` | `number` | 每日生效开始时间，单位：分钟 |
| `expiredTime` | `number` | 每日失效结束时间，单位：分钟 |

##### `type` Week

周重复位图：下标 0–6 对应周日–周六，0 不生效 1 生效

```typescript
export type Week = [
  BitStatus,
  BitStatus,
  BitStatus,
  BitStatus,
  BitStatus,
  BitStatus,
  BitStatus,
];
```


### 示例代码

```ts
import { updateTempCustom } from '@ray-js/lock-sdk';
await updateTempCustom({ id: 'pwd_001', name: '新密码名' });
```
