diff --git a/lib/guest.ts b/lib/guest.ts new file mode 100644 index 00000000..0216774f --- /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 a2329c42..3d207389 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -3,3 +3,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 2c39cc1f..a2c5a041 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "2.0.0", "license": "GPL-3.0-or-later", "dependencies": { + "@nextcloud/browser-storage": "^0.4.0", "@nextcloud/event-bus": "^3.0.2" }, "devDependencies": { @@ -954,6 +955,18 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "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/event-bus": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@nextcloud/event-bus/-/event-bus-3.0.2.tgz", @@ -1633,6 +1646,16 @@ "safe-buffer": "~5.1.1" } }, + "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/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -5037,6 +5060,14 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "@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==", + "requires": { + "core-js": "3.37.0" + } + }, "@nextcloud/event-bus": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@nextcloud/event-bus/-/event-bus-3.0.2.tgz", @@ -5577,6 +5608,11 @@ "safe-buffer": "~5.1.1" } }, + "core-js": { + "version": "3.37.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.37.0.tgz", + "integrity": "sha512-fu5vHevQ8ZG4og+LXug8ulUtVxjOcEYvifJr7L5Bfq9GOztVqsKd9/59hUk2ZSbCrS3BqUr3EpaYGIYzq7g3Ug==" + }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", diff --git a/package.json b/package.json index 8cff1970..215223ab 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "url": "https://github.com/nextcloud/nextcloud-auth" }, "dependencies": { + "@nextcloud/browser-storage": "^0.4.0", "@nextcloud/event-bus": "^3.0.2" }, "devDependencies": {