Skip to content

Commit 4981358

Browse files
committed
Release v1.12.5
Origin-SHA: a3a8e10acb515886af62d6b886a9da23447aead3
1 parent 9a88494 commit 4981358

7 files changed

Lines changed: 493 additions & 76 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# @opensea/cli
22

3+
## 1.12.5
4+
5+
### Patch Changes
6+
7+
- d846160: Use the current OpenSea API endpoints for SIWE login, scoped-token exchange, refresh, revocation, and wallet-link nonces.
8+
- da5181f: Repair the auth directory and auth file permissions whenever the CLI saves credentials. Existing files created with broader permissions are now restricted to the owning user instead of keeping their old mode.
9+
- Updated dependencies [d846160]
10+
- @opensea/sdk@11.4.4
11+
312
## 1.12.4
413

514
### Patch Changes

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opensea/cli",
3-
"version": "1.12.4",
3+
"version": "1.12.5",
44
"type": "module",
55
"description": "OpenSea CLI - Query the OpenSea API from the command line or programmatically",
66
"main": "dist/index.js",
@@ -24,8 +24,8 @@
2424
},
2525
"dependencies": {
2626
"@opensea/api-types": "^0.8.0",
27-
"@opensea/sdk": "^11.4.3",
28-
"@opensea/wallet-adapters": "^0.3.2",
27+
"@opensea/sdk": "^11.4.4",
28+
"@opensea/wallet-adapters": "^0.3.3",
2929
"commander": "^14.0.3",
3030
"zod": "^4.3.6"
3131
},

src/auth/store.ts

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"
1+
import {
2+
chmodSync,
3+
existsSync,
4+
lstatSync,
5+
mkdirSync,
6+
readFileSync,
7+
writeFileSync,
8+
} from "node:fs"
29
import { homedir } from "node:os"
310
import { join } from "node:path"
411
import { z } from "zod"
@@ -9,6 +16,7 @@ import { z } from "zod"
916
export interface StoredToken {
1017
accessToken: string
1118
refreshToken: string
19+
scopedTokenId?: string
1220
expiresAt: string
1321
scopes: string[]
1422
address: string
@@ -27,6 +35,7 @@ const storedTokenSchema = z
2735
.object({
2836
accessToken: z.string().min(1),
2937
refreshToken: z.string().min(1),
38+
scopedTokenId: z.string().min(1).optional(),
3039
expiresAt: z.iso.datetime(),
3140
scopes: z.array(z.string().min(1)),
3241
address: z.string().min(1),
@@ -45,18 +54,25 @@ const AUTH_DIR = join(homedir(), ".opensea")
4554
const AUTH_FILE = join(AUTH_DIR, "auth.json")
4655

4756
function ensureDir(): void {
48-
if (!existsSync(AUTH_DIR)) {
49-
try {
57+
try {
58+
if (!existsSync(AUTH_DIR)) {
5059
mkdirSync(AUTH_DIR, { recursive: true, mode: 0o700 })
51-
} catch (err) {
52-
const msg = err instanceof Error ? err.message : String(err)
53-
throw new Error(`Failed to create auth directory ${AUTH_DIR}: ${msg}`)
5460
}
61+
chmodSync(AUTH_DIR, 0o700)
62+
} catch (err) {
63+
const msg = err instanceof Error ? err.message : String(err)
64+
throw new Error(`Failed to secure auth directory ${AUTH_DIR}: ${msg}`)
5565
}
5666
}
5767

5868
function readStore(): AuthStore {
5969
if (!existsSync(AUTH_FILE)) return { tokens: {} }
70+
if (!lstatSync(AUTH_FILE).isFile()) {
71+
console.warn(
72+
`Warning: ${AUTH_FILE} is not a regular file and was not read.`,
73+
)
74+
return { tokens: {} }
75+
}
6076
try {
6177
const data = readFileSync(AUTH_FILE, "utf-8")
6278
const store = authStoreSchema.parse(JSON.parse(data))
@@ -82,7 +98,16 @@ function readStore(): AuthStore {
8298
function writeStore(store: AuthStore): void {
8399
ensureDir()
84100
try {
101+
if (existsSync(AUTH_FILE)) {
102+
if (!lstatSync(AUTH_FILE).isFile()) {
103+
throw new Error("auth store path is not a regular file")
104+
}
105+
chmodSync(AUTH_FILE, 0o600)
106+
}
85107
writeFileSync(AUTH_FILE, JSON.stringify(store, null, 2), { mode: 0o600 })
108+
// The mode option only applies when writeFileSync creates a file. Repair
109+
// permissions explicitly when an older or user-created auth file exists.
110+
chmodSync(AUTH_FILE, 0o600)
86111
} catch (err) {
87112
const msg = err instanceof Error ? err.message : String(err)
88113
throw new Error(`Failed to write auth store ${AUTH_FILE}: ${msg}`)

0 commit comments

Comments
 (0)