Readonly
URIReadonly
addonGets the ID of the add-on this principal belongs to.
May be called from any thread.
Readonly
addonGets the WebExtensionPolicy of the add-on this principal belongs to.
NOTE: Main-Thread Only.
Readonly
asciiReturns the "host:port" portion of the Principals URI, if any.
May be called from any thread.
Readonly
asciiReturns an ASCII compatible representation of the principals Origin
May be called from any thread.
Readonly
asciiReturns the ASCII Spec from the Principals URI. Might return the empty string, e.g. for the case of a SystemPrincipal or an EpxandedPrincipal.
May be called from any thread.
WARNING: DO NOT USE FOR SECURITY CHECKS. just for logging purposes!
Readonly
baseThe base domain of the principal URI to which this principal pertains (generally the document URI), handling null principals and non-hierarchical schemes correctly.
May be called from any thread.
Readonly
contentThe domain URI to which this principal pertains. This is null unless script successfully sets document.domain to our URI or a superdomain of our URI. Setting this has no effect on the URI. See https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#Changing_origin
The getter may be called from any thread, but may only be set on the main thread.
Readonly
exposableReturns the Pre Path of the Principals URI with user:pass stripped for privacy and spoof prevention
May be called from any thread.
Readonly
exposableReturns the Spec of the Principals URI with user/pass/ref/query stripped for privacy and spoof prevention
May be called from any thread.
Readonly
fileReturns the filePath of the principals uri. See nsIURI.
May be called from any thread.
Readonly
hashReturns a hash value for the principal.
May be called from any thread.
Readonly
hostReturns the "host" portion of the Principals URI, if any.
May be called from any thread.
Readonly
hostReturns the "host:port" portion of the Principals URI, if any.
May be called from any thread.
Readonly
isReturns true iff the principal is either an addon principal or an expanded principal, which contains at least one addon principal.
May be called from any thread.
Readonly
isReturns true iff this principal corresponds to a principal origin.
May be called from any thread.
Readonly
isReturns true iff this is an expanded principal.
May be called from any thread.
Readonly
isReturns true iff the principal is inside an isolated mozbrowser element. xul:browser is not considered to be a mozbrowser element.
Readonly
isReturns if the principal is for an IP address.
May be called from any thread.
Readonly
isReturns if the principal is for a local IP address.
May be called from any thread.
Readonly
isNOTE: Main-Thread Only.
Readonly
isReturns true iff this is a null principal (corresponding to an unknown, hence assumed minimally privileged, security context).
May be called from any thread.
Readonly
isReturns true if the URI is an Onion URI.
May be called from any thread.
Readonly
isImplementation of https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy
The value returned by this method feeds into the the Secure Context algorithm that determins the value of Window.isSecureContext and WorkerGlobalScope.isSecureContext.
This method returns false instead of throwing upon errors.
NOTE: Main-Thread Only.
Readonly
isReturns true if the Domain Policy allows js execution for the Principal's URI
NOTE: Main-Thread Only.
Readonly
isReturns true iff this is the system principal. C++ callers should use IsSystemPrincipal() instead of this scriptable accessor.
May be called from any thread.
Readonly
localReturns a Key for the LocalStorage Manager, used to check the Principals Origin Storage usage.
May be called from any thread.
Readonly
nextReturns a nsIPrincipal, with one less Subdomain Segment
Returns nullptr
if there are no more segments to remove.
May be called from any thread.
Readonly
originA canonical representation of the origin for this principal. This consists of a base string (which, for content principals, is of the format scheme://host:port), concatenated with |originAttributes| (see below).
We maintain the invariant that principalA.equals(principalB) if and only if principalA.origin == principalB.origin.
May be called from any thread.
Readonly
originA dictionary of the non-default origin attributes associated with this nsIPrincipal.
Attributes are tokens that are taken into account when determining whether two principals are same-origin - if any attributes differ, the principals are cross-origin, even if the scheme, host, and port are the same. Attributes should also be considered for all security and bucketing decisions, even those which make non-standard comparisons (like cookies, which ignore scheme, or quotas, which ignore subdomains).
If you're looking for an easy-to-use canonical stringification of the origin attributes, see |originSuffix| below.
Readonly
originThe base part of |origin| without the concatenation with |originSuffix|. This doesn't have the important invariants described above with |origin|, and as such should only be used for legacy situations.
May be called from any thread.
Readonly
originA string of the form ^key1=value1&key2=value2, where each pair represents an attribute with a non-default value. If all attributes have default values, this is the empty string.
The value of .originSuffix is automatically serialized into .origin, so any consumers using that are automatically origin-attribute-aware. Consumers with special requirements must inspect and compare .originSuffix manually.
May be called from any thread.
Readonly
preReturns the prePath of the principals uri follows the format scheme: "scheme://username:password@hostname:portnumber/"
May be called from any thread.
Readonly
precursorIf this principal is a null principal, reconstruct the precursor principal which this null principal was derived from. This may be null, in which case this is not a null principal, there is no known precursor to this null principal, it was created by a privileged context, or there was a bugged origin in the precursor string.
May be called from any thread.
WARNING: Be careful when using this principal, as it is not part of the security properties of the null principal, and should NOT be used to grant a resource with a null principal access to resources from its precursor origin. This is only to be used for places where tracking how null principals were created is necessary.
Readonly
privateGets the id of the private browsing state of the context containing this principal. If the principal has a private browsing value of 0, it is not in private browsing.
May be called from any thread.
Readonly
schemeReturn the scheme of the principals URI
May be called from any thread.
Readonly
siteA canonical representation of the site-origin for this principal. This string has the same format as |origin| (see above). Two principals with differing |siteOrigin| values will never compare equal, even when considering domain mutations.
For most principals, |siteOrigin| matches |origin| precisely. Only principals which allow mutating |domain|, such as ContentPrincipal, override the default implementation in BasePrincipal.
May be called from any thread.
Readonly
siteThe base part of |siteOrigin| without the concatenation with |originSuffix|.
May be called from any thread.
Readonly
specReturns the Spec from the Principals URI. Might return the empty string, e.g. for the case of a SystemPrincipal or an EpxandedPrincipal.
May be called from any thread.
WARNING: Do not land new Code using, as this will be removed soon
Readonly
storageReturns the Key to access the Principals Origin Local/Session Storage
May be called from any thread.
Readonly
userGets the id of the user context this principal is inside. If this principal is inside the default userContext, this returns nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID.
May be called from any thread.
Optional
aInstancePtr: objectA run time mechanism for interface discovery.
NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.
aInstancePtr must not be null.
[in] A requested interface IID
[out] A pointer to an interface pointer to receive the result.
Checks whether this principal is allowed to load the network resource located at the given URI under the same-origin policy. This means that content principals are only allowed to load resources from the same domain, the system principal is allowed to load anything, and null principals can only load URIs where they are the principal. This is changed by the optional flag allowIfInheritsPrincipal (which defaults to false) which allows URIs that inherit their loader's principal.
If the load is allowed this function does nothing. If the load is not allowed the function throws NS_ERROR_DOM_BAD_URI.
NOTE: Other policies might override this, such as the Access-Control specification. NOTE: The 'domain' attribute has no effect on the behaviour of this function. NOTE: Main-Thread Only.
NS_ERROR_DOM_BAD_URI if the load is not allowed.
The URI about to be loaded.
If true, the load is allowed if the loadee inherits the principal of the loader.
Like checkMayLoad, but if returning an error will also report that error to the console, using the provided window id. The window id may be 0 to report to just the browser console, not web consoles.
NOTE: Main-Thread Only.
Returns whether the other principal is equivalent to this principal for permission purposes Matches {originAttributes ,equalsURIForPermission}
May be called from any thread.
Checks if the Principals URI has first party storage access when loaded inside the provided 3rd party resource window. See also: ContentBlocking::ShouldAllowAccessFor
NOTE: Main-Thread Only.
Checks if the provided channel is considered third-party to the URI of the principal. Returns true if the channel is third-party. Returns false if the Principal is a System Principal
NOTE: Main-Thread Only.
The Channel to check
Returns whether the other principal is equal to or weaker than this principal. Principals are equal if they are the same object or they have the same origin.
Thus a principal always subsumes itself.
The system principal subsumes itself and all other principals.
A null principal (corresponding to an unknown, hence assumed minimally privileged, security context) is not equal to any other principal (including other null principals), and therefore does not subsume anything but itself.
May be called from any thread.
Same as the previous method, subsumes(), but takes document.domain into account.
May be called from any thread, though document.domain may racily change during the comparison when called from off-main-thread.
Same as the subsumesConsideringDomain(), but ignores the first party domain in its originAttributes.
May be called from any thread, though document.domain may racily change during the comparison when called from off-main-thread.
Generated using TypeDoc
The principal URI to which this principal pertains. This is generally the document URI.
May be called from any thread.