Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nextcloud/auth

Package Overview
Dependencies
Maintainers
12
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nextcloud/auth - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

dist/doc/.nojekyll

46

dist/index.js
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var eventBus = require('@nextcloud/event-bus');
var tokenElement = document.getElementsByTagName('head')[0];
var token = tokenElement ? tokenElement.getAttribute('data-requesttoken') : null;
var token = undefined;
var observers = [];
/**
* Get current request token
*
* @return {string|null} Current request token or null if not set
*/
function getRequestToken() {
if (token === undefined) {
// Only on first load, try to get token from document
var tokenElement = document === null || document === void 0 ? void 0 : document.getElementsByTagName('head')[0];
token = tokenElement ? tokenElement.getAttribute('data-requesttoken') : null;
}
return token;
}
/**
* Add an observer which is called when the CSRF token changes
*
* @param observer The observer
*/
function onRequestTokenUpdate(observer) {

@@ -36,17 +48,23 @@ observers.push(observer);

};
var head = document.getElementsByTagName('head')[0];
var uid = getAttribute(head, 'data-user');
var displayName = getAttribute(head, 'data-user-displayname');
var isAdmin = (typeof OC === 'undefined')
? false
: OC.isUserAdmin();
var currentUser = undefined;
function getCurrentUser() {
if (uid === null) {
if (currentUser !== undefined) {
return currentUser;
}
var head = document === null || document === void 0 ? void 0 : document.getElementsByTagName('head')[0];
if (!head) {
return null;
}
return {
// No user logged in so cache and return null
var uid = getAttribute(head, 'data-user');
if (uid === null) {
currentUser = null;
return currentUser;
}
currentUser = {
uid: uid,
displayName: displayName,
isAdmin: isAdmin,
displayName: getAttribute(head, 'data-user-displayname'),
isAdmin: (typeof OC === 'undefined') ? false : OC.isUserAdmin(),
};
return currentUser;
}

@@ -53,0 +71,0 @@

export interface CsrfTokenObserver {
(token: string): void;
}
/**
* Get current request token
*
* @return {string|null} Current request token or null if not set
*/
export declare function getRequestToken(): string | null;
/**
* Add an observer which is called when the CSRF token changes
*
* @param observer The observer
*/
export declare function onRequestTokenUpdate(observer: CsrfTokenObserver): void;
export interface NextcloudUser {
uid: String;
displayName: String | null;
isAdmin: Boolean;
uid: string;
displayName: string | null;
isAdmin: boolean;
}
export declare function getCurrentUser(): NextcloudUser | null;
{
"name": "@nextcloud/auth",
"version": "2.0.0",
"version": "2.1.0",
"description": "Nextcloud helpers related to authentication and the current user",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"exports": {
"import": "./dist/index.esm.js",
"types": "./dist/index.d.ts",
"import": "./dist/index.es.mjs",
"require": "./dist/index.js"

@@ -16,6 +16,6 @@ },

"scripts": {
"build": "rollup --config rollup.config.js",
"build": "rollup --config rollup.config.mjs",
"build:doc": "typedoc --out dist/doc lib/index.ts && touch dist/doc/.nojekyll",
"check-types": "tsc --noEmit",
"dev": "rollup --config rollup.config.js --watch",
"dev": "rollup --config rollup.config.mjs --watch",
"test": "jest",

@@ -35,14 +35,18 @@ "test:watch": "jest --watchAll"

"dependencies": {
"@nextcloud/event-bus": "^3.0.0"
"@nextcloud/event-bus": "^3.1.0"
},
"devDependencies": {
"@nextcloud/typings": "^1.4.3",
"@rollup/plugin-typescript": "^8.3.4",
"jest": "^28.1.3",
"jest-environment-jsdom": "^28.1.3",
"rollup": "^2.77.2",
"tslib": "^2.4.0",
"typedoc": "^0.23.10",
"typescript": "^4.7.4"
"@nextcloud/typings": "^1.6.0",
"@rollup/plugin-typescript": "^11.1.1",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"rollup": "^3.22.0",
"tslib": "^2.5.0",
"typedoc": "^0.24.7",
"typescript": "^5.0.4"
},
"engines": {
"node": "^16.0.0",
"npm": "^7.0.0 || ^8.0.0"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc