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

@nextcloud/auth

Package Overview
Dependencies
Maintainers
10
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 1.3.0 to 2.0.0

dist/index.esm.js

2

dist/index.d.ts

@@ -0,2 +1,4 @@

export type { CsrfTokenObserver } from './requesttoken';
export type { NextcloudUser } from './user';
export { getRequestToken, onRequestTokenUpdate } from './requesttoken';
export { getCurrentUser } from './user';

76

dist/index.js

@@ -1,28 +0,56 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
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 observers = [];
function getRequestToken() {
return token;
}
function onRequestTokenUpdate(observer) {
observers.push(observer);
}
// Listen to server event and keep token in sync
eventBus.subscribe('csrf-token-update', function (e) {
token = e.token;
observers.forEach(function (observer) {
try {
observer(e.token);
}
catch (e) {
console.error('error updating CSRF token observer', e);
}
});
});
Object.defineProperty(exports, "getRequestToken", {
enumerable: true,
get: function get() {
return _requesttoken.getRequestToken;
}
});
Object.defineProperty(exports, "onRequestTokenUpdate", {
enumerable: true,
get: function get() {
return _requesttoken.onRequestTokenUpdate;
}
});
Object.defineProperty(exports, "getCurrentUser", {
enumerable: true,
get: function get() {
return _user.getCurrentUser;
}
});
var _requesttoken = require("./requesttoken");
/// <reference types="@nextcloud/typings" />
var getAttribute = function (el, attribute) {
if (el) {
return el.getAttribute(attribute);
}
return null;
};
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();
function getCurrentUser() {
if (uid === null) {
return null;
}
return {
uid: uid,
displayName: displayName,
isAdmin: isAdmin,
};
}
var _user = require("./user");
//# sourceMappingURL=index.js.map
exports.getCurrentUser = getCurrentUser;
exports.getRequestToken = getRequestToken;
exports.onRequestTokenUpdate = onRequestTokenUpdate;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

interface CsrfTokenObserver {
export interface CsrfTokenObserver {
(token: string): void;

@@ -6,2 +6,1 @@ }

export declare function onRequestTokenUpdate(observer: CsrfTokenObserver): void;
export {};
{
"name": "@nextcloud/auth",
"version": "1.3.0",
"description": "",
"version": "2.0.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",
"require": "./dist/index.js"
},
"files": [
"dist/"
],
"scripts": {
"build": "babel ./lib --out-dir dist --extensions '.ts,.tsx' --source-maps && tsc --emitDeclarationOnly",
"build:doc": "typedoc --out dist/doc lib && touch dist/doc/.nojekyll",
"check-types": "tsc",
"dev": "babel ./lib --out-dir dist --extensions '.ts,.tsx' --watch",
"build": "rollup --config rollup.config.js",
"build:doc": "typedoc --out dist/doc lib/index.ts && touch dist/doc/.nojekyll",
"check-types": "tsc --noEmit",
"dev": "rollup --config rollup.config.js --watch",
"test": "jest",

@@ -26,21 +34,14 @@ "test:watch": "jest --watchAll"

"dependencies": {
"@nextcloud/event-bus": "^1.1.3",
"@nextcloud/typings": "^0.2.2",
"core-js": "^3.6.4"
"@nextcloud/event-bus": "^3.0.0"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@babel/preset-typescript": "^7.9.0",
"@nextcloud/browserslist-config": "^1.0.0",
"babel-jest": "^26.0.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"jest": "^26.0.1",
"typedoc": "^0.17.3",
"typescript": "^3.8.3"
},
"browserslist": [
"extends @nextcloud/browserslist-config"
]
"@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/auth
Nextcloud helpers related to authentication and the current user
[![npm](https://img.shields.io/npm/v/@nextcloud/auth.svg)](https://www.npmjs.com/package/@nextcloud/auth)
[![Documentation](https://img.shields.io/badge/Documentation-online-brightgreen)](https://nextcloud.github.io/nextcloud-auth/index.html)
## Install
```sh
yarn add @nextcloud/auth
```
```sh
npm install @nextcloud/auth --save
```
## Usage
```ts
import {
getRequestToken,
getCurrentUser,
onRequestTokenUpdate,
} from '@nextcloud/auth'
const user = getCurrentUser()
if (user.isAdmin) {
// do something
}
```
For more imformation check [nextcloud.github.io/nextcloud-auth](https://nextcloud.github.io/nextcloud-auth/index.html)

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