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

@universal-packages/authentication

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@universal-packages/authentication - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

defaults/extended/SetAuthenticatableUnconfirmedCredential.universal-auth-dynamic.d.ts

2

Authentication.js

@@ -20,3 +20,3 @@ "use strict";

sendMultiFactorInPlace: true,
enableSignUpCorroboration: true,
enableCorroboration: true,
...options.phone

@@ -23,0 +23,0 @@ },

@@ -25,5 +25,5 @@ export declare type ExtensibleUnion<T extends U, U = string | number | symbol> = T | (U & {

enableConfirmation?: boolean;
enableCorroboration?: boolean;
enableMultiFactor?: boolean;
enablePasswordCheck?: boolean;
enableSignUpCorroboration?: boolean;
enableSignUpInvitations?: boolean;

@@ -59,4 +59,6 @@ enforceConfirmation?: boolean;

emailConfirmedAt?: Date;
unconfirmedEmail?: string;
phone?: string;
phoneConfirmedAt?: Date;
unconfirmedPhone?: string;
username?: string;

@@ -266,2 +268,3 @@ failedLogInAttempts?: number;

authenticatable: Authenticatable;
corroborationToken?: string;
credential: string;

@@ -454,2 +457,6 @@ credentialKind: CredentialKind;

};
'set-authenticatable-unconfirmed-credential': {
payload: SetAuthenticatableUnconfirmedCredentialPayload;
result: void;
};
'set-authenticatable-unlocked': {

@@ -459,2 +466,6 @@ payload: SetAuthenticatableUnlockedPayload;

};
'stablish-authenticatable-unconfirmed-credential': {
payload: StablishAuthenticatableUnconfirmedCredentialPayload;
result: void;
};
'validate-attributes': {

@@ -623,5 +634,14 @@ payload: ValidateAttributesPayload;

}
export interface SetAuthenticatableUnconfirmedCredentialPayload {
authenticatable: Authenticatable;
credential: string;
credentialKind: CredentialKind;
}
export interface SetAuthenticatableUnlockedPayload {
authenticatable: Authenticatable;
}
export interface StablishAuthenticatableUnconfirmedCredentialPayload {
authenticatable: Authenticatable;
credentialKind: CredentialKind;
}
export interface ValidateAttributesPayload {

@@ -628,0 +648,0 @@ attributes: AssignableAttributes;

@@ -14,3 +14,3 @@ "use strict";

const credentialKindOptions = authentication.options[credentialKind];
if (credentialKindOptions.enableSignUpCorroboration) {
if (credentialKindOptions.enableCorroboration) {
const oneTimePassword = authentication.performDynamicSync('generate-one-time-password', { concern: 'corroboration', identifier: `${credential}.${credentialKind}` });

@@ -17,0 +17,0 @@ await authentication.performDynamic('send-corroboration', { credential, credentialKind, oneTimePassword });

@@ -27,3 +27,3 @@ "use strict";

}
if (!invitation && credentialKindOptions.enableSignUpCorroboration) {
if (!invitation && credentialKindOptions.enableCorroboration) {
corroboration = authentication.performDynamicSync('decrypt-corroboration-token', { token: corroborationToken });

@@ -30,0 +30,0 @@ if (!corroboration) {

@@ -12,7 +12,32 @@ "use strict";

async perform(payload, authentication) {
const { authenticatable, credential, credentialKind } = payload;
const { authenticatable, corroborationToken, credential, credentialKind } = payload;
const validation = await authentication.performDynamic('validate-attributes', { attributes: { [credentialKind]: credential }, include: [credentialKind] });
if (validation.valid) {
authentication.performDynamicSync('set-authenticatable-attributes', { authenticatable, attributes: { [credentialKind]: credential }, include: [credentialKind] });
const credentialKindOptions = authentication.options[credentialKind];
let corroboration;
if (credentialKindOptions.enableCorroboration) {
corroboration = authentication.performDynamicSync('decrypt-corroboration-token', { token: corroborationToken });
if (!corroboration) {
if (corroborationToken) {
return { status: 'failure', message: 'invalid-corroboration' };
}
return { status: 'failure', message: 'corroboration-required' };
}
}
if (credentialKindOptions.enableConfirmation) {
if (corroboration) {
authentication.performDynamicSync('set-authenticatable-attributes', { authenticatable, attributes: { [credentialKind]: credential }, include: [credentialKind] });
authentication.performDynamicSync('set-authenticatable-confirmed', { authenticatable, credentialKind });
}
else {
authentication.performDynamicSync('set-authenticatable-unconfirmed-credential', { authenticatable, credential, credentialKind });
}
}
else {
authentication.performDynamicSync('set-authenticatable-attributes', { authenticatable, attributes: { [credentialKind]: credential }, include: [credentialKind] });
}
await authentication.performDynamic('save-authenticatable', { authenticatable });
if (credentialKindOptions.enableConfirmation && !corroboration) {
await authentication.performDynamic('request-confirmation', { authenticatable, credentialKind });
}
return { status: 'success', authenticatable };

@@ -19,0 +44,0 @@ }

@@ -15,2 +15,3 @@ "use strict";

const authenticatable = await authentication.performDynamic('authenticatable-from-credential', { credential });
authentication.performDynamicSync('stablish-authenticatable-unconfirmed-credential', { authenticatable, credentialKind });
authentication.performDynamicSync('set-authenticatable-confirmed', { authenticatable, credentialKind });

@@ -17,0 +18,0 @@ await authentication.performDynamic('save-authenticatable', { authenticatable });

{
"name": "@universal-packages/authentication",
"version": "1.2.1",
"version": "1.3.0",
"description": "Dynamic authentication api",

@@ -5,0 +5,0 @@ "author": "David De Anda <david@universal-packages.com> (https://github.com/universal-packages)",

@@ -55,2 +55,4 @@ # Authentication

If true all confirmation behavior will take place, like verifying grace period or if an authenticatable needs to be confirmed to continue log-in.
- **`enableCorroboration`** `Boolean`
If true before signing up the email should be corroborated.
- **`enableMultiFactor`** `Boolean`

@@ -60,4 +62,2 @@ If true, and if the authenticatable has it configured,to complete a log in with email, the authenticatable needs to verify multi-factor.

If true a password will be required at login if the authenticatable has it set.
- **`enableSignUpCorroboration`** `Boolean`
If true before signing up the email should be corroborated.
- **`enableSignUpInvitations`** `Boolean`

@@ -99,3 +99,3 @@ If true an authenticatable can sign up using an invitation as well as sending them.

If true a password will be required at login if the authenticatable has it set.
- **`enableSignUpCorroboration`** `Boolean` `default: true`
- **`enableCorroboration`** `Boolean` `default: true`
If true before signing up the phone should be corroborated.

@@ -169,7 +169,10 @@ - **`enableSignUpInvitations`** `Boolean`

profilePictureUrl
email
emailConfirmedAt
unconfirmedEmail
phone
phoneConfirmedAt
unconfirmedPhone

@@ -465,3 +468,3 @@ username

Validates and updates an authenticatable credential
Validates and updates an authenticatable credential, taking corroboration and confirmation into account.

@@ -473,2 +476,4 @@ ```js

- **`PAYLOAD`** `Object`
- **`authenticatable`** `Authenticatable`
- **`corroborationToken`** `String` `optional`
- **`credential`** `String`

@@ -906,2 +911,10 @@ - **`credentialKind`** `email | phone`

### set-authenticatable-unconfirmed-credential
- **`PAYLOAD`** `Object`
- **`authenticatable`** `Authenticatable`
- **`credential`** `String`
- **`credentialKind`** `email | phone`
- **`RESULT`** `void`
### set-authenticatable-unlocked

@@ -913,2 +926,9 @@

### stablish-authenticatable-unconfirmed-credential
- **`PAYLOAD`** `Object`
- **`authenticatable`** `Authenticatable`
- **`credentialKind`** `email | phone`
- **`RESULT`** `void`
### validate-attributes

@@ -915,0 +935,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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