diff --git a/lib/guest.ts b/lib/guest.ts new file mode 100644 index 0000000..0216774 --- /dev/null +++ b/lib/guest.ts @@ -0,0 +1,18 @@ +import { getBuilder } from '@nextcloud/browser-storage' + +const browserStorage = getBuilder('public').persist().build() + +/** + * Get the guest nickname for public shares + */ +export function getGuestNickname(): string | null { + return browserStorage.getItem('guestNickname') +} + +/** + * Set the guest nickname for public shares + * @param nickname The nickname to set + */ +export function setGuestNickname(nickname: string): void { + browserStorage.setItem('guestNickname', nickname) +} diff --git a/lib/index.ts b/lib/index.ts index da95021..9a6d2bb 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -7,3 +7,4 @@ export type { NextcloudUser } from './user' export { getRequestToken, onRequestTokenUpdate } from './requesttoken' export { getCurrentUser } from './user' +export { getGuestNickname, setGuestNickname } from './guest' diff --git a/package-lock.json b/package-lock.json index 02ac332..0cf87b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "2.3.0", "license": "GPL-3.0-or-later", "dependencies": { + "@nextcloud/browser-storage": "^0.4.0", "@nextcloud/event-bus": "^3.3.1" }, "devDependencies": { @@ -1220,6 +1221,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/@nextcloud/browser-storage": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@nextcloud/browser-storage/-/browser-storage-0.4.0.tgz", + "integrity": "sha512-D6XxznxCYmJ3oBCC3p0JB6GZJ2RZ9dgbB1UqtTePXrIvHUMBAeF/YkiGKYxLAVZCZb+NSNZXgAYHm/3LnIUbDg==", + "dependencies": { + "core-js": "3.37.0" + }, + "engines": { + "node": "^20.0.0", + "npm": "^10.0.0" + } + }, "node_modules/@nextcloud/eslint-config": { "version": "8.4.1", "resolved": "https://registry.npmjs.org/@nextcloud/eslint-config/-/eslint-config-8.4.1.tgz", @@ -3016,6 +3029,16 @@ "dev": true, "peer": true }, + "node_modules/core-js": { + "version": "3.37.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.37.0.tgz", + "integrity": "sha512-fu5vHevQ8ZG4og+LXug8ulUtVxjOcEYvifJr7L5Bfq9GOztVqsKd9/59hUk2ZSbCrS3BqUr3EpaYGIYzq7g3Ug==", + "hasInstallScript": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/core-js-compat": { "version": "3.37.0", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.37.0.tgz", diff --git a/package.json b/package.json index 951fa79..3a23f30 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "url": "https://github.com/nextcloud/nextcloud-auth" }, "dependencies": { + "@nextcloud/browser-storage": "^0.4.0", "@nextcloud/event-bus": "^3.3.1" }, "devDependencies": {