@lit-protocol/auth-helpers
Advanced tools
Comparing version 6.7.0 to 7.0.0-alpha.0
@@ -20,32 +20,35 @@ { | ||
}, | ||
"gitHead": "0d7334c2c55f448e91fe32f29edc5db8f5e09e4b", | ||
"tags": [ | ||
"universal" | ||
], | ||
"browser": { | ||
"crypto": false, | ||
"stream": false | ||
}, | ||
"version": "7.0.0-alpha.0", | ||
"dependencies": { | ||
"@ethersproject/abstract-provider": "5.7.0", | ||
"@ethersproject/contracts": "5.7.0", | ||
"@ethersproject/providers": "5.7.2", | ||
"@ethersproject/providers": "^5.7.2", | ||
"@lit-protocol/accs-schemas": "^0.0.12", | ||
"@lit-protocol/contracts": "^0.0.63", | ||
"@openagenda/verror": "^3.1.4", | ||
"ajv": "^8.12.0", | ||
"bech32": "^2.0.0", | ||
"bs58": "^5.0.0", | ||
"depd": "^2.0.0", | ||
"ethers": "^5.7.1", | ||
"jszip": "^3.10.1", | ||
"siwe": "^2.0.5", | ||
"siwe": "^2.3.2", | ||
"siwe-recap": "0.0.2-alpha.0", | ||
"tslib": "2.6.0", | ||
"util": "0.12.5", | ||
"@lit-protocol/access-control-conditions": "6.7.0", | ||
"@lit-protocol/constants": "6.7.0", | ||
"@lit-protocol/logger": "6.7.0", | ||
"@lit-protocol/misc": "6.7.0", | ||
"@lit-protocol/types": "6.7.0", | ||
"@lit-protocol/uint8arrays": "6.7.0" | ||
"@lit-protocol/access-control-conditions": "7.0.0-alpha.0", | ||
"@lit-protocol/constants": "7.0.0-alpha.0", | ||
"@lit-protocol/logger": "7.0.0-alpha.0", | ||
"@lit-protocol/misc": "7.0.0-alpha.0", | ||
"@lit-protocol/types": "7.0.0-alpha.0", | ||
"@lit-protocol/uint8arrays": "7.0.0-alpha.0", | ||
"tslib": "1.14.1" | ||
}, | ||
"gitHead": "0d7334c2c55f448e91fe32f29edc5db8f5e09e4b", | ||
"tags": [ | ||
"universal" | ||
], | ||
"browser": { | ||
"crypto": false, | ||
"stream": false | ||
}, | ||
"version": "6.7.0", | ||
"main": "./src/index.js" | ||
} |
@@ -19,4 +19,4 @@ import { AuthSig, SignerLike } from '@lit-protocol/types'; | ||
toSign: string; | ||
address?: string | undefined; | ||
algo?: "ed25519" | undefined; | ||
address?: string; | ||
algo?: "ed25519"; | ||
}) => Promise<AuthSig>; |
@@ -1,2 +0,3 @@ | ||
import { SiweMessage } from 'siwe'; | ||
import { LIT_ABILITY_VALUES } from '@lit-protocol/constants'; | ||
import { ILitResource } from '@lit-protocol/types'; | ||
export interface AuthSig { | ||
@@ -8,6 +9,6 @@ sig: any; | ||
} | ||
export declare type PlainJSON = boolean | number | string | { | ||
export type PlainJSON = boolean | number | string | { | ||
[key: string]: PlainJSON; | ||
} | Array<PlainJSON>; | ||
export declare type AttenuationsObject = { | ||
export type AttenuationsObject = { | ||
[key: string]: { | ||
@@ -17,115 +18,4 @@ [key: string]: Array<PlainJSON>; | ||
}; | ||
export declare type CID = string; | ||
export type CID = string; | ||
/** | ||
* These are the user-facing abilities that can be granted to a session. | ||
*/ | ||
export declare enum LitAbility { | ||
/** | ||
* This is the ability to process an encryption access control condition. | ||
* The resource will specify the corresponding hashed key value of the | ||
* access control condition. | ||
*/ | ||
AccessControlConditionDecryption = "access-control-condition-decryption", | ||
/** | ||
* This is the ability to process a signing access control condition. | ||
* The resource will specify the corresponding hashed key value of the | ||
* access control condition. | ||
*/ | ||
AccessControlConditionSigning = "access-control-condition-signing", | ||
/** | ||
* This is the ability to use a PKP for signing purposes. The resource will specify | ||
* the corresponding PKP token ID. | ||
*/ | ||
PKPSigning = "pkp-signing", | ||
/** | ||
* This is the ability to use a Rate Limit Increase (Capacity Credits NFT) token during | ||
* authentication with the nodes. The resource will specify the corresponding | ||
* Capacity Credits NFT token ID. | ||
*/ | ||
RateLimitIncreaseAuth = "rate-limit-increase-auth", | ||
/** | ||
* This is the ability to execute a Lit Action. The resource will specify the | ||
* corresponding Lit Action IPFS CID. | ||
*/ | ||
LitActionExecution = "lit-action-execution" | ||
} | ||
/** | ||
* Prefixes used for identifying various LIT resources. | ||
* | ||
* @description These resource prefixes are also used as valid IRI schemes. | ||
*/ | ||
export declare enum LitResourcePrefix { | ||
AccessControlCondition = "lit-accesscontrolcondition", | ||
PKP = "lit-pkp", | ||
RLI = "lit-ratelimitincrease", | ||
LitAction = "lit-litaction" | ||
} | ||
export interface ISessionCapabilityObject { | ||
get attenuations(): AttenuationsObject; | ||
get proofs(): Array<CID>; | ||
get statement(): string; | ||
addProof(proof: CID): void; | ||
/** | ||
* Add an arbitrary attenuation to the session capability object. | ||
* | ||
* @description We do NOT recommend using this unless with the LIT specific | ||
* abilities. Use this ONLY if you know what you are doing. | ||
*/ | ||
addAttenuation(resource: string, namespace?: string, name?: string, restriction?: { | ||
[key: string]: PlainJSON; | ||
}): void; | ||
addToSiweMessage(siwe: SiweMessage): SiweMessage; | ||
/** | ||
* Encode the session capability object as a SIWE resource. | ||
*/ | ||
encodeAsSiweResource(): string; | ||
/** LIT specific methods */ | ||
/** | ||
* Add a LIT-specific capability to the session capability object for the | ||
* specified resource. | ||
* | ||
* @param litResource The LIT-specific resource being added. | ||
* @param ability The LIT-specific ability being added. | ||
* @example If the ability is `LitAbility.AccessControlConditionDecryption`, | ||
* then the resource should be the hashed key value of the access control | ||
* condition. | ||
* @example If the ability is `LitAbility.AccessControlConditionSigning`, | ||
* then the resource should be the hashed key value of the access control | ||
* condition. | ||
* @example If the ability is `LitAbility.PKPSigning`, then the resource | ||
* should be the PKP token ID. | ||
* @example If the ability is `LitAbility.RateLimitIncreaseAuth`, then the | ||
* resource should be the RLI token ID. | ||
* @example If the ability is `LitAbility.LitActionExecution`, then the | ||
* resource should be the Lit Action IPFS CID. | ||
* @throws If the ability is not a LIT-specific ability. | ||
*/ | ||
addCapabilityForResource(litResource: ILitResource, ability: LitAbility, data?: any): void; | ||
/** | ||
* Verify that the session capability object has the specified LIT-specific | ||
* capability for the specified resource. | ||
*/ | ||
verifyCapabilitiesForResource(litResource: ILitResource, ability: LitAbility): boolean; | ||
/** | ||
* Add a wildcard ability to the session capability object for the specified | ||
* resource. | ||
*/ | ||
addAllCapabilitiesForResource(litResource: ILitResource): void; | ||
} | ||
export interface ILitResource { | ||
/** | ||
* Gets the fully qualified resource key. | ||
* @returns The fully qualified resource key. | ||
*/ | ||
getResourceKey(): string; | ||
/** | ||
* Validates that the given LIT ability is valid for this resource. | ||
* @param litAbility The LIT ability to validate. | ||
*/ | ||
isValidLitAbility(litAbility: LitAbility): boolean; | ||
toString(): string; | ||
readonly resourcePrefix: LitResourcePrefix; | ||
readonly resource: string; | ||
} | ||
/** | ||
* A LIT resource ability is a combination of a LIT resource and a LIT ability. | ||
@@ -139,6 +29,6 @@ * It specifies which LIT specific ability is being requested to be performed | ||
*/ | ||
export declare type LitResourceAbilityRequest = { | ||
export type LitResourceAbilityRequest = { | ||
resource: ILitResource; | ||
ability: LitAbility; | ||
ability: LIT_ABILITY_VALUES; | ||
data?: any; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LitResourcePrefix = exports.LitAbility = void 0; | ||
/** | ||
* These are the user-facing abilities that can be granted to a session. | ||
*/ | ||
var LitAbility; | ||
(function (LitAbility) { | ||
/** | ||
* This is the ability to process an encryption access control condition. | ||
* The resource will specify the corresponding hashed key value of the | ||
* access control condition. | ||
*/ | ||
LitAbility["AccessControlConditionDecryption"] = "access-control-condition-decryption"; | ||
/** | ||
* This is the ability to process a signing access control condition. | ||
* The resource will specify the corresponding hashed key value of the | ||
* access control condition. | ||
*/ | ||
LitAbility["AccessControlConditionSigning"] = "access-control-condition-signing"; | ||
/** | ||
* This is the ability to use a PKP for signing purposes. The resource will specify | ||
* the corresponding PKP token ID. | ||
*/ | ||
LitAbility["PKPSigning"] = "pkp-signing"; | ||
/** | ||
* This is the ability to use a Rate Limit Increase (Capacity Credits NFT) token during | ||
* authentication with the nodes. The resource will specify the corresponding | ||
* Capacity Credits NFT token ID. | ||
*/ | ||
LitAbility["RateLimitIncreaseAuth"] = "rate-limit-increase-auth"; | ||
/** | ||
* This is the ability to execute a Lit Action. The resource will specify the | ||
* corresponding Lit Action IPFS CID. | ||
*/ | ||
LitAbility["LitActionExecution"] = "lit-action-execution"; | ||
})(LitAbility = exports.LitAbility || (exports.LitAbility = {})); | ||
/** | ||
* Prefixes used for identifying various LIT resources. | ||
* | ||
* @description These resource prefixes are also used as valid IRI schemes. | ||
*/ | ||
var LitResourcePrefix; | ||
(function (LitResourcePrefix) { | ||
LitResourcePrefix["AccessControlCondition"] = "lit-accesscontrolcondition"; | ||
LitResourcePrefix["PKP"] = "lit-pkp"; | ||
LitResourcePrefix["RLI"] = "lit-ratelimitincrease"; | ||
LitResourcePrefix["LitAction"] = "lit-litaction"; | ||
})(LitResourcePrefix = exports.LitResourcePrefix || (exports.LitResourcePrefix = {})); | ||
//# sourceMappingURL=models.js.map |
import { SiweMessage } from 'siwe'; | ||
import { AttenuationsObject, CID as CIDString, ILitResource, ISessionCapabilityObject, LitAbility, PlainJSON } from '../models'; | ||
import { LIT_ABILITY_VALUES } from '@lit-protocol/constants'; | ||
import { ILitResource, ISessionCapabilityObject } from '@lit-protocol/types'; | ||
import { AttenuationsObject, CID as CIDString, PlainJSON } from '../models'; | ||
export declare class RecapSessionCapabilityObject implements ISessionCapabilityObject { | ||
@@ -18,4 +20,4 @@ private _inner; | ||
/** LIT specific methods */ | ||
addCapabilityForResource(litResource: ILitResource, ability: LitAbility, data?: any): void; | ||
verifyCapabilitiesForResource(litResource: ILitResource, ability: LitAbility): boolean; | ||
addCapabilityForResource(litResource: ILitResource, ability: LIT_ABILITY_VALUES, data?: any): void; | ||
verifyCapabilitiesForResource(litResource: ILitResource, ability: LIT_ABILITY_VALUES): boolean; | ||
/** | ||
@@ -22,0 +24,0 @@ * Returns the attenuated resource key to match against. This supports matching |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RecapSessionCapabilityObject = void 0; | ||
const tslib_1 = require("tslib"); | ||
const constants_1 = require("@lit-protocol/constants"); | ||
const depd_1 = tslib_1.__importDefault(require("depd")); | ||
const siwe_recap_1 = require("siwe-recap"); | ||
const utils_1 = require("./utils"); | ||
const siwe_helper_1 = require("../siwe/siwe-helper"); | ||
const deprecated = (0, depd_1.default)('lit-js-sdk:auth-recap:session-capability-object'); | ||
class RecapSessionCapabilityObject { | ||
@@ -44,3 +48,8 @@ constructor(att = {}, prf = []) { | ||
if (!litResource.isValidLitAbility(ability)) { | ||
throw new Error(`The specified Lit resource does not support the specified ability.`); | ||
throw new constants_1.InvalidArgumentException({ | ||
info: { | ||
litResource, | ||
ability, | ||
}, | ||
}, `The specified Lit resource does not support the specified ability.`); | ||
} | ||
@@ -47,0 +56,0 @@ const { recapNamespace, recapAbility } = (0, utils_1.getRecapNamespaceAndAbility)(ability); |
@@ -1,2 +0,3 @@ | ||
import { ILitResource, LitAbility } from '../models'; | ||
import { LIT_ABILITY_VALUES } from '@lit-protocol/constants'; | ||
import { ILitResource } from '@lit-protocol/types'; | ||
/** | ||
@@ -58,4 +59,4 @@ * Lit resrouce ability request builder for creating resource ability requests. | ||
resource: ILitResource; | ||
ability: LitAbility; | ||
ability: LIT_ABILITY_VALUES; | ||
}>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ResourceAbilityRequestBuilder = void 0; | ||
const models_1 = require("../models"); | ||
const constants_1 = require("@lit-protocol/constants"); | ||
const resources_1 = require("../resources"); | ||
@@ -36,3 +36,3 @@ /** | ||
resource: new resources_1.LitPKPResource(resourceId), | ||
ability: models_1.LitAbility.PKPSigning, | ||
ability: constants_1.LIT_ABILITY.PKPSigning, | ||
}); | ||
@@ -49,3 +49,3 @@ return this; | ||
resource: new resources_1.LitActionResource(resourceId), | ||
ability: models_1.LitAbility.LitActionExecution, | ||
ability: constants_1.LIT_ABILITY.LitActionExecution, | ||
}); | ||
@@ -62,3 +62,3 @@ return this; | ||
resource: new resources_1.LitAccessControlConditionResource(resourceId), | ||
ability: models_1.LitAbility.AccessControlConditionSigning, | ||
ability: constants_1.LIT_ABILITY.AccessControlConditionSigning, | ||
}); | ||
@@ -75,3 +75,3 @@ return this; | ||
resource: new resources_1.LitAccessControlConditionResource(resourceId), | ||
ability: models_1.LitAbility.AccessControlConditionDecryption, | ||
ability: constants_1.LIT_ABILITY.AccessControlConditionDecryption, | ||
}); | ||
@@ -88,3 +88,3 @@ return this; | ||
resource: new resources_1.LitRLIResource(resourceId), | ||
ability: models_1.LitAbility.RateLimitIncreaseAuth, | ||
ability: constants_1.LIT_ABILITY.RateLimitIncreaseAuth, | ||
}); | ||
@@ -91,0 +91,0 @@ return this; |
@@ -1,2 +0,2 @@ | ||
import { LitAbility } from '../models'; | ||
import { LIT_ABILITY_VALUES, LIT_RECAP_ABILITY_VALUES, LIT_NAMESPACE_VALUES } from '@lit-protocol/constants'; | ||
/** | ||
@@ -6,19 +6,5 @@ * Map from a LitAbility to the Recap namespace and ability. | ||
*/ | ||
export declare function getRecapNamespaceAndAbility(litAbility: LitAbility): { | ||
recapNamespace: LitNamespace; | ||
recapAbility: LitRecapAbility; | ||
export declare function getRecapNamespaceAndAbility(litAbility: LIT_ABILITY_VALUES): { | ||
recapNamespace: LIT_NAMESPACE_VALUES; | ||
recapAbility: LIT_RECAP_ABILITY_VALUES; | ||
}; | ||
/** | ||
* LIT specific abilities mapped into the Recap specific terminology | ||
* of an 'ability'. | ||
*/ | ||
export declare enum LitRecapAbility { | ||
Decryption = "Decryption", | ||
Signing = "Signing", | ||
Auth = "Auth", | ||
Execution = "Execution" | ||
} | ||
export declare enum LitNamespace { | ||
Auth = "Auth", | ||
Threshold = "Threshold" | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LitNamespace = exports.LitRecapAbility = exports.getRecapNamespaceAndAbility = void 0; | ||
const models_1 = require("../models"); | ||
exports.getRecapNamespaceAndAbility = getRecapNamespaceAndAbility; | ||
const constants_1 = require("@lit-protocol/constants"); | ||
/** | ||
@@ -11,48 +11,35 @@ * Map from a LitAbility to the Recap namespace and ability. | ||
switch (litAbility) { | ||
case models_1.LitAbility.AccessControlConditionDecryption: | ||
case constants_1.LIT_ABILITY.AccessControlConditionDecryption: | ||
return { | ||
recapNamespace: LitNamespace.Threshold, | ||
recapAbility: LitRecapAbility.Decryption, | ||
recapNamespace: constants_1.LIT_NAMESPACE.Threshold, | ||
recapAbility: constants_1.LIT_RECAP_ABILITY.Decryption, | ||
}; | ||
case models_1.LitAbility.AccessControlConditionSigning: | ||
case constants_1.LIT_ABILITY.AccessControlConditionSigning: | ||
return { | ||
recapNamespace: LitNamespace.Threshold, | ||
recapAbility: LitRecapAbility.Signing, | ||
recapNamespace: constants_1.LIT_NAMESPACE.Threshold, | ||
recapAbility: constants_1.LIT_RECAP_ABILITY.Signing, | ||
}; | ||
case models_1.LitAbility.PKPSigning: | ||
case constants_1.LIT_ABILITY.PKPSigning: | ||
return { | ||
recapNamespace: LitNamespace.Threshold, | ||
recapAbility: LitRecapAbility.Signing, | ||
recapNamespace: constants_1.LIT_NAMESPACE.Threshold, | ||
recapAbility: constants_1.LIT_RECAP_ABILITY.Signing, | ||
}; | ||
case models_1.LitAbility.RateLimitIncreaseAuth: | ||
case constants_1.LIT_ABILITY.RateLimitIncreaseAuth: | ||
return { | ||
recapNamespace: LitNamespace.Auth, | ||
recapAbility: LitRecapAbility.Auth, | ||
recapNamespace: constants_1.LIT_NAMESPACE.Auth, | ||
recapAbility: constants_1.LIT_RECAP_ABILITY.Auth, | ||
}; | ||
case models_1.LitAbility.LitActionExecution: | ||
case constants_1.LIT_ABILITY.LitActionExecution: | ||
return { | ||
recapNamespace: LitNamespace.Threshold, | ||
recapAbility: LitRecapAbility.Execution, | ||
recapNamespace: constants_1.LIT_NAMESPACE.Threshold, | ||
recapAbility: constants_1.LIT_RECAP_ABILITY.Execution, | ||
}; | ||
default: | ||
throw new Error(`Unknown LitAbility: ${litAbility}`); | ||
throw new constants_1.InvalidArgumentException({ | ||
info: { | ||
litAbility, | ||
}, | ||
}, `Unknown LitAbility`); | ||
} | ||
} | ||
exports.getRecapNamespaceAndAbility = getRecapNamespaceAndAbility; | ||
/** | ||
* LIT specific abilities mapped into the Recap specific terminology | ||
* of an 'ability'. | ||
*/ | ||
var LitRecapAbility; | ||
(function (LitRecapAbility) { | ||
LitRecapAbility["Decryption"] = "Decryption"; | ||
LitRecapAbility["Signing"] = "Signing"; | ||
LitRecapAbility["Auth"] = "Auth"; | ||
LitRecapAbility["Execution"] = "Execution"; | ||
})(LitRecapAbility = exports.LitRecapAbility || (exports.LitRecapAbility = {})); | ||
var LitNamespace; | ||
(function (LitNamespace) { | ||
LitNamespace["Auth"] = "Auth"; | ||
LitNamespace["Threshold"] = "Threshold"; | ||
})(LitNamespace = exports.LitNamespace || (exports.LitNamespace = {})); | ||
//# sourceMappingURL=utils.js.map |
@@ -1,4 +0,5 @@ | ||
import { AccessControlConditions, ILitResource, LitAbility, LitResourcePrefix } from '@lit-protocol/types'; | ||
import { LIT_ABILITY_VALUES, LIT_RESOURCE_PREFIX_VALUES } from '@lit-protocol/constants'; | ||
import { AccessControlConditions, ILitResource } from '@lit-protocol/types'; | ||
declare abstract class LitResourceBase { | ||
abstract resourcePrefix: LitResourcePrefix; | ||
abstract resourcePrefix: LIT_RESOURCE_PREFIX_VALUES; | ||
readonly resource: string; | ||
@@ -10,3 +11,3 @@ constructor(resource: string); | ||
export declare class LitAccessControlConditionResource extends LitResourceBase implements ILitResource { | ||
readonly resourcePrefix = LitResourcePrefix.AccessControlCondition; | ||
readonly resourcePrefix: "lit-accesscontrolcondition"; | ||
/** | ||
@@ -18,3 +19,3 @@ * Creates a new LitAccessControlConditionResource. | ||
constructor(resource: string); | ||
isValidLitAbility(litAbility: LitAbility): boolean; | ||
isValidLitAbility(litAbility: LIT_ABILITY_VALUES): boolean; | ||
/** | ||
@@ -30,3 +31,3 @@ * Composes a resource string by hashing access control conditions and appending a data hash. | ||
export declare class LitPKPResource extends LitResourceBase implements ILitResource { | ||
readonly resourcePrefix = LitResourcePrefix.PKP; | ||
readonly resourcePrefix: "lit-pkp"; | ||
/** | ||
@@ -38,6 +39,6 @@ * Creates a new LitPKPResource. | ||
constructor(resource: string); | ||
isValidLitAbility(litAbility: LitAbility): boolean; | ||
isValidLitAbility(litAbility: LIT_ABILITY_VALUES): boolean; | ||
} | ||
export declare class LitRLIResource extends LitResourceBase implements ILitResource { | ||
readonly resourcePrefix = LitResourcePrefix.RLI; | ||
readonly resourcePrefix: "lit-ratelimitincrease"; | ||
/** | ||
@@ -49,6 +50,6 @@ * Creates a new LitRLIResource. | ||
constructor(resource: string); | ||
isValidLitAbility(litAbility: LitAbility): boolean; | ||
isValidLitAbility(litAbility: LIT_ABILITY_VALUES): boolean; | ||
} | ||
export declare class LitActionResource extends LitResourceBase implements ILitResource { | ||
readonly resourcePrefix = LitResourcePrefix.LitAction; | ||
readonly resourcePrefix: "lit-litaction"; | ||
/** | ||
@@ -60,5 +61,5 @@ * Creates a new LitActionResource. | ||
constructor(resource: string); | ||
isValidLitAbility(litAbility: LitAbility): boolean; | ||
isValidLitAbility(litAbility: LIT_ABILITY_VALUES): boolean; | ||
} | ||
export declare function parseLitResource(resourceKey: string): ILitResource; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseLitResource = exports.LitActionResource = exports.LitRLIResource = exports.LitPKPResource = exports.LitAccessControlConditionResource = void 0; | ||
const types_1 = require("@lit-protocol/types"); | ||
exports.LitActionResource = exports.LitRLIResource = exports.LitPKPResource = exports.LitAccessControlConditionResource = void 0; | ||
exports.parseLitResource = parseLitResource; | ||
const access_control_conditions_1 = require("@lit-protocol/access-control-conditions"); | ||
const constants_1 = require("@lit-protocol/constants"); | ||
const uint8arrays_1 = require("@lit-protocol/uint8arrays"); | ||
@@ -27,7 +28,7 @@ const utils_1 = require("./utils"); | ||
super(resource); | ||
this.resourcePrefix = types_1.LitResourcePrefix.AccessControlCondition; | ||
this.resourcePrefix = constants_1.LIT_RESOURCE_PREFIX.AccessControlCondition; | ||
} | ||
isValidLitAbility(litAbility) { | ||
return (litAbility === types_1.LitAbility.AccessControlConditionDecryption || | ||
litAbility === types_1.LitAbility.AccessControlConditionSigning); | ||
return (litAbility === constants_1.LIT_ABILITY.AccessControlConditionDecryption || | ||
litAbility === constants_1.LIT_ABILITY.AccessControlConditionSigning); | ||
} | ||
@@ -43,3 +44,8 @@ /** | ||
if (!accs || !dataToEncryptHash) { | ||
throw new Error('Invalid input: Access control conditions and data hash are required.'); | ||
throw new constants_1.InvalidArgumentException({ | ||
info: { | ||
accs, | ||
dataToEncryptHash, | ||
}, | ||
}, 'Invalid input: Access control conditions and data hash are required.'); | ||
} | ||
@@ -62,6 +68,6 @@ const hashedAccs = await (0, access_control_conditions_1.hashAccessControlConditions)(accs); | ||
super(fixedResource); | ||
this.resourcePrefix = types_1.LitResourcePrefix.PKP; | ||
this.resourcePrefix = constants_1.LIT_RESOURCE_PREFIX.PKP; | ||
} | ||
isValidLitAbility(litAbility) { | ||
return litAbility === types_1.LitAbility.PKPSigning; | ||
return litAbility === constants_1.LIT_ABILITY.PKPSigning; | ||
} | ||
@@ -78,6 +84,6 @@ } | ||
super(resource); | ||
this.resourcePrefix = types_1.LitResourcePrefix.RLI; | ||
this.resourcePrefix = constants_1.LIT_RESOURCE_PREFIX.RLI; | ||
} | ||
isValidLitAbility(litAbility) { | ||
return litAbility === types_1.LitAbility.RateLimitIncreaseAuth; | ||
return litAbility === constants_1.LIT_ABILITY.RateLimitIncreaseAuth; | ||
} | ||
@@ -94,6 +100,6 @@ } | ||
super(resource); | ||
this.resourcePrefix = types_1.LitResourcePrefix.LitAction; | ||
this.resourcePrefix = constants_1.LIT_RESOURCE_PREFIX.LitAction; | ||
} | ||
isValidLitAbility(litAbility) { | ||
return litAbility === types_1.LitAbility.LitActionExecution; | ||
return litAbility === constants_1.LIT_ABILITY.LitActionExecution; | ||
} | ||
@@ -103,17 +109,20 @@ } | ||
function parseLitResource(resourceKey) { | ||
if (resourceKey.startsWith(types_1.LitResourcePrefix.AccessControlCondition)) { | ||
return new LitAccessControlConditionResource(resourceKey.substring(`${types_1.LitResourcePrefix.AccessControlCondition}://`.length)); | ||
if (resourceKey.startsWith(constants_1.LIT_RESOURCE_PREFIX.AccessControlCondition)) { | ||
return new LitAccessControlConditionResource(resourceKey.substring(`${constants_1.LIT_RESOURCE_PREFIX.AccessControlCondition}://`.length)); | ||
} | ||
else if (resourceKey.startsWith(types_1.LitResourcePrefix.PKP)) { | ||
return new LitPKPResource(resourceKey.substring(`${types_1.LitResourcePrefix.PKP}://`.length)); | ||
else if (resourceKey.startsWith(constants_1.LIT_RESOURCE_PREFIX.PKP)) { | ||
return new LitPKPResource(resourceKey.substring(`${constants_1.LIT_RESOURCE_PREFIX.PKP}://`.length)); | ||
} | ||
else if (resourceKey.startsWith(types_1.LitResourcePrefix.RLI)) { | ||
return new LitRLIResource(resourceKey.substring(`${types_1.LitResourcePrefix.RLI}://`.length)); | ||
else if (resourceKey.startsWith(constants_1.LIT_RESOURCE_PREFIX.RLI)) { | ||
return new LitRLIResource(resourceKey.substring(`${constants_1.LIT_RESOURCE_PREFIX.RLI}://`.length)); | ||
} | ||
else if (resourceKey.startsWith(types_1.LitResourcePrefix.LitAction)) { | ||
return new LitActionResource(resourceKey.substring(`${types_1.LitResourcePrefix.LitAction}://`.length)); | ||
else if (resourceKey.startsWith(constants_1.LIT_RESOURCE_PREFIX.LitAction)) { | ||
return new LitActionResource(resourceKey.substring(`${constants_1.LIT_RESOURCE_PREFIX.LitAction}://`.length)); | ||
} | ||
throw new Error(`Invalid resource prefix: ${resourceKey}`); | ||
throw new constants_1.InvalidArgumentException({ | ||
info: { | ||
resourceKey, | ||
}, | ||
}, `Invalid resource prefix`); | ||
} | ||
exports.parseLitResource = parseLitResource; | ||
//# sourceMappingURL=resources.js.map |
import { SiweMessage } from 'siwe'; | ||
import { AttenuationsObject, CID, ISessionCapabilityObject } from './models'; | ||
import { ISessionCapabilityObject } from '@lit-protocol/types'; | ||
import { AttenuationsObject, CID } from './models'; | ||
/** | ||
@@ -4,0 +5,0 @@ * |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extract = exports.decode = exports.newSessionCapabilityObject = void 0; | ||
exports.newSessionCapabilityObject = newSessionCapabilityObject; | ||
exports.decode = decode; | ||
exports.extract = extract; | ||
const recap_session_capability_object_1 = require("./recap/recap-session-capability-object"); | ||
@@ -22,11 +24,8 @@ /** | ||
} | ||
exports.newSessionCapabilityObject = newSessionCapabilityObject; | ||
function decode(encoded) { | ||
return recap_session_capability_object_1.RecapSessionCapabilityObject.decode(encoded); | ||
} | ||
exports.decode = decode; | ||
function extract(siwe) { | ||
return recap_session_capability_object_1.RecapSessionCapabilityObject.extract(siwe); | ||
} | ||
exports.extract = extract; | ||
//# sourceMappingURL=session-capability-object.js.map |
@@ -1,3 +0,2 @@ | ||
import { BaseSiweMessage } from '@lit-protocol/types'; | ||
import { WithCapacityDelegation, WithRecap } from '@lit-protocol/types'; | ||
import { BaseSiweMessage, WithCapacityDelegation, WithRecap } from '@lit-protocol/types'; | ||
/** | ||
@@ -4,0 +3,0 @@ * Creates a SIWE |
@@ -5,3 +5,3 @@ "use strict"; | ||
const siwe_1 = require("siwe"); | ||
const types_1 = require("@lit-protocol/types"); | ||
const constants_1 = require("@lit-protocol/constants"); | ||
const resources_1 = require("../resources"); | ||
@@ -21,3 +21,3 @@ const siwe_helper_1 = require("./siwe-helper"); | ||
const ONE_WEEK_FROM_NOW = new Date(Date.now() + 1000 * 60 * 60 * 24 * 7).toISOString(); | ||
let siweParams = { | ||
const siweParams = { | ||
domain: params?.domain ?? 'localhost', | ||
@@ -45,3 +45,3 @@ address: params.walletAddress, | ||
resource: new resources_1.LitRLIResource(ccParams.capacityTokenId ?? '*'), | ||
ability: types_1.LitAbility.RateLimitIncreaseAuth, | ||
ability: constants_1.LIT_ABILITY.RateLimitIncreaseAuth, | ||
data: capabilities, | ||
@@ -48,0 +48,0 @@ }, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.addRecapToSiweMessage = exports.createCapacityCreditsResourceData = exports.sanitizeSiweMessage = void 0; | ||
exports.addRecapToSiweMessage = exports.createCapacityCreditsResourceData = void 0; | ||
exports.sanitizeSiweMessage = sanitizeSiweMessage; | ||
/** | ||
@@ -15,3 +16,2 @@ * Sanitizes a SIWE message by unescaping double-escaped newlines and replacing escaped double quotes with single quotes. | ||
} | ||
exports.sanitizeSiweMessage = sanitizeSiweMessage; | ||
/** | ||
@@ -24,3 +24,3 @@ * Creates the resource data for a capacity delegation request. | ||
return { | ||
...(params.capacityTokenId ? { nft_id: [params.capacityTokenId] } : {}), | ||
...(params.capacityTokenId ? { nft_id: [params.capacityTokenId] } : {}), // Conditionally include nft_id | ||
...(params.delegateeAddresses | ||
@@ -27,0 +27,0 @@ ? { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.formatPKPResource = void 0; | ||
exports.formatPKPResource = formatPKPResource; | ||
/** | ||
@@ -40,3 +40,2 @@ * Formats the resource ID to a 32-byte hex string. | ||
} | ||
exports.formatPKPResource = formatPKPResource; | ||
//# sourceMappingURL=utils.js.map |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
181
57903
21
961
1
+ Added@openagenda/verror@^3.1.4
+ Addedbech32@^2.0.0
+ Addedbs58@^5.0.0
+ Addeddepd@^2.0.0
+ Added@lit-protocol/access-control-conditions@7.0.0-alpha.0(transitive)
+ Added@lit-protocol/constants@7.0.0-alpha.0(transitive)
+ Added@lit-protocol/logger@7.0.0-alpha.0(transitive)
+ Added@lit-protocol/misc@7.0.0-alpha.0(transitive)
+ Added@lit-protocol/types@7.0.0-alpha.0(transitive)
+ Added@lit-protocol/uint8arrays@7.0.0-alpha.0(transitive)
+ Added@openagenda/verror@3.1.4(transitive)
+ Addedassertion-error@1.1.0(transitive)
+ Addedbase-x@4.0.0(transitive)
+ Addedbech32@2.0.0(transitive)
+ Addedbs58@5.0.0(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addedsprintf-js@1.1.3(transitive)
- Removedjszip@^3.10.1
- Removed@lit-protocol/access-control-conditions@6.7.0(transitive)
- Removed@lit-protocol/constants@6.7.0(transitive)
- Removed@lit-protocol/logger@6.7.0(transitive)
- Removed@lit-protocol/misc@6.7.0(transitive)
- Removed@lit-protocol/types@6.7.0(transitive)
- Removed@lit-protocol/uint8arrays@6.7.0(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedimmediate@3.0.6(transitive)
- Removedisarray@1.0.0(transitive)
- Removedjszip@3.10.1(transitive)
- Removedlie@3.3.0(transitive)
- Removedpako@1.0.11(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedtslib@2.6.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updated@lit-protocol/access-control-conditions@7.0.0-alpha.0
Updatedsiwe@^2.3.2
Updatedtslib@1.14.1